From a5eeb65bf56b02cd6f6ff40c60d6b268db0359c6 Mon Sep 17 00:00:00 2001 From: Izel Nakri Date: Wed, 11 Mar 2020 07:22:01 +0100 Subject: [PATCH 1/8] low CI risk packages updated --- package-lock.json | 106 +++++++++++++++++++++++----------------------- package.json | 16 +++---- 2 files changed, 61 insertions(+), 61 deletions(-) diff --git a/package-lock.json b/package-lock.json index 38482f86..e8f40d2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -869,9 +869,9 @@ } }, "@babel/plugin-transform-typescript": { - "version": "7.8.3", - "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.8.3.tgz", - "integrity": "sha512-Ebj230AxcrKGZPKIp4g4TdQLrqX95TobLUWKd/CwG7X1XHUH1ZpkpFvXuXqWbtGRWb7uuEWNlrl681wsOArAdQ==", + "version": "7.8.7", + "resolved": "https://registry.npmjs.org/@babel/plugin-transform-typescript/-/plugin-transform-typescript-7.8.7.tgz", + "integrity": "sha512-7O0UsPQVNKqpHeHLpfvOG4uXmlw+MOxYvUv6Otc9uH5SYMIxvF6eBdjkWvC3f9G+VXe0RsNExyAQBeTRug/wqQ==", "requires": { "@babel/helper-create-class-features-plugin": "^7.8.3", "@babel/helper-plugin-utils": "^7.8.3", @@ -1787,32 +1787,32 @@ "integrity": "sha512-Lja2xYuuf2B3knEsga8ShbOdsfNOtzT73GyJmZyY7eGl2+ajOqrs8yM5ze0fsSoYwvA6bw7/Qr7OZ7PEEmYwWg==" }, "@typescript-eslint/experimental-utils": { - "version": "2.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.21.0.tgz", - "integrity": "sha512-olKw9JP/XUkav4lq0I7S1mhGgONJF9rHNhKFn9wJlpfRVjNo3PPjSvybxEldvCXnvD+WAshSzqH5cEjPp9CsBA==", + "version": "2.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/experimental-utils/-/experimental-utils-2.23.0.tgz", + "integrity": "sha512-OswxY59RcXH3NNPmq+4Kis2CYZPurRU6mG5xPcn24CjFyfdVli5mySwZz/g/xDbJXgDsYqNGq7enV0IziWGXVQ==", "dev": true, "requires": { "@types/json-schema": "^7.0.3", - "@typescript-eslint/typescript-estree": "2.21.0", + "@typescript-eslint/typescript-estree": "2.23.0", "eslint-scope": "^5.0.0" } }, "@typescript-eslint/parser": { - "version": "2.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.21.0.tgz", - "integrity": "sha512-VrmbdrrrvvI6cPPOG7uOgGUFXNYTiSbnRq8ZMyuGa4+qmXJXVLEEz78hKuqupvkpwJQNk1Ucz1TenrRP90gmBg==", + "version": "2.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-2.23.0.tgz", + "integrity": "sha512-k61pn/Nepk43qa1oLMiyqApC6x5eP5ddPz6VUYXCAuXxbmRLqkPYzkFRKl42ltxzB2luvejlVncrEpflgQoSUg==", "dev": true, "requires": { "@types/eslint-visitor-keys": "^1.0.0", - "@typescript-eslint/experimental-utils": "2.21.0", - "@typescript-eslint/typescript-estree": "2.21.0", + "@typescript-eslint/experimental-utils": "2.23.0", + "@typescript-eslint/typescript-estree": "2.23.0", "eslint-visitor-keys": "^1.1.0" } }, "@typescript-eslint/typescript-estree": { - "version": "2.21.0", - "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.21.0.tgz", - "integrity": "sha512-NC/nogZNb9IK2MEFQqyDBAciOT8Lp8O3KgAfvHx2Skx6WBo+KmDqlU3R9KxHONaijfTIKtojRe3SZQyMjr3wBw==", + "version": "2.23.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-2.23.0.tgz", + "integrity": "sha512-pmf7IlmvXdlEXvE/JWNNJpEvwBV59wtJqA8MLAxMKLXNKVRC3HZBXR/SlZLPWTCcwOSg9IM7GeRSV3SIerGVqw==", "dev": true, "requires": { "debug": "^4.1.1", @@ -2251,9 +2251,9 @@ "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" }, "ava": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/ava/-/ava-3.4.0.tgz", - "integrity": "sha512-Y32CkzR8mrAmn0A9sWhq36kc9GR4eunZ4LZYoFi1VImhNfRh2zmI+8RcNdL/SYdQI1wIklK08rvDdCI58YQQEA==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/ava/-/ava-3.5.0.tgz", + "integrity": "sha512-o+xq1RgAZrQ7GX5nddTNeYbUDogwlBoa/Hnt+b1ciCLLxSOj5U6ZFblLNBSKwHtP1X/8R06bmzvX47jmlVu9KQ==", "dev": true, "requires": { "@concordance/react": "^2.0.0", @@ -6628,9 +6628,9 @@ } }, "eslint-plugin-ember": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/eslint-plugin-ember/-/eslint-plugin-ember-7.8.1.tgz", - "integrity": "sha512-74Whm5MHV+llWv0LA/4b4IaLQxMTj5Jc1zoK11gYEPQbPIAviTF4JsRuzPM/x7QMo5pQZyTdfGYF5zVMbgQ2RA==", + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/eslint-plugin-ember/-/eslint-plugin-ember-7.10.1.tgz", + "integrity": "sha512-3iOrcUsqZXsri6krYw+8fEH20Es8A2QEkog8fCw/Ldr54SR2/IEO41F7ldOrr0X3h8w9z1W1/v97IlMiGJhXkg==", "requires": { "@ember-data/rfc395-data": "^0.0.4", "ember-rfc176-data": "^0.3.12", @@ -7182,12 +7182,12 @@ } }, "fastq": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.0.tgz", - "integrity": "sha512-jmxqQ3Z/nXoeyDmWAzF9kH1aGZSis6e/SbfPmJpUnyZ0ogr6iscHQaml4wsEepEWSdtmpy+eVXmCRIMpxaXqOA==", + "version": "1.6.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.6.1.tgz", + "integrity": "sha512-mpIH5sKYueh3YyeJwqtVo8sORi0CgtmkVbK6kZStpQlZBYQuTzG2CZ7idSiJuA7bY0SFCWUc5WIs+oYumGCQNw==", "dev": true, "requires": { - "reusify": "^1.0.0" + "reusify": "^1.0.4" } }, "fd-slicer": { @@ -7731,9 +7731,9 @@ } }, "hosted-git-info": { - "version": "2.8.5", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.5.tgz", - "integrity": "sha512-kssjab8CvdXfcXMXVcvsXum4Hwdq9XGtRD3TteMEvEbq0LXyiNQr6AprqKqfeaDXze7SxWvRxdpwE6ku7ikLkg==", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", "dev": true }, "html-encoding-sniffer": { @@ -7775,9 +7775,9 @@ } }, "http-cache-semantics": { - "version": "4.0.4", - "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.0.4.tgz", - "integrity": "sha512-Z2EICWNJou7Tr9Bd2M2UqDJq3A9F2ePG9w3lIpjoyuSyXFP9QbniJVu3XQYytuw5ebmG7dXSXO9PgAjJG8DDKA==", + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.0.tgz", + "integrity": "sha512-carPklcUh7ROWRK7Cv27RPtdhYhUsela/ue5/jKzjegVvXDqM2ILE9Q2BGn9JZJh1g87cp56su/FgQSzcWS8cQ==", "dev": true }, "http-errors": { @@ -9812,9 +9812,9 @@ } }, "pretty-ms": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-6.0.0.tgz", - "integrity": "sha512-X5i1y9/8VuBMb9WU8zubTiLKnJG4lcKvL7eaCEVc/jpTe3aS74gCcBM6Yd1vvUDoTCXm4Y15obNS/16yB0FTaQ==", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/pretty-ms/-/pretty-ms-6.0.1.tgz", + "integrity": "sha512-ke4njoVmlotekHlHyCZ3wI/c5AMT8peuHs8rKJqekj/oR5G8lND2dVpicFlUz5cbZgE290vvkMuDwfj/OcW1kw==", "dev": true, "requires": { "parse-ms": "^2.1.0" @@ -10504,9 +10504,9 @@ "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, "sass": { - "version": "1.26.1", - "resolved": "https://registry.npmjs.org/sass/-/sass-1.26.1.tgz", - "integrity": "sha512-DWtzW0jDu+96MYkEdM8vUigjpisvM9qSlDwNvTFcr+XC7o2+3aXSAbHNcJ+8HzD1857uW9Opbxgu39esytVUKA==", + "version": "1.26.2", + "resolved": "https://registry.npmjs.org/sass/-/sass-1.26.2.tgz", + "integrity": "sha512-9TRp1d1NH0mWH8rqaR/jCS05f/TFD1ykPF2zSYviprMhLb0EmXVqtKMUHsvDt3YIT/jbSK6qAvUlfCW/HJkdCw==", "requires": { "chokidar": ">=2.0.0 <4.0.0" } @@ -11473,9 +11473,9 @@ } }, "typescript": { - "version": "3.8.2", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.2.tgz", - "integrity": "sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==", + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.8.3.tgz", + "integrity": "sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==", "dev": true }, "umd": { @@ -11892,9 +11892,9 @@ } }, "write-file-atomic": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.1.tgz", - "integrity": "sha512-JPStrIyyVJ6oCSz/691fAjFtefZ6q+fP6tm+OS4Qw6o+TGQxNp1ziY2PgS+X/m0V8OWhZiO/m4xSj+Pr4RrZvw==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", "dev": true, "requires": { "imurmurhash": "^0.1.4", @@ -11904,9 +11904,9 @@ } }, "ws": { - "version": "7.2.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.1.tgz", - "integrity": "sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A==" + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/ws/-/ws-7.2.3.tgz", + "integrity": "sha512-HTDl9G9hbkNDk98naoR/cHDws7+EyYMOdL1BmjsZXRUjf7d+MficC4B7HLUPlSiho0vg+CWKrGIt/VJBd1xunQ==" }, "xdg-basedir": { "version": "4.0.0", @@ -11936,9 +11936,9 @@ "dev": true }, "yargs": { - "version": "15.1.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.1.0.tgz", - "integrity": "sha512-T39FNN1b6hCW4SOIk1XyTOWxtXdcen0t+XYrysQmChzSipvhBO8Bj0nK1ozAasdk24dNWuMZvr4k24nz+8HHLg==", + "version": "15.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.0.tgz", + "integrity": "sha512-g/QCnmjgOl1YJjGsnUg2SatC7NUYEiLXJqxNOQU9qSpjzGtGXda9b+OKccr1kLTy8BN9yqEyqfq5lxlwdc13TA==", "dev": true, "requires": { "cliui": "^6.0.0", @@ -11951,7 +11951,7 @@ "string-width": "^4.2.0", "which-module": "^2.0.0", "y18n": "^4.0.0", - "yargs-parser": "^16.1.0" + "yargs-parser": "^18.1.0" }, "dependencies": { "find-up": { @@ -12006,9 +12006,9 @@ } }, "yargs-parser": { - "version": "16.1.0", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-16.1.0.tgz", - "integrity": "sha512-H/V41UNZQPkUMIT5h5hiwg4QKIY1RPvoBV4XcjUbRM8Bk2oKqqyZ0DIEbTFZB0XjbtSPG8SAa/0DxCQmiRgzKg==", + "version": "18.1.0", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.0.tgz", + "integrity": "sha512-o/Jr6JBOv6Yx3pL+5naWSoIA2jJ+ZkMYQG/ie9qFbukBe4uzmBatlXFOiu/tNKRWEtyf+n5w7jc/O16ufqOTdQ==", "dev": true, "requires": { "camelcase": "^5.0.0", diff --git a/package.json b/package.json index ace3a54b..45440b92 100644 --- a/package.json +++ b/package.json @@ -36,7 +36,7 @@ "@ember/test-helpers": "1.7.1", "@glimmer/di": "^0.2.1", "@glimmer/resolver": "^0.4.3", - "ava": "^3.3.0", + "ava": "^3.5.0", "cors": "^2.8.5", "ember-cli-fastboot": "2.2.1", "ember-cli-test-loader": "^3.0.0", @@ -54,8 +54,8 @@ "qunit": "2.9.3", "strip-ansi": "^6.0.0", "whatwg-fetch": "^3.0.0", - "@typescript-eslint/parser": "2.21.0", - "typescript": "^3.7.5" + "@typescript-eslint/parser": "2.23.0", + "typescript": "^3.8.3" }, "repository": { "type": "git", @@ -66,7 +66,7 @@ "@babel/plugin-proposal-class-properties": "^7.8.3", "@babel/plugin-proposal-decorators": "^7.8.3", "@babel/plugin-transform-modules-amd": "^7.8.3", - "@babel/plugin-transform-typescript": "^7.8.3", + "@babel/plugin-transform-typescript": "^7.8.7", "@babel/preset-env": "^7.8.4", "@ember-data/canary-features": "^3.16.0", "@ember/ordered-set": "^2.0.3", @@ -75,7 +75,7 @@ "abortcontroller-polyfill": "^1.4.0", "amd-name-resolver": "^1.3.1", "ansi-colors": "^4.1.1", - "babel-eslint": "^10.0.3", + "babel-eslint": "^10.1.0", "babel-plugin-debug-macros": "^0.3.2", "babel-plugin-ember-modules-api-polyfill": "^2.9.0", "babel-plugin-filter-imports": "^4.0.0", @@ -88,7 +88,7 @@ "chokidar": "^3.3.1", "compression": "^1.7.3", "eslint": "^6.8.0", - "eslint-plugin-ember": "^7.8.1", + "eslint-plugin-ember": "^7.10.1", "express": "^4.17.1", "fastboot": "^3.0.0", "fs-extra": "^8.1.0", @@ -100,11 +100,11 @@ "node-fetch": "^2.6.0", "ora": "^4.0.2", "puppeteer": "2.1.1", - "sass": "1.26.1", + "sass": "1.26.2", "say": "^0.16.0", "terser": "4.6.3", "through2": "^3.0.0", - "ws": "^7.2.1" + "ws": "^7.2.3" }, "ava": { "nodeArguments": [ From a671402e6fcf46c1f7a555a81618d4bcdb4ab874 Mon Sep 17 00:00:00 2001 From: Izel Nakri Date: Wed, 11 Mar 2020 07:24:38 +0100 Subject: [PATCH 2/8] additional packages upgraded --- package-lock.json | 138 ++++++++++++++++++++++++++++++++-------------- package.json | 4 +- 2 files changed, 99 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index e8f40d2f..3e6cd89d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1866,23 +1866,23 @@ "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==" }, "acorn-globals": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.3.4.tgz", - "integrity": "sha512-clfQEh21R+D0leSbUdWf3OcfqyaCSAQ8Ryq00bofSekfr9W8u1jyYZo6ir0xu9Gtcf7BjcHJpnbZH7JOCpP60A==", + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-6.0.0.tgz", + "integrity": "sha512-ZQl7LOWaF5ePqqcX4hLuv/bLXYQNfNWw2c0/yX/TsPRKamzHcTGQnlCjHT3TsmkOUVEPS3crCxiPfdzE/Trlhg==", "requires": { - "acorn": "^6.0.1", - "acorn-walk": "^6.0.1" + "acorn": "^7.1.1", + "acorn-walk": "^7.1.1" }, "dependencies": { "acorn": { - "version": "6.4.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-6.4.0.tgz", - "integrity": "sha512-gac8OEcQ2Li1dxIEWGZzsp2BitJxwkwcOm0zHAJLcPJaVvm58FRnk6RkuLRpU1EujipU2ZFODv2P9DLMfnV8mw==" + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==" }, "acorn-walk": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-6.2.0.tgz", - "integrity": "sha512-7evsyfH1cLOCdAzZAd43Cic04yKydNx0cF+7tiA19p1XnLLPU4dpCQOqpjqwokFe//vS0QqfqqjCS2JkiIs0cA==" + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-7.1.1.tgz", + "integrity": "sha512-wdlPY2tm/9XBr7QkKlq0WQVgiuGTX6YWPyRyBviSoScBuLfTVQhvwg6wJ369GJ/1nPfTLMfnrFIfjqVg6d+jQQ==" } } }, @@ -3865,9 +3865,9 @@ } }, "browser-process-hrtime": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-0.1.3.tgz", - "integrity": "sha512-bRFnI4NnjO6cnyLmOV/7PVoDEMJChlcfN0z4s1YMBY989/SvlfMI1lgCnkFUs53e9gQF+w7qu7XdllSTiSl8Aw==" + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/browser-process-hrtime/-/browser-process-hrtime-1.0.0.tgz", + "integrity": "sha512-9o5UecI3GhkpM6DrXr69PblIuWxPKk9Y0jHBRhdocZ2y7YECBFCsHm79Pr3OyR2AvjhDkabFJaDJMYRazHgsow==" }, "browser-resolve": { "version": "1.11.3", @@ -7737,9 +7737,9 @@ "dev": true }, "html-encoding-sniffer": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.0.tgz", - "integrity": "sha512-Y9prnPKkM7FXxQevZ5UH8Z6aVTY0ede1tHquck5UxGmKWDshxXh95gSa2xXYjS8AsGO5iOvrCI5+GttRKnLdNA==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/html-encoding-sniffer/-/html-encoding-sniffer-2.0.1.tgz", + "integrity": "sha512-D5JbOMBIR/TVZkubHT+OyT2705QvogUW4IBn6nHd756OwieSF9aDYFj4dv6HHEVGYbHaLETa3WggZYWWMyy3ZQ==", "requires": { "whatwg-encoding": "^1.0.5" } @@ -8282,29 +8282,29 @@ "integrity": "sha1-peZUwuWi3rXyAdls77yoDA7y9RM=" }, "jsdom": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.2.0.tgz", - "integrity": "sha512-6VaW3UWyKbm9DFVIAgTfhuwnvqiqlRYNg5Rk6dINTVoZT0eKz+N86vQZr+nqt1ny1lSB1TWZJWSEWQAfu8oTpA==", + "version": "16.2.1", + "resolved": "https://registry.npmjs.org/jsdom/-/jsdom-16.2.1.tgz", + "integrity": "sha512-3p0gHs5EfT7PxW9v8Phz3mrq//4Dy8MQenU/PoKxhdT+c45S7NjIjKbGT3Ph0nkICweE1r36+yaknXA5WfVNAg==", "requires": { "abab": "^2.0.3", - "acorn": "^7.1.0", - "acorn-globals": "^4.3.4", + "acorn": "^7.1.1", + "acorn-globals": "^6.0.0", "cssom": "^0.4.4", "cssstyle": "^2.2.0", "data-urls": "^2.0.0", "decimal.js": "^10.2.0", "domexception": "^2.0.1", - "escodegen": "^1.13.0", - "html-encoding-sniffer": "^2.0.0", + "escodegen": "^1.14.1", + "html-encoding-sniffer": "^2.0.1", "is-potential-custom-element-name": "^1.0.0", "nwsapi": "^2.2.0", "parse5": "5.1.1", - "request": "^2.88.0", + "request": "^2.88.2", "request-promise-native": "^1.0.8", - "saxes": "^4.0.2", + "saxes": "^5.0.0", "symbol-tree": "^3.2.4", "tough-cookie": "^3.0.1", - "w3c-hr-time": "^1.0.1", + "w3c-hr-time": "^1.0.2", "w3c-xmlserializer": "^2.0.0", "webidl-conversions": "^5.0.0", "whatwg-encoding": "^1.0.5", @@ -8314,10 +8314,63 @@ "xml-name-validator": "^3.0.0" }, "dependencies": { + "acorn": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==" + }, "parse5": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/parse5/-/parse5-5.1.1.tgz", "integrity": "sha512-ugq4DFI0Ptb+WWjAdOK16+u/nHfiIrcE+sh8kZMaM0WllQKLI9rOUq6c2b7cwPkXdzfQESqvoqK6ug7U/Yyzug==" + }, + "punycode": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.1.1.tgz", + "integrity": "sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A==" + }, + "qs": { + "version": "6.5.2", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + }, + "request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "requires": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "dependencies": { + "tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "requires": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + } + } + } } } }, @@ -10271,6 +10324,7 @@ "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", "integrity": "sha512-NAqBSrijGLZdM0WZNsInLJpkJokL72XYjUpnB0iwsRgxh7dB6COrHnTBNwN0E+lHDAJzu7kLAkDeY08z2/A0hg==", + "dev": true, "requires": { "aws-sign2": "~0.7.0", "aws4": "^1.8.0", @@ -10297,12 +10351,14 @@ "qs": { "version": "6.5.2", "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", - "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" + "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==", + "dev": true }, "tough-cookie": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.4.3.tgz", "integrity": "sha512-Q5srk/4vDM54WJsJio3XNn6K2sCG+CQ8G5Wz6bZhRZoAe/+TxjWB/GlFAnYEbkYVlON9FMk/fE3h2RLpPXo4lQ==", + "dev": true, "requires": { "psl": "^1.1.24", "punycode": "^1.4.1" @@ -10512,9 +10568,9 @@ } }, "saxes": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/saxes/-/saxes-4.0.2.tgz", - "integrity": "sha512-EZOTeQ4bgkOaGCDaTKux+LaRNcLNbdbvMH7R3/yjEEULPEmqvkFbFub6DJhJTub2iGMT93CfpZ5LTdKZmAbVeQ==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/saxes/-/saxes-5.0.0.tgz", + "integrity": "sha512-LXTZygxhf8lfwKaTP/8N9CsVdjTlea3teze4lL6u37ivbgGbV0GGMuNtS/I9rnD/HC2/txUM7Df4S2LVl1qhiA==", "requires": { "xmlchars": "^2.2.0" } @@ -11212,9 +11268,9 @@ "dev": true }, "terser": { - "version": "4.6.3", - "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.3.tgz", - "integrity": "sha512-Lw+ieAXmY69d09IIc/yqeBqXpEQIpDGZqT34ui1QWXIUpR2RjbqEkT8X7Lgex19hslSqcWM5iMN2kM11eMsESQ==", + "version": "4.6.6", + "resolved": "https://registry.npmjs.org/terser/-/terser-4.6.6.tgz", + "integrity": "sha512-4lYPyeNmstjIIESr/ysHg2vUPRGf2tzF9z2yYwnowXVuVzLEamPN1Gfrz7f8I9uEPuHcbFlW4PLIAsJoxXyJ1g==", "requires": { "commander": "^2.20.0", "source-map": "~0.6.1", @@ -11324,9 +11380,9 @@ } }, "tr46": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.0.tgz", - "integrity": "sha512-LrErSqfhdUw73AC/eXV2fEmNkvgSYxfm5lvxnLvuVgoVDknvD28Pa5FeDGc8RuVouDxUD3GnHHFv7xnBp7As5w==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-2.0.2.tgz", + "integrity": "sha512-3n1qG+/5kg+jrbTzwAykB5yRYtQCTqOGKq5U5PE3b0a1/mzo6snDhjGS0zJVJunO0NrT3Dg1MLy5TjWP/UJppg==", "requires": { "punycode": "^2.1.1" }, @@ -11731,11 +11787,11 @@ "integrity": "sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ==" }, "w3c-hr-time": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.1.tgz", - "integrity": "sha1-gqwr/2PZUOqeMYmlimViX+3xkEU=", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/w3c-hr-time/-/w3c-hr-time-1.0.2.tgz", + "integrity": "sha512-z8P5DvDNjKDoFIHK7q8r8lackT6l+jo/Ye3HOle7l9nICP9lf1Ci25fy9vHd0JOWewkIFzXIEig3TdKT7JQ5fQ==", "requires": { - "browser-process-hrtime": "^0.1.2" + "browser-process-hrtime": "^1.0.0" } }, "w3c-xmlserializer": { diff --git a/package.json b/package.json index 45440b92..552f6689 100644 --- a/package.json +++ b/package.json @@ -93,7 +93,7 @@ "fastboot": "^3.0.0", "fs-extra": "^8.1.0", "jquery": "^3.4.1", - "jsdom": "^16.2.0", + "jsdom": "^16.2.1", "klaw": "^3.0.0", "memserver": "^2.0.10", "mustache": "^4.0.0", @@ -102,7 +102,7 @@ "puppeteer": "2.1.1", "sass": "1.26.2", "say": "^0.16.0", - "terser": "4.6.3", + "terser": "4.6.6", "through2": "^3.0.0", "ws": "^7.2.3" }, From 39408566ff8c7bdaf923f7839c2eb1634e0a4578 Mon Sep 17 00:00:00 2001 From: Izel Nakri Date: Wed, 11 Mar 2020 07:29:13 +0100 Subject: [PATCH 3/8] all packages upgraded --- package-lock.json | 491 +- package.json | 22 +- vendor/ember-template-compiler.js | 8515 ++-- vendor/ember-testing.js | 30 +- vendor/full-ember-debug.js | 31692 ++++++++------- vendor/full-ember-prod.js | 3975 +- vendor/no-ember-data-ember-debug.js | 56515 ++++++++++++++------------ vendor/no-ember-data-ember-prod.js | 4128 +- vendor/test-support.js | 858 +- 9 files changed, 57638 insertions(+), 48588 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3e6cd89d..b4b72476 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1093,13 +1093,13 @@ } }, "@ember-data/adapter": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/@ember-data/adapter/-/adapter-3.16.0.tgz", - "integrity": "sha512-b3aPPMvzLOkBafa/uqlbIF5wv6Byf+oZ9Oz9XK1rD9UbbgsJGENKyTepaIKmE28lpMAvKN/jVyCDtq7iuVmThw==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/adapter/-/adapter-3.17.0.tgz", + "integrity": "sha512-tYFhDNYZe84UkOHCM//HBqr4M1JyMw9xu6w/KbJaHyFMG4LaqR0vPWb1Q+u0btC7ZV1Sp+6d8bkjvx15oxBwQg==", "dev": true, "requires": { - "@ember-data/private-build-infra": "3.16.0", - "@ember-data/store": "3.16.0", + "@ember-data/private-build-infra": "3.17.0", + "@ember-data/store": "3.17.0", "@ember/edition-utils": "^1.2.0", "ember-cli-babel": "^7.13.2", "ember-cli-test-info": "^1.0.0", @@ -1107,21 +1107,21 @@ } }, "@ember-data/canary-features": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/@ember-data/canary-features/-/canary-features-3.16.0.tgz", - "integrity": "sha512-x+dZw3YOIvvjcu6KM4IQxkQlV5CkNCuWl4msQRUFgA1RT+lgnve1bCeBQAiY8i/J4rQGyYyAyeTbUsQMGzPAwg==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/canary-features/-/canary-features-3.17.0.tgz", + "integrity": "sha512-vJ9KiHNW1LD2VgQLxZqPFhuVl0GVn82m+dlpU8tC9mPsqjTBPyAja2gKtzigRaWxUslW35+1zl/d9u8bhPJMew==", "requires": { "ember-cli-babel": "^7.13.2", "ember-cli-typescript": "^3.1.3" } }, "@ember-data/debug": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/@ember-data/debug/-/debug-3.16.0.tgz", - "integrity": "sha512-Wgw3SPeM6Yi8eQLnLB+e45JaBjt/B8BvPQNIRNOcSvqjtvXackPq549HPMZyncvmQKJxAB9C1uex6T8GYvatqA==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/debug/-/debug-3.17.0.tgz", + "integrity": "sha512-K07uC73BwqRPDaARBjHDsAi6f4Qt90TrmbhnCFVPe2v2k5d0agEcb9y7FKkh9bv1C+1APFH9dROpWw4J5KgnYA==", "dev": true, "requires": { - "@ember-data/private-build-infra": "3.16.0", + "@ember-data/private-build-infra": "3.17.0", "@ember/edition-utils": "^1.2.0", "ember-cli-babel": "^7.13.2", "ember-cli-test-info": "^1.0.0", @@ -1129,14 +1129,14 @@ } }, "@ember-data/model": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/@ember-data/model/-/model-3.16.0.tgz", - "integrity": "sha512-9OQx//9YRBqBdMAPP85vBJEXZ54FtBdgu0evFiyMWDCwaA3rG1xBELEsLlrtDltbag3MU0H99YXLppqAFROjXw==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/model/-/model-3.17.0.tgz", + "integrity": "sha512-ohhcKr1dTtFDzxFHFiLNBJcvm8xRA92usqX9LeFrJE4Xt7g/PIvr6AbvwxsI5/n4m2Rk4MT+h4S7WTeLVyYhdg==", "dev": true, "requires": { - "@ember-data/canary-features": "3.16.0", - "@ember-data/private-build-infra": "3.16.0", - "@ember-data/store": "3.16.0", + "@ember-data/canary-features": "3.17.0", + "@ember-data/private-build-infra": "3.17.0", + "@ember-data/store": "3.17.0", "@ember/edition-utils": "^1.2.0", "ember-cli-babel": "^7.13.2", "ember-cli-string-utils": "^1.1.0", @@ -1144,16 +1144,28 @@ "ember-cli-typescript": "^3.1.3", "ember-compatibility-helpers": "^1.2.0", "inflection": "1.12.0" + }, + "dependencies": { + "@ember-data/canary-features": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/canary-features/-/canary-features-3.17.0.tgz", + "integrity": "sha512-vJ9KiHNW1LD2VgQLxZqPFhuVl0GVn82m+dlpU8tC9mPsqjTBPyAja2gKtzigRaWxUslW35+1zl/d9u8bhPJMew==", + "dev": true, + "requires": { + "ember-cli-babel": "^7.13.2", + "ember-cli-typescript": "^3.1.3" + } + } } }, "@ember-data/private-build-infra": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/@ember-data/private-build-infra/-/private-build-infra-3.16.0.tgz", - "integrity": "sha512-Psk7PN5YJF2q9S7Oq/TejfkM+tjnHi9QyUDktcQD0biLuZoes4UGIJiCXAWg/cHhkTGoxRj3pRXceoym33kQrw==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/private-build-infra/-/private-build-infra-3.17.0.tgz", + "integrity": "sha512-I3qw6Py4LsZZX9ShNpO4SgDrUw7+ImNLJfT0sGUe7Ula7UaWRWep6H2/zfc2jtOjQPDk1oDdUkNFNU1Dtd/PTg==", "dev": true, "requires": { - "@babel/plugin-transform-block-scoping": "^7.7.4", - "@ember-data/canary-features": "3.16.0", + "@babel/plugin-transform-block-scoping": "^7.8.3", + "@ember-data/canary-features": "3.17.0", "@ember/edition-utils": "^1.2.0", "babel-plugin-debug-macros": "^0.3.3", "babel-plugin-filter-imports": "^4.0.0", @@ -1161,7 +1173,7 @@ "broccoli-debug": "^0.6.5", "broccoli-file-creator": "^2.1.1", "broccoli-funnel": "^2.0.2", - "broccoli-merge-trees": "^3.0.2", + "broccoli-merge-trees": "^4.1.0", "broccoli-rollup": "^4.1.1", "calculate-cache-key-for-tree": "^2.0.0", "chalk": "^3.0.0", @@ -1176,10 +1188,20 @@ "npm-git-info": "^1.0.3", "rimraf": "^3.0.0", "rsvp": "^4.8.5", - "semver": "^6.3.0", + "semver": "^7.1.1", "silent-error": "^1.1.1" }, "dependencies": { + "@ember-data/canary-features": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/canary-features/-/canary-features-3.17.0.tgz", + "integrity": "sha512-vJ9KiHNW1LD2VgQLxZqPFhuVl0GVn82m+dlpU8tC9mPsqjTBPyAja2gKtzigRaWxUslW35+1zl/d9u8bhPJMew==", + "dev": true, + "requires": { + "ember-cli-babel": "^7.13.2", + "ember-cli-typescript": "^3.1.3" + } + }, "ansi-styles": { "version": "4.2.1", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", @@ -1190,6 +1212,42 @@ "color-convert": "^2.0.1" } }, + "broccoli-merge-trees": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/broccoli-merge-trees/-/broccoli-merge-trees-4.1.0.tgz", + "integrity": "sha512-1OXsksKPFiRdiZZOfh1z1mm7ZqKezlMS+DPBpHMDLSb6AhYHvoQfjf0KuMXbY8aoYskj7+Z+EJ5SsS/OC2v5yw==", + "dev": true, + "requires": { + "broccoli-plugin": "^3.1.0", + "merge-trees": "^2.0.0" + } + }, + "broccoli-plugin": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/broccoli-plugin/-/broccoli-plugin-3.1.0.tgz", + "integrity": "sha512-7w7FP8WJYjLvb0eaw27LO678TGGaom++49O1VYIuzjhXjK5kn2+AMlDm7CaUFw4F7CLGoVQeZ84d8gICMJa4lA==", + "dev": true, + "requires": { + "broccoli-node-api": "^1.6.0", + "broccoli-output-wrapper": "^2.0.0", + "fs-merger": "^3.0.1", + "promise-map-series": "^0.2.1", + "quick-temp": "^0.1.3", + "rimraf": "^2.3.4", + "symlink-or-copy": "^1.1.8" + }, + "dependencies": { + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } + } + }, "chalk": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", @@ -1240,9 +1298,9 @@ "dev": true }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.1.3.tgz", + "integrity": "sha512-ekM0zfiA9SCBlsKa2X1hxyxiI4L3B6EbVJkkdgQXnSEEaHlGdvyodMruTiulSRWMMB4NeIuYNMC9rTKTz97GxA==", "dev": true }, "supports-color": { @@ -1257,19 +1315,31 @@ } }, "@ember-data/record-data": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/@ember-data/record-data/-/record-data-3.16.0.tgz", - "integrity": "sha512-dujprHQWafM+yxigA0W1h/JyiJzhwDWGHsE1+DHDWuh3W12QmRzBC944LKB8Vv+UUYd2DqwUnBvLnWTYnfeSMQ==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/record-data/-/record-data-3.17.0.tgz", + "integrity": "sha512-MGGZtb0+vCxNtCN1dn+u/gQwhTPVYvgoetzx3OOmLzO0QqoVZOxEqoKSOQIj4dVF+WonbIrDJjeCmG9d5qutQA==", "dev": true, "requires": { - "@ember-data/canary-features": "3.16.0", - "@ember-data/private-build-infra": "3.16.0", - "@ember-data/store": "3.16.0", + "@ember-data/canary-features": "3.17.0", + "@ember-data/private-build-infra": "3.17.0", + "@ember-data/store": "3.17.0", "@ember/edition-utils": "^1.2.0", "@ember/ordered-set": "^2.0.3", "ember-cli-babel": "^7.13.2", "ember-cli-test-info": "^1.0.0", "ember-cli-typescript": "^3.1.3" + }, + "dependencies": { + "@ember-data/canary-features": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/canary-features/-/canary-features-3.17.0.tgz", + "integrity": "sha512-vJ9KiHNW1LD2VgQLxZqPFhuVl0GVn82m+dlpU8tC9mPsqjTBPyAja2gKtzigRaWxUslW35+1zl/d9u8bhPJMew==", + "dev": true, + "requires": { + "ember-cli-babel": "^7.13.2", + "ember-cli-typescript": "^3.1.3" + } + } } }, "@ember-data/rfc395-data": { @@ -1278,32 +1348,42 @@ "integrity": "sha512-tGRdvgC9/QMQSuSuJV45xoyhI0Pzjm7A9o/MVVA3HakXIImJbbzx/k/6dO9CUEQXIyS2y0fW6C1XaYOG7rY0FQ==" }, "@ember-data/serializer": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/@ember-data/serializer/-/serializer-3.16.0.tgz", - "integrity": "sha512-8Qp2eDmvZfctH9PhcsSlqV7Nc1J5HhVOIpuP+8kCtMsgYwbyukFOywdRgc+uN9n/08aufG4L9PcfZp64OT03rQ==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/serializer/-/serializer-3.17.0.tgz", + "integrity": "sha512-mmnrJIlOIY5EWg+Cptiwo7TYIWM/zIWGh+7w4jnIVAds+E3opVaBggxawwRk3c/wOjVWPadwaCH/otEMDmSUbw==", "dev": true, "requires": { - "@ember-data/private-build-infra": "3.16.0", - "@ember-data/store": "3.16.0", + "@ember-data/private-build-infra": "3.17.0", + "@ember-data/store": "3.17.0", "ember-cli-babel": "^7.13.2", "ember-cli-test-info": "^1.0.0", "ember-cli-typescript": "^3.1.3" } }, "@ember-data/store": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/@ember-data/store/-/store-3.16.0.tgz", - "integrity": "sha512-xjJMmTK9Fxsrethf9uxbVTj0jbgZsEMJ6YZ0hwFvHDDRhLJ8rKGFafmYoCm1nKsprUWGnMr5YXX5C21CCaHJnA==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/store/-/store-3.17.0.tgz", + "integrity": "sha512-1KotGw/zxpFFWMYxXfDisY4hSKq35orn9+7lV1b/JpE1fvCtGcC8un9PjN6B08xNVtV0mlIjmXkp4rzO56k1sw==", "dev": true, "requires": { - "@ember-data/canary-features": "3.16.0", - "@ember-data/private-build-infra": "3.16.0", + "@ember-data/canary-features": "3.17.0", + "@ember-data/private-build-infra": "3.17.0", "ember-cli-babel": "^7.13.2", "ember-cli-path-utils": "^1.0.0", "ember-cli-typescript": "^3.1.3", "heimdalljs": "^0.3.0" }, "dependencies": { + "@ember-data/canary-features": { + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/@ember-data/canary-features/-/canary-features-3.17.0.tgz", + "integrity": "sha512-vJ9KiHNW1LD2VgQLxZqPFhuVl0GVn82m+dlpU8tC9mPsqjTBPyAja2gKtzigRaWxUslW35+1zl/d9u8bhPJMew==", + "dev": true, + "requires": { + "ember-cli-babel": "^7.13.2", + "ember-cli-typescript": "^3.1.3" + } + }, "heimdalljs": { "version": "0.3.3", "resolved": "https://registry.npmjs.org/heimdalljs/-/heimdalljs-0.3.3.tgz", @@ -1486,6 +1566,24 @@ "ember-cli-babel": "^7.7.3", "ember-cli-htmlbars-inline-precompile": "^2.1.0", "ember-test-waiters": "^1.1.1" + }, + "dependencies": { + "ember-test-waiters": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/ember-test-waiters/-/ember-test-waiters-1.2.0.tgz", + "integrity": "sha512-aEw7YuutLuJT4NUuPTNiGFwgTYl23ThqmBxSkfFimQAn+keWjAftykk3dlFELuhsJhYW/S8YoVjN0bSAQRLNtw==", + "dev": true, + "requires": { + "ember-cli-babel": "^7.11.0", + "semver": "^6.3.0" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } } }, "@glimmer/component": { @@ -1861,9 +1959,9 @@ } }, "acorn": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz", - "integrity": "sha512-kL5CuoXA/dgxlBbVrflsflzQ3PAas7RYZB52NOm/6839iVYJgKMJ3cQJD+t2i5+qFa8h3MDpEOJiS64E8JLnSQ==" + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.1.tgz", + "integrity": "sha512-add7dgA5ppRPxCFJoAGfMDi7PIBXq1RtGo7BhbLaxwrXPOmw8gq48Y9ozT01hUKy9byMjlR20EJhu5zlkErEkg==" }, "acorn-globals": { "version": "6.0.0", @@ -3640,6 +3738,27 @@ "merge-trees": "^2.0.0" } }, + "broccoli-node-api": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/broccoli-node-api/-/broccoli-node-api-1.7.0.tgz", + "integrity": "sha512-QIqLSVJWJUVOhclmkmypJJH9u9s/aWH4+FH6Q6Ju5l+Io4dtwqdPUNmDfw40o6sxhbZHhqGujDJuHTML1wG8Yw==", + "dev": true + }, + "broccoli-node-info": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/broccoli-node-info/-/broccoli-node-info-2.1.0.tgz", + "integrity": "sha512-l6qDuboJThHfRVVWQVaTs++bFdrFTP0gJXgsWenczc1PavRVUmL1Eyb2swTAXXMpDOnr2zhNOBLx4w9AxkqbPQ==", + "dev": true + }, + "broccoli-output-wrapper": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/broccoli-output-wrapper/-/broccoli-output-wrapper-2.0.0.tgz", + "integrity": "sha512-V/ozejo+snzNf75i/a6iTmp71k+rlvqjE3+jYfimuMwR1tjNNRdtfno+NGNQB2An9bIAeqZnKhMDurAznHAdtA==", + "dev": true, + "requires": { + "heimdalljs-logger": "^0.1.10" + } + }, "broccoli-persistent-filter": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/broccoli-persistent-filter/-/broccoli-persistent-filter-2.3.1.tgz", @@ -5621,25 +5740,61 @@ } }, "ember-data": { - "version": "3.16.0", - "resolved": "https://registry.npmjs.org/ember-data/-/ember-data-3.16.0.tgz", - "integrity": "sha512-yrQ+tMmN+VJbFple/dURB0VaQsBKZnYP9/5WVFQFZFpXzdAMPlNYq2HxyQWz4HMZ++uMwvez+/FhSiNfuUvcrQ==", - "dev": true, - "requires": { - "@ember-data/adapter": "3.16.0", - "@ember-data/debug": "3.16.0", - "@ember-data/model": "3.16.0", - "@ember-data/private-build-infra": "3.16.0", - "@ember-data/record-data": "3.16.0", - "@ember-data/serializer": "3.16.0", - "@ember-data/store": "3.16.0", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/ember-data/-/ember-data-3.17.0.tgz", + "integrity": "sha512-lcHk4rjIVoynGbVH3qFfHbbI1WX1bMCEkzWV/BXPlXM6AwYYBqkMC4AD5Udt4VQk9qZ5us4CaKd+7Ryozz5eZw==", + "dev": true, + "requires": { + "@ember-data/adapter": "3.17.0", + "@ember-data/debug": "3.17.0", + "@ember-data/model": "3.17.0", + "@ember-data/private-build-infra": "3.17.0", + "@ember-data/record-data": "3.17.0", + "@ember-data/serializer": "3.17.0", + "@ember-data/store": "3.17.0", "@ember/edition-utils": "^1.2.0", "@ember/ordered-set": "^2.0.3", "@glimmer/env": "^0.1.7", - "broccoli-merge-trees": "^3.0.2", + "broccoli-merge-trees": "^4.1.0", "ember-cli-babel": "^7.13.2", "ember-cli-typescript": "^3.1.3", "ember-inflector": "^3.0.1" + }, + "dependencies": { + "broccoli-merge-trees": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/broccoli-merge-trees/-/broccoli-merge-trees-4.1.0.tgz", + "integrity": "sha512-1OXsksKPFiRdiZZOfh1z1mm7ZqKezlMS+DPBpHMDLSb6AhYHvoQfjf0KuMXbY8aoYskj7+Z+EJ5SsS/OC2v5yw==", + "dev": true, + "requires": { + "broccoli-plugin": "^3.1.0", + "merge-trees": "^2.0.0" + } + }, + "broccoli-plugin": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/broccoli-plugin/-/broccoli-plugin-3.1.0.tgz", + "integrity": "sha512-7w7FP8WJYjLvb0eaw27LO678TGGaom++49O1VYIuzjhXjK5kn2+AMlDm7CaUFw4F7CLGoVQeZ84d8gICMJa4lA==", + "dev": true, + "requires": { + "broccoli-node-api": "^1.6.0", + "broccoli-output-wrapper": "^2.0.0", + "fs-merger": "^3.0.1", + "promise-map-series": "^0.2.1", + "quick-temp": "^0.1.3", + "rimraf": "^2.3.4", + "symlink-or-copy": "^1.1.8" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + } } }, "ember-devtools": { @@ -6340,9 +6495,9 @@ } }, "ember-source": { - "version": "3.16.2", - "resolved": "https://registry.npmjs.org/ember-source/-/ember-source-3.16.2.tgz", - "integrity": "sha512-aRF90V88rJ6h47ootUw8oGcV7O4ulwLYNVqnokTr9RTeWjEimwMtzLLazUfDR1LZMkdMTLVLGcQkJCJVvUAg5A==", + "version": "3.17.0", + "resolved": "https://registry.npmjs.org/ember-source/-/ember-source-3.17.0.tgz", + "integrity": "sha512-CfOi00tYGdwR12FuBMuiBzyC4cmabHtkL+LpORWavCRHN0UfBpBTj64rmKMD2HNJhYZFVX+8ZFTO27FX8D6Glg==", "dev": true, "requires": { "@babel/helper-module-imports": "^7.0.0", @@ -6350,13 +6505,13 @@ "@babel/plugin-transform-object-assign": "^7.2.0", "@ember/edition-utils": "^1.2.0", "babel-plugin-debug-macros": "^0.3.3", - "babel-plugin-filter-imports": "^3.0.0", + "babel-plugin-filter-imports": "^4.0.0", "broccoli-concat": "^3.7.4", "broccoli-debug": "^0.6.4", "broccoli-funnel": "^2.0.2", "broccoli-merge-trees": "^3.0.2", - "chalk": "^2.4.2", - "ember-cli-babel": "^7.11.0", + "chalk": "^3.0.0", + "ember-cli-babel": "^7.13.2", "ember-cli-get-component-path-option": "^1.0.0", "ember-cli-is-package-missing": "^1.0.0", "ember-cli-normalize-entity-name": "^1.0.0", @@ -6366,21 +6521,46 @@ "ember-router-generator": "^2.0.0", "inflection": "^1.12.0", "jquery": "^3.4.1", - "resolve": "^1.11.1", + "resolve": "^1.14.2", "semver": "^6.1.1", "silent-error": "^1.1.1" }, "dependencies": { - "babel-plugin-filter-imports": { + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "chalk": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/babel-plugin-filter-imports/-/babel-plugin-filter-imports-3.0.0.tgz", - "integrity": "sha512-p/chjzVTgCxUqyLM0q/pfWVZS7IJTwGQMwNg0LOvuQpKiTftQgZDtkGB8XvETnUw19rRcL7bJCTopSwibTN2tA==", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-3.0.0.tgz", + "integrity": "sha512-4D3B6Wf41KOYRFdszmDqMCGq5VV/uMAB273JILmO+3jAlh8X4qDtdtgCR3fxtbLEMzSx22QdhnDcJvu2u1fVwg==", "dev": true, "requires": { - "@babel/types": "^7.4.0", - "lodash": "^4.17.11" + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" } }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "ember-cli-version-checker": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/ember-cli-version-checker/-/ember-cli-version-checker-3.1.3.tgz", @@ -6399,28 +6579,108 @@ } } }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, "semver": { "version": "6.3.0", "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true + }, + "supports-color": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } } } }, "ember-test-waiters": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/ember-test-waiters/-/ember-test-waiters-1.2.0.tgz", - "integrity": "sha512-aEw7YuutLuJT4NUuPTNiGFwgTYl23ThqmBxSkfFimQAn+keWjAftykk3dlFELuhsJhYW/S8YoVjN0bSAQRLNtw==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ember-test-waiters/-/ember-test-waiters-2.0.0.tgz", + "integrity": "sha512-R7H/BgKeAJdmpNA7aropEJkcJZNBMSOXTogz7hF+ZO0tnHSq3cJb/gDpu6Beok3DzLCJIrYYApU3MPbQ0/teXQ==", "dev": true, "requires": { - "ember-cli-babel": "^7.11.0", - "semver": "^6.3.0" + "ember-cli-babel": "^7.18.0", + "ember-cli-typescript": "^3.1.3", + "semver": "^7.1.3" }, "dependencies": { + "babel-plugin-ember-data-packages-polyfill": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/babel-plugin-ember-data-packages-polyfill/-/babel-plugin-ember-data-packages-polyfill-0.1.2.tgz", + "integrity": "sha512-kTHnOwoOXfPXi00Z8yAgyD64+jdSXk3pknnS7NlqnCKAU6YDkXZ4Y7irl66kaZjZn0FBBt0P4YOZFZk85jYOww==", + "dev": true, + "requires": { + "@ember-data/rfc395-data": "^0.0.4" + } + }, + "babel-plugin-module-resolver": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/babel-plugin-module-resolver/-/babel-plugin-module-resolver-3.2.0.tgz", + "integrity": "sha512-tjR0GvSndzPew/Iayf4uICWZqjBwnlMWjSx6brryfQ81F9rxBVqwDJtFCV8oOs0+vJeefK9TmdZtkIFdFe1UnA==", + "dev": true, + "requires": { + "find-babel-config": "^1.1.0", + "glob": "^7.1.2", + "pkg-up": "^2.0.0", + "reselect": "^3.0.1", + "resolve": "^1.4.0" + } + }, + "ember-cli-babel": { + "version": "7.18.0", + "resolved": "https://registry.npmjs.org/ember-cli-babel/-/ember-cli-babel-7.18.0.tgz", + "integrity": "sha512-OLPfYD8wSfCrmGHcUf8zEfySSvbAL+5Qp2RWLycJIMaBZhg+SncKj5kVkL3cPJR5n2hVHPdfmKTQIYjOYl6FnQ==", + "dev": true, + "requires": { + "@babel/core": "^7.8.4", + "@babel/helper-compilation-targets": "^7.8.4", + "@babel/plugin-proposal-class-properties": "^7.8.3", + "@babel/plugin-proposal-decorators": "^7.8.3", + "@babel/plugin-transform-modules-amd": "^7.8.3", + "@babel/plugin-transform-runtime": "^7.8.3", + "@babel/plugin-transform-typescript": "^7.8.3", + "@babel/polyfill": "^7.8.3", + "@babel/preset-env": "^7.8.4", + "@babel/runtime": "^7.8.4", + "amd-name-resolver": "^1.2.1", + "babel-plugin-debug-macros": "^0.3.0", + "babel-plugin-ember-data-packages-polyfill": "^0.1.2", + "babel-plugin-ember-modules-api-polyfill": "^2.12.0", + "babel-plugin-module-resolver": "^3.1.1", + "broccoli-babel-transpiler": "^7.4.0", + "broccoli-debug": "^0.6.4", + "broccoli-funnel": "^2.0.1", + "broccoli-source": "^1.1.0", + "clone": "^2.1.2", + "ember-cli-babel-plugin-helpers": "^1.1.0", + "ember-cli-version-checker": "^4.1.0", + "ensure-posix-path": "^1.0.2", + "fixturify-project": "^1.10.0", + "rimraf": "^3.0.1", + "semver": "^5.5.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, "semver": { - "version": "6.3.0", - "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", - "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.1.3.tgz", + "integrity": "sha512-ekM0zfiA9SCBlsKa2X1hxyxiI4L3B6EbVJkkdgQXnSEEaHlGdvyodMruTiulSRWMMB4NeIuYNMC9rTKTz97GxA==", "dev": true } } @@ -7393,6 +7653,65 @@ "universalify": "^0.1.0" } }, + "fs-merger": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/fs-merger/-/fs-merger-3.0.2.tgz", + "integrity": "sha512-63wmgjPDClP5XcTSKdIXz66X5paYy/m2Ymq5c5YpGxRQEk1HFZ8rtti3LMNSOSw1ketbBMGbSFFcQeEnpnzDpQ==", + "dev": true, + "requires": { + "broccoli-node-api": "^1.7.0", + "broccoli-node-info": "^2.1.0", + "fs-extra": "^8.0.1", + "fs-tree-diff": "^2.0.1", + "rimraf": "^2.6.3", + "walk-sync": "^2.0.2" + }, + "dependencies": { + "fs-tree-diff": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fs-tree-diff/-/fs-tree-diff-2.0.1.tgz", + "integrity": "sha512-x+CfAZ/lJHQqwlD64pYM5QxWjzWhSjroaVsr8PW831zOApL55qPibed0c+xebaLWVr2BnHFoHdrwOv8pzt8R5A==", + "dev": true, + "requires": { + "@types/symlink-or-copy": "^1.2.0", + "heimdalljs-logger": "^0.1.7", + "object-assign": "^4.1.0", + "path-posix": "^1.0.0", + "symlink-or-copy": "^1.1.8" + } + }, + "matcher-collection": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/matcher-collection/-/matcher-collection-2.0.1.tgz", + "integrity": "sha512-daE62nS2ZQsDg9raM0IlZzLmI2u+7ZapXBwdoeBUKAYERPDDIc0qNqA8E0Rp2D+gspKR7BgIFP52GeujaGXWeQ==", + "dev": true, + "requires": { + "@types/minimatch": "^3.0.3", + "minimatch": "^3.0.2" + } + }, + "rimraf": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.7.1.tgz", + "integrity": "sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "walk-sync": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/walk-sync/-/walk-sync-2.0.2.tgz", + "integrity": "sha512-dCZkrxfHjPn7tIvdYrX3uMD/R0beVrHpA8lROQ5wWrl8psJgR6xwCkwqTFes0dNujbS2o/ITpvSYgIFsLsf13A==", + "dev": true, + "requires": { + "@types/minimatch": "^3.0.3", + "ensure-posix-path": "^1.1.0", + "matcher-collection": "^2.0.0" + } + } + } + }, "fs-tree-diff": { "version": "0.5.9", "resolved": "https://registry.npmjs.org/fs-tree-diff/-/fs-tree-diff-0.5.9.tgz", @@ -10210,9 +10529,9 @@ } }, "recast": { - "version": "0.18.5", - "resolved": "https://registry.npmjs.org/recast/-/recast-0.18.5.tgz", - "integrity": "sha512-sD1WJrpLQAkXGyQZyGzTM75WJvyAd98II5CHdK3IYbt/cZlU0UzCRVU11nUFNXX9fBVEt4E9ajkMjBlUlG+Oog==", + "version": "0.18.7", + "resolved": "https://registry.npmjs.org/recast/-/recast-0.18.7.tgz", + "integrity": "sha512-qNfoxvMkW4k8jJgNCfmIES7S31MEejXcEQs57eKUcQGiJUuX7cXNOD2h+W9z0rjNun2EkKqf0WvuRtmHw4NPNg==", "dev": true, "requires": { "ast-types": "0.13.2", @@ -10498,9 +10817,9 @@ } }, "rollup": { - "version": "1.31.0", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.31.0.tgz", - "integrity": "sha512-9C6ovSyNeEwvuRuUUmsTpJcXac1AwSL1a3x+O5lpmQKZqi5mmrjauLeqIjvREC+yNRR8fPdzByojDng+af3nVw==", + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", + "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", "dev": true, "requires": { "@types/estree": "*", diff --git a/package.json b/package.json index 552f6689..f9cd8ca9 100644 --- a/package.json +++ b/package.json @@ -26,13 +26,13 @@ "test": "node_modules/.bin/ava --verbose" }, "devDependencies": { - "@ember-data/adapter": "3.16.0", - "@ember-data/debug": "^3.16.0", - "@ember-data/model": "3.16.0", - "@ember-data/private-build-infra": "^3.16.0", - "@ember-data/record-data": "3.16.0", - "@ember-data/serializer": "3.16.0", - "@ember-data/store": "3.16.0", + "@ember-data/adapter": "3.17.0", + "@ember-data/debug": "^3.17.0", + "@ember-data/model": "3.17.0", + "@ember-data/private-build-infra": "^3.17.0", + "@ember-data/record-data": "3.17.0", + "@ember-data/serializer": "3.17.0", + "@ember-data/store": "3.17.0", "@ember/test-helpers": "1.7.1", "@glimmer/di": "^0.2.1", "@glimmer/resolver": "^0.4.3", @@ -40,13 +40,13 @@ "cors": "^2.8.5", "ember-cli-fastboot": "2.2.1", "ember-cli-test-loader": "^3.0.0", - "ember-data": "3.16.0", + "ember-data": "3.17.0", "ember-devtools": "^6.0.0", "ember-load-initializers": "^2.1.1", "ember-qunit": "^4.6.0", "ember-resolver": "^6.0.0", - "ember-source": "3.16.2", - "ember-test-waiters": "1.2.0", + "ember-source": "3.17.0", + "ember-test-waiters": "2.0.0", "intercept-stdout": "^0.1.2", "loader.js": "^4.7.0", "mber-head": "^0.1.0", @@ -68,7 +68,7 @@ "@babel/plugin-transform-modules-amd": "^7.8.3", "@babel/plugin-transform-typescript": "^7.8.7", "@babel/preset-env": "^7.8.4", - "@ember-data/canary-features": "^3.16.0", + "@ember-data/canary-features": "^3.17.0", "@ember/ordered-set": "^2.0.3", "@ember/render-modifiers": "^1.0.2", "@glimmer/component": "^1.0.0", diff --git a/vendor/ember-template-compiler.js b/vendor/ember-template-compiler.js index a5f80f58..10f6c5c6 100644 --- a/vendor/ember-template-compiler.js +++ b/vendor/ember-template-compiler.js @@ -6,7 +6,7 @@ * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 3.16.2 + * @version 3.17.0 */ /*globals process */ @@ -461,6 +461,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ _exports.getName = getName; _exports.setName = setName; _exports.toString = toString; + _exports.isObject = isObject; _exports.isProxy = isProxy; _exports.setProxy = setProxy; _exports.isEmberArray = isEmberArray; @@ -713,7 +714,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ functionName = match && match[1] || ''; } - return functionName; + return functionName.replace(/^bound /, ''); }; var getObjectName = function getObjectName(obj) { @@ -1228,6 +1229,19 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ var setWithMandatorySetter; _exports.setWithMandatorySetter = setWithMandatorySetter; + function isElementKey(key) { + return typeof key === 'number' ? isPositiveInt(key) : isStringInt(key); + } + + function isStringInt(str) { + var num = parseInt(str, 10); + return isPositiveInt(num) && str === String(num); + } + + function isPositiveInt(num) { + return num >= 0 && num % 1 === 0; + } + if (true /* DEBUG */ ) { @@ -1244,6 +1258,11 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ } SEEN_TAGS.add(tag); + + if (Array.isArray(obj) && isElementKey(keyName)) { + return; + } + var desc = lookupDescriptor(obj, keyName) || {}; if (desc.get || desc.set) { @@ -1335,7 +1354,7 @@ define("@ember/canary-features/index", ["exports", "@ember/-internals/environmen value: true }); _exports.isEnabled = isEnabled; - _exports.EMBER_ROUTING_MODEL_ARG = _exports.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = _exports.EMBER_CUSTOM_COMPONENT_ARG_PROXY = _exports.EMBER_MODULE_UNIFICATION = _exports.EMBER_IMPROVED_INSTRUMENTATION = _exports.EMBER_LIBRARIES_ISREGISTERED = _exports.FEATURES = _exports.DEFAULT_FEATURES = void 0; + _exports.EMBER_ROUTING_MODEL_ARG = _exports.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = _exports.EMBER_CUSTOM_COMPONENT_ARG_PROXY = _exports.EMBER_MODULE_UNIFICATION = _exports.EMBER_NAMED_BLOCKS = _exports.EMBER_IMPROVED_INSTRUMENTATION = _exports.EMBER_LIBRARIES_ISREGISTERED = _exports.FEATURES = _exports.DEFAULT_FEATURES = void 0; /** Set `EmberENV.FEATURES` in your application's `config/environment.js` file @@ -1350,6 +1369,7 @@ define("@ember/canary-features/index", ["exports", "@ember/-internals/environmen var DEFAULT_FEATURES = { EMBER_LIBRARIES_ISREGISTERED: false, EMBER_IMPROVED_INSTRUMENTATION: false, + EMBER_NAMED_BLOCKS: false, EMBER_MODULE_UNIFICATION: false, EMBER_CUSTOM_COMPONENT_ARG_PROXY: true, EMBER_GLIMMER_SET_COMPONENT_TEMPLATE: true, @@ -1409,6 +1429,8 @@ define("@ember/canary-features/index", ["exports", "@ember/-internals/environmen _exports.EMBER_LIBRARIES_ISREGISTERED = EMBER_LIBRARIES_ISREGISTERED; var EMBER_IMPROVED_INSTRUMENTATION = featureValue(FEATURES.EMBER_IMPROVED_INSTRUMENTATION); _exports.EMBER_IMPROVED_INSTRUMENTATION = EMBER_IMPROVED_INSTRUMENTATION; + var EMBER_NAMED_BLOCKS = featureValue(FEATURES.EMBER_NAMED_BLOCKS); + _exports.EMBER_NAMED_BLOCKS = EMBER_NAMED_BLOCKS; var EMBER_MODULE_UNIFICATION = featureValue(FEATURES.EMBER_MODULE_UNIFICATION); _exports.EMBER_MODULE_UNIFICATION = EMBER_MODULE_UNIFICATION; var EMBER_CUSTOM_COMPONENT_ARG_PROXY = featureValue(FEATURES.EMBER_CUSTOM_COMPONENT_ARG_PROXY); @@ -1785,8 +1807,10 @@ define("@ember/debug/lib/capture-render-tree", ["exports", "@glimmer/util"], fun @since 3.14.0 */ function captureRenderTree(app) { - var env = (0, _util.expect)(app.lookup('service:-glimmer-environment'), 'BUG: owner is missing service:-glimmer-environment'); - return env.debugRenderTree.capture(); + var env = (0, _util.expect)(app.lookup('-environment:main'), 'BUG: owner is missing -environment:main'); + var rendererType = env.isInteractive ? 'renderer:-dom' : 'renderer:-inert'; + var renderer = (0, _util.expect)(app.lookup(rendererType), "BUG: owner is missing " + rendererType); + return renderer.debugRenderTree.capture(); } }); define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment", "@ember/debug/index", "@ember/debug/lib/handlers"], function (_exports, _environment, _index, _handlers) { @@ -2383,7 +2407,14 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ value: true }); _exports.precompile = precompile; - _exports.TemplateVisitor = _exports.TemplateCompiler = _exports.defaultId = void 0; + _exports.buildStatement = buildStatement; + _exports.buildStatements = buildStatements; + _exports.s = s; + _exports.c = c; + _exports.unicode = unicode; + _exports.locationToOffset = locationToOffset; + _exports.offsetToLocation = offsetToLocation; + _exports.WireFormatDebugger = _exports.TemplateVisitor = _exports.TemplateCompiler = _exports.NEWLINE = _exports.ProgramSymbols = _exports.defaultId = void 0; var SymbolTable = /*#__PURE__*/ @@ -2418,6 +2449,7 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ _this2 = _SymbolTable.apply(this, arguments) || this; _this2.symbols = []; + _this2.freeVariables = []; _this2.size = 1; _this2.named = (0, _util.dict)(); _this2.blocks = (0, _util.dict)(); @@ -2442,6 +2474,18 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ return []; }; + _proto2.allocateFree = function allocateFree(name) { + var index = this.freeVariables.indexOf(name); + + if (index !== -1) { + return index; + } + + index = this.freeVariables.length; + this.freeVariables.push(name); + return index; + }; + _proto2.allocateNamed = function allocateNamed(name) { var named = this.named[name]; @@ -2453,6 +2497,10 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ }; _proto2.allocateBlock = function allocateBlock(name) { + if (name === 'inverse') { + name = 'else'; + } + var block = this.blocks[name]; if (!block) { @@ -2513,6 +2561,10 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ }); }; + _proto3.allocateFree = function allocateFree(name) { + return this.parent.allocateFree(name); + }; + _proto3.allocateNamed = function allocateNamed(name) { return this.parent.allocateNamed(name); }; @@ -2606,7 +2658,15 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ } // Traversal methods ; - _proto4.Program = function Program(program) { + _proto4.Block = function Block(program) { + return this.anyBlock(program); + }; + + _proto4.Template = function Template(program) { + return this.anyBlock(program); + }; + + _proto4.anyBlock = function anyBlock(program) { var _this$actions; this.programDepth++; @@ -2614,9 +2674,9 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ var programFrame = this.pushFrame(); if (!parentFrame) { - program['symbols'] = SymbolTable.top(); + program.symbols = SymbolTable.top(); } else { - program['symbols'] = parentFrame.symbols.child(program.blockParams); + program.symbols = parentFrame.symbols.child(program.blockParams); } var startType, endType; @@ -2662,7 +2722,7 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ elementFrame.childCount = element.children.length; elementFrame.mustacheCount += element.modifiers.length; elementFrame.blankChildTextNodes = []; - elementFrame.symbols = element['symbols'] = parentFrame.symbols.child(element.blockParams); + elementFrame.symbols = element.symbols = parentFrame.symbols.child(element.blockParams); var actionArgs = [element, parentFrame.childIndex, parentFrame.childCount]; elementFrame.actions.push(['closeElement', actionArgs]); @@ -2827,22 +2887,38 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ return InlineBlock; }(Block); + var NamedBlock = + /*#__PURE__*/ + function (_InlineBlock) { + (0, _emberBabel.inheritsLoose)(NamedBlock, _InlineBlock); + + function NamedBlock(name, table) { + var _this6; + + _this6 = _InlineBlock.call(this, table) || this; + _this6.name = name; + return _this6; + } + + return NamedBlock; + }(InlineBlock); + var TemplateBlock = /*#__PURE__*/ function (_Block2) { (0, _emberBabel.inheritsLoose)(TemplateBlock, _Block2); function TemplateBlock(symbolTable) { - var _this6; + var _this7; - _this6 = _Block2.call(this) || this; - _this6.symbolTable = symbolTable; - _this6.type = 'template'; - _this6.yields = new _util.DictSet(); - _this6.named = new _util.DictSet(); - _this6.blocks = []; - _this6.hasEval = false; - return _this6; + _this7 = _Block2.call(this) || this; + _this7.symbolTable = symbolTable; + _this7.type = 'template'; + _this7.yields = new _util.DictSet(); + _this7.named = new _util.DictSet(); + _this7.blocks = []; + _this7.hasEval = false; + return _this7; } var _proto7 = TemplateBlock.prototype; @@ -2855,7 +2931,8 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ return { symbols: this.symbolTable.symbols, statements: this.statements, - hasEval: this.hasEval + hasEval: this.hasEval, + upvars: this.symbolTable.freeVariables }; }; @@ -2868,17 +2945,18 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ (0, _emberBabel.inheritsLoose)(ComponentBlock, _Block3); function ComponentBlock(tag, table, selfClosing) { - var _this7; - - _this7 = _Block3.call(this) || this; - _this7.tag = tag; - _this7.table = table; - _this7.selfClosing = selfClosing; - _this7.attributes = []; - _this7.arguments = []; - _this7.inParams = true; - _this7.positionals = []; - return _this7; + var _this8; + + _this8 = _Block3.call(this) || this; + _this8.tag = tag; + _this8.table = table; + _this8.selfClosing = selfClosing; + _this8.attributes = []; + _this8.arguments = []; + _this8.inParams = true; + _this8.positionals = []; + _this8.blocks = []; + return _this8; } var _proto8 = ComponentBlock.prototype; @@ -2899,19 +2977,45 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ } }; + _proto8.pushBlock = function pushBlock(name, block) { + this.blocks.push([name, block]); + }; + _proto8.toJSON = function toJSON() { + var blocks; var args = this.arguments; var keys = args.map(function (arg) { return arg[1]; }); - var values = args.map(function (arg) { + var values$$1 = args.map(function (arg) { return arg[2]; }); - var block = this.selfClosing ? null : { - statements: this.statements, - parameters: this.table.slots - }; - return [this.tag, this.attributes, [keys, values], block]; + + if (this.selfClosing) { + blocks = null; + } else if (this.blocks.length > 0) { + var _keys = []; + var _values$$ = []; + + for (var i = 0; i < this.blocks.length; i++) { + var _this$blocks$i = this.blocks[i], + key = _this$blocks$i[0], + value = _this$blocks$i[1]; + + _keys.push(key.slice(1)); + + _values$$.push(value); + } + + blocks = [_keys, _values$$]; + } else { + blocks = [['default'], [{ + statements: this.statements, + parameters: this.table.slots + }]]; + } + + return [this.tag, this.attributes, [keys, values$$1], blocks]; }; return ComponentBlock; @@ -2936,48 +3040,49 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ var JavaScriptCompiler = /*#__PURE__*/ function () { - function JavaScriptCompiler(opcodes, symbols, options) { + function JavaScriptCompiler(opcodes, symbols, locations, options) { + this.locations = locations; this.blocks = new _util.Stack(); this.values = []; + this.location = null; + this.locationStack = []; this.opcodes = opcodes; this.template = new Template(symbols); this.options = options; } - JavaScriptCompiler.process = function process(opcodes, symbols, options) { - var compiler = new JavaScriptCompiler(opcodes, symbols, options); + JavaScriptCompiler.process = function process(opcodes, locations, symbols, options) { + var compiler = new JavaScriptCompiler(opcodes, symbols, locations, options); return compiler.process(); }; var _proto10 = JavaScriptCompiler.prototype; _proto10.process = function process() { - var _this8 = this; + var _this9 = this; - this.opcodes.forEach(function (op) { + this.opcodes.forEach(function (op, i) { var opcode = op[0]; + _this9.location = _this9.locations[i]; var arg = op[1]; - if (!_this8[opcode]) { + if (!_this9[opcode]) { throw new Error("unimplemented " + opcode + " on JavaScriptCompiler"); } - _this8[opcode](arg); + _this9[opcode](arg); }); return this.template; } /// Nesting ; _proto10.startBlock = function startBlock(program) { - var block = new InlineBlock(program['symbols']); - this.blocks.push(block); + this.startInlineBlock(program.symbols); }; _proto10.endBlock = function endBlock() { - var template = this.template, - blocks = this.blocks; - var block = blocks.pop(); - template.block.blocks.push(block.toJSON()); + var block = this.endInlineBlock(); + this.template.block.blocks.push(block); }; _proto10.startProgram = function startProgram() { @@ -2988,39 +3093,66 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ ; _proto10.text = function text(content) { - this.push([_wireFormat.Ops.Text, content]); + this.push([1 + /* Append */ + , 1, 0, 0, content]); }; _proto10.append = function append(trusted) { - this.push([_wireFormat.Ops.Append, this.popValue(), trusted]); + this.push([1 + /* Append */ + , +trusted, 0, 0, this.popValue()]); }; _proto10.comment = function comment(value) { - this.push([_wireFormat.Ops.Comment, value]); + this.push([2 + /* Comment */ + , value]); }; - _proto10.modifier = function modifier(name) { + _proto10.modifier = function modifier() { + var name = this.popValue(); var params = this.popValue(); var hash = this.popValue(); - this.push([_wireFormat.Ops.Modifier, name, params, hash]); + this.push([3 + /* Modifier */ + , 0, 0, name, params, hash]); }; _proto10.block = function block(_ref) { - var name = _ref[0], - template = _ref[1], - inverse = _ref[2]; + var template = _ref[0], + inverse = _ref[1]; + var head = this.popValue(); var params = this.popValue(); var hash = this.popValue(); var blocks = this.template.block.blocks; - this.push([_wireFormat.Ops.Block, name, params, hash, blocks[template], blocks[inverse]]); + var namedBlocks; + + if (template === null && inverse === null) { + namedBlocks = null; + } else if (inverse === null) { + namedBlocks = [['default'], [blocks[template]]]; + } else { + namedBlocks = [['default', 'else'], [blocks[template], blocks[inverse]]]; + } // assert(head[]); + + + this.push([5 + /* Block */ + , head, params, hash, namedBlocks]); }; _proto10.openComponent = function openComponent(element) { var tag = this.options && this.options.customizeComponentName ? this.options.customizeComponentName(element.tag) : element.tag; - var component = new ComponentBlock(tag, element['symbols'], element.selfClosing); + var component = new ComponentBlock(tag, element.symbols, element.selfClosing); this.blocks.push(component); }; + _proto10.openNamedBlock = function openNamedBlock(element) { + var block = new NamedBlock(element.tag, element.symbols); + this.blocks.push(block); + }; + _proto10.openElement = function openElement(_ref2) { var element = _ref2[0], simple = _ref2[1]; @@ -3029,12 +3161,16 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ if (element.blockParams.length > 0) { throw new Error("Compile Error: <" + element.tag + "> is not a component and doesn't support block parameters"); } else { - this.push([_wireFormat.Ops.OpenElement, tag, simple]); + this.push([9 + /* OpenElement */ + , tag, simple]); } }; _proto10.flushElement = function flushElement() { - this.push([_wireFormat.Ops.FlushElement]); + this.push([10 + /* FlushElement */ + ]); }; _proto10.closeComponent = function closeComponent(_element) { @@ -3042,9 +3178,17 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ tag = _this$endComponent[0], attrs = _this$endComponent[1], args = _this$endComponent[2], - block = _this$endComponent[3]; + blocks = _this$endComponent[3]; - this.push([_wireFormat.Ops.Component, tag, attrs, args, block]); + this.push([7 + /* Component */ + , tag, attrs, args, blocks]); + }; + + _proto10.closeNamedBlock = function closeNamedBlock(_element) { + var blocks = this.blocks; + var block = blocks.pop(); + this.currentComponent.pushBlock(block.name, block.toJSON()); }; _proto10.closeDynamicComponent = function closeDynamicComponent(_element) { @@ -3053,143 +3197,209 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ args = _this$endComponent2[2], block = _this$endComponent2[3]; - this.push([_wireFormat.Ops.DynamicComponent, this.popValue(), attrs, args, block]); + this.push([7 + /* Component */ + , this.popValue(), attrs, args, block]); }; _proto10.closeElement = function closeElement(_element) { - this.push([_wireFormat.Ops.CloseElement]); + this.push([11 + /* CloseElement */ + ]); }; _proto10.staticAttr = function staticAttr(_ref3) { var name = _ref3[0], namespace = _ref3[1]; var value = this.popValue(); - this.push([_wireFormat.Ops.StaticAttr, name, value, namespace]); + this.push([12 + /* StaticAttr */ + , name, value, namespace]); }; - _proto10.dynamicAttr = function dynamicAttr(_ref4) { + _proto10.staticComponentAttr = function staticComponentAttr(_ref4) { var name = _ref4[0], namespace = _ref4[1]; var value = this.popValue(); - this.push([_wireFormat.Ops.DynamicAttr, name, value, namespace]); + this.push([23 + /* StaticComponentAttr */ + , name, value, namespace]); }; - _proto10.componentAttr = function componentAttr(_ref5) { + _proto10.dynamicAttr = function dynamicAttr(_ref5) { var name = _ref5[0], namespace = _ref5[1]; var value = this.popValue(); - this.push([_wireFormat.Ops.ComponentAttr, name, value, namespace]); + this.push([13 + /* DynamicAttr */ + , name, value, namespace]); }; - _proto10.trustingAttr = function trustingAttr(_ref6) { + _proto10.componentAttr = function componentAttr(_ref6) { var name = _ref6[0], namespace = _ref6[1]; var value = this.popValue(); - this.push([_wireFormat.Ops.TrustingAttr, name, value, namespace]); + this.push([14 + /* ComponentAttr */ + , name, value, namespace]); }; - _proto10.trustingComponentAttr = function trustingComponentAttr(_ref7) { + _proto10.trustingAttr = function trustingAttr(_ref7) { var name = _ref7[0], namespace = _ref7[1]; var value = this.popValue(); - this.push([_wireFormat.Ops.TrustingComponentAttr, name, value, namespace]); + this.push([20 + /* TrustingDynamicAttr */ + , name, value, namespace]); + }; + + _proto10.trustingComponentAttr = function trustingComponentAttr(_ref8) { + var name = _ref8[0], + namespace = _ref8[1]; + var value = this.popValue(); + this.push([21 + /* TrustingComponentAttr */ + , name, value, namespace]); }; _proto10.staticArg = function staticArg(name) { var value = this.popValue(); - this.push([_wireFormat.Ops.StaticArg, name, value]); + this.push([19 + /* StaticArg */ + , name, value]); }; _proto10.dynamicArg = function dynamicArg(name) { var value = this.popValue(); - this.push([_wireFormat.Ops.DynamicArg, name, value]); + this.push([18 + /* DynamicArg */ + , name, value]); }; _proto10.yield = function _yield(to) { var params = this.popValue(); - this.push([_wireFormat.Ops.Yield, to, params]); + this.push([16 + /* Yield */ + , to, params]); }; _proto10.attrSplat = function attrSplat(to) { // consume (and disregard) the value pushed for the // ...attributes attribute this.popValue(); - this.push([_wireFormat.Ops.AttrSplat, to]); + this.push([15 + /* AttrSplat */ + , to]); }; _proto10.debugger = function _debugger(evalInfo) { - this.push([_wireFormat.Ops.Debugger, evalInfo]); + this.push([22 + /* Debugger */ + , evalInfo]); this.template.block.hasEval = true; }; _proto10.hasBlock = function hasBlock(name) { - this.pushValue([_wireFormat.Ops.HasBlock, name]); + this.pushValue([28 + /* HasBlock */ + , [24 + /* GetSymbol */ + , name]]); }; _proto10.hasBlockParams = function hasBlockParams(name) { - this.pushValue([_wireFormat.Ops.HasBlockParams, name]); + this.pushValue([29 + /* HasBlockParams */ + , [24 + /* GetSymbol */ + , name]]); }; _proto10.partial = function partial(evalInfo) { var params = this.popValue(); - this.push([_wireFormat.Ops.Partial, params[0], evalInfo]); + this.push([17 + /* Partial */ + , params[0], evalInfo]); this.template.block.hasEval = true; } /// Expressions ; _proto10.literal = function literal(value) { if (value === undefined) { - this.pushValue([_wireFormat.Ops.Undefined]); + this.pushValue([30 + /* Undefined */ + ]); } else { this.pushValue(value); } }; - _proto10.unknown = function unknown(name) { - this.pushValue([_wireFormat.Ops.Unknown, name]); + _proto10.getPath = function getPath(rest) { + var head = this.popValue(); + this.pushValue([27 + /* GetPath */ + , head, rest]); + }; + + _proto10.getSymbol = function getSymbol(head) { + this.pushValue([24 + /* GetSymbol */ + , head]); }; - _proto10.get = function get(_ref8) { - var head = _ref8[0], - path = _ref8[1]; - this.pushValue([_wireFormat.Ops.Get, head, path]); + _proto10.getFree = function getFree(head) { + this.pushValue([25 + /* GetFree */ + , head]); }; - _proto10.maybeLocal = function maybeLocal(path) { - this.pushValue([_wireFormat.Ops.MaybeLocal, path]); + _proto10.getFreeWithContext = function getFreeWithContext(_ref9) { + var head = _ref9[0], + context = _ref9[1]; + this.pushValue([26 + /* GetContextualFree */ + , head, context]); }; _proto10.concat = function concat() { - this.pushValue([_wireFormat.Ops.Concat, this.popValue()]); + this.pushValue([32 + /* Concat */ + , this.popValue()]); }; - _proto10.helper = function helper(name) { + _proto10.helper = function helper() { + var _this$popLocatedValue = this.popLocatedValue(), + head = _this$popLocatedValue.value, + location = _this$popLocatedValue.location; + var params = this.popValue(); var hash = this.popValue(); - this.pushValue([_wireFormat.Ops.Helper, name, params, hash]); + this.pushValue([31 + /* Call */ + , start(location), end(location), head, params, hash]); } /// Stack Management Opcodes ; _proto10.prepareArray = function prepareArray(size) { - var values = []; + var values$$1 = []; for (var i = 0; i < size; i++) { - values.push(this.popValue()); + values$$1.push(this.popValue()); } - this.pushValue(values); + this.pushValue(values$$1); }; _proto10.prepareObject = function prepareObject(size) { var keys = new Array(size); - var values = new Array(size); + var values$$1 = new Array(size); for (var i = 0; i < size; i++) { keys[i] = this.popValue(); - values[i] = this.popValue(); + values$$1[i] = this.popValue(); } - this.pushValue([keys, values]); + this.pushValue([keys, values$$1]); } /// Utilities ; @@ -3198,20 +3408,42 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ return component.toJSON(); }; - _proto10.push = function push(args) { - while (args[args.length - 1] === null) { - args.pop(); - } + _proto10.startInlineBlock = function startInlineBlock(symbols) { + var block = new InlineBlock(symbols); + this.blocks.push(block); + }; + + _proto10.endInlineBlock = function endInlineBlock() { + var blocks = this.blocks; + var block = blocks.pop(); + return block.toJSON(); + }; + _proto10.push = function push(args) { this.currentBlock.push(args); }; _proto10.pushValue = function pushValue(val) { this.values.push(val); + this.locationStack.push(this.location); + }; + + _proto10.popLocatedValue = function popLocatedValue() { + var value = this.values.pop(); + var location = this.locationStack.pop(); + + if (location === undefined) { + throw new Error('Unbalanced location push and pop'); + } + + return { + value: value, + location: location + }; }; _proto10.popValue = function popValue() { - return this.values.pop(); + return this.popLocatedValue().value; }; (0, _emberBabel.createClass)(JavaScriptCompiler, [{ @@ -3219,9 +3451,36 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ get: function get() { return this.blocks.current; } + }, { + key: "currentComponent", + get: function get() { + var block = this.currentBlock; + + if (block instanceof ComponentBlock) { + return block; + } else { + throw new Error("Expected ComponentBlock on stack, found " + block.constructor.name); + } + } }]); return JavaScriptCompiler; - }(); // There is a small whitelist of namespaced attributes specially + }(); + + function start(location) { + if (location) { + return location.start; + } else { + return -1; + } + } + + function end(location) { + if (location) { + return location.end - location.start; + } else { + return -1; + } + } // There is a small whitelist of namespaced attributes specially // enumerated in // https://www.w3.org/TR/html/syntax.html#attributes-0 // @@ -3261,8 +3520,9 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ var SymbolAllocator = /*#__PURE__*/ function () { - function SymbolAllocator(ops) { + function SymbolAllocator(ops, locations) { this.ops = ops; + this.locations = locations; this.symbolStack = new _util.Stack(); } @@ -3270,46 +3530,55 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ _proto11.process = function process() { var out = []; + var locations = []; var ops = this.ops; for (var i = 0; i < ops.length; i++) { var op = ops[i]; + var location = this.locations[i]; var result = this.dispatch(op); - - if (result === undefined) { - out.push(op); - } else { - out.push(result); - } + out.push(result); + locations.push(location); } - return out; + return { + ops: out, + locations: locations + }; }; _proto11.dispatch = function dispatch(op) { var name = op[0]; var operand = op[1]; - return this[name](operand); + return this[name](operand) || op; }; _proto11.startProgram = function startProgram(op) { - this.symbolStack.push(op['symbols']); + this.symbolStack.push(op.symbols); }; - _proto11.endProgram = function endProgram(_op) { + _proto11.endProgram = function endProgram() { this.symbolStack.pop(); }; _proto11.startBlock = function startBlock(op) { - this.symbolStack.push(op['symbols']); + this.symbolStack.push(op.symbols); + }; + + _proto11.endBlock = function endBlock() { + this.symbolStack.pop(); + }; + + _proto11.openNamedBlock = function openNamedBlock(op) { + this.symbolStack.push(op.symbols); }; - _proto11.endBlock = function endBlock(_op) { + _proto11.closeNamedBlock = function closeNamedBlock(_op) { this.symbolStack.pop(); }; _proto11.flushElement = function flushElement(op) { - this.symbolStack.push(op['symbols']); + this.symbolStack.push(op.symbols); }; _proto11.closeElement = function closeElement(_op) { @@ -3324,57 +3593,43 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ this.symbolStack.pop(); }; - _proto11.attrSplat = function attrSplat(_op) { + _proto11.attrSplat = function attrSplat() { return ['attrSplat', this.symbols.allocateBlock('attrs')]; }; - _proto11.get = function get(op) { - var name = op[0], - rest = op[1]; - - if (name === 0) { - return ['get', [0, rest]]; - } - - if (isLocal(name, this.symbols)) { - var head = this.symbols.get(name); - return ['get', [head, rest]]; - } else if (name[0] === '@') { - var _head = this.symbols.allocateNamed(name); - - return ['get', [_head, rest]]; - } else { - return ['maybeLocal', [name].concat(rest)]; - } + _proto11.getFree = function getFree(name) { + var symbol = this.symbols.allocateFree(name); + return ['getFree', symbol]; }; - _proto11.maybeGet = function maybeGet(op) { - var name = op[0], - rest = op[1]; + _proto11.getArg = function getArg(name) { + var symbol = this.symbols.allocateNamed(name); + return ['getSymbol', symbol]; + }; - if (name === 0) { - return ['get', [0, rest]]; - } + _proto11.getThis = function getThis() { + return ['getSymbol', 0]; + }; - if (isLocal(name, this.symbols)) { - var head = this.symbols.get(name); - return ['get', [head, rest]]; - } else if (name[0] === '@') { - var _head2 = this.symbols.allocateNamed(name); + _proto11.getVar = function getVar(_ref10) { + var name = _ref10[0], + context = _ref10[1]; - return ['get', [_head2, rest]]; - } else if (rest.length === 0) { - return ['unknown', name]; + if (this.symbols.has(name)) { + var symbol = this.symbols.get(name); + return ['getSymbol', symbol]; } else { - return ['maybeLocal', [name].concat(rest)]; + var _symbol = this.symbols.allocateFree(name); + + return ['getFreeWithContext', [_symbol, context]]; } }; - _proto11.yield = function _yield(op) { - if (op === 0) { - throw new Error('Cannot yield to this'); - } + _proto11.getPath = function getPath(rest) { + return ['getPath', rest]; + }; + _proto11.yield = function _yield(op) { return ['yield', this.symbols.allocateBlock(op)]; }; @@ -3398,51 +3653,105 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ return ['hasBlockParams', this.symbols.allocateBlock(op)]; }; - _proto11.partial = function partial(_op) { + _proto11.partial = function partial() { return ['partial', this.symbols.getEvalInfo()]; }; - _proto11.text = function text(_op) {}; - - _proto11.comment = function comment(_op) {}; + _proto11.block = function block(_ref11) { + var template = _ref11[0], + inverse = _ref11[1]; + return ['block', [template, inverse]]; + }; - _proto11.openComponent = function openComponent(_op) {}; + _proto11.modifier = function modifier() { + return ['modifier']; + }; - _proto11.openElement = function openElement(_op) {}; + _proto11.helper = function helper() { + return ['helper']; + }; - _proto11.staticArg = function staticArg(_op) {}; + _proto11.text = function text(content) { + return ['text', content]; + }; - _proto11.dynamicArg = function dynamicArg(_op) {}; + _proto11.comment = function comment(_comment) { + return ['comment', _comment]; + }; - _proto11.staticAttr = function staticAttr(_op) {}; + _proto11.openComponent = function openComponent(element) { + return ['openComponent', element]; + }; - _proto11.trustingAttr = function trustingAttr(_op) {}; + _proto11.openElement = function openElement(_ref12) { + var element = _ref12[0], + simple = _ref12[1]; + return ['openElement', [element, simple]]; + }; - _proto11.trustingComponentAttr = function trustingComponentAttr(_op) {}; + _proto11.staticArg = function staticArg(name) { + return ['staticArg', name]; + }; - _proto11.dynamicAttr = function dynamicAttr(_op) {}; + _proto11.dynamicArg = function dynamicArg(name) { + return ['dynamicArg', name]; + }; - _proto11.componentAttr = function componentAttr(_op) {}; + _proto11.staticAttr = function staticAttr(_ref13) { + var name = _ref13[0], + ns = _ref13[1]; + return ['staticAttr', [name, ns]]; + }; - _proto11.modifier = function modifier(_op) {}; + _proto11.staticComponentAttr = function staticComponentAttr(_ref14) { + var name = _ref14[0], + ns = _ref14[1]; + return ['staticComponentAttr', [name, ns]]; + }; - _proto11.append = function append(_op) {}; + _proto11.trustingAttr = function trustingAttr(_ref15) { + var name = _ref15[0], + ns = _ref15[1]; + return ['trustingAttr', [name, ns]]; + }; - _proto11.block = function block(_op) {}; + _proto11.dynamicAttr = function dynamicAttr(_ref16) { + var name = _ref16[0], + ns = _ref16[1]; + return ['dynamicAttr', [name, ns]]; + }; - _proto11.literal = function literal(_op) {}; + _proto11.componentAttr = function componentAttr(_ref17) { + var name = _ref17[0], + ns = _ref17[1]; + return ['componentAttr', [name, ns]]; + }; - _proto11.helper = function helper(_op) {}; + _proto11.trustingComponentAttr = function trustingComponentAttr(_ref18) { + var name = _ref18[0], + ns = _ref18[1]; + return ['trustingComponentAttr', [name, ns]]; + }; - _proto11.unknown = function unknown(_op) {}; + _proto11.append = function append(trusted) { + return ['append', trusted]; + }; - _proto11.maybeLocal = function maybeLocal(_op) {}; + _proto11.literal = function literal(value) { + return ['literal', value]; + }; - _proto11.prepareArray = function prepareArray(_op) {}; + _proto11.prepareArray = function prepareArray(count) { + return ['prepareArray', count]; + }; - _proto11.prepareObject = function prepareObject(_op) {}; + _proto11.prepareObject = function prepareObject(count) { + return ['prepareObject', count]; + }; - _proto11.concat = function concat(_op) {}; + _proto11.concat = function concat() { + return ['concat']; + }; (0, _emberBabel.createClass)(SymbolAllocator, [{ key: "symbols", @@ -3453,8 +3762,48 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ return SymbolAllocator; }(); - function isLocal(name, symbols) { - return symbols && symbols.has(name); + function locationToOffset(source, line, column) { + var seenLines = 0; + var seenChars = 0; + + while (true) { + if (seenChars === source.length) return null; + var nextLine = source.indexOf('\n', seenChars); + if (nextLine === -1) nextLine = source.length; + + if (seenLines === line) { + if (seenChars + column > nextLine) return null; + return seenChars + column; + } else if (nextLine === -1) { + return null; + } else { + seenLines += 1; + seenChars = nextLine + 1; + } + } + } + + function offsetToLocation(source, offset) { + var seenLines = 0; + var seenChars = 0; + + if (offset > source.length) { + return null; + } + + while (true) { + var nextLine = source.indexOf('\n', seenChars); + + if (offset <= nextLine || nextLine === -1) { + return { + line: seenLines, + column: offset - seenChars + }; + } else { + seenLines += 1; + seenChars = nextLine + 1; + } + } } function isTrustedValue(value) { @@ -3464,72 +3813,85 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ var TemplateCompiler = /*#__PURE__*/ function () { - function TemplateCompiler() { + function TemplateCompiler(source) { + this.source = source; this.templateId = 0; this.templateIds = []; this.opcodes = []; - this.includeMeta = false; + this.locations = []; + this.includeMeta = true; } - TemplateCompiler.compile = function compile(ast, options) { + TemplateCompiler.compile = function compile(ast, source, options) { var templateVisitor = new TemplateVisitor(); templateVisitor.visit(ast); - var compiler = new TemplateCompiler(); - var opcodes = compiler.process(templateVisitor.actions); - var symbols = new SymbolAllocator(opcodes).process(); - return JavaScriptCompiler.process(symbols, ast['symbols'], options); + var compiler = new TemplateCompiler(source); + + var _compiler$process = compiler.process(templateVisitor.actions), + opcodes = _compiler$process.opcodes, + templateLocations = _compiler$process.locations; + + var _process = new SymbolAllocator(opcodes, templateLocations).process(), + ops = _process.ops, + allocationLocations = _process.locations; + + var out = JavaScriptCompiler.process(ops, allocationLocations, ast.symbols, options); + return out; }; var _proto12 = TemplateCompiler.prototype; _proto12.process = function process(actions) { - var _this9 = this; + var _this10 = this; - actions.forEach(function (_ref9) { - var name = _ref9[0], - args = _ref9.slice(1); + actions.forEach(function (_ref19) { + var name = _ref19[0], + args = _ref19[1]; - if (!_this9[name]) { + if (!_this10[name]) { throw new Error("Unimplemented " + name + " on TemplateCompiler"); } - _this9[name].apply(_this9, args); + _this10[name](args); }); - return this.opcodes; + return { + opcodes: this.opcodes, + locations: this.locations + }; }; - _proto12.startProgram = function startProgram(_ref10) { - var program = _ref10[0]; + _proto12.startProgram = function startProgram(_ref20) { + var program = _ref20[0]; this.opcode(['startProgram', program], program); }; _proto12.endProgram = function endProgram() { - this.opcode(['endProgram', null], null); + this.opcode(['endProgram'], null); }; - _proto12.startBlock = function startBlock(_ref11) { - var program = _ref11[0]; + _proto12.startBlock = function startBlock(_ref21) { + var program = _ref21[0]; this.templateId++; this.opcode(['startBlock', program], program); }; _proto12.endBlock = function endBlock() { this.templateIds.push(this.templateId - 1); - this.opcode(['endBlock', null], null); + this.opcode(['endBlock'], null); }; - _proto12.text = function text(_ref12) { - var action = _ref12[0]; + _proto12.text = function text(_ref22) { + var action = _ref22[0]; this.opcode(['text', action.chars], action); }; - _proto12.comment = function comment(_ref13) { - var action = _ref13[0]; + _proto12.comment = function comment(_ref23) { + var action = _ref23[0]; this.opcode(['comment', action.value], action); }; - _proto12.openElement = function openElement(_ref14) { - var action = _ref14[0]; + _proto12.openElement = function openElement(_ref24) { + var action = _ref24[0]; var attributes = action.attributes; var simple = true; @@ -3547,22 +3909,16 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ } var actionIsComponent = false; + var dynamic = destructureDynamicComponent(action); - if (isDynamicComponent(action)) { - var head, rest; - - var _action$tag$split = action.tag.split('.'); - - head = _action$tag$split[0]; - rest = _action$tag$split.slice(1); - - if (head === 'this') { - head = 0; - } - - this.opcode(['get', [head, rest]]); + if (dynamic) { + this.expression(dynamic, "ComponentHead" + /* ComponentHead */ + , action); this.opcode(['openComponent', action], action); actionIsComponent = true; + } else if (isNamedBlock(action)) { + this.opcode(['openNamedBlock', action], action); } else if (isComponent(action)) { this.opcode(['openComponent', action], action); actionIsComponent = true; @@ -3570,33 +3926,38 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ this.opcode(['openElement', [action, simple]], action); } - var typeAttr = null; - var attrs = action.attributes; + if (!isNamedBlock(action)) { + // TODO: Assert no attributes + var typeAttr = null; + var attrs = action.attributes; + + for (var _i2 = 0; _i2 < attrs.length; _i2++) { + if (attrs[_i2].name === 'type') { + typeAttr = attrs[_i2]; + continue; + } - for (var _i2 = 0; _i2 < attrs.length; _i2++) { - if (attrs[_i2].name === 'type') { - typeAttr = attrs[_i2]; - continue; + this.attribute([attrs[_i2]], !simple || actionIsComponent); } - this.attribute([attrs[_i2]], !simple || actionIsComponent); - } + if (typeAttr) { + this.attribute([typeAttr], !simple || actionIsComponent); + } - if (typeAttr) { - this.attribute([typeAttr], !simple || actionIsComponent); - } + for (var _i3 = 0; _i3 < action.modifiers.length; _i3++) { + this.modifier([action.modifiers[_i3]]); + } - for (var _i3 = 0; _i3 < action.modifiers.length; _i3++) { - this.modifier([action.modifiers[_i3]]); + this.opcode(['flushElement', action], null); } - - this.opcode(['flushElement', action], null); }; - _proto12.closeElement = function closeElement(_ref15) { - var action = _ref15[0]; + _proto12.closeElement = function closeElement(_ref25) { + var action = _ref25[0]; - if (isDynamicComponent(action)) { + if (isNamedBlock(action)) { + this.opcode(['closeNamedBlock', action]); + } else if (destructureDynamicComponent(action)) { this.opcode(['closeDynamicComponent', action], action); } else if (isComponent(action)) { this.opcode(['closeComponent', action], action); @@ -3605,8 +3966,8 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ } }; - _proto12.attribute = function attribute(_ref16, isComponent) { - var action = _ref16[0]; + _proto12.attribute = function attribute(_ref26, isComponent) { + var action = _ref26[0]; var name = action.name, value = action.value; var namespace = getAttrNamespace(name); @@ -3625,99 +3986,110 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ var isTrusting = isTrustedValue(value); if (isStatic && name === '...attributes') { - this.opcode(['attrSplat', null], action); - } else if (isStatic && !isComponent) { - this.opcode(['staticAttr', [name, namespace]], action); + this.opcode(['attrSplat'], action); + } else if (isStatic) { + this.opcode(isComponent ? ['staticComponentAttr', [name, namespace]] : ['staticAttr', [name, namespace]], action); } else if (isTrusting) { - this.opcode([isComponent ? 'trustingComponentAttr' : 'trustingAttr', [name, namespace]], action); + this.opcode(isComponent ? ['trustingComponentAttr', [name, namespace]] : ['trustingAttr', [name, namespace]], action); } else if (action.value.type === 'MustacheStatement') { - this.opcode([isComponent ? 'componentAttr' : 'dynamicAttr', [name, null]], action); + this.opcode(isComponent ? ['componentAttr', [name, namespace]] : ['dynamicAttr', [name, namespace]], action); } else { - this.opcode([isComponent ? 'componentAttr' : 'dynamicAttr', [name, namespace]], action); + this.opcode(isComponent ? ['componentAttr', [name, namespace]] : ['dynamicAttr', [name, namespace]], action); } } }; - _proto12.modifier = function modifier(_ref17) { - var action = _ref17[0]; - assertIsSimplePath(action.path, action.loc, 'modifier'); - var parts = action.path.parts; - this.prepareHelper(action); - this.opcode(['modifier', parts[0]], action); + _proto12.modifier = function modifier(_ref27) { + var action = _ref27[0]; + this.prepareHelper(action, 'modifier'); + this.expression(action.path, "ModifierHead" + /* ModifierHead */ + , action); + this.opcode(['modifier'], action); }; - _proto12.mustache = function mustache(_ref18) { - var action = _ref18[0]; - var path = action.path; + _proto12.mustache = function mustache(_ref28) { + var _mustache = _ref28[0]; + var path = _mustache.path; if ((0, _syntax.isLiteral)(path)) { - this.mustacheExpression(action); - this.opcode(['append', !action.escaped], action); + this.expression(_mustache.path, "Expression" + /* Expression */ + , _mustache); + this.opcode(['append', !_mustache.escaped], _mustache); + } else if (path.type !== 'PathExpression') { + throw new _syntax.SyntaxError("Expected PathExpression, got " + path.type, path.loc); } else if (isYield(path)) { - var to = assertValidYield(action); - this.yield(to, action); + var to = assertValidYield(_mustache); + this.yield(to, _mustache); } else if (isPartial(path)) { - var params = assertValidPartial(action); - this.partial(params, action); + var params = assertValidPartial(_mustache); + this.partial(params, _mustache); } else if (isDebugger(path)) { - assertValidDebuggerUsage(action); - this.debugger('debugger', action); + assertValidDebuggerUsage(_mustache); + this.debugger('debugger', _mustache); + } else if (isKeyword(_mustache)) { + this.keyword(_mustache); + this.opcode(['append', !_mustache.escaped], _mustache); + } else if (isHelperInvocation(_mustache)) { + this.prepareHelper(_mustache, 'helper'); + this.expression(_mustache.path, "CallHead" + /* CallHead */ + , _mustache.path); + this.opcode(['helper'], _mustache); + this.opcode(['append', !_mustache.escaped], _mustache); } else { - this.mustacheExpression(action); - this.opcode(['append', !action.escaped], action); + this.expression(_mustache.path, mustacheContext(_mustache.path), _mustache); + this.opcode(['append', !_mustache.escaped], _mustache); } }; - _proto12.block = function block(_ref19) { + _proto12.block = function block(_ref29) { var action /*, index, count*/ - = _ref19[0]; - this.prepareHelper(action); + = _ref29[0]; + this.prepareHelper(action, 'block'); var templateId = this.templateIds.pop(); var inverseId = action.inverse === null ? null : this.templateIds.pop(); - this.opcode(['block', [action.path.parts[0], templateId, inverseId]], action); + this.expression(action.path, "BlockHead" + /* BlockHead */ + , action); + this.opcode(['block', [templateId, inverseId]], action); } /// Internal actions, not found in the original processed actions + // private path(head: string, rest: string[], context: ExpressionContext, loc: AST.BaseNode) { + // if (head[0] === '@') { + // this.argPath(head, rest, loc); + // } else { + // this.varPath(head, rest, context, loc); + // } + // } ; - _proto12.arg = function arg(_ref20) { - var path = _ref20[0]; - - var _path$parts = path.parts, - head = _path$parts[0], - rest = _path$parts.slice(1); + _proto12.argPath = function argPath(head, rest, loc) { + this.opcode(['getArg', head], loc); + this.opcode(['getPath', rest], loc); + }; - this.opcode(['get', ["@" + head, rest]], path); + _proto12.varPath = function varPath(head, rest, context, loc) { + this.opcode(['getVar', [head, context]], loc); + this.opcode(['getPath', rest], loc); }; - _proto12.mustacheExpression = function mustacheExpression(expr) { - var path = expr.path; + _proto12.thisPath = function thisPath(rest, loc) { + this.opcode(['getThis'], loc); + this.opcode(['getPath', rest], loc); + }; + _proto12.expression = function expression(path, context, expr) { if ((0, _syntax.isLiteral)(path)) { this.opcode(['literal', path.value], expr); - } else if (isBuiltInHelper(path)) { - this.builtInHelper(expr); - } else if (isArg(path)) { - this.arg([path]); - } else if (isHelperInvocation(expr)) { - this.prepareHelper(expr); - this.opcode(['helper', path.parts[0]], expr); - } else if (path.this) { - this.opcode(['get', [0, path.parts]], expr); + } else if (path.type !== 'PathExpression') { + throw new _syntax.SyntaxError("Expected PathExpression, got " + path.type, path.loc); + } else if (isKeyword(expr)) { + this.keyword(expr); } else { - var _path$parts2 = path.parts, - head = _path$parts2[0], - parts = _path$parts2.slice(1); - - this.opcode(['maybeGet', [head, parts]], expr); - } // } else if (isLocal(path, this.symbols)) { - // let [head, ...parts] = path.parts; - // this.opcode(['get', [head, parts]], expr); - // } else if (isSimplePath(path)) { - // this.opcode(['unknown', path.parts[0]], expr); - // } else { - // this.opcode(['maybeLocal', path.parts], expr); - // } - + this.path(path, context); + } } /// Internal Syntax ; @@ -3740,45 +4112,52 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ _proto12.partial = function partial(_params, action) { this.prepareParams(action.params); - this.opcode(['partial', null], action); + this.opcode(['partial'], action); }; - _proto12.builtInHelper = function builtInHelper(expr) { - var path = expr.path; + _proto12.keyword = function keyword(action) { + var path = action.path; if (isHasBlock(path)) { - var name = assertValidHasBlockUsage(expr.path.original, expr); - this.hasBlock(name, expr); + var name = assertValidHasBlockUsage(path.original, action); + this.hasBlock(name, action); } else if (isHasBlockParams(path)) { - var _name2 = assertValidHasBlockUsage(expr.path.original, expr); + var _name2 = assertValidHasBlockUsage(path.original, action); - this.hasBlockParams(_name2, expr); + this.hasBlockParams(_name2, action); } } /// Expressions, invoked recursively from prepareParams and prepareHash ; _proto12.SubExpression = function SubExpression(expr) { - if (isBuiltInHelper(expr.path)) { - this.builtInHelper(expr); + if (isKeyword(expr)) { + this.keyword(expr); } else { - this.prepareHelper(expr); - this.opcode(['helper', expr.path.parts[0]], expr); + this.prepareHelper(expr, 'helper'); + this.expression(expr.path, "CallHead" + /* CallHead */ + , expr); + this.opcode(['helper']); } }; _proto12.PathExpression = function PathExpression(expr) { + this.path(expr, "Expression" + /* Expression */ + ); + }; + + _proto12.path = function path(expr, context) { + var _expr$parts = expr.parts, + head = _expr$parts[0], + rest = _expr$parts.slice(1); + if (expr.data) { - this.arg([expr]); + this.argPath("@" + head, rest, expr); + } else if (expr.this) { + this.thisPath(expr.parts, expr); } else { - var _expr$parts = expr.parts, - head = _expr$parts[0], - rest = _expr$parts.slice(1); - - if (expr.this) { - this.opcode(['get', [0, expr.parts]], expr); - } else { - this.opcode(['get', [head, rest]], expr); - } + this.varPath(head, rest, context, expr); } }; @@ -3808,7 +4187,12 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ action = null; } - // TODO: This doesn't really work + if (action) { + this.locations.push(this.location(action)); + } else { + this.locations.push(null); + } + if (this.includeMeta && action) { _opcode.push(this.meta(action)); } @@ -3816,8 +4200,24 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ this.opcodes.push(_opcode); }; - _proto12.prepareHelper = function prepareHelper(expr) { - assertIsSimplePath(expr.path, expr.loc, 'helper'); + _proto12.helperCall = function helperCall(call, node) { + this.prepareHelper(call, 'helper'); + this.expression(call.path, "CallHead" + /* CallHead */ + , node); + this.opcode(['helper'], node); + }; + + _proto12.mustacheCall = function mustacheCall(call) { + this.prepareHelper(call, 'helper'); + this.expression(call.path, "CallHead" + /* CallHead */ + , call); + this.opcode(['helper'], call); + }; + + _proto12.prepareHelper = function prepareHelper(expr, context) { + assertIsSimplePath(expr.path, expr.loc, context); var params = expr.params, hash = expr.hash; this.prepareHash(hash); @@ -3859,39 +4259,43 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ _proto12.prepareAttributeValue = function prepareAttributeValue(value) { // returns the static value if the value is static - switch (value.type) { - case 'TextNode': - this.opcode(['literal', value.chars], value); - return true; - - case 'MustacheStatement': - this.attributeMustache([value]); - return false; - - case 'ConcatStatement': - this.prepareConcatParts(value.parts); - this.opcode(['concat', null], value); - return false; + if (value.type === 'ConcatStatement') { + this.prepareConcatParts(value.parts); + this.opcode(['concat'], value); + return false; + } else { + return this.mustacheAttrValue(value); } }; _proto12.prepareConcatParts = function prepareConcatParts(parts) { for (var i = parts.length - 1; i >= 0; i--) { var part = parts[i]; - - if (part.type === 'MustacheStatement') { - this.attributeMustache([part]); - } else if (part.type === 'TextNode') { - this.opcode(['literal', part.chars], null); - } + this.mustacheAttrValue(part); } this.opcode(['prepareArray', parts.length], null); }; - _proto12.attributeMustache = function attributeMustache(_ref21) { - var action = _ref21[0]; - this.mustacheExpression(action); + _proto12.mustacheAttrValue = function mustacheAttrValue(value) { + if (value.type === 'TextNode') { + this.opcode(['literal', value.chars]); + return true; + } else if (isKeyword(value)) { + this.keyword(value); + } else if (isHelperInvocation(value)) { + this.prepareHelper(value, 'helper'); + this.expression(value.path, "CallHead" + /* CallHead */ + , value); + this.opcode(['helper'], value); + } else { + this.expression(value.path, "AppendSingleId" + /* AppendSingleId */ + , value); + } + + return false; }; _proto12.meta = function meta(node) { @@ -3907,17 +4311,42 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ return ['loc', [source || null, [start.line, start.column], [end.line, end.column]]]; }; + _proto12.location = function location(node) { + var loc = node.loc; + if (!loc) return null; + var source = loc.source, + start = loc.start, + end = loc.end; + var startOffset = locationToOffset(this.source, start.line - 1, start.column); + var endOffset = locationToOffset(this.source, end.line - 1, end.column); + + if (startOffset === null || endOffset === null) { + // Should this be an assertion? + return null; + } + + return { + source: source || null, + start: startOffset, + end: endOffset + }; + }; + return TemplateCompiler; }(); _exports.TemplateCompiler = TemplateCompiler; function isHelperInvocation(mustache) { + if (mustache.type !== 'SubExpression' && mustache.type !== 'MustacheStatement') { + return false; + } + return mustache.params && mustache.params.length > 0 || mustache.hash && mustache.hash.pairs.length > 0; } - function isSimplePath(_ref22) { - var parts = _ref22.parts; + function isSimplePath(_ref30) { + var parts = _ref30.parts; return parts.length === 1; } @@ -3934,45 +4363,97 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ } function isHasBlock(path) { + if (path.type !== 'PathExpression') return false; return path.original === 'has-block'; } function isHasBlockParams(path) { + if (path.type !== 'PathExpression') return false; return path.original === 'has-block-params'; } - function isBuiltInHelper(path) { - return isHasBlock(path) || isHasBlockParams(path); + function isKeyword(node) { + if (isCall(node)) { + return isHasBlock(node.path) || isHasBlockParams(node.path); + } else if (isPath(node)) { + return isHasBlock(node) || isHasBlockParams(node); + } else { + return false; + } + } + + function isCall(node) { + return node.type === 'SubExpression' || node.type === 'MustacheStatement'; } - function isArg(path) { - return !!path['data']; + function isPath(node) { + return node.type === 'PathExpression'; } - function isDynamicComponent(element) { + function destructureDynamicComponent(element) { var open = element.tag.charAt(0); var _element$tag$split = element.tag.split('.'), - maybeLocal = _element$tag$split[0]; + maybeLocal = _element$tag$split[0], + rest = _element$tag$split.slice(1); var isNamedArgument = open === '@'; - var isLocal = element['symbols'].has(maybeLocal); - var isThisPath = element.tag.indexOf('this.') === 0; - return isLocal || isNamedArgument || isThisPath; - } - - function isComponent(element) { - var open = element.tag.charAt(0); - var isPath = element.tag.indexOf('.') > -1; - var isUpperCase = open === open.toUpperCase() && open !== open.toLowerCase(); - return isUpperCase && !isPath || isDynamicComponent(element); - } + var isLocal = element.symbols.has(maybeLocal); + var isThisPath = maybeLocal === 'this'; - function assertIsSimplePath(path, loc, context) { - if (!isSimplePath(path)) { - throw new _syntax.SyntaxError("`" + path.original + "` is not a valid name for a " + context + " on line " + loc.start.line + ".", path.loc); - } - } + if (isLocal) { + return { + type: 'PathExpression', + data: false, + parts: [maybeLocal].concat(rest), + this: false, + original: element.tag, + loc: element.loc + }; + } else if (isNamedArgument) { + return { + type: 'PathExpression', + data: true, + parts: [maybeLocal.slice(1)].concat(rest), + this: false, + original: element.tag, + loc: element.loc + }; + } else if (isThisPath) { + return { + type: 'PathExpression', + data: false, + parts: rest, + this: true, + original: element.tag, + loc: element.loc + }; + } else { + return null; + } + } + + function isComponent(element) { + var open = element.tag.charAt(0); + var isPath = element.tag.indexOf('.') > -1; + var isUpperCase = open === open.toUpperCase() && open !== open.toLowerCase(); + return isUpperCase && !isPath || !!destructureDynamicComponent(element); + } + + function isNamedBlock(element) { + var open = element.tag.charAt(0); + return open === ':'; + } + + function assertIsSimplePath(path, loc, context) { + if (path.type !== 'PathExpression') { + throw new _syntax.SyntaxError("`" + path.type + "` is not a valid " + context + " on line " + loc.start.line + ".", path.loc); + } + + if (!isSimplePath(path)) { + throw new _syntax.SyntaxError("`" + path.original + "` is not a valid name for a " + context + " on line " + loc.start.line + ".", path.loc); + } + } function assertValidYield(statement) { var pairs = statement.hash.pairs; @@ -4044,12 +4525,29 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ } } + function mustacheContext(body) { + if (body.type === 'PathExpression') { + if (body.parts.length > 1 || body.data) { + return "Expression" + /* Expression */ + ; + } else { + return "AppendSingleId" + /* AppendSingleId */ + ; + } + } else { + return "Expression" + /* Expression */ + ; + } + } + var defaultId = function () { if (typeof _nodeModule.require === 'function') { try { - /* tslint:disable:no-require-imports */ + // eslint-disable-next-line @typescript-eslint/no-require-imports var crypto = (0, _nodeModule.require)('crypto'); - /* tslint:enable:no-require-imports */ var idFn = function idFn(src) { var hash = crypto.createHash('sha1'); @@ -4083,7 +4581,7 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ var _options = options, meta = _options.meta; - var _TemplateCompiler$com = TemplateCompiler.compile(ast, options), + var _TemplateCompiler$com = TemplateCompiler.compile(ast, string, options), block = _TemplateCompiler$com.block; var idFn = options.id || defaultId; @@ -4096,2029 +4594,4776 @@ define("@glimmer/compiler", ["exports", "ember-babel", "node-module", "@glimmer/ return JSON.stringify(templateJSONObject); } -}); -define("@glimmer/syntax", ["exports", "ember-babel", "simple-html-tokenizer", "@glimmer/util", "handlebars"], function (_exports, _emberBabel, _simpleHtmlTokenizer, _util, _handlebars) { - "use strict"; - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.preprocess = preprocess; - _exports.cannotRemoveNode = cannotRemoveNode; - _exports.cannotReplaceNode = cannotReplaceNode; - _exports.cannotReplaceOrRemoveInKeyHandlerYet = cannotReplaceOrRemoveInKeyHandlerYet; - _exports.traverse = traverse; - _exports.print = build; - _exports.isLiteral = isLiteral; - _exports.printLiteral = printLiteral; - _exports.SyntaxError = _exports.Walker = _exports.TraversalError = _exports.builders = _exports.AST = void 0; + var VariableKind; + + (function (VariableKind) { + VariableKind["Local"] = "Local"; + VariableKind["Free"] = "Free"; + VariableKind["Arg"] = "Arg"; + VariableKind["Block"] = "Block"; + VariableKind["This"] = "This"; + })(VariableKind || (VariableKind = {})); + + function normalizeStatement(statement) { + if (Array.isArray(statement)) { + if (statementIsExpression(statement)) { + return normalizeAppendExpression(statement, "AppendSingleId" + /* AppendSingleId */ + ); + } else if (isSugaryArrayStatement(statement)) { + return normalizeSugaryArrayStatement(statement); + } else { + return normalizeVerboseStatement(statement); + } + } else if (typeof statement === 'string') { + return { + kind: "AppendPath" + /* AppendPath */ + , + path: normalizeDottedPath(statement), + trusted: false + }; + } else { + throw (0, _util.assertNever)(statement); + } + } - function buildMustache(path, params, hash, raw, loc) { - if (typeof path === 'string') { - path = buildPath(path); + function isSugaryArrayStatement(statement) { + if (Array.isArray(statement) && typeof statement[0] === 'string') { + switch (statement[0][0]) { + case '(': + case '#': + case '<': + return true; + + default: + return false; + } } - return { - type: 'MustacheStatement', - path: path, - params: params || [], - hash: hash || buildHash([]), - escaped: !raw, - loc: buildLoc(loc || null) - }; + return false; } - function buildBlock(path, params, hash, program, inverse, loc) { - return { - type: 'BlockStatement', - path: buildPath(path), - params: params || [], - hash: hash || buildHash([]), - program: program || null, - inverse: inverse || null, - loc: buildLoc(loc || null) - }; - } + function normalizeSugaryArrayStatement(statement) { + var name = statement[0]; - function buildElementModifier(path, params, hash, loc) { - return { - type: 'ElementModifierStatement', - path: buildPath(path), - params: params || [], - hash: hash || buildHash([]), - loc: buildLoc(loc || null) - }; - } + switch (name[0]) { + case '(': + { + var params = null; + var hash = null; + + if (statement.length === 3) { + params = normalizeParams(statement[1]); + hash = normalizeHash(statement[2]); + } else if (statement.length === 2) { + if (Array.isArray(statement[1])) { + params = normalizeParams(statement[1]); + } else { + hash = normalizeHash(statement[1]); + } + } - function buildPartial(name, params, hash, indent, loc) { - return { - type: 'PartialStatement', - name: name, - params: params || [], - hash: hash || buildHash([]), - indent: indent || '', - strip: { - open: false, - close: false - }, - loc: buildLoc(loc || null) - }; - } + return { + kind: "Call" + /* Call */ + , + path: normalizeCallHead(name), + params: params, + hash: hash, + trusted: false + }; + } - function buildComment(value, loc) { - return { - type: 'CommentStatement', - value: value, - loc: buildLoc(loc || null) - }; + case '#': + { + var _normalizeBuilderBloc = normalizeBuilderBlockStatement(statement), + path = _normalizeBuilderBloc.head, + _params2 = _normalizeBuilderBloc.params, + _hash = _normalizeBuilderBloc.hash, + blocks = _normalizeBuilderBloc.blocks, + blockParams = _normalizeBuilderBloc.blockParams; + + return { + kind: "Block" + /* Block */ + , + path: path, + params: _params2, + hash: _hash, + blocks: blocks, + blockParams: blockParams + }; + } + + case '<': + { + var attrs = (0, _util.dict)(); + var block = []; + + if (statement.length === 3) { + attrs = normalizeAttrs(statement[1]); + block = normalizeBlock(statement[2]); + } else if (statement.length === 2) { + if (Array.isArray(statement[1])) { + block = normalizeBlock(statement[1]); + } else { + attrs = normalizeAttrs(statement[1]); + } + } + + return { + kind: "Element" + /* Element */ + , + name: extractElement(name), + attrs: attrs, + block: block + }; + } + + default: + throw new Error("Unreachable " + JSON.stringify(statement) + " in normalizeSugaryArrayStatement"); + } } - function buildMustacheComment(value, loc) { - return { - type: 'MustacheCommentStatement', - value: value, - loc: buildLoc(loc || null) - }; + function normalizeVerboseStatement(statement) { + switch (statement[0]) { + case 0 + /* Literal */ + : + { + return { + kind: "Literal" + /* Literal */ + , + value: statement[1] + }; + } + + case 2 + /* Append */ + : + { + return normalizeAppendExpression(statement[1], "AppendSingleId" + /* AppendSingleId */ + , statement[2]); + } + + case 3 + /* Modifier */ + : + { + return { + kind: "Modifier" + /* Modifier */ + , + params: normalizeParams(statement[1]), + hash: normalizeHash(statement[2]) + }; + } + + case 4 + /* DynamicComponent */ + : + { + return { + kind: "DynamicComponent" + /* DynamicComponent */ + , + expr: normalizeExpression(statement[1]), + hash: normalizeHash(statement[2]), + block: normalizeBlock(statement[3]) + }; + } + + case 1 + /* Comment */ + : + { + return { + kind: "Comment" + /* Comment */ + , + value: statement[1] + }; + } + } } - function buildConcat(parts, loc) { - return { - type: 'ConcatStatement', - parts: parts || [], - loc: buildLoc(loc || null) - }; + function extractBlockHead(name) { + var result = name.match(/^#(.*)$/); + + if (result === null) { + throw new Error("Unexpected missing # in block head"); + } + + return normalizeDottedPath(result[1]); } - function buildElement(tag, attributes, modifiers, children, comments, blockParams, loc) { - // this is used for backwards compat prior to `blockParams` being added to the AST - if (Array.isArray(comments)) { - if (isBlockParms(comments)) { - blockParams = comments; - comments = []; - } else if (isLoc(blockParams)) { - loc = blockParams; - blockParams = []; - } - } else if (isLoc(comments)) { - // this is used for backwards compat prior to `comments` being added to the AST - loc = comments; - comments = []; - } else if (isLoc(blockParams)) { - loc = blockParams; - blockParams = []; - } // this is used for backwards compat, prior to `selfClosing` being part of the ElementNode AST + function normalizeCallHead(name) { + var result = name.match(/^\((.*)\)$/); + if (result === null) { + throw new Error("Unexpected missing () in call head"); + } - var selfClosing = false; + return normalizeDottedPath(result[1]); + } - if (typeof tag === 'object') { - selfClosing = tag.selfClosing; - tag = tag.name; + function normalizePath(head, tail) { + if (tail === void 0) { + tail = []; } + var pathHead = normalizePathHead(head); return { - type: 'ElementNode', - tag: tag || '', - selfClosing: selfClosing, - attributes: attributes || [], - blockParams: blockParams || [], - modifiers: modifiers || [], - comments: comments || [], - children: children || [], - loc: buildLoc(loc || null) + variable: pathHead, + tail: tail }; } - function buildAttr(name, value, loc) { + function normalizeDottedPathExpression(whole) { return { - type: 'AttrNode', - name: name, - value: value, - loc: buildLoc(loc || null) + type: "Get" + /* Get */ + , + path: normalizeDottedPath(whole) }; } - function buildText(chars, loc) { - return { - type: 'TextNode', - chars: chars || '', - loc: buildLoc(loc || null) - }; - } // Expressions + function normalizeDottedPath(whole) { + var _normalizePathHead = normalizePathHead(whole), + kind = _normalizePathHead.kind, + rest = _normalizePathHead.name; + var _rest$split = rest.split('.'), + name = _rest$split[0], + tail = _rest$split.slice(1); - function buildSexpr(path, params, hash, loc) { return { - type: 'SubExpression', - path: buildPath(path), - params: params || [], - hash: hash || buildHash([]), - loc: buildLoc(loc || null) + variable: { + kind: kind, + name: name + }, + tail: tail }; } - function buildPath(original, loc) { - if (typeof original !== 'string') return original; - var parts = original.split('.'); - var thisHead = false; + function normalizePathHead(whole) { + var kind; + var name; - if (parts[0] === 'this') { - thisHead = true; - parts = parts.slice(1); + if (whole.match(/^this(\.|$)/)) { + return { + kind: VariableKind.This, + name: whole + }; + } + + switch (whole[0]) { + case '^': + kind = VariableKind.Free; + name = whole.slice(1); + break; + + case '@': + kind = VariableKind.Arg; + name = whole.slice(1); + break; + + case '&': + kind = VariableKind.Block; + name = whole.slice(1); + break; + + default: + kind = VariableKind.Local; + name = whole; } return { - type: 'PathExpression', - original: original, - this: thisHead, - parts: parts, - data: false, - loc: buildLoc(loc || null) + kind: kind, + name: name }; } - function buildLiteral(type, value, loc) { + function normalizeBuilderBlockStatement(statement) { + var head = statement[0]; + var blocks = (0, _util.dict)(); + var params = null; + var hash = null; + var blockParams = null; + + if (statement.length === 2) { + blocks = normalizeBlocks(statement[1]); + } else if (statement.length === 3) { + if (Array.isArray(statement[1])) { + params = normalizeParams(statement[1]); + } else { + var _normalizeBlockHash = normalizeBlockHash(statement[1]); + + hash = _normalizeBlockHash.hash; + blockParams = _normalizeBlockHash.blockParams; + } + + blocks = normalizeBlocks(statement[2]); + } else if (statement.length === 4) { + params = normalizeParams(statement[1]); + + var _normalizeBlockHash2 = normalizeBlockHash(statement[2]); + + hash = _normalizeBlockHash2.hash; + blockParams = _normalizeBlockHash2.blockParams; + blocks = normalizeBlocks(statement[3]); + } + return { - type: type, - value: value, - original: value, - loc: buildLoc(loc || null) + head: extractBlockHead(head), + params: params, + hash: hash, + blockParams: blockParams, + blocks: blocks }; - } // Miscellaneous + } + function normalizeBlockHash(hash) { + if (hash === null) { + return { + hash: null, + blockParams: null + }; + } - function buildHash(pairs, loc) { + var out = null; + var blockParams = null; + entries(hash, function (key, value) { + if (key === 'as') { + blockParams = Array.isArray(value) ? value : [value]; + } else { + out = out || (0, _util.dict)(); + out[key] = normalizeExpression(value); + } + }); return { - type: 'Hash', - pairs: pairs || [], - loc: buildLoc(loc || null) + hash: out, + blockParams: blockParams }; } - function buildPair(key, value, loc) { - return { - type: 'HashPair', - key: key, - value: value, - loc: buildLoc(loc || null) - }; + function entries(dict$$1, callback) { + Object.keys(dict$$1).forEach(function (key) { + var value = dict$$1[key]; + callback(key, value); + }); } - function buildProgram(body, blockParams, loc) { - return { - type: 'Program', - body: body || [], - blockParams: blockParams || [], - loc: buildLoc(loc || null) - }; + function normalizeBlocks(value) { + if (Array.isArray(value)) { + return { + default: normalizeBlock(value) + }; + } else { + return mapObject(value, normalizeBlock); + } } - function buildSource(source) { - return source || null; + function normalizeBlock(block) { + return block.map(function (s) { + return normalizeStatement(s); + }); } - function buildPosition(line, column) { - return { - line: line, - column: column - }; + function normalizeAttrs(attrs) { + return mapObject(attrs, function (a) { + return normalizeAttr(a).expr; + }); } - var SYNTHETIC = { - source: '(synthetic)', - start: { - line: 1, - column: 0 - }, - end: { - line: 1, - column: 0 - } - }; - - function buildLoc() { - for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { - args[_key] = arguments[_key]; - } - - if (args.length === 1) { - var loc = args[0]; - - if (loc && typeof loc === 'object') { - return { - source: buildSource(loc.source), - start: buildPosition(loc.start.line, loc.start.column), - end: buildPosition(loc.end.line, loc.end.column) - }; - } else { - return SYNTHETIC; - } + function normalizeAttr(attr) { + if (attr === 'splat') { + return { + expr: "Splat" + /* Splat */ + , + trusted: false + }; } else { - var startLine = args[0], - startColumn = args[1], - endLine = args[2], - endColumn = args[3], - source = args[4]; + var expr = normalizeExpression(attr); return { - source: buildSource(source), - start: buildPosition(startLine, startColumn), - end: buildPosition(endLine, endColumn) + expr: expr, + trusted: false }; } } - function isBlockParms(arr) { - return arr[0] === 'string'; + function mapObject(object, callback) { + var out = (0, _util.dict)(); + Object.keys(object).forEach(function (k) { + out[k] = callback(object[k], k); + }); + return out; } - function isLoc(item) { - return !Array.isArray(item); + function extractElement(input) { + var match = input.match(/^<([a-z0-9\-][a-zA-Z0-9\-]*)>$/); + return match ? match[1] : null; } - var b = { - mustache: buildMustache, - block: buildBlock, - partial: buildPartial, - comment: buildComment, - mustacheComment: buildMustacheComment, - element: buildElement, - elementModifier: buildElementModifier, - attr: buildAttr, - text: buildText, - sexpr: buildSexpr, - path: buildPath, - concat: buildConcat, - hash: buildHash, - pair: buildPair, - literal: buildLiteral, - program: buildProgram, - loc: buildLoc, - pos: buildPosition, - string: literal('StringLiteral'), - boolean: literal('BooleanLiteral'), - number: literal('NumberLiteral'), - undefined: function (_undefined) { - function undefined() { - return _undefined.apply(this, arguments); - } - - undefined.toString = function () { - return _undefined.toString(); - }; - - return undefined; - }(function () { - return buildLiteral('UndefinedLiteral', undefined); - }), - null: function _null() { - return buildLiteral('NullLiteral', null); + function normalizeAppendExpression(expression, _context, forceTrusted) { + if (forceTrusted === void 0) { + forceTrusted = false; } - }; - _exports.builders = b; - - function literal(type) { - return function (value) { - return buildLiteral(type, value); - }; - } - /** - * Subclass of `Error` with additional information - * about location of incorrect markup. - */ + if (expression === null || expression === undefined) { + return { + expr: { + type: "Literal" + /* Literal */ + , + value: expression + }, + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: true + }; + } else if (Array.isArray(expression)) { + switch (expression[0]) { + case 0 + /* Literal */ + : + return { + expr: { + type: "Literal" + /* Literal */ + , + value: expression[1] + }, + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: true + }; - var SyntaxError = function () { - SyntaxError.prototype = Object.create(Error.prototype); - SyntaxError.prototype.constructor = SyntaxError; + case 5 + /* Get */ + : + { + var path = normalizePath(expression[1], expression[2]); + var expr = { + type: "Get" + /* Get */ + , + path: path + }; - function SyntaxError(message, location) { - var error = Error.call(this, message); - this.message = message; - this.stack = error.stack; - this.location = location; - } + if (path.tail.length === 0) { + return { + path: path, + kind: "AppendPath" + /* AppendPath */ + , + trusted: forceTrusted + }; + } else { + return { + expr: expr, + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: forceTrusted + }; + } + } - return SyntaxError; - }(); // Regex to validate the identifier for block parameters. - // Based on the ID validation regex in Handlebars. + case 6 + /* Concat */ + : + { + var _expr = { + type: "Concat" + /* Concat */ + , + params: normalizeParams(expression.slice(1)) + }; + return { + expr: _expr, + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: forceTrusted + }; + } + case 7 + /* HasBlock */ + : + return { + expr: { + type: "HasBlock" + /* HasBlock */ + , + name: expression[1] + }, + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: forceTrusted + }; - _exports.SyntaxError = SyntaxError; - var ID_INVERSE_PATTERN = /[!"#%-,\.\/;->@\[-\^`\{-~]/; // Checks the element's attributes to see if it uses block params. - // If it does, registers the block params with the program and - // removes the corresponding attributes from the element. + case 8 + /* HasBlockParams */ + : + return { + expr: { + type: "HasBlockParams" + /* HasBlockParams */ + , + name: expression[1] + }, + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: forceTrusted + }; - function parseElementBlockParams(element) { - var params = parseBlockParams(element); - if (params) element.blockParams = params; - } + default: + { + if (isBuilderCallExpression(expression)) { + return { + expr: normalizeCallExpression(expression), + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: forceTrusted + }; + } else { + throw new Error("Unexpected array in expression position (wasn't a tuple expression and " + expression[0] + " isn't wrapped in parens, so it isn't a call): " + JSON.stringify(expression)); + } + } + // BuilderCallExpression + } + } else if (typeof expression !== 'object') { + switch (typeof expression) { + case 'string': + { + var _expr2 = normalizeDottedPathExpression(expression); + + if (_expr2.path.tail.length === 0) { + return { + path: _expr2.path, + kind: "AppendPath" + /* AppendPath */ + , + trusted: forceTrusted + }; + } else { + return { + expr: _expr2, + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: forceTrusted + }; + } + } - function parseBlockParams(element) { - var l = element.attributes.length; - var attrNames = []; + case 'boolean': + case 'number': + return { + expr: { + type: "Literal" + /* Literal */ + , + value: expression + }, + kind: "AppendExpr" + /* AppendExpr */ + , + trusted: true + }; - for (var i = 0; i < l; i++) { - attrNames.push(element.attributes[i].name); + default: + throw (0, _util.assertNever)(expression); + } + } else { + throw (0, _util.assertNever)(expression); } + } - var asIndex = attrNames.indexOf('as'); + function normalizeExpression(expression) { + if (expression === null || expression === undefined) { + return { + type: "Literal" + /* Literal */ + , + value: expression + }; + } else if (Array.isArray(expression)) { + switch (expression[0]) { + case 0 + /* Literal */ + : + return { + type: "Literal" + /* Literal */ + , + value: expression[1] + }; - if (asIndex !== -1 && l > asIndex && attrNames[asIndex + 1].charAt(0) === '|') { - // Some basic validation, since we're doing the parsing ourselves - var paramsString = attrNames.slice(asIndex).join(' '); + case 5 + /* Get */ + : + { + var path = normalizePath(expression[1], expression[2]); + var expr = { + type: "Get" + /* Get */ + , + path: path + }; + return expr; + } - if (paramsString.charAt(paramsString.length - 1) !== '|' || paramsString.match(/\|/g).length !== 2) { - throw new SyntaxError("Invalid block parameters syntax: '" + paramsString + "'", element.loc); - } + case 6 + /* Concat */ + : + { + var _expr3 = { + type: "Concat" + /* Concat */ + , + params: normalizeParams(expression.slice(1)) + }; + return _expr3; + } - var params = []; + case 7 + /* HasBlock */ + : + return { + type: "HasBlock" + /* HasBlock */ + , + name: expression[1] + }; - for (var _i = asIndex + 1; _i < l; _i++) { - var param = attrNames[_i].replace(/\|/g, ''); + case 8 + /* HasBlockParams */ + : + return { + type: "HasBlockParams" + /* HasBlockParams */ + , + name: expression[1] + }; - if (param !== '') { - if (ID_INVERSE_PATTERN.test(param)) { - throw new SyntaxError("Invalid identifier for block parameters: '" + param + "' in '" + paramsString + "'", element.loc); + default: + { + if (isBuilderCallExpression(expression)) { + return normalizeCallExpression(expression); + } else { + throw new Error("Unexpected array in expression position (wasn't a tuple expression and " + expression[0] + " isn't wrapped in parens, so it isn't a call): " + JSON.stringify(expression)); + } } - - params.push(param); - } + // BuilderCallExpression } + } else if (typeof expression !== 'object') { + switch (typeof expression) { + case 'string': + { + return normalizeDottedPathExpression(expression); + } - if (params.length === 0) { - throw new SyntaxError("Cannot use zero block parameters: '" + paramsString + "'", element.loc); + case 'boolean': + case 'number': + return { + type: "Literal" + /* Literal */ + , + value: expression + }; + + default: + throw (0, _util.assertNever)(expression); } + } else { + throw (0, _util.assertNever)(expression); + } + } - element.attributes = element.attributes.slice(0, asIndex); - return params; + function statementIsExpression(statement) { + if (!Array.isArray(statement)) { + return false; } - return null; - } + var name = statement[0]; - function childrenFor(node) { - switch (node.type) { - case 'Program': - return node.body; + if (typeof name === 'number') { + switch (name) { + case 0 + /* Literal */ + : + case 5 + /* Get */ + : + case 6 + /* Concat */ + : + case 7 + /* HasBlock */ + : + case 8 + /* HasBlockParams */ + : + return true; - case 'ElementNode': - return node.children; + default: + return false; + } + } + + if (name[0] === '(') { + return true; } + + return false; } - function appendChild(parent, node) { - childrenFor(parent).push(node); + function isBuilderCallExpression(value) { + return typeof value[0] === 'string' && value[0][0] === '('; } - function isLiteral(path) { - return path.type === 'StringLiteral' || path.type === 'BooleanLiteral' || path.type === 'NumberLiteral' || path.type === 'NullLiteral' || path.type === 'UndefinedLiteral'; + function normalizeParams(input) { + return input.map(normalizeExpression); } - function printLiteral(literal) { - if (literal.type === 'UndefinedLiteral') { - return 'undefined'; - } else { - return JSON.stringify(literal.value); - } + function normalizeHash(input) { + if (input === null) return null; + return mapObject(input, normalizeExpression); } - var entityParser = new _simpleHtmlTokenizer.EntityParser(_simpleHtmlTokenizer.HTML5NamedCharRefs); + function normalizeCallExpression(expr) { + switch (expr.length) { + case 1: + return { + type: "Call" + /* Call */ + , + path: normalizeCallHead(expr[0]), + params: null, + hash: null + }; - var Parser = + case 2: + { + if (Array.isArray(expr[1])) { + return { + type: "Call" + /* Call */ + , + path: normalizeCallHead(expr[0]), + params: normalizeParams(expr[1]), + hash: null + }; + } else { + return { + type: "Call" + /* Call */ + , + path: normalizeCallHead(expr[0]), + params: null, + hash: normalizeHash(expr[1]) + }; + } + } + + case 3: + return { + type: "Call" + /* Call */ + , + path: normalizeCallHead(expr[0]), + params: normalizeParams(expr[1]), + hash: normalizeHash(expr[2]) + }; + } + } + + var ProgramSymbols = /*#__PURE__*/ function () { - function Parser(source) { - this.elementStack = []; - this.currentAttribute = null; - this.currentNode = null; - this.tokenizer = new _simpleHtmlTokenizer.EventedTokenizer(this, entityParser); - this.source = source.split(/(?:\r\n?|\n)/g); + function ProgramSymbols() { + this._freeVariables = []; + this._symbols = ['this']; + this.top = this; } - var _proto = Parser.prototype; + var _proto13 = ProgramSymbols.prototype; - _proto.acceptNode = function acceptNode(node) { - return this[node.type](node); + _proto13.toSymbols = function toSymbols() { + return this._symbols.slice(1); }; - _proto.currentElement = function currentElement() { - return this.elementStack[this.elementStack.length - 1]; + _proto13.toUpvars = function toUpvars() { + return this._freeVariables; }; - _proto.sourceForNode = function sourceForNode(node, endNode) { - var firstLine = node.loc.start.line - 1; - var currentLine = firstLine - 1; - var firstColumn = node.loc.start.column; - var string = []; - var line; - var lastLine; - var lastColumn; + _proto13.freeVar = function freeVar(name) { + return addString(this._freeVariables, name); + }; - if (endNode) { - lastLine = endNode.loc.end.line - 1; - lastColumn = endNode.loc.end.column; - } else { - lastLine = node.loc.end.line - 1; - lastColumn = node.loc.end.column; - } + _proto13.block = function block(name) { + return this.symbol(name); + }; - while (currentLine < lastLine) { - currentLine++; - line = this.source[currentLine]; + _proto13.arg = function arg(name) { + return addString(this._symbols, name); + }; - if (currentLine === firstLine) { - if (firstLine === lastLine) { - string.push(line.slice(firstColumn, lastColumn)); - } else { - string.push(line.slice(firstColumn)); - } - } else if (currentLine === lastLine) { - string.push(line.slice(0, lastColumn)); + _proto13.local = function local(name) { + throw new Error("No local " + name + " was found. Maybe you meant ^" + name + "?"); + }; + + _proto13.this = function _this() { + return 0; + }; + + _proto13.hasLocal = function hasLocal(_name) { + return false; + } // any symbol + ; + + _proto13.symbol = function symbol(name) { + return addString(this._symbols, name); + }; + + _proto13.child = function child(locals) { + return new LocalSymbols(this, locals); + }; + + return ProgramSymbols; + }(); + + _exports.ProgramSymbols = ProgramSymbols; + + var LocalSymbols = + /*#__PURE__*/ + function () { + function LocalSymbols(parent, locals) { + this.parent = parent; + this.locals = (0, _util.dict)(); + + for (var _iterator = locals, _isArray = Array.isArray(_iterator), _i4 = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref31; + + if (_isArray) { + if (_i4 >= _iterator.length) break; + _ref31 = _iterator[_i4++]; } else { - string.push(line); + _i4 = _iterator.next(); + if (_i4.done) break; + _ref31 = _i4.value; } + + var _local = _ref31; + this.locals[_local] = parent.top.symbol(_local); } + } - return string.join('\n'); + var _proto14 = LocalSymbols.prototype; + + _proto14.freeVar = function freeVar(name) { + return this.parent.freeVar(name); }; - (0, _emberBabel.createClass)(Parser, [{ - key: "currentAttr", - get: function get() { - return this.currentAttribute; - } - }, { - key: "currentTag", - get: function get() { - var node = this.currentNode; - return node; - } - }, { - key: "currentStartTag", - get: function get() { - var node = this.currentNode; - return node; + _proto14.arg = function arg(name) { + return this.parent.arg(name); + }; + + _proto14.block = function block(name) { + return this.parent.block(name); + }; + + _proto14.local = function local(name) { + if (name in this.locals) { + return this.locals[name]; + } else { + return this.parent.local(name); } - }, { - key: "currentEndTag", - get: function get() { - var node = this.currentNode; - return node; + }; + + _proto14.this = function _this() { + return this.parent.this(); + }; + + _proto14.hasLocal = function hasLocal(name) { + if (name in this.locals) { + return true; + } else { + return this.parent.hasLocal(name); } - }, { - key: "currentComment", + }; + + _proto14.child = function child(locals) { + return new LocalSymbols(this, locals); + }; + + (0, _emberBabel.createClass)(LocalSymbols, [{ + key: "paramSymbols", get: function get() { - var node = this.currentNode; - return node; + return (0, _util.values)(this.locals); } }, { - key: "currentData", + key: "top", get: function get() { - var node = this.currentNode; - return node; + return this.parent.top; } }]); - return Parser; + return LocalSymbols; }(); - var HandlebarsNodeVisitors = - /*#__PURE__*/ - function (_Parser) { - (0, _emberBabel.inheritsLoose)(HandlebarsNodeVisitors, _Parser); + function addString(array, item) { + var index = array.indexOf(item); - function HandlebarsNodeVisitors() { - var _this; + if (index === -1) { + index = array.length; + array.push(item); + return index; + } else { + return index; + } + } - _this = _Parser.apply(this, arguments) || this; - _this.cursorCount = 0; - return _this; + function unimpl(message) { + return new Error("unimplemented " + message); + } + + function buildStatements(statements, symbols) { + var out = []; + statements.forEach(function (s) { + return out.push.apply(out, buildStatement(normalizeStatement(s), symbols)); + }); + return out; + } + + function buildNormalizedStatements(statements, symbols) { + var out = []; + statements.forEach(function (s) { + return out.push.apply(out, buildStatement(s, symbols)); + }); + return out; + } + + function buildStatement(normalized, symbols) { + if (symbols === void 0) { + symbols = new ProgramSymbols(); } - var _proto2 = HandlebarsNodeVisitors.prototype; + switch (normalized.kind) { + case "AppendPath" + /* AppendPath */ + : + { + return [[1 + /* Append */ + , +normalized.trusted, 0, 0, buildPath(normalized.path, "AppendSingleId" + /* AppendSingleId */ + , symbols)]]; + } - _proto2.cursor = function cursor() { - return "%cursor:" + this.cursorCount++ + "%"; - }; + case "AppendExpr" + /* AppendExpr */ + : + { + return [[1 + /* Append */ + , +normalized.trusted, 0, 0, buildExpression(normalized.expr, "Expression" + /* Expression */ + , symbols)]]; + } - _proto2.Program = function Program(program) { - var body = []; - this.cursorCount = 0; - var node = b.program(body, program.blockParams, program.loc); - var i, - l = program.body.length; - this.elementStack.push(node); + case "Call" + /* Call */ + : + { + var path = normalized.path, + params = normalized.params, + hash = normalized.hash, + trusted = normalized.trusted; + var builtParams = params ? buildParams(params, symbols) : []; + var builtHash = hash ? buildHash(hash, symbols) : null; + var builtExpr = buildPath(path, "CallHead" + /* CallHead */ + , symbols); + return [[1 + /* Append */ + , +trusted, 0, 0, [31 + /* Call */ + , 0, 0, builtExpr, builtParams, builtHash]]]; + } - if (l === 0) { - return this.elementStack.pop(); - } + case "Literal" + /* Literal */ + : + { + return [[1 + /* Append */ + , 1, 0, 0, normalized.value]]; + } - for (i = 0; i < l; i++) { - this.acceptNode(program.body[i]); - } // Ensure that that the element stack is balanced properly. + case "Comment" + /* Comment */ + : + { + return [[2 + /* Comment */ + , normalized.value]]; + } + case "Block" + /* Block */ + : + { + var blocks = buildBlocks(normalized.blocks, normalized.blockParams, symbols); - var poppedNode = this.elementStack.pop(); + var _hash2 = buildHash(normalized.hash, symbols); - if (poppedNode !== node) { - var elementNode = poppedNode; - throw new SyntaxError('Unclosed element `' + elementNode.tag + '` (on line ' + elementNode.loc.start.line + ').', elementNode.loc); - } + var _params3 = buildParams(normalized.params, symbols); - return node; - }; + var _path = buildPath(normalized.path, "BlockHead" + /* BlockHead */ + , symbols); - _proto2.BlockStatement = function BlockStatement(block) { - if (this.tokenizer['state'] === 'comment') { - this.appendToCommentData(this.sourceForNode(block)); - return; - } + return [[5 + /* Block */ + , _path, _params3, _hash2, blocks]]; + } - if (this.tokenizer['state'] !== 'comment' && this.tokenizer['state'] !== 'data' && this.tokenizer['state'] !== 'beforeData') { - throw new SyntaxError('A block may only be used inside an HTML element or another block.', block.loc); - } + case "Element" + /* Element */ + : + return buildElement(normalized, symbols); - var _acceptCallNodes = acceptCallNodes(this, block), - path = _acceptCallNodes.path, - params = _acceptCallNodes.params, - hash = _acceptCallNodes.hash; + case "Modifier" + /* Modifier */ + : + throw unimpl('modifier'); - var program = this.Program(block.program); - var inverse = block.inverse ? this.Program(block.inverse) : null; + case "DynamicComponent" + /* DynamicComponent */ + : + throw unimpl('dynamic component'); - if (path.original === 'in-element') { - hash = addInElementHash(this.cursor(), hash, block.loc); - } + default: + throw (0, _util.assertNever)(normalized); + } + } - var node = b.block(path, params, hash, program, inverse, block.loc); - var parentProgram = this.currentElement(); - appendChild(parentProgram, node); - }; + function s(arr) { + for (var _len = arguments.length, interpolated = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + interpolated[_key - 1] = arguments[_key]; + } - _proto2.MustacheStatement = function MustacheStatement(rawMustache) { - var tokenizer = this.tokenizer; + var result = arr.reduce(function (result, string, i) { + return result + ("" + string + (interpolated[i] ? interpolated[i] : '')); + }, ''); + return [0 + /* Literal */ + , result]; + } - if (tokenizer.state === 'comment') { - this.appendToCommentData(this.sourceForNode(rawMustache)); - return; - } + function c(arr) { + for (var _len2 = arguments.length, interpolated = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + interpolated[_key2 - 1] = arguments[_key2]; + } - var mustache; - var escaped = rawMustache.escaped, - loc = rawMustache.loc; + var result = arr.reduce(function (result, string, i) { + return result + ("" + string + (interpolated[i] ? interpolated[i] : '')); + }, ''); + return [1 + /* Comment */ + , result]; + } - if (rawMustache.path.type.match(/Literal$/)) { - mustache = { - type: 'MustacheStatement', - path: this.acceptNode(rawMustache.path), - params: [], - hash: b.hash(), - escaped: escaped, - loc: loc - }; - } else { - var _acceptCallNodes2 = acceptCallNodes(this, rawMustache), - path = _acceptCallNodes2.path, - params = _acceptCallNodes2.params, - hash = _acceptCallNodes2.hash; + function unicode(charCode) { + return String.fromCharCode(parseInt(charCode, 16)); + } - mustache = b.mustache(path, params, hash, !escaped, loc); - } + var NEWLINE = '\n'; + _exports.NEWLINE = NEWLINE; - switch (tokenizer.state) { - // Tag helpers - case "tagOpen" - /* tagOpen */ - : - case "tagName" - /* tagName */ - : - throw new SyntaxError("Cannot use mustaches in an elements tagname: `" + this.sourceForNode(rawMustache, rawMustache.path) + "` at L" + loc.start.line + ":C" + loc.start.column, mustache.loc); + function buildElement(_ref32, symbols) { + var name = _ref32.name, + attrs = _ref32.attrs, + block = _ref32.block; + var out = [[9 + /* OpenElement */ + , name, !hasSplat(attrs)]]; - case "beforeAttributeName" - /* beforeAttributeName */ - : - addElementModifier(this.currentStartTag, mustache); - break; + if (attrs) { + var _buildAttrs = buildAttrs(attrs, symbols), + attributes = _buildAttrs.attributes, + args = _buildAttrs.args; - case "attributeName" - /* attributeName */ - : - case "afterAttributeName" - /* afterAttributeName */ - : - this.beginAttributeValue(false); - this.finishAttributeValue(); - addElementModifier(this.currentStartTag, mustache); - tokenizer.transitionTo("beforeAttributeName" - /* beforeAttributeName */ - ); - break; + out.push.apply(out, attributes); + } - case "afterAttributeValueQuoted" - /* afterAttributeValueQuoted */ - : - addElementModifier(this.currentStartTag, mustache); - tokenizer.transitionTo("beforeAttributeName" - /* beforeAttributeName */ - ); - break; - // Attribute values + out.push([10 + /* FlushElement */ + ]); - case "beforeAttributeValue" - /* beforeAttributeValue */ - : - this.beginAttributeValue(false); - appendDynamicAttributeValuePart(this.currentAttribute, mustache); - tokenizer.transitionTo("attributeValueUnquoted" - /* attributeValueUnquoted */ - ); - break; + if (Array.isArray(block)) { + block.forEach(function (s) { + return out.push.apply(out, buildStatement(s, symbols)); + }); + } else if (block === null) {// do nothing + } else { + throw (0, _util.assertNever)(block); + } - case "attributeValueDoubleQuoted" - /* attributeValueDoubleQuoted */ - : - case "attributeValueSingleQuoted" - /* attributeValueSingleQuoted */ - : - case "attributeValueUnquoted" - /* attributeValueUnquoted */ - : - appendDynamicAttributeValuePart(this.currentAttribute, mustache); - break; - // TODO: Only append child when the tokenizer state makes - // sense to do so, otherwise throw an error. + out.push([11 + /* CloseElement */ + ]); + return out; + } - default: - appendChild(this.currentElement(), mustache); - } + function hasSplat(attrs) { + if (attrs === null) return false; + return Object.keys(attrs).some(function (a) { + return attrs[a] === "Splat"; + } + /* Splat */ + ); + } - return mustache; - }; + function buildAttrs(attrs, symbols) { + var attributes = []; + var keys = []; + var values$$1 = []; + Object.keys(attrs).forEach(function (key) { + var value = attrs[key]; - _proto2.ContentStatement = function ContentStatement(content) { - updateTokenizerLocation(this.tokenizer, content); - this.tokenizer.tokenizePart(content.value); - this.tokenizer.flushData(); + if (value === "Splat" + /* Splat */ + ) { + attributes.push([15 + /* AttrSplat */ + , symbols.block('&attrs')]); + } else if (key[0] === '@') { + keys.push(key); + values$$1.push(buildExpression(value, "Expression" + /* Expression */ + , symbols)); + } else { + attributes.push.apply(attributes, buildAttributeValue(key, value, // TODO: extract namespace from key + extractNamespace(key), symbols)); + } + }); + return { + attributes: attributes, + args: keys.length === 0 ? null : [keys, values$$1] }; + } - _proto2.CommentStatement = function CommentStatement(rawComment) { - var tokenizer = this.tokenizer; - - if (tokenizer.state === "comment" - /* comment */ - ) { - this.appendToCommentData(this.sourceForNode(rawComment)); - return null; - } + function extractNamespace(name) { + if (name === 'xmlns') { + return "http://www.w3.org/2000/xmlns/" + /* XMLNS */ + ; + } - var value = rawComment.value, - loc = rawComment.loc; - var comment = b.mustacheComment(value, loc); + var match = name.match(/^([^:]*):([^:]*)$/); - switch (tokenizer.state) { - case "beforeAttributeName" - /* beforeAttributeName */ - : - this.currentStartTag.comments.push(comment); - break; + if (match === null) { + return null; + } - case "beforeData" - /* beforeData */ - : - case "data" - /* data */ - : - appendChild(this.currentElement(), comment); - break; + var namespace = match[1]; - default: - throw new SyntaxError("Using a Handlebars comment when in the `" + tokenizer['state'] + "` state is not supported: \"" + comment.value + "\" on line " + loc.start.line + ":" + loc.start.column, rawComment.loc); - } + switch (namespace) { + case 'xlink': + return "http://www.w3.org/1999/xlink" + /* XLink */ + ; - return comment; - }; + case 'xml': + return "http://www.w3.org/XML/1998/namespace" + /* XML */ + ; - _proto2.PartialStatement = function PartialStatement(partial) { - var loc = partial.loc; - throw new SyntaxError("Handlebars partials are not supported: \"" + this.sourceForNode(partial, partial.name) + "\" at L" + loc.start.line + ":C" + loc.start.column, partial.loc); - }; + case 'xmlns': + return "http://www.w3.org/2000/xmlns/" + /* XMLNS */ + ; + } - _proto2.PartialBlockStatement = function PartialBlockStatement(partialBlock) { - var loc = partialBlock.loc; - throw new SyntaxError("Handlebars partial blocks are not supported: \"" + this.sourceForNode(partialBlock, partialBlock.name) + "\" at L" + loc.start.line + ":C" + loc.start.column, partialBlock.loc); - }; + return null; + } - _proto2.Decorator = function Decorator(decorator) { - var loc = decorator.loc; - throw new SyntaxError("Handlebars decorators are not supported: \"" + this.sourceForNode(decorator, decorator.path) + "\" at L" + loc.start.line + ":C" + loc.start.column, decorator.loc); - }; + function buildAttributeValue(name, value, namespace, symbols) { + switch (value.type) { + case "Literal" + /* Literal */ + : + { + var val = value.value; + + if (val === false) { + return []; + } else if (val === true) { + return [[12 + /* StaticAttr */ + , name, '', namespace]]; + } else if (typeof val === 'string') { + return [[12 + /* StaticAttr */ + , name, val, namespace]]; + } else { + throw new Error("Unexpected/unimplemented literal attribute " + JSON.stringify(val)); + } + } - _proto2.DecoratorBlock = function DecoratorBlock(decoratorBlock) { - var loc = decoratorBlock.loc; - throw new SyntaxError("Handlebars decorator blocks are not supported: \"" + this.sourceForNode(decoratorBlock, decoratorBlock.path) + "\" at L" + loc.start.line + ":C" + loc.start.column, decoratorBlock.loc); - }; + default: + return [[13 + /* DynamicAttr */ + , name, buildExpression(value, "AppendSingleId" + /* AppendSingleId */ + , symbols), namespace]]; + } + } - _proto2.SubExpression = function SubExpression(sexpr) { - var _acceptCallNodes3 = acceptCallNodes(this, sexpr), - path = _acceptCallNodes3.path, - params = _acceptCallNodes3.params, - hash = _acceptCallNodes3.hash; + function buildExpression(expr, context, symbols) { + switch (expr.type) { + case "Get" + /* Get */ + : + { + return buildPath(expr.path, context, symbols); + } - return b.sexpr(path, params, hash, sexpr.loc); - }; + case "Concat" + /* Concat */ + : + { + return [32 + /* Concat */ + , buildConcat(expr.params, symbols)]; + } - _proto2.PathExpression = function PathExpression(path) { - var original = path.original, - loc = path.loc; - var parts; + case "Call" + /* Call */ + : + { + var builtParams = buildParams(expr.params, symbols); + var builtHash = buildHash(expr.hash, symbols); + var builtExpr = buildPath(expr.path, "CallHead" + /* CallHead */ + , symbols); + return [31 + /* Call */ + , 0, 0, builtExpr, builtParams, builtHash]; + } - if (original.indexOf('/') !== -1) { - if (original.slice(0, 2) === './') { - throw new SyntaxError("Using \"./\" is not supported in Glimmer and unnecessary: \"" + path.original + "\" on line " + loc.start.line + ".", path.loc); + case "HasBlock" + /* HasBlock */ + : + { + return [28 + /* HasBlock */ + , buildVar({ + kind: VariableKind.Block, + name: expr.name + }, "Expression" + /* Expression */ + , symbols)]; } - if (original.slice(0, 3) === '../') { - throw new SyntaxError("Changing context using \"../\" is not supported in Glimmer: \"" + path.original + "\" on line " + loc.start.line + ".", path.loc); + case "HasBlockParams" + /* HasBlockParams */ + : + { + return [29 + /* HasBlockParams */ + , buildVar({ + kind: VariableKind.Block, + name: expr.name + }, "Expression" + /* Expression */ + , symbols)]; } - if (original.indexOf('.') !== -1) { - throw new SyntaxError("Mixing '.' and '/' in paths is not supported in Glimmer; use only '.' to separate property paths: \"" + path.original + "\" on line " + loc.start.line + ".", path.loc); + case "Literal" + /* Literal */ + : + { + if (expr.value === undefined) { + return [30 + /* Undefined */ + ]; + } else { + return expr.value; + } } + } + } - parts = [path.parts.join('/')]; - } else if (original === '.') { - var locationInfo = "L" + loc.start.line + ":C" + loc.start.column; - throw new SyntaxError("'.' is not a supported path in Glimmer; check for a path with a trailing '.' at " + locationInfo + ".", path.loc); + function buildPath(path, context, symbols) { + if (path.tail.length === 0) { + return [27 + /* GetPath */ + , buildVar(path.variable, context, symbols), path.tail]; + } else { + return [27 + /* GetPath */ + , buildVar(path.variable, "Expression" + /* Expression */ + , symbols), path.tail]; + } + } + + function buildVar(head, context, symbols) { + switch (head.kind) { + case VariableKind.Free: + return [26 + /* GetContextualFree */ + , symbols.freeVar(head.name), context]; + + case VariableKind.Arg: + return [24 + /* GetSymbol */ + , symbols.arg(head.name)]; + + case VariableKind.Block: + return [24 + /* GetSymbol */ + , symbols.block(head.name)]; + + case VariableKind.Local: + return [24 + /* GetSymbol */ + , symbols.local(head.name)]; + + case VariableKind.This: + return [24 + /* GetSymbol */ + , symbols.this()]; + } + } + + function buildParams(exprs, symbols) { + if (exprs === null) return null; + return exprs.map(function (e) { + return buildExpression(e, "Expression" + /* Expression */ + , symbols); + }); + } + + function buildConcat(exprs, symbols) { + return exprs.map(function (e) { + return buildExpression(e, "AppendSingleId" + /* AppendSingleId */ + , symbols); + }); + } + + function buildHash(exprs, symbols) { + if (exprs === null) return null; + var out = [[], []]; + Object.keys(exprs).forEach(function (key) { + out[0].push(key); + out[1].push(buildExpression(exprs[key], "Expression" + /* Expression */ + , symbols)); + }); + return out; + } + + function buildBlocks(blocks, blockParams, parent) { + var keys = []; + var values$$1 = []; + Object.keys(blocks).forEach(function (name) { + keys.push(name); + + if (name === 'default') { + var symbols = parent.child(blockParams || []); + values$$1.push({ + parameters: symbols.paramSymbols, + statements: buildNormalizedStatements(blocks[name], symbols) + }); } else { - parts = path.parts; + values$$1.push({ + parameters: [], + statements: buildNormalizedStatements(blocks[name], parent) + }); } + }); + return [keys, values$$1]; + } - var thisHead = false; // This is to fix a bug in the Handlebars AST where the path expressions in - // `{{this.foo}}` (and similarly `{{foo-bar this.foo named=this.foo}}` etc) - // are simply turned into `{{foo}}`. The fix is to push it back onto the - // parts array and let the runtime see the difference. However, we cannot - // simply use the string `this` as it means literally the property called - // "this" in the current context (it can be expressed in the syntax as - // `{{[this]}}`, where the square bracket are generally for this kind of - // escaping – such as `{{foo.["bar.baz"]}}` would mean lookup a property - // named literally "bar.baz" on `this.foo`). By convention, we use `null` - // for this purpose. + var WireFormatDebugger = + /*#__PURE__*/ + function () { + function WireFormatDebugger(program, _parameters) { + this.program = program; + } - if (original.match(/^this(\..+)?$/)) { - thisHead = true; - } + var _proto15 = WireFormatDebugger.prototype; - return { - type: 'PathExpression', - original: path.original, - this: thisHead, - parts: parts, - data: path.data, - loc: path.loc - }; - }; + _proto15.format = function format() { + var out = []; - _proto2.Hash = function Hash(hash) { - var pairs = []; + for (var _iterator2 = this.program.statements, _isArray2 = Array.isArray(_iterator2), _i5 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref33; - for (var i = 0; i < hash.pairs.length; i++) { - var pair = hash.pairs[i]; - pairs.push(b.pair(pair.key, this.acceptNode(pair.value), pair.loc)); + if (_isArray2) { + if (_i5 >= _iterator2.length) break; + _ref33 = _iterator2[_i5++]; + } else { + _i5 = _iterator2.next(); + if (_i5.done) break; + _ref33 = _i5.value; + } + + var _statement = _ref33; + out.push(this.formatOpcode(_statement)); } - return b.hash(pairs, hash.loc); + return out; }; - _proto2.StringLiteral = function StringLiteral(string) { - return b.literal('StringLiteral', string.value, string.loc); + _proto15.formatOpcode = function formatOpcode(opcode) { + if (Array.isArray(opcode)) { + switch (opcode[0]) { + case 1 + /* Append */ + : + return ['append', this.formatOpcode(opcode[1]), opcode[2]]; + + case 5 + /* Block */ + : + return ['block', this.formatOpcode(opcode[1]), this.formatParams(opcode[2]), this.formatHash(opcode[3]), this.formatBlocks(opcode[4])]; + + case 9 + /* OpenElement */ + : + return ['open-element', opcode[1], opcode[2]]; + + case 11 + /* CloseElement */ + : + return ['close-element']; + + case 10 + /* FlushElement */ + : + return ['flush-element']; + + case 12 + /* StaticAttr */ + : + return ['static-attr', opcode[1], opcode[2], opcode[3]]; + + case 23 + /* StaticComponentAttr */ + : + return ['static-component-attr', opcode[1], opcode[2], opcode[3]]; + + case 13 + /* DynamicAttr */ + : + return ['dynamic-attr', opcode[1], this.formatOpcode(opcode[2]), opcode[3]]; + + case 14 + /* ComponentAttr */ + : + return ['component-attr', opcode[1], this.formatOpcode(opcode[2]), opcode[3]]; + + case 15 + /* AttrSplat */ + : + return ['attr-splat']; + + case 16 + /* Yield */ + : + return ['yield', opcode[1], this.formatParams(opcode[2])]; + + case 17 + /* Partial */ + : + return ['partial', this.formatOpcode(opcode[1]), opcode[2]]; + + case 18 + /* DynamicArg */ + : + return ['dynamic-arg', opcode[1], this.formatOpcode(opcode[2])]; + + case 19 + /* StaticArg */ + : + return ['static-arg', opcode[1], this.formatOpcode(opcode[2])]; + + case 20 + /* TrustingDynamicAttr */ + : + return ['trusting-dynamic-attr', opcode[1], this.formatOpcode(opcode[2]), opcode[3]]; + + case 21 + /* TrustingComponentAttr */ + : + return ['trusting-component-attr', opcode[1], this.formatOpcode(opcode[2]), opcode[3]]; + + case 22 + /* Debugger */ + : + return ['debugger', opcode[1]]; + + case 2 + /* Comment */ + : + return ['comment', opcode[1]]; + + case 3 + /* Modifier */ + : + return ['modifier', this.formatOpcode(opcode[1]), this.formatParams(opcode[4]), this.formatHash(opcode[5])]; + + case 7 + /* Component */ + : + return ['component', opcode[1], this.formatAttrs(opcode[2]), this.formatHash(opcode[3]), this.formatBlocks(opcode[4])]; + // case Op.DynamicComponent: + // return [ + // 'dynamic-component', + // this.formatOpcode(opcode[1]), + // this.formatAttrs(opcode[2]), + // this.formatHash(opcode[3]), + // this.formatBlocks(opcode[4]), + // ]; + + case 24 + /* GetSymbol */ + : + return ['get-symbol', this.program.symbols[opcode[1]], opcode[1]]; + + case 25 + /* GetFree */ + : + return ['get-free', this.program.upvars[opcode[1]]]; + + case 26 + /* GetContextualFree */ + : + return ['get-contextual-free', this.program.upvars[opcode[1]], opcode[2]]; + + case 27 + /* GetPath */ + : + return ['get-path', this.formatOpcode(opcode[1]), opcode[2]]; + + case 28 + /* HasBlock */ + : + return ['has-block', opcode[1]]; + + case 29 + /* HasBlockParams */ + : + return ['has-block-params', opcode[1]]; + + case 30 + /* Undefined */ + : + return ['undefined']; + + case 31 + /* Call */ + : + return ['call', this.formatOpcode(opcode[3]), this.formatParams(opcode[4]), this.formatHash(opcode[5])]; + + case 32 + /* Concat */ + : + return ['concat', this.formatParams(opcode[1])]; + + default: + { + var opName = opcode[0]; + throw (0, _util.assertNever)(opName, "unexpected " + opName); + } + } + } else { + return opcode; + } }; - _proto2.BooleanLiteral = function BooleanLiteral(boolean) { - return b.literal('BooleanLiteral', boolean.value, boolean.loc); + _proto15.formatAttrs = function formatAttrs(opcodes) { + var _this11 = this; + + if (opcodes === null) return null; + return opcodes.map(function (o) { + return _this11.formatOpcode(o); + }); }; - _proto2.NumberLiteral = function NumberLiteral(number) { - return b.literal('NumberLiteral', number.value, number.loc); + _proto15.formatParams = function formatParams(opcodes) { + var _this12 = this; + + if (opcodes === null) return null; + return opcodes.map(function (o) { + return _this12.formatOpcode(o); + }); }; - _proto2.UndefinedLiteral = function UndefinedLiteral(undef) { - return b.literal('UndefinedLiteral', undefined, undef.loc); + _proto15.formatHash = function formatHash(hash) { + var _this13 = this; + + if (hash === null) return null; + return hash[0].reduce(function (accum, key, index) { + accum[key] = _this13.formatOpcode(hash[1][index]); + return accum; + }, (0, _util.dict)()); }; - _proto2.NullLiteral = function NullLiteral(nul) { - return b.literal('NullLiteral', null, nul.loc); + _proto15.formatBlocks = function formatBlocks(blocks) { + var _this14 = this; + + if (blocks === null) return null; + return blocks[0].reduce(function (accum, key, index) { + accum[key] = _this14.formatBlock(blocks[1][index]); + return accum; + }, (0, _util.dict)()); }; - return HandlebarsNodeVisitors; - }(Parser); + _proto15.formatBlock = function formatBlock(block) { + var _this15 = this; - function calculateRightStrippedOffsets(original, value) { - if (value === '') { - // if it is empty, just return the count of newlines - // in original return { - lines: original.split('\n').length - 1, - columns: 0 + parameters: block.parameters, + statements: block.statements.map(function (s) { + return _this15.formatOpcode(s); + }) }; - } // otherwise, return the number of newlines prior to - // `value` + }; + return WireFormatDebugger; + }(); + + _exports.WireFormatDebugger = WireFormatDebugger; +}); +define("@glimmer/env", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.CI = _exports.DEBUG = void 0; + var DEBUG = false; + _exports.DEBUG = DEBUG; + var CI = false; + _exports.CI = CI; +}); +define("@glimmer/syntax", ["exports", "ember-babel", "@glimmer/util", "simple-html-tokenizer", "handlebars"], function (_exports, _emberBabel, _util, _simpleHtmlTokenizer, _handlebars) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.preprocess = preprocess; + _exports.cannotRemoveNode = cannotRemoveNode; + _exports.cannotReplaceNode = cannotReplaceNode; + _exports.cannotReplaceOrRemoveInKeyHandlerYet = cannotReplaceOrRemoveInKeyHandlerYet; + _exports.traverse = traverse; + _exports.print = build; + _exports.isLiteral = isLiteral; + _exports.printLiteral = printLiteral; + _exports.SyntaxError = _exports.Walker = _exports.Path = _exports.TraversalError = _exports.builders = _exports.AST = void 0; + + function buildMustache(path, params, hash, raw, loc, strip) { + if (typeof path === 'string') { + path = buildHead(path); + } - var difference = original.split(value)[0]; - var lines = difference.split(/\n/); - var lineCount = lines.length - 1; return { - lines: lineCount, - columns: lines[lineCount].length + type: 'MustacheStatement', + path: path, + params: params || [], + hash: hash || buildHash([]), + escaped: !raw, + loc: buildLoc(loc || null), + strip: strip || { + open: false, + close: false + } }; } - function updateTokenizerLocation(tokenizer, content) { - var line = content.loc.start.line; - var column = content.loc.start.column; - var offsets = calculateRightStrippedOffsets(content.original, content.value); - line = line + offsets.lines; + function buildBlock(path, params, hash, _defaultBlock, _elseBlock, loc, openStrip, inverseStrip, closeStrip) { + var defaultBlock; + var elseBlock; - if (offsets.lines) { - column = offsets.columns; + if (_defaultBlock.type === 'Template') { + defaultBlock = (0, _util.assign)({}, _defaultBlock, { + type: 'Block' + }); } else { - column = column + offsets.columns; + defaultBlock = _defaultBlock; } - tokenizer.line = line; - tokenizer.column = column; - } + if (_elseBlock !== undefined && _elseBlock !== null && _elseBlock.type === 'Template') { + elseBlock = (0, _util.assign)({}, _elseBlock, { + type: 'Block' + }); + } else { + elseBlock = _elseBlock; + } - function acceptCallNodes(compiler, node) { - var path = compiler.PathExpression(node.path); - var params = node.params ? node.params.map(function (e) { - return compiler.acceptNode(e); - }) : []; - var hash = node.hash ? compiler.Hash(node.hash) : b.hash(); return { - path: path, - params: params, - hash: hash + type: 'BlockStatement', + path: buildHead(path), + params: params || [], + hash: hash || buildHash([]), + program: defaultBlock || null, + inverse: elseBlock || null, + loc: buildLoc(loc || null), + openStrip: openStrip || { + open: false, + close: false + }, + inverseStrip: inverseStrip || { + open: false, + close: false + }, + closeStrip: closeStrip || { + open: false, + close: false + } }; } - function addElementModifier(element, mustache) { - var path = mustache.path, - params = mustache.params, - hash = mustache.hash, - loc = mustache.loc; - - if (isLiteral(path)) { - var _modifier = "{{" + printLiteral(path) + "}}"; - - var tag = "<" + element.name + " ... " + _modifier + " ..."; - throw new SyntaxError("In " + tag + ", " + _modifier + " is not a valid modifier: \"" + path.original + "\" on line " + (loc && loc.start.line) + ".", mustache.loc); - } + function buildElementModifier(path, params, hash, loc) { + return { + type: 'ElementModifierStatement', + path: buildHead(path), + params: params || [], + hash: hash || buildHash([]), + loc: buildLoc(loc || null) + }; + } - var modifier = b.elementModifier(path, params, hash, loc); - element.modifiers.push(modifier); + function buildPartial(name, params, hash, indent, loc) { + return { + type: 'PartialStatement', + name: name, + params: params || [], + hash: hash || buildHash([]), + indent: indent || '', + strip: { + open: false, + close: false + }, + loc: buildLoc(loc || null) + }; } - function addInElementHash(cursor, hash, loc) { - var hasNextSibling = false; - hash.pairs.forEach(function (pair) { - if (pair.key === 'guid') { - throw new SyntaxError('Cannot pass `guid` from user space', loc); - } + function buildComment(value, loc) { + return { + type: 'CommentStatement', + value: value, + loc: buildLoc(loc || null) + }; + } - if (pair.key === 'nextSibling') { - hasNextSibling = true; - } - }); - var guid = b.literal('StringLiteral', cursor); - var guidPair = b.pair('guid', guid); - hash.pairs.unshift(guidPair); + function buildMustacheComment(value, loc) { + return { + type: 'MustacheCommentStatement', + value: value, + loc: buildLoc(loc || null) + }; + } - if (!hasNextSibling) { - var nullLiteral = b.literal('NullLiteral', null); - var nextSibling = b.pair('nextSibling', nullLiteral); - hash.pairs.push(nextSibling); - } + function buildConcat(parts, loc) { + return { + type: 'ConcatStatement', + parts: parts || [], + loc: buildLoc(loc || null) + }; + } - return hash; + function isLocSexp(value) { + return Array.isArray(value) && value.length === 2 && value[0] === 'loc'; } - function appendDynamicAttributeValuePart(attribute, part) { - attribute.isDynamic = true; - attribute.parts.push(part); + function isParamsSexp(value) { + return Array.isArray(value) && !isLocSexp(value); } - function tuple() { - for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { - args[_key2] = arguments[_key2]; + function isHashSexp(value) { + if (typeof value === 'object' && value && !Array.isArray(value)) { + return true; + } else { + return false; } + } - return args; - } // ensure stays in sync with typing - // ParentNode and ChildKey types are derived from VisitorKeysMap + function normalizeModifier(sexp) { + if (typeof sexp === 'string') { + return buildElementModifier(sexp); + } + var path = normalizeHead(sexp[0]); + var params; + var hash; + var loc = null; + var parts = sexp.slice(1); + var next = parts.shift(); - var visitorKeys = { - Program: tuple('body'), - MustacheStatement: tuple('path', 'params', 'hash'), - BlockStatement: tuple('path', 'params', 'hash', 'program', 'inverse'), - ElementModifierStatement: tuple('path', 'params', 'hash'), - PartialStatement: tuple('name', 'params', 'hash'), - CommentStatement: tuple(), - MustacheCommentStatement: tuple(), - ElementNode: tuple('attributes', 'modifiers', 'children', 'comments'), - AttrNode: tuple('value'), - TextNode: tuple(), - ConcatStatement: tuple('parts'), - SubExpression: tuple('path', 'params', 'hash'), - PathExpression: tuple(), - StringLiteral: tuple(), - BooleanLiteral: tuple(), - NumberLiteral: tuple(), - NullLiteral: tuple(), - UndefinedLiteral: tuple(), - Hash: tuple('pairs'), - HashPair: tuple('value') - }; + _process: { + if (isParamsSexp(next)) { + params = next; + } else { + break _process; + } - var TraversalError = function () { - TraversalError.prototype = Object.create(Error.prototype); - TraversalError.prototype.constructor = TraversalError; + next = parts.shift(); - function TraversalError(message, node, parent, key) { - var error = Error.call(this, message); - this.key = key; - this.message = message; - this.node = node; - this.parent = parent; - this.stack = error.stack; + if (isHashSexp(next)) { + hash = normalizeHash(next); + } else { + break _process; + } } - return TraversalError; - }(); - - _exports.TraversalError = TraversalError; + if (isLocSexp(next)) { + loc = next[1]; + } - function cannotRemoveNode(node, parent, key) { - return new TraversalError('Cannot remove a node unless it is part of an array', node, parent, key); + return { + type: 'ElementModifierStatement', + path: path, + params: params || [], + hash: hash || buildHash([]), + loc: buildLoc(loc || null) + }; } - function cannotReplaceNode(node, parent, key) { - return new TraversalError('Cannot replace a node with multiple nodes unless it is part of an array', node, parent, key); - } + function normalizeAttr(sexp) { + var name = sexp[0]; + var value; - function cannotReplaceOrRemoveInKeyHandlerYet(node, key) { - return new TraversalError('Replacing and removing in key handlers is not yet supported.', node, null, key); - } + if (typeof sexp[1] === 'string') { + value = buildText(sexp[1]); + } else { + value = sexp[1]; + } - function getEnterFunction(handler) { - return typeof handler === 'function' ? handler : handler.enter; + var loc = sexp[2] ? sexp[2][1] : undefined; + return buildAttr(name, value, loc); } - function getExitFunction(handler) { - return typeof handler !== 'function' ? handler.exit : undefined; + function normalizeHash(hash, loc) { + var pairs = []; + Object.keys(hash).forEach(function (key) { + pairs.push(buildPair(key, hash[key])); + }); + return buildHash(pairs, loc); } - function getKeyHandler(handler, key) { - var keyVisitor = typeof handler !== 'function' ? handler.keys : undefined; - if (keyVisitor === undefined) return; - var keyHandler = keyVisitor[key]; - - if (keyHandler !== undefined) { - // widen specific key to all keys - return keyHandler; + function normalizeHead(path) { + if (typeof path === 'string') { + return buildHead(path); + } else { + return buildHead(path[1], path[2] && path[2][1]); } - - return keyVisitor.All; } - function getNodeHandler(visitor, nodeType) { - var handler = visitor[nodeType]; + function normalizeElementOptions() { + var out = {}; - if (handler !== undefined) { - // widen specific Node to all nodes - return handler; + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; } - return visitor.All; - } + for (var _i = 0, _args = args; _i < _args.length; _i++) { + var arg = _args[_i]; - function visitNode(visitor, node) { - var handler = getNodeHandler(visitor, node.type); - var enter; - var exit; + switch (arg[0]) { + case 'attrs': + { + var rest = arg.slice(1); + out.attrs = rest.map(normalizeAttr); + break; + } - if (handler !== undefined) { - enter = getEnterFunction(handler); - exit = getExitFunction(handler); - } + case 'modifiers': + { + var _rest = arg.slice(1); - var result; + out.modifiers = _rest.map(normalizeModifier); + break; + } - if (enter !== undefined) { - result = enter(node); - } + case 'body': + { + var _rest2 = arg.slice(1); - if (result !== undefined && result !== null) { - if (JSON.stringify(node) === JSON.stringify(result)) { - result = undefined; - } else if (Array.isArray(result)) { - visitArray(visitor, result); - return result; - } else { - return visitNode(visitor, result) || result; - } - } + out.children = _rest2; + break; + } - if (result === undefined) { - var keys = visitorKeys[node.type]; + case 'comments': + { + var _rest3 = arg.slice(1); - for (var i = 0; i < keys.length; i++) { - // we know if it has child keys we can widen to a ParentNode - visitKey(visitor, handler, node, keys[i]); - } + out.comments = _rest3; + break; + } - if (exit !== undefined) { - result = exit(node); + case 'as': + { + var _rest4 = arg.slice(1); + + out.blockParams = _rest4; + break; + } + + case 'loc': + { + var _rest5 = arg[1]; + out.loc = _rest5; + break; + } } } - return result; + return out; } - function visitKey(visitor, handler, node, key) { - var value = node[key]; + function buildElement(tag, options) { + var normalized; - if (!value) { - return; + if (Array.isArray(options)) { + for (var _len2 = arguments.length, rest = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { + rest[_key2 - 2] = arguments[_key2]; + } + + normalized = normalizeElementOptions.apply(void 0, [options].concat(rest)); + } else { + normalized = options || {}; } - var keyEnter; - var keyExit; + var _normalized = normalized, + attrs = _normalized.attrs, + blockParams = _normalized.blockParams, + modifiers = _normalized.modifiers, + comments = _normalized.comments, + children = _normalized.children, + loc = _normalized.loc; // this is used for backwards compat, prior to `selfClosing` being part of the ElementNode AST - if (handler !== undefined) { - var keyHandler = getKeyHandler(handler, key); + var selfClosing = false; + + if (typeof tag === 'object') { + selfClosing = tag.selfClosing; + tag = tag.name; + } else { + if (tag.slice(-1) === '/') { + tag = tag.slice(0, -1); + selfClosing = true; + } + } + + return { + type: 'ElementNode', + tag: tag || '', + selfClosing: selfClosing, + attributes: attrs || [], + blockParams: blockParams || [], + modifiers: modifiers || [], + comments: comments || [], + children: children || [], + loc: buildLoc(loc || null) + }; + } + + function buildAttr(name, value, loc) { + return { + type: 'AttrNode', + name: name, + value: value, + loc: buildLoc(loc || null) + }; + } + + function buildText(chars, loc) { + return { + type: 'TextNode', + chars: chars || '', + loc: buildLoc(loc || null) + }; + } // Expressions + + + function buildSexpr(path, params, hash, loc) { + return { + type: 'SubExpression', + path: buildHead(path), + params: params || [], + hash: hash || buildHash([]), + loc: buildLoc(loc || null) + }; + } + + function buildHead(original, loc) { + if (typeof original !== 'string') return original; + var parts = original.split('.'); + var thisHead = false; + + if (parts[0] === 'this') { + thisHead = true; + parts = parts.slice(1); + } + + return { + type: 'PathExpression', + original: original, + this: thisHead, + parts: parts, + data: false, + loc: buildLoc(loc || null) + }; + } + + function buildLiteral(type, value, loc) { + return { + type: type, + value: value, + original: value, + loc: buildLoc(loc || null) + }; + } // Miscellaneous + + + function buildHash(pairs, loc) { + return { + type: 'Hash', + pairs: pairs || [], + loc: buildLoc(loc || null) + }; + } + + function buildPair(key, value, loc) { + return { + type: 'HashPair', + key: key, + value: value, + loc: buildLoc(loc || null) + }; + } + + function buildProgram(body, blockParams, loc) { + return { + type: 'Template', + body: body || [], + blockParams: blockParams || [], + loc: buildLoc(loc || null) + }; + } + + function buildBlockItself(body, blockParams, chained, loc) { + if (chained === void 0) { + chained = false; + } + + return { + type: 'Block', + body: body || [], + blockParams: blockParams || [], + chained: chained, + loc: buildLoc(loc || null) + }; + } + + function buildTemplate(body, blockParams, loc) { + return { + type: 'Template', + body: body || [], + blockParams: blockParams || [], + loc: buildLoc(loc || null) + }; + } + + function buildSource(source) { + return source || null; + } + + function buildPosition(line, column) { + return { + line: line, + column: column + }; + } + + var SYNTHETIC = { + source: '(synthetic)', + start: { + line: 1, + column: 0 + }, + end: { + line: 1, + column: 0 + } + }; + + function buildLoc() { + for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) { + args[_key3] = arguments[_key3]; + } + + if (args.length === 1) { + var loc = args[0]; + + if (loc && typeof loc === 'object') { + return { + source: buildSource(loc.source), + start: buildPosition(loc.start.line, loc.start.column), + end: buildPosition(loc.end.line, loc.end.column) + }; + } else { + return SYNTHETIC; + } + } else { + var startLine = args[0], + startColumn = args[1], + endLine = args[2], + endColumn = args[3], + source = args[4]; + return { + source: buildSource(source), + start: buildPosition(startLine, startColumn), + end: buildPosition(endLine, endColumn) + }; + } + } + + var b = { + mustache: buildMustache, + block: buildBlock, + partial: buildPartial, + comment: buildComment, + mustacheComment: buildMustacheComment, + element: buildElement, + elementModifier: buildElementModifier, + attr: buildAttr, + text: buildText, + sexpr: buildSexpr, + path: buildHead, + concat: buildConcat, + hash: buildHash, + pair: buildPair, + literal: buildLiteral, + program: buildProgram, + blockItself: buildBlockItself, + template: buildTemplate, + loc: buildLoc, + pos: buildPosition, + string: literal('StringLiteral'), + boolean: literal('BooleanLiteral'), + number: literal('NumberLiteral'), + undefined: function (_undefined) { + function undefined() { + return _undefined.apply(this, arguments); + } + + undefined.toString = function () { + return _undefined.toString(); + }; + + return undefined; + }(function () { + return buildLiteral('UndefinedLiteral', undefined); + }), + null: function _null() { + return buildLiteral('NullLiteral', null); + } + }; + _exports.builders = b; + + function literal(type) { + return function (value) { + return buildLiteral(type, value); + }; + } + /** + * Subclass of `Error` with additional information + * about location of incorrect markup. + */ + + + var SyntaxError = function () { + SyntaxError.prototype = Object.create(Error.prototype); + SyntaxError.prototype.constructor = SyntaxError; + + function SyntaxError(message, location) { + var error = Error.call(this, message); + this.message = message; + this.stack = error.stack; + this.location = location; + } + + return SyntaxError; + }(); // Regex to validate the identifier for block parameters. + // Based on the ID validation regex in Handlebars. + + + _exports.SyntaxError = SyntaxError; + var ID_INVERSE_PATTERN = /[!"#%-,\.\/;->@\[-\^`\{-~]/; // Checks the element's attributes to see if it uses block params. + // If it does, registers the block params with the program and + // removes the corresponding attributes from the element. + + function parseElementBlockParams(element) { + var params = parseBlockParams(element); + if (params) element.blockParams = params; + } + + function parseBlockParams(element) { + var l = element.attributes.length; + var attrNames = []; + + for (var i = 0; i < l; i++) { + attrNames.push(element.attributes[i].name); + } + + var asIndex = attrNames.indexOf('as'); + + if (asIndex !== -1 && l > asIndex && attrNames[asIndex + 1].charAt(0) === '|') { + // Some basic validation, since we're doing the parsing ourselves + var paramsString = attrNames.slice(asIndex).join(' '); + + if (paramsString.charAt(paramsString.length - 1) !== '|' || paramsString.match(/\|/g).length !== 2) { + throw new SyntaxError("Invalid block parameters syntax: '" + paramsString + "'", element.loc); + } + + var params = []; + + for (var _i2 = asIndex + 1; _i2 < l; _i2++) { + var param = attrNames[_i2].replace(/\|/g, ''); + + if (param !== '') { + if (ID_INVERSE_PATTERN.test(param)) { + throw new SyntaxError("Invalid identifier for block parameters: '" + param + "' in '" + paramsString + "'", element.loc); + } + + params.push(param); + } + } + + if (params.length === 0) { + throw new SyntaxError("Cannot use zero block parameters: '" + paramsString + "'", element.loc); + } + + element.attributes = element.attributes.slice(0, asIndex); + return params; + } + + return null; + } + + function childrenFor(node) { + switch (node.type) { + case 'Block': + case 'Template': + return node.body; + + case 'ElementNode': + return node.children; + } + } + + function appendChild(parent, node) { + childrenFor(parent).push(node); + } + + function isLiteral(path) { + return path.type === 'StringLiteral' || path.type === 'BooleanLiteral' || path.type === 'NumberLiteral' || path.type === 'NullLiteral' || path.type === 'UndefinedLiteral'; + } + + function printLiteral(literal) { + if (literal.type === 'UndefinedLiteral') { + return 'undefined'; + } else { + return JSON.stringify(literal.value); + } + } + + var Parser = + /*#__PURE__*/ + function () { + function Parser(source, entityParser) { + if (entityParser === void 0) { + entityParser = new _simpleHtmlTokenizer.EntityParser(_simpleHtmlTokenizer.HTML5NamedCharRefs); + } + + this.elementStack = []; + this.currentAttribute = null; + this.currentNode = null; + this.source = source.split(/(?:\r\n?|\n)/g); + this.tokenizer = new _simpleHtmlTokenizer.EventedTokenizer(this, entityParser); + } + + var _proto = Parser.prototype; + + _proto.acceptTemplate = function acceptTemplate(node) { + return this[node.type](node); + }; + + _proto.acceptNode = function acceptNode(node) { + return this[node.type](node); + }; + + _proto.currentElement = function currentElement() { + return this.elementStack[this.elementStack.length - 1]; + }; + + _proto.sourceForNode = function sourceForNode(node, endNode) { + var firstLine = node.loc.start.line - 1; + var currentLine = firstLine - 1; + var firstColumn = node.loc.start.column; + var string = []; + var line; + var lastLine; + var lastColumn; + + if (endNode) { + lastLine = endNode.loc.end.line - 1; + lastColumn = endNode.loc.end.column; + } else { + lastLine = node.loc.end.line - 1; + lastColumn = node.loc.end.column; + } + + while (currentLine < lastLine) { + currentLine++; + line = this.source[currentLine]; + + if (currentLine === firstLine) { + if (firstLine === lastLine) { + string.push(line.slice(firstColumn, lastColumn)); + } else { + string.push(line.slice(firstColumn)); + } + } else if (currentLine === lastLine) { + string.push(line.slice(0, lastColumn)); + } else { + string.push(line); + } + } + + return string.join('\n'); + }; + + (0, _emberBabel.createClass)(Parser, [{ + key: "currentAttr", + get: function get() { + return this.currentAttribute; + } + }, { + key: "currentTag", + get: function get() { + var node = this.currentNode; + return node; + } + }, { + key: "currentStartTag", + get: function get() { + var node = this.currentNode; + return node; + } + }, { + key: "currentEndTag", + get: function get() { + var node = this.currentNode; + return node; + } + }, { + key: "currentComment", + get: function get() { + var node = this.currentNode; + return node; + } + }, { + key: "currentData", + get: function get() { + var node = this.currentNode; + return node; + } + }]); + return Parser; + }(); + + var HandlebarsNodeVisitors = + /*#__PURE__*/ + function (_Parser) { + (0, _emberBabel.inheritsLoose)(HandlebarsNodeVisitors, _Parser); + + function HandlebarsNodeVisitors() { + var _this; + + _this = _Parser.apply(this, arguments) || this; + _this.cursorCount = 0; + return _this; + } + + var _proto2 = HandlebarsNodeVisitors.prototype; + + _proto2.cursor = function cursor() { + return "%cursor:" + this.cursorCount++ + "%"; + }; + + _proto2.Program = function Program(program) { + var body = []; + this.cursorCount = 0; + var node; + + if (this.isTopLevel) { + node = b.template(body, program.blockParams, program.loc); + } else { + node = b.blockItself(body, program.blockParams, program.chained, program.loc); + } + + var i, + l = program.body.length; + this.elementStack.push(node); + + if (l === 0) { + return this.elementStack.pop(); + } + + for (i = 0; i < l; i++) { + this.acceptNode(program.body[i]); + } // Ensure that that the element stack is balanced properly. + + + var poppedNode = this.elementStack.pop(); + + if (poppedNode !== node) { + var elementNode = poppedNode; + throw new SyntaxError('Unclosed element `' + elementNode.tag + '` (on line ' + elementNode.loc.start.line + ').', elementNode.loc); + } + + return node; + }; + + _proto2.BlockStatement = function BlockStatement(block) { + if (this.tokenizer['state'] === 'comment') { + this.appendToCommentData(this.sourceForNode(block)); + return; + } + + if (this.tokenizer['state'] !== 'comment' && this.tokenizer['state'] !== 'data' && this.tokenizer['state'] !== 'beforeData') { + throw new SyntaxError('A block may only be used inside an HTML element or another block.', block.loc); + } + + var _acceptCallNodes = acceptCallNodes(this, block), + path = _acceptCallNodes.path, + params = _acceptCallNodes.params, + hash = _acceptCallNodes.hash; + + var program = this.Program(block.program); + var inverse = block.inverse ? this.Program(block.inverse) : null; + + if (path.original === 'in-element') { + hash = addInElementHash(this.cursor(), hash, block.loc); + } + + var node = b.block(path, params, hash, program, inverse, block.loc, block.openStrip, block.inverseStrip, block.closeStrip); + var parentProgram = this.currentElement(); + appendChild(parentProgram, node); + }; + + _proto2.MustacheStatement = function MustacheStatement(rawMustache) { + var tokenizer = this.tokenizer; + + if (tokenizer.state === 'comment') { + this.appendToCommentData(this.sourceForNode(rawMustache)); + return; + } + + var mustache; + var escaped = rawMustache.escaped, + loc = rawMustache.loc, + strip = rawMustache.strip; + + if (isLiteral(rawMustache.path)) { + mustache = { + type: 'MustacheStatement', + path: this.acceptNode(rawMustache.path), + params: [], + hash: b.hash(), + escaped: escaped, + loc: loc, + strip: strip + }; + } else { + var _acceptCallNodes2 = acceptCallNodes(this, rawMustache), + path = _acceptCallNodes2.path, + params = _acceptCallNodes2.params, + hash = _acceptCallNodes2.hash; + + mustache = b.mustache(path, params, hash, !escaped, loc, strip); + } + + switch (tokenizer.state) { + // Tag helpers + case "tagOpen" + /* tagOpen */ + : + case "tagName" + /* tagName */ + : + throw new SyntaxError("Cannot use mustaches in an elements tagname: `" + this.sourceForNode(rawMustache, rawMustache.path) + "` at L" + loc.start.line + ":C" + loc.start.column, mustache.loc); + + case "beforeAttributeName" + /* beforeAttributeName */ + : + addElementModifier(this.currentStartTag, mustache); + break; + + case "attributeName" + /* attributeName */ + : + case "afterAttributeName" + /* afterAttributeName */ + : + this.beginAttributeValue(false); + this.finishAttributeValue(); + addElementModifier(this.currentStartTag, mustache); + tokenizer.transitionTo("beforeAttributeName" + /* beforeAttributeName */ + ); + break; + + case "afterAttributeValueQuoted" + /* afterAttributeValueQuoted */ + : + addElementModifier(this.currentStartTag, mustache); + tokenizer.transitionTo("beforeAttributeName" + /* beforeAttributeName */ + ); + break; + // Attribute values + + case "beforeAttributeValue" + /* beforeAttributeValue */ + : + this.beginAttributeValue(false); + appendDynamicAttributeValuePart(this.currentAttribute, mustache); + tokenizer.transitionTo("attributeValueUnquoted" + /* attributeValueUnquoted */ + ); + break; + + case "attributeValueDoubleQuoted" + /* attributeValueDoubleQuoted */ + : + case "attributeValueSingleQuoted" + /* attributeValueSingleQuoted */ + : + case "attributeValueUnquoted" + /* attributeValueUnquoted */ + : + appendDynamicAttributeValuePart(this.currentAttribute, mustache); + break; + // TODO: Only append child when the tokenizer state makes + // sense to do so, otherwise throw an error. + + default: + appendChild(this.currentElement(), mustache); + } + + return mustache; + }; + + _proto2.ContentStatement = function ContentStatement(content) { + updateTokenizerLocation(this.tokenizer, content); + this.tokenizer.tokenizePart(content.value); + this.tokenizer.flushData(); + }; + + _proto2.CommentStatement = function CommentStatement(rawComment) { + var tokenizer = this.tokenizer; + + if (tokenizer.state === "comment" + /* comment */ + ) { + this.appendToCommentData(this.sourceForNode(rawComment)); + return null; + } + + var value = rawComment.value, + loc = rawComment.loc; + var comment = b.mustacheComment(value, loc); + + switch (tokenizer.state) { + case "beforeAttributeName" + /* beforeAttributeName */ + : + this.currentStartTag.comments.push(comment); + break; + + case "beforeData" + /* beforeData */ + : + case "data" + /* data */ + : + appendChild(this.currentElement(), comment); + break; + + default: + throw new SyntaxError("Using a Handlebars comment when in the `" + tokenizer['state'] + "` state is not supported: \"" + comment.value + "\" on line " + loc.start.line + ":" + loc.start.column, rawComment.loc); + } + + return comment; + }; + + _proto2.PartialStatement = function PartialStatement(partial) { + var loc = partial.loc; + throw new SyntaxError("Handlebars partials are not supported: \"" + this.sourceForNode(partial, partial.name) + "\" at L" + loc.start.line + ":C" + loc.start.column, partial.loc); + }; + + _proto2.PartialBlockStatement = function PartialBlockStatement(partialBlock) { + var loc = partialBlock.loc; + throw new SyntaxError("Handlebars partial blocks are not supported: \"" + this.sourceForNode(partialBlock, partialBlock.name) + "\" at L" + loc.start.line + ":C" + loc.start.column, partialBlock.loc); + }; + + _proto2.Decorator = function Decorator(decorator) { + var loc = decorator.loc; + throw new SyntaxError("Handlebars decorators are not supported: \"" + this.sourceForNode(decorator, decorator.path) + "\" at L" + loc.start.line + ":C" + loc.start.column, decorator.loc); + }; + + _proto2.DecoratorBlock = function DecoratorBlock(decoratorBlock) { + var loc = decoratorBlock.loc; + throw new SyntaxError("Handlebars decorator blocks are not supported: \"" + this.sourceForNode(decoratorBlock, decoratorBlock.path) + "\" at L" + loc.start.line + ":C" + loc.start.column, decoratorBlock.loc); + }; + + _proto2.SubExpression = function SubExpression(sexpr) { + var _acceptCallNodes3 = acceptCallNodes(this, sexpr), + path = _acceptCallNodes3.path, + params = _acceptCallNodes3.params, + hash = _acceptCallNodes3.hash; + + return b.sexpr(path, params, hash, sexpr.loc); + }; + + _proto2.PathExpression = function PathExpression(path) { + var original = path.original, + loc = path.loc; + var parts; + + if (original.indexOf('/') !== -1) { + if (original.slice(0, 2) === './') { + throw new SyntaxError("Using \"./\" is not supported in Glimmer and unnecessary: \"" + path.original + "\" on line " + loc.start.line + ".", path.loc); + } + + if (original.slice(0, 3) === '../') { + throw new SyntaxError("Changing context using \"../\" is not supported in Glimmer: \"" + path.original + "\" on line " + loc.start.line + ".", path.loc); + } + + if (original.indexOf('.') !== -1) { + throw new SyntaxError("Mixing '.' and '/' in paths is not supported in Glimmer; use only '.' to separate property paths: \"" + path.original + "\" on line " + loc.start.line + ".", path.loc); + } + + parts = [path.parts.join('/')]; + } else if (original === '.') { + var locationInfo = "L" + loc.start.line + ":C" + loc.start.column; + throw new SyntaxError("'.' is not a supported path in Glimmer; check for a path with a trailing '.' at " + locationInfo + ".", path.loc); + } else { + parts = path.parts; + } + + var thisHead = false; // This is to fix a bug in the Handlebars AST where the path expressions in + // `{{this.foo}}` (and similarly `{{foo-bar this.foo named=this.foo}}` etc) + // are simply turned into `{{foo}}`. The fix is to push it back onto the + // parts array and let the runtime see the difference. However, we cannot + // simply use the string `this` as it means literally the property called + // "this" in the current context (it can be expressed in the syntax as + // `{{[this]}}`, where the square bracket are generally for this kind of + // escaping – such as `{{foo.["bar.baz"]}}` would mean lookup a property + // named literally "bar.baz" on `this.foo`). By convention, we use `null` + // for this purpose. + + if (original.match(/^this(\..+)?$/)) { + thisHead = true; + } + + return { + type: 'PathExpression', + original: path.original, + this: thisHead, + parts: parts, + data: path.data, + loc: path.loc + }; + }; + + _proto2.Hash = function Hash(hash) { + var pairs = []; + + for (var i = 0; i < hash.pairs.length; i++) { + var pair = hash.pairs[i]; + pairs.push(b.pair(pair.key, this.acceptNode(pair.value), pair.loc)); + } + + return b.hash(pairs, hash.loc); + }; + + _proto2.StringLiteral = function StringLiteral(string) { + return b.literal('StringLiteral', string.value, string.loc); + }; + + _proto2.BooleanLiteral = function BooleanLiteral(boolean) { + return b.literal('BooleanLiteral', boolean.value, boolean.loc); + }; + + _proto2.NumberLiteral = function NumberLiteral(number) { + return b.literal('NumberLiteral', number.value, number.loc); + }; + + _proto2.UndefinedLiteral = function UndefinedLiteral(undef) { + return b.literal('UndefinedLiteral', undefined, undef.loc); + }; + + _proto2.NullLiteral = function NullLiteral(nul) { + return b.literal('NullLiteral', null, nul.loc); + }; + + (0, _emberBabel.createClass)(HandlebarsNodeVisitors, [{ + key: "isTopLevel", + get: function get() { + return this.elementStack.length === 0; + } + }]); + return HandlebarsNodeVisitors; + }(Parser); + + function calculateRightStrippedOffsets(original, value) { + if (value === '') { + // if it is empty, just return the count of newlines + // in original + return { + lines: original.split('\n').length - 1, + columns: 0 + }; + } // otherwise, return the number of newlines prior to + // `value` + + + var difference = original.split(value)[0]; + var lines = difference.split(/\n/); + var lineCount = lines.length - 1; + return { + lines: lineCount, + columns: lines[lineCount].length + }; + } + + function updateTokenizerLocation(tokenizer, content) { + var line = content.loc.start.line; + var column = content.loc.start.column; + var offsets = calculateRightStrippedOffsets(content.original, content.value); + line = line + offsets.lines; + + if (offsets.lines) { + column = offsets.columns; + } else { + column = column + offsets.columns; + } + + tokenizer.line = line; + tokenizer.column = column; + } + + function acceptCallNodes(compiler, node) { + var path = compiler.PathExpression(node.path); + var params = node.params ? node.params.map(function (e) { + return compiler.acceptNode(e); + }) : []; + var hash = node.hash ? compiler.Hash(node.hash) : b.hash(); + return { + path: path, + params: params, + hash: hash + }; + } + + function addElementModifier(element, mustache) { + var path = mustache.path, + params = mustache.params, + hash = mustache.hash, + loc = mustache.loc; + + if (isLiteral(path)) { + var _modifier = "{{" + printLiteral(path) + "}}"; + + var tag = "<" + element.name + " ... " + _modifier + " ..."; + throw new SyntaxError("In " + tag + ", " + _modifier + " is not a valid modifier: \"" + path.original + "\" on line " + (loc && loc.start.line) + ".", mustache.loc); + } + + var modifier = b.elementModifier(path, params, hash, loc); + element.modifiers.push(modifier); + } + + function addInElementHash(cursor, hash, loc) { + var hasInsertBefore = false; + hash.pairs.forEach(function (pair) { + if (pair.key === 'guid') { + throw new SyntaxError('Cannot pass `guid` from user space', loc); + } + + if (pair.key === 'insertBefore') { + hasInsertBefore = true; + } + }); + var guid = b.literal('StringLiteral', cursor); + var guidPair = b.pair('guid', guid); + hash.pairs.unshift(guidPair); + + if (!hasInsertBefore) { + var undefinedLiteral = b.literal('UndefinedLiteral', undefined); + var beforeSibling = b.pair('insertBefore', undefinedLiteral); + hash.pairs.push(beforeSibling); + } + + return hash; + } + + function appendDynamicAttributeValuePart(attribute, part) { + attribute.isDynamic = true; + attribute.parts.push(part); + } // ensure stays in sync with typing + // ParentNode and ChildKey types are derived from VisitorKeysMap + + + var visitorKeys = { + Program: (0, _util.tuple)('body'), + Template: (0, _util.tuple)('body'), + Block: (0, _util.tuple)('body'), + MustacheStatement: (0, _util.tuple)('path', 'params', 'hash'), + BlockStatement: (0, _util.tuple)('path', 'params', 'hash', 'program', 'inverse'), + ElementModifierStatement: (0, _util.tuple)('path', 'params', 'hash'), + PartialStatement: (0, _util.tuple)('name', 'params', 'hash'), + CommentStatement: (0, _util.tuple)(), + MustacheCommentStatement: (0, _util.tuple)(), + ElementNode: (0, _util.tuple)('attributes', 'modifiers', 'children', 'comments'), + AttrNode: (0, _util.tuple)('value'), + TextNode: (0, _util.tuple)(), + ConcatStatement: (0, _util.tuple)('parts'), + SubExpression: (0, _util.tuple)('path', 'params', 'hash'), + PathExpression: (0, _util.tuple)(), + StringLiteral: (0, _util.tuple)(), + BooleanLiteral: (0, _util.tuple)(), + NumberLiteral: (0, _util.tuple)(), + NullLiteral: (0, _util.tuple)(), + UndefinedLiteral: (0, _util.tuple)(), + Hash: (0, _util.tuple)('pairs'), + HashPair: (0, _util.tuple)('value') + }; + + var TraversalError = function () { + TraversalError.prototype = Object.create(Error.prototype); + TraversalError.prototype.constructor = TraversalError; + + function TraversalError(message, node, parent, key) { + var error = Error.call(this, message); + this.key = key; + this.message = message; + this.node = node; + this.parent = parent; + this.stack = error.stack; + } + + return TraversalError; + }(); + + _exports.TraversalError = TraversalError; + + function cannotRemoveNode(node, parent, key) { + return new TraversalError('Cannot remove a node unless it is part of an array', node, parent, key); + } + + function cannotReplaceNode(node, parent, key) { + return new TraversalError('Cannot replace a node with multiple nodes unless it is part of an array', node, parent, key); + } + + function cannotReplaceOrRemoveInKeyHandlerYet(node, key) { + return new TraversalError('Replacing and removing in key handlers is not yet supported.', node, null, key); + } + + var Path = + /*#__PURE__*/ + function () { + function Path(node, parent, parentKey) { + if (parent === void 0) { + parent = null; + } + + if (parentKey === void 0) { + parentKey = null; + } + + this.node = node; + this.parent = parent; + this.parentKey = parentKey; + } + + var _proto3 = Path.prototype; + + _proto3.parents = function parents() { + var _this2 = this, + _ref; + + return _ref = {}, _ref[Symbol.iterator] = function () { + return new PathParentsIterator(_this2); + }, _ref; + }; + + (0, _emberBabel.createClass)(Path, [{ + key: "parentNode", + get: function get() { + return this.parent ? this.parent.node : null; + } + }]); + return Path; + }(); + + _exports.Path = Path; + + var PathParentsIterator = + /*#__PURE__*/ + function () { + function PathParentsIterator(path) { + this.path = path; + } + + var _proto4 = PathParentsIterator.prototype; + + _proto4.next = function next() { + if (this.path.parent) { + this.path = this.path.parent; + return { + done: false, + value: this.path + }; + } else { + return { + done: true, + value: null + }; + } + }; + + return PathParentsIterator; + }(); + + function getEnterFunction(handler) { + if (typeof handler === 'function') { + return handler; + } else { + return handler.enter; + } + } + + function getExitFunction(handler) { + if (typeof handler === 'function') { + return undefined; + } else { + return handler.exit; + } + } + + function getKeyHandler(handler, key) { + var keyVisitor = typeof handler !== 'function' ? handler.keys : undefined; + if (keyVisitor === undefined) return; + var keyHandler = keyVisitor[key]; + + if (keyHandler !== undefined) { + return keyHandler; + } + + return keyVisitor.All; + } + + function getNodeHandler(visitor, nodeType) { + if (nodeType === 'Template' || nodeType === 'Block') { + if (visitor.Program) { + return visitor.Program; + } + } + + var handler = visitor[nodeType]; + + if (handler !== undefined) { + return handler; + } + + return visitor.All; + } + + function visitNode(visitor, path) { + var node = path.node, + parent = path.parent, + parentKey = path.parentKey; + var handler = getNodeHandler(visitor, node.type); + var enter; + var exit; + + if (handler !== undefined) { + enter = getEnterFunction(handler); + exit = getExitFunction(handler); + } + + var result; + + if (enter !== undefined) { + result = enter(node, path); + } + + if (result !== undefined && result !== null) { + if (JSON.stringify(node) === JSON.stringify(result)) { + result = undefined; + } else if (Array.isArray(result)) { + visitArray(visitor, result, parent, parentKey); + return result; + } else { + var _path = new Path(result, parent, parentKey); + + return visitNode(visitor, _path) || result; + } + } + + if (result === undefined) { + var keys = visitorKeys[node.type]; + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; // we know if it has child keys we can widen to a ParentNode + + visitKey(visitor, handler, path, key); + } + + if (exit !== undefined) { + result = exit(node, path); + } + } + + return result; + } + + function get(node, key) { + return node[key]; + } + + function set(node, key, value) { + node[key] = value; + } + + function visitKey(visitor, handler, path, key) { + var node = path.node; + var value = get(node, key); + + if (!value) { + return; + } + + var keyEnter; + var keyExit; + + if (handler !== undefined) { + var keyHandler = getKeyHandler(handler, key); + + if (keyHandler !== undefined) { + keyEnter = getEnterFunction(keyHandler); + keyExit = getExitFunction(keyHandler); + } + } + + if (keyEnter !== undefined) { + if (keyEnter(node, key) !== undefined) { + throw cannotReplaceOrRemoveInKeyHandlerYet(node, key); + } + } + + if (Array.isArray(value)) { + visitArray(visitor, value, path, key); + } else { + var keyPath = new Path(value, path, key); + var result = visitNode(visitor, keyPath); + + if (result !== undefined) { + // TODO: dynamically check the results by having a table of + // expected node types in value space, not just type space + assignKey(node, key, value, result); + } + } + + if (keyExit !== undefined) { + if (keyExit(node, key) !== undefined) { + throw cannotReplaceOrRemoveInKeyHandlerYet(node, key); + } + } + } + + function visitArray(visitor, array, parent, parentKey) { + for (var i = 0; i < array.length; i++) { + var node = array[i]; + var path = new Path(node, parent, parentKey); + var result = visitNode(visitor, path); + + if (result !== undefined) { + i += spliceArray(array, i, result) - 1; + } + } + } + + function assignKey(node, key, value, result) { + if (result === null) { + throw cannotRemoveNode(value, node, key); + } else if (Array.isArray(result)) { + if (result.length === 1) { + set(node, key, result[0]); + } else { + if (result.length === 0) { + throw cannotRemoveNode(value, node, key); + } else { + throw cannotReplaceNode(value, node, key); + } + } + } else { + set(node, key, result); + } + } + + function spliceArray(array, index, result) { + if (result === null) { + array.splice(index, 1); + return 0; + } else if (Array.isArray(result)) { + array.splice.apply(array, [index, 1].concat(result)); + return result.length; + } else { + array.splice(index, 1, result); + return 1; + } + } + + function traverse(node, visitor) { + var path = new Path(node); + visitNode(visitor, path); + } + + var ATTR_VALUE_REGEX_TEST = /[\xA0"&]/; + var ATTR_VALUE_REGEX_REPLACE = new RegExp(ATTR_VALUE_REGEX_TEST.source, 'g'); + var TEXT_REGEX_TEST = /[\xA0&<>]/; + var TEXT_REGEX_REPLACE = new RegExp(TEXT_REGEX_TEST.source, 'g'); + + function attrValueReplacer(char) { + switch (char.charCodeAt(0)) { + case 160 + /* NBSP */ + : + return ' '; + + case 34 + /* QUOT */ + : + return '"'; + + case 38 + /* AMP */ + : + return '&'; + + default: + return char; + } + } + + function textReplacer(char) { + switch (char.charCodeAt(0)) { + case 160 + /* NBSP */ + : + return ' '; + + case 38 + /* AMP */ + : + return '&'; + + case 60 + /* LT */ + : + return '<'; + + case 62 + /* GT */ + : + return '>'; + + default: + return char; + } + } + + function escapeAttrValue(attrValue) { + if (ATTR_VALUE_REGEX_TEST.test(attrValue)) { + return attrValue.replace(ATTR_VALUE_REGEX_REPLACE, attrValueReplacer); + } + + return attrValue; + } + + function escapeText(text) { + if (TEXT_REGEX_TEST.test(text)) { + return text.replace(TEXT_REGEX_REPLACE, textReplacer); + } + + return text; + } + + var NON_WHITESPACE = /\S/; + + var Printer = + /*#__PURE__*/ + function () { + function Printer(options) { + this.buffer = ''; + this.options = options; + } + /* + This is used by _all_ methods on this Printer class that add to `this.buffer`, + it allows consumers of the printer to use alternate string representations for + a given node. + The primary use case for this are things like source -> source codemod utilities. + For example, ember-template-recast attempts to always preserve the original string + formatting in each AST node if no modifications are made to it. + */ + + + var _proto5 = Printer.prototype; + + _proto5.handledByOverride = function handledByOverride(node, ensureLeadingWhitespace) { + if (ensureLeadingWhitespace === void 0) { + ensureLeadingWhitespace = false; + } + + if (this.options.override !== undefined) { + var result = this.options.override(node, this.options); + + if (typeof result === 'string') { + if (ensureLeadingWhitespace && NON_WHITESPACE.test(result[0])) { + result = " " + result; + } + + this.buffer += result; + return true; + } + } + + return false; + }; + + _proto5.Node = function Node(node) { + switch (node.type) { + case 'MustacheStatement': + case 'BlockStatement': + case 'PartialStatement': + case 'MustacheCommentStatement': + case 'CommentStatement': + case 'TextNode': + case 'ElementNode': + case 'AttrNode': + case 'Block': + case 'Template': + return this.TopLevelStatement(node); + + case 'StringLiteral': + case 'BooleanLiteral': + case 'NumberLiteral': + case 'UndefinedLiteral': + case 'NullLiteral': + case 'PathExpression': + case 'SubExpression': + return this.Expression(node); + + case 'Program': + return this.Block(node); + + case 'ConcatStatement': + // should have an AttrNode parent + return this.ConcatStatement(node); + + case 'Hash': + return this.Hash(node); + + case 'HashPair': + return this.HashPair(node); + + case 'ElementModifierStatement': + return this.ElementModifierStatement(node); + } + + return unreachable(node, 'Node'); + }; + + _proto5.Expression = function Expression(expression) { + switch (expression.type) { + case 'StringLiteral': + case 'BooleanLiteral': + case 'NumberLiteral': + case 'UndefinedLiteral': + case 'NullLiteral': + return this.Literal(expression); + + case 'PathExpression': + return this.PathExpression(expression); + + case 'SubExpression': + return this.SubExpression(expression); + } + + return unreachable(expression, 'Expression'); + }; + + _proto5.Literal = function Literal(literal) { + switch (literal.type) { + case 'StringLiteral': + return this.StringLiteral(literal); + + case 'BooleanLiteral': + return this.BooleanLiteral(literal); + + case 'NumberLiteral': + return this.NumberLiteral(literal); + + case 'UndefinedLiteral': + return this.UndefinedLiteral(literal); + + case 'NullLiteral': + return this.NullLiteral(literal); + } + + return unreachable(literal, 'Literal'); + }; + + _proto5.TopLevelStatement = function TopLevelStatement(statement) { + switch (statement.type) { + case 'MustacheStatement': + return this.MustacheStatement(statement); + + case 'BlockStatement': + return this.BlockStatement(statement); + + case 'PartialStatement': + return this.PartialStatement(statement); + + case 'MustacheCommentStatement': + return this.MustacheCommentStatement(statement); + + case 'CommentStatement': + return this.CommentStatement(statement); + + case 'TextNode': + return this.TextNode(statement); + + case 'ElementNode': + return this.ElementNode(statement); + + case 'Block': + case 'Template': + return this.Block(statement); + + case 'AttrNode': + // should have element + return this.AttrNode(statement); + } + + unreachable(statement, 'TopLevelStatement'); + }; + + _proto5.Block = function Block(block) { + /* + When processing a template like: + ```hbs + {{#if whatever}} + whatever + {{else if somethingElse}} + something else + {{else}} + fallback + {{/if}} + ``` + The AST still _effectively_ looks like: + ```hbs + {{#if whatever}} + whatever + {{else}}{{#if somethingElse}} + something else + {{else}} + fallback + {{/if}}{{/if}} + ``` + The only way we can tell if that is the case is by checking for + `block.chained`, but unfortunately when the actual statements are + processed the `block.body[0]` node (which will always be a + `BlockStatement`) has no clue that its anscestor `Block` node was + chained. + This "forwards" the `chained` setting so that we can check + it later when processing the `BlockStatement`. + */ + if (block.chained) { + var firstChild = block.body[0]; + firstChild.chained = true; + } + + if (this.handledByOverride(block)) { + return; + } + + this.TopLevelStatements(block.body); + }; + + _proto5.TopLevelStatements = function TopLevelStatements(statements) { + var _this3 = this; + + statements.forEach(function (statement) { + return _this3.TopLevelStatement(statement); + }); + }; + + _proto5.ElementNode = function ElementNode(el) { + if (this.handledByOverride(el)) { + return; + } + + this.OpenElementNode(el); + this.TopLevelStatements(el.children); + this.CloseElementNode(el); + }; + + _proto5.OpenElementNode = function OpenElementNode(el) { + var _this4 = this; + + this.buffer += "<" + el.tag; + + if (el.attributes.length) { + el.attributes.forEach(function (attr) { + _this4.buffer += ' '; + + _this4.AttrNode(attr); + }); + } + + if (el.modifiers.length) { + el.modifiers.forEach(function (mod) { + _this4.buffer += ' '; + + _this4.ElementModifierStatement(mod); + }); + } + + if (el.comments.length) { + el.comments.forEach(function (comment) { + _this4.buffer += ' '; + + _this4.MustacheCommentStatement(comment); + }); + } + + if (el.blockParams.length) { + this.BlockParams(el.blockParams); + } + + if (el.selfClosing) { + this.buffer += ' /'; + } + + this.buffer += '>'; + }; + + _proto5.CloseElementNode = function CloseElementNode(el) { + if (el.selfClosing || voidMap[el.tag.toLowerCase()]) { + return; + } + + this.buffer += ""; + }; + + _proto5.AttrNode = function AttrNode(attr) { + if (this.handledByOverride(attr)) { + return; + } + + var name = attr.name, + value = attr.value; + this.buffer += name; + + if (value.type !== 'TextNode' || value.chars.length > 0) { + this.buffer += '='; + this.AttrNodeValue(value); + } + }; + + _proto5.AttrNodeValue = function AttrNodeValue(value) { + if (value.type === 'TextNode') { + this.buffer += '"'; + this.TextNode(value, true); + this.buffer += '"'; + } else { + this.Node(value); + } + }; + + _proto5.TextNode = function TextNode(text, isAttr) { + if (this.handledByOverride(text)) { + return; + } + + if (this.options.entityEncoding === 'raw') { + this.buffer += text.chars; + } else if (isAttr) { + this.buffer += escapeAttrValue(text.chars); + } else { + this.buffer += escapeText(text.chars); + } + }; + + _proto5.MustacheStatement = function MustacheStatement(mustache) { + if (this.handledByOverride(mustache)) { + return; + } + + this.buffer += mustache.escaped ? '{{' : '{{{'; + + if (mustache.strip.open) { + this.buffer += '~'; + } + + this.Expression(mustache.path); + this.Params(mustache.params); + this.Hash(mustache.hash); + + if (mustache.strip.close) { + this.buffer += '~'; + } + + this.buffer += mustache.escaped ? '}}' : '}}}'; + }; + + _proto5.BlockStatement = function BlockStatement(block) { + if (this.handledByOverride(block)) { + return; + } + + if (block.chained) { + this.buffer += block.inverseStrip.open ? '{{~' : '{{'; + this.buffer += 'else '; + } else { + this.buffer += block.openStrip.open ? '{{~#' : '{{#'; + } + + this.Expression(block.path); + this.Params(block.params); + this.Hash(block.hash); + + if (block.program.blockParams.length) { + this.BlockParams(block.program.blockParams); + } + + if (block.chained) { + this.buffer += block.inverseStrip.close ? '~}}' : '}}'; + } else { + this.buffer += block.openStrip.close ? '~}}' : '}}'; + } + + this.Block(block.program); + + if (block.inverse) { + if (!block.inverse.chained) { + this.buffer += block.inverseStrip.open ? '{{~' : '{{'; + this.buffer += 'else'; + this.buffer += block.inverseStrip.close ? '~}}' : '}}'; + } + + this.Block(block.inverse); + } + + if (!block.chained) { + this.buffer += block.closeStrip.open ? '{{~/' : '{{/'; + this.Expression(block.path); + this.buffer += block.closeStrip.close ? '~}}' : '}}'; + } + }; + + _proto5.BlockParams = function BlockParams(blockParams) { + this.buffer += " as |" + blockParams.join(' ') + "|"; + }; + + _proto5.PartialStatement = function PartialStatement(partial) { + if (this.handledByOverride(partial)) { + return; + } + + this.buffer += '{{>'; + this.Expression(partial.name); + this.Params(partial.params); + this.Hash(partial.hash); + this.buffer += '}}'; + }; + + _proto5.ConcatStatement = function ConcatStatement(concat) { + var _this5 = this; + + if (this.handledByOverride(concat)) { + return; + } + + this.buffer += '"'; + concat.parts.forEach(function (part) { + if (part.type === 'TextNode') { + _this5.TextNode(part, true); + } else { + _this5.Node(part); + } + }); + this.buffer += '"'; + }; + + _proto5.MustacheCommentStatement = function MustacheCommentStatement(comment) { + if (this.handledByOverride(comment)) { + return; + } + + this.buffer += "{{!--" + comment.value + "--}}"; + }; + + _proto5.ElementModifierStatement = function ElementModifierStatement(mod) { + if (this.handledByOverride(mod)) { + return; + } + + this.buffer += '{{'; + this.Expression(mod.path); + this.Params(mod.params); + this.Hash(mod.hash); + this.buffer += '}}'; + }; + + _proto5.CommentStatement = function CommentStatement(comment) { + if (this.handledByOverride(comment)) { + return; + } + + this.buffer += ""; + }; + + _proto5.PathExpression = function PathExpression(path) { + if (this.handledByOverride(path)) { + return; + } + + this.buffer += path.original; + }; + + _proto5.SubExpression = function SubExpression(sexp) { + if (this.handledByOverride(sexp)) { + return; + } + + this.buffer += '('; + this.Expression(sexp.path); + this.Params(sexp.params); + this.Hash(sexp.hash); + this.buffer += ')'; + }; + + _proto5.Params = function Params(params) { + var _this6 = this; + + // TODO: implement a top level Params AST node (just like the Hash object) + // so that this can also be overridden + if (params.length) { + params.forEach(function (param) { + _this6.buffer += ' '; + + _this6.Expression(param); + }); + } + }; - if (keyHandler !== undefined) { - keyEnter = getEnterFunction(keyHandler); - keyExit = getExitFunction(keyHandler); + _proto5.Hash = function Hash(hash) { + var _this7 = this; + + if (this.handledByOverride(hash, true)) { + return; } - } - if (keyEnter !== undefined) { - if (keyEnter(node, key) !== undefined) { - throw cannotReplaceOrRemoveInKeyHandlerYet(node, key); + hash.pairs.forEach(function (pair) { + _this7.buffer += ' '; + + _this7.HashPair(pair); + }); + }; + + _proto5.HashPair = function HashPair(pair) { + if (this.handledByOverride(pair)) { + return; } - } - if (Array.isArray(value)) { - visitArray(visitor, value); - } else { - var result = visitNode(visitor, value); + this.buffer += pair.key; + this.buffer += '='; + this.Node(pair.value); + }; - if (result !== undefined) { - assignKey(node, key, result); + _proto5.StringLiteral = function StringLiteral(str) { + if (this.handledByOverride(str)) { + return; } - } - if (keyExit !== undefined) { - if (keyExit(node, key) !== undefined) { - throw cannotReplaceOrRemoveInKeyHandlerYet(node, key); + this.buffer += JSON.stringify(str.value); + }; + + _proto5.BooleanLiteral = function BooleanLiteral(bool) { + if (this.handledByOverride(bool)) { + return; } - } - } - function visitArray(visitor, array) { - for (var i = 0; i < array.length; i++) { - var result = visitNode(visitor, array[i]); + this.buffer += bool.value; + }; - if (result !== undefined) { - i += spliceArray(array, i, result) - 1; + _proto5.NumberLiteral = function NumberLiteral(number) { + if (this.handledByOverride(number)) { + return; } - } - } - function assignKey(node, key, result) { - if (result === null) { - throw cannotRemoveNode(node[key], node, key); - } else if (Array.isArray(result)) { - if (result.length === 1) { - node[key] = result[0]; - } else { - if (result.length === 0) { - throw cannotRemoveNode(node[key], node, key); - } else { - throw cannotReplaceNode(node[key], node, key); + this.buffer += number.value; + }; + + _proto5.UndefinedLiteral = function UndefinedLiteral(node) { + if (this.handledByOverride(node)) { + return; + } + + this.buffer += 'undefined'; + }; + + _proto5.NullLiteral = function NullLiteral(node) { + if (this.handledByOverride(node)) { + return; + } + + this.buffer += 'null'; + }; + + _proto5.print = function print(node) { + var options = this.options; + + if (options.override) { + var result = options.override(node, options); + + if (result !== undefined) { + return result; } } - } else { - node[key] = result; - } + + this.buffer = ''; + this.Node(node); + return this.buffer; + }; + + return Printer; + }(); + + function unreachable(node, parentNodeType) { + var loc = node.loc, + type = node.type; + throw new Error("Non-exhaustive node narrowing " + type + " @ location: " + JSON.stringify(loc) + " for parent " + parentNodeType); } - function spliceArray(array, index, result) { - if (result === null) { - array.splice(index, 1); - return 0; - } else if (Array.isArray(result)) { - array.splice.apply(array, [index, 1].concat(result)); - return result.length; - } else { - array.splice(index, 1, result); - return 1; + function build(ast, options) { + if (options === void 0) { + options = { + entityEncoding: 'transformed' + }; } - } - function traverse(node, visitor) { - visitNode(visitor, node); + if (!ast) { + return ''; + } + + var printer = new Printer(options); + return printer.print(ast); } - var ATTR_VALUE_REGEX_TEST = /[\xA0"&]/; - var ATTR_VALUE_REGEX_REPLACE = new RegExp(ATTR_VALUE_REGEX_TEST.source, 'g'); - var TEXT_REGEX_TEST = /[\xA0&<>]/; - var TEXT_REGEX_REPLACE = new RegExp(TEXT_REGEX_TEST.source, 'g'); + var Walker = + /*#__PURE__*/ + function () { + function Walker(order) { + this.order = order; + this.stack = []; + } - function attrValueReplacer(char) { - switch (char.charCodeAt(0)) { - case 160 - /* NBSP */ - : - return ' '; + var _proto6 = Walker.prototype; - case 34 - /* QUOT */ - : - return '"'; + _proto6.visit = function visit(node, callback) { + if (!node) { + return; + } - case 38 - /* AMP */ - : - return '&'; + this.stack.push(node); - default: - return char; - } - } + if (this.order === 'post') { + this.children(node, callback); + callback(node, this); + } else { + callback(node, this); + this.children(node, callback); + } - function textReplacer(char) { - switch (char.charCodeAt(0)) { - case 160 - /* NBSP */ - : - return ' '; + this.stack.pop(); + }; - case 38 - /* AMP */ - : - return '&'; + _proto6.children = function children(node, callback) { + var type; - case 60 - /* LT */ - : - return '<'; + if (node.type === 'Block' || node.type === 'Template' && visitors.Program) { + type = 'Program'; + } else { + type = node.type; + } - case 62 - /* GT */ - : - return '>'; + var visitor = visitors[type]; - default: - return char; + if (visitor) { + visitor(this, node, callback); + } + }; + + return Walker; + }(); + + _exports.Walker = Walker; + var visitors = { + Program: function Program(walker, node, callback) { + for (var i = 0; i < node.body.length; i++) { + walker.visit(node.body[i], callback); + } + }, + Template: function Template(walker, node, callback) { + for (var i = 0; i < node.body.length; i++) { + walker.visit(node.body[i], callback); + } + }, + Block: function Block(walker, node, callback) { + for (var i = 0; i < node.body.length; i++) { + walker.visit(node.body[i], callback); + } + }, + ElementNode: function ElementNode(walker, node, callback) { + for (var i = 0; i < node.children.length; i++) { + walker.visit(node.children[i], callback); + } + }, + BlockStatement: function BlockStatement(walker, node, callback) { + walker.visit(node.program, callback); + walker.visit(node.inverse || null, callback); } - } + }; + var voidMap = Object.create(null); + var voidTagNames = 'area base br col command embed hr img input keygen link meta param source track wbr'; + voidTagNames.split(' ').forEach(function (tagName) { + voidMap[tagName] = true; + }); - function escapeAttrValue(attrValue) { - if (ATTR_VALUE_REGEX_TEST.test(attrValue)) { - return attrValue.replace(ATTR_VALUE_REGEX_REPLACE, attrValueReplacer); + var TokenizerEventHandlers = + /*#__PURE__*/ + function (_HandlebarsNodeVisito) { + (0, _emberBabel.inheritsLoose)(TokenizerEventHandlers, _HandlebarsNodeVisito); + + function TokenizerEventHandlers() { + var _this8; + + _this8 = _HandlebarsNodeVisito.apply(this, arguments) || this; + _this8.tagOpenLine = 0; + _this8.tagOpenColumn = 0; + return _this8; } - return attrValue; - } + var _proto7 = TokenizerEventHandlers.prototype; + + _proto7.reset = function reset() { + this.currentNode = null; + } // Comment + ; + + _proto7.beginComment = function beginComment() { + this.currentNode = b.comment(''); + this.currentNode.loc = { + source: null, + start: b.pos(this.tagOpenLine, this.tagOpenColumn), + end: null + }; + }; + + _proto7.appendToCommentData = function appendToCommentData(char) { + this.currentComment.value += char; + }; + + _proto7.finishComment = function finishComment() { + this.currentComment.loc.end = b.pos(this.tokenizer.line, this.tokenizer.column); + appendChild(this.currentElement(), this.currentComment); + } // Data + ; + + _proto7.beginData = function beginData() { + this.currentNode = b.text(); + this.currentNode.loc = { + source: null, + start: b.pos(this.tokenizer.line, this.tokenizer.column), + end: null + }; + }; + + _proto7.appendToData = function appendToData(char) { + this.currentData.chars += char; + }; + + _proto7.finishData = function finishData() { + this.currentData.loc.end = b.pos(this.tokenizer.line, this.tokenizer.column); + appendChild(this.currentElement(), this.currentData); + } // Tags - basic + ; + + _proto7.tagOpen = function tagOpen() { + this.tagOpenLine = this.tokenizer.line; + this.tagOpenColumn = this.tokenizer.column; + }; + + _proto7.beginStartTag = function beginStartTag() { + this.currentNode = { + type: 'StartTag', + name: '', + attributes: [], + modifiers: [], + comments: [], + selfClosing: false, + loc: SYNTHETIC + }; + }; + + _proto7.beginEndTag = function beginEndTag() { + this.currentNode = { + type: 'EndTag', + name: '', + attributes: [], + modifiers: [], + comments: [], + selfClosing: false, + loc: SYNTHETIC + }; + }; + + _proto7.finishTag = function finishTag() { + var _this$tokenizer = this.tokenizer, + line = _this$tokenizer.line, + column = _this$tokenizer.column; + var tag = this.currentTag; + tag.loc = b.loc(this.tagOpenLine, this.tagOpenColumn, line, column); - function escapeText(text) { - if (TEXT_REGEX_TEST.test(text)) { - return text.replace(TEXT_REGEX_REPLACE, textReplacer); - } + if (tag.type === 'StartTag') { + this.finishStartTag(); - return text; - } + if (voidMap[tag.name] || tag.selfClosing) { + this.finishEndTag(true); + } + } else if (tag.type === 'EndTag') { + this.finishEndTag(false); + } + }; - function unreachable() { - throw new Error('unreachable'); - } + _proto7.finishStartTag = function finishStartTag() { + var _this$currentStartTag = this.currentStartTag, + name = _this$currentStartTag.name, + attrs = _this$currentStartTag.attributes, + modifiers = _this$currentStartTag.modifiers, + comments = _this$currentStartTag.comments, + selfClosing = _this$currentStartTag.selfClosing; + var loc = b.loc(this.tagOpenLine, this.tagOpenColumn); + var element = b.element({ + name: name, + selfClosing: selfClosing + }, { + attrs: attrs, + modifiers: modifiers, + comments: comments, + loc: loc + }); + this.elementStack.push(element); + }; - function build(ast) { - if (!ast) { - return ''; - } + _proto7.finishEndTag = function finishEndTag(isVoid) { + var tag = this.currentTag; + var element = this.elementStack.pop(); + var parent = this.currentElement(); + validateEndTag(tag, element, isVoid); + element.loc.end.line = this.tokenizer.line; + element.loc.end.column = this.tokenizer.column; + parseElementBlockParams(element); + appendChild(parent, element); + }; - var output = []; + _proto7.markTagAsSelfClosing = function markTagAsSelfClosing() { + this.currentTag.selfClosing = true; + } // Tags - name + ; - switch (ast.type) { - case 'Program': - { - var chainBlock = ast['chained'] && ast.body[0]; + _proto7.appendToTagName = function appendToTagName(char) { + this.currentTag.name += char; + } // Tags - attributes + ; - if (chainBlock) { - chainBlock['chained'] = true; - } + _proto7.beginAttribute = function beginAttribute() { + var tag = this.currentTag; - var body = buildEach(ast.body).join(''); - output.push(body); - } - break; + if (tag.type === 'EndTag') { + throw new SyntaxError("Invalid end tag: closing tag must not have attributes, " + ("in `" + tag.name + "` (on line " + this.tokenizer.line + ")."), tag.loc); + } - case 'ElementNode': - output.push('<', ast.tag); + this.currentAttribute = { + name: '', + parts: [], + isQuoted: false, + isDynamic: false, + start: b.pos(this.tokenizer.line, this.tokenizer.column), + valueStartLine: 0, + valueStartColumn: 0 + }; + }; - if (ast.attributes.length) { - output.push(' ', buildEach(ast.attributes).join(' ')); - } + _proto7.appendToAttributeName = function appendToAttributeName(char) { + this.currentAttr.name += char; + }; - if (ast.modifiers.length) { - output.push(' ', buildEach(ast.modifiers).join(' ')); - } + _proto7.beginAttributeValue = function beginAttributeValue(isQuoted) { + this.currentAttr.isQuoted = isQuoted; + this.currentAttr.valueStartLine = this.tokenizer.line; + this.currentAttr.valueStartColumn = this.tokenizer.column; + }; - if (ast.comments.length) { - output.push(' ', buildEach(ast.comments).join(' ')); - } + _proto7.appendToAttributeValue = function appendToAttributeValue(char) { + var parts = this.currentAttr.parts; + var lastPart = parts[parts.length - 1]; - if (ast.blockParams.length) { - output.push(' ', 'as', ' ', "|" + ast.blockParams.join(' ') + "|"); - } + if (lastPart && lastPart.type === 'TextNode') { + lastPart.chars += char; // update end location for each added char - if (voidMap[ast.tag]) { - if (ast.selfClosing) { - output.push(' /'); - } + lastPart.loc.end.line = this.tokenizer.line; + lastPart.loc.end.column = this.tokenizer.column; + } else { + // initially assume the text node is a single char + var loc = b.loc(this.tokenizer.line, this.tokenizer.column, this.tokenizer.line, this.tokenizer.column); // the tokenizer line/column have already been advanced, correct location info - output.push('>'); + if (char === '\n') { + loc.start.line -= 1; + loc.start.column = lastPart ? lastPart.loc.end.column : this.currentAttr.valueStartColumn; } else { - output.push('>'); - output.push.apply(output, buildEach(ast.children)); - output.push(''); + loc.start.column -= 1; } - break; - - case 'AttrNode': - if (ast.value.type === 'TextNode') { - if (ast.value.chars !== '') { - output.push(ast.name, '='); - output.push('"', escapeAttrValue(ast.value.chars), '"'); - } else { - output.push(ast.name); - } - } else { - output.push(ast.name, '='); // ast.value is mustache or concat - - output.push(build(ast.value)); - } + var text = b.text(char, loc); + parts.push(text); + } + }; - break; + _proto7.finishAttributeValue = function finishAttributeValue() { + var _this$currentAttr = this.currentAttr, + name = _this$currentAttr.name, + parts = _this$currentAttr.parts, + isQuoted = _this$currentAttr.isQuoted, + isDynamic = _this$currentAttr.isDynamic, + valueStartLine = _this$currentAttr.valueStartLine, + valueStartColumn = _this$currentAttr.valueStartColumn; + var value = assembleAttributeValue(parts, isQuoted, isDynamic, this.tokenizer.line); + value.loc = b.loc(valueStartLine, valueStartColumn, this.tokenizer.line, this.tokenizer.column); + var loc = b.loc(this.currentAttr.start.line, this.currentAttr.start.column, this.tokenizer.line, this.tokenizer.column); + var attribute = b.attr(name, value, loc); + this.currentStartTag.attributes.push(attribute); + }; - case 'ConcatStatement': - output.push('"'); - ast.parts.forEach(function (node) { - if (node.type === 'TextNode') { - output.push(escapeAttrValue(node.chars)); - } else { - output.push(build(node)); - } - }); - output.push('"'); - break; + _proto7.reportSyntaxError = function reportSyntaxError(message) { + throw new SyntaxError("Syntax error at line " + this.tokenizer.line + " col " + this.tokenizer.column + ": " + message, b.loc(this.tokenizer.line, this.tokenizer.column)); + }; - case 'TextNode': - output.push(escapeText(ast.chars)); - break; + return TokenizerEventHandlers; + }(HandlebarsNodeVisitors); - case 'MustacheStatement': - { - output.push(compactJoin(['{{', pathParams(ast), '}}'])); + function assembleAttributeValue(parts, isQuoted, isDynamic, line) { + if (isDynamic) { + if (isQuoted) { + return assembleConcatenatedValue(parts); + } else { + if (parts.length === 1 || parts.length === 2 && parts[1].type === 'TextNode' && parts[1].chars === '/') { + return parts[0]; + } else { + throw new SyntaxError("An unquoted attribute value must be a string or a mustache, " + "preceeded by whitespace or a '=' character, and " + ("followed by whitespace, a '>' character, or '/>' (on line " + line + ")"), b.loc(line, 0)); } - break; + } + } else { + return parts.length > 0 ? parts[0] : b.text(''); + } + } - case 'MustacheCommentStatement': - { - output.push(compactJoin(['{{!--', ast.value, '--}}'])); - } - break; + function assembleConcatenatedValue(parts) { + for (var i = 0; i < parts.length; i++) { + var part = parts[i]; - case 'ElementModifierStatement': - { - output.push(compactJoin(['{{', pathParams(ast), '}}'])); - } - break; + if (part.type !== 'MustacheStatement' && part.type !== 'TextNode') { + throw new SyntaxError('Unsupported node in quoted attribute value: ' + part['type'], part.loc); + } + } - case 'PathExpression': - output.push(ast.original); - break; + return b.concat(parts); + } - case 'SubExpression': - { - output.push('(', pathParams(ast), ')'); - } - break; + function validateEndTag(tag, element, selfClosing) { + var error; - case 'BooleanLiteral': - output.push(ast.value ? 'true' : 'false'); - break; + if (voidMap[tag.name] && !selfClosing) { + // EngTag is also called by StartTag for void and self-closing tags (i.e. + // or
, so we need to check for that here. Otherwise, we would + // throw an error for those cases. + error = 'Invalid end tag ' + formatEndTagInfo(tag) + ' (void elements cannot have end tags).'; + } else if (element.tag === undefined) { + error = 'Closing tag ' + formatEndTagInfo(tag) + ' without an open tag.'; + } else if (element.tag !== tag.name) { + error = 'Closing tag ' + formatEndTagInfo(tag) + ' did not match last open tag `' + element.tag + '` (on line ' + element.loc.start.line + ').'; + } - case 'BlockStatement': - { - var lines = []; + if (error) { + throw new SyntaxError(error, element.loc); + } + } - if (ast['chained']) { - lines.push(['{{else ', pathParams(ast), '}}'].join('')); - } else { - lines.push(openBlock(ast)); - } + function formatEndTagInfo(tag) { + return '`' + tag.name + '` (on line ' + tag.loc.end.line + ')'; + } + + var syntax = { + parse: preprocess, + builders: b, + print: build, + traverse: traverse, + Walker: Walker + }; - lines.push(build(ast.program)); + function preprocess(html, options) { + if (options === void 0) { + options = {}; + } - if (ast.inverse) { - if (!ast.inverse['chained']) { - lines.push('{{else}}'); - } + var mode = options.mode || 'precompile'; + var ast; - lines.push(build(ast.inverse)); - } + if (typeof html === 'object') { + ast = html; + } else if (mode === 'codemod') { + ast = (0, _handlebars.parseWithoutProcessing)(html, options.parseOptions); + } else { + ast = (0, _handlebars.parse)(html, options.parseOptions); + } - if (!ast['chained']) { - lines.push(closeBlock(ast)); - } + var entityParser = undefined; - output.push(lines.join('')); - } - break; + if (mode === 'codemod') { + entityParser = new _simpleHtmlTokenizer.EntityParser({}); + } - case 'PartialStatement': - { - output.push(compactJoin(['{{>', pathParams(ast), '}}'])); - } - break; + var program = new TokenizerEventHandlers(html, entityParser).acceptTemplate(ast); - case 'CommentStatement': - { - output.push(compactJoin([''])); - } - break; + if (options && options.plugins && options.plugins.ast) { + for (var i = 0, l = options.plugins.ast.length; i < l; i++) { + var transform = options.plugins.ast[i]; + var env = (0, _util.assign)({}, options, { + syntax: syntax + }, { + plugins: undefined + }); + var pluginResult = transform(env); + traverse(program, pluginResult.visitor); + } + } - case 'StringLiteral': - { - output.push("\"" + ast.value + "\""); - } - break; + return program; + } - case 'NumberLiteral': - { - output.push(String(ast.value)); - } - break; + var nodes = + /*#__PURE__*/ + Object.freeze({}); // used by ember-compiler - case 'UndefinedLiteral': - { - output.push('undefined'); - } - break; + _exports.AST = nodes; +}); +define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBabel) { + "use strict"; - case 'NullLiteral': - { - output.push('null'); - } - break; + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.assertNever = assertNever; + _exports.assert = debugAssert; + _exports.deprecate = deprecate; + _exports.dict = dict; + _exports.isDict = isDict; + _exports.isObject = isObject; + _exports.ensureGuid = ensureGuid; + _exports.initializeGuid = initializeGuid; + _exports.isSerializationFirstNode = isSerializationFirstNode; + _exports.assign = assign; + _exports.fillNulls = fillNulls; + _exports.values = values; + _exports.isDestroyable = isDestroyable; + _exports.isStringDestroyable = isStringDestroyable; + _exports.clearElement = clearElement; + _exports.isDrop = isDrop; + _exports.associate = associate; + _exports.associateDestructor = associateDestructor; + _exports.peekAssociated = peekAssociated; + _exports.takeAssociated = takeAssociated; + _exports.willDestroyAssociated = willDestroyAssociated; + _exports.didDestroyAssociated = didDestroyAssociated; + _exports.destructor = destructor; + _exports.snapshot = snapshot; + _exports.debugDropTree = debugDropTree; + _exports.printDropTree = printDropTree; + _exports.printDrop = printDrop; + _exports.keys = keys; + _exports.unwrap = unwrap; + _exports.expect = expect; + _exports.unreachable = unreachable; + _exports.exhausted = exhausted; + _exports.strip = strip; + _exports.encodeImmediate = encodeImmediate; + _exports.decodeImmediate = decodeImmediate; + _exports.isSmallInt = isSmallInt; + _exports.isHandle = isHandle; + _exports.encodeHandle = encodeHandle; + _exports.decodeHandle = decodeHandle; + _exports.symbol = _exports.tuple = _exports.ListContentsDestructor = _exports.DESTRUCTORS = _exports.CHILDREN = _exports.DID_DROP = _exports.WILL_DROP = _exports.LINKED = _exports.DESTROY = _exports.debugToString = _exports.ListSlice = _exports.ListNode = _exports.LinkedList = _exports.EMPTY_SLICE = _exports.SERIALIZATION_FIRST_NODE_STRING = _exports.Stack = _exports.DictSet = _exports.EMPTY_ARRAY = void 0; + var EMPTY_ARRAY = Object.freeze([]); // import Logger from './logger'; + // let alreadyWarned = false; - case 'Hash': - { - output.push(ast.pairs.map(function (pair) { - return build(pair); - }).join(' ')); - } - break; + _exports.EMPTY_ARRAY = EMPTY_ARRAY; - case 'HashPair': - { - output.push(ast.key + "=" + build(ast.value)); - } - break; + function debugAssert(test, msg) { + // if (!alreadyWarned) { + // alreadyWarned = true; + // Logger.warn("Don't leave debug assertions on in public builds"); + // } + if (!test) { + throw new Error(msg || 'assertion failure'); } - - return output.join(''); - } - - function compact(array) { - var newArray = []; - array.forEach(function (a) { - if (typeof a !== 'undefined' && a !== null && a !== '') { - newArray.push(a); - } - }); - return newArray; } - function buildEach(asts) { - return asts.map(build); + function deprecate(desc) { + console.warn("DEPRECATION: " + desc); } - function pathParams(ast) { - var path; - - switch (ast.type) { - case 'MustacheStatement': - case 'SubExpression': - case 'ElementModifierStatement': - case 'BlockStatement': - if (isLiteral(ast.path)) { - return String(ast.path.value); - } - - path = build(ast.path); - break; - - case 'PartialStatement': - path = build(ast.name); - break; - - default: - return unreachable(); - } + var GUID = 0; - return compactJoin([path, buildEach(ast.params).join(' '), build(ast.hash)], ' '); + function initializeGuid(object) { + return object._guid = ++GUID; } - function compactJoin(array, delimiter) { - return compact(array).join(delimiter || ''); + function ensureGuid(object) { + return object._guid || initializeGuid(object); } - function blockParams(block) { - var params = block.program.blockParams; - - if (params.length) { - return " as |" + params.join(' ') + "|"; - } - - return null; + function dict() { + return Object.create(null); } - function openBlock(block) { - return ['{{#', pathParams(block), blockParams(block), '}}'].join(''); + function isDict(u) { + return u !== null && u !== undefined; } - function closeBlock(block) { - return ['{{/', build(block.path), '}}'].join(''); + function isObject(u) { + return typeof u === 'object' && u !== null; } - var Walker = + var DictSet = /*#__PURE__*/ function () { - function Walker(order) { - this.order = order; - this.stack = []; + function DictSet() { + this.dict = dict(); } - var _proto3 = Walker.prototype; - - _proto3.visit = function visit(node, callback) { - if (!node) { - return; - } - - this.stack.push(node); - - if (this.order === 'post') { - this.children(node, callback); - callback(node, this); - } else { - callback(node, this); - this.children(node, callback); - } + var _proto = DictSet.prototype; - this.stack.pop(); + _proto.add = function add(obj) { + if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[ensureGuid(obj)] = obj; + return this; }; - _proto3.children = function children(node, callback) { - var visitor = visitors[node.type]; - - if (visitor) { - visitor(this, node, callback); - } + _proto.delete = function _delete(obj) { + if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; }; - return Walker; + return DictSet; }(); - _exports.Walker = Walker; - var visitors = { - Program: function Program(walker, node, callback) { - for (var i = 0; i < node.body.length; i++) { - walker.visit(node.body[i], callback); - } - }, - ElementNode: function ElementNode(walker, node, callback) { - for (var i = 0; i < node.children.length; i++) { - walker.visit(node.children[i], callback); - } - }, - BlockStatement: function BlockStatement(walker, node, callback) { - walker.visit(node.program, callback); - walker.visit(node.inverse || null, callback); - } - }; - var voidMap = Object.create(null); - var voidTagNames = 'area base br col command embed hr img input keygen link meta param source track wbr'; - voidTagNames.split(' ').forEach(function (tagName) { - voidMap[tagName] = true; - }); + _exports.DictSet = DictSet; - var TokenizerEventHandlers = + var StackImpl = /*#__PURE__*/ - function (_HandlebarsNodeVisito) { - (0, _emberBabel.inheritsLoose)(TokenizerEventHandlers, _HandlebarsNodeVisito); - - function TokenizerEventHandlers() { - var _this2; - - _this2 = _HandlebarsNodeVisito.apply(this, arguments) || this; - _this2.tagOpenLine = 0; - _this2.tagOpenColumn = 0; - return _this2; + function () { + function StackImpl() { + this.stack = []; + this.current = null; } - var _proto4 = TokenizerEventHandlers.prototype; - - _proto4.reset = function reset() { - this.currentNode = null; - } // Comment - ; - - _proto4.beginComment = function beginComment() { - this.currentNode = b.comment(''); - this.currentNode.loc = { - source: null, - start: b.pos(this.tagOpenLine, this.tagOpenColumn), - end: null - }; - }; - - _proto4.appendToCommentData = function appendToCommentData(char) { - this.currentComment.value += char; - }; - - _proto4.finishComment = function finishComment() { - this.currentComment.loc.end = b.pos(this.tokenizer.line, this.tokenizer.column); - appendChild(this.currentElement(), this.currentComment); - } // Data - ; + var _proto2 = StackImpl.prototype; - _proto4.beginData = function beginData() { - this.currentNode = b.text(); - this.currentNode.loc = { - source: null, - start: b.pos(this.tokenizer.line, this.tokenizer.column), - end: null - }; + _proto2.push = function push(item) { + this.current = item; + this.stack.push(item); }; - _proto4.appendToData = function appendToData(char) { - this.currentData.chars += char; + _proto2.pop = function pop() { + var item = this.stack.pop(); + var len = this.stack.length; + this.current = len === 0 ? null : this.stack[len - 1]; + return item === undefined ? null : item; }; - _proto4.finishData = function finishData() { - this.currentData.loc.end = b.pos(this.tokenizer.line, this.tokenizer.column); - appendChild(this.currentElement(), this.currentData); - } // Tags - basic - ; - - _proto4.tagOpen = function tagOpen() { - this.tagOpenLine = this.tokenizer.line; - this.tagOpenColumn = this.tokenizer.column; + _proto2.nth = function nth(from) { + var len = this.stack.length; + return len < from ? null : this.stack[len - from]; }; - _proto4.beginStartTag = function beginStartTag() { - this.currentNode = { - type: 'StartTag', - name: '', - attributes: [], - modifiers: [], - comments: [], - selfClosing: false, - loc: SYNTHETIC - }; + _proto2.isEmpty = function isEmpty() { + return this.stack.length === 0; }; - _proto4.beginEndTag = function beginEndTag() { - this.currentNode = { - type: 'EndTag', - name: '', - attributes: [], - modifiers: [], - comments: [], - selfClosing: false, - loc: SYNTHETIC - }; + _proto2.toArray = function toArray() { + return this.stack; }; - _proto4.finishTag = function finishTag() { - var _this$tokenizer = this.tokenizer, - line = _this$tokenizer.line, - column = _this$tokenizer.column; - var tag = this.currentTag; - tag.loc = b.loc(this.tagOpenLine, this.tagOpenColumn, line, column); - - if (tag.type === 'StartTag') { - this.finishStartTag(); - - if (voidMap[tag.name] || tag.selfClosing) { - this.finishEndTag(true); - } - } else if (tag.type === 'EndTag') { - this.finishEndTag(false); + (0, _emberBabel.createClass)(StackImpl, [{ + key: "size", + get: function get() { + return this.stack.length; } - }; - - _proto4.finishStartTag = function finishStartTag() { - var _this$currentStartTag = this.currentStartTag, - name = _this$currentStartTag.name, - attributes = _this$currentStartTag.attributes, - modifiers = _this$currentStartTag.modifiers, - comments = _this$currentStartTag.comments, - selfClosing = _this$currentStartTag.selfClosing; - var loc = b.loc(this.tagOpenLine, this.tagOpenColumn); - var element = b.element({ - name: name, - selfClosing: selfClosing - }, attributes, modifiers, [], comments, [], loc); - this.elementStack.push(element); - }; - - _proto4.finishEndTag = function finishEndTag(isVoid) { - var tag = this.currentTag; - var element = this.elementStack.pop(); - var parent = this.currentElement(); - validateEndTag(tag, element, isVoid); - element.loc.end.line = this.tokenizer.line; - element.loc.end.column = this.tokenizer.column; - parseElementBlockParams(element); - appendChild(parent, element); - }; - - _proto4.markTagAsSelfClosing = function markTagAsSelfClosing() { - this.currentTag.selfClosing = true; - } // Tags - name - ; - - _proto4.appendToTagName = function appendToTagName(char) { - this.currentTag.name += char; - } // Tags - attributes - ; - - _proto4.beginAttribute = function beginAttribute() { - var tag = this.currentTag; + }]); + return StackImpl; + }(); - if (tag.type === 'EndTag') { - throw new SyntaxError("Invalid end tag: closing tag must not have attributes, " + ("in `" + tag.name + "` (on line " + this.tokenizer.line + ")."), tag.loc); - } + _exports.Stack = StackImpl; - this.currentAttribute = { - name: '', - parts: [], - isQuoted: false, - isDynamic: false, - start: b.pos(this.tokenizer.line, this.tokenizer.column), - valueStartLine: 0, - valueStartColumn: 0 - }; - }; + function keys(obj) { + return Object.keys(obj); + } - _proto4.appendToAttributeName = function appendToAttributeName(char) { - this.currentAttr.name += char; - }; + function unwrap(val) { + if (val === null || val === undefined) throw new Error("Expected value to be present"); + return val; + } - _proto4.beginAttributeValue = function beginAttributeValue(isQuoted) { - this.currentAttr.isQuoted = isQuoted; - this.currentAttr.valueStartLine = this.tokenizer.line; - this.currentAttr.valueStartColumn = this.tokenizer.column; - }; + function expect(val, message) { + if (val === null || val === undefined) throw new Error(message); + return val; + } - _proto4.appendToAttributeValue = function appendToAttributeValue(char) { - var parts = this.currentAttr.parts; - var lastPart = parts[parts.length - 1]; + function unreachable(message) { + if (message === void 0) { + message = 'unreachable'; + } - if (lastPart && lastPart.type === 'TextNode') { - lastPart.chars += char; // update end location for each added char + return new Error(message); + } - lastPart.loc.end.line = this.tokenizer.line; - lastPart.loc.end.column = this.tokenizer.column; - } else { - // initially assume the text node is a single char - var loc = b.loc(this.tokenizer.line, this.tokenizer.column, this.tokenizer.line, this.tokenizer.column); // correct for `\n` as first char + function exhausted(value) { + throw new Error("Exhausted " + value); + } - if (char === '\n') { - loc.start.line -= 1; - loc.start.column = lastPart ? lastPart.loc.end.column : this.currentAttr.valueStartColumn; - } + var tuple = function tuple() { + for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { + args[_key] = arguments[_key]; + } - var text = b.text(char, loc); - parts.push(text); - } - }; + return args; + }; - _proto4.finishAttributeValue = function finishAttributeValue() { - var _this$currentAttr = this.currentAttr, - name = _this$currentAttr.name, - parts = _this$currentAttr.parts, - isQuoted = _this$currentAttr.isQuoted, - isDynamic = _this$currentAttr.isDynamic, - valueStartLine = _this$currentAttr.valueStartLine, - valueStartColumn = _this$currentAttr.valueStartColumn; - var value = assembleAttributeValue(parts, isQuoted, isDynamic, this.tokenizer.line); - value.loc = b.loc(valueStartLine, valueStartColumn, this.tokenizer.line, this.tokenizer.column); - var loc = b.loc(this.currentAttr.start.line, this.currentAttr.start.column, this.tokenizer.line, this.tokenizer.column); - var attribute = b.attr(name, value, loc); - this.currentStartTag.attributes.push(attribute); - }; + _exports.tuple = tuple; + var symbol = typeof Symbol !== 'undefined' ? Symbol : function (key) { + return "__" + key + Math.floor(Math.random() * Date.now()) + "__"; + }; + _exports.symbol = symbol; + var DESTROY = symbol('DESTROY'); + _exports.DESTROY = DESTROY; - _proto4.reportSyntaxError = function reportSyntaxError(message) { - throw new SyntaxError("Syntax error at line " + this.tokenizer.line + " col " + this.tokenizer.column + ": " + message, b.loc(this.tokenizer.line, this.tokenizer.column)); - }; + function isDestroyable(value) { + return !!(value && value[DESTROY] !== undefined); + } - return TokenizerEventHandlers; - }(HandlebarsNodeVisitors); + function isStringDestroyable(value) { + return !!(value && typeof value === 'object' && typeof value.destroy === 'function'); + } - function assembleAttributeValue(parts, isQuoted, isDynamic, line) { - if (isDynamic) { - if (isQuoted) { - return assembleConcatenatedValue(parts); - } else { - if (parts.length === 1 || parts.length === 2 && parts[1].type === 'TextNode' && parts[1].chars === '/') { - return parts[0]; - } else { - throw new SyntaxError("An unquoted attribute value must be a string or a mustache, " + "preceeded by whitespace or a '=' character, and " + ("followed by whitespace, a '>' character, or '/>' (on line " + line + ")"), b.loc(line, 0)); - } - } - } else { - return parts.length > 0 ? parts[0] : b.text(''); + function clearElement(parent) { + var current = parent.firstChild; + + while (current) { + var next = current.nextSibling; + parent.removeChild(current); + current = next; } } - function assembleConcatenatedValue(parts) { - for (var i = 0; i < parts.length; i++) { - var part = parts[i]; + var SERIALIZATION_FIRST_NODE_STRING = '%+b:0%'; + _exports.SERIALIZATION_FIRST_NODE_STRING = SERIALIZATION_FIRST_NODE_STRING; - if (part.type !== 'MustacheStatement' && part.type !== 'TextNode') { - throw new SyntaxError('Unsupported node in quoted attribute value: ' + part['type'], part.loc); - } - } + function isSerializationFirstNode(node) { + return node.nodeValue === SERIALIZATION_FIRST_NODE_STRING; + } - return b.concat(parts); + var LINKED = new WeakMap(); + _exports.LINKED = LINKED; + var WILL_DROP = symbol('WILL_DROP'); + _exports.WILL_DROP = WILL_DROP; + var DID_DROP = symbol('DID_DROP'); + _exports.DID_DROP = DID_DROP; + var CHILDREN = symbol('CHILDREN'); + _exports.CHILDREN = CHILDREN; + var DESTRUCTORS = new WeakMap(); + _exports.DESTRUCTORS = DESTRUCTORS; + + function isDrop(value) { + if (value === null || typeof value !== 'object') return false; + return value[DID_DROP] !== undefined; } - function validateEndTag(tag, element, selfClosing) { - var error; + function associate(parent, child) { + associateDestructor(parent, destructor(child)); + } - if (voidMap[tag.name] && !selfClosing) { - // EngTag is also called by StartTag for void and self-closing tags (i.e. - // or
, so we need to check for that here. Otherwise, we would - // throw an error for those cases. - error = 'Invalid end tag ' + formatEndTagInfo(tag) + ' (void elements cannot have end tags).'; - } else if (element.tag === undefined) { - error = 'Closing tag ' + formatEndTagInfo(tag) + ' without an open tag.'; - } else if (element.tag !== tag.name) { - error = 'Closing tag ' + formatEndTagInfo(tag) + ' did not match last open tag `' + element.tag + '` (on line ' + element.loc.start.line + ').'; - } + function associateDestructor(parent, child) { + var associated = LINKED.get(parent); - if (error) { - throw new SyntaxError(error, element.loc); + if (!associated) { + associated = new Set(); + LINKED.set(parent, associated); } + + associated.add(child); } - function formatEndTagInfo(tag) { - return '`' + tag.name + '` (on line ' + tag.loc.end.line + ')'; + function peekAssociated(parent) { + return LINKED.get(parent) || null; } - var syntax = { - parse: preprocess, - builders: b, - print: build, - traverse: traverse, - Walker: Walker - }; + function takeAssociated(parent) { + var linked = LINKED.get(parent); - function preprocess(html, options) { - var parseOptions = options ? options.parseOptions : {}; - var ast = typeof html === 'object' ? html : (0, _handlebars.parse)(html, parseOptions); - var program = new TokenizerEventHandlers(html).acceptNode(ast); + if (linked && linked.size > 0) { + LINKED.delete(parent); + return linked; + } else { + return null; + } + } - if (options && options.plugins && options.plugins.ast) { - for (var i = 0, l = options.plugins.ast.length; i < l; i++) { - var transform = options.plugins.ast[i]; - var env = (0, _util.assign)({}, options, { - syntax: syntax - }, { - plugins: undefined - }); - var pluginResult = transform(env); - traverse(program, pluginResult.visitor); - } + function willDestroyAssociated(parent) { + var associated = LINKED.get(parent); + + if (associated) { + associated.forEach(function (item) { + item[WILL_DROP](); + }); } + } - return program; + function didDestroyAssociated(parent) { + var associated = LINKED.get(parent); + + if (associated) { + associated.forEach(function (item) { + item[DID_DROP](); + associated.delete(item); + }); + } } - var nodes = - /*#__PURE__*/ - Object.freeze({}); // used by ember-compiler + function destructor(value) { + var d = DESTRUCTORS.get(value); - _exports.AST = nodes; -}); -define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBabel) { - "use strict"; + if (!d) { + if (isDestroyable(value)) { + d = new DestroyableDestructor(value); + } else if (isStringDestroyable(value)) { + d = new StringDestroyableDestructor(value); + } else { + d = new SimpleDestructor(value); + } - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.assert = debugAssert; - _exports.assign = assign; - _exports.fillNulls = fillNulls; - _exports.ensureGuid = ensureGuid; - _exports.initializeGuid = initializeGuid; - _exports.dict = dict; - _exports.unwrap = unwrap; - _exports.expect = expect; - _exports.unreachable = unreachable; - _exports.EMPTY_ARRAY = _exports.ListSlice = _exports.ListNode = _exports.LinkedList = _exports.EMPTY_SLICE = _exports.DictSet = _exports.Stack = void 0; + DESTRUCTORS.set(value, d); + } - function unwrap(val) { - if (val === null || val === undefined) throw new Error("Expected value to be present"); - return val; + return d; } - function expect(val, message) { - if (val === null || val === undefined) throw new Error(message); - return val; + function snapshot(values) { + return new SnapshotDestructor(values); } - function unreachable(message) { - if (message === void 0) { - message = 'unreachable'; + var SnapshotDestructor = + /*#__PURE__*/ + function () { + function SnapshotDestructor(destructors) { + this.destructors = destructors; } - return new Error(message); - } // import Logger from './logger'; - // let alreadyWarned = false; + var _proto3 = SnapshotDestructor.prototype; + _proto3[WILL_DROP] = function () { + this.destructors.forEach(function (item) { + return item[WILL_DROP](); + }); + }; - function debugAssert(test, msg) { - // if (!alreadyWarned) { - // alreadyWarned = true; - // Logger.warn("Don't leave debug assertions on in public builds"); - // } - if (!test) { - throw new Error(msg || 'assertion failure'); + _proto3[DID_DROP] = function () { + this.destructors.forEach(function (item) { + return item[DID_DROP](); + }); + }; + + _proto3.toString = function toString() { + return 'SnapshotDestructor'; + }; + + (0, _emberBabel.createClass)(SnapshotDestructor, [{ + key: CHILDREN, + get: function get() { + return this.destructors; + } + }]); + return SnapshotDestructor; + }(); + + var DestroyableDestructor = + /*#__PURE__*/ + function () { + function DestroyableDestructor(inner) { + this.inner = inner; } - } - var objKeys = Object.keys; + var _proto4 = DestroyableDestructor.prototype; - function assign(obj) { - for (var i = 1; i < arguments.length; i++) { - var assignment = arguments[i]; - if (assignment === null || typeof assignment !== 'object') continue; - var keys = objKeys(assignment); + _proto4[WILL_DROP] = function () { + willDestroyAssociated(this.inner); + }; - for (var j = 0; j < keys.length; j++) { - var key = keys[j]; - obj[key] = assignment[key]; + _proto4[DID_DROP] = function () { + this.inner[DESTROY](); + didDestroyAssociated(this.inner); + }; + + _proto4.toString = function toString() { + return 'DestroyableDestructor'; + }; + + (0, _emberBabel.createClass)(DestroyableDestructor, [{ + key: CHILDREN, + get: function get() { + return LINKED.get(this.inner) || []; } + }]); + return DestroyableDestructor; + }(); + + var StringDestroyableDestructor = + /*#__PURE__*/ + function () { + function StringDestroyableDestructor(inner) { + this.inner = inner; } - return obj; - } + var _proto5 = StringDestroyableDestructor.prototype; - function fillNulls(count) { - var arr = new Array(count); + _proto5[WILL_DROP] = function () { + if (typeof this.inner.willDestroy === 'function') { + this.inner.willDestroy(); + } - for (var i = 0; i < count; i++) { - arr[i] = null; + willDestroyAssociated(this.inner); + }; + + _proto5[DID_DROP] = function () { + this.inner.destroy(); + didDestroyAssociated(this.inner); + }; + + _proto5.toString = function toString() { + return 'StringDestroyableDestructor'; + }; + + (0, _emberBabel.createClass)(StringDestroyableDestructor, [{ + key: CHILDREN, + get: function get() { + return LINKED.get(this.inner) || []; + } + }]); + return StringDestroyableDestructor; + }(); + + var SimpleDestructor = + /*#__PURE__*/ + function () { + function SimpleDestructor(inner) { + this.inner = inner; } - return arr; - } + var _proto6 = SimpleDestructor.prototype; - var GUID = 0; + _proto6[WILL_DROP] = function () { + willDestroyAssociated(this.inner); + }; - function initializeGuid(object) { - return object._guid = ++GUID; - } + _proto6[DID_DROP] = function () { + didDestroyAssociated(this.inner); + }; - function ensureGuid(object) { - return object._guid || initializeGuid(object); - } + _proto6.toString = function toString() { + return 'SimpleDestructor'; + }; - function dict() { - return Object.create(null); - } + (0, _emberBabel.createClass)(SimpleDestructor, [{ + key: CHILDREN, + get: function get() { + return LINKED.get(this.inner) || []; + } + }]); + return SimpleDestructor; + }(); - var DictSet = + var ListContentsDestructor = /*#__PURE__*/ function () { - function DictSet() { - this.dict = dict(); + function ListContentsDestructor(inner) { + this.inner = inner; } - var _proto = DictSet.prototype; + var _proto7 = ListContentsDestructor.prototype; - _proto.add = function add(obj) { - if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[ensureGuid(obj)] = obj; - return this; + _proto7[WILL_DROP] = function () { + this.inner.forEachNode(function (d) { + return destructor(d)[WILL_DROP](); + }); + }; + + _proto7[DID_DROP] = function () { + this.inner.forEachNode(function (d) { + return destructor(d)[DID_DROP](); + }); + }; + + _proto7.toString = function toString() { + return 'ListContentsDestructor'; }; - _proto.delete = function _delete(obj) { - if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; - }; + (0, _emberBabel.createClass)(ListContentsDestructor, [{ + key: CHILDREN, + get: function get() { + var out = []; + this.inner.forEachNode(function (d) { + return out.push.apply(out, destructor(d)[CHILDREN]); + }); + return out; + } + }]); + return ListContentsDestructor; + }(); + + _exports.ListContentsDestructor = ListContentsDestructor; + + function debugDropTree(inner) { + var hasDrop = isDrop(inner); + var rawChildren = LINKED.get(inner) || null; + var children = null; + + if (rawChildren) { + children = []; + + for (var _iterator = rawChildren, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; - return DictSet; - }(); + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } - _exports.DictSet = DictSet; + var _child = _ref; + children.push(debugDropTree(_child)); + } + } - var Stack = - /*#__PURE__*/ - function () { - function Stack() { - this.stack = []; - this.current = null; + var obj = Object.create(null); + obj.inner = inner; + + if (children) { + obj.children = children; } - var _proto2 = Stack.prototype; + obj.hasDrop = hasDrop; + return obj; + } - _proto2.push = function push(item) { - this.current = item; - this.stack.push(item); - }; + function printDropTree(inner) { + printDrop(destructor(inner)); + } - _proto2.pop = function pop() { - var item = this.stack.pop(); - var len = this.stack.length; - this.current = len === 0 ? null : this.stack[len - 1]; - return item === undefined ? null : item; - }; + function printDrop(inner) { + console.group(String(inner)); + console.log(inner); + var children = inner[CHILDREN] || null; - _proto2.isEmpty = function isEmpty() { - return this.stack.length === 0; - }; + if (children) { + for (var _iterator2 = children, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref2; - (0, _emberBabel.createClass)(Stack, [{ - key: "size", - get: function get() { - return this.stack.length; + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var _child2 = _ref2; + printDrop(_child2); } - }]); - return Stack; - }(); + } - _exports.Stack = Stack; + console.groupEnd(); + } var ListNode = function ListNode(value) { this.next = null; @@ -6135,21 +9380,21 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa this.clear(); } - var _proto3 = LinkedList.prototype; + var _proto8 = LinkedList.prototype; - _proto3.head = function head() { + _proto8.head = function head() { return this._head; }; - _proto3.tail = function tail() { + _proto8.tail = function tail() { return this._tail; }; - _proto3.clear = function clear() { + _proto8.clear = function clear() { this._head = this._tail = null; }; - _proto3.toArray = function toArray() { + _proto8.toArray = function toArray() { var out = []; this.forEachNode(function (n) { return out.push(n); @@ -6157,11 +9402,11 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa return out; }; - _proto3.nextNode = function nextNode(node) { + _proto8.nextNode = function nextNode(node) { return node.next; }; - _proto3.forEachNode = function forEachNode(callback) { + _proto8.forEachNode = function forEachNode(callback) { var node = this._head; while (node !== null) { @@ -6170,7 +9415,7 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa } }; - _proto3.insertBefore = function insertBefore(node, reference) { + _proto8.insertBefore = function insertBefore(node, reference) { if (reference === void 0) { reference = null; } @@ -6183,7 +9428,7 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa return node; }; - _proto3.append = function append(node) { + _proto8.append = function append(node) { var tail = this._tail; if (tail) { @@ -6197,12 +9442,34 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa return this._tail = node; }; - _proto3.remove = function remove(node) { + _proto8.remove = function remove(node) { if (node.prev) node.prev.next = node.next;else this._head = node.next; if (node.next) node.next.prev = node.prev;else this._tail = node.prev; return node; }; + _proto8[WILL_DROP] = function () { + this.forEachNode(function (d) { + return destructor(d)[WILL_DROP](); + }); + }; + + _proto8[DID_DROP] = function () { + this.forEachNode(function (d) { + return destructor(d)[DID_DROP](); + }); + }; + + (0, _emberBabel.createClass)(LinkedList, [{ + key: CHILDREN, + get: function get() { + var out = []; + this.forEachNode(function (d) { + return out.push.apply(out, destructor(d)[CHILDREN]); + }); + return out; + } + }]); return LinkedList; }(); @@ -6216,9 +9483,9 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa this._tail = tail; } - var _proto4 = ListSlice.prototype; + var _proto9 = ListSlice.prototype; - _proto4.forEachNode = function forEachNode(callback) { + _proto9.forEachNode = function forEachNode(callback) { var node = this._head; while (node !== null) { @@ -6227,15 +9494,15 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa } }; - _proto4.head = function head() { + _proto9.head = function head() { return this._head; }; - _proto4.tail = function tail() { + _proto9.tail = function tail() { return this._tail; }; - _proto4.toArray = function toArray() { + _proto9.toArray = function toArray() { var out = []; this.forEachNode(function (n) { return out.push(n); @@ -6243,7 +9510,7 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa return out; }; - _proto4.nextNode = function nextNode(node) { + _proto9.nextNode = function nextNode(node) { if (node === this._tail) return null; return node.next; }; @@ -6254,8 +9521,339 @@ define("@glimmer/util", ["exports", "ember-babel"], function (_exports, _emberBa _exports.ListSlice = ListSlice; var EMPTY_SLICE = new ListSlice(null, null); _exports.EMPTY_SLICE = EMPTY_SLICE; - var EMPTY_ARRAY = Object.freeze([]); - _exports.EMPTY_ARRAY = EMPTY_ARRAY; + var objKeys = Object.keys; + + function assign(obj) { + for (var i = 1; i < arguments.length; i++) { + var assignment = arguments[i]; + if (assignment === null || typeof assignment !== 'object') continue; + + var _keys = objKeys(assignment); + + for (var j = 0; j < _keys.length; j++) { + var key = _keys[j]; + obj[key] = assignment[key]; + } + } + + return obj; + } + + function fillNulls(count) { + var arr = new Array(count); + + for (var i = 0; i < count; i++) { + arr[i] = null; + } + + return arr; + } + + function values(obj) { + var vals = []; + + for (var key in obj) { + vals.push(obj[key]); + } + + return vals; + } + + function strip(strings) { + var out = ''; + + for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) { + args[_key2 - 1] = arguments[_key2]; + } + + for (var i = 0; i < strings.length; i++) { + var string = strings[i]; + var dynamic = args[i] !== undefined ? String(args[i]) : ''; + out += "" + string + dynamic; + } + + var lines = out.split('\n'); + + while (lines.length && lines[0].match(/^\s*$/)) { + lines.shift(); + } + + while (lines.length && lines[lines.length - 1].match(/^\s*$/)) { + lines.pop(); + } + + var min = Infinity; + + for (var _iterator3 = lines, _isArray3 = Array.isArray(_iterator3), _i3 = 0, _iterator3 = _isArray3 ? _iterator3 : _iterator3[Symbol.iterator]();;) { + var _ref3; + + if (_isArray3) { + if (_i3 >= _iterator3.length) break; + _ref3 = _iterator3[_i3++]; + } else { + _i3 = _iterator3.next(); + if (_i3.done) break; + _ref3 = _i3.value; + } + + var _line2 = _ref3; + + var _leading = _line2.match(/^\s*/)[0].length; + + min = Math.min(min, _leading); + } + + var stripped = []; + + for (var _iterator4 = lines, _isArray4 = Array.isArray(_iterator4), _i4 = 0, _iterator4 = _isArray4 ? _iterator4 : _iterator4[Symbol.iterator]();;) { + var _ref4; + + if (_isArray4) { + if (_i4 >= _iterator4.length) break; + _ref4 = _iterator4[_i4++]; + } else { + _i4 = _iterator4.next(); + if (_i4.done) break; + _ref4 = _i4.value; + } + + var _line3 = _ref4; + stripped.push(_line3.slice(min)); + } + + return stripped.join('\n'); + } + /** + * Encodes a value that can be stored directly instead of being a handle. + * + * Immediates use the positive half of 32bits + * + * @param value - the value to be encoded. + */ + + + function encodeImmediate(value) { + if (typeof value === 'number') { + // map -1 to -1073741820 onto 1073741828 to 2147483647 + // 1073741827 - (-1) == 1073741828 + // 1073741827 - (-1073741820) == 2147483647 + // positive it stays as is + // 0 - 1073741823 + return value < 0 ? 1073741827 + /* NEGATIVE_BASE */ + - value : value; + } + + if (value === false) { + return 1073741824 + /* FALSE */ + ; + } + + if (value === true) { + return 1073741825 + /* TRUE */ + ; + } + + if (value === null) { + return 1073741826 + /* NULL */ + ; + } + + if (value === undefined) { + return 1073741827 + /* UNDEFINED */ + ; + } + + return exhausted(value); + } + /** + * Decodes an immediate into its value. + * + * @param value - the encoded immediate value + */ + + + function decodeImmediate(value) { + if (value > 1073741823 + /* MAX_INT */ + ) { + switch (value) { + case 1073741824 + /* FALSE */ + : + return false; + + case 1073741825 + /* TRUE */ + : + return true; + + case 1073741826 + /* NULL */ + : + return null; + + case 1073741827 + /* UNDEFINED */ + : + return undefined; + + default: + // map 1073741828 to 2147483647 to -1 to -1073741820 + // 1073741827 - 1073741828 == -1 + // 1073741827 - 2147483647 == -1073741820 + return 1073741827 + /* NEGATIVE_BASE */ + - value; + } + } + + return value; + } + /** + * True if the number can be stored directly or false if it needs a handle. + * + * This is used on any number type to see if it can be directly encoded. + */ + + + function isSmallInt(num) { + return isInt(num, -1073741820 + /* MIN_INT */ + , 1073741823 + /* MAX_INT */ + ); + } + /** + * True if the encoded int32 operand or encoded stack int32 is a handle. + */ + + + function isHandle(encoded) { + return encoded < 0; + } + /** + * Encodes an index to an operand or stack handle. + */ + + + function encodeHandle(index, maxIndex + /* MAX_INDEX */ + , maxHandle + /* MAX_HANDLE */ + ) { + if (maxIndex === void 0) { + maxIndex = 2147483647; + } + + if (maxHandle === void 0) { + maxHandle = -1; + } + + if (index > maxIndex) { + throw new Error("index " + index + " overflowed range 0 to " + maxIndex); + } // -1 - 0 == -1 + // -1 - 1073741823 == -1073741824 + // -1073741825 - 0 == -1073741825 + // -1073741825 - 1073741823 == -2147483648 + + + return maxHandle - index; + } + /** + * Decodes the index from the specified operand or stack handle. + */ + + + function decodeHandle(handle, maxHandle + /* MAX_HANDLE */ + ) { + if (maxHandle === void 0) { + maxHandle = -1; + } + + // -1 - -1 == 0 + // -1 - -1073741824 == 1073741823 + // -1073741825 - -1073741825 == 0 + // -1073741825 - -2147483648 == 1073741823 + return maxHandle - handle; + } + + function isInt(num, min, max) { + // this is the same as Math.floor(num) === num + // also NaN % 1 is NaN and Infinity % 1 is NaN so both should fail + return num % 1 === 0 && num >= min && num <= max; + } + + var debugToString; + + if (true + /* DEBUG */ + ) { + var getFunctionName = function getFunctionName(fn) { + var functionName = fn.name; + + if (functionName === undefined) { + var match = Function.prototype.toString.call(fn).match(/function (\w+)\s*\(/); + functionName = match && match[1] || ''; + } + + return functionName.replace(/^bound /, ''); + }; + + var getObjectName = function getObjectName(obj) { + var name; + var className; + + if (obj.constructor && obj.constructor !== Object) { + className = getFunctionName(obj.constructor); + } + + if ('toString' in obj && obj.toString !== Object.prototype.toString && obj.toString !== Function.prototype.toString) { + name = obj.toString(); + } // If the class has a decent looking name, and the `toString` is one of the + // default Ember toStrings, replace the constructor portion of the toString + // with the class name. We check the length of the class name to prevent doing + // this when the value is minified. + + + if (name && name.match(/<.*:ember\d+>/) && className && className[0] !== '_' && className.length > 2 && className !== 'Class') { + return name.replace(/<.*:/, "<" + className + ":"); + } + + return name || className; + }; + + var getPrimitiveName = function getPrimitiveName(value) { + return String(value); + }; + + debugToString = function debugToString(value) { + if (typeof value === 'function') { + return getFunctionName(value) || "(unknown function)"; + } else if (typeof value === 'object' && value !== null) { + return getObjectName(value) || "(unknown object)"; + } else { + return getPrimitiveName(value); + } + }; + } + + var debugToString$1 = debugToString; + _exports.debugToString = debugToString$1; + + function assertNever(value, desc) { + if (desc === void 0) { + desc = 'unexpected unreachable branch'; + } + + console.log('unreachable', value); + console.trace(desc + " :: " + JSON.stringify(value) + " (" + value + ")"); + } }); define("@glimmer/wire-format", ["exports"], function (_exports) { "use strict"; @@ -6266,45 +9864,8 @@ define("@glimmer/wire-format", ["exports"], function (_exports) { _exports.is = is; _exports.isAttribute = isAttribute; _exports.isArgument = isArgument; - _exports.isMaybeLocal = _exports.isGet = _exports.isFlushElement = _exports.Ops = void 0; - var Opcodes; - _exports.Ops = Opcodes; - - (function (Opcodes) { - // Statements - Opcodes[Opcodes["Text"] = 0] = "Text"; - Opcodes[Opcodes["Append"] = 1] = "Append"; - Opcodes[Opcodes["Comment"] = 2] = "Comment"; - Opcodes[Opcodes["Modifier"] = 3] = "Modifier"; - Opcodes[Opcodes["Block"] = 4] = "Block"; - Opcodes[Opcodes["Component"] = 5] = "Component"; - Opcodes[Opcodes["DynamicComponent"] = 6] = "DynamicComponent"; - Opcodes[Opcodes["OpenElement"] = 7] = "OpenElement"; - Opcodes[Opcodes["FlushElement"] = 8] = "FlushElement"; - Opcodes[Opcodes["CloseElement"] = 9] = "CloseElement"; - Opcodes[Opcodes["StaticAttr"] = 10] = "StaticAttr"; - Opcodes[Opcodes["DynamicAttr"] = 11] = "DynamicAttr"; - Opcodes[Opcodes["ComponentAttr"] = 12] = "ComponentAttr"; - Opcodes[Opcodes["AttrSplat"] = 13] = "AttrSplat"; - Opcodes[Opcodes["Yield"] = 14] = "Yield"; - Opcodes[Opcodes["Partial"] = 15] = "Partial"; - Opcodes[Opcodes["DynamicArg"] = 16] = "DynamicArg"; - Opcodes[Opcodes["StaticArg"] = 17] = "StaticArg"; - Opcodes[Opcodes["TrustingAttr"] = 18] = "TrustingAttr"; - Opcodes[Opcodes["TrustingComponentAttr"] = 19] = "TrustingComponentAttr"; - Opcodes[Opcodes["Debugger"] = 20] = "Debugger"; - Opcodes[Opcodes["ClientSideStatement"] = 21] = "ClientSideStatement"; // Expressions - - Opcodes[Opcodes["Unknown"] = 22] = "Unknown"; - Opcodes[Opcodes["Get"] = 23] = "Get"; - Opcodes[Opcodes["MaybeLocal"] = 24] = "MaybeLocal"; - Opcodes[Opcodes["HasBlock"] = 25] = "HasBlock"; - Opcodes[Opcodes["HasBlockParams"] = 26] = "HasBlockParams"; - Opcodes[Opcodes["Undefined"] = 27] = "Undefined"; - Opcodes[Opcodes["Helper"] = 28] = "Helper"; - Opcodes[Opcodes["Concat"] = 29] = "Concat"; - Opcodes[Opcodes["ClientSideExpression"] = 30] = "ClientSideExpression"; - })(Opcodes || (_exports.Ops = Opcodes = {})); + _exports.isHelper = isHelper; + _exports.isGet = _exports.isFlushElement = void 0; function is(variant) { return function (value) { @@ -6313,22 +9874,50 @@ define("@glimmer/wire-format", ["exports"], function (_exports) { } // Statements - var isFlushElement = is(Opcodes.FlushElement); + var isFlushElement = is(10 + /* FlushElement */ + ); _exports.isFlushElement = isFlushElement; function isAttribute(val) { - return val[0] === Opcodes.StaticAttr || val[0] === Opcodes.DynamicAttr || val[0] === Opcodes.ComponentAttr || val[0] === Opcodes.TrustingAttr || val[0] === Opcodes.TrustingComponentAttr || val[0] === Opcodes.AttrSplat || val[0] === Opcodes.Modifier; + return val[0] === 12 + /* StaticAttr */ + || val[0] === 13 + /* DynamicAttr */ + || val[0] === 20 + /* TrustingDynamicAttr */ + || val[0] === 14 + /* ComponentAttr */ + || val[0] === 23 + /* StaticComponentAttr */ + || val[0] === 21 + /* TrustingComponentAttr */ + || val[0] === 15 + /* AttrSplat */ + || val[0] === 3 + /* Modifier */ + ; } function isArgument(val) { - return val[0] === Opcodes.StaticArg || val[0] === Opcodes.DynamicArg; + return val[0] === 19 + /* StaticArg */ + || val[0] === 18 + /* DynamicArg */ + ; + } + + function isHelper(expr) { + return Array.isArray(expr) && expr[0] === 31 + /* Call */ + ; } // Expressions - var isGet = is(Opcodes.Get); + var isGet = is(24 + /* GetSymbol */ + ); _exports.isGet = isGet; - var isMaybeLocal = is(Opcodes.MaybeLocal); - _exports.isMaybeLocal = isMaybeLocal; }); define("ember-babel", ["exports"], function (_exports) { "use strict"; @@ -6382,7 +9971,7 @@ define("ember-babel", ["exports"], function (_exports) { Overrides default `inheritsLoose` to _also_ call `Object.setPrototypeOf`. This is needed so that we can use `loose` option with the `@babel/plugin-transform-classes` (because we want simple assignment to the - prototype whereever possible) but also keep our constructor based prototypal + prototype wherever possible) but also keep our constructor based prototypal inheritance working properly */ @@ -6565,7 +10154,53 @@ define("ember-template-compiler/lib/compat", ["exports", "ember-template-compile EmberHTMLBars.registerPlugin = _compileOptions.registerPlugin; } }); -define("ember-template-compiler/lib/plugins/assert-if-helper-without-arguments", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display"], function (_exports, _debug, _calculateLocationDisplay) { +define("ember-template-compiler/lib/plugins/assert-against-named-blocks", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display"], function (_exports, _debug, _calculateLocationDisplay) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.default = assertAgainstNamedBlocks; + + /** + @module ember + */ + + /** + Prevents usage of named blocks + + @private + @class AssertAgainstNamedBlocks + */ + function assertAgainstNamedBlocks(env) { + var moduleName = env.meta.moduleName; + return { + name: 'assert-against-named-blocks', + visitor: { + ElementNode: function ElementNode(node) { + if (node.tag[0] === ':') { + var sourceInformation = (0, _calculateLocationDisplay.default)(moduleName, node.loc); + (true && !(false) && (0, _debug.assert)("Named blocks are not currently available, attempted to use the <" + node.tag + "> named block. " + sourceInformation)); + } + }, + MustacheStatement: function MustacheStatement(node) { + if (node.path.type === 'PathExpression' && node.path.original === 'yield') { + var to = node.hash.pairs.filter(function (pair) { + return pair.key === 'to'; + })[0]; // Glimmer template compiler ensures yield must receive a string literal, + // so we only need to check if it is not "default" or "inverse" + + if (to && to.value.type === 'StringLiteral' && to.value.original !== 'default' && to.value.original !== 'inverse') { + var sourceInformation = (0, _calculateLocationDisplay.default)(moduleName, node.loc); + (true && !(false) && (0, _debug.assert)("Named blocks are not currently available, attempted to yield to a named block other than \"default\" or \"inverse\": {{yield to=\"" + to.value.original + "\"}}. " + sourceInformation)); + } + } + } + } + }; + } +}); +define("ember-template-compiler/lib/plugins/assert-if-helper-without-arguments", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display", "ember-template-compiler/lib/plugins/utils"], function (_exports, _debug, _calculateLocationDisplay, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -6579,17 +10214,17 @@ define("ember-template-compiler/lib/plugins/assert-if-helper-without-arguments", name: 'assert-if-helper-without-arguments', visitor: { BlockStatement: function BlockStatement(node) { - if (isInvalidBlockIf(node)) { + if ((0, _utils.isPath)(node.path) && isInvalidBlockIf(node.path, node.params)) { (true && !(false) && (0, _debug.assert)(blockAssertMessage(node.path.original) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc))); } }, MustacheStatement: function MustacheStatement(node) { - if (isInvalidInlineIf(node)) { + if ((0, _utils.isPath)(node.path) && isInvalidInlineIf(node.path, node.params)) { (true && !(false) && (0, _debug.assert)(inlineAssertMessage(node.path.original) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc))); } }, SubExpression: function SubExpression(node) { - if (isInvalidInlineIf(node)) { + if ((0, _utils.isPath)(node.path) && isInvalidInlineIf(node.path, node.params)) { (true && !(false) && (0, _debug.assert)(inlineAssertMessage(node.path.original) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc))); } } @@ -6605,15 +10240,15 @@ define("ember-template-compiler/lib/plugins/assert-if-helper-without-arguments", return "The inline form of the '" + original + "' helper expects two or three arguments."; } - function isInvalidInlineIf(node) { - return node.path.original === 'if' && (!node.params || node.params.length < 2 || node.params.length > 3); + function isInvalidInlineIf(path, params) { + return (0, _utils.isPath)(path) && path.original === 'if' && (!params || params.length < 2 || params.length > 3); } - function isInvalidBlockIf(node) { - return node.path.original === 'if' && (!node.params || node.params.length !== 1); + function isInvalidBlockIf(path, params) { + return (0, _utils.isPath)(path) && path.original === 'if' && (!params || params.length !== 1); } }); -define("ember-template-compiler/lib/plugins/assert-input-helper-without-block", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display"], function (_exports, _debug, _calculateLocationDisplay) { +define("ember-template-compiler/lib/plugins/assert-input-helper-without-block", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display", "ember-template-compiler/lib/plugins/utils"], function (_exports, _debug, _calculateLocationDisplay, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -6627,11 +10262,9 @@ define("ember-template-compiler/lib/plugins/assert-input-helper-without-block", name: 'assert-input-helper-without-block', visitor: { BlockStatement: function BlockStatement(node) { - if (node.path.original !== 'input') { - return; + if ((0, _utils.isPath)(node.path) && node.path.original === 'input') { + (true && !(false) && (0, _debug.assert)(assertMessage(moduleName, node))); } - - (true && !(false) && (0, _debug.assert)(assertMessage(moduleName, node))); } } }; @@ -6642,7 +10275,7 @@ define("ember-template-compiler/lib/plugins/assert-input-helper-without-block", return "The {{input}} helper cannot be used in block form. " + sourceInformation; } }); -define("ember-template-compiler/lib/plugins/assert-local-variable-shadowing-helper-invocation", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display"], function (_exports, _debug, _calculateLocationDisplay) { +define("ember-template-compiler/lib/plugins/assert-local-variable-shadowing-helper-invocation", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display", "ember-template-compiler/lib/plugins/utils"], function (_exports, _debug, _calculateLocationDisplay, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -6652,69 +10285,53 @@ define("ember-template-compiler/lib/plugins/assert-local-variable-shadowing-help function assertLocalVariableShadowingHelperInvocation(env) { var moduleName = env.meta.moduleName; - var locals = []; + + var _trackLocals = (0, _utils.trackLocals)(), + hasLocal = _trackLocals.hasLocal, + node = _trackLocals.node; + return { name: 'assert-local-variable-shadowing-helper-invocation', visitor: { - Program: { - enter: function enter(node) { - locals.push(node.blockParams); - }, - exit: function exit() { - locals.pop(); - } - }, + Program: node, ElementNode: { keys: { - children: { - enter: function enter(node) { - locals.push(node.blockParams); - }, - exit: function exit() { - locals.pop(); - } - } + children: node } }, MustacheStatement: function MustacheStatement(node) { - if (isPath(node.path) && hasArguments(node)) { + if ((0, _utils.isPath)(node.path) && hasArguments(node)) { var name = node.path.parts[0]; var type = 'helper'; - (true && !(!isLocalVariable(node.path, locals)) && (0, _debug.assert)(messageFor(name, type) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc), !isLocalVariable(node.path, locals))); + (true && !(!isLocalVariable(node.path, hasLocal)) && (0, _debug.assert)(messageFor(name, type) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc), !isLocalVariable(node.path, hasLocal))); } }, SubExpression: function SubExpression(node) { - var name = node.path.parts[0]; - var type = 'helper'; - (true && !(!isLocalVariable(node.path, locals)) && (0, _debug.assert)(messageFor(name, type) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc), !isLocalVariable(node.path, locals))); + if ((0, _utils.isPath)(node.path)) { + var name = node.path.parts[0]; + var type = 'helper'; + (true && !(!isLocalVariable(node.path, hasLocal)) && (0, _debug.assert)(messageFor(name, type) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc), !isLocalVariable(node.path, hasLocal))); + } }, ElementModifierStatement: function ElementModifierStatement(node) { - var name = node.path.parts[0]; - var type = 'modifier'; - (true && !(!isLocalVariable(node.path, locals)) && (0, _debug.assert)(messageFor(name, type) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc), !isLocalVariable(node.path, locals))); + if ((0, _utils.isPath)(node.path)) { + var name = node.path.parts[0]; + var type = 'modifier'; + (true && !(!isLocalVariable(node.path, hasLocal)) && (0, _debug.assert)(messageFor(name, type) + " " + (0, _calculateLocationDisplay.default)(moduleName, node.loc), !isLocalVariable(node.path, hasLocal))); + } } } }; } - function isLocalVariable(node, locals) { - return !node.this && node.parts.length === 1 && hasLocalVariable(node.parts[0], locals); - } - - function hasLocalVariable(name, locals) { - return locals.some(function (names) { - return names.indexOf(name) !== -1; - }); + function isLocalVariable(node, hasLocal) { + return !node.this && node.parts.length === 1 && hasLocal(node.parts[0]); } function messageFor(name, type) { return "Cannot invoke the `" + name + "` " + type + " because it was shadowed by a local variable (i.e. a block param) with the same name. Please rename the local variable to resolve the conflict."; } - function isPath(node) { - return node.type === 'PathExpression'; - } - function hasArguments(node) { return node.params.length > 0 || node.hash.pairs.length > 0; } @@ -6803,7 +10420,7 @@ define("ember-template-compiler/lib/plugins/assert-splattribute-expression", ["e return '`...attributes` can only be used in the element position e.g. `
`. It cannot be used as a path.'; } }); -define("ember-template-compiler/lib/plugins/deprecate-send-action", ["exports", "@ember/debug", "@ember/deprecated-features", "ember-template-compiler/lib/system/calculate-location-display"], function (_exports, _debug, _deprecatedFeatures, _calculateLocationDisplay) { +define("ember-template-compiler/lib/plugins/deprecate-send-action", ["exports", "@ember/debug", "@ember/deprecated-features", "ember-template-compiler/lib/system/calculate-location-display", "ember-template-compiler/lib/plugins/utils"], function (_exports, _debug, _deprecatedFeatures, _calculateLocationDisplay, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -6860,7 +10477,7 @@ define("ember-template-compiler/lib/plugins/deprecate-send-action", ["exports", }); }, MustacheStatement: function MustacheStatement(node) { - if (node.path.original !== 'input') { + if (!(0, _utils.isPath)(node.path) || node.path.original !== 'input') { return; } @@ -6881,24 +10498,110 @@ define("ember-template-compiler/lib/plugins/deprecate-send-action", ["exports", return; } }); -define("ember-template-compiler/lib/plugins/index", ["exports", "ember-template-compiler/lib/plugins/assert-if-helper-without-arguments", "ember-template-compiler/lib/plugins/assert-input-helper-without-block", "ember-template-compiler/lib/plugins/assert-local-variable-shadowing-helper-invocation", "ember-template-compiler/lib/plugins/assert-reserved-named-arguments", "ember-template-compiler/lib/plugins/assert-splattribute-expression", "ember-template-compiler/lib/plugins/deprecate-send-action", "ember-template-compiler/lib/plugins/transform-action-syntax", "ember-template-compiler/lib/plugins/transform-attrs-into-args", "ember-template-compiler/lib/plugins/transform-component-invocation", "ember-template-compiler/lib/plugins/transform-each-in-into-each", "ember-template-compiler/lib/plugins/transform-has-block-syntax", "ember-template-compiler/lib/plugins/transform-in-element", "ember-template-compiler/lib/plugins/transform-link-to", "ember-template-compiler/lib/plugins/transform-old-class-binding-syntax", "ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings", "@ember/deprecated-features"], function (_exports, _assertIfHelperWithoutArguments, _assertInputHelperWithoutBlock, _assertLocalVariableShadowingHelperInvocation, _assertReservedNamedArguments, _assertSplattributeExpression, _deprecateSendAction, _transformActionSyntax, _transformAttrsIntoArgs, _transformComponentInvocation, _transformEachInIntoEach, _transformHasBlockSyntax, _transformInElement, _transformLinkTo, _transformOldClassBindingSyntax, _transformQuotedBindingsIntoJustBindings, _deprecatedFeatures) { +define("ember-template-compiler/lib/plugins/index", ["exports", "ember-template-compiler/lib/plugins/assert-against-named-blocks", "ember-template-compiler/lib/plugins/assert-if-helper-without-arguments", "ember-template-compiler/lib/plugins/assert-input-helper-without-block", "ember-template-compiler/lib/plugins/assert-local-variable-shadowing-helper-invocation", "ember-template-compiler/lib/plugins/assert-reserved-named-arguments", "ember-template-compiler/lib/plugins/assert-splattribute-expression", "ember-template-compiler/lib/plugins/deprecate-send-action", "ember-template-compiler/lib/plugins/safe-integers-bugfix", "ember-template-compiler/lib/plugins/transform-action-syntax", "ember-template-compiler/lib/plugins/transform-attrs-into-args", "ember-template-compiler/lib/plugins/transform-component-invocation", "ember-template-compiler/lib/plugins/transform-each-in-into-each", "ember-template-compiler/lib/plugins/transform-each-track-array", "ember-template-compiler/lib/plugins/transform-has-block-syntax", "ember-template-compiler/lib/plugins/transform-in-element", "ember-template-compiler/lib/plugins/transform-link-to", "ember-template-compiler/lib/plugins/transform-old-class-binding-syntax", "ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just-bindings", "ember-template-compiler/lib/plugins/transform-wrap-mount-and-outlet", "@ember/deprecated-features"], function (_exports, _assertAgainstNamedBlocks, _assertIfHelperWithoutArguments, _assertInputHelperWithoutBlock, _assertLocalVariableShadowingHelperInvocation, _assertReservedNamedArguments, _assertSplattributeExpression, _deprecateSendAction, _safeIntegersBugfix, _transformActionSyntax, _transformAttrsIntoArgs, _transformComponentInvocation, _transformEachInIntoEach, _transformEachTrackArray, _transformHasBlockSyntax, _transformInElement, _transformLinkTo, _transformOldClassBindingSyntax, _transformQuotedBindingsIntoJustBindings, _transformWrapMountAndOutlet, _deprecatedFeatures) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); _exports.default = void 0; - var transforms = [_transformComponentInvocation.default, _transformOldClassBindingSyntax.default, _transformQuotedBindingsIntoJustBindings.default, _assertReservedNamedArguments.default, _transformActionSyntax.default, _transformAttrsIntoArgs.default, _transformEachInIntoEach.default, _transformHasBlockSyntax.default, _assertLocalVariableShadowingHelperInvocation.default, _transformLinkTo.default, _assertInputHelperWithoutBlock.default, _transformInElement.default, _assertIfHelperWithoutArguments.default, _assertSplattributeExpression.default]; + // order of plugins is important + var transforms = [_transformComponentInvocation.default, _transformOldClassBindingSyntax.default, _transformQuotedBindingsIntoJustBindings.default, _assertReservedNamedArguments.default, _transformActionSyntax.default, _transformAttrsIntoArgs.default, _transformEachInIntoEach.default, _transformHasBlockSyntax.default, _assertLocalVariableShadowingHelperInvocation.default, _transformLinkTo.default, _assertInputHelperWithoutBlock.default, _transformInElement.default, _assertIfHelperWithoutArguments.default, _assertSplattributeExpression.default, _transformEachTrackArray.default, _transformWrapMountAndOutlet.default, _safeIntegersBugfix.default]; if (_deprecatedFeatures.SEND_ACTION) { transforms.push(_deprecateSendAction.default); } + if (!false + /* EMBER_NAMED_BLOCKS */ + ) { + transforms.push(_assertAgainstNamedBlocks.default); + } + var _default = Object.freeze(transforms); _exports.default = _default; }); -define("ember-template-compiler/lib/plugins/transform-action-syntax", ["exports"], function (_exports) { +define("ember-template-compiler/lib/plugins/safe-integers-bugfix", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.default = safeIntegersBugfix; + + /** + @module ember + */ + + /** + A Glimmer2 AST transformation that replaces all instances of + + ```handlebars + {{987654321}} + ``` + + to + + ```handlebars + {{-i "987654321"}} + ``` + + as well as other integer number literals in sexp arguments, etc. + + The version of Glimmer VM we are using has a bug that encodes + certain integers incorrectly. This forces them into strings and + use `{{-i}}` (which is a wrapper around `parseInt`) to decode + them manually as a workaround. + + This should be removed when the Glimmer VM bug is fixed. + + @private + @class SafeIntegersBugfix + */ + function safeIntegersBugfix(env) { + var b = env.syntax.builders; + return { + name: 'safe-integers-bugfix', + visitor: { + MustacheStatement: function MustacheStatement(node) { + if (!requiresWorkaround(node)) { + return; + } + + return b.mustache('-i', [b.string(String(node.path.value))], undefined, !node.escaped, node.loc); + }, + NumberLiteral: function NumberLiteral(node) { + if (!requiresWorkaround(node)) { + return; + } + + return b.sexpr('-i', [b.string(String(node.value))], undefined, node.loc); + } + } + }; + } + + function requiresWorkaround(node) { + if (node.type === 'MustacheStatement' && node.path.type === 'NumberLiteral') { + return requiresWorkaround(node.path); + } else if (node.type === 'NumberLiteral') { + return isInteger(node.value) && isOverflowing(node.value); + } else { + return false; + } + } // Number.isInteger polyfill + + + function isInteger(value) { + return isFinite(value) && Math.floor(value) === value; + } + + function isOverflowing(value) { + return value >= Math.pow(2, 28); + } +}); +define("ember-template-compiler/lib/plugins/transform-action-syntax", ["exports", "ember-template-compiler/lib/plugins/utils"], function (_exports, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -6956,7 +10659,7 @@ define("ember-template-compiler/lib/plugins/transform-action-syntax", ["exports" } function isAction(node) { - return node.path.original === 'action'; + return (0, _utils.isPath)(node.path) && node.path.original === 'action'; } function insertThisAsFirstParam(node, builders) { @@ -7040,7 +10743,7 @@ define("ember-template-compiler/lib/plugins/transform-attrs-into-args", ["export return false; } }); -define("ember-template-compiler/lib/plugins/transform-component-invocation", ["exports", "ember-template-compiler/lib/system/calculate-location-display"], function (_exports, _calculateLocationDisplay) { +define("ember-template-compiler/lib/plugins/transform-component-invocation", ["exports", "ember-template-compiler/lib/system/calculate-location-display", "ember-template-compiler/lib/plugins/utils"], function (_exports, _calculateLocationDisplay, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -7169,19 +10872,16 @@ define("ember-template-compiler/lib/plugins/transform-component-invocation", ["e function transformComponentInvocation(env) { var moduleName = env.meta.moduleName; var b = env.syntax.builders; - var locals = []; + + var _trackLocals = (0, _utils.trackLocals)(), + hasLocal = _trackLocals.hasLocal, + node = _trackLocals.node; + var isAttrs = false; return { name: 'transform-component-invocation', visitor: { - Program: { - enter: function enter(node) { - locals.push(node.blockParams); - }, - exit: function exit() { - locals.pop(); - } - }, + Program: node, ElementNode: { keys: { attributes: { @@ -7192,23 +10892,16 @@ define("ember-template-compiler/lib/plugins/transform-component-invocation", ["e isAttrs = false; } }, - children: { - enter: function enter(node) { - locals.push(node.blockParams); - }, - exit: function exit() { - locals.pop(); - } - } + children: node } }, BlockStatement: function BlockStatement(node) { - if (isBlockInvocation(node, locals)) { + if (isBlockInvocation(node, hasLocal)) { wrapInComponent(moduleName, node, b); } }, MustacheStatement: function MustacheStatement(node) { - if (!isAttrs && isInlineInvocation(node, locals)) { + if (!isAttrs && isInlineInvocation(node, hasLocal)) { wrapInComponent(moduleName, node, b); } } @@ -7216,17 +10909,13 @@ define("ember-template-compiler/lib/plugins/transform-component-invocation", ["e }; } - function isInlineInvocation(node, locals) { + function isInlineInvocation(node, hasLocal) { var path = node.path; - return isPath(path) && isIllegalName(path, locals) && hasArguments(node); - } - - function isPath(node) { - return node.type === 'PathExpression'; + return (0, _utils.isPath)(path) && isIllegalName(path, hasLocal) && hasArguments(node); } - function isIllegalName(node, locals) { - return isThisPath(node) || isDotPath(node) || isNamedArg(node) || isLocalVariable(node, locals); + function isIllegalName(node, hasLocal) { + return isThisPath(node) || isDotPath(node) || isNamedArg(node) || isLocalVariable(node, hasLocal); } function isThisPath(node) { @@ -7241,22 +10930,16 @@ define("ember-template-compiler/lib/plugins/transform-component-invocation", ["e return node.data === true; } - function isLocalVariable(node, locals) { - return !node.this && hasLocalVariable(node.parts[0], locals); - } - - function hasLocalVariable(name, locals) { - return locals.some(function (names) { - return names.indexOf(name) !== -1; - }); + function isLocalVariable(node, hasLocal) { + return !node.this && hasLocal(node.parts[0]); } function hasArguments(node) { return node.params.length > 0 || node.hash.pairs.length > 0; } - function isBlockInvocation(node, locals) { - return isIllegalName(node.path, locals); + function isBlockInvocation(node, hasLocal) { + return (0, _utils.isPath)(node.path) && isIllegalName(node.path, hasLocal); } function wrapInAssertion(moduleName, node, b) { @@ -7270,7 +10953,7 @@ define("ember-template-compiler/lib/plugins/transform-component-invocation", ["e node.params.unshift(component); } }); -define("ember-template-compiler/lib/plugins/transform-each-in-into-each", ["exports"], function (_exports) { +define("ember-template-compiler/lib/plugins/transform-each-in-into-each", ["exports", "ember-template-compiler/lib/plugins/utils"], function (_exports, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -7286,13 +10969,13 @@ define("ember-template-compiler/lib/plugins/transform-each-in-into-each", ["expo A Glimmer2 AST transformation that replaces all instances of ```handlebars - {{#each-in iterableThing as |key value|}} + {{#each-in iterableThing as |key value|}} ``` with ```handlebars - {{#each (-each-in iterableThing) as |value key|}} + {{#each (-each-in iterableThing) as |value key|}} ``` @private @@ -7304,7 +10987,7 @@ define("ember-template-compiler/lib/plugins/transform-each-in-into-each", ["expo name: 'transform-each-in-into-each', visitor: { BlockStatement: function BlockStatement(node) { - if (node.path.original === 'each-in') { + if ((0, _utils.isPath)(node.path) && node.path.original === 'each-in') { node.params[0] = b.sexpr(b.path('-each-in'), [node.params[0]]); var blockParams = node.program.blockParams; @@ -7327,7 +11010,56 @@ define("ember-template-compiler/lib/plugins/transform-each-in-into-each", ["expo }; } }); -define("ember-template-compiler/lib/plugins/transform-has-block-syntax", ["exports"], function (_exports) { +define("ember-template-compiler/lib/plugins/transform-each-track-array", ["exports", "ember-template-compiler/lib/plugins/utils"], function (_exports, _utils) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.default = transformEachTrackArray; + + /** + @module ember + */ + + /** + A Glimmer2 AST transformation that replaces all instances of + + ```handlebars + {{#each iterableThing as |key value|}} + ``` + + with + + ```handlebars + {{#each (-track-array iterableThing) as |key value|}} + ``` + + @private + @class TransformHasBlockSyntax + */ + function transformEachTrackArray(env) { + var b = env.syntax.builders; + return { + name: 'transform-each-track-array', + visitor: { + BlockStatement: function BlockStatement(node) { + if ((0, _utils.isPath)(node.path) && node.path.original === 'each') { + var firstParam = node.params[0]; + + if (firstParam.type === 'SubExpression' && firstParam.path.type === 'PathExpression' && firstParam.path.original === '-each-in') { + return; + } + + node.params[0] = b.sexpr(b.path('-track-array'), [node.params[0]]); + return b.block(b.path('each'), node.params, node.hash, node.program, node.inverse, node.loc); + } + } + } + }; + } +}); +define("ember-template-compiler/lib/plugins/transform-has-block-syntax", ["exports", "ember-template-compiler/lib/plugins/utils"], function (_exports, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -7371,12 +11103,12 @@ define("ember-template-compiler/lib/plugins/transform-has-block-syntax", ["expor } }, MustacheStatement: function MustacheStatement(node) { - if (typeof node.path.original === 'string' && TRANSFORMATIONS[node.path.original]) { + if ((0, _utils.isPath)(node.path) && TRANSFORMATIONS[node.path.original]) { return b.mustache(b.path(TRANSFORMATIONS[node.path.original]), node.params, node.hash, undefined, node.loc); } }, SubExpression: function SubExpression(node) { - if (TRANSFORMATIONS[node.path.original]) { + if ((0, _utils.isPath)(node.path) && TRANSFORMATIONS[node.path.original]) { return b.sexpr(b.path(TRANSFORMATIONS[node.path.original]), node.params, node.hash); } } @@ -7384,7 +11116,7 @@ define("ember-template-compiler/lib/plugins/transform-has-block-syntax", ["expor }; } }); -define("ember-template-compiler/lib/plugins/transform-in-element", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display"], function (_exports, _debug, _calculateLocationDisplay) { +define("ember-template-compiler/lib/plugins/transform-in-element", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display", "ember-template-compiler/lib/plugins/utils"], function (_exports, _debug, _calculateLocationDisplay, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -7442,6 +11174,8 @@ define("ember-template-compiler/lib/plugins/transform-in-element", ["exports", " name: 'transform-in-element', visitor: { BlockStatement: function BlockStatement(node) { + if (!(0, _utils.isPath)(node.path)) return; + if (node.path.original === 'in-element') { (true && !(false) && (0, _debug.assert)(assertMessage(moduleName, node))); } else if (node.path.original === '-in-element') { @@ -7449,20 +11183,21 @@ define("ember-template-compiler/lib/plugins/transform-in-element", ["exports", " node.path.parts = ['in-element']; // replicate special hash arguments added here: // https://github.com/glimmerjs/glimmer-vm/blob/ba9b37d44b85fa1385eeeea71910ff5798198c8e/packages/%40glimmer/syntax/lib/parser/handlebars-node-visitors.ts#L340-L363 - var hasNextSibling = false; + var needsInsertBefore = true; var hash = node.hash; hash.pairs.forEach(function (pair) { - if (pair.key === 'nextSibling') { - hasNextSibling = true; + if (pair.key === 'insertBefore') { + (true && !(pair.value.type === 'NullLiteral' || pair.value.type === 'UndefinedLiteral') && (0, _debug.assert)("Can only pass a null or undefined literals to insertBefore in -in-element, received: " + JSON.stringify(pair.value), pair.value.type === 'NullLiteral' || pair.value.type === 'UndefinedLiteral')); + needsInsertBefore = false; } }); var guid = b.literal('StringLiteral', "%cursor:" + cursorCount++ + "%"); var guidPair = b.pair('guid', guid); - hash.pairs.unshift(guidPair); + hash.pairs.unshift(guidPair); // Maintain compatibility with previous -in-element behavior (defaults to append, not clear) - if (!hasNextSibling) { + if (needsInsertBefore) { var nullLiteral = b.literal('NullLiteral', null); - var nextSibling = b.pair('nextSibling', nullLiteral); + var nextSibling = b.pair('insertBefore', nullLiteral); hash.pairs.push(nextSibling); } } @@ -7476,7 +11211,7 @@ define("ember-template-compiler/lib/plugins/transform-in-element", ["exports", " return "The {{in-element}} helper cannot be used. " + sourceInformation; } }); -define("ember-template-compiler/lib/plugins/transform-link-to", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display"], function (_exports, _debug, _calculateLocationDisplay) { +define("ember-template-compiler/lib/plugins/transform-link-to", ["exports", "@ember/debug", "ember-template-compiler/lib/system/calculate-location-display", "ember-template-compiler/lib/plugins/utils"], function (_exports, _debug, _calculateLocationDisplay, _utils) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -7485,24 +11220,20 @@ define("ember-template-compiler/lib/plugins/transform-link-to", ["exports", "@em _exports.default = transformLinkTo; function isInlineLinkTo(node) { - return node.path.original === 'link-to'; + return (0, _utils.isPath)(node.path) && node.path.original === 'link-to'; } function isBlockLinkTo(node) { - return node.path.original === 'link-to'; - } - - function isSubExpression(node) { - return node.type === 'SubExpression'; + return (0, _utils.isPath)(node.path) && node.path.original === 'link-to'; } function isQueryParams(node) { - return isSubExpression(node) && node.path.original === 'query-params'; + return (0, _utils.isSubExpression)(node) && (0, _utils.isPath)(node.path) && node.path.original === 'query-params'; } function transformInlineLinkToIntoBlockForm(env, node) { var b = env.syntax.builders; - return b.block('link-to', node.params.slice(1), node.hash, buildProgram(b, node.params[0], node.escaped, node.loc), null, node.loc); + return b.block('link-to', node.params.slice(1), node.hash, b.blockItself([buildStatement(b, node.params[0], node.escaped, node.loc)], undefined, false, node.loc), null, node.loc); } function transformPositionalLinkToIntoNamedArguments(env, node) { @@ -7532,7 +11263,7 @@ define("ember-template-compiler/lib/plugins/transform-link-to", ["exports", "@em if (query && isQueryParams(query)) { params.pop(); (true && !(query.params.length === 0) && (0, _debug.assert)("The `(query-params ...)` helper does not take positional arguments. " + (0, _calculateLocationDisplay.default)(moduleName, query.loc), query.params.length === 0)); - pairs.push(b.pair('query', b.sexpr(b.path('hash', query.path.loc), [], query.hash, query.loc), query.loc)); + pairs.push(b.pair('query', b.sexpr(b.path('-hash', query.path.loc), [], query.hash, query.loc), query.loc)); } // 2. If there is a `route`, it is now at index 0. @@ -7552,10 +11283,6 @@ define("ember-template-compiler/lib/plugins/transform-link-to", ["exports", "@em return b.block(node.path, null, b.hash(pairs, node.hash.loc), node.program, node.inverse, node.loc); } - function buildProgram(b, content, escaped, loc) { - return b.program([buildStatement(b, content, escaped, loc)], undefined, loc); - } - function buildStatement(b, content, escaped, loc) { switch (content.type) { case 'PathExpression': @@ -7772,6 +11499,142 @@ define("ember-template-compiler/lib/plugins/transform-quoted-bindings-into-just- return undefined; } }); +define("ember-template-compiler/lib/plugins/transform-wrap-mount-and-outlet", ["exports", "ember-template-compiler/lib/plugins/utils"], function (_exports, _utils) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.default = transformWrapMountAndOutlet; + + /** + @module ember + */ + + /** + A Glimmer2 AST transformation that replaces all instances of + + ```handlebars + {{mount "engine" model=this.model}} + ``` + + with + + ```handlebars + {{component (-mount "engine" model=this.model)}} + ``` + + and + + ```handlebars + {{outlet}} + ``` + + with + + ```handlebars + {{component (-outlet)}} + ``` + + @private + @class TransformHasBlockSyntax + */ + function transformWrapMountAndOutlet(env) { + var b = env.syntax.builders; + + var _trackLocals = (0, _utils.trackLocals)(), + hasLocal = _trackLocals.hasLocal, + node = _trackLocals.node; + + return { + name: 'transform-wrap-mount-and-outlet', + visitor: { + Program: node, + ElementNode: node, + MustacheStatement: function MustacheStatement(node) { + if ((0, _utils.isPath)(node.path) && (node.path.original === 'mount' || node.path.original === 'outlet') && !hasLocal(node.path.original)) { + var subexpression = b.sexpr(b.path("-" + node.path.original), node.params, node.hash, node.loc); + return b.mustache(b.path('component'), [subexpression], b.hash(), undefined, node.loc); + } + } + } + }; + } +}); +define("ember-template-compiler/lib/plugins/utils", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.isPath = isPath; + _exports.isSubExpression = isSubExpression; + _exports.trackLocals = trackLocals; + + function isPath(node) { + return node.type === 'PathExpression'; + } + + function isSubExpression(node) { + return node.type === 'SubExpression'; + } + + function trackLocals() { + var locals = new Map(); + var node = { + enter: function enter(node) { + for (var _iterator = node.blockParams, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { + var _ref; + + if (_isArray) { + if (_i >= _iterator.length) break; + _ref = _iterator[_i++]; + } else { + _i = _iterator.next(); + if (_i.done) break; + _ref = _i.value; + } + + var _param = _ref; + + var _value = locals.get(_param) || 0; + + locals.set(_param, _value + 1); + } + }, + exit: function exit(node) { + for (var _iterator2 = node.blockParams, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { + var _ref2; + + if (_isArray2) { + if (_i2 >= _iterator2.length) break; + _ref2 = _iterator2[_i2++]; + } else { + _i2 = _iterator2.next(); + if (_i2.done) break; + _ref2 = _i2.value; + } + + var _param2 = _ref2; + + var _value2 = locals.get(_param2) - 1; + + if (_value2 === 0) { + locals.delete(_param2); + } else { + locals.set(_param2, _value2); + } + } + } + }; + return { + hasLocal: function hasLocal(key) { + return locals.has(key); + }, + node: node + }; + } +}); define("ember-template-compiler/lib/system/bootstrap", ["exports", "ember-template-compiler/lib/system/compile"], function (_exports, _compile) { "use strict"; @@ -8117,7 +11980,7 @@ define("ember/version", ["exports"], function (_exports) { value: true }); _exports.default = void 0; - var _default = "3.16.2"; + var _default = "3.17.0"; _exports.default = _default; }); define("handlebars", ["exports"], function (_exports) { @@ -8126,6 +11989,7 @@ define("handlebars", ["exports"], function (_exports) { Object.defineProperty(_exports, "__esModule", { value: true }); + _exports.parseWithoutProcessing = parseWithoutProcessing; _exports.parse = parse; _exports.parser = void 0; @@ -8152,7 +12016,7 @@ define("handlebars", ["exports"], function (_exports) { "COMMENT": 14, "CONTENT": 15, "openRawBlock": 16, - "rawBlock_repetition_plus0": 17, + "rawBlock_repetition0": 17, "END_RAW_BLOCK": 18, "OPEN_RAW_BLOCK": 19, "helperName": 20, @@ -8259,7 +12123,7 @@ define("handlebars", ["exports"], function (_exports) { 85: "DATA", 87: "SEP" }, - productions_: [0, [3, 2], [4, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [13, 1], [10, 3], [16, 5], [9, 4], [9, 4], [24, 6], [27, 6], [38, 6], [43, 2], [45, 3], [45, 1], [26, 3], [8, 5], [8, 5], [11, 5], [12, 3], [59, 5], [63, 1], [63, 1], [64, 5], [69, 1], [71, 3], [74, 3], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [56, 1], [56, 1], [79, 2], [78, 1], [86, 3], [86, 1], [6, 0], [6, 2], [17, 1], [17, 2], [21, 0], [21, 2], [22, 0], [22, 1], [25, 0], [25, 1], [28, 0], [28, 1], [30, 0], [30, 2], [31, 0], [31, 1], [32, 0], [32, 1], [35, 0], [35, 2], [36, 0], [36, 1], [37, 0], [37, 1], [40, 0], [40, 2], [41, 0], [41, 1], [42, 0], [42, 1], [46, 0], [46, 1], [49, 0], [49, 2], [50, 0], [50, 1], [52, 0], [52, 2], [53, 0], [53, 1], [57, 0], [57, 2], [58, 0], [58, 1], [61, 0], [61, 2], [62, 0], [62, 1], [66, 0], [66, 2], [67, 0], [67, 1], [70, 1], [70, 2], [76, 1], [76, 2]], + productions_: [0, [3, 2], [4, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [7, 1], [13, 1], [10, 3], [16, 5], [9, 4], [9, 4], [24, 6], [27, 6], [38, 6], [43, 2], [45, 3], [45, 1], [26, 3], [8, 5], [8, 5], [11, 5], [12, 3], [59, 5], [63, 1], [63, 1], [64, 5], [69, 1], [71, 3], [74, 3], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [20, 1], [56, 1], [56, 1], [79, 2], [78, 1], [86, 3], [86, 1], [6, 0], [6, 2], [17, 0], [17, 2], [21, 0], [21, 2], [22, 0], [22, 1], [25, 0], [25, 1], [28, 0], [28, 1], [30, 0], [30, 2], [31, 0], [31, 1], [32, 0], [32, 1], [35, 0], [35, 2], [36, 0], [36, 1], [37, 0], [37, 1], [40, 0], [40, 2], [41, 0], [41, 1], [42, 0], [42, 1], [46, 0], [46, 1], [49, 0], [49, 2], [50, 0], [50, 1], [52, 0], [52, 2], [53, 0], [53, 1], [57, 0], [57, 2], [58, 0], [58, 1], [61, 0], [61, 2], [62, 0], [62, 1], [66, 0], [66, 2], [67, 0], [67, 1], [70, 1], [70, 2], [76, 1], [76, 2]], performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$) { var $0 = $$.length - 1; @@ -8560,7 +12424,7 @@ define("handlebars", ["exports"], function (_exports) { break; case 48: - this.$ = [$$[$0]]; + this.$ = []; break; case 49: @@ -8867,14 +12731,14 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 46], 60: [2, 46] }, { - 13: 40, - 15: [1, 20], - 17: 39 + 15: [2, 48], + 17: 39, + 18: [2, 48] }, { - 20: 42, - 56: 41, - 64: 43, - 65: [1, 44], + 20: 41, + 56: 40, + 64: 42, + 65: [1, 43], 72: [1, 35], 78: 26, 79: 27, @@ -8886,7 +12750,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 4: 45, + 4: 44, 6: 3, 14: [2, 46], 15: [2, 46], @@ -8914,7 +12778,7 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 10], 60: [2, 10] }, { - 20: 46, + 20: 45, 72: [1, 35], 78: 26, 79: 27, @@ -8926,7 +12790,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 20: 47, + 20: 46, 72: [1, 35], 78: 26, 79: 27, @@ -8938,7 +12802,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 20: 48, + 20: 47, 72: [1, 35], 78: 26, 79: 27, @@ -8950,10 +12814,10 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 20: 42, - 56: 49, - 64: 43, - 65: [1, 44], + 20: 41, + 56: 48, + 64: 42, + 65: [1, 43], 72: [1, 35], 78: 26, 79: 27, @@ -8966,7 +12830,7 @@ define("handlebars", ["exports"], function (_exports) { 86: 33 }, { 33: [2, 78], - 49: 50, + 49: 49, 65: [2, 78], 72: [2, 78], 80: [2, 78], @@ -9087,10 +12951,10 @@ define("handlebars", ["exports"], function (_exports) { 83: [2, 43], 84: [2, 43], 85: [2, 43], - 87: [1, 51] + 87: [1, 50] }, { 72: [1, 35], - 86: 52 + 86: 51 }, { 23: [2, 45], 33: [2, 45], @@ -9107,7 +12971,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [2, 45], 87: [2, 45] }, { - 52: 53, + 52: 52, 54: [2, 82], 65: [2, 82], 72: [2, 82], @@ -9118,28 +12982,25 @@ define("handlebars", ["exports"], function (_exports) { 84: [2, 82], 85: [2, 82] }, { - 25: 54, - 38: 56, - 39: [1, 58], - 43: 57, - 44: [1, 59], - 45: 55, + 25: 53, + 38: 55, + 39: [1, 57], + 43: 56, + 44: [1, 58], + 45: 54, 47: [2, 54] }, { - 28: 60, - 43: 61, - 44: [1, 59], + 28: 59, + 43: 60, + 44: [1, 58], 47: [2, 56] }, { - 13: 63, + 13: 62, 15: [1, 20], - 18: [1, 62] - }, { - 15: [2, 48], - 18: [2, 48] + 18: [1, 61] }, { 33: [2, 86], - 57: 64, + 57: 63, 65: [2, 86], 72: [2, 86], 80: [2, 86], @@ -9169,7 +13030,7 @@ define("handlebars", ["exports"], function (_exports) { 84: [2, 41], 85: [2, 41] }, { - 20: 65, + 20: 64, 72: [1, 35], 78: 26, 79: 27, @@ -9181,10 +13042,10 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 26: 66, - 47: [1, 67] + 26: 65, + 47: [1, 66] }, { - 30: 68, + 30: 67, 33: [2, 58], 65: [2, 58], 72: [2, 58], @@ -9197,7 +13058,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [2, 58] }, { 33: [2, 64], - 35: 69, + 35: 68, 65: [2, 64], 72: [2, 64], 75: [2, 64], @@ -9208,7 +13069,7 @@ define("handlebars", ["exports"], function (_exports) { 84: [2, 64], 85: [2, 64] }, { - 21: 70, + 21: 69, 23: [2, 50], 65: [2, 50], 72: [2, 50], @@ -9220,7 +13081,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [2, 50] }, { 33: [2, 90], - 61: 71, + 61: 70, 65: [2, 90], 72: [2, 90], 80: [2, 90], @@ -9230,16 +13091,16 @@ define("handlebars", ["exports"], function (_exports) { 84: [2, 90], 85: [2, 90] }, { - 20: 75, + 20: 74, 33: [2, 80], - 50: 72, - 63: 73, - 64: 76, - 65: [1, 44], - 69: 74, - 70: 77, - 71: 78, - 72: [1, 79], + 50: 71, + 63: 72, + 64: 75, + 65: [1, 43], + 69: 73, + 70: 76, + 71: 77, + 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], @@ -9250,7 +13111,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 72: [1, 80] + 72: [1, 79] }, { 23: [2, 42], 33: [2, 42], @@ -9265,18 +13126,18 @@ define("handlebars", ["exports"], function (_exports) { 83: [2, 42], 84: [2, 42], 85: [2, 42], - 87: [1, 51] + 87: [1, 50] }, { - 20: 75, - 53: 81, + 20: 74, + 53: 80, 54: [2, 84], - 63: 82, - 64: 76, - 65: [1, 44], - 69: 83, - 70: 77, - 71: 78, - 72: [1, 79], + 63: 81, + 64: 75, + 65: [1, 43], + 69: 82, + 70: 76, + 71: 77, + 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], @@ -9287,12 +13148,12 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 26: 84, - 47: [1, 67] + 26: 83, + 47: [1, 66] }, { 47: [2, 55] }, { - 4: 85, + 4: 84, 6: 3, 14: [2, 46], 15: [2, 46], @@ -9309,7 +13170,7 @@ define("handlebars", ["exports"], function (_exports) { }, { 47: [2, 20] }, { - 20: 86, + 20: 85, 72: [1, 35], 78: 26, 79: 27, @@ -9321,7 +13182,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 4: 87, + 4: 86, 6: 3, 14: [2, 46], 15: [2, 46], @@ -9334,8 +13195,8 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 46], 60: [2, 46] }, { - 26: 88, - 47: [1, 67] + 26: 87, + 47: [1, 66] }, { 47: [2, 57] }, { @@ -9356,16 +13217,16 @@ define("handlebars", ["exports"], function (_exports) { 15: [2, 49], 18: [2, 49] }, { - 20: 75, + 20: 74, 33: [2, 88], - 58: 89, - 63: 90, - 64: 76, - 65: [1, 44], - 69: 91, - 70: 77, - 71: 78, - 72: [1, 79], + 58: 88, + 63: 89, + 64: 75, + 65: [1, 43], + 69: 90, + 70: 76, + 71: 77, + 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], @@ -9377,7 +13238,7 @@ define("handlebars", ["exports"], function (_exports) { 86: 33 }, { 65: [2, 94], - 66: 92, + 66: 91, 68: [2, 94], 72: [2, 94], 80: [2, 94], @@ -9401,7 +13262,7 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 25], 60: [2, 25] }, { - 20: 93, + 20: 92, 72: [1, 35], 78: 26, 79: 27, @@ -9413,16 +13274,16 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 20: 75, - 31: 94, + 20: 74, + 31: 93, 33: [2, 60], - 63: 95, - 64: 76, - 65: [1, 44], - 69: 96, - 70: 77, - 71: 78, - 72: [1, 79], + 63: 94, + 64: 75, + 65: [1, 43], + 69: 95, + 70: 76, + 71: 77, + 72: [1, 78], 75: [2, 60], 78: 26, 79: 27, @@ -9434,16 +13295,16 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 20: 75, + 20: 74, 33: [2, 66], - 36: 97, - 63: 98, - 64: 76, - 65: [1, 44], - 69: 99, - 70: 77, - 71: 78, - 72: [1, 79], + 36: 96, + 63: 97, + 64: 75, + 65: [1, 43], + 69: 98, + 70: 76, + 71: 77, + 72: [1, 78], 75: [2, 66], 78: 26, 79: 27, @@ -9455,16 +13316,16 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 20: 75, - 22: 100, + 20: 74, + 22: 99, 23: [2, 52], - 63: 101, - 64: 76, - 65: [1, 44], - 69: 102, - 70: 77, - 71: 78, - 72: [1, 79], + 63: 100, + 64: 75, + 65: [1, 43], + 69: 101, + 70: 76, + 71: 77, + 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], @@ -9475,16 +13336,16 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 20: 75, + 20: 74, 33: [2, 92], - 62: 103, - 63: 104, - 64: 76, - 65: [1, 44], - 69: 105, - 70: 77, - 71: 78, - 72: [1, 79], + 62: 102, + 63: 103, + 64: 75, + 65: [1, 43], + 69: 104, + 70: 76, + 71: 77, + 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], @@ -9495,7 +13356,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 33: [1, 106] + 33: [1, 105] }, { 33: [2, 79], 65: [2, 79], @@ -9541,8 +13402,8 @@ define("handlebars", ["exports"], function (_exports) { 33: [2, 30], 54: [2, 30], 68: [2, 30], - 71: 107, - 72: [1, 108], + 71: 106, + 72: [1, 107], 75: [2, 30] }, { 23: [2, 98], @@ -9558,7 +13419,7 @@ define("handlebars", ["exports"], function (_exports) { 65: [2, 45], 68: [2, 45], 72: [2, 45], - 73: [1, 109], + 73: [1, 108], 75: [2, 45], 80: [2, 45], 81: [2, 45], @@ -9583,7 +13444,7 @@ define("handlebars", ["exports"], function (_exports) { 85: [2, 44], 87: [2, 44] }, { - 54: [1, 110] + 54: [1, 109] }, { 54: [2, 83], 65: [2, 83], @@ -9611,16 +13472,16 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 13], 60: [2, 13] }, { - 38: 56, - 39: [1, 58], - 43: 57, - 44: [1, 59], - 45: 112, - 46: 111, + 38: 55, + 39: [1, 57], + 43: 56, + 44: [1, 58], + 45: 111, + 46: 110, 47: [2, 76] }, { 33: [2, 70], - 40: 113, + 40: 112, 65: [2, 70], 72: [2, 70], 75: [2, 70], @@ -9647,7 +13508,7 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 14], 60: [2, 14] }, { - 33: [1, 114] + 33: [1, 113] }, { 33: [2, 87], 65: [2, 87], @@ -9661,16 +13522,16 @@ define("handlebars", ["exports"], function (_exports) { }, { 33: [2, 89] }, { - 20: 75, - 63: 116, - 64: 76, - 65: [1, 44], - 67: 115, + 20: 74, + 63: 115, + 64: 75, + 65: [1, 43], + 67: 114, 68: [2, 96], - 69: 117, - 70: 77, - 71: 78, - 72: [1, 79], + 69: 116, + 70: 76, + 71: 77, + 72: [1, 78], 78: 26, 79: 27, 80: [1, 28], @@ -9681,12 +13542,12 @@ define("handlebars", ["exports"], function (_exports) { 85: [1, 34], 86: 33 }, { - 33: [1, 118] + 33: [1, 117] }, { - 32: 119, + 32: 118, 33: [2, 62], - 74: 120, - 75: [1, 121] + 74: 119, + 75: [1, 120] }, { 33: [2, 59], 65: [2, 59], @@ -9703,9 +13564,9 @@ define("handlebars", ["exports"], function (_exports) { 75: [2, 61] }, { 33: [2, 68], - 37: 122, - 74: 123, - 75: [1, 121] + 37: 121, + 74: 122, + 75: [1, 120] }, { 33: [2, 65], 65: [2, 65], @@ -9721,7 +13582,7 @@ define("handlebars", ["exports"], function (_exports) { 33: [2, 67], 75: [2, 67] }, { - 23: [1, 124] + 23: [1, 123] }, { 23: [2, 51], 65: [2, 51], @@ -9735,7 +13596,7 @@ define("handlebars", ["exports"], function (_exports) { }, { 23: [2, 53] }, { - 33: [1, 125] + 33: [1, 124] }, { 33: [2, 91], 65: [2, 91], @@ -9770,12 +13631,12 @@ define("handlebars", ["exports"], function (_exports) { 72: [2, 99], 75: [2, 99] }, { - 73: [1, 109] + 73: [1, 108] }, { - 20: 75, - 63: 126, - 64: 76, - 65: [1, 44], + 20: 74, + 63: 125, + 64: 75, + 65: [1, 43], 72: [1, 35], 78: 26, 79: 27, @@ -9805,16 +13666,16 @@ define("handlebars", ["exports"], function (_exports) { }, { 47: [2, 77] }, { - 20: 75, + 20: 74, 33: [2, 72], - 41: 127, - 63: 128, - 64: 76, - 65: [1, 44], - 69: 129, - 70: 77, - 71: 78, - 72: [1, 79], + 41: 126, + 63: 127, + 64: 75, + 65: [1, 43], + 69: 128, + 70: 76, + 71: 77, + 72: [1, 78], 75: [2, 72], 78: 26, 79: 27, @@ -9840,7 +13701,7 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 24], 60: [2, 24] }, { - 68: [1, 130] + 68: [1, 129] }, { 65: [2, 95], 68: [2, 95], @@ -9868,18 +13729,19 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 21], 60: [2, 21] }, { - 33: [1, 131] + 33: [1, 130] }, { 33: [2, 63] }, { - 72: [1, 133], - 76: 132 + 72: [1, 132], + 76: 131 }, { - 33: [1, 134] + 33: [1, 133] }, { 33: [2, 69] }, { - 15: [2, 12] + 15: [2, 12], + 18: [2, 12] }, { 14: [2, 26], 15: [2, 26], @@ -9900,9 +13762,9 @@ define("handlebars", ["exports"], function (_exports) { 75: [2, 31] }, { 33: [2, 74], - 42: 135, - 74: 136, - 75: [1, 121] + 42: 134, + 74: 135, + 75: [1, 120] }, { 33: [2, 71], 65: [2, 71], @@ -9945,8 +13807,8 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 15], 60: [2, 15] }, { - 72: [1, 138], - 77: [1, 137] + 72: [1, 137], + 77: [1, 136] }, { 72: [2, 100], 77: [2, 100] @@ -9963,7 +13825,7 @@ define("handlebars", ["exports"], function (_exports) { 55: [2, 16], 60: [2, 16] }, { - 33: [1, 139] + 33: [1, 138] }, { 33: [2, 75] }, { @@ -9987,23 +13849,22 @@ define("handlebars", ["exports"], function (_exports) { }], defaultActions: { 4: [2, 1], - 55: [2, 55], - 57: [2, 20], - 61: [2, 57], - 74: [2, 81], - 83: [2, 85], - 87: [2, 18], - 91: [2, 89], - 102: [2, 53], - 105: [2, 93], - 111: [2, 19], - 112: [2, 77], - 117: [2, 97], - 120: [2, 63], - 123: [2, 69], - 124: [2, 12], - 136: [2, 75], - 137: [2, 32] + 54: [2, 55], + 56: [2, 20], + 60: [2, 57], + 73: [2, 81], + 82: [2, 85], + 86: [2, 18], + 90: [2, 89], + 101: [2, 53], + 104: [2, 93], + 110: [2, 19], + 111: [2, 77], + 116: [2, 97], + 119: [2, 63], + 122: [2, 69], + 135: [2, 75], + 136: [2, 32] }, parseError: function parseError(str, hash) { throw new Error(str); @@ -10345,7 +14206,7 @@ define("handlebars", ["exports"], function (_exports) { lexer.performAction = function anonymous(yy, yy_, $avoiding_name_collisions, YY_START) { function strip(start, end) { - return yy_.yytext = yy_.yytext.substr(start, yy_.yyleng - end); + return yy_.yytext = yy_.yytext.substring(start, yy_.yyleng - end + start); } switch ($avoiding_name_collisions) { @@ -10385,7 +14246,7 @@ define("handlebars", ["exports"], function (_exports) { if (this.conditionStack[this.conditionStack.length - 1] === 'raw') { return 15; } else { - yy_.yytext = yy_.yytext.substr(5, yy_.yyleng - 9); + strip(5, 9); return 'END_RAW_BLOCK'; } @@ -10566,7 +14427,7 @@ define("handlebars", ["exports"], function (_exports) { } }; - lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/, /^(?:\{\{\{\{(?=[^\/]))/, /^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/, /^(?:[^\x00]*?(?=(\{\{\{\{)))/, /^(?:[\s\S]*?--(~)?\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{\{\{)/, /^(?:\}\}\}\})/, /^(?:\{\{(~)?>)/, /^(?:\{\{(~)?#>)/, /^(?:\{\{(~)?#\*?)/, /^(?:\{\{(~)?\/)/, /^(?:\{\{(~)?\^\s*(~)?\}\})/, /^(?:\{\{(~)?\s*else\s*(~)?\}\})/, /^(?:\{\{(~)?\^)/, /^(?:\{\{(~)?\s*else\b)/, /^(?:\{\{(~)?\{)/, /^(?:\{\{(~)?&)/, /^(?:\{\{(~)?!--)/, /^(?:\{\{(~)?![\s\S]*?\}\})/, /^(?:\{\{(~)?\*?)/, /^(?:=)/, /^(?:\.\.)/, /^(?:\.(?=([=~}\s\/.)|])))/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:\}(~)?\}\})/, /^(?:(~)?\}\})/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@)/, /^(?:true(?=([~}\s)])))/, /^(?:false(?=([~}\s)])))/, /^(?:undefined(?=([~}\s)])))/, /^(?:null(?=([~}\s)])))/, /^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/, /^(?:as\s+\|)/, /^(?:\|)/, /^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/, /^(?:\[(\\\]|[^\]])*\])/, /^(?:.)/, /^(?:$)/]; + lexer.rules = [/^(?:[^\x00]*?(?=(\{\{)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|\\\{\{|\\\\\{\{|$)))/, /^(?:\{\{\{\{(?=[^\/]))/, /^(?:\{\{\{\{\/[^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=[=}\s\/.])\}\}\}\})/, /^(?:[^\x00]+?(?=(\{\{\{\{)))/, /^(?:[\s\S]*?--(~)?\}\})/, /^(?:\()/, /^(?:\))/, /^(?:\{\{\{\{)/, /^(?:\}\}\}\})/, /^(?:\{\{(~)?>)/, /^(?:\{\{(~)?#>)/, /^(?:\{\{(~)?#\*?)/, /^(?:\{\{(~)?\/)/, /^(?:\{\{(~)?\^\s*(~)?\}\})/, /^(?:\{\{(~)?\s*else\s*(~)?\}\})/, /^(?:\{\{(~)?\^)/, /^(?:\{\{(~)?\s*else\b)/, /^(?:\{\{(~)?\{)/, /^(?:\{\{(~)?&)/, /^(?:\{\{(~)?!--)/, /^(?:\{\{(~)?![\s\S]*?\}\})/, /^(?:\{\{(~)?\*?)/, /^(?:=)/, /^(?:\.\.)/, /^(?:\.(?=([=~}\s\/.)|])))/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:\}(~)?\}\})/, /^(?:(~)?\}\})/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@)/, /^(?:true(?=([~}\s)])))/, /^(?:false(?=([~}\s)])))/, /^(?:undefined(?=([~}\s)])))/, /^(?:null(?=([~}\s)])))/, /^(?:-?[0-9]+(?:\.[0-9]+)?(?=([~}\s)])))/, /^(?:as\s+\|)/, /^(?:\|)/, /^(?:([^\s!"#%-,\.\/;->@\[-\^`\{-~]+(?=([=~}\s\/.)|]))))/, /^(?:\[(\\\]|[^\]])*\])/, /^(?:.)/, /^(?:$)/]; lexer.conditions = { "mu": { "rules": [7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44], @@ -10604,16 +14465,20 @@ define("handlebars", ["exports"], function (_exports) { }(); _exports.parser = handlebars; - var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + var errorProps = ['description', 'fileName', 'lineNumber', 'endLineNumber', 'message', 'name', 'number', 'stack']; function Exception(message, node) { var loc = node && node.loc, line, - column; + endLineNumber, + column, + endColumn; if (loc) { line = loc.start.line; + endLineNumber = loc.end.line; column = loc.start.column; + endColumn = loc.end.column; message += ' - ' + line + ':' + column; } @@ -10631,7 +14496,8 @@ define("handlebars", ["exports"], function (_exports) { try { if (loc) { - this.lineNumber = line; // Work around issue under safari where we can't directly set the column value + this.lineNumber = line; + this.endLineNumber = endLineNumber; // Work around issue under safari where we can't directly set the column value /* istanbul ignore next */ @@ -10640,8 +14506,13 @@ define("handlebars", ["exports"], function (_exports) { value: column, enumerable: true }); + Object.defineProperty(this, 'endColumn', { + value: endColumn, + enumerable: true + }); } else { this.column = column; + this.endColumn = endColumn; } } } catch (nop) { @@ -10986,7 +14857,7 @@ define("handlebars", ["exports"], function (_exports) { if (!current || current.type !== 'ContentStatement' || !multiple && current.leftStripped) { return; - } // We omit the last node if it's whitespace only and not preceeded by a non-content node. + } // We omit the last node if it's whitespace only and not preceded by a non-content node. var original = current.value; @@ -11020,7 +14891,7 @@ define("handlebars", ["exports"], function (_exports) { function id(token) { if (/^\[.*\]$/.test(token)) { - return token.substr(1, token.length - 2); + return token.substring(1, token.length - 1); } else { return token; } @@ -11246,7 +15117,7 @@ define("handlebars", ["exports"], function (_exports) { var yy = {}; extend(yy, Helpers); - function parse(input, options) { + function parseWithoutProcessing(input, options) { // Just return if an already-compiled AST was passed in. if (input.type === 'Program') { return input; @@ -11258,8 +15129,14 @@ define("handlebars", ["exports"], function (_exports) { return new yy.SourceLocation(options && options.srcName, locInfo); }; + var ast = handlebars.parse(input); + return ast; + } + + function parse(input, options) { + var ast = parseWithoutProcessing(input, options); var strip = new WhitespaceControl(options); - return strip.accept(handlebars.parse(input)); + return strip.accept(ast); } }); define("node-module/index", ["exports"], function (_exports) { diff --git a/vendor/ember-testing.js b/vendor/ember-testing.js index fc8e0df3..707962e6 100644 --- a/vendor/ember-testing.js +++ b/vendor/ember-testing.js @@ -6,7 +6,7 @@ * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 3.16.2 + * @version 3.17.0 */ /*globals process */ var define, require, Ember; // Used in @ember/-internals/environment/lib/global.js @@ -286,7 +286,7 @@ define("@ember/debug/index", ["exports", "@ember/-internals/browser-environment" */ setDebugFunction('assert', function assert(desc, test) { if (!test) { - throw new _error.default("Assertion Failed: " + desc); + throw new _error.default(`Assertion Failed: ${desc}`); } }); /** @@ -308,9 +308,9 @@ define("@ember/debug/index", ["exports", "@ember/-internals/browser-environment" setDebugFunction('debug', function debug(message) { /* eslint-disable no-console */ if (console.debug) { - console.debug("DEBUG: " + message); + console.debug(`DEBUG: ${message}`); } else { - console.log("DEBUG: " + message); + console.log(`DEBUG: ${message}`); } /* eslint-ensable no-console */ @@ -435,7 +435,7 @@ define("@ember/debug/index", ["exports", "@ember/-internals/browser-environment" downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; } - debug("For more advanced debugging, install the Ember Inspector from " + downloadURL); + debug(`For more advanced debugging, install the Ember Inspector from ${downloadURL}`); } }, false); } @@ -467,8 +467,10 @@ define("@ember/debug/lib/capture-render-tree", ["exports", "@glimmer/util"], fun @since 3.14.0 */ function captureRenderTree(app) { - var env = (0, _util.expect)(app.lookup('service:-glimmer-environment'), 'BUG: owner is missing service:-glimmer-environment'); - return env.debugRenderTree.capture(); + var env = (0, _util.expect)(app.lookup('-environment:main'), 'BUG: owner is missing -environment:main'); + var rendererType = env.isInteractive ? 'renderer:-dom' : 'renderer:-inert'; + var renderer = (0, _util.expect)(app.lookup(rendererType), `BUG: owner is missing ${rendererType}`); + return renderer.debugRenderTree.capture(); } }); define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment", "@ember/debug/index", "@ember/debug/lib/handlers"], function (_exports, _environment, _index, _handlers) { @@ -545,11 +547,11 @@ define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment" var message = _message; if (options && options.id) { - message = message + (" [deprecation id: " + options.id + "]"); + message = message + ` [deprecation id: ${options.id}]`; } if (options && options.url) { - message += " See " + options.url + " for more details."; + message += ` See ${options.url} for more details.`; } return message; @@ -557,7 +559,7 @@ define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment" registerHandler(function logDeprecationToConsole(message, options) { var updatedMessage = formatMessage(message, options); - console.warn("DEPRECATION: " + updatedMessage); // eslint-disable-line no-console + console.warn(`DEPRECATION: ${updatedMessage}`); // eslint-disable-line no-console }); var captureErrorForStack; @@ -589,11 +591,11 @@ define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment" stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); } - stackStr = "\n " + stack.slice(2).join('\n '); + stackStr = `\n ${stack.slice(2).join('\n ')}`; } var updatedMessage = formatMessage(message, options); - console.warn("DEPRECATION: " + updatedMessage + stackStr); // eslint-disable-line no-console + console.warn(`DEPRECATION: ${updatedMessage}${stackStr}`); // eslint-disable-line no-console } else { next(message, options); } @@ -766,7 +768,7 @@ define("@ember/debug/lib/warn", ["exports", "@ember/debug/index", "@ember/debug/ registerHandler(function logWarning(message) { /* eslint-disable no-console */ - console.warn("WARNING: " + message); + console.warn(`WARNING: ${message}`); /* eslint-enable no-console */ }); _exports.missingOptionsDeprecation = missingOptionsDeprecation = 'When calling `warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; @@ -2437,7 +2439,7 @@ define("ember-testing/lib/test/promise", ["exports", "@ember/-internals/runtime" _exports.default = TestPromise; function promise(resolver, label) { - var fullLabel = "Ember.Test.promise: " + (label || ''); + var fullLabel = `Ember.Test.promise: ${label || ''}`; return new TestPromise(resolver, fullLabel); } /** diff --git a/vendor/full-ember-debug.js b/vendor/full-ember-debug.js index 076d63d0..7396fdc1 100644 --- a/vendor/full-ember-debug.js +++ b/vendor/full-ember-debug.js @@ -1306,7 +1306,7 @@ define("@glimmer/component/-private/owner", ["exports", "@glimmer/di"], function * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 3.16.2 + * @version 3.17.0 */ /*globals process */ var define, require, Ember; // Used in @ember/-internals/environment/lib/global.js @@ -1743,7 +1743,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner lookup(fullName, options) { if (this.isDestroyed) { - throw new Error("Can not call `.lookup` after the owner has been destroyed"); + throw new Error(`Can not call \`.lookup\` after the owner has been destroyed`); } (true && !(this.registry.isValidFullName(fullName)) && (0, _debug.assert)('fullName must be a proper full name', this.registry.isValidFullName(fullName))); @@ -1814,7 +1814,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner factoryFor(fullName, options = {}) { if (this.isDestroyed) { - throw new Error("Can not call `.factoryFor` after the owner has been destroyed"); + throw new Error(`Can not call \`.factoryFor\` after the owner has been destroyed`); } var normalizedName = this.registry.normalize(fullName); @@ -1853,7 +1853,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner if (_utils.HAS_NATIVE_PROXY) { var validator = { set(_obj, prop) { - throw new Error("You attempted to set \"" + prop + "\" on a factory manager created by container#factoryFor. A factory manager is a read-only construct."); + throw new Error(`You attempted to set "${prop}" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.`); } }; // Note: @@ -2123,7 +2123,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner } = this; if (container.isDestroyed) { - throw new Error("Can not create new instances after the owner has been destroyed (you attempted to create " + this.fullName + ")"); + throw new Error(`Can not create new instances after the owner has been destroyed (you attempted to create ${this.fullName})`); } var injectionsCache = this.injections; @@ -2162,7 +2162,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner } if (!this.class.create) { - throw new Error("Failed to create an instance of '" + this.normalizedName + "'. Most likely an improperly defined class or an invalid module export."); + throw new Error(`Failed to create an instance of '${this.normalizedName}'. Most likely an improperly defined class or an invalid module export.`); } // required to allow access to things like // the customized toString, _debugContainerKey, // owner, etc. without a double extend and without @@ -2308,9 +2308,9 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner register(fullName, factory, options = {}) { (true && !(this.isValidFullName(fullName)) && (0, _debug.assert)('fullName must be a proper full name', this.isValidFullName(fullName))); - (true && !(factory !== undefined) && (0, _debug.assert)("Attempting to register an unknown factory: '" + fullName + "'", factory !== undefined)); + (true && !(factory !== undefined) && (0, _debug.assert)(`Attempting to register an unknown factory: '${fullName}'`, factory !== undefined)); var normalizedName = this.normalize(fullName); - (true && !(!this._resolveCache[normalizedName]) && (0, _debug.assert)("Cannot re-register: '" + fullName + "', as it has already been resolved.", !this._resolveCache[normalizedName])); + (true && !(!this._resolveCache[normalizedName]) && (0, _debug.assert)(`Cannot re-register: '${fullName}', as it has already been resolved.`, !this._resolveCache[normalizedName])); this._failSet.delete(normalizedName); @@ -2582,7 +2582,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner typeInjection(type, property, fullName) { (true && !(this.isValidFullName(fullName)) && (0, _debug.assert)('fullName must be a proper full name', this.isValidFullName(fullName))); var fullNameType = fullName.split(':')[0]; - (true && !(fullNameType !== type) && (0, _debug.assert)("Cannot inject a '" + fullName + "' on other " + type + "(s).", fullNameType !== type)); + (true && !(fullNameType !== type) && (0, _debug.assert)(`Cannot inject a '${fullName}' on other ${type}(s).`, fullNameType !== type)); var injections = this._typeInjections[type] || (this._typeInjections[type] = []); injections.push({ property, @@ -2625,7 +2625,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner injection(fullName, property, injectionName) { - (true && !(this.isValidFullName(injectionName)) && (0, _debug.assert)("Invalid injectionName, expected: 'type:name' got: " + injectionName, this.isValidFullName(injectionName))); + (true && !(this.isValidFullName(injectionName)) && (0, _debug.assert)(`Invalid injectionName, expected: 'type:name' got: ${injectionName}`, this.isValidFullName(injectionName))); var normalizedInjectionName = this.normalize(injectionName); if (fullName.indexOf(':') === -1) { @@ -2754,7 +2754,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner source, namespace } = hash[key]; - (true && !(this.isValidFullName(specifier)) && (0, _debug.assert)("Expected a proper full name, given '" + specifier + "'", this.isValidFullName(specifier))); + (true && !(this.isValidFullName(specifier)) && (0, _debug.assert)(`Expected a proper full name, given '${specifier}'`, this.isValidFullName(specifier))); injections.push({ property: key, specifier, @@ -2781,7 +2781,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner (true && !(this.has(specifier, { source, namespace - })) && (0, _debug.assert)("Attempting to inject an unknown injection: '" + specifier + "'", this.has(specifier, { + })) && (0, _debug.assert)(`Attempting to inject an unknown injection: '${specifier}'`, this.has(specifier, { source, namespace }))); @@ -2857,7 +2857,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner } var privateNames = (0, _utils.dictionary)(null); - var privateSuffix = ("" + Math.random() + Date.now()).replace('.', ''); + var privateSuffix = `${Math.random()}${Date.now()}`.replace('.', ''); function privatize([fullName]) { var name = privateNames[fullName]; @@ -2867,7 +2867,7 @@ define("@ember/-internals/container/index", ["exports", "@ember/-internals/owner } var [type, rawName] = fullName.split(':'); - return privateNames[fullName] = (0, _utils.intern)(type + ":" + rawName + "-" + privateSuffix); + return privateNames[fullName] = (0, _utils.intern)(`${type}:${rawName}-${privateSuffix}`); } /* Public API for the container is still in flux. @@ -3313,7 +3313,7 @@ define("@ember/-internals/extension-support/lib/container_debug_adapter", ["expo catalogEntriesByType(type) { var namespaces = (0, _runtime.A)(_runtime.Namespace.NAMESPACES); var types = (0, _runtime.A)(); - var typeSuffixRegex = new RegExp((0, _string.classify)(type) + "$"); + var typeSuffixRegex = new RegExp(`${(0, _string.classify)(type)}$`); namespaces.forEach(namespace => { for (var key in namespace) { if (!namespace.hasOwnProperty(key)) { @@ -3485,7 +3485,7 @@ define("@ember/-internals/extension-support/lib/data_adapter", ["exports", "@emb _nameToClass(type) { if (typeof type === 'string') { var owner = (0, _owner.getOwner)(this); - var Factory = owner.factoryFor("model:" + type); + var Factory = owner.factoryFor(`model:${type}`); type = Factory && Factory.class; } @@ -3809,7 +3809,7 @@ define("@ember/-internals/extension-support/lib/data_adapter", ["exports", "@emb _exports.default = _default; }); -define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/polyfills", "@ember/-internals/container", "@glimmer/opcode-compiler", "@ember/-internals/runtime", "@ember/-internals/utils", "@ember/runloop", "@glimmer/reference", "@ember/-internals/metal", "@ember/debug", "@glimmer/runtime", "@ember/-internals/owner", "@ember/-internals/views", "@ember/-internals/browser-environment", "@ember/instrumentation", "@ember/service", "@glimmer/util", "@ember/-internals/environment", "@ember/deprecated-features", "@ember/string", "@glimmer/wire-format", "rsvp", "@glimmer/node", "@ember/-internals/routing", "@ember/component/template-only", "@ember/error"], function (_exports, _emberBabel, _polyfills, _container, _opcodeCompiler, _runtime, _utils, _runloop, _reference, _metal, _debug, _runtime2, _owner, _views, _browserEnvironment, _instrumentation, _service, _util, _environment2, _deprecatedFeatures, _string, _wireFormat, _rsvp, _node, _routing, _templateOnly, _error) { +define("@ember/-internals/glimmer/index", ["exports", "@ember/polyfills", "@glimmer/opcode-compiler", "@ember/-internals/metal", "@ember/-internals/owner", "@ember/-internals/runtime", "@ember/-internals/utils", "@ember/-internals/views", "@ember/debug", "@glimmer/reference", "@glimmer/runtime", "@glimmer/validator", "@ember/-internals/browser-environment", "@ember/instrumentation", "@ember/service", "@ember/runloop", "@ember/-internals/environment", "@ember/deprecated-features", "@ember/string", "@ember/-internals/container", "@glimmer/util", "@glimmer/node", "@ember/-internals/routing", "@ember/component/template-only", "@ember/error", "@glimmer/program", "rsvp"], function (_exports, _polyfills, _opcodeCompiler, _metal, _owner, _runtime, _utils, _views, _debug, _reference, _runtime2, _validator, _browserEnvironment, _instrumentation, _service, _runloop, _environment2, _deprecatedFeatures, _string, _container, _util, _node, _routing, _templateOnly, _error, _program, _rsvp) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -3830,7 +3830,6 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol _exports.setupEngineRegistry = setupEngineRegistry; _exports.setupApplicationRegistry = setupApplicationRegistry; _exports._registerMacros = registerMacros; - _exports.iterableFor = iterableFor; _exports.capabilities = capabilities; _exports.setComponentManager = setComponentManager; _exports.getComponentManager = getComponentManager; @@ -3863,107 +3862,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return _node.NodeDOMTreeConstruction; } }); - _exports.OutletView = _exports.INVOKE = _exports.UpdatableReference = _exports.AbstractComponentManager = _exports._experimentalMacros = _exports.InteractiveRenderer = _exports.InertRenderer = _exports.Renderer = _exports.SafeString = _exports.Environment = _exports.Helper = _exports.Component = _exports.LinkComponent = _exports.TextArea = _exports.TextField = _exports.Checkbox = _exports.templateCacheCounters = _exports.RootTemplate = void 0; - - function _templateObject10() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["component:-default"]); - - _templateObject10 = function () { - return data; - }; - - return data; - } - - function _templateObject9() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template-compiler:main"]); - - _templateObject9 = function () { - return data; - }; - - return data; - } - - function _templateObject8() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template-compiler:main"]); - - _templateObject8 = function () { - return data; - }; - - return data; - } - - function _templateObject7() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template:components/-default"]); - - _templateObject7 = function () { - return data; - }; - - return data; - } - - function _templateObject6() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template:-root"]); - - _templateObject6 = function () { - return data; - }; - - return data; - } - - function _templateObject5() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template:-root"]); - - _templateObject5 = function () { - return data; - }; - - return data; - } - - function _templateObject4() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["component:-default"]); - - _templateObject4 = function () { - return data; - }; - - return data; - } - - function _templateObject3() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template:components/-default"]); - - _templateObject3 = function () { - return data; - }; - - return data; - } - - function _templateObject2() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template:components/-default"]); - - _templateObject2 = function () { - return data; - }; - - return data; - } - - function _templateObject() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template-compiler:main"]); - - _templateObject = function () { - return data; - }; - - return data; - } + _exports.OutletView = _exports.INVOKE = _exports.AbstractComponentManager = _exports._experimentalMacros = _exports.InteractiveRenderer = _exports.InertRenderer = _exports.Renderer = _exports.SafeString = _exports.Helper = _exports.Component = _exports.LinkComponent = _exports.TextArea = _exports.TextField = _exports.Checkbox = _exports.templateCacheCounters = _exports.RootTemplate = void 0; function isTemplateFactory(template) { return typeof template === 'function'; @@ -3974,21 +3873,20 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol cacheMiss: 0 }; _exports.templateCacheCounters = counters; - var TEMPLATE_COMPILER_MAIN = (0, _container.privatize)(_templateObject()); function template(json) { var glimmerFactory = (0, _opcodeCompiler.templateFactory)(json); var cache = new WeakMap(); + var meta = glimmerFactory.meta; var factory = owner => { var result = cache.get(owner); if (result === undefined) { counters.cacheMiss++; - var compiler = owner.lookup(TEMPLATE_COMPILER_MAIN); - result = glimmerFactory.create(compiler, { + result = glimmerFactory.create((0, _polyfills.assign)({ owner - }); + }, meta)); cache.set(owner, result); } else { counters.cacheHit++; @@ -3998,798 +3896,160 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol }; factory.__id = glimmerFactory.id; - factory.__meta = glimmerFactory.meta; + factory.__meta = meta; return factory; } var RootTemplate = template({ - "id": "hjhxUoru", - "block": "{\"symbols\":[],\"statements\":[[1,[28,\"component\",[[23,0,[]]],null],false]],\"hasEval\":false}", + "id": "9Fedtpxe", + "block": "{\"symbols\":[],\"statements\":[[1,0,0,0,[31,2,9,[27,[26,0,\"CallHead\"],[]],[[27,[24,0],[]]],null]]],\"hasEval\":false,\"upvars\":[\"component\"]}", "meta": { "moduleName": "packages/@ember/-internals/glimmer/lib/templates/root.hbs" } }); + _exports.RootTemplate = RootTemplate; + var DIRTY_TAG = (0, _utils.symbol)('DIRTY_TAG'); + var ARGS = (0, _utils.symbol)('ARGS'); + var IS_DISPATCHING_ATTRS = (0, _utils.symbol)('IS_DISPATCHING_ATTRS'); + var HAS_BLOCK = (0, _utils.symbol)('HAS_BLOCK'); + var BOUNDS = (0, _utils.symbol)('BOUNDS'); /** @module @ember/component */ - _exports.RootTemplate = RootTemplate; - var RECOMPUTE_TAG = (0, _utils.symbol)('RECOMPUTE_TAG'); - - function isHelperFactory(helper) { - return typeof helper === 'object' && helper !== null && helper.class && helper.class.isHelperFactory; - } - - function isSimpleHelper(helper) { - return helper.destroy === undefined; - } /** - Ember Helpers are functions that can compute values, and are used in templates. - For example, this code calls a helper named `format-currency`: + A component is an isolated piece of UI, represented by a template and an + optional class. When a component has a class, its template's `this` value + is an instance of the component class. + + ## Template-only Components + + The simplest way to create a component is to create a template file in + `app/templates/components`. For example, if you name a template + `app/templates/components/person-profile.hbs`: + + ```app/templates/components/person-profile.hbs +

{{@person.name}}

+ +

{{@person.signature}}

+ ``` + + You will be able to use `` to invoke this component elsewhere + in your application: ```app/templates/application.hbs - + ``` - ```app/components/cost.hbs -
{{format-currency @cents currency="$"}}
+ Note that component names are capitalized here in order to distinguish them + from regular HTML elements, but they are dasherized in the file system. + + While the angle bracket invocation form is generally preferred, it is also + possible to invoke the same component with the `{{person-profile}}` syntax: + + ```app/templates/application.hbs + {{person-profile person=this.currentUser}} ``` - Additionally a helper can be called as a nested helper. - In this example, we show the formatted currency value if the `showMoney` - named argument is truthy. + Note that with this syntax, you use dashes in the component name and + arguments are passed without the `@` sign. + + In both cases, Ember will render the content of the component template we + created above. The end result will be something like this: + + ```html +

Tomster

+ +

Out of office this week

+ ``` + + ## File System Nesting + + Components can be nested inside sub-folders for logical groupping. For + example, if we placed our template in + `app/templates/components/person/short-profile.hbs`, we can invoke it as + ``: + + ```app/templates/application.hbs + + ``` + + Or equivalently, `{{person/short-profile}}`: + + ```app/templates/application.hbs + {{person/short-profile person=this.currentUser}} + ``` + + ## Yielding Contents + + You can use `yield` inside a template to include the **contents** of any block + attached to the component. The block will be executed in its original context: ```handlebars - {{if @showMoney (format-currency @cents currency="$")}} + +

Admin mode

+ {{! Executed in the current context. }} +
``` - Helpers defined using a class must provide a `compute` function. For example: + or - ```app/helpers/format-currency.js - import Helper from '@ember/component/helper'; + ```handlebars + {{#person-profile person=this.currentUser}} +

Admin mode

+ {{! Executed in the current context. }} + {{/person-profile}} + ``` - export default class extends Helper { - compute([cents], { currency }) { - return `${currency}${cents * 0.01}`; - } - } + ```app/templates/components/person-profile.hbs +

{{@person.name}}

+ {{yield}} ``` - Each time the input to a helper changes, the `compute` function will be - called again. + ## Customizing Components With JavaScript - As instances, these helpers also have access to the container and will accept - injected dependencies. + If you want to customize the component in order to handle events, transform + arguments or maintain internal state, you implement a subclass of `Component`. - Additionally, class helpers can call `recompute` to force a new computation. + One example is to add computed properties to your component: - @class Helper - @public - @since 1.13.0 - */ - - - var Helper = _runtime.FrameworkObject.extend({ - init() { - this._super(...arguments); - - this[RECOMPUTE_TAG] = (0, _reference.createTag)(); - }, - - /** - On a class-based helper, it may be useful to force a recomputation of that - helpers value. This is akin to `rerender` on a component. - For example, this component will rerender when the `currentUser` on a - session service changes: - ```app/helpers/current-user-email.js - import Helper from '@ember/component/helper' - import { inject as service } from '@ember/service' - import { observer } from '@ember/object' - export default Helper.extend({ - session: service(), - onNewUser: observer('session.currentUser', function() { - this.recompute(); - }), - compute() { - return this.get('session.currentUser.email'); + ```app/components/person-profile.js + import Component from '@ember/component'; + + export default Component.extend({ + displayName: computed('person.title', 'person.firstName', 'person.lastName', function() { + let { title, firstName, lastName } = this; + + if (title) { + return `${title} ${lastName}`; + } else { + return `${firstName} ${lastName}`; } - }); - ``` - @method recompute - @public - @since 1.13.0 - */ - recompute() { - (0, _runloop.join)(() => (0, _reference.dirty)(this[RECOMPUTE_TAG])); - } - - }); - - _exports.Helper = Helper; - Helper.isHelperFactory = true; - (0, _runtime.setFrameworkClass)(Helper); - - class Wrapper { - constructor(compute) { - this.compute = compute; - this.isHelperFactory = true; - } - - create() { - // needs new instance or will leak containers - return { - compute: this.compute - }; - } - - } - /** - In many cases it is not necessary to use the full `Helper` class. - The `helper` method create pure-function helpers without instances. - For example: + }) + }); + ``` - ```app/helpers/format-currency.js - import { helper } from '@ember/component/helper'; + And then use it in the component's template: - export default helper(function([cents], {currency}) { - return `${currency}${cents * 0.01}`; - }); - ``` - - @static - @param {Function} helper The helper function - @method helper - @for @ember/component/helper - @public - @since 1.13.0 - */ - - - function helper(helperFn) { - return new Wrapper(helperFn); - } - - var debugRenderMessage; - - if (true - /* DEBUG */ - ) { - debugRenderMessage = renderingStack => { - return "While rendering:\n----------------\n" + renderingStack.replace(/^/gm, ' '); - }; - } - - var debugRenderMessage$1 = debugRenderMessage; - - function toBool(predicate) { - if ((0, _runtime.isArray)(predicate)) { - return predicate.length !== 0; - } else { - return Boolean(predicate); - } - } - - var UPDATE = (0, _utils.symbol)('UPDATE'); - var INVOKE = (0, _utils.symbol)('INVOKE'); - _exports.INVOKE = INVOKE; - var ACTION = (0, _utils.symbol)('ACTION'); - - class EmberPathReference { - get(key) { - return PropertyReference.create(this, key); - } - - } - - class CachedReference$1 extends EmberPathReference { - constructor() { - super(); - this.lastRevision = null; - this.lastValue = null; - } - - value() { - var { - tag, - lastRevision, - lastValue - } = this; - - if (lastRevision === null || !(0, _reference.validate)(tag, lastRevision)) { - lastValue = this.lastValue = this.compute(); - this.lastRevision = (0, _reference.value)(tag); - } - - return lastValue; - } - - } - - class RootReference extends _reference.ConstReference { - constructor(value$$1, env) { - super(value$$1); - this.env = env; - this.children = Object.create(null); - } - - static create(value$$1, env) { - return valueToRef(value$$1, true, env); - } - - get(propertyKey) { - var ref = this.children[propertyKey]; - - if (ref === undefined) { - ref = this.children[propertyKey] = new RootPropertyReference(this.inner, propertyKey, this.env); - } - - return ref; - } - - } - - class PropertyReference extends CachedReference$1 { - static create(parentReference, propertyKey) { - if ((0, _reference.isConst)(parentReference)) { - return valueKeyToRef(parentReference.value(), propertyKey); - } else { - return new NestedPropertyReference(parentReference, propertyKey); - } - } - - get(key) { - return new NestedPropertyReference(this, key); - } - - } - - class RootPropertyReference extends PropertyReference { - constructor(parentValue, propertyKey, env) { - super(); - this.parentValue = parentValue; - this.propertyKey = propertyKey; - - if (true - /* DEBUG */ - ) { - // Capture the stack when this reference is created, as that is the - // component/context that the component was created _in_. Later, it could - // be accessed from any number of components. - this.debugStackLog = env ? env.debugRenderTree.logCurrentRenderStack() : ''; - } - - this.propertyTag = (0, _reference.createUpdatableTag)(); - this.tag = this.propertyTag; - } - - compute() { - var { - parentValue, - propertyKey - } = this; - var ret; - var tag = (0, _metal.track)(() => ret = (0, _metal.get)(parentValue, propertyKey), true - /* DEBUG */ - && debugRenderMessage$1(this['debug']())); - (0, _metal.consume)(tag); - (0, _reference.update)(this.propertyTag, tag); - return ret; - } - - [UPDATE](value$$1) { - (0, _metal.set)(this.parentValue, this.propertyKey, value$$1); - } - - } - - if (true - /* DEBUG */ - ) { - RootPropertyReference.prototype['debug'] = function debug(subPath) { - var path = "this." + this['propertyKey']; - - if (subPath) { - path += "." + subPath; - } - - return "" + this['debugStackLog'] + path; - }; - } - - class NestedPropertyReference extends PropertyReference { - constructor(parentReference, propertyKey) { - super(); - this.parentReference = parentReference; - this.propertyKey = propertyKey; - var parentReferenceTag = parentReference.tag; - var propertyTag = this.propertyTag = (0, _reference.createUpdatableTag)(); - this.tag = (0, _reference.combine)([parentReferenceTag, propertyTag]); - } - - compute() { - var { - parentReference, - propertyTag, - propertyKey - } = this; - - var _parentValue = parentReference.value(); - - var parentValueType = typeof _parentValue; - - if (parentValueType === 'string' && propertyKey === 'length') { - return _parentValue.length; - } - - if (parentValueType === 'object' && _parentValue !== null || parentValueType === 'function') { - var parentValue = _parentValue; - var ret; - var tag = (0, _metal.track)(() => ret = (0, _metal.get)(parentValue, propertyKey), true - /* DEBUG */ - && debugRenderMessage$1(this['debug']())); - (0, _metal.consume)(tag); - (0, _reference.update)(propertyTag, tag); - return ret; - } else { - return undefined; - } - } - - [UPDATE](value$$1) { - (0, _metal.set)(this.parentReference.value() - /* let the other side handle the error */ - , this.propertyKey, value$$1); - } - - } - - if (true - /* DEBUG */ - ) { - NestedPropertyReference.prototype['debug'] = function debug(subPath) { - var parent = this['parentReference']; - var path = subPath ? this['propertyKey'] + "." + subPath : this['propertyKey']; - - if (typeof parent['debug'] === 'function') { - return parent['debug'](path); - } else { - return "unknownObject." + path; - } - }; - } - - class UpdatableReference extends EmberPathReference { - constructor(value$$1) { - super(); - this.tag = (0, _reference.createTag)(); - this._value = value$$1; - } - - value() { - return this._value; - } - - update(value$$1) { - var { - _value - } = this; - - if (value$$1 !== _value) { - (0, _reference.dirty)(this.tag); - this._value = value$$1; - } - } - - } - - _exports.UpdatableReference = UpdatableReference; - - class ConditionalReference$1 extends _runtime2.ConditionalReference { - static create(reference) { - if ((0, _reference.isConst)(reference)) { - var value$$1 = reference.value(); - - if (!(0, _utils.isProxy)(value$$1)) { - return _runtime2.PrimitiveReference.create(toBool(value$$1)); - } - } - - return new ConditionalReference$1(reference); - } - - constructor(reference) { - super(reference); - this.objectTag = (0, _reference.createUpdatableTag)(); - this.tag = (0, _reference.combine)([reference.tag, this.objectTag]); - } - - toBool(predicate) { - if ((0, _utils.isProxy)(predicate)) { - (0, _reference.update)(this.objectTag, (0, _metal.tagForProperty)(predicate, 'isTruthy')); - return Boolean((0, _metal.get)(predicate, 'isTruthy')); - } else { - (0, _reference.update)(this.objectTag, (0, _metal.tagFor)(predicate)); - return toBool(predicate); - } - } - - } - - class SimpleHelperReference extends CachedReference$1 { - constructor(helper$$1, args) { - super(); - this.helper = helper$$1; - this.args = args; - var computeTag = this.computeTag = (0, _reference.createUpdatableTag)(); - this.tag = (0, _reference.combine)([args.tag, computeTag]); - } - - static create(helper$$1, args) { - if ((0, _reference.isConst)(args)) { - var { - positional, - named - } = args; - var positionalValue = positional.value(); - var namedValue = named.value(); - - if (true - /* DEBUG */ - ) { - (0, _debug.debugFreeze)(positionalValue); - (0, _debug.debugFreeze)(namedValue); - } - - var result = helper$$1(positionalValue, namedValue); - return valueToRef(result); - } else { - return new SimpleHelperReference(helper$$1, args); - } - } - - compute() { - var { - helper: helper$$1, - computeTag, - args: { - positional, - named - } - } = this; - var positionalValue = positional.value(); - var namedValue = named.value(); - - if (true - /* DEBUG */ - ) { - (0, _debug.debugFreeze)(positionalValue); - (0, _debug.debugFreeze)(namedValue); - } - - var computedValue; - var combinedTrackingTag = (0, _metal.track)(() => { - if (true - /* DEBUG */ - ) { - (0, _metal.deprecateMutationsInAutotrackingTransaction)(() => { - computedValue = helper$$1(positionalValue, namedValue); - }); - } else { - computedValue = helper$$1(positionalValue, namedValue); - } - }, true - /* DEBUG */ - && debugRenderMessage$1("(result of a `" + (0, _utils.getDebugName)(helper$$1) + "` helper)")); - (0, _reference.update)(computeTag, combinedTrackingTag); - return computedValue; - } - - } - - class ClassBasedHelperReference extends CachedReference$1 { - constructor(instance, args) { - super(); - this.instance = instance; - this.args = args; - var computeTag = this.computeTag = (0, _reference.createUpdatableTag)(); - this.tag = (0, _reference.combine)([instance[RECOMPUTE_TAG], args.tag, computeTag]); - } - - static create(instance, args) { - return new ClassBasedHelperReference(instance, args); - } - - compute() { - var { - instance, - computeTag, - args: { - positional, - named - } - } = this; - var positionalValue = positional.value(); - var namedValue = named.value(); - - if (true - /* DEBUG */ - ) { - (0, _debug.debugFreeze)(positionalValue); - (0, _debug.debugFreeze)(namedValue); - } - - var computedValue; - var combinedTrackingTag = (0, _metal.track)(() => { - if (true - /* DEBUG */ - ) { - (0, _metal.deprecateMutationsInAutotrackingTransaction)(() => { - computedValue = instance.compute(positionalValue, namedValue); - }); - } else { - computedValue = instance.compute(positionalValue, namedValue); - } - }, true - /* DEBUG */ - && debugRenderMessage$1("(result of a `" + (0, _utils.getDebugName)(instance) + "` helper)")); - (0, _reference.update)(computeTag, combinedTrackingTag); - return computedValue; - } - - } - - class InternalHelperReference extends CachedReference$1 { - constructor(helper$$1, args) { - super(); - this.helper = helper$$1; - this.args = args; - this.tag = args.tag; - } - - compute() { - var { - helper: helper$$1, - args - } = this; - return helper$$1(args); - } - - } - - class UnboundReference extends _reference.ConstReference { - static create(value$$1) { - return valueToRef(value$$1, false); - } - - get(key) { - return valueToRef(this.inner[key], false); - } - - } - - class ReadonlyReference extends CachedReference$1 { - constructor(inner) { - super(); - this.inner = inner; - this.tag = inner.tag; - } - - get [INVOKE]() { - return this.inner[INVOKE]; - } - - compute() { - return this.inner.value(); - } - - get(key) { - return this.inner.get(key); - } - - } - - function referenceFromParts(root, parts) { - var reference = root; - - for (var i = 0; i < parts.length; i++) { - reference = reference.get(parts[i]); - } - - return reference; - } - - function isObject(value$$1) { - return value$$1 !== null && typeof value$$1 === 'object'; - } - - function isFunction(value$$1) { - return typeof value$$1 === 'function'; - } - - function ensurePrimitive(value$$1) { - if (true - /* DEBUG */ - ) { - var label; - - try { - label = " (was `" + String(value$$1) + "`)"; - } catch (e) { - label = null; - } - - (true && !(value$$1 === undefined || value$$1 === null || typeof value$$1 === 'boolean' || typeof value$$1 === 'number' || typeof value$$1 === 'string') && (0, _debug.assert)("This is a fall-through check for typing purposes only! `value` must already be a primitive at this point." + label + ")", value$$1 === undefined || value$$1 === null || typeof value$$1 === 'boolean' || typeof value$$1 === 'number' || typeof value$$1 === 'string')); - } - } - - function valueToRef(value$$1, bound = true, env) { - if (isObject(value$$1)) { - // root of interop with ember objects - return bound ? new RootReference(value$$1, env) : new UnboundReference(value$$1); - } else if (isFunction(value$$1)) { - // ember doesn't do observing with functions - return new UnboundReference(value$$1); - } else { - ensurePrimitive(value$$1); - return _runtime2.PrimitiveReference.create(value$$1); - } - } - - function valueKeyToRef(value$$1, key) { - if (isObject(value$$1)) { - // root of interop with ember objects - return new RootPropertyReference(value$$1, key); - } else if (isFunction(value$$1)) { - // ember doesn't do observing with functions - return new UnboundReference(value$$1[key]); - } else { - ensurePrimitive(value$$1); - return _runtime2.UNDEFINED_REFERENCE; - } - } - - var DIRTY_TAG = (0, _utils.symbol)('DIRTY_TAG'); - var ARGS = (0, _utils.symbol)('ARGS'); - var IS_DISPATCHING_ATTRS = (0, _utils.symbol)('IS_DISPATCHING_ATTRS'); - var HAS_BLOCK = (0, _utils.symbol)('HAS_BLOCK'); - var BOUNDS = (0, _utils.symbol)('BOUNDS'); - /** - @module @ember/component - */ - - /** - A component is an isolated piece of UI, represented by a template and an - optional class. When a component has a class, its template's `this` value - is an instance of the component class. - - ## Template-only Components - - The simplest way to create a component is to create a template file in - `app/templates/components`. For example, if you name a template - `app/templates/components/person-profile.hbs`: - - ```app/templates/components/person-profile.hbs -

{{@person.name}}

- -

{{@person.signature}}

- ``` - - You will be able to use `` to invoke this component elsewhere - in your application: - - ```app/templates/application.hbs - - ``` - - Note that component names are capitalized here in order to distinguish them - from regular HTML elements, but they are dasherized in the file system. - - While the angle bracket invocation form is generally preferred, it is also - possible to invoke the same component with the `{{person-profile}}` syntax: - - ```app/templates/application.hbs - {{person-profile person=this.currentUser}} - ``` - - Note that with this syntax, you use dashes in the component name and - arguments are passed without the `@` sign. - - In both cases, Ember will render the content of the component template we - created above. The end result will be something like this: - - ```html -

Tomster

- -

Out of office this week

- ``` - - ## File System Nesting - - Components can be nested inside sub-folders for logical groupping. For - example, if we placed our template in - `app/templates/components/person/short-profile.hbs`, we can invoke it as - ``: - - ```app/templates/application.hbs - - ``` - - Or equivalently, `{{person/short-profile}}`: - - ```app/templates/application.hbs - {{person/short-profile person=this.currentUser}} - ``` - - ## Yielding Contents - - You can use `yield` inside a template to include the **contents** of any block - attached to the component. The block will be executed in its original context: - - ```handlebars - -

Admin mode

- {{! Executed in the current context. }} -
- ``` - - or - - ```handlebars - {{#person-profile person=this.currentUser}} -

Admin mode

- {{! Executed in the current context. }} - {{/person-profile}} - ``` - - ```app/templates/components/person-profile.hbs -

{{@person.name}}

- {{yield}} - ``` - - ## Customizing Components With JavaScript - - If you want to customize the component in order to handle events, transform - arguments or maintain internal state, you implement a subclass of `Component`. - - One example is to add computed properties to your component: - - ```app/components/person-profile.js - import Component from '@ember/component'; - - export default Component.extend({ - displayName: computed('person.title', 'person.firstName', 'person.lastName', function() { - let { title, firstName, lastName } = this; - - if (title) { - return `${title} ${lastName}`; - } else { - return `${firstName} ${lastName}`; - } - }) - }); - ``` - - And then use it in the component's template: - - ```app/templates/components/person-profile.hbs -

{{this.displayName}}

- {{yield}} - ``` - - ## Customizing a Component's HTML Element in JavaScript - - ### HTML Tag - - The default HTML tag name used for a component's HTML representation is `div`. - This can be customized by setting the `tagName` property. - - Consider the following component class: - - ```app/components/emphasized-paragraph.js - import Component from '@ember/component'; - - export default Component.extend({ - tagName: 'em' + ```app/templates/components/person-profile.hbs +

{{this.displayName}}

+ {{yield}} + ``` + + ## Customizing a Component's HTML Element in JavaScript + + ### HTML Tag + + The default HTML tag name used for a component's HTML representation is `div`. + This can be customized by setting the `tagName` property. + + Consider the following component class: + + ```app/components/emphasized-paragraph.js + import Component from '@ember/component'; + + export default Component.extend({ + tagName: 'em' }); ``` @@ -5204,10 +4464,10 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol actions with angle bracket invocation, adding event handler methods to the component's class, or adding actions to the component's template. - ### Passing Actions With Angle Bracket Invoation + ### Passing Actions With Angle Bracket Invocation For one-off events specific to particular instance of a component, it is possible - to pass actions to the component's element using angle bracket invoation syntax. + to pass actions to the component's element using angle bracket invocation syntax. ```handlebars @@ -5225,7 +4485,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol ### Event Handler Methods Components can also respond to user-initiated events by implementing a method - that matches the event name. This approach is appropiate when the same event + that matches the event name. This approach is appropriate when the same event should be handled by all instances of the same component. An event object will be passed as the argument to the event handler method. @@ -5344,7 +4604,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this._super(...arguments); this[IS_DISPATCHING_ATTRS] = false; - this[DIRTY_TAG] = (0, _reference.createTag)(); + this[DIRTY_TAG] = (0, _validator.createTag)(); this[BOUNDS] = null; if (true @@ -5364,20 +4624,20 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol (true && !(!eventNames.length) && (0, _debug.assert)( // tslint:disable-next-line:max-line-length - "You can not define `" + eventNames + "` function(s) to handle DOM event in the `" + this + "` tagless component since it doesn't have any DOM element.", !eventNames.length)); + `You can not define \`${eventNames}\` function(s) to handle DOM event in the \`${this}\` tagless component since it doesn't have any DOM element.`, !eventNames.length)); } - (true && !(this.mouseEnter === undefined) && (0, _debug.deprecate)(this + ": Using `mouseEnter` event handler methods in components has been deprecated.", this.mouseEnter === undefined, { + (true && !(this.mouseEnter === undefined) && (0, _debug.deprecate)(`${this}: Using \`mouseEnter\` event handler methods in components has been deprecated.`, this.mouseEnter === undefined, { id: 'ember-views.event-dispatcher.mouseenter-leave-move', until: '4.0.0', url: 'https://emberjs.com/deprecations/v3.x#toc_component-mouseenter-leave-move' })); - (true && !(this.mouseLeave === undefined) && (0, _debug.deprecate)(this + ": Using `mouseLeave` event handler methods in components has been deprecated.", this.mouseLeave === undefined, { + (true && !(this.mouseLeave === undefined) && (0, _debug.deprecate)(`${this}: Using \`mouseLeave\` event handler methods in components has been deprecated.`, this.mouseLeave === undefined, { id: 'ember-views.event-dispatcher.mouseenter-leave-move', until: '4.0.0', url: 'https://emberjs.com/deprecations/v3.x#toc_component-mouseenter-leave-move' })); - (true && !(this.mouseMove === undefined) && (0, _debug.deprecate)(this + ": Using `mouseMove` event handler methods in components has been deprecated.", this.mouseMove === undefined, { + (true && !(this.mouseMove === undefined) && (0, _debug.deprecate)(`${this}: Using \`mouseMove\` event handler methods in components has been deprecated.`, this.mouseMove === undefined, { id: 'ember-views.event-dispatcher.mouseenter-leave-move', until: '4.0.0', url: 'https://emberjs.com/deprecations/v3.x#toc_component-mouseenter-leave-move' @@ -5385,7 +4645,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol }, rerender() { - (0, _reference.dirty)(this[DIRTY_TAG]); + (0, _validator.dirty)(this[DIRTY_TAG]); this._super(); }, @@ -5398,8 +4658,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var args = this[ARGS]; var reference = args !== undefined ? args[key] : undefined; - if (reference !== undefined && reference[UPDATE] !== undefined) { - reference[UPDATE]((0, _metal.get)(this, key)); + if (reference !== undefined && reference[_reference.UPDATE_REFERENCED_VALUE] !== undefined) { + reference[_reference.UPDATE_REFERENCED_VALUE]((0, _metal.get)(this, key)); } }, @@ -5438,9 +4698,11 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol // TODO revisit this var _element = (0, _views.getViewElement)(this); - (true && !(_element !== null) && (0, _debug.assert)("Cannot call `readDOMAttr` on " + this + " which does not have an element", _element !== null)); + (true && !(_element !== null) && (0, _debug.assert)(`Cannot call \`readDOMAttr\` on ${this} which does not have an element`, _element !== null)); var element = _element; - var isSVG = element.namespaceURI === _runtime2.SVG_NAMESPACE; + var isSVG = element.namespaceURI === "http://www.w3.org/2000/svg" + /* SVG */ + ; var { type, normalized @@ -5620,8 +4882,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol }); (0, _runtime.setFrameworkClass)(Component); var layout = template({ - "id": "hvtsz7RF", - "block": "{\"symbols\":[],\"statements\":[],\"hasEval\":false}", + "id": "SWbqsLhV", + "block": "{\"symbols\":[],\"statements\":[],\"hasEval\":false,\"upvars\":[]}", "meta": { "moduleName": "packages/@ember/-internals/glimmer/lib/templates/empty.hbs" } @@ -6076,8 +5338,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol TextArea.toString = () => '@ember/component/text-area'; var layout$1 = template({ - "id": "giTNx+op", - "block": "{\"symbols\":[\"&default\"],\"statements\":[[4,\"if\",[[25,1]],null,{\"statements\":[[14,1]],\"parameters\":[]},{\"statements\":[[1,[23,0,[\"linkTitle\"]],false]],\"parameters\":[]}]],\"hasEval\":false}", + "id": "oodT3nZ5", + "block": "{\"symbols\":[\"&default\"],\"statements\":[[5,[27,[26,0,\"BlockHead\"],[]],[[28,[24,1]]],null,[[\"default\",\"else\"],[{\"statements\":[[16,1,null]],\"parameters\":[]},{\"statements\":[[1,0,0,0,[27,[24,0],[\"linkTitle\"]]]],\"parameters\":[]}]]]],\"hasEval\":false,\"upvars\":[\"if\"]}", "meta": { "moduleName": "packages/@ember/-internals/glimmer/lib/templates/link-to.hbs" } @@ -6578,7 +5840,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol get(_key) { // always returns false for `get` because (due to the `set` just below) // the cached return value from the set will prevent this getter from _ever_ - // being called after a set has occured + // being called after a set has occurred return false; }, @@ -6652,8 +5914,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol _routing: routing } = this; - for (var i = 0; i < currentWhen.length; i++) { - if (routing.isActiveForRoute(models, query, currentWhen[i], routerState, isCurrentWhenSpecified)) { + for (var _i = 0; _i < currentWhen.length; _i++) { + if (routing.isActiveForRoute(models, query, currentWhen[_i], routerState, isCurrentWhenSpecified)) { return true; } } @@ -6783,7 +6045,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return routing.generateURL(route, models, query); } catch (e) { // tslint:disable-next-line:max-line-length - (true && !(false) && (0, _debug.assert)("You attempted to generate a link for the \"" + this.route + "\" route, but did not " + "pass the models required for generating its dynamic segments. " + e.message)); + (true && !(false) && (0, _debug.assert)(`You attempted to generate a link for the "${this.route}" route, but did not ` + `pass the models required for generating its dynamic segments. ` + e.message)); } } else { return routing.generateURL(route, models, query); @@ -6804,8 +6066,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol _models: models } = this; - for (var i = 0; i < models.length; i++) { - var model = models[i]; + for (var _i2 = 0; _i2 < models.length; _i2++) { + var model = models[_i2]; if (model === null || model === undefined) { return false; @@ -6893,671 +6155,162 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol positionalParams: 'params' }); /** - @module ember + @module @ember/component */ + var RECOMPUTE_TAG = (0, _utils.symbol)('RECOMPUTE_TAG'); + + function isHelperFactory(helper) { + return typeof helper === 'object' && helper !== null && helper.class && helper.class.isHelperFactory; + } + + function isSimpleHelper(helper) { + return helper.destroy === undefined; + } /** - The `{{#each}}` helper loops over elements in a collection. It is an extension - of the base Handlebars `{{#each}}` helper. - - The default behavior of `{{#each}}` is to yield its inner block once for every - item in an array passing the item as the first block parameter. - - Assuming the `@developers` argument contains this array: - - ```javascript - [{ name: 'Yehuda' },{ name: 'Tom' }, { name: 'Paul' }]; - ``` - - ```handlebars -
    - {{#each @developers as |person|}} -
  • Hello, {{person.name}}!
  • - {{/each}} -
- ``` - - The same rules apply to arrays of primitives. - - ```javascript - ['Yehuda', 'Tom', 'Paul'] - ``` - - ```handlebars -
    - {{#each @developerNames as |name|}} -
  • Hello, {{name}}!
  • - {{/each}} -
- ``` - - During iteration, the index of each item in the array is provided as a second block - parameter. - - ```handlebars -
    - {{#each @developers as |person index|}} -
  • Hello, {{person.name}}! You're number {{index}} in line
  • - {{/each}} -
- ``` - - ### Specifying Keys - - In order to improve rendering speed, Ember will try to reuse the DOM elements - where possible. Specifically, if the same item is present in the array both - before and after the change, its DOM output will be reused. - - The `key` option is used to tell Ember how to determine if the items in the - array being iterated over with `{{#each}}` has changed between renders. By - default the item's object identity is used. - - This is usually sufficient, so in most cases, the `key` option is simply not - needed. However, in some rare cases, the objects' identities may change even - though they represent the same underlying data. - - For example: + Ember Helpers are functions that can compute values, and are used in templates. + For example, this code calls a helper named `format-currency`: - ```javascript - people.map(person => { - return { ...person, type: 'developer' }; - }); + ```app/templates/application.hbs + ``` - In this case, each time the `people` array is `map`-ed over, it will produce - an new array with completely different objects between renders. In these cases, - you can help Ember determine how these objects related to each other with the - `key` option: - - ```handlebars -
    - {{#each @developers key="name" as |person|}} -
  • Hello, {{person.name}}!
  • - {{/each}} -
+ ```app/components/cost.hbs +
{{format-currency @cents currency="$"}}
``` - By doing so, Ember will use the value of the property specified (`person.name` - in the example) to find a "match" from the previous render. That is, if Ember - has previously seen an object from the `@developers` array with a matching - name, its DOM elements will be re-used. - - ### {{else}} condition - - `{{#each}}` can have a matching `{{else}}`. The contents of this block will render - if the collection is empty. + Additionally a helper can be called as a nested helper. + In this example, we show the formatted currency value if the `showMoney` + named argument is truthy. ```handlebars -
    - {{#each @developers as |person|}} -
  • {{person.name}} is available!
  • - {{else}} -
  • Sorry, nobody is available for this task.
  • - {{/each}} -
+ {{if @showMoney (format-currency @cents currency="$")}} ``` - @method each - @for Ember.Templates.helpers - @public - */ - - /** - The `{{each-in}}` helper loops over properties on an object. - - For example, given this component definition: + Helpers defined using a class must provide a `compute` function. For example: - ```app/components/developer-details.js - import Component from '@glimmer/component'; - import { tracked } from '@glimmer/tracking'; + ```app/helpers/format-currency.js + import Helper from '@ember/component/helper'; - export default class extends Component { - @tracked developer = { - "name": "Shelly Sails", - "age": 42 - }; + export default class extends Helper { + compute([cents], { currency }) { + return `${currency}${cents * 0.01}`; + } } ``` - This template would display all properties on the `developer` - object in a list: + Each time the input to a helper changes, the `compute` function will be + called again. - ```app/components/developer-details.hbs -
    - {{#each-in this.developer as |key value|}} -
  • {{key}}: {{value}}
  • - {{/each-in}} -
- ``` + As instances, these helpers also have access to the container and will accept + injected dependencies. - Outputting their name and age. + Additionally, class helpers can call `recompute` to force a new computation. - @method each-in - @for Ember.Templates.helpers + @class Helper @public - @since 2.1.0 + @since 1.13.0 */ - var EACH_IN_REFERENCE = (0, _utils.symbol)('EACH_IN'); - class EachInReference { - constructor(inner) { - this.inner = inner; - this.tag = inner.tag; - this[EACH_IN_REFERENCE] = true; + var Helper = _runtime.FrameworkObject.extend({ + init() { + this._super(...arguments); + + this[RECOMPUTE_TAG] = (0, _validator.createTag)(); + }, + + /** + On a class-based helper, it may be useful to force a recomputation of that + helpers value. This is akin to `rerender` on a component. + For example, this component will rerender when the `currentUser` on a + session service changes: + ```app/helpers/current-user-email.js + import Helper from '@ember/component/helper' + import { inject as service } from '@ember/service' + import { observer } from '@ember/object' + export default Helper.extend({ + session: service(), + onNewUser: observer('session.currentUser', function() { + this.recompute(); + }), + compute() { + return this.get('session.currentUser.email'); + } + }); + ``` + @method recompute + @public + @since 1.13.0 + */ + recompute() { + (0, _runloop.join)(() => (0, _validator.dirty)(this[RECOMPUTE_TAG])); } - value() { - return this.inner.value(); + }); + + _exports.Helper = Helper; + Helper.isHelperFactory = true; + (0, _runtime.setFrameworkClass)(Helper); + + class Wrapper { + constructor(compute) { + this.compute = compute; + this.isHelperFactory = true; } - get(key) { - return this.inner.get(key); + create() { + // needs new instance or will leak containers + return { + compute: this.compute + }; } } + /** + In many cases it is not necessary to use the full `Helper` class. + The `helper` method create pure-function helpers without instances. + For example: + + ```app/helpers/format-currency.js + import { helper } from '@ember/component/helper'; + + export default helper(function([cents], {currency}) { + return `${currency}${cents * 0.01}`; + }); + ``` + + @static + @param {Function} helper The helper function + @method helper + @for @ember/component/helper + @public + @since 1.13.0 + */ - function isEachIn(ref) { - return ref !== null && typeof ref === 'object' && ref[EACH_IN_REFERENCE]; - } - function eachIn(_vm, args) { - return new EachInReference(args.positional.at(0)); + function helper(helperFn) { + return new Wrapper(helperFn); } + /** + @module @ember/template + */ - var ITERATOR_KEY_GUID = 'be277757-bbbe-4620-9fcb-213ef433cca2'; - - function iterableFor(ref, keyPath) { - if (isEachIn(ref)) { - return new EachInIterable(ref, keyPath || '@key'); - } else { - return new EachIterable(ref, keyPath || '@identity'); - } - } - class BoundedIterator { - constructor(length, keyFor) { - this.length = length; - this.keyFor = keyFor; - this.position = 0; + class SafeString { + constructor(string) { + this.string = string; } - isEmpty() { - return false; + toString() { + return `${this.string}`; } - memoFor(position) { - return position; + toHTML() { + return this.toString(); } - next() { - var { - length, - keyFor, - position - } = this; - - if (position >= length) { - return null; - } - - var value$$1 = this.valueFor(position); - var memo = this.memoFor(position); - var key = keyFor(value$$1, memo, position); - this.position++; - return { - key, - value: value$$1, - memo - }; - } - - } - - class ArrayIterator extends BoundedIterator { - constructor(array, length, keyFor) { - super(length, keyFor); - this.array = array; - } - - static from(array, keyFor) { - var { - length - } = array; - - if (length === 0) { - return EMPTY_ITERATOR; - } else { - return new this(array, length, keyFor); - } - } - - static fromForEachable(object, keyFor) { - var array = []; - object.forEach(item => array.push(item)); - return this.from(array, keyFor); - } - - valueFor(position) { - return this.array[position]; - } - - } - - class EmberArrayIterator extends BoundedIterator { - constructor(array, length, keyFor) { - super(length, keyFor); - this.array = array; - } - - static from(array, keyFor) { - var { - length - } = array; - - if (length === 0) { - return EMPTY_ITERATOR; - } else { - return new this(array, length, keyFor); - } - } - - valueFor(position) { - return (0, _metal.objectAt)(this.array, position); - } - - } - - class ObjectIterator extends BoundedIterator { - constructor(keys, values, length, keyFor) { - super(length, keyFor); - this.keys = keys; - this.values = values; - } - - static fromIndexable(obj, keyFor) { - var keys = Object.keys(obj); - var { - length - } = keys; - - if (length === 0) { - return EMPTY_ITERATOR; - } else { - var values = []; - - for (var i = 0; i < length; i++) { - var value$$1 = void 0; - var key = keys[i]; - value$$1 = obj[key]; // Add the tag of the returned value if it is an array, since arrays - // should always cause updates if they are consumed and then changed - - if ((0, _metal.isTracking)()) { - (0, _metal.consume)((0, _metal.tagForProperty)(obj, key)); - - if (Array.isArray(value$$1) || (0, _utils.isEmberArray)(value$$1)) { - (0, _metal.consume)((0, _metal.tagForProperty)(value$$1, '[]')); - } - } - - values.push(value$$1); - } - - return new this(keys, values, length, keyFor); - } - } - - static fromForEachable(obj, keyFor) { - var keys = []; - var values = []; - var length = 0; - var isMapLike = false; - obj.forEach((value$$1, key) => { - isMapLike = isMapLike || arguments.length >= 2; - - if (isMapLike) { - keys.push(key); - } - - values.push(value$$1); - length++; - }); - - if (length === 0) { - return EMPTY_ITERATOR; - } else if (isMapLike) { - return new this(keys, values, length, keyFor); - } else { - return new ArrayIterator(values, length, keyFor); - } - } - - valueFor(position) { - return this.values[position]; - } - - memoFor(position) { - return this.keys[position]; - } - - } - - class NativeIterator { - constructor(iterable, result, keyFor) { - this.iterable = iterable; - this.result = result; - this.keyFor = keyFor; - this.position = 0; - } - - static from(iterable, keyFor) { - var iterator = iterable[Symbol.iterator](); - var result = iterator.next(); - var { - value: value$$1, - done - } = result; - - if (done) { - return EMPTY_ITERATOR; - } else if (Array.isArray(value$$1) && value$$1.length === 2) { - return new this(iterator, result, keyFor); - } else { - return new ArrayLikeNativeIterator(iterator, result, keyFor); - } - } - - isEmpty() { - return false; - } - - next() { - var { - iterable, - result, - position, - keyFor - } = this; - - if (result.done) { - return null; - } - - var value$$1 = this.valueFor(result, position); - var memo = this.memoFor(result, position); - var key = keyFor(value$$1, memo, position); - this.position++; - this.result = iterable.next(); - return { - key, - value: value$$1, - memo - }; - } - - } - - class ArrayLikeNativeIterator extends NativeIterator { - valueFor(result) { - return result.value; - } - - memoFor(_result, position) { - return position; - } - - } - - class MapLikeNativeIterator extends NativeIterator { - valueFor(result) { - return result.value[1]; - } - - memoFor(result) { - return result.value[0]; - } - - } - - var EMPTY_ITERATOR = { - isEmpty() { - return true; - }, - - next() { - (true && !(false) && (0, _debug.assert)('Cannot call next() on an empty iterator')); - return null; - } - - }; - - class EachInIterable { - constructor(ref, keyPath) { - this.ref = ref; - this.keyPath = keyPath; - this.valueTag = (0, _reference.createUpdatableTag)(); - this.tag = (0, _reference.combine)([ref.tag, this.valueTag]); - } - - iterate() { - var { - ref, - valueTag - } = this; - var iterable = ref.value(); - var tag = (0, _metal.tagFor)(iterable); - - if ((0, _utils.isProxy)(iterable)) { - // this is because the each-in doesn't actually get(proxy, 'key') but bypasses it - // and the proxy's tag is lazy updated on access - iterable = (0, _runtime._contentFor)(iterable); - } - - (0, _reference.update)(valueTag, tag); - - if (!isIndexable(iterable)) { - return EMPTY_ITERATOR; - } - - if (Array.isArray(iterable) || (0, _utils.isEmberArray)(iterable)) { - return ObjectIterator.fromIndexable(iterable, this.keyFor(true)); - } else if (_utils.HAS_NATIVE_SYMBOL && isNativeIterable(iterable)) { - return MapLikeNativeIterator.from(iterable, this.keyFor()); - } else if (hasForEach(iterable)) { - return ObjectIterator.fromForEachable(iterable, this.keyFor()); - } else { - return ObjectIterator.fromIndexable(iterable, this.keyFor(true)); - } - } - - valueReferenceFor(item) { - return new UpdatableReference(item.value); - } - - updateValueReference(ref, item) { - ref.update(item.value); - } - - memoReferenceFor(item) { - return new UpdatableReference(item.memo); - } - - updateMemoReference(ref, item) { - ref.update(item.memo); - } - - keyFor(hasUniqueKeys = false) { - var { - keyPath - } = this; - - switch (keyPath) { - case '@key': - return hasUniqueKeys ? ObjectKey : Unique(MapKey); - - case '@index': - return Index; - - case '@identity': - return Unique(Identity); - - default: - (true && !(keyPath[0] !== '@') && (0, _debug.assert)("Invalid key: " + keyPath, keyPath[0] !== '@')); - return Unique(KeyPath(keyPath)); - } - } - - } - - class EachIterable { - constructor(ref, keyPath) { - this.ref = ref; - this.keyPath = keyPath; - this.valueTag = (0, _reference.createUpdatableTag)(); - this.tag = (0, _reference.combine)([ref.tag, this.valueTag]); - } - - iterate() { - var { - ref, - valueTag - } = this; - var iterable = ref.value(); - (0, _reference.update)(valueTag, (0, _metal.tagForProperty)(iterable, '[]')); - - if (iterable === null || typeof iterable !== 'object') { - return EMPTY_ITERATOR; - } - - var keyFor = this.keyFor(); - - if (Array.isArray(iterable)) { - return ArrayIterator.from(iterable, keyFor); - } else if ((0, _utils.isEmberArray)(iterable)) { - return EmberArrayIterator.from(iterable, keyFor); - } else if (_utils.HAS_NATIVE_SYMBOL && isNativeIterable(iterable)) { - return ArrayLikeNativeIterator.from(iterable, keyFor); - } else if (hasForEach(iterable)) { - return ArrayIterator.fromForEachable(iterable, keyFor); - } else { - return EMPTY_ITERATOR; - } - } - - valueReferenceFor(item) { - return new UpdatableReference(item.value); - } - - updateValueReference(ref, item) { - ref.update(item.value); - } - - memoReferenceFor(item) { - return new UpdatableReference(item.memo); - } - - updateMemoReference(ref, item) { - ref.update(item.memo); - } - - keyFor() { - var { - keyPath - } = this; - - switch (keyPath) { - case '@index': - return Index; - - case '@identity': - return Unique(Identity); - - default: - (true && !(keyPath[0] !== '@') && (0, _debug.assert)("Invalid key: " + keyPath, keyPath[0] !== '@')); - return Unique(KeyPath(keyPath)); - } - } - - } - - function hasForEach(value$$1) { - return typeof value$$1['forEach'] === 'function'; - } - - function isNativeIterable(value$$1) { - return typeof value$$1[Symbol.iterator] === 'function'; - } - - function isIndexable(value$$1) { - return value$$1 !== null && (typeof value$$1 === 'object' || typeof value$$1 === 'function'); - } // Position in an array is guarenteed to be unique - - - function Index(_value, _memo, position) { - return String(position); - } // Object.keys(...) is guarenteed to be strings and unique - - - function ObjectKey(_value, memo) { - return memo; - } // Map keys can be any objects - - - function MapKey(_value, memo) { - return Identity(memo); - } - - function Identity(value$$1) { - switch (typeof value$$1) { - case 'string': - return value$$1; - - case 'number': - return String(value$$1); - - default: - return (0, _utils.guidFor)(value$$1); - } - } - - function KeyPath(keyPath) { - return value$$1 => String((0, _metal.get)(value$$1, keyPath)); - } - - function Unique(func) { - var seen = {}; - return (value$$1, memo, position) => { - var key = func(value$$1, memo, position); - var count = seen[key]; - - if (count === undefined) { - seen[key] = 0; - return key; - } else { - seen[key] = ++count; - return "" + key + ITERATOR_KEY_GUID + count; - } - }; - } - /** - @module @ember/template - */ - - - class SafeString { - constructor(string) { - this.string = string; - } - - toString() { - return "" + this.string; - } - - toHTML() { - return this.toString(); - } - - } + } _exports.SafeString = SafeString; var escape = { @@ -7651,446 +6404,112 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol function isHTMLSafe(str) { return str !== null && typeof str === 'object' && typeof str.toHTML === 'function'; } - /* globals module, URL */ - - - var nodeURL; - var parsingNode; - - function installProtocolForURL(environment) { - var protocol; - - if (_browserEnvironment.hasDOM) { - protocol = browserProtocolForURL.call(environment, 'foobar:baz'); - } // Test to see if our DOM implementation parses - // and normalizes URLs. - - - if (protocol === 'foobar:') { - // Swap in the method that doesn't do this test now that - // we know it works. - environment.protocolForURL = browserProtocolForURL; - } else if (typeof URL === 'object') { - // URL globally provided, likely from FastBoot's sandbox - nodeURL = URL; - environment.protocolForURL = nodeProtocolForURL; - } else if (typeof module !== undefined && typeof module.require === 'function') { - // Otherwise, we need to fall back to our own URL parsing. - // Global `require` is shadowed by Ember's loader so we have to use the fully - // qualified `module.require`. - // tslint:disable-next-line:no-require-imports - nodeURL = module.require('url'); - environment.protocolForURL = nodeProtocolForURL; - } else { - throw new Error('Could not find valid URL parsing mechanism for URL Sanitization'); - } - } - - function browserProtocolForURL(url) { - if (!parsingNode) { - parsingNode = document.createElement('a'); - } - - parsingNode.href = url; - return parsingNode.protocol; - } - - function nodeProtocolForURL(url) { - var protocol = null; - - if (typeof url === 'string') { - protocol = nodeURL.parse(url).protocol; - } - return protocol === null ? ':' : protocol; + function isStaticComponentManager(_manager, capabilities) { + return !capabilities.dynamicLayout; } - var GUID = 0; - - class Ref { - constructor(value$$1) { - this.id = GUID++; - this.value = value$$1; + class CompileTimeResolver { + constructor(resolver) { + this.resolver = resolver; } - get() { - return this.value; + lookupHelper(name, referrer) { + return this.resolver.lookupHelper(name, referrer); } - release() { - (true && !(this.value !== null) && (0, _debug.assert)('BUG: double release?', this.value !== null)); - this.value = null; + lookupModifier(name, referrer) { + return this.resolver.lookupModifier(name, referrer); } - toString() { - var label = "Ref " + this.id; + lookupComponent(name, referrer) { + var definitionHandle = this.resolver.lookupComponentHandle(name, referrer); - if (this.value === null) { - return label + " (released)"; - } else { - try { - return label + ": " + this.value; - } catch (_a) { - return label; - } + if (definitionHandle === null) { + return null; } - } - - } - - var _repeat = String.prototype.repeat || function (count) { - return new Array(count + 1).join(this); - }; - - function repeatString(str, count) { - return _repeat.call(str, count); - } - class StackWithToArray extends _util.Stack { - toArray() { - // polyfilling feature of modern Glimmer VM - return this['stack']; - } + var { + manager, + state + } = this.resolver.resolve(definitionHandle); + var capabilities = manager.getCapabilities(state); - } + if (!isStaticComponentManager(manager, capabilities)) { + return { + handle: definitionHandle, + capabilities, + compilable: null + }; + } - class DebugRenderTree { - constructor() { - this.stack = new StackWithToArray(); - this.refs = new WeakMap(); - this.roots = new Set(); - this.nodes = new WeakMap(); + return { + handle: definitionHandle, + capabilities, + compilable: manager.getJitStaticLayout(state, this.resolver) + }; } - begin() { - this.reset(); + lookupPartial(name, referrer) { + return this.resolver.lookupPartial(name, referrer); } - create(state, node) { - this.nodes.set(state, (0, _polyfills.assign)({}, node, { - bounds: null, - refs: new Set() - })); - this.appendChild(state); - this.enter(state); + resolve(handle) { + return this.resolver.resolve(handle); } - update(state) { - this.enter(state); - } // for dynamic layouts - + } // implements the ComponentManager interface as defined in glimmer: + // tslint:disable-next-line:max-line-length + // https://github.com/glimmerjs/glimmer-vm/blob/v0.24.0-beta.4/packages/%40glimmer/runtime/lib/component/interfaces.ts#L21 - setTemplate(state, template) { - this.nodeFor(state).template = template; - } - didRender(state, bounds) { - (true && !(this.stack.current === state) && (0, _debug.assert)("BUG: expecting " + this.stack.current + ", got " + state, this.stack.current === state)); - this.nodeFor(state).bounds = bounds; - this.exit(); + class AbstractManager { + prepareArgs(_state, _args) { + return null; } - willDestroy(state) { - (0, _util.expect)(this.refs.get(state), 'BUG: missing ref').release(); + didCreateElement(_component, _element, _operations) {// noop } - commit() { - this.reset(); + didRenderLayout(_component, _bounds) {// noop } - capture() { - return this.captureRefs(this.roots); + didCreate(_bucket) {// noop } - logCurrentRenderStack() { - var nodes = this.stack.toArray().map(bucket => this.nodeFor(bucket)); - var message = nodes.filter(node => node.type !== 'outlet' && node.name !== '-top-level').map((node, index) => "" + repeatString(' ', index * 2) + node.name); - message.push("" + repeatString(' ', message.length * 2)); - return message.join('\n'); + update(_bucket, _dynamicScope) {// noop } - reset() { - if (this.stack.size !== 0) { - // We probably encountered an error during the rendering loop. This will - // likely trigger undefined behavior and memory leaks as the error left - // things in an inconsistent state. It is recommended that the user - // refresh the page. - // TODO: We could warn here? But this happens all the time in our tests? - while (!this.stack.isEmpty()) { - this.stack.pop(); - } - } + didUpdateLayout(_bucket, _bounds) {// noop } - enter(state) { - this.stack.push(state); + didUpdate(_bucket) {// noop } - exit() { - (true && !(this.stack.size !== 0) && (0, _debug.assert)('BUG: unbalanced pop', this.stack.size !== 0)); - this.stack.pop(); - } + } - nodeFor(state) { - return (0, _util.expect)(this.nodes.get(state), 'BUG: missing node'); - } + _exports.AbstractComponentManager = AbstractManager; - appendChild(state) { - (true && !(!this.refs.has(state)) && (0, _debug.assert)('BUG: child already appended', !this.refs.has(state))); - var parent = this.stack.current; - var ref = new Ref(state); - this.refs.set(state, ref); + function instrumentationPayload(def) { + return { + object: `${def.name}:${def.outlet}` + }; + } - if (parent) { - this.nodeFor(parent).refs.add(ref); - } else { - this.roots.add(ref); - } - } - - captureRefs(refs) { - var captured = []; - refs.forEach(ref => { - var state = ref.get(); - - if (state) { - captured.push(this.captureNode("render-node:" + ref.id, state)); - } else { - refs.delete(ref); - } - }); - return captured; - } - - captureNode(id, state) { - var node = this.nodeFor(state); - var { - type, - name, - args, - instance, - refs - } = node; - var template = this.captureTemplate(node); - var bounds = this.captureBounds(node); - var children = this.captureRefs(refs); - return { - id, - type, - name, - args: args.value(), - instance, - template, - bounds, - children - }; - } - - captureTemplate({ - template - }) { - return template && template.referrer.moduleName || null; - } - - captureBounds(node) { - var bounds = (0, _util.expect)(node.bounds, 'BUG: missing bounds'); - var parentElement = bounds.parentElement(); - var firstNode = bounds.firstNode(); - var lastNode = bounds.lastNode(); - return { - parentElement, - firstNode, - lastNode - }; - } - - } - - class Environment$1 extends _runtime2.Environment { - constructor(injections) { - super(injections); - this.inTransaction = false; - var owner = injections[_owner.OWNER]; - this.owner = owner; - this.isInteractive = owner.lookup('-environment:main').isInteractive; // can be removed once https://github.com/tildeio/glimmer/pull/305 lands - - this.destroyedComponents = []; - installProtocolForURL(this); - - if (_environment2.ENV._DEBUG_RENDER_TREE) { - this._debugRenderTree = new DebugRenderTree(); - } - } - - static create(options) { - return new this(options); - } - - get debugRenderTree() { - if (_environment2.ENV._DEBUG_RENDER_TREE) { - return this._debugRenderTree; - } else { - throw new Error("Can't access debug render tree outside of the inspector (_DEBUG_RENDER_TREE flag is disabled)"); - } - } // this gets clobbered by installPlatformSpecificProtocolForURL - // it really should just delegate to a platform specific injection - - - protocolForURL(s) { - return s; - } - - toConditionalReference(reference) { - return ConditionalReference$1.create(reference); - } - - iterableFor(ref, key) { - return iterableFor(ref, key); - } - - scheduleInstallModifier(modifier, manager) { - if (this.isInteractive) { - super.scheduleInstallModifier(modifier, manager); - } - } - - scheduleUpdateModifier(modifier, manager) { - if (this.isInteractive) { - super.scheduleUpdateModifier(modifier, manager); - } - } - - didDestroy(destroyable) { - destroyable.destroy(); - } - - begin() { - if (_environment2.ENV._DEBUG_RENDER_TREE) { - this.debugRenderTree.begin(); - } - - this.inTransaction = true; - super.begin(); - } - - commit() { - var destroyedComponents = this.destroyedComponents; - this.destroyedComponents = []; // components queued for destruction must be destroyed before firing - // `didCreate` to prevent errors when removing and adding a component - // with the same name (would throw an error when added to view registry) - - for (var i = 0; i < destroyedComponents.length; i++) { - destroyedComponents[i].destroy(); - } - - try { - super.commit(); - } finally { - this.inTransaction = false; - } - - if (_environment2.ENV._DEBUG_RENDER_TREE) { - this.debugRenderTree.commit(); - } - } - - } - - _exports.Environment = Environment$1; - - if (true - /* DEBUG */ - ) { - class StyleAttributeManager extends _runtime2.SimpleDynamicAttribute { - set(dom, value$$1, env) { - (true && (0, _debug.warn)((0, _views.constructStyleDeprecationMessage)(value$$1), (() => { - if (value$$1 === null || value$$1 === undefined || isHTMLSafe(value$$1)) { - return true; - } - - return false; - })(), { - id: 'ember-htmlbars.style-xss-warning' - })); - super.set(dom, value$$1, env); - } - - update(value$$1, env) { - (true && (0, _debug.warn)((0, _views.constructStyleDeprecationMessage)(value$$1), (() => { - if (value$$1 === null || value$$1 === undefined || isHTMLSafe(value$$1)) { - return true; - } - - return false; - })(), { - id: 'ember-htmlbars.style-xss-warning' - })); - super.update(value$$1, env); - } - - } - - Environment$1.prototype.attributeFor = function (element, attribute, isTrusting, namespace) { - if (attribute === 'style' && !isTrusting) { - return new StyleAttributeManager({ - element, - name: attribute, - namespace - }); - } - - return _runtime2.Environment.prototype.attributeFor.call(this, element, attribute, isTrusting, namespace); - }; - } // implements the ComponentManager interface as defined in glimmer: - // tslint:disable-next-line:max-line-length - // https://github.com/glimmerjs/glimmer-vm/blob/v0.24.0-beta.4/packages/%40glimmer/runtime/lib/component/interfaces.ts#L21 - - - class AbstractManager { - prepareArgs(_state, _args) { - return null; - } - - didCreateElement(_component, _element, _operations) {// noop - } - - didRenderLayout(_component, _bounds) {// noop - } - - didCreate(_bucket) {// noop - } - - update(_bucket, _dynamicScope) {// noop - } - - didUpdateLayout(_bucket, _bounds) {// noop - } - - didUpdate(_bucket) {// noop - } - - } - - _exports.AbstractComponentManager = AbstractManager; - - function instrumentationPayload(def) { - return { - object: def.name + ":" + def.outlet - }; - } - - var CAPABILITIES = { - dynamicLayout: false, - dynamicTag: false, - prepareArgs: false, - createArgs: _environment2.ENV._DEBUG_RENDER_TREE, - attributeHook: false, - elementHook: false, - createCaller: false, - dynamicScope: true, - updateHook: _environment2.ENV._DEBUG_RENDER_TREE, - createInstance: true - }; + var CAPABILITIES = { + dynamicLayout: false, + dynamicTag: false, + prepareArgs: false, + createArgs: _environment2.ENV._DEBUG_RENDER_TREE, + attributeHook: false, + elementHook: false, + createCaller: false, + dynamicScope: true, + updateHook: _environment2.ENV._DEBUG_RENDER_TREE, + createInstance: true, + wrapped: false, + willDestroy: false + }; class OutletComponentManager extends AbstractManager { create(environment, definition, args, dynamicScope) { @@ -8098,7 +6517,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var currentStateRef = definition.ref; dynamicScope.outletState = currentStateRef; var state = { - self: RootReference.create(definition.controller), + self: new _reference.ComponentRootReference(definition.controller, environment), environment, finalize: (0, _instrumentation._instrumentStart)('render.outlet', instrumentationPayload, definition) }; @@ -8107,7 +6526,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol state.outlet = { name: definition.outlet }; - environment.debugRenderTree.create(state.outlet, { + environment.extra.debugRenderTree.create(state.outlet, { type: 'outlet', name: state.outlet.name, args: _runtime2.EMPTY_ARGS, @@ -8126,7 +6545,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol state.engine = { mountPoint }; - environment.debugRenderTree.create(state.engine, { + environment.extra.debugRenderTree.create(state.engine, { type: 'engine', name: mountPoint, args: _runtime2.EMPTY_ARGS, @@ -8135,7 +6554,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol }); } - environment.debugRenderTree.create(state, { + environment.extra.debugRenderTree.create(state, { type: 'route-template', name: definition.name, args: args.capture(), @@ -8147,15 +6566,11 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return state; } - getLayout({ + getJitStaticLayout({ template }, _resolver) { // The router has already resolved the template - var layout = template.asLayout(); - return { - handle: layout.compile(), - symbolTable: layout.symbolTable - }; + return (0, _opcodeCompiler.unwrapTemplate)(template).asLayout(); } getCapabilities() { @@ -8171,10 +6586,10 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol getTag() { if (_environment2.ENV._DEBUG_RENDER_TREE) { // returning a const tag skips the update hook (VM BUG?) - return (0, _reference.createTag)(); + return (0, _validator.createTag)(); } else { // an outlet has no hooks - return _reference.CONSTANT_TAG; + return _validator.CONSTANT_TAG; } } @@ -8182,37 +6597,37 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol state.finalize(); if (_environment2.ENV._DEBUG_RENDER_TREE) { - state.environment.debugRenderTree.didRender(state, bounds); + state.environment.extra.debugRenderTree.didRender(state, bounds); if (state.engine) { - state.environment.debugRenderTree.didRender(state.engine, bounds); + state.environment.extra.debugRenderTree.didRender(state.engine, bounds); } - state.environment.debugRenderTree.didRender(state.outlet, bounds); + state.environment.extra.debugRenderTree.didRender(state.outlet, bounds); } } update(state) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - state.environment.debugRenderTree.update(state.outlet); + state.environment.extra.debugRenderTree.update(state.outlet); if (state.engine) { - state.environment.debugRenderTree.update(state.engine); + state.environment.extra.debugRenderTree.update(state.engine); } - state.environment.debugRenderTree.update(state); + state.environment.extra.debugRenderTree.update(state); } } didUpdateLayout(state, bounds) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - state.environment.debugRenderTree.didRender(state, bounds); + state.environment.extra.debugRenderTree.didRender(state, bounds); if (state.engine) { - state.environment.debugRenderTree.didRender(state.engine, bounds); + state.environment.extra.debugRenderTree.didRender(state.engine, bounds); } - state.environment.debugRenderTree.didRender(state.outlet, bounds); + state.environment.extra.debugRenderTree.didRender(state.outlet, bounds); } } @@ -8220,13 +6635,13 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol if (_environment2.ENV._DEBUG_RENDER_TREE) { return { destroy() { - state.environment.debugRenderTree.willDestroy(state); + state.environment.extra.debugRenderTree.willDestroy(state); if (state.engine) { - state.environment.debugRenderTree.willDestroy(state.engine); + state.environment.extra.debugRenderTree.willDestroy(state.engine); } - state.environment.debugRenderTree.willDestroy(state.outlet); + state.environment.extra.debugRenderTree.willDestroy(state.outlet); } }; @@ -8251,21 +6666,19 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol if (_environment2.ENV._APPLICATION_TEMPLATE_WRAPPER) { var WRAPPED_CAPABILITIES = (0, _polyfills.assign)({}, CAPABILITIES, { dynamicTag: true, - elementHook: true + elementHook: true, + wrapped: true }); var WrappedOutletComponentManager = class extends OutletComponentManager { getTagName(_component) { return 'div'; } - getLayout(state) { + getJitStaticLayout({ + template + }) { // The router has already resolved the template - var template = state.template; - var layout = template.asWrappedLayout(); - return { - handle: layout.compile(), - symbolTable: layout.symbolTable - }; + return (0, _opcodeCompiler.unwrapTemplate)(template).asWrappedLayout(); } getCapabilities() { @@ -8308,11 +6721,11 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this.hasWrappedElement = hasWrappedElement; this.classRef = null; this.classRef = null; - this.argsRevision = args === null ? 0 : (0, _reference.value)(args.tag); - this.rootRef = new RootReference(component, environment); + this.argsRevision = args === null ? 0 : (0, _validator.value)(args.tag); + this.rootRef = new _reference.ComponentRootReference(component, environment); } - destroy() { + willDestroy() { var { component, environment @@ -8329,7 +6742,11 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } } - environment.destroyedComponents.push(component); + component.renderer.unregister(component); + } + + destroy() { + this.component.destroy(); } finalize() { @@ -8342,48 +6759,106 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } - function referenceForKey(rootRef, key) { - return rootRef.get(key); - } + class EmberHelperRootReference extends _reference.HelperRootReference { + constructor(helper$$1, args, env) { + var fnWrapper = args => { + var { + positional, + named + } = args; + var positionalValue = positional.value(); + var namedValue = named.value(); + var ret; - function referenceForParts(rootRef, parts) { - var isAttrs = parts[0] === 'attrs'; // TODO deprecate this + if (true + /* DEBUG */ + ) { + (0, _debug.debugFreeze)(positionalValue); + (0, _debug.debugFreeze)(namedValue); + (0, _validator.deprecateMutationsInAutotrackingTransaction)(() => { + ret = helper$$1.compute(positionalValue, namedValue); + }); + } else { + ret = helper$$1.compute(positionalValue, namedValue); + } - if (isAttrs) { - parts.shift(); + if (helper$$1[RECOMPUTE_TAG]) { + (0, _validator.consume)(helper$$1[RECOMPUTE_TAG]); + } - if (parts.length === 1) { - return referenceForKey(rootRef, parts[0]); + return ret; + }; + + if (true + /* DEBUG */ + ) { + var debugName = isSimpleHelper(helper$$1) ? (0, _utils.getDebugName)(helper$$1.compute) : (0, _utils.getDebugName)(helper$$1); + super(fnWrapper, args, env, debugName); + } else { + super(fnWrapper, args, env); } } - return referenceFromParts(rootRef, parts); - } // TODO we should probably do this transform at build time + } + class UnboundRootReference extends _reference.RootReference { + constructor(inner, env, parent, key) { + super(env); + this.inner = inner; + this.env = env; - function wrapComponentClassAttribute(hash) { - if (hash === null) { - return; + if (true + /* DEBUG */ + ) { + env.setTemplatePathDebugContext(this, key || 'this', parent || null); + } } - var [keys, values] = hash; - var index = keys === null ? -1 : keys.indexOf('class'); + value() { + return this.inner; + } - if (index !== -1) { - var value$$1 = values[index]; + get(key) { + var value$$1 = this.value(); - if (!Array.isArray(value$$1)) { - return; + if ((0, _utils.isObject)(value$$1)) { + // root of interop with ember objects + return new UnboundPropertyReference(value$$1[key], this.env, this, key); + } else { + return _runtime2.PrimitiveReference.create(value$$1); } + } + + } + + class UnboundPropertyReference extends UnboundRootReference {} - var [type] = value$$1; + function referenceFromParts(root, parts) { + var reference = root; + + for (var _i3 = 0; _i3 < parts.length; _i3++) { + reference = reference.get(parts[_i3]); + } + + return reference; + } + + function referenceForKey(rootRef, key) { + return rootRef.get(key); + } + + function referenceForParts(rootRef, parts) { + var isAttrs = parts[0] === 'attrs'; // TODO deprecate this + + if (isAttrs) { + parts.shift(); - if (type === _wireFormat.Ops.Get || type === _wireFormat.Ops.MaybeLocal) { - var path = value$$1[value$$1.length - 1]; - var propName = path[path.length - 1]; - values[index] = [_wireFormat.Ops.Helper, '-class', [value$$1, propName], null]; + if (parts.length === 1) { + return referenceForKey(rootRef, parts[0]); } } + + return referenceFromParts(rootRef, parts); } var AttributeBinding = { @@ -8401,7 +6876,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } }, - install(_element, component, rootRef, parsed, operations) { + install(component, rootRef, parsed, operations, env) { var [prop, attribute, isSimple] = parsed; if (attribute === 'id') { @@ -8419,10 +6894,10 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var isPath = prop.indexOf('.') > -1; var reference = isPath ? referenceForParts(rootRef, prop.split('.')) : referenceForKey(rootRef, prop); - (true && !(!(isSimple && isPath)) && (0, _debug.assert)("Illegal attributeBinding: '" + prop + "' is not a valid attribute name.", !(isSimple && isPath))); + (true && !(!(isSimple && isPath)) && (0, _debug.assert)(`Illegal attributeBinding: '${prop}' is not a valid attribute name.`, !(isSimple && isPath))); if (_deprecatedFeatures.EMBER_COMPONENT_IS_VISIBLE && attribute === 'style' && StyleBindingReference !== undefined) { - reference = new StyleBindingReference(reference, referenceForKey(rootRef, 'isVisible'), component); + reference = new StyleBindingReference(rootRef, reference, referenceForKey(rootRef, 'isVisible'), env); } operations.setAttribute(attribute, reference, false, null); // operations.addDynamicAttribute(element, attribute, reference, false); @@ -8432,23 +6907,29 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var DISPLAY_NONE = 'display: none;'; var SAFE_DISPLAY_NONE = htmlSafe(DISPLAY_NONE); var StyleBindingReference; + var installIsVisibleBinding; if (_deprecatedFeatures.EMBER_COMPONENT_IS_VISIBLE) { - StyleBindingReference = class extends _reference.CachedReference { - constructor(inner, isVisible, component) { - super(); + StyleBindingReference = class { + constructor(parent, inner, isVisible, env) { this.inner = inner; this.isVisible = isVisible; - this.component = component; - this.tag = (0, _reference.combine)([inner.tag, isVisible.tag]); + this.env = env; + this.tag = (0, _validator.combine)([inner.tag, isVisible.tag]); + + if (true + /* DEBUG */ + ) { + env.setTemplatePathDebugContext(this, 'style', parent); + } } - compute() { + value() { var value$$1 = this.inner.value(); var isVisible = this.isVisible.value(); if (isVisible !== undefined) { - (true && !(false) && (0, _debug.deprecate)("`isVisible` is deprecated (from \"" + this.component._debugContainerKey + "\")", false, { + (true && !(false) && (0, _debug.deprecate)(`The \`isVisible\` property on classic component classes is deprecated. Was accessed ${this.env.getTemplatePathDebugContext(this).replace(/^W/, 'w')}`, false, { id: 'ember-component.is-visible', until: '4.0.0', url: 'https://deprecations.emberjs.com/v3.x#toc_ember-component-is-visible' @@ -8457,9 +6938,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol if (isVisible !== false) { return value$$1; - } - - if (!value$$1) { + } else if (!value$$1) { return SAFE_DISPLAY_NONE; } else { var style = value$$1 + ' ' + DISPLAY_NONE; @@ -8467,37 +6946,15 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } } - }; - } - - var IsVisibleBinding; - - if (_deprecatedFeatures.EMBER_COMPONENT_IS_VISIBLE) { - IsVisibleBinding = { - install(_element, component, rootRef, operations) { - var componentMapStyleValue = isVisible => { - return this.mapStyleValue(isVisible, component); - }; - - operations.setAttribute('style', (0, _reference.map)(referenceForKey(rootRef, 'isVisible'), componentMapStyleValue), false, null); // // the upstream type for addDynamicAttribute's `value` argument - // // appears to be incorrect. It is currently a Reference, I - // // think it should be a Reference. - // operations.addDynamicAttribute(element, 'style', ref as any as Reference, false); - }, - - mapStyleValue(isVisible, component) { - if (isVisible !== undefined) { - (true && !(false) && (0, _debug.deprecate)("`isVisible` is deprecated (from \"" + component._debugContainerKey + "\")", false, { - id: 'ember-component.is-visible', - until: '4.0.0', - url: 'https://deprecations.emberjs.com/v3.x#toc_ember-component-is-visible' - })); - } - - return isVisible === false ? SAFE_DISPLAY_NONE : null; + get() { + return _runtime2.UNDEFINED_REFERENCE; } }; + + installIsVisibleBinding = (rootRef, operations, environment) => { + operations.setAttribute('style', new StyleBindingReference(rootRef, _runtime2.UNDEFINED_REFERENCE, rootRef.get('isVisible'), environment), false, null); + }; } var ClassNameBinding = { @@ -8519,27 +6976,21 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol ref = new ColonClassNameBindingReference(value$$1, truthy, falsy); } - operations.setAttribute('class', ref, false, null); // // the upstream type for addDynamicAttribute's `value` argument - // // appears to be incorrect. It is currently a Reference, I - // // think it should be a Reference. - // operations.addDynamicAttribute(element, 'class', ref as any as Reference, false); + operations.setAttribute('class', ref, false, null); } } }; - class SimpleClassNameBindingReference extends _reference.CachedReference { + class SimpleClassNameBindingReference { constructor(inner, path) { - super(); this.inner = inner; this.path = path; this.tag = inner.tag; - this.inner = inner; - this.path = path; this.dasherizedPath = null; } - compute() { + value() { var value$$1 = this.inner.value(); if (value$$1 === true) { @@ -8557,16 +7008,15 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } - class ColonClassNameBindingReference extends _reference.CachedReference { + class ColonClassNameBindingReference { constructor(inner, truthy = null, falsy = null) { - super(); this.inner = inner; this.truthy = truthy; this.falsy = falsy; this.tag = inner.tag; } - compute() { + value() { var { inner, truthy, @@ -8575,128 +7025,638 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return inner.value() ? truthy : falsy; } - } // inputs needed by CurlyComponents (attrs and props, with mutable - // cells, etc). - - - function processComponentArgs(namedArgs) { - var keys = namedArgs.names; - var attrs = namedArgs.value(); - var props = Object.create(null); - var args = Object.create(null); - props[ARGS] = args; - - for (var i = 0; i < keys.length; i++) { - var name = keys[i]; - var ref = namedArgs.get(name); - var value$$1 = attrs[name]; + } + /** + @module ember + */ - if (typeof value$$1 === 'function' && value$$1[ACTION]) { - attrs[name] = value$$1; - } else if (ref[UPDATE]) { - attrs[name] = new MutableCell(ref, value$$1); + /** + The `mut` helper lets you __clearly specify__ that a child `Component` can update the + (mutable) value passed to it, which will __change the value of the parent component__. + + To specify that a parameter is mutable, when invoking the child `Component`: + + ```handlebars + + ``` + + or + + ```handlebars + {{my-child childClickCount=(mut totalClicks)}} + ``` + + The child `Component` can then modify the parent's value just by modifying its own + property: + + ```javascript + // my-child.js + export default Component.extend({ + click() { + this.incrementProperty('childClickCount'); } + }); + ``` + + Note that for curly components (`{{my-component}}`) the bindings are already mutable, + making the `mut` unnecessary. + + Additionally, the `mut` helper can be combined with the `fn` helper to + mutate a value. For example: + + ```handlebars + + ``` + + or + + ```handlebars + {{my-child childClickCount=totalClicks click-count-change=(fn (mut totalClicks))}} + ``` + + The child `Component` would invoke the function with the new click value: + + ```javascript + // my-child.js + export default Component.extend({ + click() { + this.get('click-count-change')(this.get('childClickCount') + 1); + } + }); + ``` + + The `mut` helper changes the `totalClicks` value to what was provided as the `fn` argument. + + The `mut` helper, when used with `fn`, will return a function that + sets the value passed to `mut` to its first argument. As an example, we can create a + button that increments a value passing the value directly to the `fn`: + + ```handlebars + {{! inc helper is not provided by Ember }} + + ``` + + @method mut + @param {Object} [attr] the "two-way" attribute that can be modified. + @for Ember.Templates.helpers + @public + */ - args[name] = ref; - props[name] = value$$1; - } - - props.attrs = attrs; - return props; - } - var REF = (0, _utils.symbol)('REF'); + var INVOKE = (0, _utils.symbol)('INVOKE'); + _exports.INVOKE = INVOKE; + var SOURCE = (0, _utils.symbol)('SOURCE'); - class MutableCell { - constructor(ref, value$$1) { - this[_views.MUTABLE_CELL] = true; - this[REF] = ref; - this.value = value$$1; + class MutReference extends _reference.RootReference { + constructor(inner, env) { + super(env); + this.inner = inner; + this.tag = inner.tag; + this[SOURCE] = inner; } - update(val) { - this[REF][UPDATE](val); + value() { + return this.inner.value(); } - } - - var __rest = undefined && undefined.__rest || function (s, e) { - var t = {}; - - for (var p in s) { - if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + get(key) { + return this.inner.get(key); } - if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { - if (e.indexOf(p[i]) < 0) t[p[i]] = s[p[i]]; + [_reference.UPDATE_REFERENCED_VALUE](value$$1) { + return this.inner[_reference.UPDATE_REFERENCED_VALUE](value$$1); } - return t; - }; - function aliasIdToElementId(args, props) { - if (args.named.has('id')) { - // tslint:disable-next-line:max-line-length - (true && !(!args.named.has('elementId')) && (0, _debug.assert)("You cannot invoke a component with both 'id' and 'elementId' at the same time.", !args.named.has('elementId'))); - props.elementId = props.id; + [INVOKE](value$$1) { + return this.inner[_reference.UPDATE_REFERENCED_VALUE](value$$1); } - } // We must traverse the attributeBindings in reverse keeping track of - // what has already been applied. This is essentially refining the concatenated - // properties applying right to left. - - function applyAttributeBindings(element, attributeBindings, component, rootRef, operations) { - var seen = []; - var i = attributeBindings.length - 1; + } - while (i !== -1) { - var binding = attributeBindings[i]; - var parsed = AttributeBinding.parse(binding); - var attribute = parsed[1]; + function unMut(ref) { + return ref[SOURCE] || ref; + } - if (seen.indexOf(attribute) === -1) { - seen.push(attribute); - AttributeBinding.install(element, component, rootRef, parsed, operations); - } + function mut(args, vm) { + var rawRef = args.positional.at(0); - i--; - } + if (typeof rawRef[INVOKE] === 'function') { + return rawRef; + } // TODO: Improve this error message. This covers at least two distinct + // cases: + // + // 1. (mut "not a path") – passing a literal, result from a helper + // invocation, etc + // + // 2. (mut receivedValue) – passing a value received from the caller + // that was originally derived from a literal, result from a helper + // invocation, etc + // + // This message is alright for the first case, but could be quite + // confusing for the second case. - if (seen.indexOf('id') === -1) { - var id$$1 = component.elementId ? component.elementId : (0, _utils.guidFor)(component); - operations.setAttribute('id', _runtime2.PrimitiveReference.create(id$$1), false, null); - } - if (_deprecatedFeatures.EMBER_COMPONENT_IS_VISIBLE && IsVisibleBinding !== undefined && seen.indexOf('style') === -1) { - IsVisibleBinding.install(element, component, rootRef, operations); - } + (true && !(rawRef[_reference.UPDATE_REFERENCED_VALUE] !== undefined) && (0, _debug.assert)('You can only pass a path to mut', rawRef[_reference.UPDATE_REFERENCED_VALUE] !== undefined)); + return new MutReference(rawRef, vm.env); } + /** + @module ember + */ - var DEFAULT_LAYOUT = (0, _container.privatize)(_templateObject2()); - var EMPTY_POSITIONAL_ARGS = []; - (0, _debug.debugFreeze)(EMPTY_POSITIONAL_ARGS); - - class CurlyComponentManager extends AbstractManager { - getLayout(state, _resolver) { - return { - // TODO fix - handle: state.handle, - symbolTable: state.symbolTable - }; - } - templateFor(component) { - var { - layout, - layoutName + var ACTION = (0, _utils.symbol)('ACTION'); + /** + The `{{action}}` helper provides a way to pass triggers for behavior (usually + just a function) between components, and into components from controllers. + + ### Passing functions with the action helper + + There are three contexts an action helper can be used in. The first two + contexts to discuss are attribute context, and Handlebars value context. + + ```handlebars + {{! An example of attribute context }} +
+ {{! Examples of Handlebars value context }} + {{input on-input=(action "save")}} + {{yield (action "refreshData") andAnotherParam}} + ``` + + In these contexts, + the helper is called a "closure action" helper. Its behavior is simple: + If passed a function name, read that function off the `actions` property + of the current context. Once that function is read, or immediately if a function was + passed, create a closure over that function and any arguments. + The resulting value of an action helper used this way is simply a function. + + For example, in the attribute context: + + ```handlebars + {{! An example of attribute context }} +
+ ``` + + The resulting template render logic would be: + + ```js + var div = document.createElement('div'); + var actionFunction = (function(context){ + return function() { + return context.actions.save.apply(context, arguments); + }; + })(context); + div.onclick = actionFunction; + ``` + + Thus when the div is clicked, the action on that context is called. + Because the `actionFunction` is just a function, closure actions can be + passed between components and still execute in the correct context. + + Here is an example action handler on a component: + + ```app/components/my-component.js + import Component from '@glimmer/component'; + import { action } from '@ember/object'; + + export default class extends Component { + @action + save() { + this.model.save(); + } + } + ``` + + Actions are always looked up on the `actions` property of the current context. + This avoids collisions in the naming of common actions, such as `destroy`. + Two options can be passed to the `action` helper when it is used in this way. + + * `target=someProperty` will look to `someProperty` instead of the current + context for the `actions` hash. This can be useful when targeting a + service for actions. + * `value="target.value"` will read the path `target.value` off the first + argument to the action when it is called and rewrite the first argument + to be that value. This is useful when attaching actions to event listeners. + + ### Invoking an action + + Closure actions curry both their scope and any arguments. When invoked, any + additional arguments are added to the already curried list. + Actions should be invoked using the [sendAction](/ember/release/classes/Component/methods/sendAction?anchor=sendAction) + method. The first argument to `sendAction` is the action to be called, and + additional arguments are passed to the action function. This has interesting + properties combined with currying of arguments. For example: + + ```app/components/update-name.js + import Component from '@glimmer/component'; + import { action } from '@ember/object'; + + export default class extends Component { + @action + setName(model, name) { + model.set('name', name); + } + } + ``` + + ```app/components/update-name.hbs + {{input on-input=(action (action 'setName' @model) value="target.value")}} + ``` + + The first argument (`@model`) was curried over, and the run-time argument (`event`) + becomes a second argument. Action calls can be nested this way because each simply + returns a function. Any function can be passed to the `{{action}}` helper, including + other actions. + + Actions invoked with `sendAction` have the same currying behavior as demonstrated + with `on-input` above. For example: + + ```app/components/my-input.js + import Component from '@glimmer/component'; + import { action } from '@ember/object'; + + export default class extends Component { + @action + setName(model, name) { + model.set('name', name); + } + } + ``` + + ```handlebars + + ``` + + or + + ```handlebars + {{my-input submit=(action 'setName' @model)}} + ``` + + ```app/components/my-component.js + import Component from '@ember/component'; + + export default Component.extend({ + click() { + // Note that model is not passed, it was curried in the template + this.sendAction('submit', 'bob'); + } + }); + ``` + + ### Attaching actions to DOM elements + + The third context of the `{{action}}` helper can be called "element space". + For example: + + ```handlebars + {{! An example of element space }} +
+ ``` + + Used this way, the `{{action}}` helper provides a useful shortcut for + registering an HTML element in a template for a single DOM event and + forwarding that interaction to the template's context (controller or component). + If the context of a template is a controller, actions used this way will + bubble to routes when the controller does not implement the specified action. + Once an action hits a route, it will bubble through the route hierarchy. + + ### Event Propagation + + `{{action}}` helpers called in element space can control event bubbling. Note + that the closure style actions cannot. + + Events triggered through the action helper will automatically have + `.preventDefault()` called on them. You do not need to do so in your event + handlers. If you need to allow event propagation (to handle file inputs for + example) you can supply the `preventDefault=false` option to the `{{action}}` helper: + + ```handlebars +
+ + +
+ ``` + + To disable bubbling, pass `bubbles=false` to the helper: + + ```handlebars + + ``` + + To disable bubbling with closure style actions you must create your own + wrapper helper that makes use of `event.stopPropagation()`: + + ```handlebars +
Hello
+ ``` + + ```app/helpers/disable-bubbling.js + import { helper } from '@ember/component/helper'; + + export function disableBubbling([action]) { + return function(event) { + event.stopPropagation(); + return action(event); + }; + } + export default helper(disableBubbling); + ``` + + If you need the default handler to trigger you should either register your + own event handler, or use event methods on your view class. See + ["Responding to Browser Events"](/ember/release/classes/Component) + in the documentation for `Component` for more information. + + ### Specifying DOM event type + + `{{action}}` helpers called in element space can specify an event type. + By default the `{{action}}` helper registers for DOM `click` events. You can + supply an `on` option to the helper to specify a different DOM event name: + + ```handlebars +
+ click me +
+ ``` + + See ["Event Names"](/ember/release/classes/Component) for a list of + acceptable DOM event names. + + ### Specifying whitelisted modifier keys + + `{{action}}` helpers called in element space can specify modifier keys. + By default the `{{action}}` helper will ignore click events with pressed modifier + keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. + + ```handlebars +
+ click me +
+ ``` + + This way the action will fire when clicking with the alt key pressed down. + Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. + + ```handlebars +
+ click me with any key pressed +
+ ``` + + ### Specifying a Target + + A `target` option can be provided to the helper to change + which object will receive the method call. This option must be a path + to an object, accessible in the current context: + + ```app/templates/application.hbs +
+ click me +
+ ``` + + ```app/controllers/application.js + import Controller from '@ember/controller'; + import { inject as service } from '@ember/service'; + + export default class extends Controller { + @service someService; + } + ``` + + @method action + @for Ember.Templates.helpers + @public + */ + + function action(args, vm) { + var { + named, + positional + } = args; + var capturedArgs = positional.capture(); // The first two argument slots are reserved. + // pos[0] is the context (or `this`) + // pos[1] is the action name or function + // Anything else is an action argument. + + var [context, action, ...restArgs] = capturedArgs.references; // TODO: Is there a better way of doing this? + + var debugKey = action.propertyKey; + var target = named.has('target') ? named.get('target') : context; + var processArgs = makeArgsProcessor(named.has('value') && named.get('value'), restArgs); + var fn; + + if (typeof action[INVOKE] === 'function') { + fn = makeClosureAction(action, action, action[INVOKE], processArgs, debugKey); + } else if ((0, _validator.isConst)(target) && (0, _validator.isConst)(action)) { + fn = makeClosureAction(context.value(), target.value(), action.value(), processArgs, debugKey); + } else { + fn = makeDynamicClosureAction(context.value(), target, action, processArgs, debugKey); + } + + fn[ACTION] = true; + return new UnboundRootReference(fn, vm.env); + } + + function NOOP$1(args) { + return args; + } + + function makeArgsProcessor(valuePathRef, actionArgsRef) { + var mergeArgs; + + if (actionArgsRef.length > 0) { + mergeArgs = args => { + return actionArgsRef.map(ref => ref.value()).concat(args); + }; + } + + var readValue; + + if (valuePathRef) { + readValue = args => { + var valuePath = valuePathRef.value(); + + if (valuePath && args.length > 0) { + args[0] = (0, _metal.get)(args[0], valuePath); + } + + return args; + }; + } + + if (mergeArgs && readValue) { + return args => { + return readValue(mergeArgs(args)); + }; + } else { + return mergeArgs || readValue || NOOP$1; + } + } + + function makeDynamicClosureAction(context, targetRef, actionRef, processArgs, debugKey) { + // We don't allow undefined/null values, so this creates a throw-away action to trigger the assertions + if (true + /* DEBUG */ + ) { + makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey); + } + + return (...args) => { + return makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey)(...args); + }; + } + + function makeClosureAction(context, target, action, processArgs, debugKey) { + var self; + var fn; + (true && !(action !== undefined && action !== null) && (0, _debug.assert)(`Action passed is null or undefined in (action) from ${target}.`, action !== undefined && action !== null)); + + if (typeof action[INVOKE] === 'function') { + self = action; + fn = action[INVOKE]; + } else { + var typeofAction = typeof action; + + if (typeofAction === 'string') { + self = target; + fn = target.actions && target.actions[action]; + (true && !(fn) && (0, _debug.assert)(`An action named '${action}' was not found in ${target}`, fn)); + } else if (typeofAction === 'function') { + self = context; + fn = action; + } else { + // tslint:disable-next-line:max-line-length + (true && !(false) && (0, _debug.assert)(`An action could not be made for \`${debugKey || action}\` in ${target}. Please confirm that you are using either a quoted action name (i.e. \`(action '${debugKey || 'myAction'}')\`) or a function available in ${target}.`, false)); + } + } + + return (...args) => { + var payload = { + target: self, + args, + label: '@glimmer/closure-action' + }; + return (0, _instrumentation.flaggedInstrument)('interaction.ember-action', payload, () => { + return (0, _runloop.join)(self, fn, ...processArgs(args)); + }); + }; + } // inputs needed by CurlyComponents (attrs and props, with mutable + // cells, etc). + + + function processComponentArgs(namedArgs) { + var keys = namedArgs.names; + var attrs = namedArgs.value(); + var props = Object.create(null); + var args = Object.create(null); + props[ARGS] = args; + + for (var _i4 = 0; _i4 < keys.length; _i4++) { + var name = keys[_i4]; + var ref = namedArgs.get(name); + var value$$1 = attrs[name]; + + if (typeof value$$1 === 'function' && value$$1[ACTION]) { + attrs[name] = value$$1; + } else if (ref[_reference.UPDATE_REFERENCED_VALUE]) { + attrs[name] = new MutableCell(ref, value$$1); + } + + args[name] = ref; + props[name] = value$$1; + } + + props.attrs = attrs; + return props; + } + + var REF = (0, _utils.symbol)('REF'); + + class MutableCell { + constructor(ref, value$$1) { + this[_views.MUTABLE_CELL] = true; + this[REF] = ref; + this.value = value$$1; + } + + update(val) { + this[REF][_reference.UPDATE_REFERENCED_VALUE](val); + } + + } + + var __rest = undefined && undefined.__rest || function (s, e) { + var t = {}; + + for (var p in s) { + if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; + } + + if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { + if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; + } + return t; + }; + + function aliasIdToElementId(args, props) { + if (args.named.has('id')) { + // tslint:disable-next-line:max-line-length + (true && !(!args.named.has('elementId')) && (0, _debug.assert)(`You cannot invoke a component with both 'id' and 'elementId' at the same time.`, !args.named.has('elementId'))); + props.elementId = props.id; + } + } // We must traverse the attributeBindings in reverse keeping track of + // what has already been applied. This is essentially refining the concatenated + // properties applying right to left. + + + function applyAttributeBindings(attributeBindings, component, rootRef, operations, environment) { + var seen = []; + var i = attributeBindings.length - 1; + + while (i !== -1) { + var binding = attributeBindings[i]; + var parsed = AttributeBinding.parse(binding); + var attribute = parsed[1]; + + if (seen.indexOf(attribute) === -1) { + seen.push(attribute); + AttributeBinding.install(component, rootRef, parsed, operations, environment); + } + + i--; + } + + if (seen.indexOf('id') === -1) { + var id$$1 = component.elementId ? component.elementId : (0, _utils.guidFor)(component); + operations.setAttribute('id', _runtime2.PrimitiveReference.create(id$$1), false, null); + } + + if (_deprecatedFeatures.EMBER_COMPONENT_IS_VISIBLE && installIsVisibleBinding !== undefined && seen.indexOf('style') === -1) { + installIsVisibleBinding(rootRef, operations, environment); + } + } + + var DEFAULT_LAYOUT = _container.privatize`template:components/-default`; + var EMPTY_POSITIONAL_ARGS = []; + (0, _debug.debugFreeze)(EMPTY_POSITIONAL_ARGS); + + class CurlyComponentManager extends AbstractManager { + templateFor(component) { + var { + layout, + layoutName } = component; var owner = (0, _owner.getOwner)(component); var factory; if (layout === undefined) { if (layoutName !== undefined) { - var _factory = owner.lookup("template:" + layoutName); + var _factory = owner.lookup(`template:${layoutName}`); - (true && !(_factory !== undefined) && (0, _debug.assert)("Layout `" + layoutName + "` not found!", _factory !== undefined)); + (true && !(_factory !== undefined) && (0, _debug.assert)(`Layout \`${layoutName}\` not found!`, _factory !== undefined)); factory = _factory; } else { factory = owner.lookup(DEFAULT_LAYOUT); @@ -8711,19 +7671,19 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return factory(owner); } - getDynamicLayout(bucket) { + getJitStaticLayout(state, _resolver) { + return (0, _opcodeCompiler.unwrapTemplate)(state.template).asLayout(); + } + + getJitDynamicLayout(bucket) { var component = bucket.component; var template$$1 = this.templateFor(component); - var layout = template$$1.asWrappedLayout(); if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.environment.debugRenderTree.setTemplate(bucket, template$$1); + bucket.environment.extra.debugRenderTree.setTemplate(bucket, template$$1); } - return { - handle: layout.compile(), - symbolTable: layout.symbolTable - }; + return template$$1; } getTagName(state) { @@ -8769,7 +7729,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var named; if (typeof positionalParams === 'string') { - (true && !(!args.named.has(positionalParams)) && (0, _debug.assert)("You cannot specify positional parameters and the hash argument `" + positionalParams + "`.", !args.named.has(positionalParams))); + (true && !(!args.named.has(positionalParams)) && (0, _debug.assert)(`You cannot specify positional parameters and the hash argument \`${positionalParams}\`.`, !args.named.has(positionalParams))); named = { [positionalParams]: args.positional.capture() }; @@ -8779,10 +7739,10 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol named = {}; (0, _polyfills.assign)(named, args.named.capture().map); - for (var i = 0; i < count; i++) { - var name = positionalParams[i]; - (true && !(!args.named.has(name)) && (0, _debug.assert)("You cannot specify both a positional param (at position " + i + ") and the hash argument `" + name + "`.", !args.named.has(name))); - named[name] = args.positional.at(i); + for (var _i5 = 0; _i5 < count; _i5++) { + var name = positionalParams[_i5]; + (true && !(!args.named.has(name)) && (0, _debug.assert)(`You cannot specify both a positional param (at position ${_i5}) and the hash argument \`${name}\`.`, !args.named.has(name))); + named[name] = args.positional.at(_i5); } } else { return null; @@ -8880,7 +7840,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } if (_environment2.ENV._DEBUG_RENDER_TREE) { - environment.debugRenderTree.create(bucket, { + environment.extra.debugRenderTree.create(bucket, { type: 'component', name: state.name, args: args.capture(), @@ -8913,13 +7873,13 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } = component; if (attributeBindings && attributeBindings.length) { - applyAttributeBindings(element, attributeBindings, component, rootRef, operations); + applyAttributeBindings(attributeBindings, component, rootRef, operations, environment); } else { var id$$1 = component.elementId ? component.elementId : (0, _utils.guidFor)(component); operations.setAttribute('id', _runtime2.PrimitiveReference.create(id$$1), false, null); - if (_deprecatedFeatures.EMBER_COMPONENT_IS_VISIBLE && IsVisibleBinding !== undefined) { - IsVisibleBinding.install(element, component, rootRef, operations); + if (_deprecatedFeatures.EMBER_COMPONENT_IS_VISIBLE) { + installIsVisibleBinding(rootRef, operations, environment); } } @@ -8958,7 +7918,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol bucket.finalize(); if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.environment.debugRenderTree.didRender(bucket, bounds); + bucket.environment.extra.debugRenderTree.didRender(bucket, bounds); } } @@ -8966,7 +7926,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol args, component }) { - return args ? (0, _reference.combine)([args.tag, component[DIRTY_TAG]]) : component[DIRTY_TAG]; + return args ? (0, _validator.combine)([args.tag, component[DIRTY_TAG]]) : component[DIRTY_TAG]; } didCreate({ @@ -8990,14 +7950,14 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } = bucket; if (_environment2.ENV._DEBUG_RENDER_TREE) { - environment.debugRenderTree.update(bucket); + environment.extra.debugRenderTree.update(bucket); } bucket.finalizer = (0, _instrumentation._instrumentStart)('render.component', rerenderInstrumentDetails, component); - if (args && !(0, _reference.validate)(args.tag, argsRevision)) { + if (args && !(0, _validator.validate)(args.tag, argsRevision)) { var props = processComponentArgs(args); - bucket.argsRevision = (0, _reference.value)(args.tag); + bucket.argsRevision = (0, _validator.value)(args.tag); component[IS_DISPATCHING_ATTRS] = true; component.setProperties(props); component[IS_DISPATCHING_ATTRS] = false; @@ -9015,7 +7975,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol bucket.finalize(); if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.environment.debugRenderTree.didRender(bucket, bounds); + bucket.environment.extra.debugRenderTree.didRender(bucket, bounds); } } @@ -9032,8 +7992,12 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol getDestructor(bucket) { if (_environment2.ENV._DEBUG_RENDER_TREE) { return { + willDestroy() { + bucket.willDestroy(); + }, + destroy() { - bucket.environment.debugRenderTree.willDestroy(bucket); + bucket.environment.extra.debugRenderTree.willDestroy(bucket); bucket.destroy(); } @@ -9051,8 +8015,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol classNameBindings } = component; - for (var i = 0; i < classNameBindings.length; i++) { - var binding = classNameBindings[i]; + for (var _i6 = 0; _i6 < classNameBindings.length; _i6++) { + var binding = classNameBindings[_i6]; if (typeof binding !== 'string' || binding.length === 0) { return false; @@ -9060,13 +8024,13 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } return true; - })()) && (0, _debug.assert)("classNameBindings must be non-empty strings: " + component, (() => { + })()) && (0, _debug.assert)(`classNameBindings must be non-empty strings: ${component}`, (() => { var { classNameBindings } = component; - for (var i = 0; i < classNameBindings.length; i++) { - var binding = classNameBindings[i]; + for (var _i6 = 0; _i6 < classNameBindings.length; _i6++) { + var binding = classNameBindings[_i6]; if (typeof binding !== 'string' || binding.length === 0) { return false; @@ -9080,8 +8044,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol classNameBindings } = component; - for (var i = 0; i < classNameBindings.length; i++) { - var binding = classNameBindings[i]; + for (var _i7 = 0; _i7 < classNameBindings.length; _i7++) { + var binding = classNameBindings[_i7]; if (binding.split(' ').length > 1) { return false; @@ -9089,13 +8053,13 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } return true; - })()) && (0, _debug.assert)("classNameBindings must not have spaces in them: " + component, (() => { + })()) && (0, _debug.assert)(`classNameBindings must not have spaces in them: ${component}`, (() => { var { classNameBindings } = component; - for (var i = 0; i < classNameBindings.length; i++) { - var binding = classNameBindings[i]; + for (var _i7 = 0; _i7 < classNameBindings.length; _i7++) { + var binding = classNameBindings[_i7]; if (binding.split(' ').length > 1) { return false; @@ -9104,9 +8068,9 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return true; })())); - (true && !(component.tagName !== '' || !component.classNameBindings || component.classNameBindings.length === 0) && (0, _debug.assert)("You cannot use `classNameBindings` on a tag-less component: " + component, component.tagName !== '' || !component.classNameBindings || component.classNameBindings.length === 0)); - (true && !(component.tagName !== '' || props.id === component.elementId || !component.elementId && component.elementId !== '') && (0, _debug.assert)("You cannot use `elementId` on a tag-less component: " + component, component.tagName !== '' || props.id === component.elementId || !component.elementId && component.elementId !== '')); - (true && !(component.tagName !== '' || !component.attributeBindings || component.attributeBindings.length === 0) && (0, _debug.assert)("You cannot use `attributeBindings` on a tag-less component: " + component, component.tagName !== '' || !component.attributeBindings || component.attributeBindings.length === 0)); + (true && !(component.tagName !== '' || !component.classNameBindings || component.classNameBindings.length === 0) && (0, _debug.assert)(`You cannot use \`classNameBindings\` on a tag-less component: ${component}`, component.tagName !== '' || !component.classNameBindings || component.classNameBindings.length === 0)); + (true && !(component.tagName !== '' || props.id === component.elementId || !component.elementId && component.elementId !== '') && (0, _debug.assert)(`You cannot use \`elementId\` on a tag-less component: ${component}`, component.tagName !== '' || props.id === component.elementId || !component.elementId && component.elementId !== '')); + (true && !(component.tagName !== '' || !component.attributeBindings || component.attributeBindings.length === 0) && (0, _debug.assert)(`You cannot use \`attributeBindings\` on a tag-less component: ${component}`, component.tagName !== '' || !component.attributeBindings || component.attributeBindings.length === 0)); } function initialRenderInstrumentDetails(component) { @@ -9131,30 +8095,24 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol createCaller: true, dynamicScope: true, updateHook: true, - createInstance: true + createInstance: true, + wrapped: true, + willDestroy: true }; var CURLY_COMPONENT_MANAGER = new CurlyComponentManager(); class CurlyComponentDefinition { - // tslint:disable-next-line:no-shadowed-variable - constructor(name, ComponentClass, handle, template$$1, args) { + constructor(name, ComponentClass, template$$1, args) { this.name = name; this.ComponentClass = ComponentClass; - this.handle = handle; - this.template = template$$1; - this.manager = CURLY_COMPONENT_MANAGER; - var layout = template$$1 && template$$1.asLayout(); - var symbolTable = layout ? layout.symbolTable : undefined; - this.symbolTable = symbolTable; this.template = template$$1; this.args = args; + this.manager = CURLY_COMPONENT_MANAGER; this.state = { name, ComponentClass, - handle, template: template$$1, - capabilities: CURLY_CAPABILITIES, - symbolTable + capabilities: CURLY_CAPABILITIES }; } @@ -9166,13 +8124,9 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this.component = component; } - getLayout(_state) { + getJitStaticLayout(_state) { var template = this.templateFor(this.component); - var layout = template.asWrappedLayout(); - return { - handle: layout.compile(), - symbolTable: layout.symbolTable - }; + return (0, _opcodeCompiler.unwrapTemplate)(template).asWrappedLayout(); } create(environment, state, _args, dynamicScope) { @@ -9202,7 +8156,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var bucket = new ComponentStateBucket(environment, component, null, finalizer, hasWrappedElement); if (_environment2.ENV._DEBUG_RENDER_TREE) { - environment.debugRenderTree.create(bucket, { + environment.extra.debugRenderTree.create(bucket, { type: 'component', name: state.name, args: _runtime2.EMPTY_ARGS, @@ -9228,7 +8182,9 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol createCaller: true, dynamicScope: true, updateHook: true, - createInstance: true + createInstance: true, + wrapped: true, + willDestroy: false }; class RootComponentDefinition { @@ -9242,8 +8198,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this.state = { name: factory.fullName.slice(10), capabilities: ROOT_CAPABILITIES, - ComponentClass: factory, - handle: null + ComponentClass: factory }; } @@ -9254,968 +8209,1002 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } } + /* globals module, URL */ - class DynamicScope { - constructor(view, outletState) { - this.view = view; - this.outletState = outletState; - } - child() { - return new DynamicScope(this.view, this.outletState); - } + var nodeURL; + var parsingNode; - get(key) { - // tslint:disable-next-line:max-line-length - (true && !(key === 'outletState') && (0, _debug.assert)("Using `-get-dynamic-scope` is only supported for `outletState` (you used `" + key + "`).", key === 'outletState')); - return this.outletState; - } + function installProtocolForURL(environment) { + var protocol; - set(key, value$$1) { - // tslint:disable-next-line:max-line-length - (true && !(key === 'outletState') && (0, _debug.assert)("Using `-with-dynamic-scope` is only supported for `outletState` (you used `" + key + "`).", key === 'outletState')); - this.outletState = value$$1; - return value$$1; - } + if (_browserEnvironment.hasDOM) { + protocol = browserProtocolForURL.call(environment, 'foobar:baz'); + } // Test to see if our DOM implementation parses + // and normalizes URLs. - } - class RootState { - constructor(root, env, template, self, parentElement, dynamicScope, builder) { - (true && !(template !== undefined) && (0, _debug.assert)("You cannot render `" + self.value() + "` without a template.", template !== undefined)); - this.id = (0, _views.getViewId)(root); - this.env = env; - this.root = root; - this.result = undefined; - this.shouldReflush = false; - this.destroyed = false; - - this.render = () => { - var layout = template.asLayout(); - var handle = layout.compile(); - var iterator = (0, _runtime2.renderMain)(layout['compiler'].program, env, self, dynamicScope, builder(env, { - element: parentElement, - nextSibling: null - }), handle); - var iteratorResult; - - do { - iteratorResult = iterator.next(); - } while (!iteratorResult.done); - - var result = this.result = iteratorResult.value; // override .render function after initial render - - this.render = () => result.rerender({ - alwaysRevalidate: false - }); - }; + if (protocol === 'foobar:') { + // Swap in the method that doesn't do this test now that + // we know it works. + environment.protocolForURL = browserProtocolForURL; + } else if (typeof URL === 'object') { + // URL globally provided, likely from FastBoot's sandbox + nodeURL = URL; + environment.protocolForURL = nodeProtocolForURL; + } else if (typeof module !== undefined && typeof module.require === 'function') { + // Otherwise, we need to fall back to our own URL parsing. + // Global `require` is shadowed by Ember's loader so we have to use the fully + // qualified `module.require`. + // tslint:disable-next-line:no-require-imports + nodeURL = module.require('url'); + environment.protocolForURL = nodeProtocolForURL; + } else { + throw new Error('Could not find valid URL parsing mechanism for URL Sanitization'); } + } - isFor(possibleRoot) { - return this.root === possibleRoot; + function browserProtocolForURL(url) { + if (!parsingNode) { + parsingNode = document.createElement('a'); } - destroy() { - var { - result, - env - } = this; - this.destroyed = true; - this.env = undefined; - this.root = null; - this.result = undefined; - this.render = undefined; - - if (result) { - /* - Handles these scenarios: - * When roots are removed during standard rendering process, a transaction exists already - `.begin()` / `.commit()` are not needed. - * When roots are being destroyed manually (`component.append(); component.destroy() case), no - transaction exists already. - * When roots are being destroyed during `Renderer#destroy`, no transaction exists - */ - var needsTransaction = !env.inTransaction; + parsingNode.href = url; + return parsingNode.protocol; + } - if (needsTransaction) { - env.begin(); - } + function nodeProtocolForURL(url) { + var protocol = null; - try { - result.destroy(); - } finally { - if (needsTransaction) { - env.commit(); - } - } - } + if (typeof url === 'string') { + protocol = nodeURL.parse(url).protocol; } + return protocol === null ? ':' : protocol; } - var renderers = []; - - function _resetRenderers() { - renderers.length = 0; - } - - function register(renderer) { - (true && !(renderers.indexOf(renderer) === -1) && (0, _debug.assert)('Cannot register the same renderer twice', renderers.indexOf(renderer) === -1)); - renderers.push(renderer); - } + var GUID = 0; - function deregister(renderer) { - var index = renderers.indexOf(renderer); - (true && !(index !== -1) && (0, _debug.assert)('Cannot deregister unknown unregistered renderer', index !== -1)); - renderers.splice(index, 1); + function isPathNode(node) { + return node.type === 'root' || node.type === 'argument' || node.type === 'property' || node.type === 'iterator'; } - function loopBegin() { - for (var i = 0; i < renderers.length; i++) { - renderers[i]._scheduleRevalidate(); + class Ref { + constructor(value$$1) { + this.id = GUID++; + this.value = value$$1; } - } - - function K() { - /* noop */ - } - - var renderSettledDeferred = null; - /* - Returns a promise which will resolve when rendering has settled. Settled in - this context is defined as when all of the tags in use are "current" (e.g. - `renderers.every(r => r._isValid())`). When this is checked at the _end_ of - the run loop, this essentially guarantees that all rendering is completed. - - @method renderSettled - @returns {Promise} a promise which fulfills when rendering has settled - */ - - function renderSettled() { - if (renderSettledDeferred === null) { - renderSettledDeferred = _rsvp.default.defer(); // if there is no current runloop, the promise created above will not have - // a chance to resolve (because its resolved in backburner's "end" event) - if (!(0, _runloop.getCurrentRunLoop)()) { - // ensure a runloop has been kicked off - _runloop.backburner.schedule('actions', null, K); - } + get() { + return this.value; } - return renderSettledDeferred.promise; - } - - function resolveRenderPromise() { - if (renderSettledDeferred !== null) { - var resolve = renderSettledDeferred.resolve; - renderSettledDeferred = null; - - _runloop.backburner.join(null, resolve); + release() { + (true && !(this.value !== null) && (0, _debug.assert)('BUG: double release?', this.value !== null)); + this.value = null; } - } - - var loops = 0; - function loopEnd() { - for (var i = 0; i < renderers.length; i++) { - if (!renderers[i]._isValid()) { - if (loops > _environment2.ENV._RERENDER_LOOP_LIMIT) { - loops = 0; // TODO: do something better + toString() { + var label = `Ref ${this.id}`; - renderers[i].destroy(); - throw new Error('infinite rendering invalidation detected'); + if (this.value === null) { + return `${label} (released)`; + } else { + try { + return `${label}: ${this.value}`; + } catch (_a) { + return label; } - - loops++; - return _runloop.backburner.join(null, K); } } - loops = 0; - resolveRenderPromise(); } - _runloop.backburner.on('begin', loopBegin); - - _runloop.backburner.on('end', loopEnd); - - class Renderer { - constructor(env, rootTemplate, viewRegistry, destinedForDOM = false, builder = _runtime2.clientBuilder) { - this._env = env; - this._rootTemplate = rootTemplate(env.owner); - this._viewRegistry = viewRegistry; - this._destinedForDOM = destinedForDOM; - this._destroyed = false; - this._roots = []; - this._lastRevision = -1; - this._isRenderingRoots = false; - this._removedRoots = []; - this._builder = builder; - } // renderer HOOKS - - - appendOutletView(view, target) { - var definition = createRootOutlet(view); - - this._appendDefinition(view, (0, _runtime2.curry)(definition), target); - } - - appendTo(view, target) { - var definition = new RootComponentDefinition(view); - - this._appendDefinition(view, (0, _runtime2.curry)(definition), target); - } - - _appendDefinition(root, definition, target) { - var self = new UnboundReference(definition); - var dynamicScope = new DynamicScope(null, _runtime2.UNDEFINED_REFERENCE); - var rootState = new RootState(root, this._env, this._rootTemplate, self, target, dynamicScope, this._builder); + var _repeat = String.prototype.repeat || function (count) { + return new Array(count + 1).join(this); + }; - this._renderRoot(rootState); - } + function repeatString(str, count) { + return _repeat.call(str, count); + } - rerender() { - this._scheduleRevalidate(); + class DebugRenderTree { + constructor() { + this.stack = new _util.Stack(); + this.refs = new WeakMap(); + this.roots = new Set(); + this.nodes = new WeakMap(); + this.pathNodes = new WeakMap(); } - register(view) { - var id = (0, _views.getViewId)(view); - (true && !(!this._viewRegistry[id]) && (0, _debug.assert)('Attempted to register a view with an id already in use: ' + id, !this._viewRegistry[id])); - this._viewRegistry[id] = view; + begin() { + this.reset(); } - unregister(view) { - delete this._viewRegistry[(0, _views.getViewId)(view)]; + create(state, node) { + var internalNode = (0, _polyfills.assign)({}, node, { + bounds: null, + refs: new Set(), + paths: new Set() + }); + this.nodes.set(state, internalNode); + this.appendChild(internalNode, state); + this.enter(state); } - remove(view) { - view._transitionTo('destroying'); + update(state) { + this.enter(state); + } // for dynamic layouts - this.cleanupRootFor(view); - if (this._destinedForDOM) { - view.trigger('didDestroyElement'); - } + setTemplate(state, template) { + this.nodeFor(state).template = template; } - cleanupRootFor(view) { - // no need to cleanup roots if we have already been destroyed - if (this._destroyed) { - return; - } - - var roots = this._roots; // traverse in reverse so we can remove items - // without mucking up the index - - var i = this._roots.length; - - while (i--) { - var root = roots[i]; - - if (root.isFor(view)) { - root.destroy(); - roots.splice(i, 1); - } - } + didRender(state, bounds) { + (true && !(this.stack.current === state) && (0, _debug.assert)(`BUG: expecting ${this.stack.current}, got ${state}`, this.stack.current === state)); + this.nodeFor(state).bounds = bounds; + this.exit(); } - destroy() { - if (this._destroyed) { - return; - } - - this._destroyed = true; - - this._clearAllRoots(); + willDestroy(state) { + (0, _util.expect)(this.refs.get(state), 'BUG: missing ref').release(); } - getBounds(view) { - var bounds = view[BOUNDS]; - (true && !(Boolean(bounds)) && (0, _debug.assert)('object passed to getBounds must have the BOUNDS symbol as a property', Boolean(bounds))); - var parentElement = bounds.parentElement(); - var firstNode = bounds.firstNode(); - var lastNode = bounds.lastNode(); - return { - parentElement, - firstNode, - lastNode - }; + commit() { + this.reset(); } - createElement(tagName) { - return this._env.getAppendOperations().createElement(tagName); + capture() { + return this.captureRefs(this.roots); } - _renderRoot(root) { + createPath(pathRef, name, type, parentRef) { + (true && !(!this.pathNodes.has(pathRef)) && (0, _debug.assert)('BUG: Attempted to register a path that had already been registered', !this.pathNodes.has(pathRef))); var { - _roots: roots - } = this; - roots.push(root); + current + } = this.stack; - if (roots.length === 1) { - register(this); + if (current === null) { + // Not currently in a rendering context, don't register the node + return; } - this._renderRootsTransaction(); - } - - _renderRoots() { - var { - _roots: roots, - _env: env, - _removedRoots: removedRoots - } = this; - var initialRootsLength; - - do { - env.begin(); - - try { - // ensure that for the first iteration of the loop - // each root is processed - initialRootsLength = roots.length; - - for (var i = 0; i < roots.length; i++) { - var root = roots[i]; - - if (root.destroyed) { - // add to the list of roots to be removed - // they will be removed from `this._roots` later - removedRoots.push(root); // skip over roots that have been marked as destroyed - - continue; - } // when processing non-initial reflush loops, - // do not process more roots than needed - - - if (i >= initialRootsLength) { - continue; - } - - if (true - /* DEBUG */ - ) { - // run in an autotracking transaction to prevent backflow errors. - // we use `bind` here to avoid creating a closure (and requiring a - // hoisted variable). - (0, _metal.runInAutotrackingTransaction)(root.render.bind(root)); - } else { - root.render(); - } - } + var currentNode = (0, _util.expect)(this.nodes.get(current), 'BUG: Attempted to create a path, but there is no current render node'); + var parent; - this._lastRevision = (0, _reference.value)(_reference.CURRENT_TAG); - } finally { - env.commit(); + if (parentRef === null) { + parent = currentNode; + } else { + var { + named + } = currentNode.args; + var refIndex = named.references.indexOf(parentRef); + + if (refIndex !== -1) { + parent = { + parent: currentNode, + type: 'argument', + name: `@${named.names[refIndex]}`, + paths: new Set() + }; + } else if (this.pathNodes.has(parentRef)) { + parent = this.pathNodes.get(parentRef); + } else { + // Some RootReferences get created before a component context has been + // setup (root, curly). This is mainly because the debugRenderTree is + // tied to the manager hooks, and not built into the VM directly. In + // these cases, we setup the path lazily when the first property is + // accessed. + this.createPath(parentRef, 'this', 'root', null); + parent = this.pathNodes.get(parentRef); } - } while (roots.length > initialRootsLength); // remove any roots that were destroyed during this transaction - - - while (removedRoots.length) { - var _root = removedRoots.pop(); - - var rootIndex = roots.indexOf(_root); - roots.splice(rootIndex, 1); } - if (this._roots.length === 0) { - deregister(this); - } + var pathNode = { + name, + type, + parent, + paths: new Set() + }; + parent.paths.add(pathNode); + this.pathNodes.set(pathRef, pathNode); } - _renderRootsTransaction() { - if (this._isRenderingRoots) { - // currently rendering roots, a new root was added and will - // be processed by the existing _renderRoots invocation - return; - } // used to prevent calling _renderRoots again (see above) - // while we are actively rendering roots - - - this._isRenderingRoots = true; - var completedWithoutError = false; - - try { - this._renderRoots(); - - completedWithoutError = true; - } finally { - if (!completedWithoutError) { - this._lastRevision = (0, _reference.value)(_reference.CURRENT_TAG); + logRenderStackForPath(pathRef) { + var node = (0, _util.expect)(this.pathNodes.get(pathRef), 'BUG: Attempted to create a log for a path reference, but no node exist for that reference'); + var pathParts = []; - if (this._env.inTransaction === true) { - this._env.commit(); - } + while (node !== undefined && isPathNode(node)) { + if (node.type === 'iterator') { + // Iterator items are a combination of their own name (the key of the item) and + // their parent, the iterable itself. + var part = `${node.parent.name}[${node.name}]`; + pathParts.push(part); + node = node.parent; + } else { + pathParts.unshift(node.name); } - this._isRenderingRoots = false; + node = node.parent; } - } - - _clearAllRoots() { - var roots = this._roots; - for (var i = 0; i < roots.length; i++) { - var root = roots[i]; - root.destroy(); - } + var messageParts = [pathParts.join('.')]; - this._removedRoots.length = 0; - this._roots = []; // if roots were present before destroying - // deregister this renderer instance + while (node !== undefined) { + if (node.type === 'outlet' || node.name === '-top-level') { + node = node.parent; + continue; + } - if (roots.length) { - deregister(this); + messageParts.unshift(node.name); + node = node.parent; } - } - - _scheduleRevalidate() { - _runloop.backburner.scheduleOnce('render', this, this._revalidate); - } - _isValid() { - return this._destroyed || this._roots.length === 0 || (0, _reference.validate)(_reference.CURRENT_TAG, this._lastRevision); + return messageParts.map((part, index) => `${repeatString(' ', index * 2)}${part}`).join('\n'); } - _revalidate() { - if (this._isValid()) { - return; + reset() { + if (this.stack.size !== 0) { + // We probably encountered an error during the rendering loop. This will + // likely trigger undefined behavior and memory leaks as the error left + // things in an inconsistent state. It is recommended that the user + // refresh the page. + // TODO: We could warn here? But this happens all the time in our tests? + while (!this.stack.isEmpty()) { + this.stack.pop(); + } } - - this._renderRootsTransaction(); } - } - - _exports.Renderer = Renderer; - - class InertRenderer extends Renderer { - static create({ - env, - rootTemplate, - _viewRegistry, - builder - }) { - return new this(env, rootTemplate, _viewRegistry, false, builder); - } - - getElement(_view) { - throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).'); + enter(state) { + this.stack.push(state); } - } - - _exports.InertRenderer = InertRenderer; - - class InteractiveRenderer extends Renderer { - static create({ - env, - rootTemplate, - _viewRegistry, - builder - }) { - return new this(env, rootTemplate, _viewRegistry, true, builder); + exit() { + (true && !(this.stack.size !== 0) && (0, _debug.assert)('BUG: unbalanced pop', this.stack.size !== 0)); + this.stack.pop(); } - getElement(view) { - return (0, _views.getViewElement)(view); + nodeFor(state) { + return (0, _util.expect)(this.nodes.get(state), 'BUG: missing node'); } - } - - _exports.InteractiveRenderer = InteractiveRenderer; - var TEMPLATES = {}; - - function setTemplates(templates) { - TEMPLATES = templates; - } - - function getTemplates() { - return TEMPLATES; - } + appendChild(node, state) { + (true && !(!this.refs.has(state)) && (0, _debug.assert)('BUG: child already appended', !this.refs.has(state))); + var parent = this.stack.current; + var ref = new Ref(state); + this.refs.set(state, ref); - function getTemplate(name) { - if (TEMPLATES.hasOwnProperty(name)) { - return TEMPLATES[name]; + if (parent) { + var parentNode = this.nodeFor(parent); + parentNode.refs.add(ref); + node.parent = parentNode; + } else { + this.roots.add(ref); + } } - } - - function hasTemplate(name) { - return TEMPLATES.hasOwnProperty(name); - } - function setTemplate(name, template) { - return TEMPLATES[name] = template; - } + captureRefs(refs) { + var captured = []; + refs.forEach(ref => { + var state = ref.get(); - class InternalComponentDefinition { - constructor(manager, ComponentClass, layout) { - this.manager = manager; - this.state = { - ComponentClass, - layout - }; + if (state) { + captured.push(this.captureNode(`render-node:${ref.id}`, state)); + } else { + refs.delete(ref); + } + }); + return captured; } - } - - class InternalManager extends AbstractManager { - constructor(owner) { - super(); - this.owner = owner; + captureNode(id, state) { + var node = this.nodeFor(state); + var { + type, + name, + args, + instance, + refs + } = node; + var template = this.captureTemplate(node); + var bounds = this.captureBounds(node); + var children = this.captureRefs(refs); + return { + id, + type, + name, + args: args.value(), + instance, + template, + bounds, + children + }; } - getLayout({ - layout: _layout + captureTemplate({ + template }) { - var layout = _layout.asLayout(); + return template && (0, _opcodeCompiler.unwrapTemplate)(template).referrer.moduleName || null; + } + captureBounds(node) { + var bounds = (0, _util.expect)(node.bounds, 'BUG: missing bounds'); + var parentElement = bounds.parentElement(); + var firstNode = bounds.firstNode(); + var lastNode = bounds.lastNode(); return { - handle: layout.compile(), - symbolTable: layout.symbolTable + parentElement, + firstNode, + lastNode }; } } - - var CAPABILITIES$1 = { - dynamicLayout: false, - dynamicTag: false, - prepareArgs: true, - createArgs: true, - attributeHook: false, - elementHook: false, - createCaller: true, - dynamicScope: false, - updateHook: true, - createInstance: true - }; - var EMPTY_POSITIONAL_ARGS$1 = []; - (0, _debug.debugFreeze)(EMPTY_POSITIONAL_ARGS$1); - - class InputComponentManager extends InternalManager { - getCapabilities() { - return CAPABILITIES$1; - } - - prepareArgs(_state, args) { - (true && !(args.positional.length === 0) && (0, _debug.assert)('The `` component does not take any positional arguments', args.positional.length === 0)); - var __ARGS__ = args.named.capture().map; - return { - positional: EMPTY_POSITIONAL_ARGS$1, - named: { - __ARGS__: new RootReference(__ARGS__), - type: args.named.get('type') - } - }; - } - - create(env, { - ComponentClass, - layout - }, args, _dynamicScope, caller) { - (true && !((0, _reference.isConst)(caller)) && (0, _debug.assert)('caller must be const', (0, _reference.isConst)(caller))); - var type = args.named.get('type'); - var instance = ComponentClass.create({ - caller: caller.value(), - type: type.value() - }); - var state = { - env, - type, - instance - }; - - if (_environment2.ENV._DEBUG_RENDER_TREE) { - env.debugRenderTree.create(state, { - type: 'component', - name: 'input', - args: args.capture(), - instance, - template: layout - }); - } - - return state; - } - - getSelf({ - env, - instance - }) { - return new RootReference(instance, env); - } - - getTag() { - if (_environment2.ENV._DEBUG_RENDER_TREE) { - // returning a const tag skips the update hook (VM BUG?) - return (0, _reference.createTag)(); - } else { - // an outlet has no hooks - return _reference.CONSTANT_TAG; - } - } - - didRenderLayout(state, bounds) { - if (_environment2.ENV._DEBUG_RENDER_TREE) { - state.env.debugRenderTree.didRender(state, bounds); - } - } - - update(state) { - (0, _metal.set)(state.instance, 'type', state.type.value()); - - if (_environment2.ENV._DEBUG_RENDER_TREE) { - state.env.debugRenderTree.update(state); - } - } - - didUpdateLayout(state, bounds) { - if (_environment2.ENV._DEBUG_RENDER_TREE) { - state.env.debugRenderTree.didRender(state, bounds); - } - } - - getDestructor(state) { - if (_environment2.ENV._DEBUG_RENDER_TREE) { - return { - destroy() { - state.env.debugRenderTree.willDestroy(state); - state.instance.destroy(); - } - - }; - } else { - return state.instance; - } - } - - } - - var InputComponentManagerFactory = owner => { - return new InputComponentManager(owner); - }; - - var MANAGERS = new WeakMap(); - var getPrototypeOf = Object.getPrototypeOf; - - function setManager(wrapper, obj) { - MANAGERS.set(obj, wrapper); - return obj; - } - - function getManager(obj) { - var pointer = obj; - - while (pointer !== undefined && pointer !== null) { - var manager = MANAGERS.get(pointer); - - if (manager !== undefined) { - return manager; - } - - pointer = getPrototypeOf(pointer); - } - - return null; - } - /** - @module @ember/component - */ - - /** - See [Ember.Templates.components.Input](/ember/release/classes/Ember.Templates.components/methods/Input?anchor=Input). - - @method input - @for Ember.Templates.helpers - @param {Hash} options - @public - */ + /** + @module ember + */ /** - The `Input` component lets you create an HTML `` element. - - ```handlebars - - ``` + The `{{#each}}` helper loops over elements in a collection. It is an extension + of the base Handlebars `{{#each}}` helper. - creates an `` element with `type="text"` and value set to 987. + The default behavior of `{{#each}}` is to yield its inner block once for every + item in an array passing the item as the first block parameter. - ### Text field + Assuming the `@developers` argument contains this array: - If no `type` argument is specified, a default of type 'text' is used. + ```javascript + [{ name: 'Yehuda' },{ name: 'Tom' }, { name: 'Paul' }]; + ``` ```handlebars - Search: - +
    + {{#each @developers as |person|}} +
  • Hello, {{person.name}}!
  • + {{/each}} +
``` - In this example, the initial value in the `` will be set to the value of - `this.searchWord`. If the user changes the text, the value of `this.searchWord` will also be - updated. - - ### Actions - - The `Input` component takes a number of arguments with callbacks that are invoked in response to - user events. - - * `enter` - * `insert-newline` - * `escape-press` - * `focus-in` - * `focus-out` - * `key-press` - * `key-up` + The same rules apply to arrays of primitives. - These callbacks are passed to `Input` like this: + ```javascript + ['Yehuda', 'Tom', 'Paul'] + ``` ```handlebars - +
    + {{#each @developerNames as |name|}} +
  • Hello, {{name}}!
  • + {{/each}} +
``` - ### `` HTML Attributes to Avoid - - In most cases, if you want to pass an attribute to the underlying HTML `` element, you - can pass the attribute directly, just like any other Ember component. + During iteration, the index of each item in the array is provided as a second block + parameter. ```handlebars - +
    + {{#each @developers as |person index|}} +
  • Hello, {{person.name}}! You're number {{index}} in line
  • + {{/each}} +
``` - In this example, the `size` attribute will be applied to the underlying `` element in the - outputted HTML. - - However, there are a few attributes where you **must** use the `@` version. + ### Specifying Keys - * `@type`: This argument is used to control which Ember component is used under the hood - * `@value`: The `@value` argument installs a two-way binding onto the element. If you wanted a - one-way binding, use `` with the `value` property and the `input` event instead. - * `@checked` (for checkboxes): like `@value`, the `@checked` argument installs a two-way binding - onto the element. If you wanted a one-way binding, use `` with - `checked` and the `input` event instead. + In order to improve rendering speed, Ember will try to reuse the DOM elements + where possible. Specifically, if the same item is present in the array both + before and after the change, its DOM output will be reused. - ### Extending `TextField` + The `key` option is used to tell Ember how to determine if the items in the + array being iterated over with `{{#each}}` has changed between renders. By + default the item's object identity is used. - Internally, `` creates an instance of `TextField`, passing arguments from - the helper to `TextField`'s `create` method. Subclassing `TextField` is supported but not - recommended. + This is usually sufficient, so in most cases, the `key` option is simply not + needed. However, in some rare cases, the objects' identities may change even + though they represent the same underlying data. - See [TextField](/ember/release/classes/TextField) + For example: - ### Checkbox + ```javascript + people.map(person => { + return { ...person, type: 'developer' }; + }); + ``` - To create an ``: + In this case, each time the `people` array is `map`-ed over, it will produce + an new array with completely different objects between renders. In these cases, + you can help Ember determine how these objects related to each other with the + `key` option: ```handlebars - Emberize Everything: - +
    + {{#each @developers key="name" as |person|}} +
  • Hello, {{person.name}}!
  • + {{/each}} +
``` - This will bind the checked state of this checkbox to the value of `isEmberized` -- if either one - changes, it will be reflected in the other. + By doing so, Ember will use the value of the property specified (`person.name` + in the example) to find a "match" from the previous render. That is, if Ember + has previously seen an object from the `@developers` array with a matching + name, its DOM elements will be re-used. - ### Extending `Checkbox` + ### {{else}} condition - Internally, `` creates an instance of `Checkbox`. Subclassing - `TextField` is supported but not recommended. + `{{#each}}` can have a matching `{{else}}`. The contents of this block will render + if the collection is empty. - See [Checkbox](/ember/release/classes/Checkbox) + ```handlebars +
    + {{#each @developers as |person|}} +
  • {{person.name}} is available!
  • + {{else}} +
  • Sorry, nobody is available for this task.
  • + {{/each}} +
+ ``` - @method Input - @for Ember.Templates.components - @see {TextField} - @see {Checkbox} - @param {Hash} options + @method each + @for Ember.Templates.helpers @public - */ - - - var Input = _runtime.Object.extend({ - isCheckbox: (0, _metal.computed)('type', function () { - return this.type === 'checkbox'; - }) - }); - - setManager({ - factory: InputComponentManagerFactory, - internal: true, - type: 'component' - }, Input); - - Input.toString = () => '@ember/component/input'; /// - - /** - @module ember - */ + */ /** - Calls [String.loc](/ember/release/classes/String/methods/loc?anchor=loc) with the - provided string. This is a convenient way to localize text within a template. - For example: + The `{{each-in}}` helper loops over properties on an object. - ```javascript - Ember.STRINGS = { - '_welcome_': 'Bonjour' - }; - ``` + For example, given this component definition: - ```handlebars -
- {{loc '_welcome_'}} -
+ ```app/components/developer-details.js + import Component from '@glimmer/component'; + import { tracked } from '@glimmer/tracking'; + + export default class extends Component { + @tracked developer = { + "name": "Shelly Sails", + "age": 42 + }; + } ``` - ```html -
- Bonjour -
+ This template would display all properties on the `developer` + object in a list: + + ```app/components/developer-details.hbs +
    + {{#each-in this.developer as |key value|}} +
  • {{key}}: {{value}}
  • + {{/each-in}} +
``` - See [String.loc](/ember/release/classes/String/methods/loc?anchor=loc) for how to - set up localized string references. + Outputting their name and age. - @method loc + @method each-in @for Ember.Templates.helpers - @param {String} str The string to format. - @see {String#loc} @public + @since 2.1.0 */ - var loc$1 = helper(function (params) { - return _string.loc.apply(null, params - /* let the other side handle errors */ - ); - }); + class EachInReference { + constructor(inner) { + this.inner = inner; + this.valueTag = (0, _validator.createUpdatableTag)(); + this.tag = (0, _validator.combine)([inner.tag, this.valueTag]); + } - class CompileTimeLookup { - constructor(resolver) { - this.resolver = resolver; + value() { + var iterable = this.inner.value(); + var tag = (0, _metal.tagForObject)(iterable); + + if ((0, _utils.isProxy)(iterable)) { + // this is because the each-in doesn't actually get(proxy, 'key') but bypasses it + // and the proxy's tag is lazy updated on access + iterable = (0, _runtime._contentFor)(iterable); + } + + (0, _validator.update)(this.valueTag, tag); + return new EachInWrapper(iterable); } - getCapabilities(handle) { - var definition = this.resolver.resolve(handle); - var { - manager, - state - } = definition; - return manager.getCapabilities(state); + get(key) { + return this.inner.get(key); + } + + } + + class EachInWrapper { + constructor(inner) { + this.inner = inner; + } + + } + + function eachIn(args) { + return new EachInReference(args.positional.at(0)); + } + + function toIterator(iterable) { + if (iterable instanceof EachInWrapper) { + return toEachInIterator(iterable.inner); + } else { + return toEachIterator(iterable); + } + } + + function toEachInIterator(iterable) { + if (!isIndexable(iterable)) { + return null; + } + + if (Array.isArray(iterable) || (0, _utils.isEmberArray)(iterable)) { + return ObjectIterator.fromIndexable(iterable); + } else if (_utils.HAS_NATIVE_SYMBOL && isNativeIterable(iterable)) { + return MapLikeNativeIterator.from(iterable); + } else if (hasForEach(iterable)) { + return ObjectIterator.fromForEachable(iterable); + } else { + return ObjectIterator.fromIndexable(iterable); + } + } + + function toEachIterator(iterable) { + if (!(0, _utils.isObject)(iterable)) { + return null; + } + + if (Array.isArray(iterable)) { + return ArrayIterator.from(iterable); + } else if ((0, _utils.isEmberArray)(iterable)) { + return EmberArrayIterator.from(iterable); + } else if (_utils.HAS_NATIVE_SYMBOL && isNativeIterable(iterable)) { + return ArrayLikeNativeIterator.from(iterable); + } else if (hasForEach(iterable)) { + return ArrayIterator.fromForEachable(iterable); + } else { + return null; + } + } + + class BoundedIterator { + constructor(length) { + this.length = length; + this.position = 0; + } + + isEmpty() { + return false; + } + + memoFor(position) { + return position; } - getLayout(handle) { + next() { var { - manager, - state - } = this.resolver.resolve(handle); - var capabilities = manager.getCapabilities(state); + length, + position + } = this; - if (capabilities.dynamicLayout) { + if (position >= length) { return null; } - var invocation = manager.getLayout(state, this.resolver); + var value$$1 = this.valueFor(position); + var memo = this.memoFor(position); + this.position++; return { - // TODO: this seems weird, it already is compiled - compile() { - return invocation.handle; - }, - - symbolTable: invocation.symbolTable + value: value$$1, + memo }; } - lookupHelper(name, referrer) { - return this.resolver.lookupHelper(name, referrer); + } + + class ArrayIterator extends BoundedIterator { + constructor(array) { + super(array.length); + this.array = array; } - lookupModifier(name, referrer) { - return this.resolver.lookupModifier(name, referrer); + static from(iterable) { + return iterable.length > 0 ? new this(iterable) : null; } - lookupComponentDefinition(name, referrer) { - return this.resolver.lookupComponentHandle(name, referrer); + static fromForEachable(object) { + var array = []; + object.forEach(item => array.push(item)); + return this.from(array); } - lookupPartial(name, referrer) { - return this.resolver.lookupPartial(name, referrer); + valueFor(position) { + return this.array[position]; } } - var CAPABILITIES$2 = { - dynamicLayout: false, - dynamicTag: false, - prepareArgs: false, - createArgs: true, - attributeHook: false, - elementHook: false, - createCaller: false, - dynamicScope: true, - updateHook: true, - createInstance: true - }; + class EmberArrayIterator extends BoundedIterator { + constructor(array) { + super(array.length); + this.array = array; + } - function capabilities(managerAPI, options = {}) { - (true && !(managerAPI === '3.4' || managerAPI === '3.13') && (0, _debug.assert)('Invalid component manager compatibility specified', managerAPI === '3.4' || managerAPI === '3.13')); - var updateHook = true; - { - updateHook = managerAPI === '3.13' ? Boolean(options.updateHook) : true; + static from(iterable) { + return iterable.length > 0 ? new this(iterable) : null; } - return { - asyncLifeCycleCallbacks: Boolean(options.asyncLifecycleCallbacks), - destructor: Boolean(options.destructor), - updateHook - }; - } - function hasAsyncLifeCycleCallbacks(delegate) { - return delegate.capabilities.asyncLifeCycleCallbacks; - } + valueFor(position) { + return (0, _metal.objectAt)(this.array, position); + } - function hasUpdateHook(delegate) { - return delegate.capabilities.updateHook; } - function hasAsyncUpdateHook(delegate) { - return hasAsyncLifeCycleCallbacks(delegate) && hasUpdateHook(delegate); - } + class ObjectIterator extends BoundedIterator { + constructor(keys, values) { + super(values.length); + this.keys = keys; + this.values = values; + } - function hasDestructors(delegate) { - return delegate.capabilities.destructor; - } - /** - The CustomComponentManager allows addons to provide custom component - implementations that integrate seamlessly into Ember. This is accomplished - through a delegate, registered with the custom component manager, which - implements a set of hooks that determine component behavior. - - To create a custom component manager, instantiate a new CustomComponentManager - class and pass the delegate as the first argument: - - ```js - let manager = new CustomComponentManager({ - // ...delegate implementation... - }); - ``` - - ## Delegate Hooks - - Throughout the lifecycle of a component, the component manager will invoke - delegate hooks that are responsible for surfacing those lifecycle changes to - the end developer. - - * `create()` - invoked when a new instance of a component should be created - * `update()` - invoked when the arguments passed to a component change - * `getContext()` - returns the object that should be - */ + static fromIndexable(obj) { + var keys = Object.keys(obj); + var { + length + } = keys; + if (length === 0) { + return null; + } else { + var values = []; - class CustomComponentManager extends AbstractManager { - create(env, definition, args) { - var { - delegate - } = definition; - var capturedArgs = args.capture(); + for (var _i8 = 0; _i8 < length; _i8++) { + var value$$1 = void 0; + var key = keys[_i8]; + value$$1 = obj[key]; // Add the tag of the returned value if it is an array, since arrays + // should always cause updates if they are consumed and then changed + + if ((0, _validator.isTracking)()) { + (0, _validator.consume)((0, _metal.tagForProperty)(obj, key)); + + if (Array.isArray(value$$1) || (0, _utils.isEmberArray)(value$$1)) { + (0, _validator.consume)((0, _metal.tagForProperty)(value$$1, '[]')); + } + } + + values.push(value$$1); + } + + return new this(keys, values); + } + } + + static fromForEachable(obj) { + var keys = []; + var values = []; + var length = 0; + var isMapLike = false; // Not using an arrow function here so we can get an accurate `arguments` + + obj.forEach(function (value$$1, key) { + isMapLike = isMapLike || arguments.length >= 2; + + if (isMapLike) { + keys.push(key); + } + + values.push(value$$1); + length++; + }); + + if (length === 0) { + return null; + } else if (isMapLike) { + return new this(keys, values); + } else { + return new ArrayIterator(values); + } + } + + valueFor(position) { + return this.values[position]; + } + + memoFor(position) { + return this.keys[position]; + } + + } + + class NativeIterator { + constructor(iterable, result) { + this.iterable = iterable; + this.result = result; + this.position = 0; + } + + static from(iterable) { + var iterator = iterable[Symbol.iterator](); + var result = iterator.next(); + var { + done + } = result; + + if (done) { + return null; + } else { + return new this(iterator, result); + } + } + + isEmpty() { + return false; + } + + next() { + var { + iterable, + result, + position + } = this; + + if (result.done) { + return null; + } + + var value$$1 = this.valueFor(result, position); + var memo = this.memoFor(result, position); + this.position++; + this.result = iterable.next(); + return { + value: value$$1, + memo + }; + } + + } + + class ArrayLikeNativeIterator extends NativeIterator { + valueFor(result) { + return result.value; + } + + memoFor(_result, position) { + return position; + } + + } + + class MapLikeNativeIterator extends NativeIterator { + valueFor(result) { + return result.value[1]; + } + + memoFor(result) { + return result.value[0]; + } + + } + + function hasForEach(value$$1) { + return typeof value$$1['forEach'] === 'function'; + } + + function isNativeIterable(value$$1) { + return typeof value$$1[Symbol.iterator] === 'function'; + } + + function isIndexable(value$$1) { + return value$$1 !== null && (typeof value$$1 === 'object' || typeof value$$1 === 'function'); + } + + function toBool(predicate) { + if ((0, _utils.isProxy)(predicate)) { + return Boolean((0, _metal.get)(predicate, 'isTruthy')); + } else if ((0, _runtime.isArray)(predicate)) { + return predicate.length !== 0; + } else { + return Boolean(predicate); + } + } + + class EmberEnvironmentExtra { + constructor(owner) { + this.owner = owner; + + if (_environment2.ENV._DEBUG_RENDER_TREE) { + this._debugRenderTree = new DebugRenderTree(); + } + } + + get debugRenderTree() { + if (_environment2.ENV._DEBUG_RENDER_TREE) { + return this._debugRenderTree; + } else { + throw new Error("Can't access debug render tree outside of the inspector (_DEBUG_RENDER_TREE flag is disabled)"); + } + } + + begin() { + if (_environment2.ENV._DEBUG_RENDER_TREE) { + this.debugRenderTree.begin(); + } + } + + commit() { + if (_environment2.ENV._DEBUG_RENDER_TREE) { + this.debugRenderTree.commit(); + } + } + + } + + class EmberEnvironmentDelegate { + constructor(owner, isInteractive) { + this.toBool = toBool; + this.toIterator = toIterator; + this.getPath = _metal.get; + this.setPath = _metal.set; + this.extra = new EmberEnvironmentExtra(owner); + this.isInteractive = isInteractive; + installProtocolForURL(this); + } // this gets clobbered by installPlatformSpecificProtocolForURL + // it really should just delegate to a platform specific injection + + + protocolForURL(s) { + return s; + } + + getTemplatePathDebugContext(pathRef) { + var stack = this.extra.debugRenderTree.logRenderStackForPath(pathRef); + return `While rendering:\n\n${stack}`; + } + + setTemplatePathDebugContext(pathRef, desc, parentRef) { + var type = 'root'; + + if (pathRef instanceof _reference.IterationItemReference) { + type = 'iterator'; + } else if (pathRef instanceof _reference.PropertyReference) { + type = 'property'; + } + + this.extra.debugRenderTree.createPath(pathRef, desc, type, parentRef); + } + + onTransactionBegin() { + this.extra.begin(); + } + + onTransactionCommit() { + this.extra.commit(); + } + + } + + if (true + /* DEBUG */ + ) { + class StyleAttributeManager extends _runtime2.SimpleDynamicAttribute { + set(dom, value$$1, env) { + (true && (0, _debug.warn)((0, _views.constructStyleDeprecationMessage)(value$$1), (() => { + if (value$$1 === null || value$$1 === undefined || isHTMLSafe(value$$1)) { + return true; + } + + return false; + })(), { + id: 'ember-htmlbars.style-xss-warning' + })); + super.set(dom, value$$1, env); + } + + update(value$$1, env) { + (true && (0, _debug.warn)((0, _views.constructStyleDeprecationMessage)(value$$1), (() => { + if (value$$1 === null || value$$1 === undefined || isHTMLSafe(value$$1)) { + return true; + } + + return false; + })(), { + id: 'ember-htmlbars.style-xss-warning' + })); + super.update(value$$1, env); + } + + } + + EmberEnvironmentDelegate.prototype.attributeFor = function (element, attribute, isTrusting, namespace) { + if (attribute === 'style' && !isTrusting) { + return new StyleAttributeManager({ + element, + name: attribute, + namespace + }); + } + + return (0, _runtime2.dynamicAttribute)(element, attribute, namespace); + }; + } + + var CAPABILITIES$1 = { + dynamicLayout: false, + dynamicTag: false, + prepareArgs: false, + createArgs: true, + attributeHook: false, + elementHook: false, + createCaller: false, + dynamicScope: true, + updateHook: true, + createInstance: true, + wrapped: false, + willDestroy: false + }; + + function capabilities(managerAPI, options = {}) { + (true && !(managerAPI === '3.4' || managerAPI === '3.13') && (0, _debug.assert)('Invalid component manager compatibility specified', managerAPI === '3.4' || managerAPI === '3.13')); + var updateHook = true; + { + updateHook = managerAPI === '3.13' ? Boolean(options.updateHook) : true; + } + return { + asyncLifeCycleCallbacks: Boolean(options.asyncLifecycleCallbacks), + destructor: Boolean(options.destructor), + updateHook + }; + } + + function hasAsyncLifeCycleCallbacks(delegate) { + return delegate.capabilities.asyncLifeCycleCallbacks; + } + + function hasUpdateHook(delegate) { + return delegate.capabilities.updateHook; + } + + function hasAsyncUpdateHook(delegate) { + return hasAsyncLifeCycleCallbacks(delegate) && hasUpdateHook(delegate); + } + + function hasDestructors(delegate) { + return delegate.capabilities.destructor; + } + /** + The CustomComponentManager allows addons to provide custom component + implementations that integrate seamlessly into Ember. This is accomplished + through a delegate, registered with the custom component manager, which + implements a set of hooks that determine component behavior. + + To create a custom component manager, instantiate a new CustomComponentManager + class and pass the delegate as the first argument: + + ```js + let manager = new CustomComponentManager({ + // ...delegate implementation... + }); + ``` + + ## Delegate Hooks + + Throughout the lifecycle of a component, the component manager will invoke + delegate hooks that are responsible for surfacing those lifecycle changes to + the end developer. + + * `create()` - invoked when a new instance of a component should be created + * `update()` - invoked when the arguments passed to a component change + * `getContext()` - returns the object that should be + */ + + + class CustomComponentManager extends AbstractManager { + create(env, definition, args) { + var { + delegate + } = definition; + var capturedArgs = args.capture(); var namedArgs = capturedArgs.named; var value$$1; var namedArgsProxy = {}; @@ -10229,7 +9218,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol get(_target, prop) { if (namedArgs.has(prop)) { var ref = namedArgs.get(prop); - (0, _metal.consume)(ref.tag); + (0, _validator.consume)(ref.tag); return ref.value(); } else if (prop === _metal.CUSTOM_TAG_FOR) { return getTag; @@ -10258,7 +9247,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol /* DEBUG */ ) { handler.set = function (_target, prop) { - (true && !(false) && (0, _debug.assert)("You attempted to set " + definition.ComponentClass.class + "#" + String(prop) + " on a components arguments. Component arguments are immutable and cannot be updated directly, they always represent the values that are passed to your component. If you want to set default values, you should use a getter instead")); + (true && !(false) && (0, _debug.assert)(`You attempted to set ${definition.ComponentClass.class}#${String(prop)} on a components arguments. Component arguments are immutable and cannot be updated directly, they always represent the values that are passed to your component. If you want to set default values, you should use a getter instead`)); return false; }; } @@ -10277,7 +9266,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol get() { var ref = namedArgs.get(name); - (0, _metal.consume)(ref.tag); + (0, _validator.consume)(ref.tag); return ref.value(); } @@ -10294,7 +9283,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var bucket = new CustomComponentState(delegate, component, capturedArgs, env, namedArgsProxy); if (_environment2.ENV._DEBUG_RENDER_TREE) { - env.debugRenderTree.create(bucket, { + env.extra.debugRenderTree.create(bucket, { type: 'component', name: definition.name, args: args.capture(), @@ -10308,7 +9297,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol update(bucket) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.env.debugRenderTree.update(bucket); + bucket.env.extra.debugRenderTree.update(bucket); } var { @@ -10360,7 +9349,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol delegate, component }) { - return RootReference.create(delegate.getContext(component), env); + return new _reference.ComponentRootReference(delegate.getContext(component), env); } getDestructor(state) { @@ -10374,7 +9363,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var inner = destructor; destructor = { destroy() { - state.env.debugRenderTree.willDestroy(state); + state.env.extra.debugRenderTree.willDestroy(state); if (inner) { inner.destroy(); @@ -10390,7 +9379,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol getCapabilities({ delegate }) { - return (0, _polyfills.assign)({}, CAPABILITIES$2, { + return (0, _polyfills.assign)({}, CAPABILITIES$1, { updateHook: _environment2.ENV._DEBUG_RENDER_TREE || delegate.capabilities.updateHook }); } @@ -10398,9 +9387,9 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol getTag({ args }) { - if ((0, _reference.isConst)(args)) { + if ((0, _validator.isConst)(args)) { // returning a const tag skips the update hook (VM BUG?) - return (0, _reference.createTag)(); + return (0, _validator.createTag)(); } else { return args.tag; } @@ -10408,21 +9397,18 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol didRenderLayout(bucket, bounds) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.env.debugRenderTree.didRender(bucket, bounds); + bucket.env.extra.debugRenderTree.didRender(bucket, bounds); } } didUpdateLayout(bucket, bounds) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.env.debugRenderTree.didRender(bucket, bounds); + bucket.env.extra.debugRenderTree.didRender(bucket, bounds); } } - getLayout(state) { - return { - handle: state.template.asLayout().compile(), - symbolTable: state.symbolTable - }; + getJitStaticLayout(state) { + return (0, _opcodeCompiler.unwrapTemplate)(state.template).asLayout(); } } @@ -10461,21 +9447,42 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this.delegate = delegate; this.template = template; this.manager = CUSTOM_COMPONENT_MANAGER; - var layout = template.asLayout(); - var symbolTable = layout.symbolTable; - this.symbolTable = symbolTable; this.state = { name, ComponentClass, template, - symbolTable, delegate }; } } - var CAPABILITIES$3 = { + class InternalComponentDefinition { + constructor(manager, ComponentClass, layout) { + this.manager = manager; + this.state = { + ComponentClass, + layout + }; + } + + } + + class InternalManager extends AbstractManager { + constructor(owner) { + super(); + this.owner = owner; + } + + getJitStaticLayout({ + layout: template + }) { + return (0, _opcodeCompiler.unwrapTemplate)(template).asLayout(); + } + + } + + var CAPABILITIES$2 = { dynamicLayout: false, dynamicTag: false, prepareArgs: false, @@ -10485,22 +9492,20 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol createCaller: false, dynamicScope: false, updateHook: _environment2.ENV._DEBUG_RENDER_TREE, - createInstance: true + createInstance: true, + wrapped: false, + willDestroy: false }; class TemplateOnlyComponentManager extends AbstractManager { - getLayout({ + getJitStaticLayout({ template }) { - var layout = template.asLayout(); - return { - handle: layout.compile(), - symbolTable: layout.symbolTable - }; + return (0, _opcodeCompiler.unwrapTemplate)(template).asLayout(); } getCapabilities() { - return CAPABILITIES$3; + return CAPABILITIES$2; } create(environment, { @@ -10511,7 +9516,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var bucket = { environment }; - environment.debugRenderTree.create(bucket, { + environment.extra.debugRenderTree.create(bucket, { type: 'component', name: name, args: args.capture(), @@ -10531,10 +9536,10 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol getTag() { if (_environment2.ENV._DEBUG_RENDER_TREE) { // returning a const tag skips the update hook (VM BUG?) - return (0, _reference.createTag)(); + return (0, _validator.createTag)(); } else { // an outlet has no hooks - return _reference.CONSTANT_TAG; + return _validator.CONSTANT_TAG; } } @@ -10542,7 +9547,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol if (_environment2.ENV._DEBUG_RENDER_TREE) { return { destroy() { - bucket.environment.debugRenderTree.willDestroy(bucket); + bucket.environment.extra.debugRenderTree.willDestroy(bucket); } }; @@ -10553,19 +9558,19 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol didRenderLayout(bucket, bounds) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.environment.debugRenderTree.didRender(bucket, bounds); + bucket.environment.extra.debugRenderTree.didRender(bucket, bounds); } } update(bucket) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.environment.debugRenderTree.update(bucket); + bucket.environment.extra.debugRenderTree.update(bucket); } } didUpdateLayout(bucket, bounds) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.environment.debugRenderTree.didRender(bucket, bounds); + bucket.environment.extra.debugRenderTree.didRender(bucket, bounds); } } @@ -10610,41 +9615,22 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } - helper$1 = (_vm, args) => new ComponentAssertionReference(args.positional.at(0), args.positional.at(1).value()); + helper$1 = args => new ComponentAssertionReference(args.positional.at(0), args.positional.at(1).value()); } else { - helper$1 = (_vm, args) => args.positional.at(0); + helper$1 = args => args.positional.at(0); } var componentAssertionHelper = helper$1; - function classHelper({ + function i({ positional }) { - var path = positional.at(0); - var args = positional.length; - var value$$1 = path.value(); - - if (value$$1 === true) { - if (args > 1) { - return (0, _string.dasherize)(positional.at(1).value()); - } - - return null; - } - - if (value$$1 === false) { - if (args > 2) { - return (0, _string.dasherize)(positional.at(2).value()); - } - - return null; - } - - return value$$1; + (true && !(typeof positional.at(0).value() === 'string') && (0, _debug.assert)('[BUG] -i takes a single string', typeof positional.at(0).value() === 'string')); + return parseInt(positional.at(0).value(), 10); } - function classHelper$1(_vm, args) { - return new InternalHelperReference(classHelper, args.capture()); + function parseIntHelper(args, vm) { + return new _reference.HelperRootReference(i, args.capture(), vm.env); } function inputTypeHelper({ @@ -10659,8 +9645,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return '-text-field'; } - function inputTypeHelper$1(_vm, args) { - return new InternalHelperReference(inputTypeHelper, args.capture()); + function inputTypeHelper$1(args, vm) { + return new _reference.HelperRootReference(inputTypeHelper, args.capture(), vm.env); } function normalizeClass({ @@ -10679,466 +9665,118 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } } - function normalizeClassHelper(_vm, args) { - return new InternalHelperReference(normalizeClass, args.capture()); + function normalizeClassHelper(args, vm) { + return new _reference.HelperRootReference(normalizeClass, args.capture(), vm.env); } /** @module ember */ /** - The `{{action}}` helper provides a way to pass triggers for behavior (usually - just a function) between components, and into components from controllers. - - ### Passing functions with the action helper - - There are three contexts an action helper can be used in. The first two - contexts to discuss are attribute context, and Handlebars value context. - - ```handlebars - {{! An example of attribute context }} -
- {{! Examples of Handlebars value context }} - {{input on-input=(action "save")}} - {{yield (action "refreshData") andAnotherParam}} - ``` - - In these contexts, - the helper is called a "closure action" helper. Its behavior is simple: - If passed a function name, read that function off the `actions` property - of the current context. Once that function is read, or immediately if a function was - passed, create a closure over that function and any arguments. - The resulting value of an action helper used this way is simply a function. - - For example, in the attribute context: - - ```handlebars - {{! An example of attribute context }} -
- ``` - - The resulting template render logic would be: + This reference is used to get the `[]` tag of iterables, so we can trigger + updates to `{{each}}` when it changes. It is put into place by a template + transform at build time, similar to the (-each-in) helper + */ + + + class TrackArrayReference { + constructor(inner) { + this.inner = inner; + this.valueTag = (0, _validator.createUpdatableTag)(); + this.tag = (0, _validator.combine)([inner.tag, this.valueTag]); + } + + value() { + var iterable = this.inner.value(); + var tag = (0, _metal.tagForProperty)(iterable, '[]'); + (0, _validator.update)(this.valueTag, tag); + return iterable; + } + + get(key) { + return this.inner.get(key); + } + + } + + function trackArray(args) { + return new TrackArrayReference(args.positional.at(0)); + } + /** + @module ember + */ + + /** + Use the `{{array}}` helper to create an array to pass as an option to your + components. - ```js - var div = document.createElement('div'); - var actionFunction = (function(context){ - return function() { - return context.actions.save.apply(context, arguments); - }; - })(context); - div.onclick = actionFunction; - ``` + ```handlebars + + ``` + or + ```handlebars + {{my-component people=(array + 'Tom Dade' + 'Yehuda Katz' + this.myOtherPerson) + }} + ``` - Thus when the div is clicked, the action on that context is called. - Because the `actionFunction` is just a function, closure actions can be - passed between components and still execute in the correct context. + Would result in an object such as: - Here is an example action handler on a component: + ```js + ['Tom Date', 'Yehuda Katz', this.get('myOtherPerson')] + ``` - ```app/components/my-component.js - import Component from '@glimmer/component'; - import { action } from '@ember/object'; + Where the 3rd item in the array is bound to updates of the `myOtherPerson` property. - export default class extends Component { - @action - save() { - this.model.save(); - } + @method array + @for Ember.Templates.helpers + @param {Array} options + @return {Array} Array + @since 3.8.0 + @public + */ + + + function array(args) { + return args.positional.capture(); + } + + var isEmpty = value$$1 => { + return value$$1 === null || value$$1 === undefined || typeof value$$1.toString !== 'function'; + }; + + var normalizeTextValue = value$$1 => { + if (isEmpty(value$$1)) { + return ''; } - ``` - - Actions are always looked up on the `actions` property of the current context. - This avoids collisions in the naming of common actions, such as `destroy`. - Two options can be passed to the `action` helper when it is used in this way. - - * `target=someProperty` will look to `someProperty` instead of the current - context for the `actions` hash. This can be useful when targeting a - service for actions. - * `value="target.value"` will read the path `target.value` off the first - argument to the action when it is called and rewrite the first argument - to be that value. This is useful when attaching actions to event listeners. - - ### Invoking an action + + return String(value$$1); + }; + /** + @module ember + */ + + /** + Concatenates the given arguments into a string. - Closure actions curry both their scope and any arguments. When invoked, any - additional arguments are added to the already curried list. - Actions should be invoked using the [sendAction](/ember/release/classes/Component/methods/sendAction?anchor=sendAction) - method. The first argument to `sendAction` is the action to be called, and - additional arguments are passed to the action function. This has interesting - properties combined with currying of arguments. For example: + Example: - ```app/components/update-name.js - import Component from '@glimmer/component'; - import { action } from '@ember/object'; + ```handlebars + {{some-component name=(concat firstName " " lastName)}} - export default class extends Component { - @action - setName(model, name) { - model.set('name', name); - } - } + {{! would pass name=" " to the component}} ``` - ```app/components/update-name.hbs - {{input on-input=(action (action 'setName' @model) value="target.value")}} - ``` - - The first argument (`@model`) was curried over, and the run-time argument (`event`) - becomes a second argument. Action calls can be nested this way because each simply - returns a function. Any function can be passed to the `{{action}}` helper, including - other actions. - - Actions invoked with `sendAction` have the same currying behavior as demonstrated - with `on-input` above. For example: - - ```app/components/my-input.js - import Component from '@glimmer/component'; - import { action } from '@ember/object'; - - export default class extends Component { - @action - setName(model, name) { - model.set('name', name); - } - } - ``` - - ```handlebars - - ``` - - or - - ```handlebars - {{my-input submit=(action 'setName' @model)}} - ``` - - ```app/components/my-component.js - import Component from '@ember/component'; - - export default Component.extend({ - click() { - // Note that model is not passed, it was curried in the template - this.sendAction('submit', 'bob'); - } - }); - ``` - - ### Attaching actions to DOM elements - - The third context of the `{{action}}` helper can be called "element space". - For example: - - ```handlebars - {{! An example of element space }} -
- ``` - - Used this way, the `{{action}}` helper provides a useful shortcut for - registering an HTML element in a template for a single DOM event and - forwarding that interaction to the template's context (controller or component). - If the context of a template is a controller, actions used this way will - bubble to routes when the controller does not implement the specified action. - Once an action hits a route, it will bubble through the route hierarchy. - - ### Event Propagation - - `{{action}}` helpers called in element space can control event bubbling. Note - that the closure style actions cannot. - - Events triggered through the action helper will automatically have - `.preventDefault()` called on them. You do not need to do so in your event - handlers. If you need to allow event propagation (to handle file inputs for - example) you can supply the `preventDefault=false` option to the `{{action}}` helper: - - ```handlebars -
- - -
- ``` - - To disable bubbling, pass `bubbles=false` to the helper: - - ```handlebars - - ``` - - To disable bubbling with closure style actions you must create your own - wrapper helper that makes use of `event.stopPropagation()`: - - ```handlebars -
Hello
- ``` - - ```app/helpers/disable-bubbling.js - import { helper } from '@ember/component/helper'; - - export function disableBubbling([action]) { - return function(event) { - event.stopPropagation(); - return action(event); - }; - } - export default helper(disableBubbling); - ``` - - If you need the default handler to trigger you should either register your - own event handler, or use event methods on your view class. See - ["Responding to Browser Events"](/ember/release/classes/Component) - in the documentation for `Component` for more information. - - ### Specifying DOM event type - - `{{action}}` helpers called in element space can specify an event type. - By default the `{{action}}` helper registers for DOM `click` events. You can - supply an `on` option to the helper to specify a different DOM event name: - - ```handlebars -
- click me -
- ``` - - See ["Event Names"](/ember/release/classes/Component) for a list of - acceptable DOM event names. - - ### Specifying whitelisted modifier keys - - `{{action}}` helpers called in element space can specify modifier keys. - By default the `{{action}}` helper will ignore click events with pressed modifier - keys. You can supply an `allowedKeys` option to specify which keys should not be ignored. - - ```handlebars -
- click me -
- ``` - - This way the action will fire when clicking with the alt key pressed down. - Alternatively, supply "any" to the `allowedKeys` option to accept any combination of modifier keys. - - ```handlebars -
- click me with any key pressed -
- ``` - - ### Specifying a Target - - A `target` option can be provided to the helper to change - which object will receive the method call. This option must be a path - to an object, accessible in the current context: - - ```app/templates/application.hbs -
- click me -
- ``` - - ```app/controllers/application.js - import Controller from '@ember/controller'; - import { inject as service } from '@ember/service'; - - export default class extends Controller { - @service someService; - } - ``` - - @method action - @for Ember.Templates.helpers - @public - */ - - - function action(_vm, args) { - var { - named, - positional - } = args; - var capturedArgs = positional.capture(); // The first two argument slots are reserved. - // pos[0] is the context (or `this`) - // pos[1] is the action name or function - // Anything else is an action argument. - - var [context, action, ...restArgs] = capturedArgs.references; // TODO: Is there a better way of doing this? - - var debugKey = action.propertyKey; - var target = named.has('target') ? named.get('target') : context; - var processArgs = makeArgsProcessor(named.has('value') && named.get('value'), restArgs); - var fn; - - if (typeof action[INVOKE] === 'function') { - fn = makeClosureAction(action, action, action[INVOKE], processArgs, debugKey); - } else if ((0, _reference.isConst)(target) && (0, _reference.isConst)(action)) { - fn = makeClosureAction(context.value(), target.value(), action.value(), processArgs, debugKey); - } else { - fn = makeDynamicClosureAction(context.value(), target, action, processArgs, debugKey); - } - - fn[ACTION] = true; - return new UnboundReference(fn); - } - - function NOOP$1(args) { - return args; - } - - function makeArgsProcessor(valuePathRef, actionArgsRef) { - var mergeArgs; - - if (actionArgsRef.length > 0) { - mergeArgs = args => { - return actionArgsRef.map(ref => ref.value()).concat(args); - }; - } - - var readValue; - - if (valuePathRef) { - readValue = args => { - var valuePath = valuePathRef.value(); - - if (valuePath && args.length > 0) { - args[0] = (0, _metal.get)(args[0], valuePath); - } - - return args; - }; - } - - if (mergeArgs && readValue) { - return args => { - return readValue(mergeArgs(args)); - }; - } else { - return mergeArgs || readValue || NOOP$1; - } - } - - function makeDynamicClosureAction(context, targetRef, actionRef, processArgs, debugKey) { - // We don't allow undefined/null values, so this creates a throw-away action to trigger the assertions - if (true - /* DEBUG */ - ) { - makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey); - } - - return (...args) => { - return makeClosureAction(context, targetRef.value(), actionRef.value(), processArgs, debugKey)(...args); - }; - } - - function makeClosureAction(context, target, action, processArgs, debugKey) { - var self; - var fn; - (true && !(action !== undefined && action !== null) && (0, _debug.assert)("Action passed is null or undefined in (action) from " + target + ".", action !== undefined && action !== null)); - - if (typeof action[INVOKE] === 'function') { - self = action; - fn = action[INVOKE]; - } else { - var typeofAction = typeof action; - - if (typeofAction === 'string') { - self = target; - fn = target.actions && target.actions[action]; - (true && !(fn) && (0, _debug.assert)("An action named '" + action + "' was not found in " + target, fn)); - } else if (typeofAction === 'function') { - self = context; - fn = action; - } else { - // tslint:disable-next-line:max-line-length - (true && !(false) && (0, _debug.assert)("An action could not be made for `" + (debugKey || action) + "` in " + target + ". Please confirm that you are using either a quoted action name (i.e. `(action '" + (debugKey || 'myAction') + "')`) or a function available in " + target + ".", false)); - } - } - - return (...args) => { - var payload = { - target: self, - args, - label: '@glimmer/closure-action' - }; - return (0, _instrumentation.flaggedInstrument)('interaction.ember-action', payload, () => { - return (0, _runloop.join)(self, fn, ...processArgs(args)); - }); - }; - } - /** - @module ember - */ - - /** - Use the `{{array}}` helper to create an array to pass as an option to your - components. - - ```handlebars - - ``` - or - ```handlebars - {{my-component people=(array - 'Tom Dade' - 'Yehuda Katz' - this.myOtherPerson) - }} - ``` - - Would result in an object such as: - - ```js - ['Tom Date', 'Yehuda Katz', this.get('myOtherPerson')] - ``` - - Where the 3rd item in the array is bound to updates of the `myOtherPerson` property. - - @method array - @for Ember.Templates.helpers - @param {Array} options - @return {Array} Array - @since 3.8.0 - @public - */ - - - function array(_vm, args) { - return args.positional.capture(); - } - - var isEmpty = value$$1 => { - return value$$1 === null || value$$1 === undefined || typeof value$$1.toString !== 'function'; - }; - - var normalizeTextValue = value$$1 => { - if (isEmpty(value$$1)) { - return ''; - } - - return String(value$$1); - }; - /** - @module ember - */ - - /** - Concatenates the given arguments into a string. - - Example: - - ```handlebars - {{some-component name=(concat firstName " " lastName)}} - - {{! would pass name=" " to the component}} - ``` - - or for angle bracket invocation, you actually don't need concat at all. - - ```handlebars - + or for angle bracket invocation, you actually don't need concat at all. + + ```handlebars + ``` @public @@ -11154,8 +9792,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return positional.value().map(normalizeTextValue).join(''); } - function concat$1(_vm, args) { - return new InternalHelperReference(concat, args.capture()); + function concat$1(args, vm) { + return new _reference.HelperRootReference(concat, args.capture(), vm.env); } function buildUntouchableThis(source) { @@ -11165,7 +9803,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol /* DEBUG */ && _utils.HAS_NATIVE_PROXY) { var assertOnProperty = property => { - (true && !(false) && (0, _debug.assert)("You accessed `this." + String(property) + "` from a function passed to the " + source + ", but the function itself was not bound to a valid `this` context. Consider updating to usage of `@action`.")); + (true && !(false) && (0, _debug.assert)(`You accessed \`this.${String(property)}\` from a function passed to the ${source}, but the function itself was not bound to a valid \`this\` context. Consider updating to usage of \`@action\`.`)); }; context = new Proxy({}, { @@ -11262,7 +9900,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol @since 3.11.0 */ - function fnHelper({ + function fn({ positional }) { var callbackRef = positional.at(0); @@ -11271,7 +9909,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol /* DEBUG */ && typeof callbackRef[INVOKE] !== 'function') { var callback = callbackRef.value(); - (true && !(typeof callback === 'function') && (0, _debug.assert)("You must pass a function as the `fn` helpers first argument, you passed " + callback, typeof callback === 'function')); + (true && !(typeof callback === 'function') && (0, _debug.assert)(`You must pass a function as the \`fn\` helpers first argument, you passed ${callback}`, typeof callback === 'function')); } return (...invocationArgs) => { @@ -11282,13 +9920,13 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol // the symbol to be bound to the reference return callbackRef[INVOKE](...args, ...invocationArgs); } else { - return fn['call'](context, ...args, ...invocationArgs); + return fn.call(context, ...args, ...invocationArgs); } }; } - function fn(_vm, args) { - return new InternalHelperReference(fnHelper, args.capture()); + function fn$1(args, vm) { + return new _reference.HelperRootReference(fn, args.capture(), vm.env); } /** @module ember @@ -11376,64 +10014,53 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - function get$1(_vm, args) { - return GetHelperReference.create(args.positional.at(0), args.positional.at(1)); - } + function get$1(args, vm) { + var sourceReference = args.positional.at(0); + var pathReference = args.positional.at(1); - function referenceFromPath(source, path) { - var innerReference; + if ((0, _validator.isConst)(pathReference)) { + // Since the path is constant, we can create a normal chain of property + // references. The source reference will update like normal, and all of the + // child references will update accordingly. + var path = pathReference.value(); - if (path === undefined || path === null || path === '') { - innerReference = _runtime2.NULL_REFERENCE; - } else if (typeof path === 'string' && path.indexOf('.') > -1) { - innerReference = referenceFromParts(source, path.split('.')); + if (path === undefined || path === null || path === '') { + return _runtime2.NULL_REFERENCE; + } else if (typeof path === 'string' && path.indexOf('.') > -1) { + return referenceFromParts(sourceReference, path.split('.')); + } else { + return sourceReference.get(String(path)); + } } else { - innerReference = source.get(path); + return new GetHelperRootReference(args.capture(), vm.env); } - - return innerReference; } - class GetHelperReference extends CachedReference$1 { - static create(sourceReference, pathReference) { - if ((0, _reference.isConst)(pathReference)) { - var path = pathReference.value(); - return referenceFromPath(sourceReference, path); - } else { - return new GetHelperReference(sourceReference, pathReference); - } + function get$2({ + positional + }) { + var source = positional.at(0).value(); + + if ((0, _utils.isObject)(source)) { + var path = positional.at(1).value(); + return (0, _metal.get)(source, String(path)); } + } - constructor(sourceReference, pathReference) { - super(); - this.sourceReference = sourceReference; - this.pathReference = pathReference; - this.lastPath = null; - this.innerReference = _runtime2.NULL_REFERENCE; - var innerTag = this.innerTag = (0, _reference.createUpdatableTag)(); - this.tag = (0, _reference.combine)([sourceReference.tag, pathReference.tag, innerTag]); + class GetHelperRootReference extends _reference.HelperRootReference { + constructor(args, env) { + super(get$2, args, env); + this.sourceReference = args.positional.at(0); + this.pathReference = args.positional.at(1); } - compute() { - var { - lastPath, - innerReference, - innerTag - } = this; - var path = this.pathReference.value(); + [_reference.UPDATE_REFERENCED_VALUE](value$$1) { + var source = this.sourceReference.value(); - if (path !== lastPath) { - innerReference = referenceFromPath(this.sourceReference, path); - (0, _reference.update)(innerTag, innerReference.tag); - this.innerReference = innerReference; - this.lastPath = path; + if ((0, _utils.isObject)(source)) { + var path = String(this.pathReference.value()); + (0, _metal.set)(source, path, value$$1); } - - return innerReference.value(); - } - - [UPDATE](value$$1) { - (0, _metal.set)(this.sourceReference.value(), this.pathReference.value(), value$$1); } } @@ -11481,7 +10108,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - function hash(_vm, args) { + function hash(args) { return args.named.capture(); } /** @@ -11489,32 +10116,34 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - class ConditionalHelperReference extends CachedReference$1 { - static create(_condRef, truthyRef, falsyRef) { - var condRef = ConditionalReference$1.create(_condRef); + function ifHelper({ + positional + }) { + (true && !(positional.length === 3 || positional.length === 2) && (0, _debug.assert)('The inline form of the `if` helper expects two or three arguments, e.g. `{{if trialExpired "Expired" expiryDate}}`.', positional.length === 3 || positional.length === 2)); + var condition = positional.at(0); + var truthyValue = positional.at(1); + var falsyValue = positional.at(2); - if ((0, _reference.isConst)(condRef)) { - return condRef.value() ? truthyRef : falsyRef; - } else { - return new ConditionalHelperReference(condRef, truthyRef, falsyRef); - } + if (toBool(condition.value()) === true) { + return truthyValue.value(); + } else { + return falsyValue !== undefined ? falsyValue.value() : undefined; } + } - constructor(cond, truthy, falsy) { - super(); - this.branchTag = (0, _reference.createUpdatableTag)(); - this.tag = (0, _reference.combine)([cond.tag, this.branchTag]); - this.cond = cond; - this.truthy = truthy; - this.falsy = falsy; - } + function unless({ + positional + }) { + (true && !(positional.length === 3 || positional.length === 2) && (0, _debug.assert)('The inline form of the `unless` helper expects two or three arguments, e.g. `{{unless isFirstLogin "Welcome back!"}}`.', positional.length === 3 || positional.length === 2)); + var condition = positional.at(0); + var truthyValue = positional.at(2); + var falsyValue = positional.at(1); - compute() { - var branch = this.cond.value() ? this.truthy : this.falsy; - (0, _reference.update)(this.branchTag, branch.tag); - return branch.value(); + if (toBool(condition.value()) === true) { + return truthyValue !== undefined ? truthyValue.value() : undefined; + } else { + return falsyValue.value(); } - } /** The `if` helper allows you to conditionally render one of two branches, @@ -11609,11 +10238,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - function inlineIf(_vm, { - positional - }) { - (true && !(positional.length === 3 || positional.length === 2) && (0, _debug.assert)('The inline form of the `if` helper expects two or three arguments, e.g. ' + '`{{if trialExpired "Expired" expiryDate}}`.', positional.length === 3 || positional.length === 2)); - return ConditionalHelperReference.create(positional.at(0), positional.at(1), positional.at(2)); + function inlineIf(args, vm) { + return new _reference.HelperRootReference(ifHelper, args.capture(), vm.env); } /** The `unless` helper is the inverse of the `if` helper. It displays if a value @@ -11702,11 +10328,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - function inlineUnless(_vm, { - positional - }) { - (true && !(positional.length === 3 || positional.length === 2) && (0, _debug.assert)('The inline form of the `unless` helper expects two or three arguments, e.g. ' + '`{{unless isFirstLogin "Welcome back!"}}`.', positional.length === 3 || positional.length === 2)); - return ConditionalHelperReference.create(positional.at(0), positional.at(2), positional.at(1)); + function inlineUnless(args, vm) { + return new _reference.HelperRootReference(unless, args.capture(), vm.env); } /** @module ember @@ -11735,130 +10358,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol /* eslint-enable no-console */ } - function log$1(_vm, args) { - return new InternalHelperReference(log, args.capture()); - } - /** - @module ember - */ - - /** - The `mut` helper lets you __clearly specify__ that a child `Component` can update the - (mutable) value passed to it, which will __change the value of the parent component__. - - To specify that a parameter is mutable, when invoking the child `Component`: - - ```handlebars - - ``` - - or - - ```handlebars - {{my-child childClickCount=(mut totalClicks)}} - ``` - - The child `Component` can then modify the parent's value just by modifying its own - property: - - ```javascript - // my-child.js - export default Component.extend({ - click() { - this.incrementProperty('childClickCount'); - } - }); - ``` - - Note that for curly components (`{{my-component}}`) the bindings are already mutable, - making the `mut` unnecessary. - - Additionally, the `mut` helper can be combined with the `fn` helper to - mutate a value. For example: - - ```handlebars - - ``` - - or - - ```handlebars - {{my-child childClickCount=totalClicks click-count-change=(fn (mut totalClicks))}} - ``` - - The child `Component` would invoke the function with the new click value: - - ```javascript - // my-child.js - export default Component.extend({ - click() { - this.get('click-count-change')(this.get('childClickCount') + 1); - } - }); - ``` - - The `mut` helper changes the `totalClicks` value to what was provided as the `fn` argument. - - The `mut` helper, when used with `fn`, will return a function that - sets the value passed to `mut` to its first argument. As an example, we can create a - button that increments a value passing the value directly to the `fn`: - - ```handlebars - {{! inc helper is not provided by Ember }} - - ``` - - You can also use the `value` option: - - ```handlebars - - ``` - - @method mut - @param {Object} [attr] the "two-way" attribute that can be modified. - @for Ember.Templates.helpers - @public - */ - - - var MUT_REFERENCE = (0, _utils.symbol)('MUT'); - var SOURCE = (0, _utils.symbol)('SOURCE'); - - function isMut(ref) { - return ref && ref[MUT_REFERENCE]; - } - - function unMut(ref) { - return ref[SOURCE] || ref; - } - - function mut(_vm, args) { - var rawRef = args.positional.at(0); - - if (isMut(rawRef)) { - return rawRef; - } // TODO: Improve this error message. This covers at least two distinct - // cases: - // - // 1. (mut "not a path") – passing a literal, result from a helper - // invocation, etc - // - // 2. (mut receivedValue) – passing a value received from the caller - // that was originally derived from a literal, result from a helper - // invocation, etc - // - // This message is alright for the first case, but could be quite - // confusing for the second case. - - - (true && !(rawRef[UPDATE]) && (0, _debug.assert)('You can only pass a path to mut', rawRef[UPDATE])); - var wrappedRef = Object.create(rawRef); - wrappedRef[SOURCE] = rawRef; - wrappedRef[INVOKE] = rawRef[UPDATE]; - wrappedRef[MUT_REFERENCE] = true; - return wrappedRef; + function log$1(args, vm) { + return new _reference.HelperRootReference(log, args.capture(), vm.env); } /** @module ember @@ -11896,8 +10397,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return new _routing.QueryParams((0, _polyfills.assign)({}, named.value())); } - function queryParams$1(_vm, args) { - return new InternalHelperReference(queryParams, args.capture()); + function queryParams$1(args, vm) { + return new _reference.HelperRootReference(queryParams, args.capture(), vm.env); } /** The `readonly` helper let's you specify that a binding is one-way only, @@ -12016,9 +10517,30 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - function readonly(_vm, args) { + class ReadonlyReference extends _reference.RootReference { + constructor(inner, env) { + super(env); + this.inner = inner; + this.tag = inner.tag; + } + + get [INVOKE]() { + return this.inner[INVOKE]; + } + + value() { + return this.inner.value(); + } + + get(key) { + return this.inner.get(key); + } + + } + + function readonly(args, vm) { var ref = unMut(args.positional.at(0)); - return new ReadonlyReference(ref); + return new ReadonlyReference(ref, vm.env); } /** @module ember @@ -12053,9 +10575,9 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - function unbound(_vm, args) { + function unbound(args, vm) { (true && !(args.positional.length === 1 && args.named.length === 0) && (0, _debug.assert)('unbound helper cannot be called with multiple params or hash params', args.positional.length === 1 && args.named.length === 0)); - return UnboundReference.create(args.positional.at(0).value()); + return new UnboundRootReference(args.positional.at(0).value(), vm.env); } var MODIFIERS = ['alt', 'shift', 'meta', 'ctrl']; @@ -12074,8 +10596,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return true; } - for (var i = 0; i < MODIFIERS.length; i++) { - if (event[MODIFIERS[i] + 'Key'] && allowedKeys.indexOf(MODIFIERS[i]) === -1) { + for (var _i9 = 0; _i9 < MODIFIERS.length; _i9++) { + if (event[MODIFIERS[_i9] + 'Key'] && allowedKeys.indexOf(MODIFIERS[_i9]) === -1) { return false; } } @@ -12126,8 +10648,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol getActionArgs() { var result = new Array(this.actionArgs.length); - for (var i = 0; i < this.actionArgs.length; i++) { - result[i] = this.actionArgs[i].value(); + for (var _i10 = 0; _i10 < this.actionArgs.length; _i10++) { + result[_i10] = this.actionArgs[_i10].value(); } return result; @@ -12201,7 +10723,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol target.send.apply(target, [actionName, ...args]); }); } else { - (true && !(typeof target[actionName] === 'function') && (0, _debug.assert)("The action '" + actionName + "' did not exist on " + target, typeof target[actionName] === 'function')); + (true && !(typeof target[actionName] === 'function') && (0, _debug.assert)(`The action '${actionName}' did not exist on ${target}`, typeof target[actionName] === 'function')); (0, _instrumentation.flaggedInstrument)('interaction.ember-action', payload, () => { target[actionName].apply(target, args); }); @@ -12244,13 +10766,13 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var actionArgs = []; // The first two arguments are (1) `this` and (2) the action name. // Everything else is a param. - for (var i = 2; i < positional.length; i++) { - actionArgs.push(positional.at(i)); + for (var _i11 = 2; _i11 < positional.length; _i11++) { + actionArgs.push(positional.at(_i11)); } var actionId = (0, _utils.uuid)(); var actionState = new ActionState(element, actionId, actionName, actionArgs, named, positional, implicitTarget, dom, tag); - (true && !(actionState.eventName !== 'mouseEnter' && actionState.eventName !== 'mouseLeave' && actionState.eventName !== 'mouseMove') && (0, _debug.deprecate)("Using the `{{action}}` modifier with `" + actionState.eventName + "` events has been deprecated.", actionState.eventName !== 'mouseEnter' && actionState.eventName !== 'mouseLeave' && actionState.eventName !== 'mouseMove', { + (true && !(actionState.eventName !== 'mouseEnter' && actionState.eventName !== 'mouseLeave' && actionState.eventName !== 'mouseMove') && (0, _debug.deprecate)(`Using the \`{{action}}\` modifier with \`${actionState.eventName}\` events has been deprecated.`, actionState.eventName !== 'mouseEnter' && actionState.eventName !== 'mouseLeave' && actionState.eventName !== 'mouseMove', { id: 'ember-views.event-dispatcher.mouseenter-leave-move', until: '4.0.0', url: 'https://emberjs.com/deprecations/v3.x#toc_action-mouseenter-leave-move' @@ -12266,7 +10788,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } = actionState; ActionHelper.registerAction(actionState); dom.setAttribute(element, 'data-ember-action', ''); - dom.setAttribute(element, "data-ember-action-" + actionId, actionId); + dom.setAttribute(element, `data-ember-action-${actionId}`, actionId); } update(actionState) { @@ -12292,7 +10814,19 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } - function capabilities$1(managerAPI, optionalFeatures = {}) { + var debugRenderMessage; + + if (true + /* DEBUG */ + ) { + debugRenderMessage = renderingStack => { + return `While rendering:\n----------------\n${renderingStack.replace(/^/gm, ' ')}`; + }; + } + + var debugRenderMessage$1 = debugRenderMessage; + + function capabilities$1(managerAPI, optionalFeatures = {}) { if (managerAPI !== '3.13') { managerAPI = '3.13'; (true && !(false) && (0, _debug.deprecate)('Modifier manager capabilities now require you to pass a valid version when being generated. Valid versions include: 3.13', false, { @@ -12328,7 +10862,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this.delegate = delegate; this.modifier = modifier; this.args = args; - this.tag = (0, _reference.createUpdatableTag)(); + this.tag = (0, _validator.createUpdatableTag)(); } destroy() { @@ -12391,7 +10925,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol args, tag }) { - return (0, _reference.combine)([tag, args.tag]); + return (0, _validator.combine)([tag, args.tag]); } install(state) { @@ -12407,12 +10941,12 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } = delegate; if (capabilities.disableAutoTracking === true) { - (0, _metal.untrack)(() => delegate.installModifier(modifier, element, args.value())); + (0, _validator.untrack)(() => delegate.installModifier(modifier, element, args.value())); } else { - var combinedTrackingTag = (0, _metal.track)(() => delegate.installModifier(modifier, element, args.value()), true + var combinedTrackingTag = (0, _validator.track)(() => delegate.installModifier(modifier, element, args.value()), true /* DEBUG */ - && debugRenderMessage$1("(instance of a `" + (0, _utils.getDebugName)(modifier) + "` modifier)")); - (0, _reference.update)(tag, combinedTrackingTag); + && debugRenderMessage$1(`(instance of a \`${(0, _utils.getDebugName)(modifier)}\` modifier)`)); + (0, _validator.update)(tag, combinedTrackingTag); } } @@ -12428,12 +10962,12 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } = delegate; if (capabilities.disableAutoTracking === true) { - (0, _metal.untrack)(() => delegate.updateModifier(modifier, args.value())); + (0, _validator.untrack)(() => delegate.updateModifier(modifier, args.value())); } else { - var combinedTrackingTag = (0, _metal.track)(() => delegate.updateModifier(modifier, args.value()), true + var combinedTrackingTag = (0, _validator.track)(() => delegate.updateModifier(modifier, args.value()), true /* DEBUG */ - && debugRenderMessage$1("(instance of a `" + (0, _utils.getDebugName)(modifier) + "` modifier)")); - (0, _reference.update)(tag, combinedTrackingTag); + && debugRenderMessage$1(`(instance of a \`${(0, _utils.getDebugName)(modifier)}\` modifier)`)); + (0, _validator.update)(tag, combinedTrackingTag); } } @@ -12449,7 +10983,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } getTag() { - return _reference.CONSTANT_TAG; + return _validator.CONSTANT_TAG; } install() {} @@ -12567,7 +11101,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this.shouldUpdate = true; } - (true && !(args.positional.length === 2) && (0, _debug.assert)("You can only pass two positional arguments (event name and callback) to the `on` modifier, but you provided " + args.positional.length + ". Consider using the `fn` helper to provide additional arguments to the `on` callback.", args.positional.length === 2)); + (true && !(args.positional.length === 2) && (0, _debug.assert)(`You can only pass two positional arguments (event name and callback) to the \`on\` modifier, but you provided ${args.positional.length}. Consider using the \`fn\` helper to provide additional arguments to the \`on\` callback.`, args.positional.length === 2)); var needsCustomCallback = SUPPORTS_EVENT_OPTIONS === false && once || /* needs manual once implementation */ true @@ -12583,7 +11117,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol /* DEBUG */ && passive) { event.preventDefault = () => { - (true && !(false) && (0, _debug.assert)("You marked this listener as 'passive', meaning that you must not call 'event.preventDefault()': \n\n" + userProvidedCallback)); + (true && !(false) && (0, _debug.assert)(`You marked this listener as 'passive', meaning that you must not call 'event.preventDefault()': \n\n${userProvidedCallback}`)); }; } @@ -12779,7 +11313,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol getTag(state) { if (state === null) { - return _reference.CONSTANT_TAG; + return _validator.CONSTANT_TAG; } return state.tag; @@ -12831,75 +11365,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } } - /** - @module ember - */ - - /** - The `let` helper receives one or more positional arguments and yields - them out as block params. - - This allows the developer to introduce shorter names for certain computations - in the template. - - This is especially useful if you are passing properties to a component - that receives a lot of options and you want to clean up the invocation. - - For the following example, the template receives a `post` object with - `content` and `title` properties. - - We are going to call the `my-post` component, passing a title which is - the title of the post suffixed with the name of the blog, the content - of the post, and a series of options defined in-place. - - ```handlebars - {{#let - (concat post.title ' | The Ember.js Blog') - post.content - (hash - theme="high-contrast" - enableComments=true - ) - as |title content options| - }} - - {{/let}} - ``` - or - ```handlebars - {{#let - (concat post.title ' | The Ember.js Blog') - post.content - (hash - theme="high-contrast" - enableComments=true - ) - as |title content options| - }} - {{my-post title=title content=content options=options}} - {{/let}} - ``` - - @method let - @for Ember.Templates.helpers - @public - */ - - - function blockLetMacro(params, _hash, template, _inverse, builder) { - if (template !== null) { - if (params !== null) { - builder.compileParams(params); - builder.invokeStaticBlock(template, params.length); - } else { - builder.invokeStatic(template); - } - } - - return true; - } - var CAPABILITIES$4 = { + var CAPABILITIES$3 = { dynamicLayout: true, dynamicTag: false, prepareArgs: false, @@ -12909,7 +11376,9 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol createCaller: true, dynamicScope: true, updateHook: true, - createInstance: true + createInstance: true, + wrapped: false, + willDestroy: false }; // TODO // This "disables" the "@model" feature by making the arg untypable syntatically // Delete this when EMBER_ROUTING_MODEL_ARG has shipped @@ -12917,23 +11386,19 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var MODEL_ARG_NAME = 'model'; class MountManager extends AbstractManager { - getDynamicLayout(state, _) { + getJitDynamicLayout(state, _) { var templateFactory$$1 = state.engine.lookup('template:application'); var template = templateFactory$$1(state.engine); - var layout = template.asLayout(); if (_environment2.ENV._DEBUG_RENDER_TREE) { - state.environment.debugRenderTree.setTemplate(state.controller, template); + state.environment.extra.debugRenderTree.setTemplate(state.controller, template); } - return { - handle: layout.compile(), - symbolTable: layout.symbolTable - }; + return template; } getCapabilities() { - return CAPABILITIES$4; + return CAPABILITIES$3; } create(environment, { @@ -12943,9 +11408,9 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol // mount is a runtime helper, this shouldn't use dynamic layout // we should resolve the engine app template in the helper // it also should use the owner that looked up the mount helper. - var engine = environment.owner.buildChildEngineInstance(name); + var engine = environment.extra.owner.buildChildEngineInstance(name); engine.boot(); - var applicationFactory = engine.factoryFor("controller:application"); + var applicationFactory = engine.factoryFor(`controller:application`); var controllerFactory = applicationFactory || (0, _routing.generateControllerFactory)(engine, 'application'); var controller; var self; @@ -12958,7 +11423,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol if (modelRef === undefined) { controller = controllerFactory.create(); - self = new RootReference(controller, environment); + self = new _reference.ComponentRootReference(controller, environment); bucket = { engine, controller, @@ -12970,7 +11435,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol controller = controllerFactory.create({ model }); - self = new RootReference(controller, environment); + self = new _reference.ComponentRootReference(controller, environment); bucket = { engine, controller, @@ -12981,14 +11446,14 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } if (_environment2.ENV._DEBUG_RENDER_TREE) { - environment.debugRenderTree.create(bucket, { + environment.extra.debugRenderTree.create(bucket, { type: 'engine', name, args: args.capture(), instance: engine, template: undefined }); - environment.debugRenderTree.create(controller, { + environment.extra.debugRenderTree.create(controller, { type: 'route-template', name: 'application', args: args.capture(), @@ -13008,14 +11473,14 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } getTag(state) { - var tag = _reference.CONSTANT_TAG; + var tag = _validator.CONSTANT_TAG; if (state.modelRef) { tag = state.modelRef.tag; } - if (_environment2.ENV._DEBUG_RENDER_TREE && (0, _reference.isConstTag)(tag)) { - tag = (0, _reference.createTag)(); + if (_environment2.ENV._DEBUG_RENDER_TREE && (0, _validator.isConstTag)(tag)) { + tag = (0, _validator.createTag)(); } return tag; @@ -13031,8 +11496,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol if (_environment2.ENV._DEBUG_RENDER_TREE) { return { destroy() { - environment.debugRenderTree.willDestroy(controller); - environment.debugRenderTree.willDestroy(bucket); + environment.extra.debugRenderTree.willDestroy(controller); + environment.extra.debugRenderTree.willDestroy(bucket); engine.destroy(); } @@ -13044,8 +11509,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol didRenderLayout(bucket, bounds) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.environment.debugRenderTree.didRender(bucket.controller, bounds); - bucket.environment.debugRenderTree.didRender(bucket, bounds); + bucket.environment.extra.debugRenderTree.didRender(bucket.controller, bounds); + bucket.environment.extra.debugRenderTree.didRender(bucket, bounds); } } @@ -13061,15 +11526,15 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } if (_environment2.ENV._DEBUG_RENDER_TREE) { - environment.debugRenderTree.update(bucket); - environment.debugRenderTree.update(bucket.controller); + environment.extra.debugRenderTree.update(bucket); + environment.extra.debugRenderTree.update(bucket.controller); } } didUpdateLayout(bucket, bounds) { if (_environment2.ENV._DEBUG_RENDER_TREE) { - bucket.environment.debugRenderTree.didRender(bucket.controller, bounds); - bucket.environment.debugRenderTree.didRender(bucket, bounds); + bucket.environment.extra.debugRenderTree.didRender(bucket.controller, bounds); + bucket.environment.extra.debugRenderTree.didRender(bucket, bounds); } } @@ -13086,14 +11551,28 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } } + /** + @module ember + */ - function mountHelper(vm, args) { + + function mountHelper(args, vm) { var env = vm.env; var nameRef = args.positional.at(0); - var captured = null; // TODO: the functionailty to create a proper CapturedArgument should be + var captured = null; + (true && !(args.positional.length === 1) && (0, _debug.assert)('You can only pass a single positional argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.', args.positional.length === 1)); + + if (true + /* DEBUG */ + && args.named) { + var keys = args.named.names; + var extra = keys.filter(k => k !== 'model'); + (true && !(extra.length === 0) && (0, _debug.assert)('You can only pass a `model` argument to the {{mount}} helper, ' + 'e.g. {{mount "profile-engine" model=this.profile}}. ' + `You passed ${extra.join(',')}.`, extra.length === 0)); + } // TODO: the functionality to create a proper CapturedArgument should be // exported by glimmer, or that it should provide an overload for `curry` // that takes `PreparedArguments` + if (args.named.has('model')) { (true && !(args.named.length === 1) && (0, _debug.assert)('[BUG] this should already be checked by the macro', args.named.length === 1)); var named = args.named.capture(); @@ -13168,22 +11647,6 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - function mountMacro(_name, params, hash, builder) { - (true && !(params.length === 1) && (0, _debug.assert)('You can only pass a single positional argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.', params.length === 1)); - - if (true - /* DEBUG */ - && hash) { - var keys = hash[0]; - var extra = keys.filter(k => k !== 'model'); - (true && !(extra.length === 0) && (0, _debug.assert)('You can only pass a `model` argument to the {{mount}} helper, ' + 'e.g. {{mount "profile-engine" model=this.profile}}. ' + ("You passed " + extra.join(',') + "."), extra.length === 0)); - } - - var expr = [_wireFormat.Ops.Helper, '-mount', params || [], hash]; - builder.dynamicComponent(expr, null, [], null, false, null, null); - return true; - } - class DynamicEngineReference { constructor(nameRef, env, args) { this.nameRef = nameRef; @@ -13207,9 +11670,9 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return this._lastDef; } - (true && !(env.owner.hasRegistration("engine:" + name)) && (0, _debug.assert)("You used `{{mount '" + name + "'}}`, but the engine '" + name + "' can not be found.", env.owner.hasRegistration("engine:" + name))); + (true && !(env.extra.owner.hasRegistration(`engine:${name}`)) && (0, _debug.assert)(`You used \`{{mount '${name}'}}\`, but the engine '${name}' can not be found.`, env.extra.owner.hasRegistration(`engine:${name}`))); - if (!env.owner.hasRegistration("engine:" + name)) { + if (!env.extra.owner.hasRegistration(`engine:${name}`)) { return null; } @@ -13217,7 +11680,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this._lastDef = (0, _runtime2.curry)(new MountDefinition(name), args); return this._lastDef; } else { - (true && !(name === null || name === undefined) && (0, _debug.assert)("Invalid engine name '" + name + "' specified, engine name must be either a string, null or undefined.", name === null || name === undefined)); + (true && !(name === null || name === undefined) && (0, _debug.assert)(`Invalid engine name '${name}' specified, engine name must be either a string, null or undefined.`, name === null || name === undefined)); this._lastDef = null; this._lastName = null; return null; @@ -13237,7 +11700,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol class RootOutletReference { constructor(outletState) { this.outletState = outletState; - this.tag = (0, _reference.createTag)(); + this.tag = (0, _validator.createTag)(); } get(key) { @@ -13250,7 +11713,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol update(state) { this.outletState.outlets.main = state; - (0, _reference.dirty)(this.tag); + (0, _validator.dirty)(this.tag); } } @@ -13263,7 +11726,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol constructor(parentStateRef, outletNameRef) { this.parentStateRef = parentStateRef; this.outletNameRef = outletNameRef; - this.tag = (0, _reference.combine)([parentStateRef.tag, outletNameRef.tag]); + this.tag = (0, _validator.combine)([parentStateRef.tag, outletNameRef.tag]); } value() { @@ -13349,7 +11812,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - function outletHelper(vm, args) { + function outletHelper(args, vm) { var scope = vm.dynamicScope(); var nameRef; @@ -13362,16 +11825,10 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return new OutletComponentReference(new OutletReference(scope.outletState, nameRef), vm.env); } - function outletMacro(_name, params, hash, builder) { - var expr = [_wireFormat.Ops.Helper, '-outlet', params || [], hash]; - builder.dynamicComponent(expr, null, [], null, false, null, null); - return true; - } - - class OutletModelReference { + class OutletModelReference extends _reference.RootReference { constructor(parent, env) { + super(env); this.parent = parent; - this.env = env; this.tag = parent.tag; } @@ -13393,88 +11850,22 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return render.model; } - get(property) { - if (true - /* DEBUG */ - ) { - // We capture the log stack now, as accessing `{{@model}}` directly can't - // cause issues (doesn't autotrack) but accessing subproperties can. We - // don't want to capture the log stack when `value` or `debug` are called, - // because the ref might have been passed downward, so we'd have the - // incorrect context. - // - // TODO: This feels messy, side-effect of the fact that this ref is - // created well before the component itself. - this.debugStackLog = this.env.debugRenderTree.logCurrentRenderStack(); // This guarentees that we preserve the `debug()` output below - - return new NestedPropertyReference(this, property); - } else { - return PropertyReference.create(this, property); - } - } - } if (true /* DEBUG */ ) { - OutletModelReference.prototype['debug'] = function debug(subPath) { - return this['debugStackLog'] + "@model." + subPath; - }; + OutletModelReference.prototype['debugLogName'] = '@model'; } class OutletComponentReference { constructor(outletRef, env) { this.outletRef = outletRef; - this.args = null; + this.env = env; this.definition = null; this.lastState = null; // The router always dirties the root state. - var tag = this.tag = outletRef.tag; - { - var modelRef = new OutletModelReference(outletRef, env); - var map$$1 = (0, _util.dict)(); - map$$1.model = modelRef; // TODO: the functionailty to create a proper CapturedArgument should be - // exported by glimmer, or that it should provide an overload for `curry` - // that takes `PreparedArguments` - - this.args = { - tag, - positional: _runtime2.EMPTY_ARGS.positional, - named: { - tag, - map: map$$1, - names: ['model'], - references: [modelRef], - length: 1, - - has(key) { - return key === 'model'; - }, - - get(key) { - return key === 'model' ? modelRef : _runtime2.UNDEFINED_REFERENCE; - }, - - value() { - var model = modelRef.value(); - return { - model - }; - } - - }, - length: 1, - - value() { - return { - named: this.named.value(), - positional: this.positional.value() - }; - } - - }; - } + this.tag = outletRef.tag; } value() { @@ -13488,7 +11879,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var definition = null; if (state !== null) { - definition = (0, _runtime2.curry)(new OutletComponentDefinition(state), this.args); + var args = makeArgs(this.outletRef, this.env); + definition = (0, _runtime2.curry)(new OutletComponentDefinition(state), args); } return this.definition = definition; @@ -13500,6 +11892,52 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } + function makeArgs(outletRef, env) { + var tag = outletRef.tag; + var modelRef = new OutletModelReference(outletRef, env); + var map = (0, _util.dict)(); + map.model = modelRef; // TODO: the functionailty to create a proper CapturedArgument should be + // exported by glimmer, or that it should provide an overload for `curry` + // that takes `PreparedArguments` + + return { + tag, + positional: _runtime2.EMPTY_ARGS.positional, + named: { + tag, + map, + names: ['model'], + references: [modelRef], + length: 1, + + has(key) { + return key === 'model'; + }, + + get(key) { + return key === 'model' ? modelRef : _runtime2.UNDEFINED_REFERENCE; + }, + + value() { + var model = modelRef.value(); + return { + model + }; + } + + }, + length: 1, + + value() { + return { + named: this.named.value(), + positional: this.positional.value() + }; + } + + }; + } + function stateFor(ref) { var outlet = ref.value(); if (outlet === undefined) return null; @@ -13535,118 +11973,48 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return state.template === lastState.template && state.controller === lastState.controller; } - function hashToArgs(hash) { - if (hash === null) return null; - var names = hash[0].map(key => "@" + key); - return [names, hash[1]]; - } - - function refineInlineSyntax(name, params, hash, builder) { - (true && !(!(builder.compiler['resolver']['resolver']['builtInHelpers'][name] && builder.referrer.owner.hasRegistration("helper:" + name))) && (0, _debug.assert)("You attempted to overwrite the built-in helper \"" + name + "\" which is not allowed. Please rename the helper.", !(builder.compiler['resolver']['resolver']['builtInHelpers'][name] && builder.referrer.owner.hasRegistration("helper:" + name)))); - var handle = builder.compiler['resolver'].lookupComponentDefinition(name, builder.referrer); - - if (handle !== null) { - builder.component.static(handle, [params === null ? [] : params, hashToArgs(hash), null, null]); - return true; - } + var TEMPLATES = new WeakMap(); + var getPrototypeOf = Object.getPrototypeOf; - return false; + function setComponentTemplate(factory, obj) { + (true && !(obj !== null && (typeof obj === 'object' || typeof obj === 'function')) && (0, _debug.assert)(`Cannot call \`setComponentTemplate\` on \`${(0, _utils.toString)(obj)}\``, obj !== null && (typeof obj === 'object' || typeof obj === 'function'))); + (true && !(!TEMPLATES.has(obj)) && (0, _debug.assert)(`Cannot call \`setComponentTemplate\` multiple times on the same class (\`${obj}\`)`, !TEMPLATES.has(obj))); + TEMPLATES.set(obj, factory); + return obj; } - function refineBlockSyntax(name, params, hash, template, inverse, builder) { - var handle = builder.compiler['resolver'].lookupComponentDefinition(name, builder.referrer); - - if (handle !== null) { - wrapComponentClassAttribute(hash); - builder.component.static(handle, [params, hashToArgs(hash), template, inverse]); - return true; - } - - (true && !(builder.referrer.owner.hasRegistration("helper:" + name)) && (0, _debug.assert)("A component or helper named \"" + name + "\" could not be found", builder.referrer.owner.hasRegistration("helper:" + name))); - (true && !(!(() => { - var resolver = builder.compiler['resolver']['resolver']; - var { - owner, - moduleName - } = builder.referrer; - - if (name === 'component' || resolver['builtInHelpers'][name]) { - return true; - } + function getComponentTemplate(obj) { + var pointer = obj; - var options = { - source: "template:" + moduleName - }; - return owner.hasRegistration("helper:" + name, options) || owner.hasRegistration("helper:" + name); - })()) && (0, _debug.assert)("Helpers may not be used in the block form, for example {{#" + name + "}}{{/" + name + "}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (" + name + ")}}{{/if}}.", !(() => { - var resolver = builder.compiler['resolver']['resolver']; - var { - owner, - moduleName - } = builder.referrer; + while (pointer !== undefined && pointer !== null) { + var _template = TEMPLATES.get(pointer); - if (name === 'component' || resolver['builtInHelpers'][name]) { - return true; + if (_template !== undefined) { + return _template; } - var options = { - source: "template:" + moduleName - }; - return owner.hasRegistration("helper:" + name, options) || owner.hasRegistration("helper:" + name); - })())); - return false; - } - - var experimentalMacros = []; // This is a private API to allow for experimental macros - // to be created in user space. Registering a macro should - // should be done in an initializer. - - _exports._experimentalMacros = experimentalMacros; - - function registerMacros(macro) { - experimentalMacros.push(macro); - } - - function populateMacros(macros) { - var { - inlines, - blocks - } = macros; - inlines.add('outlet', outletMacro); - inlines.add('mount', mountMacro); - inlines.addMissing(refineInlineSyntax); - blocks.add('let', blockLetMacro); - blocks.addMissing(refineBlockSyntax); - - for (var i = 0; i < experimentalMacros.length; i++) { - var macro = experimentalMacros[i]; - macro(blocks, inlines); + pointer = getPrototypeOf(pointer); } - return { - blocks, - inlines - }; + return null; } - var TEMPLATES$1 = new WeakMap(); + var MANAGERS = new WeakMap(); var getPrototypeOf$1 = Object.getPrototypeOf; - function setComponentTemplate(factory, obj) { - (true && !(obj !== null && (typeof obj === 'object' || typeof obj === 'function')) && (0, _debug.assert)("Cannot call `setComponentTemplate` on `" + (0, _utils.toString)(obj) + "`", obj !== null && (typeof obj === 'object' || typeof obj === 'function'))); - (true && !(!TEMPLATES$1.has(obj)) && (0, _debug.assert)("Cannot call `setComponentTemplate` multiple times on the same class (`" + obj + "`)", !TEMPLATES$1.has(obj))); - TEMPLATES$1.set(obj, factory); + function setManager(wrapper, obj) { + MANAGERS.set(obj, wrapper); return obj; } - function getComponentTemplate(obj) { + function getManager(obj) { var pointer = obj; while (pointer !== undefined && pointer !== null) { - var _template = TEMPLATES$1.get(pointer); + var manager = MANAGERS.get(pointer); - if (_template !== undefined) { - return _template; + if (manager !== undefined) { + return manager; } pointer = getPrototypeOf$1(pointer); @@ -13675,24 +12043,24 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol function instrumentationPayload$1(name) { return { - object: "component:" + name + object: `component:${name}` }; } function makeOptions(moduleName, namespace) { return { - source: moduleName !== undefined ? "template:" + moduleName : undefined, + source: moduleName !== undefined ? `template:${moduleName}` : undefined, namespace }; } function componentFor(name, owner, options) { - var fullName = "component:" + name; + var fullName = `component:${name}`; return owner.factoryFor(fullName, options) || null; } function layoutFor(name, owner, options) { - var templateFullName = "template:components/" + name; + var templateFullName = `template:components/${name}`; return owner.lookup(templateFullName, options) || null; } @@ -13700,12 +12068,12 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var component = componentFor(name, owner, options); { if (component !== null && component.class !== undefined) { - var _layout2 = getComponentTemplate(component.class); + var _layout = getComponentTemplate(component.class); - if (_layout2 !== null) { + if (_layout !== null) { return { component, - layout: _layout2 + layout: _layout }; } } @@ -13740,7 +12108,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol if (_deprecatedFeatures.PARTIALS) { lookupPartial = function (templateName, owner) { - (true && !(false) && (0, _debug.deprecate)("The use of `{{partial}}` is deprecated, please refactor the \"" + templateName + "\" partial to a component", false, { + (true && !(false) && (0, _debug.deprecate)(`The use of \`{{partial}}\` is deprecated, please refactor the "${templateName}" partial to a component`, false, { id: 'ember-views.partial', until: '4.0.0', url: 'https://deprecations.emberjs.com/v3.x#toc_ember-views-partial' @@ -13751,7 +12119,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } var template = templateFor(owner, parseUnderscoredName(templateName), templateName); - (true && !(Boolean(template)) && (0, _debug.assert)("Unable to find partial with name \"" + templateName + "\"", Boolean(template))); + (true && !(Boolean(template)) && (0, _debug.assert)(`Unable to find partial with name "${templateName}"`, Boolean(template))); return template; }; @@ -13761,20 +12129,20 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return; } - (true && !(name.indexOf('.') === -1) && (0, _debug.assert)("templateNames are not allowed to contain periods: " + name, name.indexOf('.') === -1)); + (true && !(name.indexOf('.') === -1) && (0, _debug.assert)(`templateNames are not allowed to contain periods: ${name}`, name.indexOf('.') === -1)); if (!owner) { throw new _error.default('Container was not found when looking up a views template. ' + 'This is most likely due to manually instantiating an Ember.View. ' + 'See: http://git.io/EKPpnA'); } - return owner.lookup("template:" + underscored) || owner.lookup("template:" + name); + return owner.lookup(`template:${underscored}`) || owner.lookup(`template:${name}`); } }; parseUnderscoredName = function (templateName) { var nameParts = templateName.split('/'); var lastPart = nameParts[nameParts.length - 1]; - nameParts[nameParts.length - 1] = "_" + lastPart; + nameParts[nameParts.length - 1] = `_${lastPart}`; return nameParts.join('/'); }; } @@ -13784,7 +12152,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol action, array, concat: concat$1, - fn, + fn: fn$1, get: get$1, hash, log: log$1, @@ -13793,10 +12161,12 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol readonly, unbound, unless: inlineUnless, - '-class': classHelper$1, + '-hash': hash, '-each-in': eachIn, + '-i': parseIntHelper, '-input-type': inputTypeHelper$1, '-normalize-class': normalizeClassHelper, + '-track-array': trackArray, '-get-dynamic-var': _runtime2.getDynamicVar, '-mount': mountHelper, '-outlet': outletHelper, @@ -13811,9 +12181,6 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol this.componentDefinitionCache = new Map(); this.componentDefinitionCount = 0; this.helperDefinitionCount = 0; - var macros = new _opcodeCompiler.Macros(); - populateMacros(macros); - this.compiler = new _opcodeCompiler.LazyCompiler(new CompileTimeLookup(this), this, macros); this.isInteractive = isInteractive; this.builtInModifiers = { action: { @@ -13834,11 +12201,11 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol */ - lookupComponentDefinition(name, meta) { + lookupComponent(name, meta) { var handle = this.lookupComponentHandle(name, meta); if (handle === null) { - (true && !(false) && (0, _debug.assert)("Could not find component named \"" + name + "\" (no component or template with that name was found)")); + (true && !(false) && (0, _debug.assert)(`Could not find component named "${name}" (no component or template with that name was found)`)); return null; } @@ -13908,7 +12275,11 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } else { return null; } - } // end CompileTimeLookup + } // TODO: This isn't necessary in all embedding environments, we should likely + // make it optional within Glimmer-VM + + + compilable() {} // end CompileTimeLookup // needed for lazy compile time lookup @@ -13928,6 +12299,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } _lookupHelper(_name, meta) { + (true && !(!(this.builtInHelpers[_name] && meta.owner.hasRegistration(`helper:${_name}`))) && (0, _debug.assert)(`You attempted to overwrite the built-in helper "${_name}" which is not allowed. Please rename the helper.`, !(this.builtInHelpers[_name] && meta.owner.hasRegistration(`helper:${_name}`)))); var helper$$1 = this.builtInHelpers[_name]; if (helper$$1 !== undefined) { @@ -13935,33 +12307,42 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } var { - owner, moduleName } = meta; + var owner = meta.owner; var name = _name; var namespace = undefined; var options = makeOptions(moduleName, namespace); - var factory = owner.factoryFor("helper:" + name, options) || owner.factoryFor("helper:" + name); + var factory = owner.factoryFor(`helper:${name}`, options) || owner.factoryFor(`helper:${name}`); if (!isHelperFactory(factory)) { return null; } - return (vm, args) => { + return (args, vm) => { var helper$$1 = factory.create(); - if (isSimpleHelper(helper$$1)) { - return SimpleHelperReference.create(helper$$1.compute, args.capture()); + if (!isSimpleHelper(helper$$1)) { + vm.associateDestroyable(helper$$1); + } else if (true + /* DEBUG */ + ) { + // Bind to null in case someone accidentally passed an unbound function + // in, and attempts use `this` on it. + // + // TODO: Update buildUntouchableThis to be flexible enough to provide a + // nice error message here. + helper$$1.compute = helper$$1.compute.bind(null); } - vm.newDestroyable(helper$$1); - return ClassBasedHelperReference.create(helper$$1, args.capture()); + return new EmberHelperRootReference(helper$$1, args.capture(), vm.env); }; } _lookupPartial(name, meta) { - var templateFactory$$1 = lookupPartial(name, meta.owner); - var template = templateFactory$$1(meta.owner); + var owner = meta.owner; + var templateFactory$$1 = lookupPartial(name, owner); + var template = templateFactory$$1(owner); return new _opcodeCompiler.PartialDefinition(name, template); } @@ -13969,10 +12350,8 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol var builtin = this.builtInModifiers[name]; if (builtin === undefined) { - var { - owner - } = meta; - var modifier = owner.factoryFor("modifier:" + name); + var owner = meta.owner; + var modifier = owner.factoryFor(`modifier:${name}`); if (modifier !== undefined) { var managerFactory = getModifierManager(modifier.class); @@ -14001,19 +12380,20 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol }; } - _lookupComponentDefinition(_name, { - moduleName, - owner - }) { + _lookupComponentDefinition(_name, meta) { var name = _name; var namespace = undefined; + var owner = meta.owner; + var { + moduleName + } = meta; var pair = lookupComponent(owner, name, makeOptions(moduleName, namespace)); if (pair === null) { return null; } - var layout = null; + var layout; var key; if (pair.component === null) { @@ -14028,7 +12408,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol return cachedComponentDefinition; } - if (layout === null && pair.layout !== null) { + if (layout === undefined && pair.layout !== null) { layout = pair.layout(owner); } @@ -14046,7 +12426,7 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } if (pair.component !== null) { - (true && !(pair.component.class !== undefined) && (0, _debug.assert)("missing component class " + name, pair.component.class !== undefined)); + (true && !(pair.component.class !== undefined) && (0, _debug.assert)(`missing component class ${name}`, pair.component.class !== undefined)); var ComponentClass = pair.component.class; var wrapper = getManager(ComponentClass); @@ -14056,16 +12436,16 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } = wrapper; if (wrapper.internal) { - (true && !(pair.layout !== null) && (0, _debug.assert)("missing layout for internal component " + name, pair.layout !== null)); + (true && !(pair.layout !== null) && (0, _debug.assert)(`missing layout for internal component ${name}`, pair.layout !== null)); definition = new InternalComponentDefinition(factory(owner), ComponentClass, layout); } else { - definition = new CustomManagerDefinition(name, pair.component, factory(owner), layout !== null ? layout : owner.lookup((0, _container.privatize)(_templateObject3()))(owner)); + definition = new CustomManagerDefinition(name, pair.component, factory(owner), layout !== undefined ? layout : owner.lookup(_container.privatize`template:components/-default`)(owner)); } } } if (definition === null) { - definition = new CurlyComponentDefinition(name, pair.component || owner.factoryFor((0, _container.privatize)(_templateObject4())), null, layout); + definition = new CurlyComponentDefinition(name, pair.component || owner.factoryFor(_container.privatize`component:-default`), layout); } finalizer(); @@ -14075,3112 +12455,3532 @@ define("@ember/-internals/glimmer/index", ["exports", "ember-babel", "@ember/pol } - var TemplateCompiler = { - create({ - environment - }) { - return new RuntimeResolver(environment.isInteractive).compiler; - } + function hashToArgs(hash) { + if (hash === null) return null; + var names = hash[0].map(key => `@${key}`); + return [names, hash[1]]; + } - }; - var ComponentTemplate = template({ - "id": "chfQcH83", - "block": "{\"symbols\":[\"&default\"],\"statements\":[[14,1]],\"hasEval\":false}", - "meta": { - "moduleName": "packages/@ember/-internals/glimmer/lib/templates/component.hbs" - } - }); - var InputTemplate = template({ - "id": "NWZzLSII", - "block": "{\"symbols\":[\"Checkbox\",\"TextField\",\"@__ARGS__\",\"&attrs\"],\"statements\":[[4,\"let\",[[28,\"component\",[\"-checkbox\"],null],[28,\"component\",[\"-text-field\"],null]],null,{\"statements\":[[4,\"if\",[[23,0,[\"isCheckbox\"]]],null,{\"statements\":[[6,[23,1,[]],[[13,4]],[[\"@target\",\"@__ARGS__\"],[[23,0,[\"caller\"]],[23,3,[]]]]]],\"parameters\":[]},{\"statements\":[[6,[23,2,[]],[[13,4]],[[\"@target\",\"@__ARGS__\"],[[23,0,[\"caller\"]],[23,3,[]]]]]],\"parameters\":[]}]],\"parameters\":[1,2]},null]],\"hasEval\":false}", - "meta": { - "moduleName": "packages/@ember/-internals/glimmer/lib/templates/input.hbs" - } - }); - var OutletTemplate = template({ - "id": "ffAL6HDl", - "block": "{\"symbols\":[],\"statements\":[[1,[22,\"outlet\"],false]],\"hasEval\":false}", - "meta": { - "moduleName": "packages/@ember/-internals/glimmer/lib/templates/outlet.hbs" - } - }); - var TOP_LEVEL_NAME = '-top-level'; - var TOP_LEVEL_OUTLET = 'main'; + var experimentalMacros = []; // This is a private API to allow for experimental macros + // to be created in user space. Registering a macro should + // should be done in an initializer. - class OutletView { - constructor(_environment, renderer, owner, template) { - this._environment = _environment; - this.renderer = renderer; - this.owner = owner; - this.template = template; - var ref = this.ref = new RootOutletReference({ - outlets: { - main: undefined - }, - render: { - owner: owner, - into: undefined, - outlet: TOP_LEVEL_OUTLET, - name: TOP_LEVEL_NAME, - controller: undefined, - model: undefined, - template - } - }); - this.state = { - ref, - name: TOP_LEVEL_NAME, - outlet: TOP_LEVEL_OUTLET, - template, - controller: undefined, - model: undefined - }; - } + _exports._experimentalMacros = experimentalMacros; - static extend(injections) { - return class extends OutletView { - static create(options) { - if (options) { - return super.create((0, _polyfills.assign)({}, injections, options)); - } else { - return super.create(injections); - } - } + function registerMacros(macro) { + experimentalMacros.push(macro); + } - }; + function refineInlineSyntax(name, params, hash, context) { + var component = context.resolver.lookupComponent(name, context.meta.referrer); + + if (component !== null) { + return (0, _opcodeCompiler.staticComponent)(component, [params === null ? [] : params, hashToArgs(hash), _opcodeCompiler.EMPTY_BLOCKS]); } - static reopenClass(injections) { - (0, _polyfills.assign)(this, injections); + return _opcodeCompiler.UNHANDLED; + } + + function refineBlockSyntax(name, params, hash, blocks, context) { + var handle = context.resolver.lookupComponent(name, context.meta.referrer); + + if (handle !== null) { + return (0, _opcodeCompiler.staticComponent)(handle, [params, hashToArgs(hash), blocks]); } - static create(options) { + (true && !(context.meta.referrer.owner.hasRegistration(`helper:${name}`)) && (0, _debug.assert)(`A component or helper named "${name}" could not be found`, context.meta.referrer.owner.hasRegistration(`helper:${name}`))); + (true && !(!(() => { + var resolver = context.resolver['inner']['resolver']; var { - _environment, - renderer, - template: templateFactory$$1 - } = options; - var owner = options[_owner.OWNER]; - var template = templateFactory$$1(owner); - return new OutletView(_environment, renderer, owner, template); - } + moduleName, + owner + } = context.meta.referrer; - appendTo(selector) { - var target; + if (name === 'component' || resolver['builtInHelpers'][name]) { + return true; + } - if (this._environment.hasDOM) { - target = typeof selector === 'string' ? document.querySelector(selector) : selector; - } else { - target = selector; + var options = { + source: `template:${moduleName}` + }; + return owner.hasRegistration(`helper:${name}`, options) || owner.hasRegistration(`helper:${name}`); + })()) && (0, _debug.assert)(`Helpers may not be used in the block form, for example {{#${name}}}{{/${name}}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if (${name})}}{{/if}}.`, !(() => { + var resolver = context.resolver['inner']['resolver']; + var { + moduleName, + owner + } = context.meta.referrer; + + if (name === 'component' || resolver['builtInHelpers'][name]) { + return true; } - (0, _runloop.schedule)('render', this.renderer, 'appendOutletView', this, target); - } + var options = { + source: `template:${moduleName}` + }; + return owner.hasRegistration(`helper:${name}`, options) || owner.hasRegistration(`helper:${name}`); + })())); + return _opcodeCompiler.NONE; + } - rerender() { - /**/ + function populateMacros(macros) { + var { + inlines, + blocks + } = macros; + inlines.addMissing(refineInlineSyntax); + blocks.addMissing(refineBlockSyntax); + + for (var _i12 = 0; _i12 < experimentalMacros.length; _i12++) { + var macro = experimentalMacros[_i12]; + macro(blocks, inlines); } - setOutletState(state) { - this.ref.update(state); + return { + blocks, + inlines + }; + } + + class DynamicScope { + constructor(view, outletState) { + this.view = view; + this.outletState = outletState; } - destroy() { - /**/ + child() { + return new DynamicScope(this.view, this.outletState); } - } + get(key) { + // tslint:disable-next-line:max-line-length + (true && !(key === 'outletState') && (0, _debug.assert)(`Using \`-get-dynamic-scope\` is only supported for \`outletState\` (you used \`${key}\`).`, key === 'outletState')); + return this.outletState; + } - _exports.OutletView = OutletView; + set(key, value$$1) { + // tslint:disable-next-line:max-line-length + (true && !(key === 'outletState') && (0, _debug.assert)(`Using \`-with-dynamic-scope\` is only supported for \`outletState\` (you used \`${key}\`).`, key === 'outletState')); + this.outletState = value$$1; + return value$$1; + } - function setupApplicationRegistry(registry) { - registry.injection('service:-glimmer-environment', 'appendOperations', 'service:-dom-tree-construction'); - registry.injection('renderer', 'env', 'service:-glimmer-environment'); // because we are using injections we can't use instantiate false - // we need to use bind() to copy the function so factory for - // association won't leak + } - registry.register('service:-dom-builder', { - create({ - bootOptions - }) { - var { - _renderMode - } = bootOptions; + class RootState { + constructor(root, runtime, context, template, self, parentElement, dynamicScope, builder) { + this.root = root; + this.runtime = runtime; + (true && !(template !== undefined) && (0, _debug.assert)(`You cannot render \`${self.value()}\` without a template.`, template !== undefined)); + this.id = (0, _views.getViewId)(root); + this.result = undefined; + this.destroyed = false; - switch (_renderMode) { - case 'serialize': - return _node.serializeBuilder.bind(null); + this.render = () => { + var layout = (0, _opcodeCompiler.unwrapTemplate)(template).asLayout(); + var handle = layout.compile(context); + var iterator = (0, _runtime2.renderJitMain)(runtime, context, self, builder(runtime.env, { + element: parentElement, + nextSibling: null + }), (0, _opcodeCompiler.unwrapHandle)(handle), dynamicScope); + var iteratorResult; - case 'rehydrate': - return _runtime2.rehydrationBuilder.bind(null); + do { + iteratorResult = iterator.next(); + } while (!iteratorResult.done); - default: - return _runtime2.clientBuilder.bind(null); - } - } + var result = this.result = iteratorResult.value; // override .render function after initial render - }); - registry.injection('service:-dom-builder', 'bootOptions', '-environment:main'); - registry.injection('renderer', 'builder', 'service:-dom-builder'); - registry.register((0, _container.privatize)(_templateObject5()), RootTemplate); - registry.injection('renderer', 'rootTemplate', (0, _container.privatize)(_templateObject6())); - registry.register('renderer:-dom', InteractiveRenderer); - registry.register('renderer:-inert', InertRenderer); + this.render = () => result.rerender({ + alwaysRevalidate: false + }); + }; + } - if (_browserEnvironment.hasDOM) { - registry.injection('service:-glimmer-environment', 'updateOperations', 'service:-dom-changes'); + isFor(possibleRoot) { + return this.root === possibleRoot; } - registry.register('service:-dom-changes', { - create({ - document - }) { - return new _runtime2.DOMChanges(document); - } + destroy() { + var { + result, + runtime: { + env + } + } = this; + this.destroyed = true; + this.runtime = undefined; + this.root = null; + this.result = undefined; + this.render = undefined; - }); - registry.register('service:-dom-tree-construction', { - create({ - document - }) { - var Implementation = _browserEnvironment.hasDOM ? _runtime2.DOMTreeConstruction : _node.NodeDOMTreeConstruction; - return new Implementation(document); + if (result) { + /* + Handles these scenarios: + * When roots are removed during standard rendering process, a transaction exists already + `.begin()` / `.commit()` are not needed. + * When roots are being destroyed manually (`component.append(); component.destroy() case), no + transaction exists already. + * When roots are being destroyed during `Renderer#destroy`, no transaction exists + */ + (0, _runtime2.inTransaction)(env, () => result.destroy()); } + } - }); } - function setupEngineRegistry(registry) { - registry.optionsForType('template', { - instantiate: false - }); - registry.register('view:-outlet', OutletView); - registry.register('template:-outlet', OutletTemplate); - registry.injection('view:-outlet', 'template', 'template:-outlet'); - registry.injection('service:-dom-changes', 'document', 'service:-document'); - registry.injection('service:-dom-tree-construction', 'document', 'service:-document'); - registry.register((0, _container.privatize)(_templateObject7()), ComponentTemplate); - registry.register('service:-glimmer-environment', Environment$1); - registry.register((0, _container.privatize)(_templateObject8()), TemplateCompiler); - registry.injection((0, _container.privatize)(_templateObject9()), 'environment', '-environment:main'); - registry.optionsForType('helper', { - instantiate: false - }); - registry.register('helper:loc', loc$1); - registry.register('component:-text-field', TextField); - registry.register('component:-checkbox', Checkbox); - registry.register('component:link-to', LinkComponent); - registry.register('component:input', Input); - registry.register('template:components/input', InputTemplate); - registry.register('component:textarea', TextArea); + var renderers = []; - if (!_environment2.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS) { - registry.register((0, _container.privatize)(_templateObject10()), Component); - } + function _resetRenderers() { + renderers.length = 0; } - function setComponentManager(stringOrFunction, obj) { - var factory; + function register(renderer) { + (true && !(renderers.indexOf(renderer) === -1) && (0, _debug.assert)('Cannot register the same renderer twice', renderers.indexOf(renderer) === -1)); + renderers.push(renderer); + } - if (_deprecatedFeatures.COMPONENT_MANAGER_STRING_LOOKUP && typeof stringOrFunction === 'string') { - (true && !(false) && (0, _debug.deprecate)('Passing the name of the component manager to "setupComponentManager" is deprecated. Please pass a function that produces an instance of the manager.', false, { - id: 'deprecate-string-based-component-manager', - until: '4.0.0', - url: 'https://emberjs.com/deprecations/v3.x/#toc_component-manager-string-lookup' - })); + function deregister(renderer) { + var index = renderers.indexOf(renderer); + (true && !(index !== -1) && (0, _debug.assert)('Cannot deregister unknown unregistered renderer', index !== -1)); + renderers.splice(index, 1); + } - factory = function (owner) { - return owner.lookup("component-manager:" + stringOrFunction); - }; - } else { - factory = stringOrFunction; + function loopBegin() { + for (var _i13 = 0; _i13 < renderers.length; _i13++) { + renderers[_i13]._scheduleRevalidate(); } + } - return setManager({ - factory, - internal: false, - type: 'component' - }, obj); + function K() { + /* noop */ } - function getComponentManager(obj) { - var wrapper = getManager(obj); + var renderSettledDeferred = null; + /* + Returns a promise which will resolve when rendering has settled. Settled in + this context is defined as when all of the tags in use are "current" (e.g. + `renderers.every(r => r._isValid())`). When this is checked at the _end_ of + the run loop, this essentially guarantees that all rendering is completed. + + @method renderSettled + @returns {Promise} a promise which fulfills when rendering has settled + */ - if (wrapper && !wrapper.internal && wrapper.type === 'component') { - return wrapper.factory; - } else { - return undefined; + function renderSettled() { + if (renderSettledDeferred === null) { + renderSettledDeferred = _rsvp.default.defer(); // if there is no current runloop, the promise created above will not have + // a chance to resolve (because its resolved in backburner's "end" event) + + if (!(0, _runloop.getCurrentRunLoop)()) { + // ensure a runloop has been kicked off + _runloop.backburner.schedule('actions', null, K); + } } + + return renderSettledDeferred.promise; } - /** - [Glimmer](https://github.com/tildeio/glimmer) is a templating engine used by Ember.js that is compatible with a subset of the [Handlebars](http://handlebarsjs.com/) syntax. - - ### Showing a property - - Templates manage the flow of an application's UI, and display state (through - the DOM) to a user. For example, given a component with the property "name", - that component's template can use the name in several ways: - - ```app/components/person-profile.js - import Component from '@ember/component'; - - export default Component.extend({ - name: 'Jill' - }); - ``` - - ```app/templates/components/person-profile.hbs - {{name}} -
{{name}}
- - ``` - - Any time the "name" property on the component changes, the DOM will be - updated. - - Properties can be chained as well: - - ```handlebars - {{aUserModel.name}} -
{{listOfUsers.firstObject.name}}
- ``` - - ### Using Ember helpers - - When content is passed in mustaches `{{}}`, Ember will first try to find a helper - or component with that name. For example, the `if` helper: - - ```handlebars - {{if name "I have a name" "I have no name"}} - - ``` - - The returned value is placed where the `{{}}` is called. The above style is - called "inline". A second style of helper usage is called "block". For example: - - ```handlebars - {{#if name}} - I have a name - {{else}} - I have no name - {{/if}} - ``` - - The block form of helpers allows you to control how the UI is created based - on the values of properties. - A third form of helper is called "nested". For example here the concat - helper will add " Doe" to a displayed name if the person has no last name: - - ```handlebars - - ``` - - Ember's built-in helpers are described under the [Ember.Templates.helpers](/ember/release/classes/Ember.Templates.helpers) - namespace. Documentation on creating custom helpers can be found under - [helper](/ember/release/functions/@ember%2Fcomponent%2Fhelper/helper) (or - under [Helper](/ember/release/classes/Helper) if a helper requires access to - dependency injection). - - ### Invoking a Component - - Ember components represent state to the UI of an application. Further - reading on components can be found under [Component](/ember/release/classes/Component). - - @module @ember/component - @main @ember/component - @public - */ -}); -define("@ember/-internals/meta/index", ["exports", "@ember/-internals/meta/lib/meta"], function (_exports, _meta) { - "use strict"; + function resolveRenderPromise() { + if (renderSettledDeferred !== null) { + var resolve = renderSettledDeferred.resolve; + renderSettledDeferred = null; - Object.defineProperty(_exports, "__esModule", { - value: true - }); - Object.defineProperty(_exports, "counters", { - enumerable: true, - get: function () { - return _meta.counters; - } - }); - Object.defineProperty(_exports, "deleteMeta", { - enumerable: true, - get: function () { - return _meta.deleteMeta; - } - }); - Object.defineProperty(_exports, "Meta", { - enumerable: true, - get: function () { - return _meta.Meta; - } - }); - Object.defineProperty(_exports, "meta", { - enumerable: true, - get: function () { - return _meta.meta; - } - }); - Object.defineProperty(_exports, "peekMeta", { - enumerable: true, - get: function () { - return _meta.peekMeta; - } - }); - Object.defineProperty(_exports, "setMeta", { - enumerable: true, - get: function () { - return _meta.setMeta; - } - }); - Object.defineProperty(_exports, "UNDEFINED", { - enumerable: true, - get: function () { - return _meta.UNDEFINED; + _runloop.backburner.join(null, resolve); } - }); -}); -define("@ember/-internals/meta/lib/meta", ["exports", "@ember/-internals/utils", "@ember/debug", "@glimmer/reference"], function (_exports, _utils, _debug, _reference) { - "use strict"; - - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.setMeta = setMeta; - _exports.peekMeta = peekMeta; - _exports.deleteMeta = deleteMeta; - _exports.counters = _exports.meta = _exports.Meta = _exports.UNDEFINED = void 0; - var objectPrototype = Object.prototype; - var counters; - _exports.counters = counters; - - if (true - /* DEBUG */ - ) { - _exports.counters = counters = { - peekCalls: 0, - peekPrototypeWalks: 0, - setCalls: 0, - deleteCalls: 0, - metaCalls: 0, - metaInstantiated: 0, - matchingListenersCalls: 0, - observerEventsCalls: 0, - addToListenersCalls: 0, - removeFromListenersCalls: 0, - removeAllListenersCalls: 0, - listenersInherited: 0, - listenersFlattened: 0, - parentListenersUsed: 0, - flattenedListenersCalls: 0, - reopensAfterFlatten: 0, - readableLazyChainsCalls: 0, - writableLazyChainsCalls: 0 - }; } - /** - @module ember - */ + var loops = 0; - var UNDEFINED = (0, _utils.symbol)('undefined'); - _exports.UNDEFINED = UNDEFINED; - var currentListenerVersion = 1; + function loopEnd() { + for (var _i14 = 0; _i14 < renderers.length; _i14++) { + if (!renderers[_i14]._isValid()) { + if (loops > _environment2.ENV._RERENDER_LOOP_LIMIT) { + loops = 0; // TODO: do something better - class Meta { - constructor(obj) { - this._listenersVersion = 1; - this._inheritedEnd = -1; - this._flattenedVersion = 0; + renderers[_i14].destroy(); - if (true - /* DEBUG */ - ) { - counters.metaInstantiated++; - this._values = undefined; - } + throw new Error('infinite rendering invalidation detected'); + } - this._parent = undefined; - this._descriptors = undefined; - this._mixins = undefined; - this._tag = undefined; - this._tags = undefined; // initial value for all flags right now is false - // see FLAGS const for detailed list of flags used + loops++; + return _runloop.backburner.join(null, K); + } + } - this._flags = 0 - /* NONE */ - ; // used only internally + loops = 0; + resolveRenderPromise(); + } - this.source = obj; - this.proto = obj.constructor === undefined ? undefined : obj.constructor.prototype; - this._listeners = undefined; - } + _runloop.backburner.on('begin', loopBegin); - get parent() { - var parent = this._parent; + _runloop.backburner.on('end', loopEnd); - if (parent === undefined) { - var proto = getPrototypeOf(this.source); - this._parent = parent = proto === null || proto === objectPrototype ? null : meta(proto); - } + class Renderer { + constructor(owner, document, env, rootTemplate, viewRegistry, destinedForDOM = false, builder = _runtime2.clientBuilder) { + this._inRenderTransaction = false; + this._lastRevision = -1; + this._destroyed = false; + this._rootTemplate = rootTemplate(owner); + this._viewRegistry = viewRegistry; + this._destinedForDOM = destinedForDOM; + this._roots = []; + this._removedRoots = []; + this._builder = builder; // resolver is exposed for tests - return parent; + var runtimeResolver = this._runtimeResolver = new RuntimeResolver(env.isInteractive); + var compileTimeResolver = new CompileTimeResolver(runtimeResolver); + this._context = (0, _opcodeCompiler.JitContext)(compileTimeResolver); + populateMacros(this._context.macros); + var program = new _program.RuntimeProgramImpl(this._context.program.constants, this._context.program.heap); + var runtimeEnvironmentDelegate = new EmberEnvironmentDelegate(owner, env.isInteractive); + this._runtime = (0, _runtime2.JitRuntimeFromProgram)({ + appendOperations: env.hasDOM ? new _runtime2.DOMTreeConstruction(document) : new _node.NodeDOMTreeConstruction(document), + updateOperations: new _runtime2.DOMChanges(document) + }, program, runtimeResolver, runtimeEnvironmentDelegate); } - setInitializing() { - this._flags |= 8 - /* INITIALIZING */ - ; - } + get debugRenderTree() { + return this._runtime.env.extra.debugRenderTree; + } // renderer HOOKS - unsetInitializing() { - this._flags ^= 8 - /* INITIALIZING */ - ; - } - isInitializing() { - return this._hasFlag(8 - /* INITIALIZING */ - ); - } + appendOutletView(view, target) { + var definition = createRootOutlet(view); - isPrototypeMeta(obj) { - return this.proto === this.source && this.source === obj; + this._appendDefinition(view, (0, _runtime2.curry)(definition), target); } - destroy() { - if (this.isMetaDestroyed()) { - return; - } + appendTo(view, target) { + var definition = new RootComponentDefinition(view); - this.setMetaDestroyed(); + this._appendDefinition(view, (0, _runtime2.curry)(definition), target); } - isSourceDestroying() { - return this._hasFlag(1 - /* SOURCE_DESTROYING */ - ); - } + _appendDefinition(root, definition, target) { + var self = new UnboundRootReference(definition, this._runtime.env); + var dynamicScope = new DynamicScope(null, _runtime2.UNDEFINED_REFERENCE); + var rootState = new RootState(root, this._runtime, this._context, this._rootTemplate, self, target, dynamicScope, this._builder); - setSourceDestroying() { - this._flags |= 1 - /* SOURCE_DESTROYING */ - ; + this._renderRoot(rootState); } - isSourceDestroyed() { - return this._hasFlag(2 - /* SOURCE_DESTROYED */ - ); + rerender() { + this._scheduleRevalidate(); } - setSourceDestroyed() { - this._flags |= 2 - /* SOURCE_DESTROYED */ - ; + register(view) { + var id = (0, _views.getViewId)(view); + (true && !(!this._viewRegistry[id]) && (0, _debug.assert)('Attempted to register a view with an id already in use: ' + id, !this._viewRegistry[id])); + this._viewRegistry[id] = view; } - isMetaDestroyed() { - return this._hasFlag(4 - /* META_DESTROYED */ - ); + unregister(view) { + delete this._viewRegistry[(0, _views.getViewId)(view)]; } - setMetaDestroyed() { - this._flags |= 4 - /* META_DESTROYED */ - ; - } + remove(view) { + view._transitionTo('destroying'); - _hasFlag(flag) { - return (this._flags & flag) === flag; - } + this.cleanupRootFor(view); - _getOrCreateOwnMap(key) { - return this[key] || (this[key] = Object.create(null)); + if (this._destinedForDOM) { + view.trigger('didDestroyElement'); + } } - _getOrCreateOwnSet(key) { - return this[key] || (this[key] = new Set()); - } + cleanupRootFor(view) { + // no need to cleanup roots if we have already been destroyed + if (this._destroyed) { + return; + } - _findInheritedMap(key, subkey) { - var pointer = this; + var roots = this._roots; // traverse in reverse so we can remove items + // without mucking up the index - while (pointer !== null) { - var map = pointer[key]; + var i = this._roots.length; - if (map !== undefined) { - var value = map.get(subkey); + while (i--) { + var root = roots[i]; - if (value !== undefined) { - return value; - } + if (root.isFor(view)) { + root.destroy(); + roots.splice(i, 1); } - - pointer = pointer.parent; } } - _hasInInheritedSet(key, value) { - var pointer = this; - - while (pointer !== null) { - var set = pointer[key]; - - if (set !== undefined && set.has(value)) { - return true; - } - - pointer = pointer.parent; + destroy() { + if (this._destroyed) { + return; } - return false; + this._destroyed = true; + + this._clearAllRoots(); } - writableTags() { - return this._getOrCreateOwnMap('_tags'); + getBounds(view) { + var bounds = view[BOUNDS]; + (true && !(Boolean(bounds)) && (0, _debug.assert)('object passed to getBounds must have the BOUNDS symbol as a property', Boolean(bounds))); + var parentElement = bounds.parentElement(); + var firstNode = bounds.firstNode(); + var lastNode = bounds.lastNode(); + return { + parentElement, + firstNode, + lastNode + }; } - readableTags() { - return this._tags; + createElement(tagName) { + return this._runtime.env.getAppendOperations().createElement(tagName); } - writableTag() { - (true && !(!this.isMetaDestroyed()) && (0, _debug.assert)(this.isMetaDestroyed() ? "Cannot create a new tag for `" + (0, _utils.toString)(this.source) + "` after it has been destroyed." : '', !this.isMetaDestroyed())); - var ret = this._tag; + _renderRoot(root) { + var { + _roots: roots + } = this; + roots.push(root); - if (ret === undefined) { - ret = this._tag = (0, _reference.createUpdatableTag)(); + if (roots.length === 1) { + register(this); } - return ret; - } - - readableTag() { - return this._tag; + this._renderRootsTransaction(); } - writableLazyChainsFor(key) { - if (true - /* DEBUG */ - ) { - counters.writableLazyChainsCalls++; - } + _renderRoots() { + var { + _roots: roots, + _runtime: runtime, + _removedRoots: removedRoots + } = this; + var initialRootsLength; - var lazyChains = this._getOrCreateOwnMap('_lazyChains'); + do { + initialRootsLength = roots.length; + (0, _runtime2.inTransaction)(runtime.env, () => { + // ensure that for the first iteration of the loop + // each root is processed + for (var _i15 = 0; _i15 < roots.length; _i15++) { + var root = roots[_i15]; - if (!(key in lazyChains)) { - lazyChains[key] = Object.create(null); - } + if (root.destroyed) { + // add to the list of roots to be removed + // they will be removed from `this._roots` later + removedRoots.push(root); // skip over roots that have been marked as destroyed - return lazyChains[key]; - } + continue; + } // when processing non-initial reflush loops, + // do not process more roots than needed - readableLazyChainsFor(key) { - if (true - /* DEBUG */ - ) { - counters.readableLazyChainsCalls++; - } - var lazyChains = this._lazyChains; + if (_i15 >= initialRootsLength) { + continue; + } - if (lazyChains !== undefined) { - return lazyChains[key]; - } + if (true + /* DEBUG */ + ) { + // run in an autotracking transaction to prevent backflow errors. + // we use `bind` here to avoid creating a closure (and requiring a + // hoisted variable). + (0, _validator.runInAutotrackingTransaction)(root.render.bind(root)); + } else { + root.render(); + } + } - return undefined; - } + this._lastRevision = (0, _validator.value)(_validator.CURRENT_TAG); + }); + } while (roots.length > initialRootsLength); // remove any roots that were destroyed during this transaction - addMixin(mixin) { - (true && !(!this.isMetaDestroyed()) && (0, _debug.assert)(this.isMetaDestroyed() ? "Cannot add mixins of `" + (0, _utils.toString)(mixin) + "` on `" + (0, _utils.toString)(this.source) + "` call addMixin after it has been destroyed." : '', !this.isMetaDestroyed())); - var set = this._getOrCreateOwnSet('_mixins'); + while (removedRoots.length) { + var root = removedRoots.pop(); + var rootIndex = roots.indexOf(root); + roots.splice(rootIndex, 1); + } - set.add(mixin); + if (this._roots.length === 0) { + deregister(this); + } } - hasMixin(mixin) { - return this._hasInInheritedSet('_mixins', mixin); - } + _renderRootsTransaction() { + if (this._inRenderTransaction) { + // currently rendering roots, a new root was added and will + // be processed by the existing _renderRoots invocation + return; + } // used to prevent calling _renderRoots again (see above) + // while we are actively rendering roots - forEachMixins(fn) { - var pointer = this; - var seen; - while (pointer !== null) { - var set = pointer._mixins; + this._inRenderTransaction = true; + var completedWithoutError = false; - if (set !== undefined) { - seen = seen === undefined ? new Set() : seen; // TODO cleanup typing here + try { + this._renderRoots(); - set.forEach(mixin => { - if (!seen.has(mixin)) { - seen.add(mixin); - fn(mixin); - } - }); + completedWithoutError = true; + } finally { + if (!completedWithoutError) { + this._lastRevision = (0, _validator.value)(_validator.CURRENT_TAG); } - pointer = pointer.parent; + this._inRenderTransaction = false; } } - writeDescriptors(subkey, value) { - (true && !(!this.isMetaDestroyed()) && (0, _debug.assert)(this.isMetaDestroyed() ? "Cannot update descriptors for `" + subkey + "` on `" + (0, _utils.toString)(this.source) + "` after it has been destroyed." : '', !this.isMetaDestroyed())); - var map = this._descriptors || (this._descriptors = new Map()); - map.set(subkey, value); - } + _clearAllRoots() { + var roots = this._roots; - peekDescriptors(subkey) { - var possibleDesc = this._findInheritedMap('_descriptors', subkey); + for (var _i16 = 0; _i16 < roots.length; _i16++) { + var root = roots[_i16]; + root.destroy(); + } - return possibleDesc === UNDEFINED ? undefined : possibleDesc; - } + this._removedRoots.length = 0; + this._roots = []; // if roots were present before destroying + // deregister this renderer instance - removeDescriptors(subkey) { - this.writeDescriptors(subkey, UNDEFINED); + if (roots.length) { + deregister(this); + } } - forEachDescriptors(fn) { - var pointer = this; - var seen; - - while (pointer !== null) { - var map = pointer._descriptors; - - if (map !== undefined) { - seen = seen === undefined ? new Set() : seen; - map.forEach((value, key) => { - if (!seen.has(key)) { - seen.add(key); - - if (value !== UNDEFINED) { - fn(key, value); - } - } - }); - } + _scheduleRevalidate() { + _runloop.backburner.scheduleOnce('render', this, this._revalidate); + } - pointer = pointer.parent; - } + _isValid() { + return this._destroyed || this._roots.length === 0 || (0, _validator.validate)(_validator.CURRENT_TAG, this._lastRevision); } - addToListeners(eventName, target, method, once, sync) { - if (true - /* DEBUG */ - ) { - counters.addToListenersCalls++; + _revalidate() { + if (this._isValid()) { + return; } - this.pushListener(eventName, target, method, once ? 1 - /* ONCE */ - : 0 - /* ADD */ - , sync); + this._renderRootsTransaction(); } - removeFromListeners(eventName, target, method) { - if (true - /* DEBUG */ - ) { - counters.removeFromListenersCalls++; - } + } - this.pushListener(eventName, target, method, 2 - /* REMOVE */ - ); - } - - pushListener(event, target, method, kind, sync = false) { - var listeners = this.writableListeners(); - var i = indexOfListener(listeners, event, target, method); // remove if found listener was inherited - - if (i !== -1 && i < this._inheritedEnd) { - listeners.splice(i, 1); - this._inheritedEnd--; - i = -1; - } // if not found, push. Note that we must always push if a listener is not - // found, even in the case of a function listener remove, because we may be - // attempting to add or remove listeners _before_ flattening has occured. - - - if (i === -1) { - (true && !(!(this.isPrototypeMeta(this.source) && typeof method === 'function')) && (0, _debug.assert)('You cannot add function listeners to prototypes. Convert the listener to a string listener, or add it to the instance instead.', !(this.isPrototypeMeta(this.source) && typeof method === 'function'))); - (true && !(!(!this.isPrototypeMeta(this.source) && typeof method === 'function' && kind === 2 - /* REMOVE */ - )) && (0, _debug.assert)('You attempted to remove a function listener which did not exist on the instance, which means you may have attempted to remove it before it was added.', !(!this.isPrototypeMeta(this.source) && typeof method === 'function' && kind === 2))); - listeners.push({ - event, - target, - method, - kind, - sync - }); - } else { - var listener = listeners[i]; // If the listener is our own listener and we are trying to remove it, we - // want to splice it out entirely so we don't hold onto a reference. - - if (kind === 2 - /* REMOVE */ - && listener.kind !== 2 - /* REMOVE */ - ) { - listeners.splice(i, 1); - } else { - (true && !(!(listener.kind === 0 - /* ADD */ - && kind === 0 - /* ADD */ - && listener.sync !== sync)) && (0, _debug.assert)("You attempted to add an observer for the same method on '" + event.split(':')[0] + "' twice to " + target + " as both sync and async. Observers must be either sync or async, they cannot be both. This is likely a mistake, you should either remove the code that added the observer a second time, or update it to always be sync or async. The method was " + method + ".", !(listener.kind === 0 && kind === 0 && listener.sync !== sync))); // update own listener + _exports.Renderer = Renderer; - listener.kind = kind; - listener.sync = sync; - } - } + class InertRenderer extends Renderer { + static create({ + [_owner.OWNER]: owner, + document, + env, + rootTemplate, + _viewRegistry, + builder + }) { + return new this(owner, document, env, rootTemplate, _viewRegistry, false, builder); } - writableListeners() { - // Check if we need to invalidate and reflatten. We need to do this if we - // have already flattened (flattened version is the current version) and - // we are either writing to a prototype meta OR we have never inherited, and - // may have cached the parent's listeners. - if (this._flattenedVersion === currentListenerVersion && (this.source === this.proto || this._inheritedEnd === -1)) { - if (true - /* DEBUG */ - ) { - counters.reopensAfterFlatten++; - } - - currentListenerVersion++; - } // Inherited end has not been set, then we have never created our own - // listeners, but may have cached the parent's - - - if (this._inheritedEnd === -1) { - this._inheritedEnd = 0; - this._listeners = []; - } - - return this._listeners; + getElement(_view) { + throw new Error('Accessing `this.element` is not allowed in non-interactive environments (such as FastBoot).'); } - /** - Flattening is based on a global revision counter. If the revision has - bumped it means that somewhere in a class inheritance chain something has - changed, so we need to reflatten everything. This can only happen if: - 1. A meta has been flattened (listener has been called) - 2. The meta is a prototype meta with children who have inherited its - listeners - 3. A new listener is subsequently added to the meta (e.g. via `.reopen()`) - This is a very rare occurence, so while the counter is global it shouldn't - be updated very often in practice. - */ - - - flattenedListeners() { - if (true - /* DEBUG */ - ) { - counters.flattenedListenersCalls++; - } - - if (this._flattenedVersion < currentListenerVersion) { - if (true - /* DEBUG */ - ) { - counters.listenersFlattened++; - } - var parent = this.parent; - - if (parent !== null) { - // compute - var parentListeners = parent.flattenedListeners(); + } - if (parentListeners !== undefined) { - if (this._listeners === undefined) { - // If this instance doesn't have any of its own listeners (writableListeners - // has never been called) then we don't need to do any flattening, return - // the parent's listeners instead. - if (true - /* DEBUG */ - ) { - counters.parentListenersUsed++; - } + _exports.InertRenderer = InertRenderer; - this._listeners = parentListeners; - } else { - var listeners = this._listeners; + class InteractiveRenderer extends Renderer { + static create({ + [_owner.OWNER]: owner, + document, + env, + rootTemplate, + _viewRegistry, + builder + }) { + return new this(owner, document, env, rootTemplate, _viewRegistry, true, builder); + } - if (this._inheritedEnd > 0) { - listeners.splice(0, this._inheritedEnd); - this._inheritedEnd = 0; - } + getElement(view) { + return (0, _views.getViewElement)(view); + } - for (var i = 0; i < parentListeners.length; i++) { - var listener = parentListeners[i]; - var index = indexOfListener(listeners, listener.event, listener.target, listener.method); + } - if (index === -1) { - if (true - /* DEBUG */ - ) { - counters.listenersInherited++; - } + _exports.InteractiveRenderer = InteractiveRenderer; + var TEMPLATES$1 = {}; - listeners.unshift(listener); - this._inheritedEnd++; - } - } - } - } - } + function setTemplates(templates) { + TEMPLATES$1 = templates; + } - this._flattenedVersion = currentListenerVersion; - } + function getTemplates() { + return TEMPLATES$1; + } - return this._listeners; + function getTemplate(name) { + if (TEMPLATES$1.hasOwnProperty(name)) { + return TEMPLATES$1[name]; } + } - matchingListeners(eventName) { - var listeners = this.flattenedListeners(); - var result; + function hasTemplate(name) { + return TEMPLATES$1.hasOwnProperty(name); + } - if (true - /* DEBUG */ - ) { - counters.matchingListenersCalls++; - } + function setTemplate(name, template) { + return TEMPLATES$1[name] = template; + } - if (listeners !== undefined) { - for (var index = 0; index < listeners.length; index++) { - var listener = listeners[index]; // REMOVE listeners are placeholders that tell us not to - // inherit, so they never match. Only ADD and ONCE can match. + var CAPABILITIES$4 = { + dynamicLayout: false, + dynamicTag: false, + prepareArgs: true, + createArgs: true, + attributeHook: false, + elementHook: false, + createCaller: true, + dynamicScope: false, + updateHook: true, + createInstance: true, + wrapped: false, + willDestroy: false + }; + var EMPTY_POSITIONAL_ARGS$1 = []; + (0, _debug.debugFreeze)(EMPTY_POSITIONAL_ARGS$1); - if (listener.event === eventName && (listener.kind === 0 - /* ADD */ - || listener.kind === 1 - /* ONCE */ - )) { - if (result === undefined) { - // we create this array only after we've found a listener that - // matches to avoid allocations when no matches are found. - result = []; - } + class InputComponentManager extends InternalManager { + getCapabilities() { + return CAPABILITIES$4; + } - result.push(listener.target, listener.method, listener.kind === 1 - /* ONCE */ - ); - } + prepareArgs(_state, args) { + (true && !(args.positional.length === 0) && (0, _debug.assert)('The `` component does not take any positional arguments', args.positional.length === 0)); + var __ARGS__ = args.named.capture().map; + return { + positional: EMPTY_POSITIONAL_ARGS$1, + named: { + __ARGS__: new _reference.ConstReference(__ARGS__), + type: args.named.get('type') } - } - - return result; + }; } - observerEvents() { - var listeners = this.flattenedListeners(); - var result; - - if (true - /* DEBUG */ - ) { - counters.observerEventsCalls++; - } - - if (listeners !== undefined) { - for (var index = 0; index < listeners.length; index++) { - var listener = listeners[index]; // REMOVE listeners are placeholders that tell us not to - // inherit, so they never match. Only ADD and ONCE can match. - - if ((listener.kind === 0 - /* ADD */ - || listener.kind === 1 - /* ONCE */ - ) && listener.event.indexOf(':change') !== -1) { - if (result === undefined) { - // we create this array only after we've found a listener that - // matches to avoid allocations when no matches are found. - result = []; - } + create(env, { + ComponentClass, + layout + }, args, _dynamicScope, caller) { + (true && !((0, _validator.isConst)(caller)) && (0, _debug.assert)('caller must be const', (0, _validator.isConst)(caller))); + var type = args.named.get('type'); + var instance = ComponentClass.create({ + caller: caller.value(), + type: type.value() + }); + var state = { + env, + type, + instance + }; - result.push(listener); - } - } + if (_environment2.ENV._DEBUG_RENDER_TREE) { + env.extra.debugRenderTree.create(state, { + type: 'component', + name: 'input', + args: args.capture(), + instance, + template: layout + }); } - return result; + return state; } - } - - _exports.Meta = Meta; - var getPrototypeOf = Object.getPrototypeOf; - var metaStore = new WeakMap(); - - function setMeta(obj, meta) { - (true && !(obj !== null) && (0, _debug.assert)('Cannot call `setMeta` on null', obj !== null)); - (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `setMeta` on undefined', obj !== undefined)); - (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)("Cannot call `setMeta` on " + typeof obj, typeof obj === 'object' || typeof obj === 'function')); - - if (true - /* DEBUG */ - ) { - counters.setCalls++; + getSelf({ + env, + instance + }) { + return new _reference.ComponentRootReference(instance, env); } - metaStore.set(obj, meta); - } - - function peekMeta(obj) { - (true && !(obj !== null) && (0, _debug.assert)('Cannot call `peekMeta` on null', obj !== null)); - (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `peekMeta` on undefined', obj !== undefined)); - (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)("Cannot call `peekMeta` on " + typeof obj, typeof obj === 'object' || typeof obj === 'function')); - - if (true - /* DEBUG */ - ) { - counters.peekCalls++; + getTag() { + if (_environment2.ENV._DEBUG_RENDER_TREE) { + // returning a const tag skips the update hook (VM BUG?) + return (0, _validator.createTag)(); + } else { + // an outlet has no hooks + return _validator.CONSTANT_TAG; + } } - var meta = metaStore.get(obj); - - if (meta !== undefined) { - return meta; + didRenderLayout(state, bounds) { + if (_environment2.ENV._DEBUG_RENDER_TREE) { + state.env.extra.debugRenderTree.didRender(state, bounds); + } } - var pointer = getPrototypeOf(obj); + update(state) { + (0, _metal.set)(state.instance, 'type', state.type.value()); - while (pointer !== null) { - if (true - /* DEBUG */ - ) { - counters.peekPrototypeWalks++; + if (_environment2.ENV._DEBUG_RENDER_TREE) { + state.env.extra.debugRenderTree.update(state); } + } - meta = metaStore.get(pointer); + didUpdateLayout(state, bounds) { + if (_environment2.ENV._DEBUG_RENDER_TREE) { + state.env.extra.debugRenderTree.didRender(state, bounds); + } + } - if (meta !== undefined) { - if (meta.proto !== pointer) { - // The meta was a prototype meta which was not marked as initializing. - // This can happen when a prototype chain was created manually via - // Object.create() and the source object does not have a constructor. - meta.proto = pointer; - } + getDestructor(state) { + if (_environment2.ENV._DEBUG_RENDER_TREE) { + return { + destroy() { + state.env.extra.debugRenderTree.willDestroy(state); + state.instance.destroy(); + } - return meta; + }; + } else { + return state.instance; } - - pointer = getPrototypeOf(pointer); } - return null; } + + var InputComponentManagerFactory = owner => { + return new InputComponentManager(owner); + }; /** - Tears down the meta on an object so that it can be garbage collected. - Multiple calls will have no effect. - - @method deleteMeta - @for Ember - @param {Object} obj the object to destroy - @return {void} - @private + @module @ember/component */ + /** + See [Ember.Templates.components.Input](/ember/release/classes/Ember.Templates.components/methods/Input?anchor=Input). + + @method input + @for Ember.Templates.helpers + @param {Hash} options + @public + */ - function deleteMeta(obj) { - (true && !(obj !== null) && (0, _debug.assert)('Cannot call `deleteMeta` on null', obj !== null)); - (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `deleteMeta` on undefined', obj !== undefined)); - (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)("Cannot call `deleteMeta` on " + typeof obj, typeof obj === 'object' || typeof obj === 'function')); - - if (true - /* DEBUG */ - ) { - counters.deleteCalls++; - } - - var meta = peekMeta(obj); - - if (meta !== null) { - meta.destroy(); - } - } /** - Retrieves the meta hash for an object. If `writable` is true ensures the - hash is writable for this object as well. + The `Input` component lets you create an HTML `` element. - The meta object contains information about computed property descriptors as - well as any watched properties and other information. You generally will - not access this information directly but instead work with higher level - methods that manipulate this hash indirectly. + ```handlebars + + ``` - @method meta - @for Ember - @private + creates an `` element with `type="text"` and value set to 987. - @param {Object} obj The object to retrieve meta for - @param {Boolean} [writable=true] Pass `false` if you do not intend to modify - the meta hash, allowing the method to avoid making an unnecessary copy. - @return {Object} the meta hash for an object + ### Text field + + If no `type` argument is specified, a default of type 'text' is used. + + ```handlebars + Search: + + ``` + + In this example, the initial value in the `` will be set to the value of + `this.searchWord`. If the user changes the text, the value of `this.searchWord` will also be + updated. + + ### Actions + + The `Input` component takes a number of arguments with callbacks that are invoked in response to + user events. + + * `enter` + * `insert-newline` + * `escape-press` + * `focus-in` + * `focus-out` + * `key-down` + * `key-press` + * `key-up` + + These callbacks are passed to `Input` like this: + + ```handlebars + + ``` + + ### `` HTML Attributes to Avoid + + In most cases, if you want to pass an attribute to the underlying HTML `` element, you + can pass the attribute directly, just like any other Ember component. + + ```handlebars + + ``` + + In this example, the `size` attribute will be applied to the underlying `` element in the + outputted HTML. + + However, there are a few attributes where you **must** use the `@` version. + + * `@type`: This argument is used to control which Ember component is used under the hood + * `@value`: The `@value` argument installs a two-way binding onto the element. If you wanted a + one-way binding, use `` with the `value` property and the `input` event instead. + * `@checked` (for checkboxes): like `@value`, the `@checked` argument installs a two-way binding + onto the element. If you wanted a one-way binding, use `` with + `checked` and the `input` event instead. + + ### Extending `TextField` + + Internally, `` creates an instance of `TextField`, passing arguments from + the helper to `TextField`'s `create` method. Subclassing `TextField` is supported but not + recommended. + + See [TextField](/ember/release/classes/TextField) + + ### Checkbox + + To create an ``: + + ```handlebars + Emberize Everything: + + ``` + + This will bind the checked state of this checkbox to the value of `isEmberized` -- if either one + changes, it will be reflected in the other. + + ### Extending `Checkbox` + + Internally, `` creates an instance of `Checkbox`. Subclassing + `TextField` is supported but not recommended. + + See [Checkbox](/ember/release/classes/Checkbox) + + @method Input + @for Ember.Templates.components + @see {TextField} + @see {Checkbox} + @param {Hash} options + @public */ - var meta = function meta(obj) { - (true && !(obj !== null) && (0, _debug.assert)('Cannot call `meta` on null', obj !== null)); - (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `meta` on undefined', obj !== undefined)); - (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)("Cannot call `meta` on " + typeof obj, typeof obj === 'object' || typeof obj === 'function')); - - if (true - /* DEBUG */ - ) { - counters.metaCalls++; - } + var Input = _runtime.Object.extend({ + isCheckbox: (0, _metal.computed)('type', function () { + return this.type === 'checkbox'; + }) + }); - var maybeMeta = peekMeta(obj); // remove this code, in-favor of explicit parent + setManager({ + factory: InputComponentManagerFactory, + internal: true, + type: 'component' + }, Input); - if (maybeMeta !== null && maybeMeta.source === obj) { - return maybeMeta; - } + Input.toString = () => '@ember/component/input'; + /** + @module ember + */ - var newMeta = new Meta(obj); - setMeta(obj, newMeta); - return newMeta; - }; - - _exports.meta = meta; - - if (true - /* DEBUG */ - ) { - meta._counters = counters; - } - - function indexOfListener(listeners, event, target, method) { - for (var i = listeners.length - 1; i >= 0; i--) { - var listener = listeners[i]; - - if (listener.event === event && listener.target === target && listener.method === method) { - return i; - } - } - - return -1; - } -}); -define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ember/-internals/utils", "@ember/debug", "@ember/-internals/environment", "@ember/runloop", "@glimmer/reference", "@ember/polyfills", "@ember/error", "ember/version", "@ember/deprecated-features", "@ember/-internals/owner"], function (_exports, _meta2, _utils, _debug, _environment, _runloop, _reference, _polyfills, _error, _version, _deprecatedFeatures, _owner) { - "use strict"; - - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.computed = computed; - _exports.isComputed = isComputed; - _exports.getCacheFor = getCacheFor; - _exports.getCachedValueFor = getCachedValueFor; - _exports.peekCacheFor = peekCacheFor; - _exports.alias = alias; - _exports.deprecateProperty = deprecateProperty; - _exports._getPath = _getPath; - _exports.get = get; - _exports.getWithDefault = getWithDefault; - _exports.set = set; - _exports.trySet = trySet; - _exports.objectAt = objectAt; - _exports.replace = replace; - _exports.replaceInNativeArray = replaceInNativeArray; - _exports.addArrayObserver = addArrayObserver; - _exports.removeArrayObserver = removeArrayObserver; - _exports.arrayContentWillChange = arrayContentWillChange; - _exports.arrayContentDidChange = arrayContentDidChange; - _exports.eachProxyArrayWillChange = eachProxyArrayWillChange; - _exports.eachProxyArrayDidChange = eachProxyArrayDidChange; - _exports.addListener = addListener; - _exports.hasListeners = hasListeners; - _exports.on = on; - _exports.removeListener = removeListener; - _exports.sendEvent = sendEvent; - _exports.isNone = isNone; - _exports.isEmpty = isEmpty; - _exports.isBlank = isBlank; - _exports.isPresent = isPresent; - _exports.beginPropertyChanges = beginPropertyChanges; - _exports.changeProperties = changeProperties; - _exports.endPropertyChanges = endPropertyChanges; - _exports.notifyPropertyChange = notifyPropertyChange; - _exports.defineProperty = defineProperty; - _exports.isElementDescriptor = isElementDescriptor; - _exports.nativeDescDecorator = nativeDescDecorator; - _exports.descriptorForDecorator = descriptorForDecorator; - _exports.descriptorForProperty = descriptorForProperty; - _exports.isClassicDecorator = isClassicDecorator; - _exports.setClassicDecorator = setClassicDecorator; - _exports.getChainTagsForKey = getChainTagsForKey; - _exports.getProperties = getProperties; - _exports.setProperties = setProperties; - _exports.expandProperties = expandProperties; - _exports.addObserver = addObserver; - _exports.activateObserver = activateObserver; - _exports.removeObserver = removeObserver; - _exports.flushAsyncObservers = flushAsyncObservers; - _exports.mixin = mixin; - _exports.observer = observer; - _exports.applyMixin = applyMixin; - _exports.inject = inject; - _exports.tagForProperty = tagForProperty; - _exports.createTagForProperty = createTagForProperty; - _exports.tagFor = tagFor; - _exports.markObjectAsDirty = markObjectAsDirty; - _exports.consume = consume; - _exports.tracked = tracked; - _exports.track = track; - _exports.untrack = untrack; - _exports.isTracking = isTracking; - _exports.addNamespace = addNamespace; - _exports.classToString = classToString; - _exports.findNamespace = findNamespace; - _exports.findNamespaces = findNamespaces; - _exports.processNamespace = processNamespace; - _exports.processAllNamespaces = processAllNamespaces; - _exports.removeNamespace = removeNamespace; - _exports.isNamespaceSearchDisabled = isSearchDisabled; - _exports.setNamespaceSearchDisabled = setSearchDisabled; - _exports.NAMESPACES_BY_ID = _exports.NAMESPACES = _exports.deprecateMutationsInAutotrackingTransaction = _exports.runInAutotrackingTransaction = _exports.Tracker = _exports.CUSTOM_TAG_FOR = _exports.DEBUG_INJECTION_FUNCTIONS = _exports.aliasMethod = _exports.Mixin = _exports.Libraries = _exports.libraries = _exports.PROPERTY_DID_CHANGE = _exports.PROXY_CONTENT = _exports.ComputedProperty = _exports._globalsComputed = void 0; - var COMPUTED_PROPERTY_CACHED_VALUES = new WeakMap(); - var COMPUTED_PROPERTY_LAST_REVISION = new WeakMap(); - - function getCacheFor(obj) { - var cache = COMPUTED_PROPERTY_CACHED_VALUES.get(obj); - - if (cache === undefined) { - cache = new Map(); - COMPUTED_PROPERTY_CACHED_VALUES.set(obj, cache); - } - - return cache; - } /** - Returns the cached value for a property, if one exists. - This can be useful for peeking at the value of a computed - property that is generated lazily, without accidentally causing - it to be created. + Calls [String.loc](/ember/release/classes/String/methods/loc?anchor=loc) with the + provided string. This is a convenient way to localize text within a template. + For example: - @method cacheFor - @static - @for @ember/object/internals - @param {Object} obj the object whose property you want to check - @param {String} key the name of the property whose cached value you want - to return - @return {Object} the cached value + ```javascript + Ember.STRINGS = { + '_welcome_': 'Bonjour' + }; + ``` + + ```handlebars +
+ {{loc '_welcome_'}} +
+ ``` + + ```html +
+ Bonjour +
+ ``` + + See [String.loc](/ember/release/classes/String/methods/loc?anchor=loc) for how to + set up localized string references. + + @method loc + @for Ember.Templates.helpers + @param {String} str The string to format. + @see {String#loc} @public */ - function getCachedValueFor(obj, key) { - var cache = COMPUTED_PROPERTY_CACHED_VALUES.get(obj); - - if (cache !== undefined) { - return cache.get(key); + var loc$1 = helper(function (params) { + return _string.loc.apply(null, params + /* let the other side handle errors */ + ); + }); + var ComponentTemplate = template({ + "id": "F6E3y+Xw", + "block": "{\"symbols\":[\"&default\"],\"statements\":[[16,1,null]],\"hasEval\":false,\"upvars\":[]}", + "meta": { + "moduleName": "packages/@ember/-internals/glimmer/lib/templates/component.hbs" } - } - - function setLastRevisionFor(obj, key, revision) { - var cache = COMPUTED_PROPERTY_LAST_REVISION.get(obj); - - if (cache === undefined) { - cache = new Map(); - COMPUTED_PROPERTY_LAST_REVISION.set(obj, cache); + }); + var InputTemplate = template({ + "id": "lIqKQBPA", + "block": "{\"symbols\":[\"Checkbox\",\"TextField\",\"@__ARGS__\",\"&attrs\"],\"statements\":[[5,[27,[26,2,\"BlockHead\"],[]],[[31,9,9,[27,[26,1,\"CallHead\"],[]],[\"-checkbox\"],null],[31,33,9,[27,[26,1,\"CallHead\"],[]],[\"-text-field\"],null]],null,[[\"default\"],[{\"statements\":[[5,[27,[26,0,\"BlockHead\"],[]],[[27,[24,0],[\"isCheckbox\"]]],null,[[\"default\",\"else\"],[{\"statements\":[[7,[27,[24,1],[]],[[15,4]],[[\"@target\",\"@__ARGS__\"],[[27,[24,0],[\"caller\"]],[27,[24,3],[]]]],null]],\"parameters\":[]},{\"statements\":[[7,[27,[24,2],[]],[[15,4]],[[\"@target\",\"@__ARGS__\"],[[27,[24,0],[\"caller\"]],[27,[24,3],[]]]],null]],\"parameters\":[]}]]]],\"parameters\":[1,2]}]]]],\"hasEval\":false,\"upvars\":[\"if\",\"component\",\"let\"]}", + "meta": { + "moduleName": "packages/@ember/-internals/glimmer/lib/templates/input.hbs" } - - cache.set(key, revision); - } - - function getLastRevisionFor(obj, key) { - var cache = COMPUTED_PROPERTY_LAST_REVISION.get(obj); - - if (cache === undefined) { - return 0; - } else { - var revision = cache.get(key); - return revision === undefined ? 0 : revision; + }); + var OutletTemplate = template({ + "id": "/N63Y+JW", + "block": "{\"symbols\":[],\"statements\":[[1,0,0,0,[31,2,9,[27,[26,1,\"CallHead\"],[]],[[31,13,7,[27,[26,0,\"CallHead\"],[]],null,null]],null]]],\"hasEval\":false,\"upvars\":[\"-outlet\",\"component\"]}", + "meta": { + "moduleName": "packages/@ember/-internals/glimmer/lib/templates/outlet.hbs" } - } + }); + var TOP_LEVEL_NAME = '-top-level'; + var TOP_LEVEL_OUTLET = 'main'; - function peekCacheFor(obj) { - return COMPUTED_PROPERTY_CACHED_VALUES.get(obj); - } - /** - @module @ember/object - */ + class OutletView { + constructor(_environment, renderer, owner, template) { + this._environment = _environment; + this.renderer = renderer; + this.owner = owner; + this.template = template; + var ref = this.ref = new RootOutletReference({ + outlets: { + main: undefined + }, + render: { + owner: owner, + into: undefined, + outlet: TOP_LEVEL_OUTLET, + name: TOP_LEVEL_NAME, + controller: undefined, + model: undefined, + template + } + }); + this.state = { + ref, + name: TOP_LEVEL_NAME, + outlet: TOP_LEVEL_OUTLET, + template, + controller: undefined, + model: undefined + }; + } - /* - The event system uses a series of nested hashes to store listeners on an - object. When a listener is registered, or when an event arrives, these - hashes are consulted to determine which target and action pair to invoke. - - The hashes are stored in the object's meta hash, and look like this: - - // Object's meta hash - { - listeners: { // variable name: `listenerSet` - "foo:change": [ // variable name: `actions` - target, method, once - ] + static extend(injections) { + return class extends OutletView { + static create(options) { + if (options) { + return super.create((0, _polyfills.assign)({}, injections, options)); + } else { + return super.create(injections); } } - - */ - - /** - Add an event listener - - @method addListener - @static - @for @ember/object/events - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @param {Boolean} once A flag whether a function should only be called once - @public - */ + }; + } - function addListener(obj, eventName, target, method, once, sync = true) { - (true && !(Boolean(obj) && Boolean(eventName)) && (0, _debug.assert)('You must pass at least an object and event name to addListener', Boolean(obj) && Boolean(eventName))); + static reopenClass(injections) { + (0, _polyfills.assign)(this, injections); + } - if (!method && 'function' === typeof target) { - method = target; - target = null; + static create(options) { + var { + _environment, + renderer, + template: templateFactory$$1 + } = options; + var owner = options[_owner.OWNER]; + var template = templateFactory$$1(owner); + return new OutletView(_environment, renderer, owner, template); } - (0, _meta2.meta)(obj).addToListeners(eventName, target, method, once === true, sync); - } - /** - Remove an event listener - - Arguments should match those passed to `addListener`. - - @method removeListener - @static - @for @ember/object/events - @param obj - @param {String} eventName - @param {Object|Function} target A target object or a function - @param {Function|String} method A function or the name of a function to be called on `target` - @public - */ + appendTo(selector) { + var target; + if (this._environment.hasDOM) { + target = typeof selector === 'string' ? document.querySelector(selector) : selector; + } else { + target = selector; + } - function removeListener(obj, eventName, targetOrFunction, functionOrName) { - (true && !(Boolean(obj) && Boolean(eventName) && (typeof targetOrFunction === 'function' || typeof targetOrFunction === 'object' && Boolean(functionOrName))) && (0, _debug.assert)('You must pass at least an object, event name, and method or target and method/method name to removeListener', Boolean(obj) && Boolean(eventName) && (typeof targetOrFunction === 'function' || typeof targetOrFunction === 'object' && Boolean(functionOrName)))); - var target, method; + (0, _runloop.schedule)('render', this.renderer, 'appendOutletView', this, target); + } - if (typeof targetOrFunction === 'object') { - target = targetOrFunction; - method = functionOrName; - } else { - target = null; - method = targetOrFunction; + rerender() { + /**/ + } + + setOutletState(state) { + this.ref.update(state); + } + + destroy() { + /**/ } - var m = (0, _meta2.meta)(obj); - m.removeFromListeners(eventName, target, method); } - /** - Send an event. The execution of suspended listeners - is skipped, and once listeners are removed. A listener without - a target is executed on the passed object. If an array of actions - is not passed, the actions stored on the passed object are invoked. - - @method sendEvent - @static - @for @ember/object/events - @param obj - @param {String} eventName - @param {Array} params Optional parameters for each listener. - @return {Boolean} if the event was delivered to one or more actions - @public - */ + _exports.OutletView = OutletView; - function sendEvent(obj, eventName, params, actions, _meta) { - if (actions === undefined) { - var meta$$1 = _meta === undefined ? (0, _meta2.peekMeta)(obj) : _meta; - actions = typeof meta$$1 === 'object' && meta$$1 !== null ? meta$$1.matchingListeners(eventName) : undefined; - } + function setupApplicationRegistry(registry) { + registry.injection('renderer', 'env', '-environment:main'); // because we are using injections we can't use instantiate false + // we need to use bind() to copy the function so factory for + // association won't leak - if (actions === undefined || actions.length === 0) { - return false; - } + registry.register('service:-dom-builder', { + create({ + bootOptions + }) { + var { + _renderMode + } = bootOptions; - for (var i = actions.length - 3; i >= 0; i -= 3) { - // looping in reverse for once listeners - var target = actions[i]; - var method = actions[i + 1]; - var once = actions[i + 2]; + switch (_renderMode) { + case 'serialize': + return _node.serializeBuilder.bind(null); - if (!method) { - continue; - } + case 'rehydrate': + return _runtime2.rehydrationBuilder.bind(null); - if (once) { - removeListener(obj, eventName, target, method); + default: + return _runtime2.clientBuilder.bind(null); + } } - if (!target) { - target = obj; - } + }); + registry.injection('service:-dom-builder', 'bootOptions', '-environment:main'); + registry.injection('renderer', 'builder', 'service:-dom-builder'); + registry.register(_container.privatize`template:-root`, RootTemplate); + registry.injection('renderer', 'rootTemplate', _container.privatize`template:-root`); + registry.register('renderer:-dom', InteractiveRenderer); + registry.register('renderer:-inert', InertRenderer); + registry.injection('renderer', 'document', 'service:-document'); + } - if ('string' === typeof method) { - method = target[method]; - } + function setupEngineRegistry(registry) { + registry.optionsForType('template', { + instantiate: false + }); + registry.register('view:-outlet', OutletView); + registry.register('template:-outlet', OutletTemplate); + registry.injection('view:-outlet', 'template', 'template:-outlet'); + registry.register(_container.privatize`template:components/-default`, ComponentTemplate); + registry.optionsForType('helper', { + instantiate: false + }); + registry.register('helper:loc', loc$1); + registry.register('component:-text-field', TextField); + registry.register('component:-checkbox', Checkbox); + registry.register('component:link-to', LinkComponent); + registry.register('component:input', Input); + registry.register('template:components/input', InputTemplate); + registry.register('component:textarea', TextArea); - method.apply(target, params); + if (!_environment2.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS) { + registry.register(_container.privatize`component:-default`, Component); } - - return true; } - /** - @private - @method hasListeners - @static - @for @ember/object/events - @param obj - @param {String} eventName - @return {Boolean} if `obj` has listeners for event `eventName` - */ + function setComponentManager(stringOrFunction, obj) { + var factory; - function hasListeners(obj, eventName) { - var meta$$1 = (0, _meta2.peekMeta)(obj); + if (_deprecatedFeatures.COMPONENT_MANAGER_STRING_LOOKUP && typeof stringOrFunction === 'string') { + (true && !(false) && (0, _debug.deprecate)('Passing the name of the component manager to "setupComponentManager" is deprecated. Please pass a function that produces an instance of the manager.', false, { + id: 'deprecate-string-based-component-manager', + until: '4.0.0', + url: 'https://emberjs.com/deprecations/v3.x/#toc_component-manager-string-lookup' + })); - if (meta$$1 === null) { - return false; + factory = function (owner) { + return owner.lookup(`component-manager:${stringOrFunction}`); + }; + } else { + factory = stringOrFunction; } - var matched = meta$$1.matchingListeners(eventName); - return matched !== undefined && matched.length > 0; + return setManager({ + factory, + internal: false, + type: 'component' + }, obj); + } + + function getComponentManager(obj) { + var wrapper = getManager(obj); + + if (wrapper && !wrapper.internal && wrapper.type === 'component') { + return wrapper.factory; + } else { + return undefined; + } } /** - Define a property as a function that should be executed when - a specified event or events are triggered. + [Glimmer](https://github.com/tildeio/glimmer) is a templating engine used by Ember.js that is compatible with a subset of the [Handlebars](http://handlebarsjs.com/) syntax. - ``` javascript - import EmberObject from '@ember/object'; - import { on } from '@ember/object/evented'; - import { sendEvent } from '@ember/object/events'; + ### Showing a property - let Job = EmberObject.extend({ - logCompleted: on('completed', function() { - console.log('Job completed!'); - }) + Templates manage the flow of an application's UI, and display state (through + the DOM) to a user. For example, given a component with the property "name", + that component's template can use the name in several ways: + + ```app/components/person-profile.js + import Component from '@ember/component'; + + export default Component.extend({ + name: 'Jill' }); + ``` - let job = Job.create(); + ```app/components/person-profile.hbs + {{this.name}} +
{{this.name}}
+ + ``` - sendEvent(job, 'completed'); // Logs 'Job completed!' - ``` + Any time the "name" property on the component changes, the DOM will be + updated. - @method on - @static - @for @ember/object/evented - @param {String} eventNames* - @param {Function} func - @return {Function} the listener function, passed as last argument to on(...) - @public - */ - - - function on(...args) { - var func = args.pop(); - var events = args; - (true && !(typeof func === 'function') && (0, _debug.assert)('on expects function as last argument', typeof func === 'function')); - (true && !(events.length > 0 && events.every(p => typeof p === 'string' && p.length > 0)) && (0, _debug.assert)('on called without valid event names', events.length > 0 && events.every(p => typeof p === 'string' && p.length > 0))); - (0, _utils.setListeners)(func, events); - return func; - } - - var AFTER_OBSERVERS = ':change'; - - function changeEvent(keyName) { - return keyName + AFTER_OBSERVERS; - } - - var SYNC_DEFAULT = !_environment.ENV._DEFAULT_ASYNC_OBSERVERS; - var SYNC_OBSERVERS = new Map(); - var ASYNC_OBSERVERS = new Map(); - /** - @module @ember/object - */ - - /** - @method addObserver - @static - @for @ember/object/observers - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] + Properties can be chained as well: + + ```handlebars + {{@aUserModel.name}} +
{{@listOfUsers.firstObject.name}}
+ ``` + + ### Using Ember helpers + + When content is passed in mustaches `{{}}`, Ember will first try to find a helper + or component with that name. For example, the `if` helper: + + ```app/components/person-profile.hbs + {{if this.name "I have a name" "I have no name"}} + + ``` + + The returned value is placed where the `{{}}` is called. The above style is + called "inline". A second style of helper usage is called "block". For example: + + ```handlebars + {{#if this.name}} + I have a name + {{else}} + I have no name + {{/if}} + ``` + + The block form of helpers allows you to control how the UI is created based + on the values of properties. + A third form of helper is called "nested". For example here the concat + helper will add " Doe" to a displayed name if the person has no last name: + + ```handlebars + + ``` + + Ember's built-in helpers are described under the [Ember.Templates.helpers](/ember/release/classes/Ember.Templates.helpers) + namespace. Documentation on creating custom helpers can be found under + [helper](/ember/release/functions/@ember%2Fcomponent%2Fhelper/helper) (or + under [Helper](/ember/release/classes/Helper) if a helper requires access to + dependency injection). + + ### Invoking a Component + + Ember components represent state to the UI of an application. Further + reading on components can be found under [Component](/ember/release/classes/Component). + + @module @ember/component + @main @ember/component @public - */ + */ - function addObserver(obj, path, target, method, sync = SYNC_DEFAULT) { - var eventName = changeEvent(path); - addListener(obj, eventName, target, method, false, sync); - var meta$$1 = (0, _meta2.peekMeta)(obj); +}); +define("@ember/-internals/meta/index", ["exports", "@ember/-internals/meta/lib/meta"], function (_exports, _meta) { + "use strict"; - if (meta$$1 === null || !(meta$$1.isPrototypeMeta(obj) || meta$$1.isInitializing())) { - activateObserver(obj, eventName, sync); + Object.defineProperty(_exports, "__esModule", { + value: true + }); + Object.defineProperty(_exports, "counters", { + enumerable: true, + get: function () { + return _meta.counters; + } + }); + Object.defineProperty(_exports, "Meta", { + enumerable: true, + get: function () { + return _meta.Meta; + } + }); + Object.defineProperty(_exports, "meta", { + enumerable: true, + get: function () { + return _meta.meta; + } + }); + Object.defineProperty(_exports, "peekMeta", { + enumerable: true, + get: function () { + return _meta.peekMeta; + } + }); + Object.defineProperty(_exports, "setMeta", { + enumerable: true, + get: function () { + return _meta.setMeta; } + }); + Object.defineProperty(_exports, "UNDEFINED", { + enumerable: true, + get: function () { + return _meta.UNDEFINED; + } + }); +}); +define("@ember/-internals/meta/lib/meta", ["exports", "@ember/-internals/utils", "@ember/debug"], function (_exports, _utils, _debug) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.setMeta = setMeta; + _exports.peekMeta = peekMeta; + _exports.counters = _exports.meta = _exports.Meta = _exports.UNDEFINED = void 0; + var objectPrototype = Object.prototype; + var counters; + _exports.counters = counters; + + if (true + /* DEBUG */ + ) { + _exports.counters = counters = { + peekCalls: 0, + peekPrototypeWalks: 0, + setCalls: 0, + deleteCalls: 0, + metaCalls: 0, + metaInstantiated: 0, + matchingListenersCalls: 0, + observerEventsCalls: 0, + addToListenersCalls: 0, + removeFromListenersCalls: 0, + removeAllListenersCalls: 0, + listenersInherited: 0, + listenersFlattened: 0, + parentListenersUsed: 0, + flattenedListenersCalls: 0, + reopensAfterFlatten: 0, + readableLazyChainsCalls: 0, + writableLazyChainsCalls: 0 + }; } /** - @method removeObserver - @static - @for @ember/object/observers - @param obj - @param {String} path - @param {Object|Function} target - @param {Function|String} [method] - @public + @module ember */ - function removeObserver(obj, path, target, method, sync = SYNC_DEFAULT) { - var eventName = changeEvent(path); - var meta$$1 = (0, _meta2.peekMeta)(obj); + var UNDEFINED = (0, _utils.symbol)('undefined'); + _exports.UNDEFINED = UNDEFINED; + var currentListenerVersion = 1; - if (meta$$1 === null || !(meta$$1.isPrototypeMeta(obj) || meta$$1.isInitializing())) { - deactivateObserver(obj, eventName, sync); - } + class Meta { + constructor(obj) { + this._listenersVersion = 1; + this._inheritedEnd = -1; + this._flattenedVersion = 0; - removeListener(obj, eventName, target, method); - } + if (true + /* DEBUG */ + ) { + counters.metaInstantiated++; + this._values = undefined; + } - function getOrCreateActiveObserversFor(target, sync) { - var observerMap = sync === true ? SYNC_OBSERVERS : ASYNC_OBSERVERS; + this._parent = undefined; + this._descriptors = undefined; + this._mixins = undefined; // initial value for all flags right now is false + // see FLAGS const for detailed list of flags used - if (!observerMap.has(target)) { - observerMap.set(target, new Map()); + this._flags = 0 + /* NONE */ + ; // used only internally + + this.source = obj; + this.proto = obj.constructor === undefined ? undefined : obj.constructor.prototype; + this._listeners = undefined; } - return observerMap.get(target); - } + get parent() { + var parent = this._parent; - function activateObserver(target, eventName, sync = false) { - var activeObservers = getOrCreateActiveObserversFor(target, sync); + if (parent === undefined) { + var proto = getPrototypeOf(this.source); + this._parent = parent = proto === null || proto === objectPrototype ? null : meta(proto); + } - if (activeObservers.has(eventName)) { - activeObservers.get(eventName).count++; - } else { - var [path] = eventName.split(':'); - var tag = (0, _reference.combine)(getChainTagsForKey(target, path)); - activeObservers.set(eventName, { - count: 1, - path, - tag, - lastRevision: (0, _reference.value)(tag), - suspended: false - }); + return parent; } - } - function deactivateObserver(target, eventName, sync = false) { - var observerMap = sync === true ? SYNC_OBSERVERS : ASYNC_OBSERVERS; - var activeObservers = observerMap.get(target); + setInitializing() { + this._flags |= 8 + /* INITIALIZING */ + ; + } - if (activeObservers !== undefined) { - var _observer = activeObservers.get(eventName); + unsetInitializing() { + this._flags ^= 8 + /* INITIALIZING */ + ; + } - _observer.count--; + isInitializing() { + return this._hasFlag(8 + /* INITIALIZING */ + ); + } - if (_observer.count === 0) { - activeObservers.delete(eventName); + isPrototypeMeta(obj) { + return this.proto === this.source && this.source === obj; + } - if (activeObservers.size === 0) { - observerMap.delete(target); - } + destroy() { + if (true + /* DEBUG */ + ) { + counters.deleteCalls++; + } + + if (this.isMetaDestroyed()) { + return; } + + this.setMetaDestroyed(); + } + + isSourceDestroying() { + return this._hasFlag(1 + /* SOURCE_DESTROYING */ + ); } - } - /** - * Primarily used for cases where we are redefining a class, e.g. mixins/reopen - * being applied later. Revalidates all the observers, resetting their tags. - * - * @private - * @param target - */ + setSourceDestroying() { + this._flags |= 1 + /* SOURCE_DESTROYING */ + ; + } - function revalidateObservers(target) { - if (ASYNC_OBSERVERS.has(target)) { - ASYNC_OBSERVERS.get(target).forEach(observer => { - observer.tag = (0, _reference.combine)(getChainTagsForKey(target, observer.path)); - observer.lastRevision = (0, _reference.value)(observer.tag); - }); + isSourceDestroyed() { + return this._hasFlag(2 + /* SOURCE_DESTROYED */ + ); } - if (SYNC_OBSERVERS.has(target)) { - SYNC_OBSERVERS.get(target).forEach(observer => { - observer.tag = (0, _reference.combine)(getChainTagsForKey(target, observer.path)); - observer.lastRevision = (0, _reference.value)(observer.tag); - }); + setSourceDestroyed() { + this._flags |= 2 + /* SOURCE_DESTROYED */ + ; } - } - var lastKnownRevision = 0; + isMetaDestroyed() { + return this._hasFlag(4 + /* META_DESTROYED */ + ); + } - function flushAsyncObservers(shouldSchedule = true) { - if (lastKnownRevision === (0, _reference.value)(_reference.CURRENT_TAG)) { - return; + setMetaDestroyed() { + this._flags |= 4 + /* META_DESTROYED */ + ; } - lastKnownRevision = (0, _reference.value)(_reference.CURRENT_TAG); - ASYNC_OBSERVERS.forEach((activeObservers, target) => { - var meta$$1 = (0, _meta2.peekMeta)(target); + _hasFlag(flag) { + return (this._flags & flag) === flag; + } - if (meta$$1 && (meta$$1.isSourceDestroying() || meta$$1.isMetaDestroyed())) { - ASYNC_OBSERVERS.delete(target); - return; - } + _getOrCreateOwnMap(key) { + return this[key] || (this[key] = Object.create(null)); + } - activeObservers.forEach((observer, eventName) => { - if (!(0, _reference.validate)(observer.tag, observer.lastRevision)) { - var sendObserver = () => { - try { - sendEvent(target, eventName, [target, observer.path]); - } finally { - observer.tag = (0, _reference.combine)(getChainTagsForKey(target, observer.path)); - observer.lastRevision = (0, _reference.value)(observer.tag); - } - }; + _getOrCreateOwnSet(key) { + return this[key] || (this[key] = new Set()); + } - if (shouldSchedule) { - (0, _runloop.schedule)('actions', sendObserver); - } else { - sendObserver(); - } - } - }); - }); - } + _findInheritedMap(key, subkey) { + var pointer = this; - function flushSyncObservers() { - // When flushing synchronous observers, we know that something has changed (we - // only do this during a notifyPropertyChange), so there's no reason to check - // a global revision. - SYNC_OBSERVERS.forEach((activeObservers, target) => { - var meta$$1 = (0, _meta2.peekMeta)(target); + while (pointer !== null) { + var map = pointer[key]; - if (meta$$1 && (meta$$1.isSourceDestroying() || meta$$1.isMetaDestroyed())) { - SYNC_OBSERVERS.delete(target); - return; - } + if (map !== undefined) { + var value = map.get(subkey); - activeObservers.forEach((observer, eventName) => { - if (!observer.suspended && !(0, _reference.validate)(observer.tag, observer.lastRevision)) { - try { - observer.suspended = true; - sendEvent(target, eventName, [target, observer.path]); - } finally { - observer.tag = (0, _reference.combine)(getChainTagsForKey(target, observer.path)); - observer.lastRevision = (0, _reference.value)(observer.tag); - observer.suspended = false; + if (value !== undefined) { + return value; } } - }); - }); - } - function setObserverSuspended(target, property, suspended) { - var activeObservers = SYNC_OBSERVERS.get(target); - - if (!activeObservers) { - return; + pointer = pointer.parent; + } } - var observer = activeObservers.get(changeEvent(property)); + _hasInInheritedSet(key, value) { + var pointer = this; - if (observer) { - observer.suspended = suspended; - } - } + while (pointer !== null) { + var set = pointer[key]; - var DECORATOR_DESCRIPTOR_MAP = new WeakMap(); - /** - Returns the CP descriptor assocaited with `obj` and `keyName`, if any. - - @method descriptorForProperty - @param {Object} obj the object to check - @param {String} keyName the key to check - @return {Descriptor} - @private - */ + if (set !== undefined && set.has(value)) { + return true; + } - function descriptorForProperty(obj, keyName, _meta) { - (true && !(obj !== null) && (0, _debug.assert)('Cannot call `descriptorForProperty` on null', obj !== null)); - (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `descriptorForProperty` on undefined', obj !== undefined)); - (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)("Cannot call `descriptorForProperty` on " + typeof obj, typeof obj === 'object' || typeof obj === 'function')); - var meta$$1 = _meta === undefined ? (0, _meta2.peekMeta)(obj) : _meta; + pointer = pointer.parent; + } - if (meta$$1 !== null) { - return meta$$1.peekDescriptors(keyName); + return false; } - } - function descriptorForDecorator(dec) { - return DECORATOR_DESCRIPTOR_MAP.get(dec); - } - /** - Check whether a value is a decorator - - @method isClassicDecorator - @param {any} possibleDesc the value to check - @return {boolean} - @private - */ + writableLazyChainsFor(key) { + if (true + /* DEBUG */ + ) { + counters.writableLazyChainsCalls++; + } + var lazyChains = this._getOrCreateOwnMap('_lazyChains'); - function isClassicDecorator(dec) { - return dec !== null && dec !== undefined && DECORATOR_DESCRIPTOR_MAP.has(dec); - } - /** - Set a value as a decorator - - @method setClassicDecorator - @param {function} decorator the value to mark as a decorator - @private - */ + if (!(key in lazyChains)) { + lazyChains[key] = Object.create(null); + } + return lazyChains[key]; + } - function setClassicDecorator(dec, value$$1 = true) { - DECORATOR_DESCRIPTOR_MAP.set(dec, value$$1); - } + readableLazyChainsFor(key) { + if (true + /* DEBUG */ + ) { + counters.readableLazyChainsCalls++; + } - function isElementDescriptor(args) { - var [maybeTarget, maybeKey, maybeDesc] = args; - return (// Ensure we have the right number of args - args.length === 3 && ( // Make sure the target is a class or object (prototype) - typeof maybeTarget === 'function' || typeof maybeTarget === 'object' && maybeTarget !== null) && // Make sure the key is a string - typeof maybeKey === 'string' && ( // Make sure the descriptor is the right shape - typeof maybeDesc === 'object' && maybeDesc !== null && 'enumerable' in maybeDesc && 'configurable' in maybeDesc || // TS compatibility - maybeDesc === undefined) - ); - } + var lazyChains = this._lazyChains; - function nativeDescDecorator(propertyDesc) { - var decorator = function () { - return propertyDesc; - }; + if (lazyChains !== undefined) { + return lazyChains[key]; + } - setClassicDecorator(decorator); - return decorator; - } - /** - Objects of this type can implement an interface to respond to requests to - get and set. The default implementation handles simple properties. - - @class Descriptor - @private - */ + return undefined; + } + addMixin(mixin) { + (true && !(!this.isMetaDestroyed()) && (0, _debug.assert)(this.isMetaDestroyed() ? `Cannot add mixins of \`${(0, _utils.toString)(mixin)}\` on \`${(0, _utils.toString)(this.source)}\` call addMixin after it has been destroyed.` : '', !this.isMetaDestroyed())); - class ComputedDescriptor { - constructor() { - this.enumerable = true; - this.configurable = true; - this._dependentKeys = undefined; - this._meta = undefined; - } + var set = this._getOrCreateOwnSet('_mixins'); - setup(_obj, keyName, _propertyDesc, meta$$1) { - meta$$1.writeDescriptors(keyName, this); + set.add(mixin); } - teardown(_obj, keyName, meta$$1) { - meta$$1.removeDescriptors(keyName); + hasMixin(mixin) { + return this._hasInInheritedSet('_mixins', mixin); } - } + forEachMixins(fn) { + var pointer = this; + var seen; - function DESCRIPTOR_GETTER_FUNCTION(name, descriptor) { - return function CPGETTER_FUNCTION() { - return descriptor.get(this, name); - }; - } + while (pointer !== null) { + var set = pointer._mixins; - function DESCRIPTOR_SETTER_FUNCTION(name, descriptor) { - var func = function CPSETTER_FUNCTION(value$$1) { - return descriptor.set(this, name, value$$1); - }; + if (set !== undefined) { + seen = seen === undefined ? new Set() : seen; // TODO cleanup typing here - CP_SETTER_FUNCS.add(func); - return func; - } + set.forEach(mixin => { + if (!seen.has(mixin)) { + seen.add(mixin); + fn(mixin); + } + }); + } - var CP_SETTER_FUNCS = new _polyfills._WeakSet(); + pointer = pointer.parent; + } + } - function makeComputedDecorator(desc, DecoratorClass) { - var decorator = function COMPUTED_DECORATOR(target, key, propertyDesc, maybeMeta, isClassicDecorator$$1) { - (true && !(isClassicDecorator$$1 || !propertyDesc || !propertyDesc.get || propertyDesc.get.toString().indexOf('CPGETTER_FUNCTION') === -1) && (0, _debug.assert)("Only one computed property decorator can be applied to a class field or accessor, but '" + key + "' was decorated twice. You may have added the decorator to both a getter and setter, which is unecessary.", isClassicDecorator$$1 || !propertyDesc || !propertyDesc.get || propertyDesc.get.toString().indexOf('CPGETTER_FUNCTION') === -1)); - var meta$$1 = arguments.length === 3 ? (0, _meta2.meta)(target) : maybeMeta; - desc.setup(target, key, propertyDesc, meta$$1); - var computedDesc = { - enumerable: desc.enumerable, - configurable: desc.configurable, - get: DESCRIPTOR_GETTER_FUNCTION(key, desc), - set: DESCRIPTOR_SETTER_FUNCTION(key, desc) - }; - return computedDesc; - }; + writeDescriptors(subkey, value) { + (true && !(!this.isMetaDestroyed()) && (0, _debug.assert)(this.isMetaDestroyed() ? `Cannot update descriptors for \`${subkey}\` on \`${(0, _utils.toString)(this.source)}\` after it has been destroyed.` : '', !this.isMetaDestroyed())); + var map = this._descriptors || (this._descriptors = new Map()); + map.set(subkey, value); + } - setClassicDecorator(decorator, desc); - Object.setPrototypeOf(decorator, DecoratorClass.prototype); - return decorator; - } + peekDescriptors(subkey) { + var possibleDesc = this._findInheritedMap('_descriptors', subkey); - var DEPRECATE_IN_AUTOTRACKING_TRANSACTION = false; - var AUTOTRACKING_TRANSACTION = null; - var runInAutotrackingTransaction; - _exports.runInAutotrackingTransaction = runInAutotrackingTransaction; - var deprecateMutationsInAutotrackingTransaction; - _exports.deprecateMutationsInAutotrackingTransaction = deprecateMutationsInAutotrackingTransaction; - var debuggingContexts; - var assertTagNotConsumed; - var markTagAsConsumed; + return possibleDesc === UNDEFINED ? undefined : possibleDesc; + } - if (true - /* DEBUG */ - ) { - /** - * Creates a global autotracking transaction. This will prevent any backflow - * in any `track` calls within the transaction, even if they are not - * externally consumed. - * - * `runInAutotrackingTransaction` can be called within itself, and it will add - * onto the existing transaction if one exists. - * - * TODO: Only throw an error if the `track` is consumed. - */ - _exports.runInAutotrackingTransaction = runInAutotrackingTransaction = fn => { - var previousDeprecateState = DEPRECATE_IN_AUTOTRACKING_TRANSACTION; - var previousTransactionState = AUTOTRACKING_TRANSACTION; - DEPRECATE_IN_AUTOTRACKING_TRANSACTION = false; + removeDescriptors(subkey) { + this.writeDescriptors(subkey, UNDEFINED); + } - if (previousTransactionState === null) { - // if there was no transaction start it. Otherwise, the transaction already exists. - AUTOTRACKING_TRANSACTION = new WeakMap(); - } + forEachDescriptors(fn) { + var pointer = this; + var seen; - try { - fn(); - } finally { - DEPRECATE_IN_AUTOTRACKING_TRANSACTION = previousDeprecateState; - AUTOTRACKING_TRANSACTION = previousTransactionState; - } - }; - /** - * Switches to deprecating within an autotracking transaction, if one exists. - * If `runInAutotrackingTransaction` is called within the callback of this - * method, it switches back to throwing an error, allowing zebra-striping of - * the types of errors that are thrown. - * - * Does not start an autotracking transaction. - */ + while (pointer !== null) { + var map = pointer._descriptors; + if (map !== undefined) { + seen = seen === undefined ? new Set() : seen; + map.forEach((value, key) => { + if (!seen.has(key)) { + seen.add(key); - _exports.deprecateMutationsInAutotrackingTransaction = deprecateMutationsInAutotrackingTransaction = fn => { - var previousDeprecateState = DEPRECATE_IN_AUTOTRACKING_TRANSACTION; - DEPRECATE_IN_AUTOTRACKING_TRANSACTION = true; + if (value !== UNDEFINED) { + fn(key, value); + } + } + }); + } - try { - fn(); - } finally { - DEPRECATE_IN_AUTOTRACKING_TRANSACTION = previousDeprecateState; + pointer = pointer.parent; } - }; - - var nthIndex = (str, pattern, n, startingPos = -1) => { - var i = startingPos; + } - while (n-- > 0 && i++ < str.length) { - i = str.indexOf(pattern, i); - if (i < 0) break; + addToListeners(eventName, target, method, once, sync) { + if (true + /* DEBUG */ + ) { + counters.addToListenersCalls++; } - return i; - }; - - var makeAutotrackingErrorMessage = (sourceData, obj, keyName) => { - var dirtyString = keyName ? "`" + keyName + "` on `" + (0, _utils.getDebugName)(obj) + "`" : "`" + (0, _utils.getDebugName)(obj) + "`"; - var message = ["You attempted to update " + dirtyString + ", but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported."]; + this.pushListener(eventName, target, method, once ? 1 + /* ONCE */ + : 0 + /* ADD */ + , sync); + } - if (sourceData.context) { - message.push("`" + keyName + "` was first used:\n\n" + sourceData.context); + removeFromListeners(eventName, target, method) { + if (true + /* DEBUG */ + ) { + counters.removeFromListenersCalls++; } - if (sourceData.error.stack) { - var sourceStack = sourceData.error.stack; - var thirdIndex = nthIndex(sourceStack, '\n', 3); - sourceStack = sourceStack.substr(thirdIndex); - message.push("Stack trace for the first usage: " + sourceStack); - } + this.pushListener(eventName, target, method, 2 + /* REMOVE */ + ); + } - message.push("Stack trace for the update:"); - return message.join('\n\n'); - }; + pushListener(event, target, method, kind, sync = false) { + var listeners = this.writableListeners(); + var i = indexOfListener(listeners, event, target, method); // remove if found listener was inherited - debuggingContexts = []; + if (i !== -1 && i < this._inheritedEnd) { + listeners.splice(i, 1); + this._inheritedEnd--; + i = -1; + } // if not found, push. Note that we must always push if a listener is not + // found, even in the case of a function listener remove, because we may be + // attempting to add or remove listeners _before_ flattening has occurred. - markTagAsConsumed = (_tag, sourceError) => { - if (!AUTOTRACKING_TRANSACTION || AUTOTRACKING_TRANSACTION.has(_tag)) return; - AUTOTRACKING_TRANSACTION.set(_tag, { - context: debuggingContexts.map(c => c.replace(/^/gm, ' ').replace(/^ /, '-')).join('\n\n'), - error: sourceError - }); // We need to mark the tag and all of its subtags as consumed, so we need to - // cast in and access its internals. In the future this shouldn't be necessary, - // this is only for computed properties.e - var tag = _tag; + if (i === -1) { + (true && !(!(this.isPrototypeMeta(this.source) && typeof method === 'function')) && (0, _debug.assert)('You cannot add function listeners to prototypes. Convert the listener to a string listener, or add it to the instance instead.', !(this.isPrototypeMeta(this.source) && typeof method === 'function'))); + (true && !(!(!this.isPrototypeMeta(this.source) && typeof method === 'function' && kind === 2 + /* REMOVE */ + )) && (0, _debug.assert)('You attempted to remove a function listener which did not exist on the instance, which means you may have attempted to remove it before it was added.', !(!this.isPrototypeMeta(this.source) && typeof method === 'function' && kind === 2))); + listeners.push({ + event, + target, + method, + kind, + sync + }); + } else { + var listener = listeners[i]; // If the listener is our own listener and we are trying to remove it, we + // want to splice it out entirely so we don't hold onto a reference. - if (tag.subtag) { - markTagAsConsumed(tag.subtag, sourceError); - } + if (kind === 2 + /* REMOVE */ + && listener.kind !== 2 + /* REMOVE */ + ) { + listeners.splice(i, 1); + } else { + (true && !(!(listener.kind === 0 + /* ADD */ + && kind === 0 + /* ADD */ + && listener.sync !== sync)) && (0, _debug.assert)(`You attempted to add an observer for the same method on '${event.split(':')[0]}' twice to ${target} as both sync and async. Observers must be either sync or async, they cannot be both. This is likely a mistake, you should either remove the code that added the observer a second time, or update it to always be sync or async. The method was ${method}.`, !(listener.kind === 0 && kind === 0 && listener.sync !== sync))); // update own listener - if (tag.subtags) { - tag.subtags.forEach(tag => markTagAsConsumed(tag, sourceError)); + listener.kind = kind; + listener.sync = sync; + } } - }; + } - assertTagNotConsumed = (tag, obj, keyName, forceHardError = false) => { - if (AUTOTRACKING_TRANSACTION === null) return; - var sourceData = AUTOTRACKING_TRANSACTION.get(tag); - if (!sourceData) return; + writableListeners() { + // Check if we need to invalidate and reflatten. We need to do this if we + // have already flattened (flattened version is the current version) and + // we are either writing to a prototype meta OR we have never inherited, and + // may have cached the parent's listeners. + if (this._flattenedVersion === currentListenerVersion && (this.source === this.proto || this._inheritedEnd === -1)) { + if (true + /* DEBUG */ + ) { + counters.reopensAfterFlatten++; + } - if (DEPRECATE_IN_AUTOTRACKING_TRANSACTION && !forceHardError) { - (true && !(false) && (0, _debug.deprecate)(makeAutotrackingErrorMessage(sourceData, obj, keyName), false, { - id: 'autotracking.mutation-after-consumption', - until: '4.0.0' - })); - } else { - // This hack makes the assertion message nicer, we can cut off the first - // few lines of the stack trace and let users know where the actual error - // occurred. - try { - (true && !(false) && (0, _debug.assert)(makeAutotrackingErrorMessage(sourceData, obj, keyName), false)); - } catch (e) { - if (e.stack) { - var updateStackBegin = e.stack.indexOf('Stack trace for the update:'); + currentListenerVersion++; + } // Inherited end has not been set, then we have never created our own + // listeners, but may have cached the parent's - if (updateStackBegin !== -1) { - var start = nthIndex(e.stack, '\n', 1, updateStackBegin); - var end = nthIndex(e.stack, '\n', 4, updateStackBegin); - e.stack = e.stack.substr(0, start) + e.stack.substr(end); - } - } - throw e; - } + if (this._inheritedEnd === -1) { + this._inheritedEnd = 0; + this._listeners = []; } - }; - } - /** - An object that that tracks @tracked properties that were consumed. - - @private - */ - - class Tracker { - constructor() { - this.tags = new Set(); - this.last = null; + return this._listeners; } + /** + Flattening is based on a global revision counter. If the revision has + bumped it means that somewhere in a class inheritance chain something has + changed, so we need to reflatten everything. This can only happen if: + 1. A meta has been flattened (listener has been called) + 2. The meta is a prototype meta with children who have inherited its + listeners + 3. A new listener is subsequently added to the meta (e.g. via `.reopen()`) + This is a very rare occurrence, so while the counter is global it shouldn't + be updated very often in practice. + */ - add(tag) { - this.tags.add(tag); + flattenedListeners() { if (true /* DEBUG */ ) { - markTagAsConsumed(tag, new Error()); + counters.flattenedListenersCalls++; } - this.last = tag; - } + if (this._flattenedVersion < currentListenerVersion) { + if (true + /* DEBUG */ + ) { + counters.listenersFlattened++; + } - get size() { - return this.tags.size; - } + var parent = this.parent; - combine() { - if (this.tags.size === 0) { - return _reference.CONSTANT_TAG; - } else if (this.tags.size === 1) { - return this.last; - } else { - var tags = []; - this.tags.forEach(tag => tags.push(tag)); - return (0, _reference.combine)(tags); - } - } + if (parent !== null) { + // compute + var parentListeners = parent.flattenedListeners(); - } + if (parentListeners !== undefined) { + if (this._listeners === undefined) { + // If this instance doesn't have any of its own listeners (writableListeners + // has never been called) then we don't need to do any flattening, return + // the parent's listeners instead. + if (true + /* DEBUG */ + ) { + counters.parentListenersUsed++; + } - _exports.Tracker = Tracker; + this._listeners = parentListeners; + } else { + var listeners = this._listeners; - function tracked(...args) { - (true && !(!(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true)) && (0, _debug.assert)("@tracked can only be used directly as a native decorator. If you're using tracked in classic classes, add parenthesis to call it like a function: tracked()", !(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true))); + if (this._inheritedEnd > 0) { + listeners.splice(0, this._inheritedEnd); + this._inheritedEnd = 0; + } - if (!isElementDescriptor(args)) { - var propertyDesc = args[0]; - (true && !(args.length === 0 || typeof propertyDesc === 'object' && propertyDesc !== null) && (0, _debug.assert)("tracked() may only receive an options object containing 'value' or 'initializer', received " + propertyDesc, args.length === 0 || typeof propertyDesc === 'object' && propertyDesc !== null)); + for (var i = 0; i < parentListeners.length; i++) { + var listener = parentListeners[i]; + var index = indexOfListener(listeners, listener.event, listener.target, listener.method); - if (true - /* DEBUG */ - && propertyDesc) { - var keys = Object.keys(propertyDesc); - (true && !(keys.length <= 1 && (keys[0] === undefined || keys[0] === 'value' || keys[0] === 'initializer')) && (0, _debug.assert)("The options object passed to tracked() may only contain a 'value' or 'initializer' property, not both. Received: [" + keys + "]", keys.length <= 1 && (keys[0] === undefined || keys[0] === 'value' || keys[0] === 'initializer'))); - (true && !(!('initializer' in propertyDesc) || typeof propertyDesc.initializer === 'function') && (0, _debug.assert)("The initializer passed to tracked must be a function. Received " + propertyDesc.initializer, !('initializer' in propertyDesc) || typeof propertyDesc.initializer === 'function')); - } + if (index === -1) { + if (true + /* DEBUG */ + ) { + counters.listenersInherited++; + } - var initializer = propertyDesc ? propertyDesc.initializer : undefined; - var value$$1 = propertyDesc ? propertyDesc.value : undefined; + listeners.unshift(listener); + this._inheritedEnd++; + } + } + } + } + } - var decorator = function (target, key, _desc, _meta, isClassicDecorator$$1) { - (true && !(isClassicDecorator$$1) && (0, _debug.assert)("You attempted to set a default value for " + key + " with the @tracked({ value: 'default' }) syntax. You can only use this syntax with classic classes. For native classes, you can use class initializers: @tracked field = 'default';", isClassicDecorator$$1)); - var fieldDesc = { - initializer: initializer || (() => value$$1) - }; - return descriptorForField([target, key, fieldDesc]); - }; + this._flattenedVersion = currentListenerVersion; + } - setClassicDecorator(decorator); - return decorator; + return this._listeners; } - return descriptorForField(args); - } - - if (true - /* DEBUG */ - ) { - // Normally this isn't a classic decorator, but we want to throw a helpful - // error in development so we need it to treat it like one - setClassicDecorator(tracked); - } - - function descriptorForField([_target, key, desc]) { - (true && !(!desc || !desc.value && !desc.get && !desc.set) && (0, _debug.assert)("You attempted to use @tracked on " + key + ", but that element is not a class field. @tracked is only usable on class fields. Native getters and setters will autotrack add any tracked fields they encounter, so there is no need mark getters and setters with @tracked.", !desc || !desc.value && !desc.get && !desc.set)); - var initializer = desc ? desc.initializer : undefined; - var values = new WeakMap(); - var hasInitializer = typeof initializer === 'function'; - return { - enumerable: true, - configurable: true, - - get() { - var propertyTag = tagForProperty(this, key); - consume(propertyTag); - var value$$1; // If the field has never been initialized, we should initialize it - - if (hasInitializer && !values.has(this)) { - value$$1 = initializer.call(this); - values.set(this, value$$1); - } else { - value$$1 = values.get(this); - } // Add the tag of the returned value if it is an array, since arrays - // should always cause updates if they are consumed and then changed - - - if (Array.isArray(value$$1) || (0, _utils.isEmberArray)(value$$1)) { - (0, _reference.update)(propertyTag, tagForProperty(value$$1, '[]')); - } + matchingListeners(eventName) { + var listeners = this.flattenedListeners(); + var result; - return value$$1; - }, + if (true + /* DEBUG */ + ) { + counters.matchingListenersCalls++; + } - set(newValue) { - if (true - /* DEBUG */ - ) { - // No matter what, attempting to update a tracked property in an - // autotracking context after it has been read is invalid, even if we - // are otherwise warning, so always assert. - assertTagNotConsumed(tagForProperty(this, key), this, key, true); - } + if (listeners !== undefined) { + for (var index = 0; index < listeners.length; index++) { + var listener = listeners[index]; // REMOVE listeners are placeholders that tell us not to + // inherit, so they never match. Only ADD and ONCE can match. - markObjectAsDirty(this, key); - values.set(this, newValue); + if (listener.event === eventName && (listener.kind === 0 + /* ADD */ + || listener.kind === 1 + /* ONCE */ + )) { + if (result === undefined) { + // we create this array only after we've found a listener that + // matches to avoid allocations when no matches are found. + result = []; + } - if (propertyDidChange !== null) { - propertyDidChange(); + result.push(listener.target, listener.method, listener.kind === 1 + /* ONCE */ + ); + } } } - }; - } - /** - @private - - Whenever a tracked computed property is entered, the current tracker is - saved off and a new tracker is replaced. - - Any tracked properties consumed are added to the current tracker. - - When a tracked computed property is exited, the tracker's tags are - combined and added to the parent tracker. - - The consequence is that each tracked computed property has a tag - that corresponds to the tracked properties consumed inside of - itself, including child tracked computed properties. - */ - - - var CURRENT_TRACKER = null; + return result; + } - function track(callback, debuggingContext) { - // Note: debuggingContext is allowed to be false so `DEBUG && 'debug message'` works - var parent = CURRENT_TRACKER; - var current = new Tracker(); - CURRENT_TRACKER = current; + observerEvents() { + var listeners = this.flattenedListeners(); + var result; - try { if (true /* DEBUG */ ) { - if (debuggingContext) { - debuggingContexts.unshift(debuggingContext); - } - - runInAutotrackingTransaction(callback); - } else { - callback(); - } - } finally { - if (true - /* DEBUG */ - && debuggingContext) { - debuggingContexts.shift(); + counters.observerEventsCalls++; } - CURRENT_TRACKER = parent; - } - - return current.combine(); - } - - function consume(tag) { - if (CURRENT_TRACKER !== null) { - CURRENT_TRACKER.add(tag); - } - } + if (listeners !== undefined) { + for (var index = 0; index < listeners.length; index++) { + var listener = listeners[index]; // REMOVE listeners are placeholders that tell us not to + // inherit, so they never match. Only ADD and ONCE can match. - function isTracking() { - return CURRENT_TRACKER !== null; - } + if ((listener.kind === 0 + /* ADD */ + || listener.kind === 1 + /* ONCE */ + ) && listener.event.indexOf(':change') !== -1) { + if (result === undefined) { + // we create this array only after we've found a listener that + // matches to avoid allocations when no matches are found. + result = []; + } - function untrack(callback) { - var parent = CURRENT_TRACKER; - CURRENT_TRACKER = null; + result.push(listener); + } + } + } - try { - callback(); - } finally { - CURRENT_TRACKER = parent; + return result; } - } - var propertyDidChange = null; - var CUSTOM_TAG_FOR = (0, _utils.symbol)('CUSTOM_TAG_FOR'); - _exports.CUSTOM_TAG_FOR = CUSTOM_TAG_FOR; + } - function tagForProperty(object, propertyKey, _meta) { - var objectType = typeof object; + _exports.Meta = Meta; + var getPrototypeOf = Object.getPrototypeOf; + var metaStore = new WeakMap(); - if (objectType !== 'function' && (objectType !== 'object' || object === null)) { - return _reference.CONSTANT_TAG; - } + function setMeta(obj, meta) { + (true && !(obj !== null) && (0, _debug.assert)('Cannot call `setMeta` on null', obj !== null)); + (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `setMeta` on undefined', obj !== undefined)); + (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)(`Cannot call \`setMeta\` on ${typeof obj}`, typeof obj === 'object' || typeof obj === 'function')); - if (typeof object[CUSTOM_TAG_FOR] === 'function') { - return object[CUSTOM_TAG_FOR](propertyKey); + if (true + /* DEBUG */ + ) { + counters.setCalls++; } - return createTagForProperty(object, propertyKey); + metaStore.set(obj, meta); } - function createTagForProperty(object, propertyKey, _meta) { - var meta$$1 = _meta === undefined ? (0, _meta2.meta)(object) : _meta; - var tags = meta$$1.writableTags(); - var tag = tags[propertyKey]; - - if (tag) { - return tag; - } - - var newTag = (0, _reference.createUpdatableTag)(); + function peekMeta(obj) { + (true && !(obj !== null) && (0, _debug.assert)('Cannot call `peekMeta` on null', obj !== null)); + (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `peekMeta` on undefined', obj !== undefined)); + (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)(`Cannot call \`peekMeta\` on ${typeof obj}`, typeof obj === 'object' || typeof obj === 'function')); if (true /* DEBUG */ ) { - (0, _utils.setupMandatorySetter)(newTag, object, propertyKey); - newTag._propertyKey = propertyKey; + counters.peekCalls++; } - return tags[propertyKey] = newTag; - } - - function tagFor(object, _meta) { - if (typeof object === 'object' && object !== null) { - var meta$$1 = _meta === undefined ? (0, _meta2.meta)(object) : _meta; + var meta = metaStore.get(obj); - if (!meta$$1.isMetaDestroyed()) { - return meta$$1.writableTag(); - } + if (meta !== undefined) { + return meta; } - return _reference.CONSTANT_TAG; - } - - function markObjectAsDirty(obj, propertyKey, _meta) { - var meta$$1 = _meta === undefined ? (0, _meta2.meta)(obj) : _meta; - var objectTag = meta$$1.readableTag(); + var pointer = getPrototypeOf(obj); - if (objectTag !== undefined) { + while (pointer !== null) { if (true /* DEBUG */ ) { - assertTagNotConsumed(objectTag, obj); + counters.peekPrototypeWalks++; } - (0, _reference.dirty)(objectTag); - } + meta = metaStore.get(pointer); - var tags = meta$$1.readableTags(); - var propertyTag = tags !== undefined ? tags[propertyKey] : undefined; + if (meta !== undefined) { + if (meta.proto !== pointer) { + // The meta was a prototype meta which was not marked as initializing. + // This can happen when a prototype chain was created manually via + // Object.create() and the source object does not have a constructor. + meta.proto = pointer; + } - if (propertyTag !== undefined) { - if (true - /* DEBUG */ - ) { - assertTagNotConsumed(propertyTag, obj, propertyKey); + return meta; } - (0, _reference.dirty)(propertyTag); - } - - if (objectTag !== undefined || propertyTag !== undefined) { - ensureRunloop(); + pointer = getPrototypeOf(pointer); } - } - function ensureRunloop() { - _runloop.backburner.ensureInstance(); + return null; } /** - @module ember - @private - */ - - - var PROPERTY_DID_CHANGE = (0, _utils.symbol)('PROPERTY_DID_CHANGE'); - _exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; - var deferred = 0; - /** - This function is called just after an object property has changed. - It will notify any observers and clear caches among other things. + Retrieves the meta hash for an object. If `writable` is true ensures the + hash is writable for this object as well. - Normally you will not need to call this method directly but if for some - reason you can't directly watch a property you can invoke this method - manually. + The meta object contains information about computed property descriptors as + well as any watched properties and other information. You generally will + not access this information directly but instead work with higher level + methods that manipulate this hash indirectly. - @method notifyPropertyChange - @for @ember/object - @param {Object} obj The object with the property that will change - @param {String} keyName The property key (or path) that will change. - @param {Meta} meta The objects meta. - @return {void} - @since 3.1.0 - @public + @method meta + @for Ember + @private + + @param {Object} obj The object to retrieve meta for + @param {Boolean} [writable=true] Pass `false` if you do not intend to modify + the meta hash, allowing the method to avoid making an unnecessary copy. + @return {Object} the meta hash for an object */ - function notifyPropertyChange(obj, keyName, _meta) { - var meta$$1 = _meta === undefined ? (0, _meta2.peekMeta)(obj) : _meta; - if (meta$$1 !== null && (meta$$1.isInitializing() || meta$$1.isPrototypeMeta(obj))) { - return; - } + var meta = function meta(obj) { + (true && !(obj !== null) && (0, _debug.assert)('Cannot call `meta` on null', obj !== null)); + (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `meta` on undefined', obj !== undefined)); + (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)(`Cannot call \`meta\` on ${typeof obj}`, typeof obj === 'object' || typeof obj === 'function')); - if (meta$$1 !== null) { - markObjectAsDirty(obj, keyName, meta$$1); + if (true + /* DEBUG */ + ) { + counters.metaCalls++; } - if (deferred <= 0) { - flushSyncObservers(); - } + var maybeMeta = peekMeta(obj); // remove this code, in-favor of explicit parent - if (PROPERTY_DID_CHANGE in obj) { - obj[PROPERTY_DID_CHANGE](keyName); + if (maybeMeta !== null && maybeMeta.source === obj) { + return maybeMeta; } + + var newMeta = new Meta(obj); + setMeta(obj, newMeta); + return newMeta; + }; + + _exports.meta = meta; + + if (true + /* DEBUG */ + ) { + meta._counters = counters; } - /** - @method beginPropertyChanges - @chainable - @private - */ + function indexOfListener(listeners, event, target, method) { + for (var i = listeners.length - 1; i >= 0; i--) { + var listener = listeners[i]; - function beginPropertyChanges() { - deferred++; + if (listener.event === event && listener.target === target && listener.method === method) { + return i; + } + } + + return -1; } - /** - @method endPropertyChanges - @private - */ +}); +define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ember/-internals/utils", "@ember/debug", "@ember/-internals/environment", "@ember/runloop", "@glimmer/validator", "@ember/polyfills", "@ember/error", "ember/version", "@ember/-internals/meta/lib/meta", "@ember/deprecated-features", "@ember/-internals/owner"], function (_exports, _meta2, _utils, _debug, _environment, _runloop, _validator, _polyfills, _error, _version, _meta3, _deprecatedFeatures, _owner) { + "use strict"; + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.computed = computed; + _exports.isComputed = isComputed; + _exports.getCacheFor = getCacheFor; + _exports.getCachedValueFor = getCachedValueFor; + _exports.peekCacheFor = peekCacheFor; + _exports.alias = alias; + _exports.deprecateProperty = deprecateProperty; + _exports._getPath = _getPath; + _exports.get = get; + _exports.getWithDefault = getWithDefault; + _exports.set = set; + _exports.trySet = trySet; + _exports.objectAt = objectAt; + _exports.replace = replace; + _exports.replaceInNativeArray = replaceInNativeArray; + _exports.addArrayObserver = addArrayObserver; + _exports.removeArrayObserver = removeArrayObserver; + _exports.arrayContentWillChange = arrayContentWillChange; + _exports.arrayContentDidChange = arrayContentDidChange; + _exports.eachProxyArrayWillChange = eachProxyArrayWillChange; + _exports.eachProxyArrayDidChange = eachProxyArrayDidChange; + _exports.addListener = addListener; + _exports.hasListeners = hasListeners; + _exports.on = on; + _exports.removeListener = removeListener; + _exports.sendEvent = sendEvent; + _exports.isNone = isNone; + _exports.isEmpty = isEmpty; + _exports.isBlank = isBlank; + _exports.isPresent = isPresent; + _exports.beginPropertyChanges = beginPropertyChanges; + _exports.changeProperties = changeProperties; + _exports.endPropertyChanges = endPropertyChanges; + _exports.notifyPropertyChange = notifyPropertyChange; + _exports.defineProperty = defineProperty; + _exports.isElementDescriptor = isElementDescriptor; + _exports.nativeDescDecorator = nativeDescDecorator; + _exports.descriptorForDecorator = descriptorForDecorator; + _exports.descriptorForProperty = descriptorForProperty; + _exports.isClassicDecorator = isClassicDecorator; + _exports.setClassicDecorator = setClassicDecorator; + _exports.getChainTagsForKey = getChainTagsForKey; + _exports.getProperties = getProperties; + _exports.setProperties = setProperties; + _exports.expandProperties = expandProperties; + _exports.destroy = destroy; + _exports.addObserver = addObserver; + _exports.activateObserver = activateObserver; + _exports.removeObserver = removeObserver; + _exports.flushAsyncObservers = flushAsyncObservers; + _exports.mixin = mixin; + _exports.observer = observer; + _exports.applyMixin = applyMixin; + _exports.inject = inject; + _exports.tagForProperty = tagForProperty; + _exports.tagForObject = tagForObject; + _exports.markObjectAsDirty = markObjectAsDirty; + _exports.tracked = tracked; + _exports.addNamespace = addNamespace; + _exports.classToString = classToString; + _exports.findNamespace = findNamespace; + _exports.findNamespaces = findNamespaces; + _exports.processNamespace = processNamespace; + _exports.processAllNamespaces = processAllNamespaces; + _exports.removeNamespace = removeNamespace; + _exports.isNamespaceSearchDisabled = isSearchDisabled; + _exports.setNamespaceSearchDisabled = setSearchDisabled; + _exports.NAMESPACES_BY_ID = _exports.NAMESPACES = _exports.CUSTOM_TAG_FOR = _exports.DEBUG_INJECTION_FUNCTIONS = _exports.aliasMethod = _exports.Mixin = _exports.SYNC_OBSERVERS = _exports.ASYNC_OBSERVERS = _exports.Libraries = _exports.libraries = _exports.PROPERTY_DID_CHANGE = _exports.PROXY_CONTENT = _exports.ComputedProperty = _exports._globalsComputed = void 0; + var COMPUTED_PROPERTY_CACHED_VALUES = new WeakMap(); + var COMPUTED_PROPERTY_LAST_REVISION = new WeakMap(); - function endPropertyChanges() { - deferred--; + function getCacheFor(obj) { + var cache = COMPUTED_PROPERTY_CACHED_VALUES.get(obj); - if (deferred <= 0) { - flushSyncObservers(); + if (cache === undefined) { + cache = new Map(); + COMPUTED_PROPERTY_CACHED_VALUES.set(obj, cache); } + + return cache; } /** - Make a series of property changes together in an - exception-safe way. - - ```javascript - Ember.changeProperties(function() { - obj1.set('foo', mayBlowUpWhenSet); - obj2.set('bar', baz); - }); - ``` + Returns the cached value for a property, if one exists. + This can be useful for peeking at the value of a computed + property that is generated lazily, without accidentally causing + it to be created. - @method changeProperties - @param {Function} callback - @private + @method cacheFor + @static + @for @ember/object/internals + @param {Object} obj the object whose property you want to check + @param {String} key the name of the property whose cached value you want + to return + @return {Object} the cached value + @public */ - function changeProperties(callback) { - beginPropertyChanges(); + function getCachedValueFor(obj, key) { + var cache = COMPUTED_PROPERTY_CACHED_VALUES.get(obj); - try { - callback(); - } finally { - endPropertyChanges(); + if (cache !== undefined) { + return cache.get(key); } } - function arrayContentWillChange(array, startIdx, removeAmt, addAmt) { - // if no args are passed assume everything changes - if (startIdx === undefined) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) { - removeAmt = -1; - } + function setLastRevisionFor(obj, key, revision) { + var cache = COMPUTED_PROPERTY_LAST_REVISION.get(obj); - if (addAmt === undefined) { - addAmt = -1; - } + if (cache === undefined) { + cache = new Map(); + COMPUTED_PROPERTY_LAST_REVISION.set(obj, cache); } - sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]); - return array; + cache.set(key, revision); } - function arrayContentDidChange(array, startIdx, removeAmt, addAmt, notify = true) { - // if no args are passed assume everything changes - if (startIdx === undefined) { - startIdx = 0; - removeAmt = addAmt = -1; - } else { - if (removeAmt === undefined) { - removeAmt = -1; - } + function getLastRevisionFor(obj, key) { + var cache = COMPUTED_PROPERTY_LAST_REVISION.get(obj); - if (addAmt === undefined) { - addAmt = -1; - } + if (cache === undefined) { + return 0; + } else { + var revision = cache.get(key); + return revision === undefined ? 0 : revision; } + } - var meta$$1 = (0, _meta2.peekMeta)(array); - - if (notify) { - if (addAmt < 0 || removeAmt < 0 || addAmt - removeAmt !== 0) { - notifyPropertyChange(array, 'length', meta$$1); - } - - notifyPropertyChange(array, '[]', meta$$1); - } + function peekCacheFor(obj) { + return COMPUTED_PROPERTY_CACHED_VALUES.get(obj); + } + /** + @module @ember/object + */ - sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]); - var cache = peekCacheFor(array); + /* + The event system uses a series of nested hashes to store listeners on an + object. When a listener is registered, or when an event arrives, these + hashes are consulted to determine which target and action pair to invoke. + + The hashes are stored in the object's meta hash, and look like this: + + // Object's meta hash + { + listeners: { // variable name: `listenerSet` + "foo:change": [ // variable name: `actions` + target, method, once + ] + } + } + + */ - if (cache !== undefined) { - var length = array.length; - var addedAmount = addAmt === -1 ? 0 : addAmt; - var removedAmount = removeAmt === -1 ? 0 : removeAmt; - var delta = addedAmount - removedAmount; - var previousLength = length - delta; - var normalStartIdx = startIdx < 0 ? previousLength + startIdx : startIdx; + /** + Add an event listener + + @method addListener + @static + @for @ember/object/events + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @param {Boolean} once A flag whether a function should only be called once + @public + */ - if (cache.has('firstObject') && normalStartIdx === 0) { - notifyPropertyChange(array, 'firstObject', meta$$1); - } - if (cache.has('lastObject')) { - var previousLastIndex = previousLength - 1; - var lastAffectedIndex = normalStartIdx + removedAmount; + function addListener(obj, eventName, target, method, once, sync = true) { + (true && !(Boolean(obj) && Boolean(eventName)) && (0, _debug.assert)('You must pass at least an object and event name to addListener', Boolean(obj) && Boolean(eventName))); - if (previousLastIndex < lastAffectedIndex) { - notifyPropertyChange(array, 'lastObject', meta$$1); - } - } + if (!method && 'function' === typeof target) { + method = target; + target = null; } - return array; + (0, _meta2.meta)(obj).addToListeners(eventName, target, method, once === true, sync); } + /** + Remove an event listener + + Arguments should match those passed to `addListener`. + + @method removeListener + @static + @for @ember/object/events + @param obj + @param {String} eventName + @param {Object|Function} target A target object or a function + @param {Function|String} method A function or the name of a function to be called on `target` + @public + */ - var EMPTY_ARRAY = Object.freeze([]); - function objectAt(array, index) { - if (Array.isArray(array)) { - return array[index]; + function removeListener(obj, eventName, targetOrFunction, functionOrName) { + (true && !(Boolean(obj) && Boolean(eventName) && (typeof targetOrFunction === 'function' || typeof targetOrFunction === 'object' && Boolean(functionOrName))) && (0, _debug.assert)('You must pass at least an object, event name, and method or target and method/method name to removeListener', Boolean(obj) && Boolean(eventName) && (typeof targetOrFunction === 'function' || typeof targetOrFunction === 'object' && Boolean(functionOrName)))); + var target, method; + + if (typeof targetOrFunction === 'object') { + target = targetOrFunction; + method = functionOrName; } else { - return array.objectAt(index); + target = null; + method = targetOrFunction; } + + var m = (0, _meta2.meta)(obj); + m.removeFromListeners(eventName, target, method); } + /** + Send an event. The execution of suspended listeners + is skipped, and once listeners are removed. A listener without + a target is executed on the passed object. If an array of actions + is not passed, the actions stored on the passed object are invoked. + + @method sendEvent + @static + @for @ember/object/events + @param obj + @param {String} eventName + @param {Array} params Optional parameters for each listener. + @return {Boolean} if the event was delivered to one or more actions + @public + */ - function replace(array, start, deleteCount, items = EMPTY_ARRAY) { - if (Array.isArray(array)) { - replaceInNativeArray(array, start, deleteCount, items); - } else { - array.replace(start, deleteCount, items); + + function sendEvent(obj, eventName, params, actions, _meta) { + if (actions === undefined) { + var meta$$1 = _meta === undefined ? (0, _meta2.peekMeta)(obj) : _meta; + actions = meta$$1 !== null ? meta$$1.matchingListeners(eventName) : undefined; } - } - var CHUNK_SIZE = 60000; // To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time. - // See https://code.google.com/p/chromium/issues/detail?id=56588 for more details. + if (actions === undefined || actions.length === 0) { + return false; + } - function replaceInNativeArray(array, start, deleteCount, items) { - arrayContentWillChange(array, start, deleteCount, items.length); + for (var i = actions.length - 3; i >= 0; i -= 3) { + // looping in reverse for once listeners + var target = actions[i]; + var method = actions[i + 1]; + var once = actions[i + 2]; - if (items.length <= CHUNK_SIZE) { - array.splice(start, deleteCount, ...items); - } else { - array.splice(start, deleteCount); + if (!method) { + continue; + } - for (var i = 0; i < items.length; i += CHUNK_SIZE) { - var chunk = items.slice(i, i + CHUNK_SIZE); - array.splice(start + i, 0, ...chunk); + if (once) { + removeListener(obj, eventName, target, method); } - } - arrayContentDidChange(array, start, deleteCount, items.length); - } + if (!target) { + target = obj; + } - function arrayObserversHelper(obj, target, opts, operation, notify) { - var willChange = opts && opts.willChange || 'arrayWillChange'; - var didChange = opts && opts.didChange || 'arrayDidChange'; - var hasObservers = obj.hasArrayObservers; - operation(obj, '@array:before', target, willChange); - operation(obj, '@array:change', target, didChange); + if ('string' === typeof method) { + method = target[method]; + } - if (hasObservers === notify) { - notifyPropertyChange(obj, 'hasArrayObservers'); + method.apply(target, params); } - return obj; - } - - function addArrayObserver(array, target, opts) { - return arrayObserversHelper(array, target, opts, addListener, false); + return true; } + /** + @private + @method hasListeners + @static + @for @ember/object/events + @param obj + @param {String} eventName + @return {Boolean} if `obj` has listeners for event `eventName` + */ - function removeArrayObserver(array, target, opts) { - return arrayObserversHelper(array, target, opts, removeListener, true); - } - function finishLazyChains(obj, key, value$$1) { + function hasListeners(obj, eventName) { var meta$$1 = (0, _meta2.peekMeta)(obj); - var lazyTags = meta$$1 !== null ? meta$$1.readableLazyChainsFor(key) : undefined; - if (lazyTags === undefined) { - return; + if (meta$$1 === null) { + return false; } - if (value$$1 === null || typeof value$$1 !== 'object' && typeof value$$1 !== 'function') { - for (var path in lazyTags) { - delete lazyTags[path]; - } + var matched = meta$$1.matchingListeners(eventName); + return matched !== undefined && matched.length > 0; + } + /** + Define a property as a function that should be executed when + a specified event or events are triggered. + + ``` javascript + import EmberObject from '@ember/object'; + import { on } from '@ember/object/evented'; + import { sendEvent } from '@ember/object/events'; + + let Job = EmberObject.extend({ + logCompleted: on('completed', function() { + console.log('Job completed!'); + }) + }); + + let job = Job.create(); + + sendEvent(job, 'completed'); // Logs 'Job completed!' + ``` + + @method on + @static + @for @ember/object/evented + @param {String} eventNames* + @param {Function} func + @return {Function} the listener function, passed as last argument to on(...) + @public + */ - return; - } - for (var _path in lazyTags) { - var tag = lazyTags[_path]; - (0, _reference.update)(tag, (0, _reference.combine)(getChainTagsForKey(value$$1, _path))); - delete lazyTags[_path]; - } + function on(...args) { + var func = args.pop(); + var events = args; + (true && !(typeof func === 'function') && (0, _debug.assert)('on expects function as last argument', typeof func === 'function')); + (true && !(events.length > 0 && events.every(p => typeof p === 'string' && p.length > 0)) && (0, _debug.assert)('on called without valid event names', events.length > 0 && events.every(p => typeof p === 'string' && p.length > 0))); + (0, _utils.setListeners)(func, events); + return func; } - function getChainTagsForKeys(obj, keys) { - var chainTags = []; - - for (var i = 0; i < keys.length; i++) { - chainTags.push(...getChainTagsForKey(obj, keys[i])); - } + var AFTER_OBSERVERS = ':change'; - return chainTags; + function changeEvent(keyName) { + return keyName + AFTER_OBSERVERS; } - function getChainTagsForKey(obj, path) { - var chainTags = []; - var current = obj; - var pathLength = path.length; - var segmentEnd = -1; // prevent closures + var SYNC_DEFAULT = !_environment.ENV._DEFAULT_ASYNC_OBSERVERS; + var SYNC_OBSERVERS = new Map(); + _exports.SYNC_OBSERVERS = SYNC_OBSERVERS; + var ASYNC_OBSERVERS = new Map(); + /** + @module @ember/object + */ - var segment, descriptor; // eslint-disable-next-line no-constant-condition + /** + @method addObserver + @static + @for @ember/object/observers + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @public + */ - while (true) { - var currentType = typeof current; + _exports.ASYNC_OBSERVERS = ASYNC_OBSERVERS; - if (current === null || currentType !== 'object' && currentType !== 'function') { - // we've hit the end of the chain for now, break out - break; - } + function addObserver(obj, path, target, method, sync = SYNC_DEFAULT) { + var eventName = changeEvent(path); + addListener(obj, eventName, target, method, false, sync); + var meta$$1 = (0, _meta2.peekMeta)(obj); - var lastSegmentEnd = segmentEnd + 1; - segmentEnd = path.indexOf('.', lastSegmentEnd); + if (meta$$1 === null || !(meta$$1.isPrototypeMeta(obj) || meta$$1.isInitializing())) { + activateObserver(obj, eventName, sync); + } + } + /** + @method removeObserver + @static + @for @ember/object/observers + @param obj + @param {String} path + @param {Object|Function} target + @param {Function|String} [method] + @public + */ - if (segmentEnd === -1) { - segmentEnd = pathLength; - } - segment = path.slice(lastSegmentEnd, segmentEnd); // If the segment is an @each, we can process it and then break + function removeObserver(obj, path, target, method, sync = SYNC_DEFAULT) { + var eventName = changeEvent(path); + var meta$$1 = (0, _meta2.peekMeta)(obj); - if (segment === '@each' && segmentEnd !== pathLength) { - lastSegmentEnd = segmentEnd + 1; - segmentEnd = path.indexOf('.', lastSegmentEnd); // There should be exactly one segment after an `@each` (i.e. `@each.foo`, not `@each.foo.bar`) + if (meta$$1 === null || !(meta$$1.isPrototypeMeta(obj) || meta$$1.isInitializing())) { + deactivateObserver(obj, eventName, sync); + } - (true && !(segmentEnd === -1) && (0, _debug.deprecate)("When using @each in a dependent-key or an observer, " + "you can only chain one property level deep after " + ("the @each. That is, `" + path.slice(0, segmentEnd) + "` ") + ("is allowed but `" + path + "` (which is what you passed) ") + "is not.\n\n" + "This was never supported. Currently, the extra segments " + ("are silently ignored, i.e. `" + path + "` behaves exactly ") + ("the same as `" + path.slice(0, segmentEnd) + "`. ") + "In the future, this will throw an error.\n\n" + "If the current behavior is acceptable for your use case, " + "please remove the extraneous segments by changing your " + ("key to `" + path.slice(0, segmentEnd) + "`. ") + "Otherwise, please create an intermediary computed property " + "or switch to using tracked properties.", segmentEnd === -1, { - until: '3.17.0', - id: 'ember-metal.computed-deep-each' - })); - var arrLength = current.length; + removeListener(obj, eventName, target, method); + } - if (typeof arrLength !== 'number' || // TODO: should the second test be `isEmberArray` instead? - !(Array.isArray(current) || 'objectAt' in current)) { - // If the current object isn't an array, there's nothing else to do, - // we don't watch individual properties. Break out of the loop. - break; - } else if (arrLength === 0) { - // Fast path for empty arrays - chainTags.push(tagForProperty(current, '[]')); - break; - } + function getOrCreateActiveObserversFor(target, sync) { + var observerMap = sync === true ? SYNC_OBSERVERS : ASYNC_OBSERVERS; - if (segmentEnd === -1) { - segment = path.slice(lastSegmentEnd); - } else { - // Deprecated, remove once we turn the deprecation into an assertion - segment = path.slice(lastSegmentEnd, segmentEnd); - } // Push the tags for each item's property + if (!observerMap.has(target)) { + observerMap.set(target, new Map()); + } + return observerMap.get(target); + } - for (var i = 0; i < arrLength; i++) { - var item = objectAt(current, i); + function activateObserver(target, eventName, sync = false) { + var activeObservers = getOrCreateActiveObserversFor(target, sync); - if (item) { - (true && !(typeof item === 'object') && (0, _debug.assert)("When using @each to observe the array `" + current.toString() + "`, the items in the array must be objects", typeof item === 'object')); - chainTags.push(tagForProperty(item, segment)); - } - } // Push the tag for the array length itself + if (activeObservers.has(eventName)) { + activeObservers.get(eventName).count++; + } else { + var [path] = eventName.split(':'); + var tag = (0, _validator.combine)(getChainTagsForKey(target, path)); + activeObservers.set(eventName, { + count: 1, + path, + tag, + lastRevision: (0, _validator.value)(tag), + suspended: false + }); + } + } + function deactivateObserver(target, eventName, sync = false) { + var observerMap = sync === true ? SYNC_OBSERVERS : ASYNC_OBSERVERS; + var activeObservers = observerMap.get(target); - chainTags.push(tagForProperty(current, '[]')); - break; - } // TODO: Assert that current[segment] isn't an undecorated, non-MANDATORY_SETTER/dependentKeyCompat getter + if (activeObservers !== undefined) { + var _observer = activeObservers.get(eventName); + _observer.count--; - var propertyTag = tagForProperty(current, segment); - descriptor = descriptorForProperty(current, segment); - chainTags.push(propertyTag); // If the key was an alias, we should always get the next value in order to - // bootstrap the alias. This is because aliases, unlike other CPs, should - // always be in sync with the aliased value. + if (_observer.count === 0) { + activeObservers.delete(eventName); - if (descriptor !== undefined && typeof descriptor.altKey === 'string') { - current = current[segment]; // We still need to break if we're at the end of the path. + if (activeObservers.size === 0) { + observerMap.delete(target); + } + } + } + } + /** + * Primarily used for cases where we are redefining a class, e.g. mixins/reopen + * being applied later. Revalidates all the observers, resetting their tags. + * + * @private + * @param target + */ - if (segmentEnd === pathLength) { - break; - } // Otherwise, continue to process the next segment + function revalidateObservers(target) { + if (ASYNC_OBSERVERS.has(target)) { + ASYNC_OBSERVERS.get(target).forEach(observer => { + observer.tag = (0, _validator.combine)(getChainTagsForKey(target, observer.path)); + observer.lastRevision = (0, _validator.value)(observer.tag); + }); + } - continue; - } // If we're at the end of the path, processing the last segment, and it's - // not an alias, we should _not_ get the last value, since we already have - // its tag. There's no reason to access it and do more work. + if (SYNC_OBSERVERS.has(target)) { + SYNC_OBSERVERS.get(target).forEach(observer => { + observer.tag = (0, _validator.combine)(getChainTagsForKey(target, observer.path)); + observer.lastRevision = (0, _validator.value)(observer.tag); + }); + } + } + var lastKnownRevision = 0; - if (segmentEnd === pathLength) { - break; - } + function flushAsyncObservers(shouldSchedule = true) { + var currentRevision = (0, _validator.value)(_validator.CURRENT_TAG); - if (descriptor === undefined) { - // If the descriptor is undefined, then its a normal property, so we should - // lookup the value to chain off of like normal. - if (!(segment in current) && typeof current.unknownProperty === 'function') { - current = current.unknownProperty(segment); - } else { - current = current[segment]; - } - } else { - // If the descriptor is defined, then its a normal CP (not an alias, which - // would have been handled earlier). We get the last revision to check if - // the CP is still valid, and if so we use the cached value. If not, then - // we create a lazy chain lookup, and the next time the CP is caluculated, - // it will update that lazy chain. - var lastRevision = getLastRevisionFor(current, segment); + if (lastKnownRevision === currentRevision) { + return; + } - if ((0, _reference.validate)(propertyTag, lastRevision)) { - current = peekCacheFor(current).get(segment); - } else { - var lazyChains = (0, _meta2.meta)(current).writableLazyChainsFor(segment); - var rest = path.substr(segmentEnd + 1); - var placeholderTag = lazyChains[rest]; + lastKnownRevision = currentRevision; + ASYNC_OBSERVERS.forEach((activeObservers, target) => { + var meta$$1 = (0, _meta2.peekMeta)(target); // if observer target is destroyed remove observers - if (placeholderTag === undefined) { - placeholderTag = lazyChains[rest] = (0, _reference.createUpdatableTag)(); - } + if (meta$$1 && (meta$$1.isSourceDestroying() || meta$$1.isMetaDestroyed())) { + ASYNC_OBSERVERS.delete(target); + return; + } - chainTags.push(placeholderTag); - break; + activeObservers.forEach((observer, eventName) => { + if (!(0, _validator.validate)(observer.tag, observer.lastRevision)) { + var sendObserver = () => { + try { + sendEvent(target, eventName, [target, observer.path], undefined, meta$$1); + } finally { + observer.tag = (0, _validator.combine)(getChainTagsForKey(target, observer.path)); + observer.lastRevision = (0, _validator.value)(observer.tag); + } + }; + + if (shouldSchedule) { + (0, _runloop.schedule)('actions', sendObserver); + } else { + sendObserver(); + } } + }); + }); + } + + function flushSyncObservers() { + // When flushing synchronous observers, we know that something has changed (we + // only do this during a notifyPropertyChange), so there's no reason to check + // a global revision. + SYNC_OBSERVERS.forEach((activeObservers, target) => { + var meta$$1 = (0, _meta2.peekMeta)(target); + + if (meta$$1 && (meta$$1.isSourceDestroying() || meta$$1.isMetaDestroyed())) { + SYNC_OBSERVERS.delete(target); + return; } - } - return chainTags; + activeObservers.forEach((observer, eventName) => { + if (!observer.suspended && !(0, _validator.validate)(observer.tag, observer.lastRevision)) { + try { + observer.suspended = true; + sendEvent(target, eventName, [target, observer.path], undefined, meta$$1); + } finally { + observer.tag = (0, _validator.combine)(getChainTagsForKey(target, observer.path)); + observer.lastRevision = (0, _validator.value)(observer.tag); + observer.suspended = false; + } + } + }); + }); } - /** - @module @ember/object - */ - - var END_WITH_EACH_REGEX = /\.@each$/; - /** - Expands `pattern`, invoking `callback` for each expansion. - - The only pattern supported is brace-expansion, anything else will be passed - once to `callback` directly. - - Example - - ```js - import { expandProperties } from '@ember/object/computed'; - - function echo(arg){ console.log(arg); } - - expandProperties('foo.bar', echo); //=> 'foo.bar' - expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' - expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' - expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' - expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' - expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' - expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' - ``` - - @method expandProperties - @static - @for @ember/object/computed - @public - @param {String} pattern The property pattern to expand. - @param {Function} callback The callback to invoke. It is invoked once per - expansion, and is passed the expansion. - */ + function setObserverSuspended(target, property, suspended) { + var activeObservers = SYNC_OBSERVERS.get(target); - function expandProperties(pattern, callback) { - (true && !(typeof pattern === 'string') && (0, _debug.assert)("A computed property key must be a string, you passed " + typeof pattern + " " + pattern, typeof pattern === 'string')); - (true && !(pattern.indexOf(' ') === -1) && (0, _debug.assert)('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1)); // regex to look for double open, double close, or unclosed braces + if (!activeObservers) { + return; + } - (true && !(pattern.match(/\{[^}{]*\{|\}[^}{]*\}|\{[^}]*$/g) === null) && (0, _debug.assert)("Brace expanded properties have to be balanced and cannot be nested, pattern: " + pattern, pattern.match(/\{[^}{]*\{|\}[^}{]*\}|\{[^}]*$/g) === null)); - var start = pattern.indexOf('{'); + var observer = activeObservers.get(changeEvent(property)); - if (start < 0) { - callback(pattern.replace(END_WITH_EACH_REGEX, '.[]')); - } else { - dive('', pattern, start, callback); + if (observer) { + observer.suspended = suspended; } } - function dive(prefix, pattern, start, callback) { - var end = pattern.indexOf('}'), - i = 0, - newStart, - arrayLength; - var tempArr = pattern.substring(start + 1, end).split(','); - var after = pattern.substring(end + 1); - prefix = prefix + pattern.substring(0, start); - arrayLength = tempArr.length; + function destroyObservers(target) { + if (SYNC_OBSERVERS.size > 0) SYNC_OBSERVERS.delete(target); + if (ASYNC_OBSERVERS.size > 0) ASYNC_OBSERVERS.delete(target); + } // Setup tracking environment - while (i < arrayLength) { - newStart = after.indexOf('{'); - if (newStart < 0) { - callback((prefix + tempArr[i++] + after).replace(END_WITH_EACH_REGEX, '.[]')); - } else { - dive(prefix + tempArr[i++], after, newStart, callback); + (0, _validator.setPropertyDidChange)(() => _runloop.backburner.ensureInstance()); + + if (true + /* DEBUG */ + ) { + (0, _validator.setAutotrackingTransactionEnv)({ + assert(message) { + (true && !(false) && (0, _debug.assert)(message, false)); + }, + + deprecate(message) { + (true && !(false) && (0, _debug.deprecate)(message, false, { + id: 'autotracking.mutation-after-consumption', + until: '4.0.0' + })); + }, + + debugMessage(obj, keyName) { + var dirtyString = keyName ? `\`${keyName}\` on \`${(0, _utils.getDebugName)(obj)}\`` : `\`${(0, _utils.getDebugName)(obj)}\``; + return `You attempted to update ${dirtyString}, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.`; } - } - } - /** - @module @ember/object - */ - /** - NOTE: This is a low-level method used by other parts of the API. You almost - never want to call this method directly. Instead you should use - `mixin()` to define new properties. - - Defines a property on an object. This method works much like the ES5 - `Object.defineProperty()` method except that it can also accept computed - properties and other special descriptors. - - Normally this method takes only three parameters. However if you pass an - instance of `Descriptor` as the third param then you can pass an - optional value as the fourth parameter. This is often more efficient than - creating new descriptor hashes for each property. - - ## Examples - - ```javascript - import { defineProperty, computed } from '@ember/object'; - - // ES5 compatible mode - defineProperty(contact, 'firstName', { - writable: true, - configurable: false, - enumerable: true, - value: 'Charles' }); - - // define a simple property - defineProperty(contact, 'lastName', undefined, 'Jolley'); - - // define a computed property - defineProperty(contact, 'fullName', computed('firstName', 'lastName', function() { - return this.firstName+' '+this.lastName; - })); - ``` - - @public - @method defineProperty - @static - @for @ember/object - @param {Object} obj the object to define this property on. This may be a prototype. - @param {String} keyName the name of the property - @param {Descriptor} [desc] an instance of `Descriptor` (typically a - computed property) or an ES5 descriptor. - You must provide this or `data` but not both. - @param {*} [data] something other than a descriptor, that will - become the explicit value of this property. - */ + } ///////// - function defineProperty(obj, keyName, desc, data, meta$$1) { - if (meta$$1 === undefined) { - meta$$1 = (0, _meta2.meta)(obj); - } + var CUSTOM_TAG_FOR = (0, _utils.symbol)('CUSTOM_TAG_FOR'); // This is exported for `@tracked`, but should otherwise be avoided. Use `tagForObject`. - var previousDesc = descriptorForProperty(obj, keyName, meta$$1); - var wasDescriptor = previousDesc !== undefined; + _exports.CUSTOM_TAG_FOR = CUSTOM_TAG_FOR; + var SELF_TAG = (0, _utils.symbol)('SELF_TAG'); - if (wasDescriptor) { - previousDesc.teardown(obj, keyName, meta$$1); - } // used to track if the the property being defined be enumerable + function tagForProperty(obj, propertyKey) { + if (!(0, _utils.isObject)(obj)) { + return _validator.CONSTANT_TAG; + } + if (typeof obj[CUSTOM_TAG_FOR] === 'function') { + return obj[CUSTOM_TAG_FOR](propertyKey); + } - var enumerable = true; // Ember.NativeArray is a normal Ember.Mixin that we mix into `Array.prototype` when prototype extensions are enabled - // mutating a native object prototype like this should _not_ result in enumerable properties being added (or we have significant - // issues with things like deep equality checks from test frameworks, or things like jQuery.extend(true, [], [])). - // - // this is a hack, and we should stop mutating the array prototype by default 😫 + var tag = (0, _validator.tagFor)(obj, propertyKey); - if (obj === Array.prototype) { - enumerable = false; - } + if (true + /* DEBUG */ + ) { + (0, _utils.setupMandatorySetter)(tag, obj, propertyKey); // TODO: Replace this with something more first class for tracking tags in DEBUG - var value$$1; + tag._propertyKey = propertyKey; + } - if (isClassicDecorator(desc)) { - var propertyDesc; + return tag; + } + function tagForObject(obj) { + if ((0, _utils.isObject)(obj)) { if (true /* DEBUG */ ) { - propertyDesc = desc(obj, keyName, undefined, meta$$1, true); - } else { - propertyDesc = desc(obj, keyName, undefined, meta$$1); + var meta$$1 = (0, _meta2.meta)(obj); + (true && !(!meta$$1.isMetaDestroyed()) && (0, _debug.assert)(meta$$1.isMetaDestroyed() ? `Cannot create a new tag for \`${(0, _utils.toString)(meta$$1.source)}\` after it has been destroyed.` : '', !meta$$1.isMetaDestroyed())); } - Object.defineProperty(obj, keyName, propertyDesc); // pass the decorator function forward for backwards compat - - value$$1 = desc; - } else if (desc === undefined || desc === null) { - value$$1 = data; + return (0, _validator.tagFor)(obj, SELF_TAG); + } - if (wasDescriptor || enumerable === false) { - Object.defineProperty(obj, keyName, { - configurable: true, - enumerable, - writable: true, - value: value$$1 - }); - } else { - if (true - /* DEBUG */ - ) { - (0, _utils.setWithMandatorySetter)(obj, keyName, data); - } else { - obj[keyName] = data; - } - } - } else { - value$$1 = desc; // fallback to ES5 + return _validator.CONSTANT_TAG; + } - Object.defineProperty(obj, keyName, desc); - } // if key is being watched, override chains that - // were initialized with the prototype + function markObjectAsDirty(obj, propertyKey) { + (0, _validator.dirtyTagFor)(obj, propertyKey); + (0, _validator.dirtyTagFor)(obj, SELF_TAG); + } + /** + @module ember + @private + */ - if (!meta$$1.isPrototypeMeta(obj)) { - revalidateObservers(obj); - } // The `value` passed to the `didDefineProperty` hook is - // either the descriptor or data, whichever was passed. + var PROPERTY_DID_CHANGE = (0, _utils.symbol)('PROPERTY_DID_CHANGE'); + _exports.PROPERTY_DID_CHANGE = PROPERTY_DID_CHANGE; + var deferred = 0; + /** + This function is called just after an object property has changed. + It will notify any observers and clear caches among other things. + + Normally you will not need to call this method directly but if for some + reason you can't directly watch a property you can invoke this method + manually. + + @method notifyPropertyChange + @for @ember/object + @param {Object} obj The object with the property that will change + @param {String} keyName The property key (or path) that will change. + @param {Meta} meta The objects meta. + @return {void} + @since 3.1.0 + @public + */ + function notifyPropertyChange(obj, keyName, _meta) { + var meta$$1 = _meta === undefined ? (0, _meta2.peekMeta)(obj) : _meta; - if (typeof obj.didDefineProperty === 'function') { - obj.didDefineProperty(obj, keyName, value$$1); + if (meta$$1 !== null && (meta$$1.isInitializing() || meta$$1.isPrototypeMeta(obj))) { + return; } - } - var firstDotIndexCache = new _utils.Cache(1000, key => key.indexOf('.')); + markObjectAsDirty(obj, keyName); - function isPath(path) { - return typeof path === 'string' && firstDotIndexCache.get(path) !== -1; + if (deferred <= 0) { + flushSyncObservers(); + } + + if (PROPERTY_DID_CHANGE in obj) { + obj[PROPERTY_DID_CHANGE](keyName); + } } /** - @module @ember/object + @method beginPropertyChanges + @chainable + @private */ - var PROXY_CONTENT = (0, _utils.symbol)('PROXY_CONTENT'); - _exports.PROXY_CONTENT = PROXY_CONTENT; - var getPossibleMandatoryProxyValue; + function beginPropertyChanges() { + deferred++; + } + /** + @method endPropertyChanges + @private + */ - if (true - /* DEBUG */ - && _utils.HAS_NATIVE_PROXY) { - getPossibleMandatoryProxyValue = function getPossibleMandatoryProxyValue(obj, keyName) { - var content = obj[PROXY_CONTENT]; - if (content === undefined) { - return obj[keyName]; - } else { - /* global Reflect */ - return Reflect.get(content, keyName, obj); - } - }; - } // .......................................................... - // GET AND SET - // - // If we are on a platform that supports accessors we can use those. - // Otherwise simulate accessors by looking up the property directly on the - // object. + function endPropertyChanges() { + deferred--; + if (deferred <= 0) { + flushSyncObservers(); + } + } /** - Gets the value of a property on an object. If the property is computed, - the function will be invoked. If the property is not defined but the - object implements the `unknownProperty` method then that will be invoked. + Make a series of property changes together in an + exception-safe way. ```javascript - import { get } from '@ember/object'; - get(obj, "name"); + Ember.changeProperties(function() { + obj1.set('foo', mayBlowUpWhenSet); + obj2.set('bar', baz); + }); ``` - If you plan to run on IE8 and older browsers then you should use this - method anytime you want to retrieve a property on an object that you don't - know for sure is private. (Properties beginning with an underscore '_' - are considered private.) - - On all newer browsers, you only need to use this method to retrieve - properties if the property might not be defined on the object and you want - to respect the `unknownProperty` handler. Otherwise you can ignore this - method. - - Note that if the object itself is `undefined`, this method will throw - an error. - - @method get - @for @ember/object - @static - @param {Object} obj The object to retrieve from. - @param {String} keyName The property key to retrieve - @return {Object} the property value or `null`. - @public + @method changeProperties + @param {Function} callback + @private */ - function get(obj, keyName) { - (true && !(arguments.length === 2) && (0, _debug.assert)("Get must be called with two arguments; an object and a property key", arguments.length === 2)); - (true && !(obj !== undefined && obj !== null) && (0, _debug.assert)("Cannot call get with '" + keyName + "' on an undefined object.", obj !== undefined && obj !== null)); - (true && !(typeof keyName === 'string' || typeof keyName === 'number' && !isNaN(keyName)) && (0, _debug.assert)("The key provided to get must be a string or number, you passed " + keyName, typeof keyName === 'string' || typeof keyName === 'number' && !isNaN(keyName))); - (true && !(typeof keyName !== 'string' || keyName.lastIndexOf('this.', 0) !== 0) && (0, _debug.assert)("'this' in paths is not supported", typeof keyName !== 'string' || keyName.lastIndexOf('this.', 0) !== 0)); - var type = typeof obj; - var isObject = type === 'object'; - var isFunction = type === 'function'; - var isObjectLike = isObject || isFunction; + function changeProperties(callback) { + beginPropertyChanges(); - if (isPath(keyName)) { - return isObjectLike ? _getPath(obj, keyName) : undefined; + try { + callback(); + } finally { + endPropertyChanges(); } + } - var value$$1; + function arrayContentWillChange(array, startIdx, removeAmt, addAmt) { + // if no args are passed assume everything changes + if (startIdx === undefined) { + startIdx = 0; + removeAmt = addAmt = -1; + } else { + if (removeAmt === undefined) { + removeAmt = -1; + } - if (isObjectLike) { - if (true - /* DEBUG */ - && _utils.HAS_NATIVE_PROXY) { - value$$1 = getPossibleMandatoryProxyValue(obj, keyName); - } else { - value$$1 = obj[keyName]; + if (addAmt === undefined) { + addAmt = -1; } + } + + sendEvent(array, '@array:before', [array, startIdx, removeAmt, addAmt]); + return array; + } + + function arrayContentDidChange(array, startIdx, removeAmt, addAmt, notify = true) { + // if no args are passed assume everything changes + if (startIdx === undefined) { + startIdx = 0; + removeAmt = addAmt = -1; } else { - value$$1 = obj[keyName]; + if (removeAmt === undefined) { + removeAmt = -1; + } + + if (addAmt === undefined) { + addAmt = -1; + } } - if (value$$1 === undefined) { - if (isObject && !(keyName in obj) && typeof obj.unknownProperty === 'function') { - if (true - /* DEBUG */ - ) { - deprecateMutationsInAutotrackingTransaction(() => { - value$$1 = obj.unknownProperty(keyName); - }); - } else { - value$$1 = obj.unknownProperty(keyName); - } + var meta$$1 = (0, _meta2.peekMeta)(array); + + if (notify) { + if (addAmt < 0 || removeAmt < 0 || addAmt - removeAmt !== 0) { + notifyPropertyChange(array, 'length', meta$$1); } + + notifyPropertyChange(array, '[]', meta$$1); } - if (isObjectLike && isTracking()) { - consume(tagForProperty(obj, keyName)); // Add the tag of the returned value if it is an array, since arrays - // should always cause updates if they are consumed and then changed + sendEvent(array, '@array:change', [array, startIdx, removeAmt, addAmt]); + var cache = peekCacheFor(array); - if (Array.isArray(value$$1) || (0, _utils.isEmberArray)(value$$1)) { - consume(tagForProperty(value$$1, '[]')); - } // Add the value of the content if the value is a proxy. This is because - // content changes the truthiness/falsiness of the proxy. + if (cache !== undefined) { + var length = array.length; + var addedAmount = addAmt === -1 ? 0 : addAmt; + var removedAmount = removeAmt === -1 ? 0 : removeAmt; + var delta = addedAmount - removedAmount; + var previousLength = length - delta; + var normalStartIdx = startIdx < 0 ? previousLength + startIdx : startIdx; + + if (cache.has('firstObject') && normalStartIdx === 0) { + notifyPropertyChange(array, 'firstObject', meta$$1); + } + if (cache.has('lastObject')) { + var previousLastIndex = previousLength - 1; + var lastAffectedIndex = normalStartIdx + removedAmount; - if ((0, _utils.isProxy)(value$$1)) { - consume(tagForProperty(value$$1, 'content')); + if (previousLastIndex < lastAffectedIndex) { + notifyPropertyChange(array, 'lastObject', meta$$1); + } } } - return value$$1; + return array; } - function _getPath(root, path) { - var obj = root; - var parts = typeof path === 'string' ? path.split('.') : path; + var EMPTY_ARRAY = Object.freeze([]); - for (var i = 0; i < parts.length; i++) { - if (obj === undefined || obj === null || obj.isDestroyed) { - return undefined; + function objectAt(array, index) { + if (Array.isArray(array)) { + return array[index]; + } else { + return array.objectAt(index); + } + } + + function replace(array, start, deleteCount, items = EMPTY_ARRAY) { + if (Array.isArray(array)) { + replaceInNativeArray(array, start, deleteCount, items); + } else { + array.replace(start, deleteCount, items); + } + } + + var CHUNK_SIZE = 60000; // To avoid overflowing the stack, we splice up to CHUNK_SIZE items at a time. + // See https://code.google.com/p/chromium/issues/detail?id=56588 for more details. + + function replaceInNativeArray(array, start, deleteCount, items) { + arrayContentWillChange(array, start, deleteCount, items.length); + + if (items.length <= CHUNK_SIZE) { + array.splice(start, deleteCount, ...items); + } else { + array.splice(start, deleteCount); + + for (var i = 0; i < items.length; i += CHUNK_SIZE) { + var chunk = items.slice(i, i + CHUNK_SIZE); + array.splice(start + i, 0, ...chunk); } + } - obj = get(obj, parts[i]); + arrayContentDidChange(array, start, deleteCount, items.length); + } + + function arrayObserversHelper(obj, target, opts, operation, notify) { + var willChange = opts && opts.willChange || 'arrayWillChange'; + var didChange = opts && opts.didChange || 'arrayDidChange'; + var hasObservers = obj.hasArrayObservers; + operation(obj, '@array:before', target, willChange); + operation(obj, '@array:change', target, didChange); + + if (hasObservers === notify) { + notifyPropertyChange(obj, 'hasArrayObservers'); } return obj; } + + function addArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, addListener, false); + } + + function removeArrayObserver(array, target, opts) { + return arrayObserversHelper(array, target, opts, removeListener, true); + } + + var DECORATOR_DESCRIPTOR_MAP = new WeakMap(); /** - Retrieves the value of a property from an Object, or a default value in the - case that the property returns `undefined`. - - ```javascript - import { getWithDefault } from '@ember/object'; - getWithDefault(person, 'lastName', 'Doe'); - ``` + Returns the CP descriptor associated with `obj` and `keyName`, if any. - @method getWithDefault - @for @ember/object - @static - @param {Object} obj The object to retrieve from. - @param {String} keyName The name of the property to retrieve - @param {Object} defaultValue The value to return if the property value is undefined - @return {Object} The property value or the defaultValue. - @public + @method descriptorForProperty + @param {Object} obj the object to check + @param {String} keyName the key to check + @return {Descriptor} + @private */ + function descriptorForProperty(obj, keyName, _meta) { + (true && !(obj !== null) && (0, _debug.assert)('Cannot call `descriptorForProperty` on null', obj !== null)); + (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `descriptorForProperty` on undefined', obj !== undefined)); + (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)(`Cannot call \`descriptorForProperty\` on ${typeof obj}`, typeof obj === 'object' || typeof obj === 'function')); + var meta$$1 = _meta === undefined ? (0, _meta2.peekMeta)(obj) : _meta; - function getWithDefault(root, key, defaultValue) { - var value$$1 = get(root, key); - - if (value$$1 === undefined) { - return defaultValue; + if (meta$$1 !== null) { + return meta$$1.peekDescriptors(keyName); } + } - return value$$1; + function descriptorForDecorator(dec) { + return DECORATOR_DESCRIPTOR_MAP.get(dec); } /** - @module @ember/object + Check whether a value is a decorator + + @method isClassicDecorator + @param {any} possibleDesc the value to check + @return {boolean} + @private */ + + function isClassicDecorator(dec) { + return dec !== null && dec !== undefined && DECORATOR_DESCRIPTOR_MAP.has(dec); + } /** - Sets the value of a property on an object, respecting computed properties - and notifying observers and other listeners of the change. - If the specified property is not defined on the object and the object - implements the `setUnknownProperty` method, then instead of setting the - value of the property on the object, its `setUnknownProperty` handler - will be invoked with the two parameters `keyName` and `value`. - - ```javascript - import { set } from '@ember/object'; - set(obj, "name", value); - ``` + Set a value as a decorator - @method set - @static - @for @ember/object - @param {Object} obj The object to modify. - @param {String} keyName The property key to set - @param {Object} value The value to set - @return {Object} the passed value. - @public + @method setClassicDecorator + @param {function} decorator the value to mark as a decorator + @private */ - function set(obj, keyName, value$$1, tolerant) { - (true && !(arguments.length === 3 || arguments.length === 4) && (0, _debug.assert)("Set must be called with three or four arguments; an object, a property key, a value and tolerant true/false", arguments.length === 3 || arguments.length === 4)); - (true && !(obj && typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)("Cannot call set with '" + keyName + "' on an undefined object.", obj && typeof obj === 'object' || typeof obj === 'function')); - (true && !(typeof keyName === 'string' || typeof keyName === 'number' && !isNaN(keyName)) && (0, _debug.assert)("The key provided to set must be a string or number, you passed " + keyName, typeof keyName === 'string' || typeof keyName === 'number' && !isNaN(keyName))); - (true && !(typeof keyName !== 'string' || keyName.lastIndexOf('this.', 0) !== 0) && (0, _debug.assert)("'this' in paths is not supported", typeof keyName !== 'string' || keyName.lastIndexOf('this.', 0) !== 0)); + function setClassicDecorator(dec, value$$1 = true) { + DECORATOR_DESCRIPTOR_MAP.set(dec, value$$1); + } - if (obj.isDestroyed) { - (true && !(tolerant) && (0, _debug.assert)("calling set on destroyed object: " + (0, _utils.toString)(obj) + "." + keyName + " = " + (0, _utils.toString)(value$$1), tolerant)); + function finishLazyChains(obj, key, value$$1) { + var meta$$1 = (0, _meta2.peekMeta)(obj); + var lazyTags = meta$$1 !== null ? meta$$1.readableLazyChainsFor(key) : undefined; + + if (lazyTags === undefined) { return; } - if (isPath(keyName)) { - return setPath(obj, keyName, value$$1, tolerant); - } + if (value$$1 === null || typeof value$$1 !== 'object' && typeof value$$1 !== 'function') { + for (var path in lazyTags) { + delete lazyTags[path]; + } - var descriptor = (0, _utils.lookupDescriptor)(obj, keyName); - var setter = descriptor === null ? undefined : descriptor.set; + return; + } - if (setter !== undefined && CP_SETTER_FUNCS.has(setter)) { - obj[keyName] = value$$1; - return value$$1; + for (var _path in lazyTags) { + var tag = lazyTags[_path]; + (0, _validator.update)(tag, (0, _validator.combine)(getChainTagsForKey(value$$1, _path))); + delete lazyTags[_path]; } + } - var currentValue; + function getChainTagsForKeys(obj, keys) { + var chainTags = []; - if (true - /* DEBUG */ - && _utils.HAS_NATIVE_PROXY) { - currentValue = getPossibleMandatoryProxyValue(obj, keyName); - } else { - currentValue = obj[keyName]; + for (var i = 0; i < keys.length; i++) { + chainTags.push(...getChainTagsForKey(obj, keys[i])); } - if (currentValue === undefined && 'object' === typeof obj && !(keyName in obj) && typeof obj.setUnknownProperty === 'function') { - /* unknown property */ - obj.setUnknownProperty(keyName, value$$1); - } else { - if (true - /* DEBUG */ - ) { - (0, _utils.setWithMandatorySetter)(obj, keyName, value$$1); - } else { - obj[keyName] = value$$1; + return chainTags; + } + + function getChainTagsForKey(obj, path) { + var chainTags = []; + var current = obj; + var pathLength = path.length; + var segmentEnd = -1; // prevent closures + + var segment, descriptor; // eslint-disable-next-line no-constant-condition + + while (true) { + var currentType = typeof current; + + if (current === null || currentType !== 'object' && currentType !== 'function') { + // we've hit the end of the chain for now, break out + break; } - if (currentValue !== value$$1) { - notifyPropertyChange(obj, keyName); + var lastSegmentEnd = segmentEnd + 1; + segmentEnd = path.indexOf('.', lastSegmentEnd); + + if (segmentEnd === -1) { + segmentEnd = pathLength; + } + + segment = path.slice(lastSegmentEnd, segmentEnd); // If the segment is an @each, we can process it and then break + + if (segment === '@each' && segmentEnd !== pathLength) { + lastSegmentEnd = segmentEnd + 1; + segmentEnd = path.indexOf('.', lastSegmentEnd); // There should be exactly one segment after an `@each` (i.e. `@each.foo`, not `@each.foo.bar`) + + (true && !(segmentEnd === -1) && (0, _debug.deprecate)(`When using @each in a dependent-key or an observer, ` + `you can only chain one property level deep after ` + `the @each. That is, \`${path.slice(0, segmentEnd)}\` ` + `is allowed but \`${path}\` (which is what you passed) ` + `is not.\n\n` + `This was never supported. Currently, the extra segments ` + `are silently ignored, i.e. \`${path}\` behaves exactly ` + `the same as \`${path.slice(0, segmentEnd)}\`. ` + `In the future, this will throw an error.\n\n` + `If the current behavior is acceptable for your use case, ` + `please remove the extraneous segments by changing your ` + `key to \`${path.slice(0, segmentEnd)}\`. ` + `Otherwise, please create an intermediary computed property ` + `or switch to using tracked properties.`, segmentEnd === -1, { + until: '3.17.0', + id: 'ember-metal.computed-deep-each' + })); + var arrLength = current.length; + + if (typeof arrLength !== 'number' || // TODO: should the second test be `isEmberArray` instead? + !(Array.isArray(current) || 'objectAt' in current)) { + // If the current object isn't an array, there's nothing else to do, + // we don't watch individual properties. Break out of the loop. + break; + } else if (arrLength === 0) { + // Fast path for empty arrays + chainTags.push(tagForProperty(current, '[]')); + break; + } + + if (segmentEnd === -1) { + segment = path.slice(lastSegmentEnd); + } else { + // Deprecated, remove once we turn the deprecation into an assertion + segment = path.slice(lastSegmentEnd, segmentEnd); + } // Push the tags for each item's property + + + for (var i = 0; i < arrLength; i++) { + var item = objectAt(current, i); + + if (item) { + (true && !(typeof item === 'object') && (0, _debug.assert)(`When using @each to observe the array \`${current.toString()}\`, the items in the array must be objects`, typeof item === 'object')); + chainTags.push(tagForProperty(item, segment)); + } + } // Push the tag for the array length itself + + + chainTags.push(tagForProperty(current, '[]')); + break; + } // TODO: Assert that current[segment] isn't an undecorated, non-MANDATORY_SETTER/dependentKeyCompat getter + + + var propertyTag = tagForProperty(current, segment); + descriptor = descriptorForProperty(current, segment); + chainTags.push(propertyTag); // If the key was an alias, we should always get the next value in order to + // bootstrap the alias. This is because aliases, unlike other CPs, should + // always be in sync with the aliased value. + + if (descriptor !== undefined && typeof descriptor.altKey === 'string') { + current = current[segment]; // We still need to break if we're at the end of the path. + + if (segmentEnd === pathLength) { + break; + } // Otherwise, continue to process the next segment + + + continue; + } // If we're at the end of the path, processing the last segment, and it's + // not an alias, we should _not_ get the last value, since we already have + // its tag. There's no reason to access it and do more work. + + + if (segmentEnd === pathLength) { + break; + } + + if (descriptor === undefined) { + // If the descriptor is undefined, then its a normal property, so we should + // lookup the value to chain off of like normal. + if (!(segment in current) && typeof current.unknownProperty === 'function') { + current = current.unknownProperty(segment); + } else { + current = current[segment]; + } + } else { + // If the descriptor is defined, then its a normal CP (not an alias, which + // would have been handled earlier). We get the last revision to check if + // the CP is still valid, and if so we use the cached value. If not, then + // we create a lazy chain lookup, and the next time the CP is calculated, + // it will update that lazy chain. + var lastRevision = getLastRevisionFor(current, segment); + + if ((0, _validator.validate)(propertyTag, lastRevision)) { + current = peekCacheFor(current).get(segment); + } else { + var lazyChains = (0, _meta2.meta)(current).writableLazyChainsFor(segment); + var rest = path.substr(segmentEnd + 1); + var placeholderTag = lazyChains[rest]; + + if (placeholderTag === undefined) { + placeholderTag = lazyChains[rest] = (0, _validator.createUpdatableTag)(); + } + + chainTags.push(placeholderTag); + break; + } } } - return value$$1; + if (true + /* DEBUG */ + ) { + chainTags.forEach(t => _validator.ALLOW_CYCLES.set(t, true)); + } + + return chainTags; } - function setPath(root, path, value$$1, tolerant) { - var parts = path.split('.'); - var keyName = parts.pop(); - (true && !(keyName.trim().length > 0) && (0, _debug.assert)('Property set failed: You passed an empty path', keyName.trim().length > 0)); + function isElementDescriptor(args) { + var [maybeTarget, maybeKey, maybeDesc] = args; + return (// Ensure we have the right number of args + args.length === 3 && ( // Make sure the target is a class or object (prototype) + typeof maybeTarget === 'function' || typeof maybeTarget === 'object' && maybeTarget !== null) && // Make sure the key is a string + typeof maybeKey === 'string' && ( // Make sure the descriptor is the right shape + typeof maybeDesc === 'object' && maybeDesc !== null && 'enumerable' in maybeDesc && 'configurable' in maybeDesc || // TS compatibility + maybeDesc === undefined) + ); + } - var newRoot = _getPath(root, parts); + function nativeDescDecorator(propertyDesc) { + var decorator = function () { + return propertyDesc; + }; - if (newRoot !== null && newRoot !== undefined) { - return set(newRoot, keyName, value$$1); - } else if (!tolerant) { - throw new _error.default("Property set failed: object in path \"" + parts.join('.') + "\" could not be found."); - } + setClassicDecorator(decorator); + return decorator; } /** - Error-tolerant form of `set`. Will not blow up if any part of the - chain is `undefined`, `null`, or destroyed. - - This is primarily used when syncing bindings, which may try to update after - an object has been destroyed. - - ```javascript - import { trySet } from '@ember/object'; - - let obj = { name: "Zoey" }; - trySet(obj, "contacts.twitter", "@emberjs"); - ``` + Objects of this type can implement an interface to respond to requests to + get and set. The default implementation handles simple properties. - @method trySet - @static - @for @ember/object - @param {Object} root The object to modify. - @param {String} path The property path to set - @param {Object} value The value to set - @public + @class Descriptor + @private */ - function trySet(root, path, value$$1) { - return set(root, path, value$$1, true); + class ComputedDescriptor { + constructor() { + this.enumerable = true; + this.configurable = true; + this._dependentKeys = undefined; + this._meta = undefined; + } + + setup(_obj, keyName, _propertyDesc, meta$$1) { + meta$$1.writeDescriptors(keyName, this); + } + + teardown(_obj, keyName, meta$$1) { + meta$$1.removeDescriptors(keyName); + } + + } + + function DESCRIPTOR_GETTER_FUNCTION(name, descriptor) { + return function CPGETTER_FUNCTION() { + return descriptor.get(this, name); + }; + } + + function DESCRIPTOR_SETTER_FUNCTION(name, descriptor) { + var func = function CPSETTER_FUNCTION(value$$1) { + return descriptor.set(this, name, value$$1); + }; + + CP_SETTER_FUNCS.add(func); + return func; + } + + var CP_SETTER_FUNCS = new _polyfills._WeakSet(); + + function makeComputedDecorator(desc, DecoratorClass) { + var decorator = function COMPUTED_DECORATOR(target, key, propertyDesc, maybeMeta, isClassicDecorator$$1) { + (true && !(isClassicDecorator$$1 || !propertyDesc || !propertyDesc.get || propertyDesc.get.toString().indexOf('CPGETTER_FUNCTION') === -1) && (0, _debug.assert)(`Only one computed property decorator can be applied to a class field or accessor, but '${key}' was decorated twice. You may have added the decorator to both a getter and setter, which is unnecessary.`, isClassicDecorator$$1 || !propertyDesc || !propertyDesc.get || propertyDesc.get.toString().indexOf('CPGETTER_FUNCTION') === -1)); + var meta$$1 = arguments.length === 3 ? (0, _meta2.meta)(target) : maybeMeta; + desc.setup(target, key, propertyDesc, meta$$1); + var computedDesc = { + enumerable: desc.enumerable, + configurable: desc.configurable, + get: DESCRIPTOR_GETTER_FUNCTION(key, desc), + set: DESCRIPTOR_SETTER_FUNCTION(key, desc) + }; + return computedDesc; + }; + + setClassicDecorator(decorator, desc); + Object.setPrototypeOf(decorator, DecoratorClass.prototype); + return decorator; } /** @module @ember/object */ - var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; - - function noop() {} + var END_WITH_EACH_REGEX = /\.@each$/; /** - `@computed` is a decorator that turns a JavaScript getter and setter into a - computed property, which is a _cached, trackable value_. By default the getter - will only be called once and the result will be cached. You can specify - various properties that your computed property depends on. This will force the - cached result to be cleared if the dependencies are modified, and lazily recomputed the next time something asks for it. + Expands `pattern`, invoking `callback` for each expansion. - In the following example we decorate a getter - `fullName` - by calling - `computed` with the property dependencies (`firstName` and `lastName`) as - arguments. The `fullName` getter will be called once (regardless of how many + The only pattern supported is brace-expansion, anything else will be passed + once to `callback` directly. + + Example + + ```js + import { expandProperties } from '@ember/object/computed'; + + function echo(arg){ console.log(arg); } + + expandProperties('foo.bar', echo); //=> 'foo.bar' + expandProperties('{foo,bar}', echo); //=> 'foo', 'bar' + expandProperties('foo.{bar,baz}', echo); //=> 'foo.bar', 'foo.baz' + expandProperties('{foo,bar}.baz', echo); //=> 'foo.baz', 'bar.baz' + expandProperties('foo.{bar,baz}.[]', echo) //=> 'foo.bar.[]', 'foo.baz.[]' + expandProperties('{foo,bar}.{spam,eggs}', echo) //=> 'foo.spam', 'foo.eggs', 'bar.spam', 'bar.eggs' + expandProperties('{foo}.bar.{baz}') //=> 'foo.bar.baz' + ``` + + @method expandProperties + @static + @for @ember/object/computed + @public + @param {String} pattern The property pattern to expand. + @param {Function} callback The callback to invoke. It is invoked once per + expansion, and is passed the expansion. + */ + + function expandProperties(pattern, callback) { + (true && !(typeof pattern === 'string') && (0, _debug.assert)(`A computed property key must be a string, you passed ${typeof pattern} ${pattern}`, typeof pattern === 'string')); + (true && !(pattern.indexOf(' ') === -1) && (0, _debug.assert)('Brace expanded properties cannot contain spaces, e.g. "user.{firstName, lastName}" should be "user.{firstName,lastName}"', pattern.indexOf(' ') === -1)); // regex to look for double open, double close, or unclosed braces + + (true && !(pattern.match(/\{[^}{]*\{|\}[^}{]*\}|\{[^}]*$/g) === null) && (0, _debug.assert)(`Brace expanded properties have to be balanced and cannot be nested, pattern: ${pattern}`, pattern.match(/\{[^}{]*\{|\}[^}{]*\}|\{[^}]*$/g) === null)); + var start = pattern.indexOf('{'); + + if (start < 0) { + callback(pattern.replace(END_WITH_EACH_REGEX, '.[]')); + } else { + dive('', pattern, start, callback); + } + } + + function dive(prefix, pattern, start, callback) { + var end = pattern.indexOf('}'), + i = 0, + newStart, + arrayLength; + var tempArr = pattern.substring(start + 1, end).split(','); + var after = pattern.substring(end + 1); + prefix = prefix + pattern.substring(0, start); + arrayLength = tempArr.length; + + while (i < arrayLength) { + newStart = after.indexOf('{'); + + if (newStart < 0) { + callback((prefix + tempArr[i++] + after).replace(END_WITH_EACH_REGEX, '.[]')); + } else { + dive(prefix + tempArr[i++], after, newStart, callback); + } + } + } + /** + @module @ember/object + */ + + /** + NOTE: This is a low-level method used by other parts of the API. You almost + never want to call this method directly. Instead you should use + `mixin()` to define new properties. + + Defines a property on an object. This method works much like the ES5 + `Object.defineProperty()` method except that it can also accept computed + properties and other special descriptors. + + Normally this method takes only three parameters. However if you pass an + instance of `Descriptor` as the third param then you can pass an + optional value as the fourth parameter. This is often more efficient than + creating new descriptor hashes for each property. + + ## Examples + + ```javascript + import { defineProperty, computed } from '@ember/object'; + + // ES5 compatible mode + defineProperty(contact, 'firstName', { + writable: true, + configurable: false, + enumerable: true, + value: 'Charles' + }); + + // define a simple property + defineProperty(contact, 'lastName', undefined, 'Jolley'); + + // define a computed property + defineProperty(contact, 'fullName', computed('firstName', 'lastName', function() { + return this.firstName+' '+this.lastName; + })); + ``` + + @public + @method defineProperty + @static + @for @ember/object + @param {Object} obj the object to define this property on. This may be a prototype. + @param {String} keyName the name of the property + @param {Descriptor} [desc] an instance of `Descriptor` (typically a + computed property) or an ES5 descriptor. + You must provide this or `data` but not both. + @param {*} [data] something other than a descriptor, that will + become the explicit value of this property. + */ + + + function defineProperty(obj, keyName, desc, data, meta$$1) { + if (meta$$1 === undefined) { + meta$$1 = (0, _meta2.meta)(obj); + } + + var previousDesc = descriptorForProperty(obj, keyName, meta$$1); + var wasDescriptor = previousDesc !== undefined; + + if (wasDescriptor) { + previousDesc.teardown(obj, keyName, meta$$1); + } // used to track if the the property being defined be enumerable + + + var enumerable = true; // Ember.NativeArray is a normal Ember.Mixin that we mix into `Array.prototype` when prototype extensions are enabled + // mutating a native object prototype like this should _not_ result in enumerable properties being added (or we have significant + // issues with things like deep equality checks from test frameworks, or things like jQuery.extend(true, [], [])). + // + // this is a hack, and we should stop mutating the array prototype by default 😫 + + if (obj === Array.prototype) { + enumerable = false; + } + + var value$$1; + + if (isClassicDecorator(desc)) { + var propertyDesc; + + if (true + /* DEBUG */ + ) { + propertyDesc = desc(obj, keyName, undefined, meta$$1, true); + } else { + propertyDesc = desc(obj, keyName, undefined, meta$$1); + } + + Object.defineProperty(obj, keyName, propertyDesc); // pass the decorator function forward for backwards compat + + value$$1 = desc; + } else if (desc === undefined || desc === null) { + value$$1 = data; + + if (wasDescriptor || enumerable === false) { + Object.defineProperty(obj, keyName, { + configurable: true, + enumerable, + writable: true, + value: value$$1 + }); + } else { + if (true + /* DEBUG */ + ) { + (0, _utils.setWithMandatorySetter)(obj, keyName, data); + } else { + obj[keyName] = data; + } + } + } else { + value$$1 = desc; // fallback to ES5 + + Object.defineProperty(obj, keyName, desc); + } // if key is being watched, override chains that + // were initialized with the prototype + + + if (!meta$$1.isPrototypeMeta(obj)) { + revalidateObservers(obj); + } // The `value` passed to the `didDefineProperty` hook is + // either the descriptor or data, whichever was passed. + + + if (typeof obj.didDefineProperty === 'function') { + obj.didDefineProperty(obj, keyName, value$$1); + } + } + + var firstDotIndexCache = new _utils.Cache(1000, key => key.indexOf('.')); + + function isPath(path) { + return typeof path === 'string' && firstDotIndexCache.get(path) !== -1; + } + /** + @module @ember/object + */ + + + var PROXY_CONTENT = (0, _utils.symbol)('PROXY_CONTENT'); + _exports.PROXY_CONTENT = PROXY_CONTENT; + var getPossibleMandatoryProxyValue; + + if (true + /* DEBUG */ + && _utils.HAS_NATIVE_PROXY) { + getPossibleMandatoryProxyValue = function getPossibleMandatoryProxyValue(obj, keyName) { + var content = obj[PROXY_CONTENT]; + + if (content === undefined) { + return obj[keyName]; + } else { + /* global Reflect */ + return Reflect.get(content, keyName, obj); + } + }; + } // .......................................................... + // GET AND SET + // + // If we are on a platform that supports accessors we can use those. + // Otherwise simulate accessors by looking up the property directly on the + // object. + + /** + Gets the value of a property on an object. If the property is computed, + the function will be invoked. If the property is not defined but the + object implements the `unknownProperty` method then that will be invoked. + + ```javascript + import { get } from '@ember/object'; + get(obj, "name"); + ``` + + If you plan to run on IE8 and older browsers then you should use this + method anytime you want to retrieve a property on an object that you don't + know for sure is private. (Properties beginning with an underscore '_' + are considered private.) + + On all newer browsers, you only need to use this method to retrieve + properties if the property might not be defined on the object and you want + to respect the `unknownProperty` handler. Otherwise you can ignore this + method. + + Note that if the object itself is `undefined`, this method will throw + an error. + + @method get + @for @ember/object + @static + @param {Object} obj The object to retrieve from. + @param {String} keyName The property key to retrieve + @return {Object} the property value or `null`. + @public + */ + + + function get(obj, keyName) { + (true && !(arguments.length === 2) && (0, _debug.assert)(`Get must be called with two arguments; an object and a property key`, arguments.length === 2)); + (true && !(obj !== undefined && obj !== null) && (0, _debug.assert)(`Cannot call get with '${keyName}' on an undefined object.`, obj !== undefined && obj !== null)); + (true && !(typeof keyName === 'string' || typeof keyName === 'number' && !isNaN(keyName)) && (0, _debug.assert)(`The key provided to get must be a string or number, you passed ${keyName}`, typeof keyName === 'string' || typeof keyName === 'number' && !isNaN(keyName))); + (true && !(typeof keyName !== 'string' || keyName.lastIndexOf('this.', 0) !== 0) && (0, _debug.assert)(`'this' in paths is not supported`, typeof keyName !== 'string' || keyName.lastIndexOf('this.', 0) !== 0)); + var type = typeof obj; + var isObject$$1 = type === 'object'; + var isFunction = type === 'function'; + var isObjectLike = isObject$$1 || isFunction; + + if (isPath(keyName)) { + return isObjectLike ? _getPath(obj, keyName) : undefined; + } + + var value$$1; + + if (isObjectLike) { + if (true + /* DEBUG */ + && _utils.HAS_NATIVE_PROXY) { + value$$1 = getPossibleMandatoryProxyValue(obj, keyName); + } else { + value$$1 = obj[keyName]; + } + } else { + value$$1 = obj[keyName]; + } + + if (value$$1 === undefined) { + if (isObject$$1 && !(keyName in obj) && typeof obj.unknownProperty === 'function') { + if (true + /* DEBUG */ + ) { + (0, _validator.deprecateMutationsInAutotrackingTransaction)(() => { + value$$1 = obj.unknownProperty(keyName); + }); + } else { + value$$1 = obj.unknownProperty(keyName); + } + } + } + + if (isObjectLike && (0, _validator.isTracking)()) { + (0, _validator.consume)(tagForProperty(obj, keyName)); // Add the tag of the returned value if it is an array, since arrays + // should always cause updates if they are consumed and then changed + + if (Array.isArray(value$$1) || (0, _utils.isEmberArray)(value$$1)) { + (0, _validator.consume)(tagForProperty(value$$1, '[]')); + } // Add the value of the content if the value is a proxy. This is because + // content changes the truthiness/falsiness of the proxy. + + + if ((0, _utils.isProxy)(value$$1)) { + (0, _validator.consume)(tagForProperty(value$$1, 'content')); + } + } + + return value$$1; + } + + function _getPath(root, path) { + var obj = root; + var parts = typeof path === 'string' ? path.split('.') : path; + + for (var i = 0; i < parts.length; i++) { + if (obj === undefined || obj === null || obj.isDestroyed) { + return undefined; + } + + obj = get(obj, parts[i]); + } + + return obj; + } + /** + Retrieves the value of a property from an Object, or a default value in the + case that the property returns `undefined`. + + ```javascript + import { getWithDefault } from '@ember/object'; + getWithDefault(person, 'lastName', 'Doe'); + ``` + + @method getWithDefault + @for @ember/object + @static + @param {Object} obj The object to retrieve from. + @param {String} keyName The name of the property to retrieve + @param {Object} defaultValue The value to return if the property value is undefined + @return {Object} The property value or the defaultValue. + @public + */ + + + function getWithDefault(root, key, defaultValue) { + var value$$1 = get(root, key); + + if (value$$1 === undefined) { + return defaultValue; + } + + return value$$1; + } + /** + @module @ember/object + */ + + /** + Sets the value of a property on an object, respecting computed properties + and notifying observers and other listeners of the change. + If the specified property is not defined on the object and the object + implements the `setUnknownProperty` method, then instead of setting the + value of the property on the object, its `setUnknownProperty` handler + will be invoked with the two parameters `keyName` and `value`. + + ```javascript + import { set } from '@ember/object'; + set(obj, "name", value); + ``` + + @method set + @static + @for @ember/object + @param {Object} obj The object to modify. + @param {String} keyName The property key to set + @param {Object} value The value to set + @return {Object} the passed value. + @public + */ + + + function set(obj, keyName, value$$1, tolerant) { + (true && !(arguments.length === 3 || arguments.length === 4) && (0, _debug.assert)(`Set must be called with three or four arguments; an object, a property key, a value and tolerant true/false`, arguments.length === 3 || arguments.length === 4)); + (true && !(obj && typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)(`Cannot call set with '${keyName}' on an undefined object.`, obj && typeof obj === 'object' || typeof obj === 'function')); + (true && !(typeof keyName === 'string' || typeof keyName === 'number' && !isNaN(keyName)) && (0, _debug.assert)(`The key provided to set must be a string or number, you passed ${keyName}`, typeof keyName === 'string' || typeof keyName === 'number' && !isNaN(keyName))); + (true && !(typeof keyName !== 'string' || keyName.lastIndexOf('this.', 0) !== 0) && (0, _debug.assert)(`'this' in paths is not supported`, typeof keyName !== 'string' || keyName.lastIndexOf('this.', 0) !== 0)); + + if (obj.isDestroyed) { + (true && !(tolerant) && (0, _debug.assert)(`calling set on destroyed object: ${(0, _utils.toString)(obj)}.${keyName} = ${(0, _utils.toString)(value$$1)}`, tolerant)); + return; + } + + if (isPath(keyName)) { + return setPath(obj, keyName, value$$1, tolerant); + } + + var descriptor = (0, _utils.lookupDescriptor)(obj, keyName); + var setter = descriptor === null ? undefined : descriptor.set; + + if (setter !== undefined && CP_SETTER_FUNCS.has(setter)) { + obj[keyName] = value$$1; + return value$$1; + } + + var currentValue; + + if (true + /* DEBUG */ + && _utils.HAS_NATIVE_PROXY) { + currentValue = getPossibleMandatoryProxyValue(obj, keyName); + } else { + currentValue = obj[keyName]; + } + + if (currentValue === undefined && 'object' === typeof obj && !(keyName in obj) && typeof obj.setUnknownProperty === 'function') { + /* unknown property */ + obj.setUnknownProperty(keyName, value$$1); + } else { + if (true + /* DEBUG */ + ) { + (0, _utils.setWithMandatorySetter)(obj, keyName, value$$1); + } else { + obj[keyName] = value$$1; + } + + if (currentValue !== value$$1) { + notifyPropertyChange(obj, keyName); + } + } + + return value$$1; + } + + function setPath(root, path, value$$1, tolerant) { + var parts = path.split('.'); + var keyName = parts.pop(); + (true && !(keyName.trim().length > 0) && (0, _debug.assert)('Property set failed: You passed an empty path', keyName.trim().length > 0)); + + var newRoot = _getPath(root, parts); + + if (newRoot !== null && newRoot !== undefined) { + return set(newRoot, keyName, value$$1); + } else if (!tolerant) { + throw new _error.default(`Property set failed: object in path "${parts.join('.')}" could not be found.`); + } + } + /** + Error-tolerant form of `set`. Will not blow up if any part of the + chain is `undefined`, `null`, or destroyed. + + This is primarily used when syncing bindings, which may try to update after + an object has been destroyed. + + ```javascript + import { trySet } from '@ember/object'; + + let obj = { name: "Zoey" }; + trySet(obj, "contacts.twitter", "@emberjs"); + ``` + + @method trySet + @static + @for @ember/object + @param {Object} root The object to modify. + @param {String} path The property path to set + @param {Object} value The value to set + @public + */ + + + function trySet(root, path, value$$1) { + return set(root, path, value$$1, true); + } + /** + @module @ember/object + */ + + + var DEEP_EACH_REGEX = /\.@each\.[^.]+\./; + + function noop() {} + /** + `@computed` is a decorator that turns a JavaScript getter and setter into a + computed property, which is a _cached, trackable value_. By default the getter + will only be called once and the result will be cached. You can specify + various properties that your computed property depends on. This will force the + cached result to be cleared if the dependencies are modified, and lazily recomputed the next time something asks for it. + + In the following example we decorate a getter - `fullName` - by calling + `computed` with the property dependencies (`firstName` and `lastName`) as + arguments. The `fullName` getter will be called once (regardless of how many times it is accessed) as long as its dependencies do not change. Once `firstName` or `lastName` are updated any future calls to `fullName` will incorporate the new values, and any watchers of the value such as templates @@ -17385,7 +16185,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ var config = args.pop(); if (typeof config === 'function') { - (true && !(!isClassicDecorator(config)) && (0, _debug.assert)("You attempted to pass a computed property instance to computed(). Computed property instances are decorator functions, and cannot be passed to computed() because they cannot be turned into decorators twice", !isClassicDecorator(config))); + (true && !(!isClassicDecorator(config)) && (0, _debug.assert)(`You attempted to pass a computed property instance to computed(). Computed property instances are decorator functions, and cannot be passed to computed() because they cannot be turned into decorators twice`, !isClassicDecorator(config))); this._getter = config; } else { var objectConfig = config; @@ -17404,12 +16204,12 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ setup(obj, keyName, propertyDesc, meta$$1) { super.setup(obj, keyName, propertyDesc, meta$$1); - (true && !(!(propertyDesc && typeof propertyDesc.value === 'function')) && (0, _debug.assert)("@computed can only be used on accessors or fields, attempted to use it with " + keyName + " but that was a method. Try converting it to a getter (e.g. `get " + keyName + "() {}`)", !(propertyDesc && typeof propertyDesc.value === 'function'))); - (true && !(!propertyDesc || !propertyDesc.initializer) && (0, _debug.assert)("@computed can only be used on empty fields. " + keyName + " has an initial value (e.g. `" + keyName + " = someValue`)", !propertyDesc || !propertyDesc.initializer)); - (true && !(!(this._hasConfig && propertyDesc && (typeof propertyDesc.get === 'function' || typeof propertyDesc.set === 'function'))) && (0, _debug.assert)("Attempted to apply a computed property that already has a getter/setter to a " + keyName + ", but it is a method or an accessor. If you passed @computed a function or getter/setter (e.g. `@computed({ get() { ... } })`), then it must be applied to a field", !(this._hasConfig && propertyDesc && (typeof propertyDesc.get === 'function' || typeof propertyDesc.set === 'function')))); + (true && !(!(propertyDesc && typeof propertyDesc.value === 'function')) && (0, _debug.assert)(`@computed can only be used on accessors or fields, attempted to use it with ${keyName} but that was a method. Try converting it to a getter (e.g. \`get ${keyName}() {}\`)`, !(propertyDesc && typeof propertyDesc.value === 'function'))); + (true && !(!propertyDesc || !propertyDesc.initializer) && (0, _debug.assert)(`@computed can only be used on empty fields. ${keyName} has an initial value (e.g. \`${keyName} = someValue\`)`, !propertyDesc || !propertyDesc.initializer)); + (true && !(!(this._hasConfig && propertyDesc && (typeof propertyDesc.get === 'function' || typeof propertyDesc.set === 'function'))) && (0, _debug.assert)(`Attempted to apply a computed property that already has a getter/setter to a ${keyName}, but it is a method or an accessor. If you passed @computed a function or getter/setter (e.g. \`@computed({ get() { ... } })\`), then it must be applied to a field`, !(this._hasConfig && propertyDesc && (typeof propertyDesc.get === 'function' || typeof propertyDesc.set === 'function')))); if (this._hasConfig === false) { - (true && !(propertyDesc && (typeof propertyDesc.get === 'function' || typeof propertyDesc.set === 'function')) && (0, _debug.assert)("Attempted to use @computed on " + keyName + ", but it did not have a getter or a setter. You must either pass a get a function or getter/setter to @computed directly (e.g. `@computed({ get() { ... } })`) or apply @computed directly to a getter/setter", propertyDesc && (typeof propertyDesc.get === 'function' || typeof propertyDesc.set === 'function'))); + (true && !(propertyDesc && (typeof propertyDesc.get === 'function' || typeof propertyDesc.set === 'function')) && (0, _debug.assert)(`Attempted to use @computed on ${keyName}, but it did not have a getter or a setter. You must either pass a get a function or getter/setter to @computed directly (e.g. \`@computed({ get() { ... } })\`) or apply @computed directly to a getter/setter`, propertyDesc && (typeof propertyDesc.get === 'function' || typeof propertyDesc.set === 'function'))); var { get: _get, set: set$$1 @@ -17573,7 +16373,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ var args = []; function addArg(property) { - (true && (0, _debug.warn)("Dependent keys containing @each only work one level deep. " + ("You used the key \"" + property + "\" which is invalid. ") + "Please create an intermediary computed property.", DEEP_EACH_REGEX.test(property) === false, { + (true && (0, _debug.warn)(`Dependent keys containing @each only work one level deep. ` + `You used the key "${property}" which is invalid. ` + `Please create an intermediary computed property.`, DEEP_EACH_REGEX.test(property) === false, { id: 'ember-metal.computed-deep-each' })); args.push(property); @@ -17634,44 +16434,44 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ var propertyTag = tagForProperty(obj, keyName); var ret; - if (cache.has(keyName) && (0, _reference.validate)(propertyTag, getLastRevisionFor(obj, keyName))) { + if (cache.has(keyName) && (0, _validator.validate)(propertyTag, getLastRevisionFor(obj, keyName))) { ret = cache.get(keyName); } else { // For backwards compatibility, we only throw if the CP has any dependencies. CPs without dependencies // should be allowed, even after the object has been destroyed, which is why we check _dependentKeys. - (true && !(this._dependentKeys === undefined || !(0, _meta2.meta)(obj).isMetaDestroyed()) && (0, _debug.assert)("Attempted to access the computed " + obj + "." + keyName + " on a destroyed object, which is not allowed", this._dependentKeys === undefined || !(0, _meta2.meta)(obj).isMetaDestroyed())); + (true && !(this._dependentKeys === undefined || !(0, _meta2.meta)(obj).isMetaDestroyed()) && (0, _debug.assert)(`Attempted to access the computed ${obj}.${keyName} on a destroyed object, which is not allowed`, this._dependentKeys === undefined || !(0, _meta2.meta)(obj).isMetaDestroyed())); var upstreamTag = undefined; if (this._auto === true) { - upstreamTag = track(() => { + upstreamTag = (0, _validator.track)(() => { ret = this._getter.call(obj, keyName); }); } else { // Create a tracker that absorbs any trackable actions inside the CP - untrack(() => { + (0, _validator.untrack)(() => { ret = this._getter.call(obj, keyName); }); } if (this._dependentKeys !== undefined) { - var tag = (0, _reference.combine)(getChainTagsForKeys(obj, this._dependentKeys)); - upstreamTag = upstreamTag === undefined ? tag : (0, _reference.combine)([upstreamTag, tag]); + var tag = (0, _validator.combine)(getChainTagsForKeys(obj, this._dependentKeys)); + upstreamTag = upstreamTag === undefined ? tag : (0, _validator.combine)([upstreamTag, tag]); } if (upstreamTag !== undefined) { - (0, _reference.update)(propertyTag, upstreamTag); + (0, _validator.update)(propertyTag, upstreamTag); } - setLastRevisionFor(obj, keyName, (0, _reference.value)(propertyTag)); + setLastRevisionFor(obj, keyName, (0, _validator.value)(propertyTag)); cache.set(keyName, ret); finishLazyChains(obj, keyName, ret); } - consume(propertyTag); // Add the tag of the returned value if it is an array, since arrays + (0, _validator.consume)(propertyTag); // Add the tag of the returned value if it is an array, since arrays // should always cause updates if they are consumed and then changed if (Array.isArray(ret) || (0, _utils.isEmberArray)(ret)) { - consume(tagForProperty(ret, '[]')); + (0, _validator.consume)(tagForProperty(ret, '[]')); } return ret; @@ -17699,10 +16499,10 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ var propertyTag = tagForProperty(obj, keyName); if (this._dependentKeys !== undefined) { - (0, _reference.update)(propertyTag, (0, _reference.combine)(getChainTagsForKeys(obj, this._dependentKeys))); + (0, _validator.update)(propertyTag, (0, _validator.combine)(getChainTagsForKeys(obj, this._dependentKeys))); } - setLastRevisionFor(obj, keyName, (0, _reference.value)(propertyTag)); + setLastRevisionFor(obj, keyName, (0, _validator.value)(propertyTag)); } finally { endPropertyChanges(); } @@ -17711,11 +16511,11 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ } _throwReadOnlyError(obj, keyName) { - throw new _error.default("Cannot set read-only property \"" + keyName + "\" on object: " + (0, _utils.inspect)(obj)); + throw new _error.default(`Cannot set read-only property "${keyName}" on object: ${(0, _utils.inspect)(obj)}`); } clobberSet(obj, keyName, value$$1) { - (true && !(false) && (0, _debug.deprecate)("The " + (0, _utils.toString)(obj) + "#" + keyName + " computed property was just overriden. This removes the computed property and replaces it with a plain value, and has been deprecated. If you want this behavior, consider defining a setter which does it manually.", false, { + (true && !(false) && (0, _debug.deprecate)(`The ${(0, _utils.toString)(obj)}#${keyName} computed property was just overridden. This removes the computed property and replaces it with a plain value, and has been deprecated. If you want this behavior, consider defining a setter which does it manually.`, false, { id: 'computed-property.override', until: '4.0.0', url: 'https://emberjs.com/deprecations/v3.x#toc_computed-property-override' @@ -17829,7 +16629,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ } function computed(...args) { - (true && !(!(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true)) && (0, _debug.assert)("@computed can only be used directly as a native decorator. If you're using tracked in classic classes, add parenthesis to call it like a function: computed()", !(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true))); + (true && !(!(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true)) && (0, _debug.assert)(`@computed can only be used directly as a native decorator. If you're using tracked in classic classes, add parenthesis to call it like a function: computed()`, !(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true))); if (isElementDescriptor(args)) { var decorator = makeComputedDecorator(new ComputedProperty([]), ComputedDecoratorImpl); @@ -17897,7 +16697,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ } setup(obj, keyName, propertyDesc, meta$$1) { - (true && !(this.altKey !== keyName) && (0, _debug.assert)("Setting alias '" + keyName + "' on self", this.altKey !== keyName)); + (true && !(this.altKey !== keyName) && (0, _debug.assert)(`Setting alias '${keyName}' on self`, this.altKey !== keyName)); super.setup(obj, keyName, propertyDesc, meta$$1); } @@ -17910,18 +16710,18 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ var propertyTag = tagForProperty(obj, keyName); // We don't use the tag since CPs are not automatic, we just want to avoid // anything tracking while we get the altKey - untrack(() => { + (0, _validator.untrack)(() => { ret = get(obj, this.altKey); }); var lastRevision = getLastRevisionFor(obj, keyName); - if (!(0, _reference.validate)(propertyTag, lastRevision)) { - (0, _reference.update)(propertyTag, (0, _reference.combine)(getChainTagsForKey(obj, this.altKey))); - setLastRevisionFor(obj, keyName, (0, _reference.value)(propertyTag)); + if (!(0, _validator.validate)(propertyTag, lastRevision)) { + (0, _validator.update)(propertyTag, (0, _validator.combine)(getChainTagsForKey(obj, this.altKey))); + setLastRevisionFor(obj, keyName, (0, _validator.value)(propertyTag)); finishLazyChains(obj, keyName, ret); } - consume(propertyTag); + (0, _validator.consume)(propertyTag); return ret; } @@ -17941,7 +16741,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ function AliasedProperty_readOnlySet(obj, keyName) { // eslint-disable-line no-unused-vars - throw new _error.default("Cannot set read-only property '" + keyName + "' on object: " + (0, _utils.inspect)(obj)); + throw new _error.default(`Cannot set read-only property '${keyName}' on object: ${(0, _utils.inspect)(obj)}`); } function AliasedProperty_oneWaySet(obj, keyName, value$$1) { @@ -17967,7 +16767,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ function deprecateProperty(object, deprecatedKey, newKey, options) { function _deprecate() { - (true && !(false) && (0, _debug.deprecate)("Usage of `" + deprecatedKey + "` is deprecated, use `" + newKey + "` instead.", false, options)); + (true && !(false) && (0, _debug.deprecate)(`Usage of \`${deprecatedKey}\` is deprecated, use \`${newKey}\` instead.`, false, options)); } Object.defineProperty(object, deprecatedKey, { @@ -18232,7 +17032,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ version }); } else { - (true && (0, _debug.warn)("Library \"" + name + "\" is already registered with Ember.", false, { + (true && (0, _debug.warn)(`Library "${name}" is already registered with Ember.`, false, { id: 'ember-metal.libraries-register' })); } @@ -18374,6 +17174,38 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ } }); return properties; + } + /** + Enqueues finalization on an object so that it can be garbage collected. + Multiple calls will have no effect. + + @method destroy + @for Ember + @param {Object} obj the object to destroy + @return {boolean} true if the object went from not destroying to destroying. + @private + */ + + + function destroy(obj) { + (true && !(obj !== null) && (0, _debug.assert)('Cannot call `destroy` on null', obj !== null)); + (true && !(obj !== undefined) && (0, _debug.assert)('Cannot call `destroy` on undefined', obj !== undefined)); + (true && !(typeof obj === 'object' || typeof obj === 'function') && (0, _debug.assert)(`Cannot call \`destroy\` on ${typeof obj}`, typeof obj === 'object' || typeof obj === 'function')); + var m = (0, _meta3.peekMeta)(obj); + + if (m === null || m.isSourceDestroying()) { + return false; + } + + m.setSourceDestroying(); + destroyObservers(obj); + (0, _runloop.schedule)('destroy', m, finalize); + return true; + } + + function finalize() { + this.setSourceDestroyed(); + this.destroy(); } // move into its own package // it is needed by Mixin for classToString // maybe move it into environment @@ -18567,7 +17399,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ str = (0, _utils.getName)(target); if (str !== void 0) { - str = "(subclass of " + str + ")"; + str = `(subclass of ${str})`; break; } } while (str === void 0); @@ -18741,7 +17573,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ function applyMergedProperties(obj, key, value$$1, values) { var baseValue = values[key] || obj[key]; - (true && !(!isArray(value$$1)) && (0, _debug.assert)("You passed in `" + JSON.stringify(value$$1) + "` as the value for `" + key + "` but `" + key + "` cannot be an Array", !isArray(value$$1))); + (true && !(!isArray(value$$1)) && (0, _debug.assert)(`You passed in \`${JSON.stringify(value$$1)}\` as the value for \`${key}\` but \`${key}\` cannot be an Array`, !isArray(value$$1))); if (!baseValue) { return value$$1; @@ -18802,7 +17634,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ for (var i = 0; i < mixins.length; i++) { currentMixin = mixins[i]; - (true && !(typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]') && (0, _debug.assert)("Expected hash or Mixin instance, got " + Object.prototype.toString.call(currentMixin), typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]')); + (true && !(typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]') && (0, _debug.assert)(`Expected hash or Mixin instance, got ${Object.prototype.toString.call(currentMixin)}`, typeof currentMixin === 'object' && currentMixin !== null && Object.prototype.toString.call(currentMixin) !== '[object Array]')); props = mixinProperties(meta$$1, currentMixin); if (props === CONTINUE) { @@ -19188,7 +18020,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ for (var i = 0; i < length; i++) { var x = mixins[i]; - (true && !(typeof x === 'object' && x !== null && Object.prototype.toString.call(x) !== '[object Array]') && (0, _debug.assert)("Expected hash or Mixin instance, got " + Object.prototype.toString.call(x), typeof x === 'object' && x !== null && Object.prototype.toString.call(x) !== '[object Array]')); + (true && !(typeof x === 'object' && x !== null && Object.prototype.toString.call(x) !== '[object Array]') && (0, _debug.assert)(`Expected hash or Mixin instance, got ${Object.prototype.toString.call(x)}`, typeof x === 'object' && x !== null && Object.prototype.toString.call(x) !== '[object Array]')); if (x instanceof Mixin) { m[i] = x; @@ -19296,7 +18128,7 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ if (_deprecatedFeatures.ALIAS_METHOD) { _exports.aliasMethod = aliasMethod = function aliasMethod(methodName) { - (true && !(false) && (0, _debug.deprecate)("You attempted to alias '" + methodName + ", but aliasMethod has been deprecated. Consider extracting the method into a shared utility function.", false, { + (true && !(false) && (0, _debug.deprecate)(`You attempted to alias '${methodName}, but aliasMethod has been deprecated. Consider extracting the method into a shared utility function.`, false, { id: 'object.alias-method', until: '4.0.0', url: 'https://emberjs.com/deprecations/v3.x#toc_object-alias-method' @@ -19357,8 +18189,8 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ var getInjection = function (propertyName) { var owner = (0, _owner.getOwner)(this) || this.container || this.__owner__; // fallback to `container` for backwards compat - (true && !(Boolean(owner)) && (0, _debug.assert)("Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.", Boolean(owner))); - return owner.lookup(type + ":" + (name || propertyName), { + (true && !(Boolean(owner)) && (0, _debug.assert)(`Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.`, Boolean(owner))); + return owner.lookup(`${type}:${name || propertyName}`, { source, namespace }); @@ -19390,6 +18222,76 @@ define("@ember/-internals/metal/index", ["exports", "@ember/-internals/meta", "@ return decorator; } } + + function tracked(...args) { + (true && !(!(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true)) && (0, _debug.assert)(`@tracked can only be used directly as a native decorator. If you're using tracked in classic classes, add parenthesis to call it like a function: tracked()`, !(isElementDescriptor(args.slice(0, 3)) && args.length === 5 && args[4] === true))); + + if (!isElementDescriptor(args)) { + var propertyDesc = args[0]; + (true && !(args.length === 0 || typeof propertyDesc === 'object' && propertyDesc !== null) && (0, _debug.assert)(`tracked() may only receive an options object containing 'value' or 'initializer', received ${propertyDesc}`, args.length === 0 || typeof propertyDesc === 'object' && propertyDesc !== null)); + + if (true + /* DEBUG */ + && propertyDesc) { + var keys = Object.keys(propertyDesc); + (true && !(keys.length <= 1 && (keys[0] === undefined || keys[0] === 'value' || keys[0] === 'initializer')) && (0, _debug.assert)(`The options object passed to tracked() may only contain a 'value' or 'initializer' property, not both. Received: [${keys}]`, keys.length <= 1 && (keys[0] === undefined || keys[0] === 'value' || keys[0] === 'initializer'))); + (true && !(!('initializer' in propertyDesc) || typeof propertyDesc.initializer === 'function') && (0, _debug.assert)(`The initializer passed to tracked must be a function. Received ${propertyDesc.initializer}`, !('initializer' in propertyDesc) || typeof propertyDesc.initializer === 'function')); + } + + var initializer = propertyDesc ? propertyDesc.initializer : undefined; + var value$$1 = propertyDesc ? propertyDesc.value : undefined; + + var decorator = function (target, key, _desc, _meta, isClassicDecorator$$1) { + (true && !(isClassicDecorator$$1) && (0, _debug.assert)(`You attempted to set a default value for ${key} with the @tracked({ value: 'default' }) syntax. You can only use this syntax with classic classes. For native classes, you can use class initializers: @tracked field = 'default';`, isClassicDecorator$$1)); + var fieldDesc = { + initializer: initializer || (() => value$$1) + }; + return descriptorForField([target, key, fieldDesc]); + }; + + setClassicDecorator(decorator); + return decorator; + } + + return descriptorForField(args); + } + + if (true + /* DEBUG */ + ) { + // Normally this isn't a classic decorator, but we want to throw a helpful + // error in development so we need it to treat it like one + setClassicDecorator(tracked); + } + + function descriptorForField([_target, key, desc]) { + (true && !(!desc || !desc.value && !desc.get && !desc.set) && (0, _debug.assert)(`You attempted to use @tracked on ${key}, but that element is not a class field. @tracked is only usable on class fields. Native getters and setters will autotrack add any tracked fields they encounter, so there is no need mark getters and setters with @tracked.`, !desc || !desc.value && !desc.get && !desc.set)); + var { + getter, + setter + } = (0, _validator.trackedData)(key, desc ? desc.initializer : undefined); + return { + enumerable: true, + configurable: true, + + get() { + var value$$1 = getter(this); // Add the tag of the returned value if it is an array, since arrays + // should always cause updates if they are consumed and then changed + + if (Array.isArray(value$$1) || (0, _utils.isEmberArray)(value$$1)) { + (0, _validator.consume)(tagForProperty(value$$1, '[]')); + } + + return value$$1; + }, + + set(newValue) { + setter(this, newValue); + (0, _validator.dirtyTagFor)(this, SELF_TAG); + } + + }; + } }); define("@ember/-internals/owner/index", ["exports", "@ember/-internals/utils"], function (_exports, _utils) { "use strict"; @@ -19858,7 +18760,7 @@ define("@ember/-internals/routing/lib/location/api", ["exports", "@ember/debug"] var implementation = options && options.implementation; (true && !(Boolean(implementation)) && (0, _debug.assert)("Location.create: you must specify a 'implementation' option", Boolean(implementation))); var implementationClass = this.implementations[implementation]; - (true && !(Boolean(implementationClass)) && (0, _debug.assert)("Location.create: " + implementation + " is not a valid implementation", Boolean(implementationClass))); + (true && !(Boolean(implementationClass)) && (0, _debug.assert)(`Location.create: ${implementation} is not a valid implementation`, Boolean(implementationClass))); return implementationClass.create(...arguments); }, @@ -19953,8 +18855,8 @@ define("@ember/-internals/routing/lib/location/auto_location", ["exports", "@emb implementation = 'none'; } - var concrete = (0, _owner.getOwner)(this).lookup("location:" + implementation); - (true && !(concrete !== undefined) && (0, _debug.assert)("Could not find location '" + implementation + "'.", concrete !== undefined)); + var concrete = (0, _owner.getOwner)(this).lookup(`location:${implementation}`); + (true && !(concrete !== undefined) && (0, _debug.assert)(`Could not find location '${implementation}'.`, concrete !== undefined)); (0, _metal.set)(concrete, 'rootURL', rootURL); (0, _metal.set)(this, 'concreteImplementation', concrete); } @@ -20111,7 +19013,7 @@ define("@ember/-internals/routing/lib/location/auto_location", ["exports", "@emb var query = (0, _util.getQuery)(location); var rootURLIndex = path.indexOf(rootURL); var routeHash, hashParts; - (true && !(rootURLIndex === 0) && (0, _debug.assert)("Path " + path + " does not start with the provided rootURL " + rootURL, rootURLIndex === 0)); // By convention, Ember.js routes using HashLocation are required to start + (true && !(rootURLIndex === 0) && (0, _debug.assert)(`Path ${path} does not start with the provided rootURL ${rootURL}`, rootURLIndex === 0)); // By convention, Ember.js routes using HashLocation are required to start // with `#/`. Anything else should NOT be considered a route and should // be passed straight through, without transformation. @@ -20130,7 +19032,7 @@ define("@ember/-internals/routing/lib/location/auto_location", ["exports", "@emb path += routeHash + query; if (hashParts.length) { - path += "#" + hashParts.join('#'); + path += `#${hashParts.join('#')}`; } } else { path += query + hash; @@ -20155,10 +19057,10 @@ define("@ember/-internals/routing/lib/location/auto_location", ["exports", "@emb if (routePath !== '') { if (routePath[0] !== '/') { - routePath = "/" + routePath; + routePath = `/${routePath}`; } - path += "#" + routePath; + path += `#${routePath}`; } return path; @@ -20246,7 +19148,7 @@ define("@ember/-internals/routing/lib/location/hash_location", ["exports", "@emb // the location.hash has a value if (originalPath) { - outPath += "#" + originalPath; + outPath += `#${originalPath}`; } } @@ -20276,7 +19178,7 @@ define("@ember/-internals/routing/lib/location/hash_location", ["exports", "@emb replaceURL(path) { - this.location.replace("#" + path); + this.location.replace(`#${path}`); (0, _metal.set)(this, 'lastSetURL', path); } /** @@ -20316,7 +19218,7 @@ define("@ember/-internals/routing/lib/location/hash_location", ["exports", "@emb formatURL(url) { - return "#" + url; + return `#${url}`; } /** Cleans up the HashLocation event listener. @@ -20472,7 +19374,7 @@ define("@ember/-internals/routing/lib/location/history_location", ["exports", "@ rootURL = rootURL.replace(/\/$/, ''); baseURL = baseURL.replace(/\/$/, ''); // remove baseURL and rootURL from start of path - var url = path.replace(new RegExp("^" + baseURL + "(?=/|$)"), '').replace(new RegExp("^" + rootURL + "(?=/|$)"), '').replace(/\/\//g, '/'); // remove extra slashes + var url = path.replace(new RegExp(`^${baseURL}(?=/|$)`), '').replace(new RegExp(`^${rootURL}(?=/|$)`), '').replace(/\/\//g, '/'); // remove extra slashes var search = location.search || ''; url += search + this.getHash(); @@ -20678,7 +19580,7 @@ define("@ember/-internals/routing/lib/location/none_location", ["exports", "@emb rootURL = rootURL.replace(/\/$/, ''); // remove rootURL from url - return path.replace(new RegExp("^" + rootURL + "(?=/|$)"), ''); + return path.replace(new RegExp(`^${rootURL}(?=/|$)`), ''); } /** Set the path and remembers what was set. Using this method @@ -20781,7 +19683,7 @@ define("@ember/-internals/routing/lib/location/util", ["exports"], function (_ex var pathname = location.pathname; // Various versions of IE/Opera don't always return a leading slash if (pathname[0] !== '/') { - pathname = "/" + pathname; + pathname = `/${pathname}`; } return pathname; @@ -20819,10 +19721,10 @@ define("@ember/-internals/routing/lib/location/util", ["exports"], function (_ex var origin = location.origin; // Older browsers, especially IE, don't have origin if (!origin) { - origin = location.protocol + "//" + location.hostname; + origin = `${location.protocol}//${location.hostname}`; if (location.port) { - origin += ":" + location.port; + origin += `:${location.port}`; } } @@ -20972,8 +19874,9 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int This behavior is different from calling `transitionTo` on a route or `transitionToRoute` on a controller. See the [Router Service RFC](https://github.com/emberjs/rfcs/blob/master/text/0095-router-service.md#query-parameter-semantics) for more info. In the following example we use the Router service to navigate to a route with a - specific model from a Component. - ```javascript + specific model from a Component in the first action, and in the second we trigger + a query-params only transition. + ```app/components/example.js import Component from '@glimmer/component'; import { action } from '@ember/object'; import { inject as service } from '@ember/service'; @@ -20982,15 +19885,22 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int @action goToComments(post) { this.router.transitionTo('comments', post); + } + @action + fetchMoreComments(latestComment) { + this.router.transitionTo({ + queryParams: { commentsAfter: latestComment } + }); } } ``` @method transitionTo - @param {String} routeNameOrUrl the name of the route or a URL - @param {...Object} models the model(s) or identifier(s) to be used while + @param {String} [routeNameOrUrl] the name of the route or a URL + @param {...Object} [models] the model(s) or identifier(s) to be used while transitioning to the route. @param {Object} [options] optional hash with a queryParams property - containing a mapping of query parameters + containing a mapping of query parameters. May be supplied as the only + parameter to trigger a query-parameter-only transition. @return {Transition} the transition object associated with this attempted transition @public @@ -20999,6 +19909,8 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int transitionTo(...args) { if ((0, _utils.resemblesURL)(args[0])) { + // NOTE: this `args[0] as string` cast is safe and TS correctly infers it + // in 3.6+, so it can be removed when TS is upgraded. return this._router._doURLTransition('transitionTo', args[0]); } @@ -21014,8 +19926,11 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int return transition; } /** - Transition into another route while replacing the current URL, if possible. - The route may be either a single route or route path: + Similar to `transitionTo`, but instead of adding the destination to the browser's URL history, + it replaces the entry for the current route. + When the user clicks the "back" button in the browser, there will be fewer steps. + This is most commonly used to manage redirects in a way that does not cause confusing additions + to the user's browsing history. See [replaceWith](/ember/release/classes/Route/methods/replaceWith?anchor=replaceWith) for more info. Calling `replaceWith` from the Router service will cause default query parameter values to be included in the URL. This behavior is different from calling `replaceWith` on a route. @@ -21032,9 +19947,9 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int }); ``` @method replaceWith - @param {String} routeNameOrUrl the name of the route or a URL + @param {String} routeNameOrUrl the name of the route or a URL of the desired destination @param {...Object} models the model(s) or identifier(s) to be used while - transitioning to the route. + transitioning to the route i.e. an object of params to pass to the destination route @param {Object} [options] optional hash with a queryParams property containing a mapping of query parameters @return {Transition} the transition object associated with this @@ -21112,11 +20027,37 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int return this._router.generate(routeName, ...args); } /** - Determines whether a route is active. + Returns `true` if `routeName/models/queryParams` is the active route, where `models` and `queryParams` are optional. + See [model](api/ember/release/classes/Route/methods/model?anchor=model) and + [queryParams](/api/ember/3.7/classes/Route/properties/queryParams?anchor=queryParams) for more information about these arguments. + In the following example, `isActive` will return `true` if the current route is `/posts`. + ```app/components/posts.js + import Component from '@glimmer/component'; + import { inject as service } from '@ember/service'; + export default class extends Component { + @service router; + displayComments() { + return this.get('router').isActive('posts'); + } + }); + ``` + The next example includes a dynamic segment, and will return `true` if the current route is `/posts/1`, + assuming the post has an id of 1: + ```app/components/posts.js + import Component from '@glimmer/component'; + import { inject as service } from '@ember/service'; + export default class extends Component { + @service router; + displayComments(post) { + return this.get('router').isActive('posts', post.id); + } + }); + ``` + Where `post.id` is the id of a specific post, which is represented in the route as /posts/[post.id]. + If `post.id` is equal to 1, then isActive will return true if the current route is /posts/1, and false if the route is anything else. @method isActive @param {String} routeName the name of the route - @param {...Object} models the model(s) or identifier(s) to be used while - transitioning to the route. + @param {...Object} models the model(s) or identifier(s) to be used when determining the active route. @param {Object} [options] optional hash with a queryParams property containing a mapping of query parameters @return {boolean} true if the provided routeName/models/queryParams are active @@ -21130,7 +20071,11 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int models, queryParams } = (0, _utils.extractRouteArgs)(args); - var routerMicrolib = this._router._routerMicrolib; + var routerMicrolib = this._router._routerMicrolib; // UNSAFE: casting `routeName as string` here encodes the existing + // assumption but may be wrong: `extractRouteArgs` correctly returns it as + // `string | undefined`. There may be bugs if `isActiveIntent` does + // not correctly account for `undefined` values for `routeName`. Spoilers: + // it *does not* account for this being `undefined`. if (!routerMicrolib.isActiveIntent(routeName, models)) { return false; @@ -21139,7 +20084,16 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int var hasQueryParams = Object.keys(queryParams).length > 0; if (hasQueryParams) { - this._router._prepareQueryParams(routeName, models, queryParams, true + this._router._prepareQueryParams( // UNSAFE: casting `routeName as string` here encodes the existing + // assumption but may be wrong: `extractRouteArgs` correctly returns it + // as `string | undefined`. There may be bugs if `_prepareQueryParams` + // does not correctly account for `undefined` values for `routeName`. + // Spoilers: under the hood this currently uses router.js APIs which + // *do not* account for this being `undefined`. + routeName, models, // UNSAFE: downstream consumers treat this as `QueryParam`, which the + // type system here *correctly* reports as incorrect, because it may be + // just an empty object. + queryParams, true /* fromRouterService */ ); @@ -21175,7 +20129,7 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int recognize(url) { - (true && !(url.indexOf(this.rootURL) === 0) && (0, _debug.assert)("You must pass a url that begins with the application's rootURL \"" + this.rootURL + "\"", url.indexOf(this.rootURL) === 0)); + (true && !(url.indexOf(this.rootURL) === 0) && (0, _debug.assert)(`You must pass a url that begins with the application's rootURL "${this.rootURL}"`, url.indexOf(this.rootURL) === 0)); var internalURL = cleanURL(url, this.rootURL); return this._router._routerMicrolib.recognize(internalURL); } @@ -21192,7 +20146,7 @@ define("@ember/-internals/routing/lib/services/router", ["exports", "@ember/-int recognizeAndLoad(url) { - (true && !(url.indexOf(this.rootURL) === 0) && (0, _debug.assert)("You must pass a url that begins with the application's rootURL \"" + this.rootURL + "\"", url.indexOf(this.rootURL) === 0)); + (true && !(url.indexOf(this.rootURL) === 0) && (0, _debug.assert)(`You must pass a url that begins with the application's rootURL "${this.rootURL}"`, url.indexOf(this.rootURL) === 0)); var internalURL = cleanURL(url, this.rootURL); return this._router._routerMicrolib.recognizeAndLoad(internalURL); } @@ -21507,7 +20461,7 @@ define("@ember/-internals/routing/lib/system/controller_for", ["exports"], funct @private */ function controllerFor(container, controllerName, lookupOptions) { - return container.lookup("controller:" + controllerName, lookupOptions); + return container.lookup(`controller:${controllerName}`, lookupOptions); } }); define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", "@ember/polyfills"], function (_exports, _debug, _polyfills) { @@ -21539,7 +20493,7 @@ define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", " route(name, _options, _callback) { var options; var callback = null; - var dummyErrorRoute = "/_unused_dummy_error_path_route_" + name + "/:error"; + var dummyErrorRoute = `/_unused_dummy_error_path_route_${name}/:error`; if (isCallback(_options)) { (true && !(arguments.length === 2) && (0, _debug.assert)('Unexpected arguments', arguments.length === 2)); @@ -21560,20 +20514,20 @@ define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", " } return ['basic', 'application'].indexOf(name) === -1; - })()) && (0, _debug.assert)("'" + name + "' cannot be used as a route name.", (() => { + })()) && (0, _debug.assert)(`'${name}' cannot be used as a route name.`, (() => { if (options.overrideNameAssertion === true) { return true; } return ['basic', 'application'].indexOf(name) === -1; })())); - (true && !(name.indexOf(':') === -1) && (0, _debug.assert)("'" + name + "' is not a valid route name. It cannot contain a ':'. You may want to use the 'path' option instead.", name.indexOf(':') === -1)); + (true && !(name.indexOf(':') === -1) && (0, _debug.assert)(`'${name}' is not a valid route name. It cannot contain a ':'. You may want to use the 'path' option instead.`, name.indexOf(':') === -1)); if (this.enableLoadingSubstates) { - createRoute(this, name + "_loading", { + createRoute(this, `${name}_loading`, { resetNamespace: options.resetNamespace }); - createRoute(this, name + "_error", { + createRoute(this, `${name}_error`, { resetNamespace: options.resetNamespace, path: dummyErrorRoute }); @@ -21610,7 +20564,7 @@ define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", " this.options.addRouteForEngine(name, routeInfo); } else if (serialize) { - throw new Error("Defining a route serializer on route '" + name + "' outside an Engine is not allowed."); + throw new Error(`Defining a route serializer on route '${name}' outside an Engine is not allowed.`); } if (url === '' || url === '/' || parts[parts.length - 1] === 'index') { @@ -21654,11 +20608,11 @@ define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", " var path = options.path; if (typeof path !== 'string') { - path = "/" + name; + path = `/${name}`; } var callback; - var dummyErrorRoute = "/_unused_dummy_error_path_route_" + name + "/:error"; + var dummyErrorRoute = `/_unused_dummy_error_path_route_${name}/:error`; if (engineRouteMap) { var shouldResetEngineInfo = false; @@ -21693,8 +20647,8 @@ define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", " if (this.enableLoadingSubstates) { // These values are important to register the loading routes under their // proper names for the Router and within the Engine's registry. - var substateName = name + "_loading"; - var _localFullName = "application_loading"; + var substateName = `${name}_loading`; + var _localFullName = `application_loading`; var _routeInfo = (0, _polyfills.assign)({ localFullName: _localFullName @@ -21704,8 +20658,8 @@ define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", " resetNamespace: options.resetNamespace }); this.options.addRouteForEngine(substateName, _routeInfo); - substateName = name + "_error"; - _localFullName = "application_error"; + substateName = `${name}_error`; + _localFullName = `application_error`; _routeInfo = (0, _polyfills.assign)({ localFullName: _localFullName }, engineInfo); @@ -21730,7 +20684,7 @@ define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", " function getFullName(dsl, name, resetNamespace) { if (canNest(dsl) && resetNamespace !== true) { - return dsl.parent + "." + name; + return `${dsl.parent}.${name}`; } else { return name; } @@ -21740,7 +20694,7 @@ define("@ember/-internals/routing/lib/system/dsl", ["exports", "@ember/debug", " var fullName = getFullName(dsl, name, options.resetNamespace); if (typeof options.path !== 'string') { - options.path = "/" + name; + options.path = `/${name}`; } dsl.push(options.path, fullName, callback, options.serialize); @@ -21773,11 +20727,11 @@ define("@ember/-internals/routing/lib/system/generate_controller", ["exports", " var Factory = owner.factoryFor('controller:basic').class; Factory = Factory.extend({ toString() { - return "(generated " + controllerName + " controller)"; + return `(generated ${controllerName} controller)`; } }); - var fullName = "controller:" + controllerName; + var fullName = `controller:${controllerName}`; owner.register(fullName, Factory); return owner.factoryFor(fullName); } @@ -21794,14 +20748,14 @@ define("@ember/-internals/routing/lib/system/generate_controller", ["exports", " function generateController(owner, controllerName) { generateControllerFactory(owner, controllerName); - var fullName = "controller:" + controllerName; + var fullName = `controller:${controllerName}`; var instance = owner.lookup(fullName); if (true /* DEBUG */ ) { if ((0, _metal.get)(instance, 'namespace.LOG_ACTIVE_GENERATION')) { - (0, _debug.info)("generated -> " + fullName, { + (0, _debug.info)(`generated -> ${fullName}`, { fullName }); } @@ -22165,7 +21119,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil var namePaths = new Array(names.length); for (var a = 0; a < names.length; ++a) { - namePaths[a] = routeInfo.name + "." + names[a]; + namePaths[a] = `${routeInfo.name}.${names[a]}`; } for (var i = 0; i < qps.length; ++i) { @@ -22240,7 +21194,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil paramsFor(name) { - var route = (0, _owner.getOwner)(this).lookup("route:" + name); + var route = (0, _owner.getOwner)(this).lookup(`route:${name}`); if (route === undefined) { return {}; @@ -22252,7 +21206,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil var params = (0, _polyfills.assign)({}, state.params[fullName]); var queryParams = getQueryParamsFor(route, state); return Object.keys(queryParams).reduce((params, key) => { - (true && !(!params[key]) && (0, _debug.assert)("The route '" + this.routeName + "' has both a dynamic segment and query param with name '" + key + "'. Please rename one to avoid collisions.", !params[key])); + (true && !(!params[key]) && (0, _debug.assert)(`The route '${this.routeName}' has both a dynamic segment and query param with name '${key}'. Please rename one to avoid collisions.`, !params[key])); params[key] = queryParams[key]; return params; }, params); @@ -22307,7 +21261,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil _optionsForQueryParam(qp) { - return (0, _metal.get)(this, "queryParams." + qp.urlKey) || (0, _metal.get)(this, "queryParams." + qp.prop) || {}; + return (0, _metal.get)(this, `queryParams.${qp.urlKey}`) || (0, _metal.get)(this, `queryParams.${qp.prop}`) || {}; } /** A hook you can use to reset controller values either when the model @@ -22354,7 +21308,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil _internalReset(isExiting, transition) { var controller = this.controller; - controller._qpDelegate = (0, _metal.get)(this, '_qp.states.inactive'); + controller['_qpDelegate'] = (0, _metal.get)(this, '_qp.states.inactive'); this.resetController(controller, isExiting, transition); } /** @@ -22699,11 +21653,12 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil } ``` @method transitionTo - @param {String} name the name of the route or a URL - @param {...Object} models the model(s) or identifier(s) to be used while + @param {String} [name] the name of the route or a URL. + @param {...Object} [models] the model(s) or identifier(s) to be used while transitioning to the route. @param {Object} [options] optional hash with a queryParams property - containing a mapping of query parameters + containing a mapping of query parameters. May be supplied as the only + parameter to trigger a query-parameter-only transition. @return {Transition} the transition object associated with this attempted transition @since 1.0.0 @@ -23108,7 +22063,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil `super`: ```app/routes/photos.js import Route from '@ember/routing/route'; - export default class PhotosRoute extendes Route { + export default class PhotosRoute extends Route { model() { return this.store.findAll('photo'); } @@ -23144,6 +22099,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil @method setupController @param {Controller} controller instance @param {Object} model + @param {Object} transition @since 1.0.0 @public */ @@ -23179,17 +22135,17 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil controllerFor(name, _skipAssert) { var owner = (0, _owner.getOwner)(this); - var route = owner.lookup("route:" + name); + var route = owner.lookup(`route:${name}`); if (route && route.controllerName) { name = route.controllerName; } - var controller = owner.lookup("controller:" + name); // NOTE: We're specifically checking that skipAssert is true, because according + var controller = owner.lookup(`controller:${name}`); // NOTE: We're specifically checking that skipAssert is true, because according // to the old API the second parameter was model. We do not want people who // passed a model to skip the assertion. - (true && !(controller !== undefined || _skipAssert === true) && (0, _debug.assert)("The controller named '" + name + "' could not be found. Make sure that this route exists and has already been entered at least once. If you are accessing a controller not associated with a route, make sure the controller class is explicitly defined.", controller !== undefined || _skipAssert === true)); + (true && !(controller !== undefined || _skipAssert === true) && (0, _debug.assert)(`The controller named '${name}' could not be found. Make sure that this route exists and has already been entered at least once. If you are accessing a controller not associated with a route, make sure the controller class is explicitly defined.`, controller !== undefined || _skipAssert === true)); return controller; } /** @@ -23262,7 +22218,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil name = _name; } - var route = owner.lookup("route:" + name); // If we are mid-transition, we want to try and look up + var route = owner.lookup(`route:${name}`); // If we are mid-transition, we want to try and look up // resolved parent contexts on the current transitionEvent. if (transition !== undefined && transition !== null) { @@ -23649,16 +22605,16 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil if (controller === undefined) { if (isDefaultRender) { - controller = route.controllerName || owner.lookup("controller:" + name); + controller = route.controllerName || owner.lookup(`controller:${name}`); } else { - controller = owner.lookup("controller:" + name) || route.controllerName || route.routeName; + controller = owner.lookup(`controller:${name}`) || route.controllerName || route.routeName; } } if (typeof controller === 'string') { var controllerName = controller; - controller = owner.lookup("controller:" + controllerName); - (true && !(isDefaultRender || controller !== undefined) && (0, _debug.assert)("You passed `controller: '" + controllerName + "'` into the `render` method, but no such controller could be found.", isDefaultRender || controller !== undefined)); + controller = owner.lookup(`controller:${controllerName}`); + (true && !(isDefaultRender || controller !== undefined) && (0, _debug.assert)(`You passed \`controller: '${controllerName}'\` into the \`render\` method, but no such controller could be found.`, isDefaultRender || controller !== undefined)); } if (model === undefined) { @@ -23667,8 +22623,8 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil controller.set('model', model); } - var template = owner.lookup("template:" + templateName); - (true && !(isDefaultRender || template !== undefined) && (0, _debug.assert)("Could not find \"" + templateName + "\" template, view, or component.", isDefaultRender || template !== undefined)); + var template = owner.lookup(`template:${templateName}`); + (true && !(isDefaultRender || template !== undefined) && (0, _debug.assert)(`Could not find "${templateName}" template, view, or component.`, isDefaultRender || template !== undefined)); var parent; if (into && (parent = parentRoute(route)) && into === parent.routeName) { @@ -23691,8 +22647,8 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil var LOG_VIEW_LOOKUPS = (0, _metal.get)(route._router, 'namespace.LOG_VIEW_LOOKUPS'); if (LOG_VIEW_LOOKUPS && !template) { - (0, _debug.info)("Could not find \"" + name + "\" template. Nothing will be rendered", { - fullName: "template:" + name + (0, _debug.info)(`Could not find "${name}" template. Nothing will be rendered`, { + fullName: `template:${name}` }); } } @@ -23800,7 +22756,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil } } - (0, _metal.addObserver)(controller, prop + ".[]", controller, controller._qpChanged, false); + (0, _metal.addObserver)(controller, `${prop}.[]`, controller, controller._qpChanged, false); }); } @@ -23811,7 +22767,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil if (routeName === 'application') { return prefix; } else { - return prefix + "." + routeName; + return `${prefix}.${routeName}`; } } @@ -23975,15 +22931,15 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil var namespace = (0, _metal.get)(this, '_router.namespace'); return { find(name, value) { - var modelClass = owner.factoryFor("model:" + name); - (true && !(Boolean(modelClass)) && (0, _debug.assert)("You used the dynamic segment " + name + "_id in your route " + routeName + ", but " + namespace + "." + (0, _string.classify)(name) + " did not exist and you did not override your route's `model` hook.", Boolean(modelClass))); + var modelClass = owner.factoryFor(`model:${name}`); + (true && !(Boolean(modelClass)) && (0, _debug.assert)(`You used the dynamic segment ${name}_id in your route ${routeName}, but ${namespace}.${(0, _string.classify)(name)} did not exist and you did not override your route's \`model\` hook.`, Boolean(modelClass))); if (!modelClass) { return; } modelClass = modelClass.class; - (true && !(typeof modelClass.find === 'function') && (0, _debug.assert)((0, _string.classify)(name) + " has no method `find`.", typeof modelClass.find === 'function')); + (true && !(typeof modelClass.find === 'function') && (0, _debug.assert)(`${(0, _string.classify)(name)} has no method \`find\`.`, typeof modelClass.find === 'function')); return modelClass.find(value); } @@ -24004,7 +22960,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil var combinedQueryParameterConfiguration; var controllerName = this.controllerName || this.routeName; var owner = (0, _owner.getOwner)(this); - var controller = owner.lookup("controller:" + controllerName); + var controller = owner.lookup(`controller:${controllerName}`); var queryParameterConfiguraton = (0, _metal.get)(this, 'queryParams'); var hasRouterDefinedQueryParams = Object.keys(queryParameterConfiguraton).length > 0; @@ -24052,7 +23008,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil defaultValue = copyDefaultValue(defaultValue); var type = desc.type || (0, _runtime.typeOf)(defaultValue); var defaultValueSerialized = this.serializeQueryParam(defaultValue, urlKey, type); - var scopedPropertyName = controllerName + ":" + propName; + var scopedPropertyName = `${controllerName}:${propName}`; var qp = { undecoratedDefaultValue: (0, _metal.get)(controller, propName), defaultValue, @@ -24157,7 +23113,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil @public */ send(...args) { - (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)("Attempted to call .send() with the action '" + args[0] + "' on the destroyed route '" + this.routeName + "'.", !this.isDestroying && !this.isDestroyed)); + (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)(`Attempted to call .send() with the action '${args[0]}' on the destroyed route '${this.routeName}'.`, !this.isDestroying && !this.isDestroyed)); if (this._router && this._router._routerMicrolib || !(0, _debug.isTesting)()) { this._router.send(...args); @@ -24318,7 +23274,7 @@ define("@ember/-internals/routing/lib/system/route", ["exports", "@ember/polyfil qpMeta.qps.forEach(qp => { var routeQpMeta = (0, _metal.get)(qp.route, '_qp'); var finalizedController = qp.route.controller; - finalizedController._qpDelegate = (0, _metal.get)(routeQpMeta, 'states.active'); + finalizedController['_qpDelegate'] = (0, _metal.get)(routeQpMeta, 'states.active'); }); router._qpUpdates.clear(); @@ -24400,7 +23356,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter ) { if ((0, _metal.get)(this, 'namespace').LOG_TRANSITIONS) { // eslint-disable-next-line no-console - console.log("Transitioned into '" + EmberRouter._routePath(infos) + "'"); + console.log(`Transitioned into '${EmberRouter._routePath(infos)}'`); } } } @@ -24413,7 +23369,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter ) { if ((0, _metal.get)(this, 'namespace').LOG_TRANSITIONS) { // eslint-disable-next-line no-console - console.log("Preparing to transition from '" + EmberRouter._routePath(oldInfos) + "' to '" + EmberRouter._routePath(newInfos) + "'"); + console.log(`Preparing to transition from '${EmberRouter._routePath(oldInfos)}' to '${EmberRouter._routePath(newInfos)}'`); } } } @@ -24444,6 +23400,8 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter this.currentRoute = null; this._qpCache = Object.create(null); this._qpUpdates = new Set(); + this._queuedQPChanges = {}; + this._toplevelView = null; this._handledErrors = new Set(); this._engineInstances = Object.create(null); this._engineInfoByRoute = Object.create(null); @@ -24472,7 +23430,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter routeName = engineInfo.localFullName; } - var fullRouteName = "route:" + routeName; + var fullRouteName = `route:${routeName}`; var route = routeOwner.lookup(fullRouteName); if (seen[name]) { @@ -24490,7 +23448,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter /* DEBUG */ ) { if ((0, _metal.get)(router, 'namespace.LOG_ACTIVE_GENERATION')) { - (0, _debug.info)("generated -> " + fullRouteName, { + (0, _debug.info)(`generated -> ${fullRouteName}`, { fullName: fullRouteName }); } @@ -24650,7 +23608,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter enableLoadingSubstates, resolveRouteMap(name) { - return owner.factoryFor("route-map:" + name); + return owner.factoryFor(`route-map:${name}`); }, addRouteForEngine(name, engineInfo) { @@ -24821,7 +23779,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter transitionTo(...args) { if ((0, _utils.resemblesURL)(args[0])) { - (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)("A transition was attempted from '" + this.currentRouteName + "' to '" + args[0] + "' but the application instance has already been destroyed.", !this.isDestroying && !this.isDestroyed)); + (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)(`A transition was attempted from '${this.currentRouteName}' to '${args[0]}' but the application instance has already been destroyed.`, !this.isDestroying && !this.isDestroyed)); return this._doURLTransition('transitionTo', args[0]); } @@ -24830,7 +23788,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter models, queryParams } = (0, _utils.extractRouteArgs)(args); - (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)("A transition was attempted from '" + this.currentRouteName + "' to '" + routeName + "' but the application instance has already been destroyed.", !this.isDestroying && !this.isDestroyed)); + (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)(`A transition was attempted from '${this.currentRouteName}' to '${routeName}' but the application instance has already been destroyed.`, !this.isDestroying && !this.isDestroyed)); return this._doTransition(routeName, models, queryParams); } @@ -24846,7 +23804,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter if ((0, _metal.get)(this, 'namespace').LOG_TRANSITIONS) { // eslint-disable-next-line no-console - console.log("Intermediate-transitioned into '" + EmberRouter._routePath(infos) + "'"); + console.log(`Intermediate-transitioned into '${EmberRouter._routePath(infos)}'`); } } } @@ -24981,7 +23939,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter var owner = (0, _owner.getOwner)(this); if ('string' === typeof location && owner) { - var resolvedLocation = owner.lookup("location:" + location); + var resolvedLocation = owner.lookup(`location:${location}`); if (resolvedLocation !== undefined) { location = (0, _metal.set)(this, 'location', resolvedLocation); @@ -25051,7 +24009,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter return JSON.stringify(value); } - return "" + value; + return `${value}`; } /** Deserializes the given query params according to their QP meta information. @@ -25121,7 +24079,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter _doTransition(_targetRouteName, models, _queryParams, _keepDefaultQueryParamValues) { var targetRouteName = _targetRouteName || (0, _utils.getActiveTargetName)(this._routerMicrolib); - (true && !(Boolean(targetRouteName) && this._routerMicrolib.hasRoute(targetRouteName)) && (0, _debug.assert)("The route " + targetRouteName + " was not found", Boolean(targetRouteName) && this._routerMicrolib.hasRoute(targetRouteName))); + (true && !(Boolean(targetRouteName) && this._routerMicrolib.hasRoute(targetRouteName)) && (0, _debug.assert)(`The route ${targetRouteName} was not found`, Boolean(targetRouteName) && this._routerMicrolib.hasRoute(targetRouteName))); var queryParams = {}; this._processActiveTransitionQueryParams(targetRouteName, models, queryParams, _queryParams); @@ -25251,7 +24209,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter qpOther = qpsByUrlKey[urlKey]; if (qpOther && qpOther.controllerName !== qp.controllerName) { - (true && !(false) && (0, _debug.assert)("You're not allowed to have more than one controller property map to the same query param key, but both `" + qpOther.scopedPropertyName + "` and `" + qp.scopedPropertyName + "` map to `" + urlKey + "`. You can fix this by mapping one of the controller properties to a different query param key via the `as` config option, e.g. `" + qpOther.prop + ": { as: 'other-" + qpOther.prop + "' }`", false)); + (true && !(false) && (0, _debug.assert)(`You're not allowed to have more than one controller property map to the same query param key, but both \`${qpOther.scopedPropertyName}\` and \`${qp.scopedPropertyName}\` map to \`${urlKey}\`. You can fix this by mapping one of the controller properties to a different query param key via the \`as\` config option, e.g. \`${qpOther.prop}: { as: \'other-${qpOther.prop}\' }\``, false)); } qpsByUrlKey[urlKey] = qp; @@ -25356,7 +24314,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter } return true; - }()) && (0, _debug.assert)("You passed the `" + presentProp + "` query parameter during a transition into " + qp.route.routeName + ", please update to " + qp.urlKey, function () { + }()) && (0, _debug.assert)(`You passed the \`${presentProp}\` query parameter during a transition into ${qp.route.routeName}, please update to ${qp.urlKey}`, function () { if (qp.urlKey === presentProp) { return true; } @@ -25436,7 +24394,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter if (!engineInstance) { var owner = (0, _owner.getOwner)(this); - (true && !(owner.hasRegistration("engine:" + name)) && (0, _debug.assert)("You attempted to mount the engine '" + name + "' in your router map, but the engine can not be found.", owner.hasRegistration("engine:" + name))); + (true && !(owner.hasRegistration(`engine:${name}`)) && (0, _debug.assert)(`You attempted to mount the engine '${name}' in your router map, but the engine can not be found.`, owner.hasRegistration(`engine:${name}`))); engineInstance = owner.buildChildEngineInstance(name, { routable: true, mountPoint @@ -25525,7 +24483,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter return true; }); - logError(error, "Error while processing route: " + transition.targetName); + logError(error, `Error while processing route: ${transition.targetName}`); }, // Attempt to find an appropriate loading route or substate to enter. @@ -25608,8 +24566,8 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter fullRouteName, _router: router } = route; - var substateName = routeName + "_" + state; - var substateNameFull = fullRouteName + "_" + state; + var substateName = `${routeName}_${state}`; + var substateNameFull = `${fullRouteName}_${state}`; return routeHasBeenDefined(owner, router, substateName, substateNameFull) ? substateNameFull : ''; } /** @@ -25631,8 +24589,8 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter fullRouteName, _router: router } = route; - var stateName = routeName === 'application' ? state : routeName + "." + state; - var stateNameFull = fullRouteName === 'application' ? state : fullRouteName + "." + state; + var stateName = routeName === 'application' ? state : `${routeName}.${state}`; + var stateNameFull = fullRouteName === 'application' ? state : `${fullRouteName}.${state}`; return routeHasBeenDefined(owner, router, stateName, stateNameFull) ? stateNameFull : ''; } /** @@ -25650,7 +24608,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter function routeHasBeenDefined(owner, router, localName, fullName) { var routerHasRoute = router.hasRoute(fullName); - var ownerHasRoute = owner.hasRegistration("template:" + localName) || owner.hasRegistration("route:" + localName); + var ownerHasRoute = owner.hasRegistration(`template:${localName}`) || owner.hasRegistration(`route:${localName}`); return routerHasRoute && ownerHasRoute; } @@ -25660,7 +24618,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter return; } - throw new _error2.default("Can't trigger action '" + name + "' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call `.send()` on the `Transition` object passed to the `model/beforeModel/afterModel` hooks."); + throw new _error2.default(`Can't trigger action '${name}' because your app hasn't finished transitioning into its first route. To trigger an action on destination routes during a transition, you can call \`.send()\` on the \`Transition\` object passed to the \`model/beforeModel/afterModel\` hooks.`); } var eventWasHandled = false; @@ -25693,7 +24651,7 @@ define("@ember/-internals/routing/lib/system/router", ["exports", "@ember/-inter } if (!eventWasHandled && !ignoreFailure) { - throw new _error2.default("Nothing handled the action '" + name + "'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble."); + throw new _error2.default(`Nothing handled the action '${name}'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.`); } } @@ -26282,15 +25240,23 @@ define("@ember/-internals/routing/lib/utils", ["exports", "@ember/-internals/met var queryParams; if (possibleQueryParams && possibleQueryParams.hasOwnProperty('queryParams')) { + // SAFETY: this cast is safe because we have just checked whether + // `possibleQueryParams` -- defined as the last item in args -- both exists + // and has the property `queryParams`. If either of these invariants change, + // ***this is unsafe and should be changed***. queryParams = args.pop().queryParams; } else { queryParams = {}; - } + } // UNSAFE: these are simply assumed as the existing behavior of the system. + // However, this could break if upstream refactors change it, and the types + // here would not be able to tell us; we would lie to everything downstream. + var routeName = args.shift(); + var models = args; return { routeName, - models: args, + models, queryParams }; } @@ -26378,7 +25344,7 @@ define("@ember/-internals/routing/lib/utils", ["exports", "@ember/-internals/met } } - suffixes += "::" + part + ":" + value; + suffixes += `::${part}:${value}`; } return prefix + suffixes.replace(ALL_PERIODS_REGEX, '-'); @@ -26486,7 +25452,7 @@ define("@ember/-internals/routing/lib/utils", ["exports", "@ember/-internals/met if (resemblesURL(routeName)) { throw new _error.default('Programmatic transitions by URL cannot be used within an Engine. Please use the route name instead.'); } else { - routeName = prefix + "." + routeName; + routeName = `${prefix}.${routeName}`; args[0] = routeName; } } @@ -27064,7 +26030,7 @@ define("@ember/-internals/runtime/lib/ext/function", ["@ember/-internals/environ enumerable: false, writable: true, value: function () { - (true && !(false) && (0, _debug.deprecate)("Function prototype extensions have been deprecated, please migrate from function(){}.property('bar') to computed('bar', function() {}).", false, { + (true && !(false) && (0, _debug.deprecate)(`Function prototype extensions have been deprecated, please migrate from function(){}.property('bar') to computed('bar', function() {}).`, false, { id: 'function-prototype-extensions.property', until: '4.0.0', url: 'https://deprecations.emberjs.com/v3.x#toc_function-prototype-extensions-property' @@ -27099,7 +26065,7 @@ define("@ember/-internals/runtime/lib/ext/function", ["@ember/-internals/environ enumerable: false, writable: true, value: function () { - (true && !(false) && (0, _debug.deprecate)("Function prototype extensions have been deprecated, please migrate from function(){}.observes('foo') to observer('foo', function() {}).", false, { + (true && !(false) && (0, _debug.deprecate)(`Function prototype extensions have been deprecated, please migrate from function(){}.observes('foo') to observer('foo', function() {}).`, false, { id: 'function-prototype-extensions.observes', until: '4.0.0', url: 'https://deprecations.emberjs.com/v3.x#toc_function-prototype-extensions-observes' @@ -27132,7 +26098,7 @@ define("@ember/-internals/runtime/lib/ext/function", ["@ember/-internals/environ enumerable: false, writable: true, value: function () { - (true && !(false) && (0, _debug.deprecate)("Function prototype extensions have been deprecated, please migrate from function(){}.on('foo') to on('foo', function() {}).", false, { + (true && !(false) && (0, _debug.deprecate)(`Function prototype extensions have been deprecated, please migrate from function(){}.on('foo') to on('foo', function() {}).`, false, { id: 'function-prototype-extensions.on', until: '4.0.0', url: 'https://deprecations.emberjs.com/v3.x#toc_function-prototype-extensions-on' @@ -27181,7 +26147,7 @@ define("@ember/-internals/runtime/lib/ext/rsvp", ["exports", "rsvp", "@ember/run } if (reason.name === 'UnrecognizedURLError') { - (true && !(false) && (0, _debug.assert)("The URL '" + reason.message + "' did not match any routes in your application", false)); + (true && !(false) && (0, _debug.assert)(`The URL '${reason.message}' did not match any routes in your application`, false)); return; } @@ -27279,7 +26245,7 @@ define("@ember/-internals/runtime/lib/is-equal", ["exports"], function (_exports return a === b; } }); -define("@ember/-internals/runtime/lib/mixins/-proxy", ["exports", "@ember/-internals/meta", "@ember/-internals/metal", "@ember/-internals/utils", "@ember/debug", "@glimmer/reference"], function (_exports, _meta, _metal, _utils, _debug, _reference) { +define("@ember/-internals/runtime/lib/mixins/-proxy", ["exports", "@ember/-internals/meta", "@ember/-internals/metal", "@ember/-internals/utils", "@ember/debug", "@glimmer/validator"], function (_exports, _meta, _metal, _utils, _debug, _validator) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -27291,14 +26257,9 @@ define("@ember/-internals/runtime/lib/mixins/-proxy", ["exports", "@ember/-inter /** @module ember */ - function contentFor(proxy, m) { + function contentFor(proxy) { var content = (0, _metal.get)(proxy, 'content'); - var tag = (m === undefined ? (0, _meta.meta)(proxy) : m).readableTag(); - - if (tag !== undefined) { - (0, _reference.update)(tag, (0, _metal.tagFor)(content)); - } - + (0, _validator.update)((0, _metal.tagForObject)(proxy), (0, _metal.tagForObject)(content)); return content; } /** @@ -27325,8 +26286,7 @@ define("@ember/-internals/runtime/lib/mixins/-proxy", ["exports", "@ember/-inter this._super(...arguments); (0, _utils.setProxy)(this); - var m = (0, _meta.meta)(this); - m.writableTag(); + (0, _metal.tagForObject)(this); }, willDestroy() { @@ -27340,12 +26300,25 @@ define("@ember/-internals/runtime/lib/mixins/-proxy", ["exports", "@ember/-inter }), [_metal.CUSTOM_TAG_FOR](key) { - var tag = (0, _metal.createTagForProperty)(this, key); + var tag = (0, _validator.tagFor)(this, key); + + if (true + /* DEBUG */ + ) { + // TODO: Replace this with something more first class for tracking tags in DEBUG + tag._propertyKey = key; + } if (key in this) { + if (true + /* DEBUG */ + ) { + (0, _utils.setupMandatorySetter)(tag, this, key); + } + return tag; } else { - return (0, _reference.combine)([tag, ...(0, _metal.getChainTagsForKey)(this, "content." + key)]); + return (0, _validator.combine)([tag, ...(0, _metal.getChainTagsForKey)(this, `content.${key}`)]); } }, @@ -27367,8 +26340,8 @@ define("@ember/-internals/runtime/lib/mixins/-proxy", ["exports", "@ember/-inter return value; } - var content = contentFor(this, m); - (true && !(content) && (0, _debug.assert)("Cannot delegate set('" + key + "', " + value + ") to the 'content' property of object proxy " + this + ": its 'content' is undefined.", content)); + var content = contentFor(this); + (true && !(content) && (0, _debug.assert)(`Cannot delegate set('${key}', ${value}) to the \'content\' property of object proxy ${this}: its 'content' is undefined.`, content)); return (0, _metal.set)(content, key, value); } @@ -27548,7 +26521,7 @@ define("@ember/-internals/runtime/lib/mixins/action_handler", ["exports", "@embe @public */ send(actionName, ...args) { - (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)("Attempted to call .send() with the action '" + actionName + "' on the destroyed object '" + this + "'.", !this.isDestroying && !this.isDestroyed)); + (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)(`Attempted to call .send() with the action '${actionName}' on the destroyed object '${this}'.`, !this.isDestroying && !this.isDestroyed)); if (this.actions && this.actions[actionName]) { var shouldBubble = this.actions[actionName].apply(this, args) === true; @@ -27561,7 +26534,7 @@ define("@ember/-internals/runtime/lib/mixins/action_handler", ["exports", "@embe var target = (0, _metal.get)(this, 'target'); if (target) { - (true && !(typeof target.send === 'function') && (0, _debug.assert)("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === 'function')); + (true && !(typeof target.send === 'function') && (0, _debug.assert)(`The \`target\` for ${this} (${target}) does not have a \`send\` method`, typeof target.send === 'function')); target.send(...arguments); } } @@ -27590,7 +26563,7 @@ define("@ember/-internals/runtime/lib/mixins/array", ["exports", "@ember/-intern var identityFunction = item => item; function uniqBy(array, key = identityFunction) { - (true && !(isArray(array)) && (0, _debug.assert)("first argument passed to `uniqBy` should be array", isArray(array))); + (true && !(isArray(array)) && (0, _debug.assert)(`first argument passed to \`uniqBy\` should be array`, isArray(array))); var ret = A(); var seen = new Set(); var getter = typeof key === 'function' ? key : item => (0, _metal.get)(item, key); @@ -27656,13 +26629,13 @@ define("@ember/-internals/runtime/lib/mixins/array", ["exports", "@ember/-intern } function removeAt(array, index, len = 1) { - (true && !(index > -1 && index < array.length) && (0, _debug.assert)("`removeAt` index provided is out of range", index > -1 && index < array.length)); + (true && !(index > -1 && index < array.length) && (0, _debug.assert)(`\`removeAt\` index provided is out of range`, index > -1 && index < array.length)); (0, _metal.replace)(array, index, len, EMPTY_ARRAY); return array; } function insertAt(array, index, item) { - (true && !(index > -1 && index <= array.length) && (0, _debug.assert)("`insertAt` index provided is out of range", index > -1 && index <= array.length)); + (true && !(index > -1 && index <= array.length) && (0, _debug.assert)(`\`insertAt\` index provided is out of range`, index > -1 && index <= array.length)); (0, _metal.replace)(array, index, 0, [item]); return item; } @@ -27930,7 +26903,7 @@ define("@ember/-internals/runtime/lib/mixins/array", ["exports", "@ember/-intern }, /** - Used to determine the passed object's first occurence in the array. + Used to determine the passed object's first occurrence in the array. Returns the index if found, -1 if no match is found. The optional `startAt` argument can be used to pass a starting index to search from, effectively slicing the searchable portion @@ -28096,7 +27069,7 @@ define("@ember/-internals/runtime/lib/mixins/array", ["exports", "@ember/-intern enumerable: false, get() { - (0, _metal.hasListeners)(this, '@array:change') || (0, _metal.hasListeners)(this, '@array:before'); + return (0, _metal.hasListeners)(this, '@array:change') || (0, _metal.hasListeners)(this, '@array:before'); } }), @@ -30082,7 +29055,7 @@ define("@ember/-internals/runtime/lib/mixins/observable", ["exports", "@ember/-i @private */ hasObserverFor(key) { - return (0, _metal.hasListeners)(this, key + ":change"); + return (0, _metal.hasListeners)(this, `${key}:change`); }, /** @@ -30720,7 +29693,7 @@ define("@ember/-internals/runtime/lib/mixins/target_action_support", ["exports", if (target.send) { ret = target.send(...[action].concat(actionContext)); } else { - (true && !(typeof target[action] === 'function') && (0, _debug.assert)("The action '" + action + "' did not exist on " + target, typeof target[action] === 'function')); + (true && !(typeof target[action] === 'function') && (0, _debug.assert)(`The action '${action}' did not exist on ${target}`, typeof target[action] === 'function')); ret = target[action](...[].concat(actionContext)); } @@ -30760,7 +29733,7 @@ define("@ember/-internals/runtime/lib/mixins/target_action_support", ["exports", return null; } }); -define("@ember/-internals/runtime/lib/system/array_proxy", ["exports", "@ember/-internals/metal", "@ember/-internals/runtime/lib/system/object", "@ember/-internals/runtime/lib/mixins/array", "@ember/debug", "@glimmer/reference"], function (_exports, _metal, _object, _array, _debug, _reference) { +define("@ember/-internals/runtime/lib/system/array_proxy", ["exports", "@ember/-internals/metal", "@ember/-internals/runtime/lib/system/object", "@ember/-internals/runtime/lib/mixins/array", "@ember/debug", "@glimmer/validator"], function (_exports, _metal, _object, _array, _debug, _validator) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -30854,13 +29827,24 @@ define("@ember/-internals/runtime/lib/system/array_proxy", ["exports", "@ember/- this._length = 0; this._arrangedContent = null; this._arrangedContentIsUpdating = false; - this._arrangedContentTag = (0, _reference.combine)((0, _metal.getChainTagsForKey)(this, 'arrangedContent')); - this._arrangedContentRevision = (0, _reference.value)(this._arrangedContentTag); + this._arrangedContentTag = null; + this._arrangedContentRevision = null; + } - this._addArrangedContentArrayObserver(); + [_metal.PROPERTY_DID_CHANGE]() { + this._revalidate(); + } + + [_metal.CUSTOM_TAG_FOR](key) { + if (key === '[]' || key === 'length') { + // revalidate eagerly if we're being tracked, since we no longer will + // be able to later on due to backtracking re-render assertion + this._revalidate(); + + return (0, _validator.combine)((0, _metal.getChainTagsForKey)(this, `arrangedContent.${key}`)); + } - (0, _reference.update)((0, _metal.tagForProperty)(this, '[]'), (0, _reference.combine)((0, _metal.getChainTagsForKey)(this, 'arrangedContent.[]'))); - (0, _reference.update)((0, _metal.tagForProperty)(this, 'length'), (0, _reference.combine)((0, _metal.getChainTagsForKey)(this, 'arrangedContent.length'))); + return (0, _validator.tagFor)(this, key); } willDestroy() { @@ -30976,10 +29960,6 @@ define("@ember/-internals/runtime/lib/system/array_proxy", ["exports", "@ember/- } } - [_metal.PROPERTY_DID_CHANGE]() { - this._revalidate(); - } - _updateArrangedContentArray() { var oldLength = this._objects === null ? 0 : this._objects.length; var arrangedContent = (0, _metal.get)(this, 'arrangedContent'); @@ -31001,7 +29981,7 @@ define("@ember/-internals/runtime/lib/system/array_proxy", ["exports", "@ember/- if (arrangedContent && !arrangedContent.isDestroyed) { (true && !(arrangedContent !== this) && (0, _debug.assert)("Can't set ArrayProxy's content to itself", arrangedContent !== this)); - (true && !((0, _array.isArray)(arrangedContent) || arrangedContent.isDestroyed) && (0, _debug.assert)("ArrayProxy expects an Array or ArrayProxy, but you passed " + typeof arrangedContent, (0, _array.isArray)(arrangedContent) || arrangedContent.isDestroyed)); + (true && !((0, _array.isArray)(arrangedContent) || arrangedContent.isDestroyed) && (0, _debug.assert)(`ArrayProxy expects an Array or ArrayProxy, but you passed ${typeof arrangedContent}`, (0, _array.isArray)(arrangedContent) || arrangedContent.isDestroyed)); (0, _metal.addArrayObserver)(arrangedContent, this, ARRAY_OBSERVER_MAPPING); this._arrangedContent = arrangedContent; } @@ -31038,14 +30018,23 @@ define("@ember/-internals/runtime/lib/system/array_proxy", ["exports", "@ember/- } _revalidate() { - if (!this._arrangedContentIsUpdating && !(0, _reference.validate)(this._arrangedContentTag, this._arrangedContentRevision)) { - this._arrangedContentIsUpdating = true; + if (this._arrangedContentIsUpdating === true) return; + + if (this._arrangedContentTag === null || !(0, _validator.validate)(this._arrangedContentTag, this._arrangedContentRevision)) { + if (this._arrangedContentTag === null) { + // This is the first time the proxy has been setup, only add the observer + // don't trigger any events + this._addArrangedContentArrayObserver(); + } else { + this._arrangedContentIsUpdating = true; + + this._updateArrangedContentArray(); - this._updateArrangedContentArray(); + this._arrangedContentIsUpdating = false; + } - this._arrangedContentIsUpdating = false; - this._arrangedContentTag = (0, _reference.combine)((0, _metal.getChainTagsForKey)(this, 'arrangedContent')); - this._arrangedContentRevision = (0, _reference.value)(this._arrangedContentTag); + this._arrangedContentTag = (0, _validator.combine)((0, _metal.getChainTagsForKey)(this, 'arrangedContent')); + this._arrangedContentRevision = (0, _validator.value)(this._arrangedContentTag); } } @@ -31064,10 +30053,6 @@ define("@ember/-internals/runtime/lib/system/array_proxy", ["exports", "@ember/- // Array proxies don't need to notify when they change since their `[]` tag is // already dependent on the `[]` tag of `arrangedContent` - arrayContentWillChange(startIdx, removeAmt, addAmt) { - return (0, _metal.arrayContentWillChange)(this, startIdx, removeAmt, addAmt, false); - }, - arrayContentDidChange(startIdx, removeAmt, addAmt) { return (0, _metal.arrayContentDidChange)(this, startIdx, removeAmt, addAmt, false); } @@ -31089,6 +30074,14 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- var reopen = _metal.Mixin.prototype.reopen; var wasApplied = new _polyfills._WeakSet(); var factoryMap = new WeakMap(); + var debugOwnerMap; + + if (true + /* DEBUG */ + ) { + debugOwnerMap = new WeakMap(); + } + var prototypeMixinMap = new WeakMap(); var initCalled = true /* DEBUG */ @@ -31261,7 +30254,7 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- /* DEBUG */ && _utils.HAS_NATIVE_PROXY && typeof self.unknownProperty === 'function') { var messageFor = (obj, property) => { - return "You attempted to access the `" + String(property) + "` property (of " + obj + ").\n" + "Since Ember 3.1, this is usually fine as you no longer need to use `.get()`\n" + "to access computed properties. However, in this case, the object in question\n" + "is a special kind of Ember object (a proxy). Therefore, it is still necessary\n" + ("to use `.get('" + String(property) + "')` in this case.\n\n") + "If you encountered this error because of third-party code that you don't control,\n" + "there is more information at https://github.com/emberjs/ember.js/issues/16148, and\n" + "you can help us improve this error message by telling us more about what happened in\n" + "this situation."; + return `You attempted to access the \`${String(property)}\` property (of ${obj}).\n` + `Since Ember 3.1, this is usually fine as you no longer need to use \`.get()\`\n` + `to access computed properties. However, in this case, the object in question\n` + `is a special kind of Ember object (a proxy). Therefore, it is still necessary\n` + `to use \`.get('${String(property)}')\` in this case.\n\n` + `If you encountered this error because of third-party code that you don't control,\n` + `there is more information at https://github.com/emberjs/ember.js/issues/16148, and\n` + `you can help us improve this error message by telling us more about what happened in\n` + `this situation.`; }; /* globals Proxy Reflect */ @@ -31291,33 +30284,13 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- var m = (0, _meta2.meta)(self); m.setInitializing(); (true && !((() => { - if (passedFromCreate === PASSED_FROM_CREATE) { - return true; - } - - if (initFactory === undefined) { - return false; - } - - if (passedFromCreate === initFactory.owner) { - return true; - } - - return false; - })()) && (0, _debug.assert)("An EmberObject based class, " + this.constructor + ", was not instantiated correctly. You may have either used `new` instead of `.create()`, or not passed arguments to your call to super in the constructor: `super(...arguments)`. If you are trying to use `new`, consider using native classes without extending from EmberObject.", (() => { - if (passedFromCreate === PASSED_FROM_CREATE) { - return true; - } - - if (initFactory === undefined) { - return false; - } - - if (passedFromCreate === initFactory.owner) { - return true; - } - - return false; + var owner = debugOwnerMap.get(this.constructor); + debugOwnerMap.delete(this.constructor); + return passedFromCreate !== undefined && (passedFromCreate === PASSED_FROM_CREATE || passedFromCreate === owner); + })()) && (0, _debug.assert)(`An EmberObject based class, ${this.constructor}, was not instantiated correctly. You may have either used \`new\` instead of \`.create()\`, or not passed arguments to your call to super in the constructor: \`super(...arguments)\`. If you are trying to use \`new\`, consider using native classes without extending from EmberObject.`, (() => { + var owner = debugOwnerMap.get(this.constructor); + debugOwnerMap.delete(this.constructor); + return passedFromCreate !== undefined && (passedFromCreate === PASSED_FROM_CREATE || passedFromCreate === owner); })())); // only return when in debug builds and `self` is the proxy created above if (true @@ -31494,7 +30467,7 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- } set isDestroyed(value) { - (true && !(false) && (0, _debug.assert)("You cannot set `" + this + ".isDestroyed` directly, please use `.destroy()`.", false)); + (true && !(false) && (0, _debug.assert)(`You cannot set \`${this}.isDestroyed\` directly, please use \`.destroy()\`.`, false)); } /** Destruction scheduled flag. The `destroy()` method has been called. @@ -31511,7 +30484,7 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- } set isDestroying(value) { - (true && !(false) && (0, _debug.assert)("You cannot set `" + this + ".isDestroying` directly, please use `.destroy()`.", false)); + (true && !(false) && (0, _debug.assert)(`You cannot set \`${this}.isDestroying\` directly, please use \`.destroy()\`.`, false)); } /** Destroys an object by setting the `isDestroyed` flag and removing its @@ -31527,15 +30500,11 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- destroy() { - var m = (0, _meta2.peekMeta)(this); - - if (m.isSourceDestroying()) { + if ((0, _metal.destroy)(this)) { + (0, _runloop.schedule)('actions', this, this.willDestroy); return; } - m.setSourceDestroying(); - (0, _runloop.schedule)('actions', this, this.willDestroy); - (0, _runloop.schedule)('destroy', this, this._scheduledDestroy, m); return this; } /** @@ -31546,22 +30515,6 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- willDestroy() {} - /** - Invoked by the run loop to actually destroy the object. This is - scheduled for execution by the `destroy` method. - @private - @method _scheduledDestroy - */ - - - _scheduledDestroy(m) { - if (m.isSourceDestroyed()) { - return; - } - - (0, _meta2.deleteMeta)(this); - m.setSourceDestroyed(); - } /** Returns a string representation which attempts to provide more information than Javascript's `toString` typically does, in a generic way for all Ember @@ -31598,8 +30551,8 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- toString() { var hasToStringExtension = typeof this.toStringExtension === 'function'; - var extension = hasToStringExtension ? ":" + this.toStringExtension() : ''; - var ret = "<" + ((0, _utils.getName)(this) || _container.FACTORY_FOR.get(this) || this.constructor.toString()) + ":" + (0, _utils.guidFor)(this) + extension + ">"; + var extension = hasToStringExtension ? `:${this.toStringExtension()}` : ''; + var ret = `<${(0, _utils.getName)(this) || _container.FACTORY_FOR.get(this) || this.constructor.toString()}:${(0, _utils.guidFor)(this)}${extension}>`; return ret; } /** @@ -31731,11 +30684,17 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- owner = (0, _owner.getOwner)(props); } - if (owner === undefined) { - // fallback to passing the special PASSED_FROM_CREATE symbol - // to avoid an error when folks call things like Controller.extend().create() - // we should do a subsequent deprecation pass to ensure this isn't allowed - owner = PASSED_FROM_CREATE; + if (true + /* DEBUG */ + ) { + if (owner === undefined) { + // fallback to passing the special PASSED_FROM_CREATE symbol + // to avoid an error when folks call things like Controller.extend().create() + // we should do a subsequent deprecation pass to ensure this isn't allowed + owner = PASSED_FROM_CREATE; + } else { + debugOwnerMap.set(this, owner); + } } instance = new C(owner); @@ -31903,7 +30862,7 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- var proto = this.proto(); // ensure prototype is initialized var possibleDesc = (0, _metal.descriptorForProperty)(proto, key); - (true && !(possibleDesc !== undefined) && (0, _debug.assert)("metaForProperty() could not find a computed property with key '" + key + "'.", possibleDesc !== undefined)); + (true && !(possibleDesc !== undefined) && (0, _debug.assert)(`metaForProperty() could not find a computed property with key '${key}'.`, possibleDesc !== undefined)); return possibleDesc._meta || {}; } /** @@ -32031,7 +30990,7 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- var desc = (0, _metal.descriptorForProperty)(proto, key); if (desc && _metal.DEBUG_INJECTION_FUNCTIONS.has(desc._getter)) { - (true && !(type === 'controller' || _metal.DEBUG_INJECTION_FUNCTIONS.get(desc._getter).type !== 'controller') && (0, _debug.assert)("Defining `" + key + "` as an injected controller property on a non-controller (`" + debugContainerKey + "`) is not allowed.", type === 'controller' || _metal.DEBUG_INJECTION_FUNCTIONS.get(desc._getter).type !== 'controller')); + (true && !(type === 'controller' || _metal.DEBUG_INJECTION_FUNCTIONS.get(desc._getter).type !== 'controller') && (0, _debug.assert)(`Defining \`${key}\` as an injected controller property on a non-controller (\`${debugContainerKey}\`) is not allowed.`, type === 'controller' || _metal.DEBUG_INJECTION_FUNCTIONS.get(desc._getter).type !== 'controller')); } } }; @@ -32064,7 +31023,7 @@ define("@ember/-internals/runtime/lib/system/core_object", ["exports", "@ember/- injections[key] = { namespace, source, - specifier: type + ":" + (name || key) + specifier: `${type}:${name || key}` }; } } @@ -32233,7 +31192,7 @@ define("@ember/-internals/runtime/lib/system/object", ["exports", "@ember/-inter } [ASSERT_INIT_WAS_CALLED]() { - (true && !(this[INIT_WAS_CALLED]) && (0, _debug.assert)("You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update " + this + " to call `this._super(...arguments);` from `init`.", this[INIT_WAS_CALLED])); + (true && !(this[INIT_WAS_CALLED]) && (0, _debug.assert)(`You must call \`this._super(...arguments);\` when overriding \`init\` on a framework object. Please update ${this} to call \`this._super(...arguments);\` from \`init\`.`, this[INIT_WAS_CALLED])); } }; @@ -32474,6 +31433,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ _exports.getName = getName; _exports.setName = setName; _exports.toString = toString; + _exports.isObject = isObject; _exports.isProxy = isProxy; _exports.setProxy = setProxy; _exports.isEmberArray = isEmberArray; @@ -32601,7 +31561,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ @final */ - var GUID_KEY = intern("__ember" + Date.now()); + var GUID_KEY = intern(`__ember${Date.now()}`); /** Generates a new guid, optionally saving the guid to the object that you pass in. You will rarely need to use this method. Instead you should @@ -32692,7 +31652,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ // want to require non-enumerability for this API, which // would introduce a large cost. var id = GUID_KEY + Math.floor(Math.random() * Date.now()); - var symbol = intern("__" + debugName + id + "__"); + var symbol = intern(`__${debugName}${id}__`); GENERATED_SYMBOLS.push(symbol); return symbol; } // the delete is meant to hint at runtimes that this object should remain in @@ -32722,7 +31682,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ functionName = match && match[1] || ''; } - return functionName; + return functionName.replace(/^bound /, ''); }; var getObjectName = obj => { @@ -32742,7 +31702,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ if (name && name.match(/<.*:ember\d+>/) && className && className[0] !== '_' && className.length > 2 && className !== 'Class') { - return name.replace(/<.*:/, "<" + className + ":"); + return name.replace(/<.*:/, `<${className}:`); } return name || className; @@ -32754,9 +31714,9 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ getDebugName = value => { if (typeof value === 'function') { - return getFunctionName(value) || "(unknown function)"; + return getFunctionName(value) || `(unknown function)`; } else if (typeof value === 'object' && value !== null) { - return getObjectName(value) || "(unknown object)"; + return getObjectName(value) || `(unknown object)`; } else { return getPrimitiveName(value); } @@ -32951,7 +31911,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ return value.toString(); case 'function': - return value.toString === functionToString ? value.name ? "[Function:" + value.name + "]" : "[Function]" : value.toString(); + return value.toString === functionToString ? value.name ? `[Function:${value.name}]` : `[Function]` : value.toString(); case 'string': return stringify(value); @@ -32966,7 +31926,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ if (seen === undefined) { seen = new _polyfills._WeakSet(); } else { - if (seen.has(value)) return "[Circular]"; + if (seen.has(value)) return `[Circular]`; } seen.add(value); @@ -32989,7 +31949,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ s += i === 0 ? ' ' : ', '; if (i >= LIST_LIMIT) { - s += "... " + (keys.length - LIST_LIMIT) + " more keys"; + s += `... ${keys.length - LIST_LIMIT} more keys`; break; } @@ -33012,7 +31972,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ s += i === 0 ? ' ' : ', '; if (i >= LIST_LIMIT) { - s += "... " + (arr.length - LIST_LIMIT) + " more items"; + s += `... ${arr.length - LIST_LIMIT} more items`; break; } @@ -33244,6 +32204,19 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ var setWithMandatorySetter; _exports.setWithMandatorySetter = setWithMandatorySetter; + function isElementKey(key) { + return typeof key === 'number' ? isPositiveInt(key) : isStringInt(key); + } + + function isStringInt(str) { + var num = parseInt(str, 10); + return isPositiveInt(num) && str === String(num); + } + + function isPositiveInt(num) { + return num >= 0 && num % 1 === 0; + } + if (true /* DEBUG */ ) { @@ -33260,6 +32233,11 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ } SEEN_TAGS.add(tag); + + if (Array.isArray(obj) && isElementKey(keyName)) { + return; + } + var desc = lookupDescriptor(obj, keyName) || {}; if (desc.get || desc.set) { @@ -33297,7 +32275,7 @@ define("@ember/-internals/utils/index", ["exports", "@ember/polyfills", "@ember/ }, set(value) { - (true && !(false) && (0, _debug.assert)("You attempted to update " + this + "." + String(keyName) + " to \"" + String(value) + "\", but it is being tracked by a tracking context, such as a template, computed property, or observer. In order to make sure the context updates properly, you must invalidate the property when updating it. You can mark the property as `@tracked`, or use `@ember/object#set` to do this.")); + (true && !(false) && (0, _debug.assert)(`You attempted to update ${this}.${String(keyName)} to "${String(value)}", but it is being tracked by a tracking context, such as a template, computed property, or observer. In order to make sure the context updates properly, you must invalidate the property when updating it. You can mark the property as \`@tracked\`, or use \`@ember/object#set\` to do this.`)); } }); @@ -33554,12 +32532,12 @@ define("@ember/-internals/views/lib/component_lookup", ["exports", "@ember/-inte var _default = _runtime.Object.extend({ componentFor(name, owner, options) { - var fullName = "component:" + name; + var fullName = `component:${name}`; return owner.factoryFor(fullName, options); }, layoutFor(name, owner, options) { - var templateFullName = "template:components/" + name; + var templateFullName = `template:components/${name}`; return owner.lookup(templateFullName, options); } @@ -33580,7 +32558,7 @@ define("@ember/-internals/views/lib/mixins/action_support", ["exports", "@ember/ */ var mixinObj = { send(actionName, ...args) { - (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)("Attempted to call .send() with the action '" + actionName + "' on the destroyed object '" + this + "'.", !this.isDestroying && !this.isDestroyed)); + (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)(`Attempted to call .send() with the action '${actionName}' on the destroyed object '${this}'.`, !this.isDestroying && !this.isDestroyed)); var action = this.actions && this.actions[actionName]; if (action) { @@ -33594,10 +32572,10 @@ define("@ember/-internals/views/lib/mixins/action_support", ["exports", "@ember/ var target = (0, _metal.get)(this, 'target'); if (target) { - (true && !(typeof target.send === 'function') && (0, _debug.assert)("The `target` for " + this + " (" + target + ") does not have a `send` method", typeof target.send === 'function')); + (true && !(typeof target.send === 'function') && (0, _debug.assert)(`The \`target\` for ${this} (${target}) does not have a \`send\` method`, typeof target.send === 'function')); target.send(...arguments); } else { - (true && !(action) && (0, _debug.assert)((0, _utils.inspect)(this) + " had no action handler for: " + actionName, action)); + (true && !(action) && (0, _debug.assert)(`${(0, _utils.inspect)(this)} had no action handler for: ${actionName}`, action)); } } @@ -33675,8 +32653,8 @@ define("@ember/-internals/views/lib/mixins/action_support", ["exports", "@ember/ @deprecated */ var sendAction = function sendAction(action, ...contexts) { - (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)("Attempted to call .sendAction() with the action '" + action + "' on the destroyed object '" + this + "'.", !this.isDestroying && !this.isDestroyed)); - (true && !(false) && (0, _debug.deprecate)("You called " + (0, _utils.inspect)(this) + ".sendAction(" + (typeof action === 'string' ? "\"" + action + "\"" : '') + ") but Component#sendAction is deprecated. Please use closure actions instead.", false, { + (true && !(!this.isDestroying && !this.isDestroyed) && (0, _debug.assert)(`Attempted to call .sendAction() with the action '${action}' on the destroyed object '${this}'.`, !this.isDestroying && !this.isDestroyed)); + (true && !(false) && (0, _debug.deprecate)(`You called ${(0, _utils.inspect)(this)}.sendAction(${typeof action === 'string' ? `"${action}"` : ''}) but Component#sendAction is deprecated. Please use closure actions instead.`, false, { id: 'ember-component.send-action', until: '4.0.0', url: 'https://emberjs.com/deprecations/v3.x#toc_ember-component-send-action' @@ -33687,7 +32665,7 @@ define("@ember/-internals/views/lib/mixins/action_support", ["exports", "@ember/ action = 'action'; } - actionName = (0, _metal.get)(this, "attrs." + action) || (0, _metal.get)(this, action); + actionName = (0, _metal.get)(this, `attrs.${action}`) || (0, _metal.get)(this, action); actionName = validateAction(this, actionName); // If no action name for that action could be found, just abort. if (actionName === undefined) { @@ -33709,7 +32687,7 @@ define("@ember/-internals/views/lib/mixins/action_support", ["exports", "@ember/ actionName = actionName.value; } - (true && !(actionName === null || actionName === undefined || typeof actionName === 'string' || typeof actionName === 'function') && (0, _debug.assert)("The default action was triggered on the component " + component.toString() + ", but the action name (" + actionName + ") was not a string.", actionName === null || actionName === undefined || typeof actionName === 'string' || typeof actionName === 'function')); + (true && !(actionName === null || actionName === undefined || typeof actionName === 'string' || typeof actionName === 'function') && (0, _debug.assert)(`The default action was triggered on the component ${component.toString()}, but the action name (${actionName}) was not a string.`, actionName === null || actionName === undefined || typeof actionName === 'string' || typeof actionName === 'function')); return actionName; }; @@ -33787,8 +32765,8 @@ define("@ember/-internals/views/lib/mixins/class_names_support", ["exports", "@e init() { this._super(...arguments); - (true && !((0, _metal.descriptorForProperty)(this, 'classNameBindings') === undefined && Array.isArray(this.classNameBindings)) && (0, _debug.assert)("Only arrays are allowed for 'classNameBindings'", (0, _metal.descriptorForProperty)(this, 'classNameBindings') === undefined && Array.isArray(this.classNameBindings))); - (true && !((0, _metal.descriptorForProperty)(this, 'classNames') === undefined && Array.isArray(this.classNames)) && (0, _debug.assert)("Only arrays of static class strings are allowed for 'classNames'. For dynamic classes, use 'classNameBindings'.", (0, _metal.descriptorForProperty)(this, 'classNames') === undefined && Array.isArray(this.classNames))); + (true && !((0, _metal.descriptorForProperty)(this, 'classNameBindings') === undefined && Array.isArray(this.classNameBindings)) && (0, _debug.assert)(`Only arrays are allowed for 'classNameBindings'`, (0, _metal.descriptorForProperty)(this, 'classNameBindings') === undefined && Array.isArray(this.classNameBindings))); + (true && !((0, _metal.descriptorForProperty)(this, 'classNames') === undefined && Array.isArray(this.classNames)) && (0, _debug.assert)(`Only arrays of static class strings are allowed for 'classNames'. For dynamic classes, use 'classNameBindings'.`, (0, _metal.descriptorForProperty)(this, 'classNames') === undefined && Array.isArray(this.classNames))); }, /** @@ -34138,11 +33116,11 @@ define("@ember/-internals/views/lib/mixins/text_support", ["exports", "@ember/-i _exports.default = _default; function sendAction(eventName, view, event) { - var actionName = (0, _metal.get)(view, "attrs." + eventName) || (0, _metal.get)(view, eventName); + var actionName = (0, _metal.get)(view, `attrs.${eventName}`) || (0, _metal.get)(view, eventName); var value = (0, _metal.get)(view, 'value'); if (_deprecatedFeatures.SEND_ACTION && typeof actionName === 'string') { - var message = "Passing actions to components as strings (like ``) is deprecated. Please use closure actions instead (``)."; + var message = `Passing actions to components as strings (like \`\`) is deprecated. Please use closure actions instead (\`\`).`; (true && !(false) && (0, _debug.deprecate)(message, false, { id: 'ember-component.send-action', until: '4.0.0', @@ -34350,7 +33328,7 @@ define("@ember/-internals/views/lib/mixins/view_support", ["exports", "@ember/-i if (_browserEnvironment.hasDOM) { target = typeof selector === 'string' ? document.querySelector(selector) : selector; - (true && !(target) && (0, _debug.assert)("You tried to append to (" + selector + ") but that isn't in the DOM", target)); + (true && !(target) && (0, _debug.assert)(`You tried to append to (${selector}) but that isn't in the DOM`, target)); (true && !(!(0, _utils2.matches)(target, '.ember-view')) && (0, _debug.assert)('You cannot append to an existing Ember.View.', !(0, _utils2.matches)(target, '.ember-view'))); (true && !((() => { var node = target.parentNode; @@ -34379,8 +33357,8 @@ define("@ember/-internals/views/lib/mixins/view_support", ["exports", "@ember/-i })())); } else { target = selector; - (true && !(typeof target !== 'string') && (0, _debug.assert)("You tried to append to a selector string (" + selector + ") in an environment without jQuery", typeof target !== 'string')); - (true && !(typeof selector.appendChild === 'function') && (0, _debug.assert)("You tried to append to a non-Element (" + selector + ") in an environment without jQuery", typeof selector.appendChild === 'function')); + (true && !(typeof target !== 'string') && (0, _debug.assert)(`You tried to append to a selector string (${selector}) in an environment without jQuery`, typeof target !== 'string')); + (true && !(typeof selector.appendChild === 'function') && (0, _debug.assert)(`You tried to append to a non-Element (${selector}) in an environment without jQuery`, typeof selector.appendChild === 'function')); } this.renderer.appendTo(this, target); @@ -34536,9 +33514,9 @@ define("@ember/-internals/views/lib/mixins/view_support", ["exports", "@ember/-i this._super(...arguments); // tslint:disable-next-line:max-line-length - (true && !((0, _metal.descriptorForProperty)(this, 'elementId') === undefined) && (0, _debug.assert)("You cannot use a computed property for the component's `elementId` (" + this + ").", (0, _metal.descriptorForProperty)(this, 'elementId') === undefined)); // tslint:disable-next-line:max-line-length + (true && !((0, _metal.descriptorForProperty)(this, 'elementId') === undefined) && (0, _debug.assert)(`You cannot use a computed property for the component's \`elementId\` (${this}).`, (0, _metal.descriptorForProperty)(this, 'elementId') === undefined)); // tslint:disable-next-line:max-line-length - (true && !((0, _metal.descriptorForProperty)(this, 'tagName') === undefined) && (0, _debug.assert)("You cannot use a computed property for the component's `tagName` (" + this + ").", (0, _metal.descriptorForProperty)(this, 'tagName') === undefined)); + (true && !((0, _metal.descriptorForProperty)(this, 'tagName') === undefined) && (0, _debug.assert)(`You cannot use a computed property for the component's \`tagName\` (${this}).`, (0, _metal.descriptorForProperty)(this, 'tagName') === undefined)); if (!this.elementId && this.tagName !== '') { this.elementId = (0, _utils.guidFor)(this); @@ -34637,7 +33615,7 @@ define("@ember/-internals/views/lib/system/event_dispatcher", ["exports", "@embe @module ember */ var ROOT_ELEMENT_CLASS = 'ember-application'; - var ROOT_ELEMENT_SELECTOR = "." + ROOT_ELEMENT_CLASS; + var ROOT_ELEMENT_SELECTOR = `.${ROOT_ELEMENT_CLASS}`; var EVENT_MAP = { mouseenter: 'mouseover', mouseleave: 'mouseout' @@ -34768,7 +33746,7 @@ define("@ember/-internals/views/lib/system/event_dispatcher", ["exports", "@embe rootElement = document.querySelector(rootElementSelector); } - (true && !(!rootElement.classList.contains(ROOT_ELEMENT_CLASS)) && (0, _debug.assert)("You cannot use the same root element (" + ((0, _metal.get)(this, 'rootElement') || rootElement.tagName) + ") multiple times in an Ember.Application", !rootElement.classList.contains(ROOT_ELEMENT_CLASS))); + (true && !(!rootElement.classList.contains(ROOT_ELEMENT_CLASS)) && (0, _debug.assert)(`You cannot use the same root element (${(0, _metal.get)(this, 'rootElement') || rootElement.tagName}) multiple times in an Ember.Application`, !rootElement.classList.contains(ROOT_ELEMENT_CLASS))); (true && !((() => { var target = rootElement.parentNode; @@ -34796,16 +33774,16 @@ define("@ember/-internals/views/lib/system/event_dispatcher", ["exports", "@embe })())); (true && !(!rootElement.querySelector(ROOT_ELEMENT_SELECTOR)) && (0, _debug.assert)('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.querySelector(ROOT_ELEMENT_SELECTOR))); rootElement.classList.add(ROOT_ELEMENT_CLASS); - (true && !(rootElement.classList.contains(ROOT_ELEMENT_CLASS)) && (0, _debug.assert)("Unable to add '" + ROOT_ELEMENT_CLASS + "' class to root element (" + ((0, _metal.get)(this, 'rootElement') || rootElement.tagName) + "). Make sure you set rootElement to the body or an element in the body.", rootElement.classList.contains(ROOT_ELEMENT_CLASS))); + (true && !(rootElement.classList.contains(ROOT_ELEMENT_CLASS)) && (0, _debug.assert)(`Unable to add '${ROOT_ELEMENT_CLASS}' class to root element (${(0, _metal.get)(this, 'rootElement') || rootElement.tagName}). Make sure you set rootElement to the body or an element in the body.`, rootElement.classList.contains(ROOT_ELEMENT_CLASS))); } else { rootElement = (0, _jquery.jQuery)(rootElementSelector); - (true && !(!rootElement.is(ROOT_ELEMENT_SELECTOR)) && (0, _debug.assert)("You cannot use the same root element (" + (rootElement.selector || rootElement[0].tagName) + ") multiple times in an Ember.Application", !rootElement.is(ROOT_ELEMENT_SELECTOR))); + (true && !(!rootElement.is(ROOT_ELEMENT_SELECTOR)) && (0, _debug.assert)(`You cannot use the same root element (${rootElement.selector || rootElement[0].tagName}) multiple times in an Ember.Application`, !rootElement.is(ROOT_ELEMENT_SELECTOR))); (true && !(!rootElement.closest(ROOT_ELEMENT_SELECTOR).length) && (0, _debug.assert)('You cannot make a new Ember.Application using a root element that is a descendent of an existing Ember.Application', !rootElement.closest(ROOT_ELEMENT_SELECTOR).length)); (true && !(!rootElement.find(ROOT_ELEMENT_SELECTOR).length) && (0, _debug.assert)('You cannot make a new Ember.Application using a root element that is an ancestor of an existing Ember.Application', !rootElement.find(ROOT_ELEMENT_SELECTOR).length)); rootElement.addClass(ROOT_ELEMENT_CLASS); if (!rootElement.is(ROOT_ELEMENT_SELECTOR)) { - throw new TypeError("Unable to add '" + ROOT_ELEMENT_CLASS + "' class to root element (" + (rootElement.selector || rootElement[0].tagName) + "). Make sure you set rootElement to the body or an element in the body."); + throw new TypeError(`Unable to add '${ROOT_ELEMENT_CLASS}' class to root element (${rootElement.selector || rootElement[0].tagName}). Make sure you set rootElement to the body or an element in the body.`); } } @@ -34951,7 +33929,7 @@ define("@ember/-internals/views/lib/system/event_dispatcher", ["exports", "@embe rootElement.addEventListener(event, handleEvent); } } else { - rootElement.on(event + ".ember", '.ember-view', function (evt) { + rootElement.on(`${event}.ember`, '.ember-view', function (evt) { var view = (0, _views.getElementView)(this); var result = true; @@ -34961,7 +33939,7 @@ define("@ember/-internals/views/lib/system/event_dispatcher", ["exports", "@embe return result; }); - rootElement.on(event + ".ember", '[data-ember-action]', evt => { + rootElement.on(`${event}.ember`, '[data-ember-action]', evt => { var attributes = evt.currentTarget.attributes; var handledActions = []; evt = (0, _jquery_event_deprecation.default)(evt); @@ -35406,7 +34384,7 @@ define("@ember/-internals/views/lib/views/core_view", ["exports", "@ember/-inter this._currentState = this._states.preRender; if (!this.renderer) { - throw new Error("Cannot instantiate a component without a renderer. Please ensure that you are creating " + this + " with a proper container/registry."); + throw new Error(`Cannot instantiate a component without a renderer. Please ensure that you are creating ${this} with a proper container/registry.`); } }, @@ -35559,7 +34537,7 @@ define("@ember/-internals/views/lib/views/states/has_element", ["exports", "@emb if (view.has(eventName)) { // Handler should be able to re-dispatch events, so we don't // preventDefault or stopPropagation. - return (0, _instrumentation.flaggedInstrument)("interaction." + eventName, { + return (0, _instrumentation.flaggedInstrument)(`interaction.${eventName}`, { event, view }, () => { @@ -35608,10 +34586,6 @@ define("@ember/-internals/views/lib/views/states/in_dom", ["exports", "@ember/-i }); } - }, - - exit(view) { - view.renderer.unregister(view); } }); @@ -35744,7 +34718,7 @@ define("@ember/application/globals-resolver", ["exports", "@ember/-internals/uti if (type !== 'template') { var result = name.replace(/(\.|_|-)./g, m => m.charAt(1).toUpperCase()); - return type + ":" + result; + return `${type}:${result}`; } else { return fullName; } @@ -35789,7 +34763,7 @@ define("@ember/application/globals-resolver", ["exports", "@ember/-internals/uti if (validationAttributes) { var [factoryFlag, expectedType] = validationAttributes; - (true && !(Boolean(resolved[factoryFlag])) && (0, _debug.assert)("Expected " + parsedName.fullName + " to resolve to an " + expectedType + " but " + ("instead it was " + resolved + "."), Boolean(resolved[factoryFlag]))); + (true && !(Boolean(resolved[factoryFlag])) && (0, _debug.assert)(`Expected ${parsedName.fullName} to resolve to an ${expectedType} but ` + `instead it was ${resolved}.`, Boolean(resolved[factoryFlag]))); } } } @@ -35823,13 +34797,13 @@ define("@ember/application/globals-resolver", ["exports", "@ember/-internals/uti name = parts[parts.length - 1]; var namespaceName = (0, _string.capitalize)(parts.slice(0, -1).join('.')); root = (0, _metal.findNamespace)(namespaceName); - (true && !(root) && (0, _debug.assert)("You are looking for a " + name + " " + type + " in the " + namespaceName + " namespace, but the namespace could not be found", root)); + (true && !(root) && (0, _debug.assert)(`You are looking for a ${name} ${type} in the ${namespaceName} namespace, but the namespace could not be found`, root)); } var resolveMethodName = fullNameWithoutType === 'main' ? 'Main' : (0, _string.classify)(type); if (!(name && type)) { - throw new TypeError("Invalid fullName: `" + fullName + "`, must be of the form `type:name` "); + throw new TypeError(`Invalid fullName: \`${fullName}\`, must be of the form \`type:name\` `); } return { @@ -35839,7 +34813,7 @@ define("@ember/application/globals-resolver", ["exports", "@ember/-internals/uti dirname, name, root, - resolveMethodName: "resolve" + resolveMethodName + resolveMethodName: `resolve${resolveMethodName}` }; } /** @@ -35858,10 +34832,10 @@ define("@ember/application/globals-resolver", ["exports", "@ember/-internals/uti var description; if (parsedName.type === 'template') { - return "template at " + parsedName.fullNameWithoutType.replace(/\./g, '/'); + return `template at ${parsedName.fullNameWithoutType.replace(/\./g, '/')}`; } - description = parsedName.root + "." + (0, _string.classify)(parsedName.name).replace(/\./g, ''); + description = `${parsedName.root}.${(0, _string.classify)(parsedName.name).replace(/\./g, '')}`; if (parsedName.type !== 'model') { description += (0, _string.classify)(parsedName.type); @@ -36000,7 +34974,7 @@ define("@ember/application/globals-resolver", ["exports", "@ember/-internals/uti knownForType(type) { var namespace = (0, _metal.get)(this, 'namespace'); var suffix = (0, _string.classify)(type); - var typeRegexp = new RegExp(suffix + "$"); + var typeRegexp = new RegExp(`${suffix}$`); var known = (0, _utils.dictionary)(null); var knownKeys = Object.keys(namespace); @@ -36031,7 +35005,7 @@ define("@ember/application/globals-resolver", ["exports", "@ember/-internals/uti var suffix = (0, _string.classify)(type); var namePrefix = name.slice(0, suffix.length * -1); var dasherizedName = (0, _string.dasherize)(namePrefix); - return type + ":" + dasherizedName; + return `${type}:${dasherizedName}`; } }; @@ -36593,7 +35567,7 @@ define("@ember/application/instance", ["exports", "@ember/polyfills", "@ember/-i var _default = ApplicationInstance; _exports.default = _default; }); -define("@ember/application/lib/application", ["exports", "ember-babel", "@ember/-internals/utils", "@ember/-internals/environment", "@ember/-internals/browser-environment", "@ember/debug", "@ember/runloop", "@ember/-internals/metal", "@ember/application/lib/lazy_load", "@ember/-internals/runtime", "@ember/-internals/views", "@ember/-internals/routing", "@ember/application/instance", "@ember/engine", "@ember/-internals/container", "@ember/-internals/glimmer", "@ember/deprecated-features"], function (_exports, _emberBabel, _utils, _environment, _browserEnvironment, _debug, _runloop, _metal, _lazy_load, _runtime, _views, _routing, _instance, _engine, _container, _glimmer, _deprecatedFeatures) { +define("@ember/application/lib/application", ["exports", "@ember/-internals/utils", "@ember/-internals/environment", "@ember/-internals/browser-environment", "@ember/debug", "@ember/runloop", "@ember/-internals/metal", "@ember/application/lib/lazy_load", "@ember/-internals/runtime", "@ember/-internals/views", "@ember/-internals/routing", "@ember/application/instance", "@ember/engine", "@ember/-internals/container", "@ember/-internals/glimmer", "@ember/deprecated-features"], function (_exports, _utils, _environment, _browserEnvironment, _debug, _runloop, _metal, _lazy_load, _runtime, _views, _routing, _instance, _engine, _container, _glimmer, _deprecatedFeatures) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -36601,16 +35575,9 @@ define("@ember/application/lib/application", ["exports", "ember-babel", "@ember/ }); _exports.default = void 0; - function _templateObject() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["-bucket-cache:main"]); - - _templateObject = function () { - return data; - }; - - return data; - } - + /** + @module @ember/application + */ var librariesRegistered = false; /** An instance of `Application` is the starting point for every Ember @@ -37225,7 +36192,10 @@ define("@ember/application/lib/application", ["exports", "ember-babel", "@ember/ @public */ reset() { - (true && !(this._globalsMode && this.autoboot) && (0, _debug.assert)("Calling reset() on instances of `Application` is not\n supported when globals mode is disabled; call `visit()` to\n create new `ApplicationInstance`s and dispose them\n via their `destroy()` method instead.", this._globalsMode && this.autoboot)); + (true && !(this._globalsMode && this.autoboot) && (0, _debug.assert)(`Calling reset() on instances of \`Application\` is not + supported when globals mode is disabled; call \`visit()\` to + create new \`ApplicationInstance\`s and dispose them + via their \`destroy()\` method instead.`, this._globalsMode && this.autoboot)); var instance = this.__deprecatedInstance__; this._readinessDeferrals = 1; this._bootPromise = null; @@ -37536,7 +36506,7 @@ define("@ember/application/lib/application", ["exports", "ember-babel", "@ember/ registry.register('location:hash', _routing.HashLocation); registry.register('location:history', _routing.HistoryLocation); registry.register('location:none', _routing.NoneLocation); - registry.register((0, _container.privatize)(_templateObject()), { + registry.register(_container.privatize`-bucket-cache:main`, { create() { return new _routing.BucketCache(); } @@ -37648,7 +36618,7 @@ define("@ember/canary-features/index", ["exports", "@ember/-internals/environmen value: true }); _exports.isEnabled = isEnabled; - _exports.EMBER_ROUTING_MODEL_ARG = _exports.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = _exports.EMBER_CUSTOM_COMPONENT_ARG_PROXY = _exports.EMBER_MODULE_UNIFICATION = _exports.EMBER_IMPROVED_INSTRUMENTATION = _exports.EMBER_LIBRARIES_ISREGISTERED = _exports.FEATURES = _exports.DEFAULT_FEATURES = void 0; + _exports.EMBER_ROUTING_MODEL_ARG = _exports.EMBER_GLIMMER_SET_COMPONENT_TEMPLATE = _exports.EMBER_CUSTOM_COMPONENT_ARG_PROXY = _exports.EMBER_MODULE_UNIFICATION = _exports.EMBER_NAMED_BLOCKS = _exports.EMBER_IMPROVED_INSTRUMENTATION = _exports.EMBER_LIBRARIES_ISREGISTERED = _exports.FEATURES = _exports.DEFAULT_FEATURES = void 0; /** Set `EmberENV.FEATURES` in your application's `config/environment.js` file @@ -37663,6 +36633,7 @@ define("@ember/canary-features/index", ["exports", "@ember/-internals/environmen var DEFAULT_FEATURES = { EMBER_LIBRARIES_ISREGISTERED: false, EMBER_IMPROVED_INSTRUMENTATION: false, + EMBER_NAMED_BLOCKS: false, EMBER_MODULE_UNIFICATION: false, EMBER_CUSTOM_COMPONENT_ARG_PROXY: true, EMBER_GLIMMER_SET_COMPONENT_TEMPLATE: true, @@ -37722,6 +36693,8 @@ define("@ember/canary-features/index", ["exports", "@ember/-internals/environmen _exports.EMBER_LIBRARIES_ISREGISTERED = EMBER_LIBRARIES_ISREGISTERED; var EMBER_IMPROVED_INSTRUMENTATION = featureValue(FEATURES.EMBER_IMPROVED_INSTRUMENTATION); _exports.EMBER_IMPROVED_INSTRUMENTATION = EMBER_IMPROVED_INSTRUMENTATION; + var EMBER_NAMED_BLOCKS = featureValue(FEATURES.EMBER_NAMED_BLOCKS); + _exports.EMBER_NAMED_BLOCKS = EMBER_NAMED_BLOCKS; var EMBER_MODULE_UNIFICATION = featureValue(FEATURES.EMBER_MODULE_UNIFICATION); _exports.EMBER_MODULE_UNIFICATION = EMBER_MODULE_UNIFICATION; var EMBER_CUSTOM_COMPONENT_ARG_PROXY = featureValue(FEATURES.EMBER_CUSTOM_COMPONENT_ARG_PROXY); @@ -38107,7 +37080,7 @@ define("@ember/debug/index", ["exports", "@ember/-internals/browser-environment" */ setDebugFunction('assert', function assert(desc, test) { if (!test) { - throw new _error.default("Assertion Failed: " + desc); + throw new _error.default(`Assertion Failed: ${desc}`); } }); /** @@ -38129,9 +37102,9 @@ define("@ember/debug/index", ["exports", "@ember/-internals/browser-environment" setDebugFunction('debug', function debug(message) { /* eslint-disable no-console */ if (console.debug) { - console.debug("DEBUG: " + message); + console.debug(`DEBUG: ${message}`); } else { - console.log("DEBUG: " + message); + console.log(`DEBUG: ${message}`); } /* eslint-ensable no-console */ @@ -38256,7 +37229,7 @@ define("@ember/debug/index", ["exports", "@ember/-internals/browser-environment" downloadURL = 'https://addons.mozilla.org/en-US/firefox/addon/ember-inspector/'; } - debug("For more advanced debugging, install the Ember Inspector from " + downloadURL); + debug(`For more advanced debugging, install the Ember Inspector from ${downloadURL}`); } }, false); } @@ -38288,8 +37261,10 @@ define("@ember/debug/lib/capture-render-tree", ["exports", "@glimmer/util"], fun @since 3.14.0 */ function captureRenderTree(app) { - var env = (0, _util.expect)(app.lookup('service:-glimmer-environment'), 'BUG: owner is missing service:-glimmer-environment'); - return env.debugRenderTree.capture(); + var env = (0, _util.expect)(app.lookup('-environment:main'), 'BUG: owner is missing -environment:main'); + var rendererType = env.isInteractive ? 'renderer:-dom' : 'renderer:-inert'; + var renderer = (0, _util.expect)(app.lookup(rendererType), `BUG: owner is missing ${rendererType}`); + return renderer.debugRenderTree.capture(); } }); define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment", "@ember/debug/index", "@ember/debug/lib/handlers"], function (_exports, _environment, _index, _handlers) { @@ -38366,11 +37341,11 @@ define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment" var message = _message; if (options && options.id) { - message = message + (" [deprecation id: " + options.id + "]"); + message = message + ` [deprecation id: ${options.id}]`; } if (options && options.url) { - message += " See " + options.url + " for more details."; + message += ` See ${options.url} for more details.`; } return message; @@ -38378,7 +37353,7 @@ define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment" registerHandler(function logDeprecationToConsole(message, options) { var updatedMessage = formatMessage(message, options); - console.warn("DEPRECATION: " + updatedMessage); // eslint-disable-line no-console + console.warn(`DEPRECATION: ${updatedMessage}`); // eslint-disable-line no-console }); var captureErrorForStack; @@ -38410,11 +37385,11 @@ define("@ember/debug/lib/deprecate", ["exports", "@ember/-internals/environment" stack = error.stack.replace(/(?:\n@:0)?\s+$/m, '').replace(/^\(/gm, '{anonymous}(').split('\n'); } - stackStr = "\n " + stack.slice(2).join('\n '); + stackStr = `\n ${stack.slice(2).join('\n ')}`; } var updatedMessage = formatMessage(message, options); - console.warn("DEPRECATION: " + updatedMessage + stackStr); // eslint-disable-line no-console + console.warn(`DEPRECATION: ${updatedMessage}${stackStr}`); // eslint-disable-line no-console } else { next(message, options); } @@ -38587,7 +37562,7 @@ define("@ember/debug/lib/warn", ["exports", "@ember/debug/index", "@ember/debug/ registerHandler(function logWarning(message) { /* eslint-disable no-console */ - console.warn("WARNING: " + message); + console.warn(`WARNING: ${message}`); /* eslint-enable no-console */ }); _exports.missingOptionsDeprecation = missingOptionsDeprecation = 'When calling `warn` you ' + 'must provide an `options` hash as the third parameter. ' + '`options` should include an `id` property.'; @@ -38673,7 +37648,7 @@ define("@ember/deprecated-features/index", ["exports"], function (_exports) { var GLOBALS_RESOLVER = !!'3.16.0-beta.1'; _exports.GLOBALS_RESOLVER = GLOBALS_RESOLVER; }); -define("@ember/engine/index", ["exports", "ember-babel", "@ember/engine/lib/engine-parent", "@ember/-internals/utils", "@ember/controller", "@ember/-internals/runtime", "@ember/-internals/container", "dag-map", "@ember/debug", "@ember/-internals/metal", "@ember/application/globals-resolver", "@ember/engine/instance", "@ember/-internals/routing", "@ember/-internals/extension-support", "@ember/-internals/views", "@ember/-internals/glimmer"], function (_exports, _emberBabel, _engineParent, _utils, _controller, _runtime, _container, _dagMap, _debug, _metal, _globalsResolver, _instance, _routing, _extensionSupport, _views, _glimmer) { +define("@ember/engine/index", ["exports", "@ember/engine/lib/engine-parent", "@ember/-internals/utils", "@ember/controller", "@ember/-internals/runtime", "@ember/-internals/container", "dag-map", "@ember/debug", "@ember/-internals/metal", "@ember/application/globals-resolver", "@ember/engine/instance", "@ember/-internals/routing", "@ember/-internals/extension-support", "@ember/-internals/views", "@ember/-internals/glimmer"], function (_exports, _engineParent, _utils, _controller, _runtime, _container, _dagMap, _debug, _metal, _globalsResolver, _instance, _routing, _extensionSupport, _views, _glimmer) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -38693,26 +37668,6 @@ define("@ember/engine/index", ["exports", "ember-babel", "@ember/engine/lib/engi }); _exports.default = void 0; - function _templateObject2() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["-bucket-cache:main"]); - - _templateObject2 = function () { - return data; - }; - - return data; - } - - function _templateObject() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["-bucket-cache:main"]); - - _templateObject = function () { - return data; - }; - - return data; - } - function props(obj) { var properties = []; @@ -38815,7 +37770,7 @@ define("@ember/engine/index", ["exports", "ember-babel", "@ember/engine/lib/engi */ runInitializers() { this._runInitializer('initializers', (name, initializer) => { - (true && !(Boolean(initializer)) && (0, _debug.assert)("No application initializer named '" + name + "'", Boolean(initializer))); + (true && !(Boolean(initializer)) && (0, _debug.assert)(`No application initializer named '${name}'`, Boolean(initializer))); initializer.initialize(this); }); }, @@ -38827,7 +37782,7 @@ define("@ember/engine/index", ["exports", "ember-babel", "@ember/engine/lib/engi */ runInstanceInitializers(instance) { this._runInitializer('instanceInitializers', (name, initializer) => { - (true && !(Boolean(initializer)) && (0, _debug.assert)("No instance initializer named '" + name + "'", Boolean(initializer))); + (true && !(Boolean(initializer)) && (0, _debug.assert)(`No instance initializer named '${name}'`, Boolean(initializer))); initializer.initialize(instance); }); }, @@ -39112,9 +38067,9 @@ define("@ember/engine/index", ["exports", "ember-babel", "@ember/engine/lib/engi this.reopenClass(attrs); } - (true && !(!this[bucketName][initializer.name]) && (0, _debug.assert)("The " + humanName + " '" + initializer.name + "' has already been registered", !this[bucketName][initializer.name])); - (true && !((0, _utils.canInvoke)(initializer, 'initialize')) && (0, _debug.assert)("An " + humanName + " cannot be registered without an initialize function", (0, _utils.canInvoke)(initializer, 'initialize'))); - (true && !(initializer.name !== undefined) && (0, _debug.assert)("An " + humanName + " cannot be registered without a name property", initializer.name !== undefined)); + (true && !(!this[bucketName][initializer.name]) && (0, _debug.assert)(`The ${humanName} '${initializer.name}' has already been registered`, !this[bucketName][initializer.name])); + (true && !((0, _utils.canInvoke)(initializer, 'initialize')) && (0, _debug.assert)(`An ${humanName} cannot be registered without an initialize function`, (0, _utils.canInvoke)(initializer, 'initialize'))); + (true && !(initializer.name !== undefined) && (0, _debug.assert)(`An ${humanName} cannot be registered without a name property`, initializer.name !== undefined)); this[bucketName][initializer.name] = initializer; }; } @@ -39135,8 +38090,8 @@ define("@ember/engine/index", ["exports", "ember-babel", "@ember/engine/lib/engi registry.injection('view:-outlet', 'namespace', 'application:main'); registry.injection('controller', 'target', 'router:main'); registry.injection('controller', 'namespace', 'application:main'); - registry.injection('router', '_bucketCache', (0, _container.privatize)(_templateObject())); - registry.injection('route', '_bucketCache', (0, _container.privatize)(_templateObject2())); + registry.injection('router', '_bucketCache', _container.privatize`-bucket-cache:main`); + registry.injection('route', '_bucketCache', _container.privatize`-bucket-cache:main`); registry.injection('route', '_router', 'router:main'); // Register the routing service... registry.register('service:-routing', _routing.RoutingService); // Then inject the app router into it @@ -39156,7 +38111,7 @@ define("@ember/engine/index", ["exports", "ember-babel", "@ember/engine/lib/engi var _default = Engine; _exports.default = _default; }); -define("@ember/engine/instance", ["exports", "ember-babel", "@ember/-internals/utils", "@ember/-internals/runtime", "@ember/debug", "@ember/error", "@ember/-internals/container", "@ember/engine/lib/engine-parent"], function (_exports, _emberBabel, _utils, _runtime, _debug, _error, _container, _engineParent) { +define("@ember/engine/instance", ["exports", "@ember/-internals/runtime", "@ember/debug", "@ember/error", "@ember/-internals/container", "@ember/-internals/utils", "@ember/engine/lib/engine-parent"], function (_exports, _runtime, _debug, _error, _container, _utils, _engineParent) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -39164,25 +38119,9 @@ define("@ember/engine/instance", ["exports", "ember-babel", "@ember/-internals/u }); _exports.default = void 0; - function _templateObject2() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["template-compiler:main"]); - - _templateObject2 = function () { - return data; - }; - - return data; - } - - function _templateObject() { - var data = (0, _emberBabel.taggedTemplateLiteralLoose)(["-bucket-cache:main"]); - - _templateObject = function () { - return data; - }; - - return data; - } + /** + @module @ember/engine + */ /** The `EngineInstance` encapsulates all of the stateful aspects of a @@ -39203,7 +38142,8 @@ define("@ember/engine/instance", ["exports", "ember-babel", "@ember/-internals/u base: null, init() { - this._super(...arguments); + this._super(...arguments); // Ensure the guid gets setup for this instance + (0, _utils.guidFor)(this); var base = this.base; @@ -39298,10 +38238,10 @@ define("@ember/engine/instance", ["exports", "ember-babel", "@ember/-internals/u @return {EngineInstance,Error} */ buildChildEngineInstance(name, options = {}) { - var Engine = this.lookup("engine:" + name); + var Engine = this.lookup(`engine:${name}`); if (!Engine) { - throw new _error.default("You attempted to mount the engine '" + name + "', but it is not registered with its parent."); + throw new _error.default(`You attempted to mount the engine '${name}', but it is not registered with its parent.`); } var engineInstance = Engine.buildInstance(options); @@ -39316,13 +38256,13 @@ define("@ember/engine/instance", ["exports", "ember-babel", "@ember/-internals/u */ cloneParentDependencies() { var parent = (0, _engineParent.getEngineParent)(this); - var registrations = ['route:basic', 'service:-routing', 'service:-glimmer-environment']; + var registrations = ['route:basic', 'service:-routing']; registrations.forEach(key => this.register(key, parent.resolveRegistration(key))); var env = parent.lookup('-environment:main'); this.register('-environment:main', env, { instantiate: false }); - var singletons = ['router:main', (0, _container.privatize)(_templateObject()), '-view-registry:main', "renderer:-" + (env.isInteractive ? 'dom' : 'inert'), 'service:-document', (0, _container.privatize)(_templateObject2())]; + var singletons = ['router:main', _container.privatize`-bucket-cache:main`, '-view-registry:main', `renderer:-${env.isInteractive ? 'dom' : 'inert'}`, 'service:-document']; if (env.isInteractive) { singletons.push('event_dispatcher:main'); @@ -39611,7 +38551,7 @@ define("@ember/instrumentation/index", ["exports", "@ember/-internals/environmen var timeName; if (STRUCTURED_PROFILE) { - timeName = name + ": " + payload.object; + timeName = `${name}: ${payload.object}`; console.time(timeName); } @@ -39670,10 +38610,10 @@ define("@ember/instrumentation/index", ["exports", "@ember/-internals/environmen } var regex = regexes.join('\\.'); - regex = regex + "(\\..*)?"; + regex = `${regex}(\\..*)?`; var subscriber = { pattern, - regex: new RegExp("^" + regex + "$"), + regex: new RegExp(`^${regex}$`), object }; subscribers.push(subscriber); @@ -39738,7 +38678,7 @@ define("@ember/modifier/index", ["exports", "@ember/-internals/glimmer"], functi } }); }); -define("@ember/object/compat", ["exports", "@ember/-internals/metal", "@ember/debug", "@glimmer/reference"], function (_exports, _metal, _debug, _reference) { +define("@ember/object/compat", ["exports", "@ember/-internals/metal", "@ember/debug", "@glimmer/validator"], function (_exports, _metal, _debug, _validator) { "use strict"; Object.defineProperty(_exports, "__esModule", { @@ -39755,11 +38695,11 @@ define("@ember/object/compat", ["exports", "@ember/-internals/metal", "@ember/de desc.get = function () { var propertyTag = (0, _metal.tagForProperty)(this, key); var ret; - var tag = (0, _metal.track)(() => { + var tag = (0, _validator.track)(() => { ret = originalGet.call(this); }); - (0, _reference.update)(propertyTag, tag); - (0, _metal.consume)(tag); + (0, _validator.update)(propertyTag, tag); + (0, _validator.consume)(tag); return ret; }; } @@ -40187,7 +39127,7 @@ define("@ember/object/lib/computed/computed_macros", ["exports", "@ember/-intern for (var i = 0; i < properties.length; i++) { var property = properties[i]; - (true && !(property.indexOf(' ') < 0) && (0, _debug.assert)("Dependent keys passed to computed." + predicateName + "() can't have spaces.", property.indexOf(' ') < 0)); + (true && !(property.indexOf(' ') < 0) && (0, _debug.assert)(`Dependent keys passed to computed.${predicateName}() can\'t have spaces.`, property.indexOf(' ') < 0)); (0, _metal.expandProperties)(property, extractProperty); } @@ -40196,7 +39136,7 @@ define("@ember/object/lib/computed/computed_macros", ["exports", "@ember/-intern function generateComputedWithPredicate(name, predicate) { return (...properties) => { - (true && !(!(0, _metal.isElementDescriptor)(properties)) && (0, _debug.assert)("You attempted to use @" + name + " as a decorator directly, but it requires at least one dependent key parameter", !(0, _metal.isElementDescriptor)(properties))); + (true && !(!(0, _metal.isElementDescriptor)(properties)) && (0, _debug.assert)(`You attempted to use @${name} as a decorator directly, but it requires at least one dependent key parameter`, !(0, _metal.isElementDescriptor)(properties))); var dependentKeys = expandPropertiesToArray(name, properties); var computedFunc = (0, _metal.computed)(...dependentKeys, function () { var lastIdx = dependentKeys.length - 1; @@ -40275,7 +39215,7 @@ define("@ember/object/lib/computed/computed_macros", ["exports", "@ember/-intern function empty(dependentKey) { (true && !(!(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments))) && (0, _debug.assert)('You attempted to use @empty as a decorator directly, but it requires a `dependentKey` parameter', !(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments)))); - return (0, _metal.computed)(dependentKey + ".length", function () { + return (0, _metal.computed)(`${dependentKey}.length`, function () { return (0, _metal.isEmpty)((0, _metal.get)(this, dependentKey)); }); } @@ -40337,7 +39277,7 @@ define("@ember/object/lib/computed/computed_macros", ["exports", "@ember/-intern function notEmpty(dependentKey) { (true && !(!(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments))) && (0, _debug.assert)('You attempted to use @notEmpty as a decorator directly, but it requires a `dependentKey` parameter', !(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments)))); - return (0, _metal.computed)(dependentKey + ".length", function () { + return (0, _metal.computed)(`${dependentKey}.length`, function () { return !(0, _metal.isEmpty)((0, _metal.get)(this, dependentKey)); }); } @@ -41327,12 +40267,12 @@ define("@ember/object/lib/computed/computed_macros", ["exports", "@ember/-intern (true && !(!(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments))) && (0, _debug.assert)('You attempted to use @deprecatingAlias as a decorator directly, but it requires `dependentKey` and `options` parameters', !(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments)))); return (0, _metal.computed)(dependentKey, { get(key) { - (true && !(false) && (0, _debug.deprecate)("Usage of `" + key + "` is deprecated, use `" + dependentKey + "` instead.", false, options)); + (true && !(false) && (0, _debug.deprecate)(`Usage of \`${key}\` is deprecated, use \`${dependentKey}\` instead.`, false, options)); return (0, _metal.get)(this, dependentKey); }, set(key, value) { - (true && !(false) && (0, _debug.deprecate)("Usage of `" + key + "` is deprecated, use `" + dependentKey + "` instead.", false, options)); + (true && !(false) && (0, _debug.deprecate)(`Usage of \`${key}\` is deprecated, use \`${dependentKey}\` instead.`, false, options)); (0, _metal.set)(this, dependentKey, value); return value; } @@ -41365,8 +40305,8 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ @module @ember/object */ function reduceMacro(dependentKey, callback, initialValue, name) { - (true && !(!/[\[\]\{\}]/g.test(dependentKey)) && (0, _debug.assert)("Dependent key passed to `computed." + name + "` shouldn't contain brace expanding pattern.", !/[\[\]\{\}]/g.test(dependentKey))); - return (0, _metal.computed)(dependentKey + ".[]", function () { + (true && !(!/[\[\]\{\}]/g.test(dependentKey)) && (0, _debug.assert)(`Dependent key passed to \`computed.${name}\` shouldn't contain brace expanding pattern.`, !/[\[\]\{\}]/g.test(dependentKey))); + return (0, _metal.computed)(`${dependentKey}.[]`, function () { var arr = (0, _metal.get)(this, dependentKey); if (arr === null || typeof arr !== 'object') { @@ -41400,9 +40340,9 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ } function multiArrayMacro(_dependentKeys, callback, name) { - (true && !(_dependentKeys.every(dependentKey => !/[\[\]\{\}]/g.test(dependentKey))) && (0, _debug.assert)("Dependent keys passed to `computed." + name + "` shouldn't contain brace expanding pattern.", _dependentKeys.every(dependentKey => !/[\[\]\{\}]/g.test(dependentKey)))); + (true && !(_dependentKeys.every(dependentKey => !/[\[\]\{\}]/g.test(dependentKey))) && (0, _debug.assert)(`Dependent keys passed to \`computed.${name}\` shouldn't contain brace expanding pattern.`, _dependentKeys.every(dependentKey => !/[\[\]\{\}]/g.test(dependentKey)))); - var dependentKeys = _dependentKeys.map(key => key + ".[]"); + var dependentKeys = _dependentKeys.map(key => `${key}.[]`); return (0, _metal.computed)(...dependentKeys, function () { return (0, _runtime.A)(callback.call(this, _dependentKeys)); @@ -41850,8 +40790,8 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ function mapBy(dependentKey, propertyKey) { (true && !(!(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments))) && (0, _debug.assert)('You attempted to use @mapBy as a decorator directly, but it requires `dependentKey` and `propertyKey` parameters', !(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments)))); (true && !(typeof propertyKey === 'string') && (0, _debug.assert)('`computed.mapBy` expects a property string for its second argument, ' + 'perhaps you meant to use "map"', typeof propertyKey === 'string')); - (true && !(!/[\[\]\{\}]/g.test(dependentKey)) && (0, _debug.assert)("Dependent key passed to `computed.mapBy` shouldn't contain brace expanding pattern.", !/[\[\]\{\}]/g.test(dependentKey))); - return map(dependentKey + ".@each." + propertyKey, item => (0, _metal.get)(item, propertyKey)); + (true && !(!/[\[\]\{\}]/g.test(dependentKey)) && (0, _debug.assert)(`Dependent key passed to \`computed.mapBy\` shouldn't contain brace expanding pattern.`, !/[\[\]\{\}]/g.test(dependentKey))); + return map(`${dependentKey}.@each.${propertyKey}`, item => (0, _metal.get)(item, propertyKey)); } /** Filters the array by the callback. @@ -42057,7 +40997,7 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ function filterBy(dependentKey, propertyKey, value) { (true && !(!(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments))) && (0, _debug.assert)('You attempted to use @filterBy as a decorator directly, but it requires atleast `dependentKey` and `propertyKey` parameters', !(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments)))); - (true && !(!/[\[\]\{\}]/g.test(dependentKey)) && (0, _debug.assert)("Dependent key passed to `computed.filterBy` shouldn't contain brace expanding pattern.", !/[\[\]\{\}]/g.test(dependentKey))); + (true && !(!/[\[\]\{\}]/g.test(dependentKey)) && (0, _debug.assert)(`Dependent key passed to \`computed.filterBy\` shouldn't contain brace expanding pattern.`, !/[\[\]\{\}]/g.test(dependentKey))); var callback; if (arguments.length === 2) { @@ -42066,7 +41006,7 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ callback = item => (0, _metal.get)(item, propertyKey) === value; } - return filter(dependentKey + ".@each." + propertyKey, callback); + return filter(`${dependentKey}.@each.${propertyKey}`, callback); } /** A computed property which returns a new array with all the unique elements @@ -42211,8 +41151,8 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ function uniqBy(dependentKey, propertyKey) { (true && !(!(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments))) && (0, _debug.assert)('You attempted to use @uniqBy as a decorator directly, but it requires `dependentKey` and `propertyKey` parameters', !(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments)))); - (true && !(!/[\[\]\{\}]/g.test(dependentKey)) && (0, _debug.assert)("Dependent key passed to `computed.uniqBy` shouldn't contain brace expanding pattern.", !/[\[\]\{\}]/g.test(dependentKey))); - return (0, _metal.computed)(dependentKey + ".[]", function () { + (true && !(!/[\[\]\{\}]/g.test(dependentKey)) && (0, _debug.assert)(`Dependent key passed to \`computed.uniqBy\` shouldn't contain brace expanding pattern.`, !/[\[\]\{\}]/g.test(dependentKey))); + return (0, _metal.computed)(`${dependentKey}.[]`, function () { var list = (0, _metal.get)(this, dependentKey); return (0, _runtime.isArray)(list) ? (0, _runtime.uniqBy)(list, propertyKey) : (0, _runtime.A)(); }).readOnly(); @@ -42451,10 +41391,10 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ function setDiff(setAProperty, setBProperty) { (true && !(!(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments))) && (0, _debug.assert)('You attempted to use @setDiff as a decorator directly, but it requires atleast one dependent key parameter', !(0, _metal.isElementDescriptor)(Array.prototype.slice.call(arguments)))); (true && !(arguments.length === 2) && (0, _debug.assert)('`computed.setDiff` requires exactly two dependent arrays.', arguments.length === 2)); - (true && !(!/[\[\]\{\}]/g.test(setAProperty) && !/[\[\]\{\}]/g.test(setBProperty)) && (0, _debug.assert)("Dependent keys passed to `computed.setDiff` shouldn't contain brace expanding pattern.", !/[\[\]\{\}]/g.test(setAProperty) && !/[\[\]\{\}]/g.test(setBProperty))); - return (0, _metal.computed)(setAProperty + ".[]", setBProperty + ".[]", function () { - var setA = this.get(setAProperty); - var setB = this.get(setBProperty); + (true && !(!/[\[\]\{\}]/g.test(setAProperty) && !/[\[\]\{\}]/g.test(setBProperty)) && (0, _debug.assert)(`Dependent keys passed to \`computed.setDiff\` shouldn't contain brace expanding pattern.`, !/[\[\]\{\}]/g.test(setAProperty) && !/[\[\]\{\}]/g.test(setBProperty))); + return (0, _metal.computed)(`${setAProperty}.[]`, `${setBProperty}.[]`, function () { + var setA = (0, _metal.get)(this, setAProperty); + var setB = (0, _metal.get)(this, setBProperty); if (!(0, _runtime.isArray)(setA)) { return (0, _runtime.A)(); @@ -42716,7 +41656,7 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ argumentsValid = typeof itemsKey === 'string' && Array.isArray(additionalDependentKeys) && typeof sortDefinition === 'function'; } - (true && !(argumentsValid) && (0, _debug.assert)('`computed.sort` can either be used with an array of sort properties or with a sort function. If used with an array of sort properties, it must receive exactly two arguments: the key of the array to sort, and the key of the array of sort properties. If used with a sort function, it may recieve up to three arguments: the key of the array to sort, an optional additional array of dependent keys for the computed property, and the sort function.', argumentsValid)); + (true && !(argumentsValid) && (0, _debug.assert)('`computed.sort` can either be used with an array of sort properties or with a sort function. If used with an array of sort properties, it must receive exactly two arguments: the key of the array to sort, and the key of the array of sort properties. If used with a sort function, it may receive up to three arguments: the key of the array to sort, an optional additional array of dependent keys for the computed property, and the sort function.', argumentsValid)); } if (sortDefinition === undefined && !Array.isArray(additionalDependentKeys)) { @@ -42740,9 +41680,9 @@ define("@ember/object/lib/computed/reduce_computed_macros", ["exports", "@ember/ function propertySort(itemsKey, sortPropertiesKey) { - var cp = (0, _metal.computed)(itemsKey + ".[]", sortPropertiesKey + ".[]", function (key) { + var cp = (0, _metal.computed)(`${itemsKey}.[]`, `${sortPropertiesKey}.[]`, function (key) { var sortProperties = (0, _metal.get)(this, sortPropertiesKey); - (true && !((0, _runtime.isArray)(sortProperties) && sortProperties.every(s => typeof s === 'string')) && (0, _debug.assert)("The sort definition for '" + key + "' on " + this + " must be a function or an array of strings", (0, _runtime.isArray)(sortProperties) && sortProperties.every(s => typeof s === 'string'))); + (true && !((0, _runtime.isArray)(sortProperties) && sortProperties.every(s => typeof s === 'string')) && (0, _debug.assert)(`The sort definition for '${key}' on ${this} must be a function or an array of strings`, (0, _runtime.isArray)(sortProperties) && sortProperties.every(s => typeof s === 'string'))); var itemsKeyIsAtThis = itemsKey === '@this'; var normalizedSortProperties = normalizeSortProperties(sortProperties); var items = itemsKeyIsAtThis ? this : (0, _metal.get)(this, itemsKey); @@ -43006,7 +41946,7 @@ define("@ember/runloop/index", ["exports", "@ember/debug", "@ember/-internals/er next(); } - var _rsvpErrorQueue = ("" + Math.random() + Date.now()).replace('.', ''); + var _rsvpErrorQueue = `${Math.random()}${Date.now()}`.replace('.', ''); /** Array of named queues. This array determines the order in which queues are flushed at the end of the RunLoop. You can define your own queues by @@ -43742,4979 +42682,7994 @@ define("@ember/runloop/index", ["exports", "@ember/debug", "@ember/-internals/er */ - function throttle() { - return backburner.throttle(...arguments); + function throttle() { + return backburner.throttle(...arguments); + } +}); +define("@ember/service/index", ["exports", "@ember/-internals/runtime", "@ember/-internals/metal"], function (_exports, _runtime, _metal) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.inject = inject; + _exports.default = void 0; + + /** + @module @ember/service + @public + */ + + /** + Creates a property that lazily looks up a service in the container. There are + no restrictions as to what objects a service can be injected into. + + Example: + + ```app/routes/application.js + import Route from '@ember/routing/route'; + import { inject as service } from '@ember/service'; + + export default class ApplicationRoute extends Route { + @service('auth') authManager; + + model() { + return this.authManager.findCurrentUser(); + } + } + ``` + + Classic Class Example: + + ```app/routes/application.js + import Route from '@ember/routing/route'; + import { inject as service } from '@ember/service'; + + export default Route.extend({ + authManager: service('auth'), + + model() { + return this.get('authManager').findCurrentUser(); + } + }); + ``` + + This example will create an `authManager` property on the application route + that looks up the `auth` service in the container, making it easily accessible + in the `model` hook. + + @method inject + @static + @since 1.10.0 + @for @ember/service + @param {String} name (optional) name of the service to inject, defaults to + the property's name + @return {ComputedDecorator} injection decorator instance + @public + */ + function inject() { + return (0, _metal.inject)('service', ...arguments); + } + /** + @class Service + @extends EmberObject + @since 1.10.0 + @public + */ + + + var Service = _runtime.FrameworkObject.extend(); + + Service.reopenClass({ + isServiceFactory: true + }); + (0, _runtime.setFrameworkClass)(Service); + var _default = Service; + _exports.default = _default; +}); +define("@ember/string/index", ["exports", "@ember/string/lib/string_registry", "@ember/-internals/environment", "@ember/-internals/utils"], function (_exports, _string_registry, _environment, _utils) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.loc = loc; + _exports.w = w; + _exports.decamelize = decamelize; + _exports.dasherize = dasherize; + _exports.camelize = camelize; + _exports.classify = classify; + _exports.underscore = underscore; + _exports.capitalize = capitalize; + Object.defineProperty(_exports, "_getStrings", { + enumerable: true, + get: function () { + return _string_registry.getStrings; + } + }); + Object.defineProperty(_exports, "_setStrings", { + enumerable: true, + get: function () { + return _string_registry.setStrings; + } + }); + + /** + @module @ember/string + */ + var STRING_DASHERIZE_REGEXP = /[ _]/g; + var STRING_DASHERIZE_CACHE = new _utils.Cache(1000, key => decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-')); + var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g; + var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; + var CAMELIZE_CACHE = new _utils.Cache(1000, key => key.replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => chr ? chr.toUpperCase() : '').replace(STRING_CAMELIZE_REGEXP_2, (match + /*, separator, chr */ + ) => match.toLowerCase())); + var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; + var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; + var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; + var CLASSIFY_CACHE = new _utils.Cache(1000, str => { + var replace1 = (_match, _separator, chr) => chr ? `_${chr.toUpperCase()}` : ''; + + var replace2 = (_match, initialChar, _separator, chr) => initialChar + (chr ? chr.toUpperCase() : ''); + + var parts = str.split('/'); + + for (var i = 0; i < parts.length; i++) { + parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2); + } + + return parts.join('/').replace(STRING_CLASSIFY_REGEXP_3, (match + /*, separator, chr */ + ) => match.toUpperCase()); + }); + var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; + var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g; + var UNDERSCORE_CACHE = new _utils.Cache(1000, str => str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase()); + var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g; + var CAPITALIZE_CACHE = new _utils.Cache(1000, str => str.replace(STRING_CAPITALIZE_REGEXP, (match + /*, separator, chr */ + ) => match.toUpperCase())); + var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; + var DECAMELIZE_CACHE = new _utils.Cache(1000, str => str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase()); + /** + Defines string helper methods including string formatting and localization. + Unless `EmberENV.EXTEND_PROTOTYPES.String` is `false` these methods will also be + added to the `String.prototype` as well. + + @class String + @public + */ + + function _fmt(str, formats) { + // first, replace any ORDERED replacements. + var idx = 0; // the current index for non-numerical replacements + + return str.replace(/%@([0-9]+)?/g, (_s, argIndex) => { + var i = argIndex ? parseInt(argIndex, 10) - 1 : idx++; + var r = i < formats.length ? formats[i] : undefined; + return typeof r === 'string' ? r : r === null ? '(null)' : r === undefined ? '' : String(r); + }); + } + /** + Formats the passed string, but first looks up the string in the localized + strings hash. This is a convenient way to localize text. + + Note that it is traditional but not required to prefix localized string + keys with an underscore or other character so you can easily identify + localized strings. + + ```javascript + import { loc } from '@ember/string'; + + Ember.STRINGS = { + '_Hello World': 'Bonjour le monde', + '_Hello %@ %@': 'Bonjour %@ %@' + }; + + loc("_Hello World"); // 'Bonjour le monde'; + loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith"; + ``` + + @method loc + @param {String} str The string to format + @param {Array} formats Optional array of parameters to interpolate into string. + @return {String} formatted string + @public + */ + + + function loc(str, formats) { + if (!Array.isArray(formats) || arguments.length > 2) { + formats = Array.prototype.slice.call(arguments, 1); + } + + str = (0, _string_registry.getString)(str) || str; + return _fmt(str, formats); + } + /** + Splits a string into separate units separated by spaces, eliminating any + empty strings in the process. This is a convenience method for split that + is mostly useful when applied to the `String.prototype`. + + ```javascript + import { w } from '@ember/string'; + + w("alpha beta gamma").forEach(function(key) { + console.log(key); + }); + + // > alpha + // > beta + // > gamma + ``` + + @method w + @param {String} str The string to split + @return {Array} array containing the split strings + @public + */ + + + function w(str) { + return str.split(/\s+/); + } + /** + Converts a camelized string into all lower case separated by underscores. + + ```javascript + import { decamelize } from '@ember/string'; + + decamelize('innerHTML'); // 'inner_html' + decamelize('action_name'); // 'action_name' + decamelize('css-class-name'); // 'css-class-name' + decamelize('my favorite items'); // 'my favorite items' + ``` + + @method decamelize + @param {String} str The string to decamelize. + @return {String} the decamelized string. + @public + */ + + + function decamelize(str) { + return DECAMELIZE_CACHE.get(str); + } + /** + Replaces underscores, spaces, or camelCase with dashes. + + ```javascript + import { dasherize } from '@ember/string'; + + dasherize('innerHTML'); // 'inner-html' + dasherize('action_name'); // 'action-name' + dasherize('css-class-name'); // 'css-class-name' + dasherize('my favorite items'); // 'my-favorite-items' + dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice' + ``` + + @method dasherize + @param {String} str The string to dasherize. + @return {String} the dasherized string. + @public + */ + + + function dasherize(str) { + return STRING_DASHERIZE_CACHE.get(str); + } + /** + Returns the lowerCamelCase form of a string. + + ```javascript + import { camelize } from '@ember/string'; + + camelize('innerHTML'); // 'innerHTML' + camelize('action_name'); // 'actionName' + camelize('css-class-name'); // 'cssClassName' + camelize('my favorite items'); // 'myFavoriteItems' + camelize('My Favorite Items'); // 'myFavoriteItems' + camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice' + ``` + + @method camelize + @param {String} str The string to camelize. + @return {String} the camelized string. + @public + */ + + + function camelize(str) { + return CAMELIZE_CACHE.get(str); + } + /** + Returns the UpperCamelCase form of a string. + + ```javascript + import { classify } from '@ember/string'; + + classify('innerHTML'); // 'InnerHTML' + classify('action_name'); // 'ActionName' + classify('css-class-name'); // 'CssClassName' + classify('my favorite items'); // 'MyFavoriteItems' + classify('private-docs/owner-invoice'); // 'PrivateDocs/OwnerInvoice' + ``` + + @method classify + @param {String} str the string to classify + @return {String} the classified string + @public + */ + + + function classify(str) { + return CLASSIFY_CACHE.get(str); + } + /** + More general than decamelize. Returns the lower\_case\_and\_underscored + form of a string. + + ```javascript + import { underscore } from '@ember/string'; + + underscore('innerHTML'); // 'inner_html' + underscore('action_name'); // 'action_name' + underscore('css-class-name'); // 'css_class_name' + underscore('my favorite items'); // 'my_favorite_items' + underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice' + ``` + + @method underscore + @param {String} str The string to underscore. + @return {String} the underscored string. + @public + */ + + + function underscore(str) { + return UNDERSCORE_CACHE.get(str); + } + /** + Returns the Capitalized form of a string + + ```javascript + import { capitalize } from '@ember/string'; + + capitalize('innerHTML') // 'InnerHTML' + capitalize('action_name') // 'Action_name' + capitalize('css-class-name') // 'Css-class-name' + capitalize('my favorite items') // 'My favorite items' + capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice' + ``` + + @method capitalize + @param {String} str The string to capitalize. + @return {String} The capitalized string. + @public + */ + + + function capitalize(str) { + return CAPITALIZE_CACHE.get(str); + } + + if (_environment.ENV.EXTEND_PROTOTYPES.String) { + Object.defineProperties(String.prototype, { + /** + See [String.w](/ember/release/classes/String/methods/w?anchor=w). + @method w + @for @ember/string + @static + @private + */ + w: { + configurable: true, + enumerable: false, + writeable: true, + + value() { + return w(this); + } + + }, + + /** + See [String.loc](/ember/release/classes/String/methods/loc?anchor=loc). + @method loc + @for @ember/string + @static + @private + */ + loc: { + configurable: true, + enumerable: false, + writeable: true, + + value(...args) { + return loc(this, args); + } + + }, + + /** + See [String.camelize](/ember/release/classes/String/methods/camelize?anchor=camelize). + @method camelize + @for @ember/string + @static + @private + */ + camelize: { + configurable: true, + enumerable: false, + writeable: true, + + value() { + return camelize(this); + } + + }, + + /** + See [String.decamelize](/ember/release/classes/String/methods/decamelize?anchor=decamelize). + @method decamelize + @for @ember/string + @static + @private + */ + decamelize: { + configurable: true, + enumerable: false, + writeable: true, + + value() { + return decamelize(this); + } + + }, + + /** + See [String.dasherize](/ember/release/classes/String/methods/dasherize?anchor=dasherize). + @method dasherize + @for @ember/string + @static + @private + */ + dasherize: { + configurable: true, + enumerable: false, + writeable: true, + + value() { + return dasherize(this); + } + + }, + + /** + See [String.underscore](/ember/release/classes/String/methods/underscore?anchor=underscore). + @method underscore + @for @ember/string + @static + @private + */ + underscore: { + configurable: true, + enumerable: false, + writeable: true, + + value() { + return underscore(this); + } + + }, + + /** + See [String.classify](/ember/release/classes/String/methods/classify?anchor=classify). + @method classify + @for @ember/string + @static + @private + */ + classify: { + configurable: true, + enumerable: false, + writeable: true, + + value() { + return classify(this); + } + + }, + + /** + See [String.capitalize](/ember/release/classes/String/methods/capitalize?anchor=capitalize). + @method capitalize + @for @ember/string + @static + @private + */ + capitalize: { + configurable: true, + enumerable: false, + writeable: true, + + value() { + return capitalize(this); + } + + } + }); + } +}); +define("@ember/string/lib/string_registry", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.setStrings = setStrings; + _exports.getStrings = getStrings; + _exports.getString = getString; + // STATE within a module is frowned upon, this exists + // to support Ember.STRINGS but shield ember internals from this legacy global + // API. + var STRINGS = {}; + + function setStrings(strings) { + STRINGS = strings; + } + + function getStrings() { + return STRINGS; + } + + function getString(name) { + return STRINGS[name]; + } +}); +define("@glimmer/encoder", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.InstructionEncoderImpl = void 0; + + class InstructionEncoderImpl { + constructor(buffer) { + this.buffer = buffer; + this.size = 0; + } + + encode(type, machine) { + if (type > 255 + /* TYPE_SIZE */ + ) { + throw new Error(`Opcode type over 8-bits. Got ${type}.`); + } + + var first = type | machine | arguments.length - 2 << 8 + /* ARG_SHIFT */ + ; + this.buffer.push(first); + + for (var i = 2; i < arguments.length; i++) { + var op = arguments[i]; + + if (typeof op === 'number' && op > 2147483647 + /* MAX_SIZE */ + ) { + throw new Error(`Operand over 32-bits. Got ${op}.`); + } + + this.buffer.push(op); + } + + this.size = this.buffer.length; + } + + patch(position, target) { + if (this.buffer[position + 1] === -1) { + this.buffer[position + 1] = target; + } else { + throw new Error('Trying to patch operand in populated slot instead of a reserved slot.'); + } + } + + } + + _exports.InstructionEncoderImpl = InstructionEncoderImpl; +}); +define("@glimmer/env", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.CI = _exports.DEBUG = void 0; + var DEBUG = false; + _exports.DEBUG = DEBUG; + var CI = false; + _exports.CI = CI; +}); +define("@glimmer/low-level", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.Stack = _exports.Storage = void 0; + + class Storage { + constructor() { + this.array = []; + this.next = 0; + } + + add(element) { + var { + next: slot, + array + } = this; + + if (slot === array.length) { + this.next++; + } else { + var prev = array[slot]; + this.next = prev; + } + + this.array[slot] = element; + return slot; + } + + deref(pointer) { + return this.array[pointer]; + } + + drop(pointer) { + this.array[pointer] = this.next; + this.next = pointer; + } + + } + + _exports.Storage = Storage; + + class Stack { + constructor(vec = []) { + this.vec = vec; + } + + clone() { + return new Stack(this.vec.slice()); + } + + sliceFrom(start) { + return new Stack(this.vec.slice(start)); + } + + slice(start, end) { + return new Stack(this.vec.slice(start, end)); + } + + copy(from, to) { + this.vec[to] = this.vec[from]; + } // TODO: how to model u64 argument? + + + writeRaw(pos, value) { + // TODO: Grow? + this.vec[pos] = value; + } // TODO: partially decoded enum? + + + getRaw(pos) { + return this.vec[pos]; + } + + reset() { + this.vec.length = 0; + } + + len() { + return this.vec.length; + } + + } + + _exports.Stack = Stack; +}); +define("@glimmer/node", ["exports", "@glimmer/runtime", "@simple-dom/document"], function (_exports, _runtime, _document) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.serializeBuilder = serializeBuilder; + _exports.NodeDOMTreeConstruction = void 0; + + class NodeDOMTreeConstruction extends _runtime.DOMTreeConstruction { + constructor(doc) { + super(doc || (0, _document.default)()); + } // override to prevent usage of `this.document` until after the constructor + + + setupUselessElement() {} + + insertHTMLBefore(parent, reference, html) { + var raw = this.document.createRawHTMLSection(html); + parent.insertBefore(raw, reference); + return new _runtime.ConcreteBounds(parent, raw, raw); + } // override to avoid SVG detection/work when in node (this is not needed in SSR) + + + createElement(tag) { + return this.document.createElement(tag); + } // override to avoid namespace shenanigans when in node (this is not needed in SSR) + + + setAttribute(element, name, value) { + element.setAttribute(name, value); + } + + } + + _exports.NodeDOMTreeConstruction = NodeDOMTreeConstruction; + var TEXT_NODE = 3; + var NEEDS_EXTRA_CLOSE = new WeakMap(); + + function currentNode(cursor) { + var { + element, + nextSibling + } = cursor; + + if (nextSibling === null) { + return element.lastChild; + } else { + return nextSibling.previousSibling; + } + } + + class SerializeBuilder extends _runtime.NewElementBuilder { + constructor() { + super(...arguments); + this.serializeBlockDepth = 0; + } + + __openBlock() { + var { + tagName + } = this.element; + + if (tagName !== 'TITLE' && tagName !== 'SCRIPT' && tagName !== 'STYLE') { + var depth = this.serializeBlockDepth++; + + this.__appendComment(`%+b:${depth}%`); + } + + super.__openBlock(); + } + + __closeBlock() { + var { + tagName + } = this.element; + + super.__closeBlock(); + + if (tagName !== 'TITLE' && tagName !== 'SCRIPT' && tagName !== 'STYLE') { + var depth = --this.serializeBlockDepth; + + this.__appendComment(`%-b:${depth}%`); + } + } + + __appendHTML(html) { + var { + tagName + } = this.element; + + if (tagName === 'TITLE' || tagName === 'SCRIPT' || tagName === 'STYLE') { + return super.__appendHTML(html); + } // Do we need to run the html tokenizer here? + + + var first = this.__appendComment('%glmr%'); + + if (tagName === 'TABLE') { + var openIndex = html.indexOf('<'); + + if (openIndex > -1) { + var tr = html.slice(openIndex + 1, openIndex + 3); + + if (tr === 'tr') { + html = `${html}`; + } + } + } + + if (html === '') { + this.__appendComment('% %'); + } else { + super.__appendHTML(html); + } + + var last = this.__appendComment('%glmr%'); + + return new _runtime.ConcreteBounds(this.element, first, last); + } + + __appendText(string) { + var { + tagName + } = this.element; + var current = currentNode(this); + + if (tagName === 'TITLE' || tagName === 'SCRIPT' || tagName === 'STYLE') { + return super.__appendText(string); + } else if (string === '') { + return this.__appendComment('% %'); + } else if (current && current.nodeType === TEXT_NODE) { + this.__appendComment('%|%'); + } + + return super.__appendText(string); + } + + closeElement() { + if (NEEDS_EXTRA_CLOSE.has(this.element)) { + NEEDS_EXTRA_CLOSE.delete(this.element); + super.closeElement(); + } + + return super.closeElement(); + } + + openElement(tag) { + if (tag === 'tr') { + if (this.element.tagName !== 'TBODY' && this.element.tagName !== 'THEAD' && this.element.tagName !== 'TFOOT') { + this.openElement('tbody'); // This prevents the closeBlock comment from being re-parented + // under the auto inserted tbody. Rehydration builder needs to + // account for the insertion since it is injected here and not + // really in the template. + + NEEDS_EXTRA_CLOSE.set(this.constructing, true); + this.flushElement(null); + } + } + + return super.openElement(tag); + } + + pushRemoteElement(element, cursorId, insertBefore = null) { + var { + dom + } = this; + var script = dom.createElement('script'); + script.setAttribute('glmr', cursorId); + dom.insertBefore(element, script, insertBefore); + return super.pushRemoteElement(element, cursorId, insertBefore); + } + + } + + function serializeBuilder(env, cursor) { + return SerializeBuilder.forInitialRender(env, cursor); + } +}); +define("@glimmer/opcode-compiler", ["exports", "@glimmer/vm", "@glimmer/program", "@glimmer/util", "@glimmer/encoder", "@glimmer/runtime"], function (_exports, _vm, _program, _util, _encoder, _runtime) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.compileStatements = compileStatements; + _exports.compilable = compilable; + _exports.staticComponent = StaticComponent; + _exports.invokeStaticBlockWithStack = InvokeStaticBlockWithStack; + _exports.invokeStaticBlock = InvokeStaticBlock; + _exports.compileStd = compileStd; + _exports.meta = meta; + _exports.templateFactory = templateFactory; + _exports.Component = Component; + _exports.unwrapTemplate = unwrapTemplate; + _exports.unwrapHandle = unwrapHandle; + _exports.isOkHandle = isOkHandle; + _exports.isErrHandle = isErrHandle; + _exports.extractHandle = extractHandle; + _exports.debug = debug; + _exports.debugSlice = debugSlice; + _exports.logOpcode = logOpcode; + _exports.resolveLayoutForTag = resolveLayoutForTag; + _exports.syntaxCompilationContext = syntaxCompilationContext; + _exports.Context = Context; + _exports.JitContext = JitContext; + _exports.AotContext = AotContext; + _exports.templateCompilationContext = templateCompilationContext; + _exports.DefaultCompileTimeResolverDelegate = _exports.MINIMAL_CAPABILITIES = _exports.DEFAULT_CAPABILITIES = _exports.JitProgramCompilationContext = _exports.ProgramCompilationContext = _exports.EMPTY_BLOCKS = _exports.WrappedBuilder = _exports.PartialDefinition = _exports.StdLib = _exports.debugCompiler = _exports.NONE = _exports.UNHANDLED = _exports.MacrosImpl = void 0; + + function arr(value) { + return { + type: 'array', + value + }; + } + + function strArray(value) { + return { + type: 'string-array', + value + }; + } + + function serializable(value) { + return { + type: 'serializable', + value + }; + } + + function templateMeta(value) { + return { + type: 'template-meta', + value + }; + } + + function other(value) { + return { + type: 'other', + value + }; + } + + function label(value) { + return { + type: 'label', + value + }; + } + + function prim(operand, type) { + return { + type: 'primitive', + value: { + primitive: operand, + type + } + }; + } + + var DEFAULT_CAPABILITIES = { + dynamicLayout: true, + dynamicTag: true, + prepareArgs: true, + createArgs: true, + attributeHook: false, + elementHook: false, + dynamicScope: true, + createCaller: false, + updateHook: true, + createInstance: true, + wrapped: false, + willDestroy: false + }; + _exports.DEFAULT_CAPABILITIES = DEFAULT_CAPABILITIES; + var MINIMAL_CAPABILITIES$1 = { + dynamicLayout: false, + dynamicTag: false, + prepareArgs: false, + createArgs: false, + attributeHook: false, + elementHook: false, + dynamicScope: false, + createCaller: false, + updateHook: false, + createInstance: false, + wrapped: false, + willDestroy: false + }; + _exports.MINIMAL_CAPABILITIES = MINIMAL_CAPABILITIES$1; + + class DefaultCompileTimeResolverDelegate { + constructor(inner) { + this.inner = inner; + } + + lookupHelper(name, referrer) { + if (this.inner.lookupHelper) { + var helper = this.inner.lookupHelper(name, referrer); + + if (helper === undefined) { + throw new Error(`Unexpected helper (${name} from ${JSON.stringify(referrer)}) (lookupHelper returned undefined)`); + } + + return helper; + } else { + throw new Error(`Can't compile global helper invocations without an implementation of lookupHelper`); + } + } + + lookupModifier(name, referrer) { + if (this.inner.lookupModifier) { + var modifier = this.inner.lookupModifier(name, referrer); + + if (modifier === undefined) { + throw new Error(`Unexpected modifier (${name} from ${JSON.stringify(referrer)}) (lookupModifier returned undefined)`); + } + + return modifier; + } else { + throw new Error(`Can't compile global modifier invocations without an implementation of lookupModifier`); + } + } + + lookupComponent(name, referrer) { + if (this.inner.lookupComponent) { + var component = this.inner.lookupComponent(name, referrer); + + if (component === undefined) { + throw new Error(`Unexpected component (${name} from ${JSON.stringify(referrer)}) (lookupComponent returned undefined)`); + } + + return component; + } else { + throw new Error(`Can't compile global component invocations without an implementation of lookupComponent`); + } + } + + lookupPartial(name, referrer) { + if (this.inner.lookupPartial) { + var partial = this.inner.lookupPartial(name, referrer); + + if (partial === undefined) { + throw new Error(`Unexpected partial (${name} from ${JSON.stringify(referrer)}) (lookupPartial returned undefined)`); + } + + return partial; + } else { + throw new Error(`Can't compile global partial invocations without an implementation of lookupPartial`); + } + } // For debugging + + + resolve(handle) { + if (this.inner.resolve) { + return this.inner.resolve(handle); + } else { + throw new Error(`Compile-time debugging requires an implementation of resolve`); + } + } + + } + + _exports.DefaultCompileTimeResolverDelegate = DefaultCompileTimeResolverDelegate; + + function resolveLayoutForTag(tag, { + resolver, + meta: { + referrer + } + }) { + var component = resolver.lookupComponent(tag, referrer); + if (component === null) return component; + var { + handle, + compilable, + capabilities + } = component; + return { + handle, + compilable, + capabilities: capabilities || MINIMAL_CAPABILITIES$1 + }; + } + + function debugSlice(context, start, end) {} + + function logOpcode(type, params) {} + + function debug(c, resolver, op, isMachine) { + return undefined; + } + + function SwitchCases(callback) { + // Setup the switch DSL + var clauses = []; + var count = 0; + + function when(match, callback) { + clauses.push({ + match, + callback, + label: `CLAUSE${count++}` + }); + } // Call the callback + + + callback(when); // Emit the opcodes for the switch + + var out = [op(69 + /* Enter */ + , 2), op(68 + /* AssertSame */ + ), op(32 + /* ReifyU32 */ + ), op('StartLabels')]; // First, emit the jump opcodes. We don't need a jump for the last + // opcode, since it bleeds directly into its clause. + + for (var clause of clauses.slice(0, -1)) { + out.push(op(67 + /* JumpEq */ + , label(clause.label), clause.match)); + } // Enumerate the clauses in reverse order. Earlier matches will + // require fewer checks. + + + for (var i = clauses.length - 1; i >= 0; i--) { + var _clause = clauses[i]; + out.push(op('Label', _clause.label), op(34 + /* Pop */ + , 2), _clause.callback()); // The first match is special: it is placed directly before the END + // label, so no additional jump is needed at the end of it. + + if (i !== 0) { + out.push(op(4 + /* Jump */ + , label('END'))); + } + } + + out.push(op('Label', 'END'), op('StopLabels'), op(70 + /* Exit */ + )); + return out; + } + /** + * A convenience for pushing some arguments on the stack and + * running some code if the code needs to be re-executed during + * updating execution if some of the arguments have changed. + * + * # Initial Execution + * + * The `args` function should push zero or more arguments onto + * the stack and return the number of arguments pushed. + * + * The `body` function provides the instructions to execute both + * during initial execution and during updating execution. + * + * Internally, this function starts by pushing a new frame, so + * that the body can return and sets the return point ($ra) to + * the ENDINITIAL label. + * + * It then executes the `args` function, which adds instructions + * responsible for pushing the arguments for the block to the + * stack. These arguments will be restored to the stack before + * updating execution. + * + * Next, it adds the Enter opcode, which marks the current position + * in the DOM, and remembers the current $pc (the next instruction) + * as the first instruction to execute during updating execution. + * + * Next, it runs `body`, which adds the opcodes that should + * execute both during initial execution and during updating execution. + * If the `body` wishes to finish early, it should Jump to the + * `FINALLY` label. + * + * Next, it adds the FINALLY label, followed by: + * + * - the Exit opcode, which finalizes the marked DOM started by the + * Enter opcode. + * - the Return opcode, which returns to the current return point + * ($ra). + * + * Finally, it adds the ENDINITIAL label followed by the PopFrame + * instruction, which restores $fp, $sp and $ra. + * + * # Updating Execution + * + * Updating execution for this `replayable` occurs if the `body` added an + * assertion, via one of the `JumpIf`, `JumpUnless` or `AssertSame` opcodes. + * + * If, during updating executon, the assertion fails, the initial VM is + * restored, and the stored arguments are pushed onto the stack. The DOM + * between the starting and ending markers is cleared, and the VM's cursor + * is set to the area just cleared. + * + * The return point ($ra) is set to -1, the exit instruction. + * + * Finally, the $pc is set to to the instruction saved off by the + * Enter opcode during initial execution, and execution proceeds as + * usual. + * + * The only difference is that when a `Return` instruction is + * encountered, the program jumps to -1 rather than the END label, + * and the PopFrame opcode is not needed. + */ + + + function Replayable({ + args: args$$1, + body + }) { + // Push the arguments onto the stack. The args() function + // tells us how many stack elements to retain for re-execution + // when updating. + var { + count, + actions + } = args$$1(); // Start a new label frame, to give END and RETURN + // a unique meaning. + + return [op('StartLabels'), op(0 + /* PushFrame */ + ), // If the body invokes a block, its return will return to + // END. Otherwise, the return in RETURN will return to END. + op(6 + /* ReturnTo */ + , label('ENDINITIAL')), actions, // Start a new updating closure, remembering `count` elements + // from the stack. Everything after this point, and before END, + // will execute both initially and to update the block. + // + // The enter and exit opcodes also track the area of the DOM + // associated with this block. If an assertion inside the block + // fails (for example, the test value changes from true to false + // in an #if), the DOM is cleared and the program is re-executed, + // restoring `count` elements to the stack and executing the + // instructions between the enter and exit. + op(69 + /* Enter */ + , count), // Evaluate the body of the block. The body of the block may + // return, which will jump execution to END during initial + // execution, and exit the updating routine. + body(), // All execution paths in the body should run the FINALLY once + // they are done. It is executed both during initial execution + // and during updating execution. + op('Label', 'FINALLY'), // Finalize the DOM. + op(70 + /* Exit */ + ), // In initial execution, this is a noop: it returns to the + // immediately following opcode. In updating execution, this + // exits the updating routine. + op(5 + /* Return */ + ), // Cleanup code for the block. Runs on initial execution + // but not on updating. + op('Label', 'ENDINITIAL'), op(1 + /* PopFrame */ + ), op('StopLabels')]; + } + /** + * A specialized version of the `replayable` convenience that allows the + * caller to provide different code based upon whether the item at + * the top of the stack is true or false. + * + * As in `replayable`, the `ifTrue` and `ifFalse` code can invoke `return`. + * + * During the initial execution, a `return` will continue execution + * in the cleanup code, which finalizes the current DOM block and pops + * the current frame. + * + * During the updating execution, a `return` will exit the updating + * routine, as it can reuse the DOM block and is always only a single + * frame deep. + */ + + + function ReplayableIf({ + args: args$$1, + ifTrue, + ifFalse + }) { + return Replayable({ + args: args$$1, + body: () => { + var out = [// If the conditional is false, jump to the ELSE label. + op(66 + /* JumpUnless */ + , label('ELSE')), // Otherwise, execute the code associated with the true branch. + ifTrue(), // We're done, so return. In the initial execution, this runs + // the cleanup code. In the updating VM, it exits the updating + // routine. + op(4 + /* Jump */ + , label('FINALLY')), op('Label', 'ELSE')]; // If the conditional is false, and code associatied ith the + // false branch was provided, execute it. If there was no code + // associated with the false branch, jumping to the else statement + // has no other behavior. + + if (ifFalse) { + out.push(ifFalse()); + } + + return out; + } + }); + } + /** + * Push a reference onto the stack corresponding to a statically known primitive + * @param value A JavaScript primitive (undefined, null, boolean, number or string) + */ + + + function PushPrimitiveReference(value) { + return [PushPrimitive(value), op(31 + /* PrimitiveReference */ + )]; + } + /** + * Push an encoded representation of a JavaScript primitive on the stack + * + * @param value A JavaScript primitive (undefined, null, boolean, number or string) + */ + + + function PushPrimitive(primitive) { + var p; + + switch (typeof primitive) { + case 'number': + if ((0, _util.isSmallInt)(primitive)) { + p = prim(primitive, 0 + /* IMMEDIATE */ + ); + } else { + p = prim(primitive, 2 + /* NUMBER */ + ); + } + + break; + + case 'string': + p = prim(primitive, 1 + /* STRING */ + ); + break; + + case 'boolean': + case 'object': // assume null + + case 'undefined': + p = prim(primitive, 0 + /* IMMEDIATE */ + ); + break; + + default: + throw new Error('Invalid primitive passed to pushPrimitive'); + } + + return op(30 + /* Primitive */ + , p); + } + /** + * Invoke a foreign function (a "helper") based on a statically known handle + * + * @param compile.handle A handle + * @param compile.params An optional list of expressions to compile + * @param compile.hash An optional list of named arguments (name + expression) to compile + */ + + + function Call({ + handle, + params, + hash + }) { + return [op(0 + /* PushFrame */ + ), op('SimpleArgs', { + params, + hash, + atNames: false + }), op(16 + /* Helper */ + , handle), op(1 + /* PopFrame */ + ), op(36 + /* Fetch */ + , _vm.$v0)]; + } + /** + * Evaluate statements in the context of new dynamic scope entries. Move entries from the + * stack into named entries in the dynamic scope, then evaluate the statements, then pop + * the dynamic scope + * + * @param names a list of dynamic scope names + * @param block a function that returns a list of statements to evaluate + */ + + + function DynamicScope(names, block) { + return [op(59 + /* PushDynamicScope */ + ), op(58 + /* BindDynamicScope */ + , strArray(names)), block(), op(60 + /* PopDynamicScope */ + )]; + } + + function pushBuilderOp(context, op$$1) { + var { + encoder, + syntax: { + program: { + mode, + constants + } + } + } = context; + + switch (op$$1.op) { + case "Option" + /* Option */ + : + return concat(context, option$1(op$$1)); + + case "Label" + /* Label */ + : + return encoder.label(op$$1.op1); + + case "StartLabels" + /* StartLabels */ + : + return encoder.startLabels(); + + case "StopLabels" + /* StopLabels */ + : + return encoder.stopLabels(); + + case "JitCompileBlock" + /* JitCompileBlock */ + : + return concat(context, jitCompileBlock(mode)); + + case "GetComponentLayout" + /* GetComponentLayout */ + : + return encoder.push(constants, compileLayoutOpcode(mode), op$$1.op1); + + case "SetBlock" + /* SetBlock */ + : + return encoder.push(constants, setBlock(mode), op$$1.op1); + + default: + return (0, _util.exhausted)(op$$1); + } + } + + function option$1(op$$1) { + var value = op$$1.op1; + return value === null ? NONE : value; + } + + function compileLayoutOpcode(mode) { + return mode === "aot" + /* aot */ + ? 94 + /* GetAotComponentLayout */ + : 95 + /* GetJitComponentLayout */ + ; + } + + function jitCompileBlock(mode) { + return mode === "jit" + /* jit */ + ? op(61 + /* CompileBlock */ + ) : NONE; + } + + function setBlock(mode) { + return mode === "aot" + /* aot */ + ? 20 + /* SetAotBlock */ + : 21 + /* SetJitBlock */ + ; + } + + function pushCompileOp(context, action) { + concatStatements(context, compileOp(context, action)); + } + + function compileOp(context, action) { + switch (action.op) { + case "CompileBlock" + /* CompileBlock */ + : + return CompileBlockOp(context, action); + + case "CompileInline" + /* CompileInline */ + : + return CompileInlineOp(context, action); + + case "InvokeStatic" + /* InvokeStatic */ + : + return InvokeStatic(context.syntax, action); + + case "Args" + /* Args */ + : + return CompileArgs(action.op1); + + case "PushCompilable" + /* PushCompilable */ + : + return PushCompilable(action.op1, context.syntax); + + case "DynamicComponent" + /* DynamicComponent */ + : + return DynamicComponent(context, action); + + case "IfResolvedComponent" + /* IfResolvedComponent */ + : + return IfResolvedComponent(context, action); + + default: + return (0, _util.exhausted)(action); + } + } + + function CompileBlockOp(context, op$$1) { + return compileBlock(op$$1.op1, context); + } + + function CompileInlineOp(context, op$$1) { + var { + inline, + ifUnhandled + } = op$$1.op1; + var returned = compileInline(inline, context); + + if (isHandled(returned)) { + return returned; + } else { + return ifUnhandled(inline); + } + } + + function InvokeStatic(context, action) { + var compilable$$1 = action.op1; + + if (context.program.mode === "aot" + /* aot */ + ) { + var handle = compilable$$1.compile(context); + + if (typeof handle !== 'number') { + return op('Error', { + problem: 'Invalid block', + start: 0, + end: 0 + }); + } // If the handle for the invoked component is not yet known (for example, + // because this is a recursive invocation and we're still compiling), push a + // function that will produce the correct handle when the heap is + // serialized. + + + if (handle === PLACEHOLDER_HANDLE) { + return op(3 + /* InvokeStatic */ + , () => compilable$$1.compile(context)); + } else { + return op(3 + /* InvokeStatic */ + , handle); + } + } else { + return [op(29 + /* Constant */ + , other(action.op1)), op(61 + /* CompileBlock */ + ), op(2 + /* InvokeVirtual */ + )]; + } + } + + function DynamicComponent(context, action) { + var { + definition, + attrs, + params, + args: args$$1, + blocks, + atNames + } = action.op1; + var attrsBlock = attrs && attrs.length > 0 ? compilableBlock(attrs, context.meta) : null; + var compiled = Array.isArray(blocks) || blocks === null ? namedBlocks(blocks, context.meta) : blocks; + return InvokeDynamicComponent(context.meta, { + definition, + attrs: attrsBlock, + params, + hash: args$$1, + atNames, + blocks: compiled + }); + } + + function IfResolvedComponent(context, action) { + var { + name, + attrs, + blocks, + staticTemplate, + dynamicTemplate, + orElse + } = action.op1; + var component = resolveLayoutForTag(name, { + resolver: context.syntax.program.resolverDelegate, + meta: context.meta + }); + var { + meta: meta$$1 + } = context; + + if (component !== null) { + var { + handle, + capabilities, + compilable: compilable$$1 + } = component; + var attrsBlock = compilableBlock(attrs, meta$$1); + var compilableBlocks = namedBlocks(blocks, meta$$1); + + if (compilable$$1 !== null) { + return staticTemplate(handle, capabilities, compilable$$1, { + attrs: attrsBlock, + blocks: compilableBlocks + }); + } else { + return dynamicTemplate(handle, capabilities, { + attrs: attrsBlock, + blocks: compilableBlocks + }); + } + } else if (orElse) { + return orElse(); + } else { + throw new Error(`Compile Error: Cannot find component ${name}`); + } + } + + function PushCompilable(block, context) { + if (block === null) { + return PushPrimitive(null); + } else if (context.program.mode === "aot" + /* aot */ + ) { + var compiled = block.compile(context); + + if (typeof compiled !== 'number') { + return op('Error', { + problem: 'Compile Error (TODO: thread better)', + start: 0, + end: 0 + }); + } + + return PushPrimitive(compiled); + } else { + return op(29 + /* Constant */ + , other(block)); + } + } + + function pushOp(encoder, constants, op) { + if (op.op3 !== undefined) { + encoder.push(constants, op.op, op.op1, op.op2, op.op3); + } else if (op.op2 !== undefined) { + encoder.push(constants, op.op, op.op1, op.op2); + } else if (op.op1 !== undefined) { + encoder.push(constants, op.op, op.op1); + } else { + encoder.push(constants, op.op); + } + } + + class Compilers { + constructor() { + this.names = (0, _util.dict)(); + } + + add(name, func) { + this.funcs.push(func); + this.names[name] = this.funcs.length - 1; + } + + } + + class StatementCompilers extends Compilers { + constructor() { + super(...arguments); + this.funcs = []; + } + + add(name, func) { + // TODO: This is not ideal and could probably miss bugs. However, getting the type inference + // to work correctly here is critical to the correctness of expressions.ts and statements.ts + // so it seems worth it for now. + this.funcs.push(func); + this.names[name] = this.funcs.length - 1; + } + + compile(sexp, meta) { + var name = sexp[0]; + var index = this.names[name]; + var func = this.funcs[index]; + return func(sexp, meta); + } + + } + + var ATTRS_BLOCK = '&attrs'; + + class ExpressionCompilers extends Compilers { + constructor() { + super(...arguments); + this.funcs = []; + } + + compile(sexp, meta) { + var name = sexp[0]; + var index = this.names[name]; + var func = this.funcs[index]; + return func(sexp, meta); + } + + } + + var EXPRESSIONS = new ExpressionCompilers(); + EXPRESSIONS.add(32 + /* Concat */ + , ([, parts]) => { + var out = []; + + for (var part of parts) { + out.push(op('Expr', part)); + } + + out.push(op(28 + /* Concat */ + , parts.length)); + return out; + }); + EXPRESSIONS.add(31 + /* Call */ + , ([, start, offset, name, params, hash], meta) => { + // TODO: triage this in the WF compiler + if (isComponent(name, meta)) { + if (!params || params.length === 0) { + return op('Error', { + problem: 'component helper requires at least one argument', + start: start, + end: start + offset + }); + } + + var [definition, ...restArgs] = params; + return curryComponent({ + definition, + params: restArgs, + hash, + atNames: false + }, meta.referrer); + } + + var nameOrError = expectString(name, meta, 'Expected call head to be a string'); + + if (typeof nameOrError !== 'string') { + return nameOrError; + } + + return op('IfResolved', { + kind: "Helper" + /* Helper */ + , + name: nameOrError, + andThen: handle => Call({ + handle, + params, + hash + }), + span: { + start, + end: start + offset + } + }); + }); + + function isComponent(expr, meta) { + if (!Array.isArray(expr)) { + return false; + } + + if (expr[0] === 27 + /* GetPath */ + ) { + var head = expr[1]; + + if (head[0] === 26 + /* GetContextualFree */ + && meta.upvars && meta.upvars[head[1]] === 'component') { + return true; + } else { + return false; + } + } + + return false; + } + + EXPRESSIONS.add(24 + /* GetSymbol */ + , ([, head]) => [op(22 + /* GetVariable */ + , head)]); + EXPRESSIONS.add(27 + /* GetPath */ + , ([, head, tail]) => { + return [op('Expr', head), ...tail.map(p => op(23 + /* GetProperty */ + , p))]; + }); + EXPRESSIONS.add(25 + /* GetFree */ + , ([, head]) => op('ResolveFree', head)); + EXPRESSIONS.add(26 + /* GetContextualFree */ + , ([, head, context]) => op('ResolveContextualFree', { + freeVar: head, + context + })); + EXPRESSIONS.add(30 + /* Undefined */ + , () => PushPrimitiveReference(undefined)); + EXPRESSIONS.add(28 + /* HasBlock */ + , ([, block]) => { + return [op('Expr', block), op(26 + /* HasBlock */ + )]; + }); + EXPRESSIONS.add(29 + /* HasBlockParams */ + , ([, block]) => [op('Expr', block), op(25 + /* JitSpreadBlock */ + ), op('JitCompileBlock'), op(27 + /* HasBlockParams */ + )]); + + function pushResolutionOp(encoder, context, operation, constants) { + switch (operation.op) { + case "SimpleArgs" + /* SimpleArgs */ + : + concatExpressions(encoder, context, compileSimpleArgs(operation.op1.params, operation.op1.hash, operation.op1.atNames), constants); + break; + + case "Expr" + /* Expr */ + : + concatExpressions(encoder, context, expr(operation.op1, context.meta), constants); + break; + + case "IfResolved" + /* IfResolved */ + : + { + concatExpressions(encoder, context, ifResolved(context, operation), constants); + break; + } + + case "ResolveFree" + /* ResolveFree */ + : + { + throw new Error('Unimplemented HighLevelResolutionOpcode.ResolveFree'); + } + + case "ResolveContextualFree" + /* ResolveContextualFree */ + : + { + var { + freeVar, + context: expressionContext + } = operation.op1; + + if (context.meta.asPartial) { + var name = context.meta.upvars[freeVar]; + concatExpressions(encoder, context, [op(105 + /* ResolveMaybeLocal */ + , name)], constants); + break; + } + + switch (expressionContext) { + case "Expression" + /* Expression */ + : + { + // in classic mode, this is always a this-fallback + var _name2 = context.meta.upvars[freeVar]; + concatExpressions(encoder, context, [op(22 + /* GetVariable */ + , 0), op(23 + /* GetProperty */ + , _name2)], constants); + break; + } + + case "AppendSingleId" + /* AppendSingleId */ + : + { + var resolver = context.syntax.program.resolverDelegate; + var _name3 = context.meta.upvars[freeVar]; + var resolvedHelper = resolver.lookupHelper(_name3, context.meta.referrer); + var expressions; + + if (resolvedHelper) { + expressions = Call({ + handle: resolvedHelper, + params: null, + hash: null + }); + } else { + // in classic mode, this is always a this-fallback + expressions = [op(22 + /* GetVariable */ + , 0), op(23 + /* GetProperty */ + , _name3)]; + } + + concatExpressions(encoder, context, expressions, constants); + break; + } + + default: + throw new Error(`unimplemented: Can't evaluate expression in context ${expressionContext}`); + } + + break; + } + + default: + return (0, _util.exhausted)(operation); + } + } + + function expr(expression$$1, meta$$1) { + if (Array.isArray(expression$$1)) { + return EXPRESSIONS.compile(expression$$1, meta$$1); + } else { + return [PushPrimitive(expression$$1), op(31 + /* PrimitiveReference */ + )]; + } + } + + function compileSimpleArgs(params, hash, atNames) { + var out = []; + var { + count, + actions + } = CompilePositional(params); + out.push(actions); + var flags = count << 4; + if (atNames) flags |= 0b1000; + var names = _util.EMPTY_ARRAY; + + if (hash) { + names = hash[0]; + var val = hash[1]; + + for (var i = 0; i < val.length; i++) { + out.push(op('Expr', val[i])); + } + } + + out.push(op(84 + /* PushArgs */ + , strArray(names), flags)); + return out; + } + + function ifResolved(context, { + op1 + }) { + var { + kind, + name, + andThen, + orElse, + span + } = op1; + var resolved = resolve(context.syntax.program.resolverDelegate, kind, name, context.meta.referrer); + + if (resolved !== null) { + return andThen(resolved); + } else if (orElse) { + return orElse(); + } else { + return error(`Unexpected ${kind} ${name}`, span.start, span.end); + } + } + + function resolve(resolver, kind, name, referrer) { + switch (kind) { + case "Modifier" + /* Modifier */ + : + return resolver.lookupModifier(name, referrer); + + case "Helper" + /* Helper */ + : + return resolver.lookupHelper(name, referrer); + + case "ComponentDefinition" + /* ComponentDefinition */ + : + { + var component = resolver.lookupComponent(name, referrer); + return component && component.handle; + } + } + } + + var NONE = { + 'no-action': true + }; + _exports.NONE = NONE; + var UNHANDLED = { + 'not-handled': true + }; + _exports.UNHANDLED = UNHANDLED; + + function isNoAction(actions) { + return actions && !!actions['no-action']; + } + + function isHandled(actions) { + return !actions || !actions['not-handled']; + } + + function concat(context, action) { + if (isNoAction(action)) { + return; + } else if (Array.isArray(action)) { + for (var item of action) { + concat(context, item); + } + } else if (action.type === 'Simple') { + pushBuilderOp(context, action); + } else { + pushOp(context.encoder, context.syntax.program.constants, action); + } + } + + function concatExpressions(encoder, context, action, constants) { + if (isNoAction(action)) { + return; + } else if (Array.isArray(action)) { + for (var item of action) { + concatExpressions(encoder, context, item, constants); + } + } else if (action.type === 'Number') { + pushOp(encoder, constants, action); + } else if (action.type === 'Resolution') { + pushResolutionOp(encoder, context, action, constants); + } else if (action.type === 'Simple') { + pushBuilderOp(context, action); + } else if (action.type === 'Error') { + encoder.error({ + problem: action.op1.problem, + span: { + start: action.op1.start, + end: action.op1.end + } + }); + } else { + throw (0, _util.assertNever)(action, 'unexpected action kind'); + } + } + + function concatStatements(context, action) { + if (isNoAction(action)) { + return; + } else if (Array.isArray(action)) { + for (var item of action) { + concatStatements(context, item); + } + } else if (action.type === 'Number') { + pushOp(context.encoder, context.syntax.program.constants, action); + } else { + if (action.type === 'Compile') { + pushCompileOp(context, action); + } else if (action.type === 'Resolution') { + pushResolutionOp(context.encoder, context, action, context.syntax.program.constants); + } else if (action.type === 'Simple') { + pushBuilderOp(context, action); + } else if (action.type === 'Error') {} else { + throw (0, _util.assertNever)(action, `unexpected action type`); + } + } + } + + function populateBuiltins(blocks, inlines) { + blocks.add('if', (params, _hash, blocks) => { + if (!params || params.length !== 1) { + throw new Error(`SYNTAX ERROR: #if requires a single argument`); + } + + return ReplayableIf({ + args() { + return { + count: 1, + actions: [op('Expr', params[0]), op(71 + /* ToBoolean */ + )] + }; + }, + + ifTrue() { + return InvokeStaticBlock(blocks.get('default')); + }, + + ifFalse() { + if (blocks.has('else')) { + return InvokeStaticBlock(blocks.get('else')); + } else { + return NONE; + } + } + + }); + }); + blocks.add('unless', (params, _hash, blocks) => { + if (!params || params.length !== 1) { + throw new Error(`SYNTAX ERROR: #unless requires a single argument`); + } + + return ReplayableIf({ + args() { + return { + count: 1, + actions: [op('Expr', params[0]), op(71 + /* ToBoolean */ + )] + }; + }, + + ifTrue() { + if (blocks.has('else')) { + return InvokeStaticBlock(blocks.get('else')); + } else { + return NONE; + } + }, + + ifFalse() { + return InvokeStaticBlock(blocks.get('default')); + } + + }); + }); + blocks.add('with', (params, _hash, blocks) => { + if (!params || params.length !== 1) { + throw new Error(`SYNTAX ERROR: #with requires a single argument`); + } + + return ReplayableIf({ + args() { + return { + count: 2, + actions: [op('Expr', params[0]), op(33 + /* Dup */ + , _vm.$sp, 0), op(71 + /* ToBoolean */ + )] + }; + }, + + ifTrue() { + return InvokeStaticBlockWithStack(blocks.get('default'), 1); + }, + + ifFalse() { + if (blocks.has('else')) { + return InvokeStaticBlock(blocks.get('else')); + } else { + return NONE; + } + } + + }); + }); + blocks.add('let', (params, _hash, blocks) => { + if (!params) { + return error('let requires arguments', 0, 0); + } + + var { + count, + actions + } = CompilePositional(params); + return [actions, InvokeStaticBlockWithStack(blocks.get('default'), count)]; + }); + blocks.add('each', (params, hash, blocks) => { + return Replayable({ + args() { + var actions; + + if (hash && hash[0][0] === 'key') { + actions = [op('Expr', hash[1][0])]; + } else { + actions = [PushPrimitiveReference(null)]; + } + + actions.push(op('Expr', params[0])); + return { + count: 2, + actions + }; + }, + + body() { + var out = [op(74 + /* PutIterator */ + ), op(66 + /* JumpUnless */ + , label('ELSE')), op(0 + /* PushFrame */ + ), op(33 + /* Dup */ + , _vm.$fp, 1), op(6 + /* ReturnTo */ + , label('ITER')), op(72 + /* EnterList */ + , label('BODY')), op('Label', 'ITER'), op(75 + /* Iterate */ + , label('BREAK')), op('Label', 'BODY'), InvokeStaticBlockWithStack(blocks.get('default'), 2), op(34 + /* Pop */ + , 2), op(4 + /* Jump */ + , label('FINALLY')), op('Label', 'BREAK'), op(73 + /* ExitList */ + ), op(1 + /* PopFrame */ + ), op(4 + /* Jump */ + , label('FINALLY')), op('Label', 'ELSE')]; + + if (blocks.has('else')) { + out.push(InvokeStaticBlock(blocks.get('else'))); + } + + return out; + } + + }); + }); + blocks.add('in-element', (params, hash, blocks) => { + if (!params || params.length !== 1) { + throw new Error(`SYNTAX ERROR: #in-element requires a single argument`); + } + + return ReplayableIf({ + args() { + var [keys, values] = hash; + var actions = []; + + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + + if (key === 'guid' || key === 'insertBefore') { + actions.push(op('Expr', values[i])); + } else { + throw new Error(`SYNTAX ERROR: #in-element does not take a \`${keys[0]}\` option`); + } + } + + actions.push(op('Expr', params[0]), op(33 + /* Dup */ + , _vm.$sp, 0)); + return { + count: 4, + actions + }; + }, + + ifTrue() { + return [op(50 + /* PushRemoteElement */ + ), InvokeStaticBlock(blocks.get('default')), op(56 + /* PopRemoteElement */ + )]; + } + + }); + }); + blocks.add('-with-dynamic-vars', (_params, hash, blocks) => { + if (hash) { + var [names, expressions] = hash; + var { + actions + } = CompilePositional(expressions); + return [actions, DynamicScope(names, () => { + return InvokeStaticBlock(blocks.get('default')); + })]; + } else { + return InvokeStaticBlock(blocks.get('default')); + } + }); + blocks.add('component', (_params, hash, blocks, context) => { + var tag = _params[0]; + + if (typeof tag === 'string') { + var returned = StaticComponentHelper(context, _params[0], hash, blocks.get('default')); + if (isHandled(returned)) return returned; + } + + var [definition, ...params] = _params; + return op('DynamicComponent', { + definition, + attrs: null, + params, + args: hash, + atNames: false, + blocks + }); + }); + inlines.add('component', (_name, _params, hash, context) => { + var tag = _params && _params[0]; + + if (typeof tag === 'string') { + var returned = StaticComponentHelper(context, tag, hash, null); + if (returned !== UNHANDLED) return returned; + } + + var [definition, ...params] = _params; + return InvokeDynamicComponent(context.meta, { + definition, + attrs: null, + params, + hash, + atNames: false, + blocks: EMPTY_BLOCKS + }); + }); + return { + blocks, + inlines + }; + } + + class MacrosImpl { + constructor() { + var { + blocks, + inlines + } = populateBuiltins(new Blocks(), new Inlines()); + this.blocks = blocks; + this.inlines = inlines; + } + + } + + _exports.MacrosImpl = MacrosImpl; + + class Blocks { + constructor() { + this.names = (0, _util.dict)(); + this.funcs = []; + } + + add(name, func) { + this.funcs.push(func); + this.names[name] = this.funcs.length - 1; + } + + addMissing(func) { + this.missing = func; + } + + compile(name, params, hash, blocks, context) { + var index = this.names[name]; + var macroContext = { + resolver: context.syntax.program.resolverDelegate, + meta: context.meta + }; + + if (index === undefined) { + var func = this.missing; + var handled = func(name, params, hash, blocks, macroContext); + return handled; + } else { + var _func = this.funcs[index]; + return _func(params, hash, blocks, macroContext); + } + } + + } + + class Inlines { + constructor() { + this.names = (0, _util.dict)(); + this.funcs = []; + } + + add(name, func) { + this.funcs.push(func); + this.names[name] = this.funcs.length - 1; + } + + addMissing(func) { + this.missing = func; + } + + compile(sexp, context) { + var [,,,, value] = sexp; // TODO: Fix this so that expression macros can return + // things like components, so that {{component foo}} + // is the same as {{(component foo)}} + + if (!Array.isArray(value)) return UNHANDLED; + var name; + var params; + var hash; + + if (value[0] === 31 + /* Call */ + ) { + var nameOrError = expectString(value[3], context.meta, 'Expected head of call to be a string'); + + if (typeof nameOrError !== 'string') { + return nameOrError; + } + + name = nameOrError; + params = value[4]; + hash = value[5]; + } else if (value[0] === 27 + /* GetPath */ + ) { + var pathName = simplePathName(value, context.meta); + + if (pathName === null) { + return UNHANDLED; + } + + name = pathName; + params = null; + hash = null; + } else { + return UNHANDLED; + } + + var index = this.names[name]; + var macroContext = { + resolver: context.syntax.program.resolverDelegate, + meta: context.meta + }; + + if (index === undefined && this.missing) { + var func = this.missing; + return func(name, params, hash, macroContext); + } else if (index !== undefined) { + var _func2 = this.funcs[index]; + return _func2(name, params, hash, macroContext); + } else { + return UNHANDLED; + } + } + + } + + function simplePathName([, get, tail], meta) { + if (tail.length > 0) { + return null; + } + + if (get[0] === 25 + /* GetFree */ + || get[0] === 26 + /* GetContextualFree */ + ) { + return meta.upvars[get[1]]; + } + + return null; + } + + function syntaxCompilationContext(program, macros) { + return { + program, + macros + }; + } + + function Context(resolver = {}, mode = "aot" + /* aot */ + , macros = new MacrosImpl()) { + return { + program: new ProgramCompilationContext(new DefaultCompileTimeResolverDelegate(resolver), mode), + macros + }; + } + + function JitContext(resolver = {}, macros = new MacrosImpl()) { + return { + program: new JitProgramCompilationContext(new DefaultCompileTimeResolverDelegate(resolver)), + macros + }; + } + + function AotContext(resolver = {}, macros = new MacrosImpl()) { + return { + program: new ProgramCompilationContext(new DefaultCompileTimeResolverDelegate(resolver), "aot" + /* aot */ + ), + macros + }; + } + + function templateCompilationContext(syntax, meta) { + var encoder = new EncoderImpl(); + return { + syntax, + encoder, + meta + }; + } + /** + * Yield to a block located at a particular symbol location. + * + * @param to the symbol containing the block to yield to + * @param params optional block parameters to yield to the block + */ + + + function YieldBlock(to, params) { + return [op('SimpleArgs', { + params, + hash: null, + atNames: true + }), op(24 + /* GetBlock */ + , to), op(25 + /* JitSpreadBlock */ + ), op('Option', op('JitCompileBlock')), op(64 + /* InvokeYield */ + ), op(40 + /* PopScope */ + ), op(1 + /* PopFrame */ + )]; + } + /** + * Push an (optional) yieldable block onto the stack. The yieldable block must be known + * statically at compile time. + * + * @param block An optional Compilable block + */ + + + function PushYieldableBlock(block) { + return [PushSymbolTable(block && block.symbolTable), op(62 + /* PushBlockScope */ + ), op('PushCompilable', block)]; + } + /** + * Invoke a block that is known statically at compile time. + * + * @param block a Compilable block + */ + + + function InvokeStaticBlock(block) { + return [op(0 + /* PushFrame */ + ), op('PushCompilable', block), op('JitCompileBlock'), op(2 + /* InvokeVirtual */ + ), op(1 + /* PopFrame */ + )]; + } + /** + * Invoke a static block, preserving some number of stack entries for use in + * updating. + * + * @param block A compilable block + * @param callerCount A number of stack entries to preserve + */ + + + function InvokeStaticBlockWithStack(block, callerCount) { + var { + parameters + } = block.symbolTable; + var calleeCount = parameters.length; + var count = Math.min(callerCount, calleeCount); + + if (count === 0) { + return InvokeStaticBlock(block); + } + + var out = []; + out.push(op(0 + /* PushFrame */ + )); + + if (count) { + out.push(op(39 + /* ChildScope */ + )); + + for (var i = 0; i < count; i++) { + out.push(op(33 + /* Dup */ + , _vm.$fp, callerCount - i)); + out.push(op(19 + /* SetVariable */ + , parameters[i])); + } + } + + out.push(op('PushCompilable', block)); + out.push(op('JitCompileBlock')); + out.push(op(2 + /* InvokeVirtual */ + )); + + if (count) { + out.push(op(40 + /* PopScope */ + )); + } + + out.push(op(1 + /* PopFrame */ + )); + return out; + } + + function PushSymbolTable(table) { + if (table) { + return op(63 + /* PushSymbolTable */ + , serializable(table)); + } else { + return PushPrimitive(null); + } + } + + var STATEMENTS = new StatementCompilers(); + STATEMENTS.add(2 + /* Comment */ + , sexp => op(42 + /* Comment */ + , sexp[1])); + STATEMENTS.add(11 + /* CloseElement */ + , () => op(55 + /* CloseElement */ + )); + STATEMENTS.add(10 + /* FlushElement */ + , () => op(54 + /* FlushElement */ + )); + STATEMENTS.add(3 + /* Modifier */ + , (sexp, meta) => { + var [,,, name, params, hash] = sexp; + var stringName = expectString(name, meta, 'Expected modifier head to be a string'); + + if (typeof stringName !== 'string') { + return stringName; + } + + return op('IfResolved', { + kind: "Modifier" + /* Modifier */ + , + name: stringName, + andThen: handle => [op(0 + /* PushFrame */ + ), op('SimpleArgs', { + params, + hash, + atNames: false + }), op(57 + /* Modifier */ + , handle), op(1 + /* PopFrame */ + )], + span: { + start: 0, + end: 0 + } + }); + }); + STATEMENTS.add(12 + /* StaticAttr */ + , ([, name, value, namespace]) => op(51 + /* StaticAttr */ + , name, value, namespace)); + STATEMENTS.add(23 + /* StaticComponentAttr */ + , ([, name, value, namespace]) => op(108 + /* StaticComponentAttr */ + , name, value, namespace)); + STATEMENTS.add(13 + /* DynamicAttr */ + , ([, name, value, namespace]) => [op('Expr', value), op(52 + /* DynamicAttr */ + , name, false, namespace)]); + STATEMENTS.add(20 + /* TrustingDynamicAttr */ + , ([, name, value, namespace]) => [op('Expr', value), op(52 + /* DynamicAttr */ + , name, true, namespace)]); + STATEMENTS.add(14 + /* ComponentAttr */ + , ([, name, value, namespace]) => [op('Expr', value), op(53 + /* ComponentAttr */ + , name, false, namespace)]); + STATEMENTS.add(21 + /* TrustingComponentAttr */ + , ([, name, value, namespace]) => [op('Expr', value), op(53 + /* ComponentAttr */ + , name, true, namespace)]); + STATEMENTS.add(9 + /* OpenElement */ + , ([, tag, simple]) => { + if (simple) { + return op(48 + /* OpenElement */ + , tag); + } else { + return [op(91 + /* PutComponentOperations */ + ), op(48 + /* OpenElement */ + , tag)]; + } + }); + STATEMENTS.add(7 + /* Component */ + , ([, tag, attrs, args$$1, blocks]) => { + if (typeof tag === 'string') { + return op('IfResolvedComponent', { + name: tag, + attrs, + blocks, + staticTemplate: (layoutHandle, capabilities, template, { + blocks, + attrs + }) => { + return [op(80 + /* PushComponentDefinition */ + , layoutHandle), InvokeStaticComponent({ + capabilities, + layout: template, + attrs, + params: null, + hash: args$$1, + blocks + })]; + }, + dynamicTemplate: (layoutHandle, capabilities, { + attrs, + blocks + }) => { + return [op(80 + /* PushComponentDefinition */ + , layoutHandle), InvokeComponent({ + capabilities, + attrs, + params: null, + hash: args$$1, + atNames: true, + blocks + })]; + } + }); + } else { + return op('DynamicComponent', { + definition: tag, + attrs, + params: null, + args: args$$1, + blocks, + atNames: true + }); + } + }); + STATEMENTS.add(17 + /* Partial */ + , ([, name, evalInfo], meta) => ReplayableIf({ + args() { + return { + count: 2, + actions: [op('Expr', name), op(33 + /* Dup */ + , _vm.$sp, 0)] + }; + }, + + ifTrue() { + return [op(104 + /* InvokePartial */ + , templateMeta(meta.referrer), strArray(meta.evalSymbols), arr(evalInfo)), op(40 + /* PopScope */ + ), op(1 + /* PopFrame */ + )]; + } + + })); + STATEMENTS.add(16 + /* Yield */ + , ([, to, params]) => YieldBlock(to, params)); + STATEMENTS.add(15 + /* AttrSplat */ + , ([, to]) => YieldBlock(to, _util.EMPTY_ARRAY)); + STATEMENTS.add(22 + /* Debugger */ + , ([, evalInfo], meta) => op(106 + /* Debugger */ + , strArray(meta.evalSymbols), arr(evalInfo))); + STATEMENTS.add(1 + /* Append */ + , sexp => { + var [, trusted,,, value] = sexp; + + if (typeof value === 'string' && trusted) { + return op(41 + /* Text */ + , value); + } + + return op('CompileInline', { + inline: sexp, + ifUnhandled: () => [op(0 + /* PushFrame */ + ), op("Expr" + /* Expr */ + , value), op(3 + /* InvokeStatic */ + , { + type: 'stdlib', + value: trusted ? 'trusting-append' : 'cautious-append' + }), op(1 + /* PopFrame */ + )] + }); + }); + STATEMENTS.add(5 + /* Block */ + , sexp => { + return op('CompileBlock', sexp); + }); + var PLACEHOLDER_HANDLE = -1; + + class CompilableTemplateImpl { + constructor(statements, meta$$1, // Part of CompilableTemplate + symbolTable) { + this.statements = statements; + this.meta = meta$$1; + this.symbolTable = symbolTable; + this.compiled = null; + } // Part of CompilableTemplate + + + compile(context) { + return maybeCompile(this, context); + } + + } + + function compilable(layout) { + var block = layout.block; + return new CompilableTemplateImpl(block.statements, meta(layout), { + symbols: block.symbols, + hasEval: block.hasEval + }); + } + + function maybeCompile(compilable, context) { + if (compilable.compiled !== null) return compilable.compiled; + compilable.compiled = PLACEHOLDER_HANDLE; + var { + statements, + meta: meta$$1 + } = compilable; + var result = compileStatements(statements, meta$$1, context); + (0, _program.patchStdlibs)(context.program); + compilable.compiled = result; + return result; + } + + function compileStatements(statements, meta$$1, syntaxContext) { + var sCompiler = STATEMENTS; + var context = templateCompilationContext(syntaxContext, meta$$1); + + for (var i = 0; i < statements.length; i++) { + concatStatements(context, sCompiler.compile(statements[i], context.meta)); + } + + var handle = context.encoder.commit(syntaxContext.program.heap, meta$$1.size); + return handle; + } + + function compilableBlock(overloadBlock, containing) { + var block = Array.isArray(overloadBlock) ? { + statements: overloadBlock, + parameters: _util.EMPTY_ARRAY + } : overloadBlock; + return new CompilableTemplateImpl(block.statements, containing, { + parameters: block.parameters + }); + } + + class NamedBlocksImpl { + constructor(blocks) { + this.blocks = blocks; + } + + get(name) { + if (!this.blocks) return null; + return this.blocks[name] || null; + } + + has(name) { + var { + blocks + } = this; + return blocks !== null && name in blocks; + } + + with(name, block) { + var { + blocks + } = this; + + if (blocks) { + return new NamedBlocksImpl((0, _util.assign)({}, blocks, { + [name]: block + })); + } else { + return new NamedBlocksImpl({ + [name]: block + }); + } + } + + get hasAny() { + return this.blocks !== null; + } + + } + + var EMPTY_BLOCKS = new NamedBlocksImpl(null); + _exports.EMPTY_BLOCKS = EMPTY_BLOCKS; + + function namedBlocks(blocks, meta) { + if (blocks === null) { + return EMPTY_BLOCKS; + } + + var out = (0, _util.dict)(); + var [keys, values] = blocks; + + for (var i = 0; i < keys.length; i++) { + out[keys[i]] = compilableBlock(values[i], meta); + } + + return new NamedBlocksImpl(out); + } + + function expectString(expr, meta, desc) { + if (!meta.upvars) { + return error(`${desc}, but there were no free variables in the template`, 0, 0); + } + + if (!Array.isArray(expr) || expr[0] !== 27 + /* GetPath */ + ) { + throw new Error(`${desc}, got ${JSON.stringify(expr)}`); + } + + if (expr[2].length !== 0) { + throw new Error(`${desc}, got ${JSON.stringify(expr)}`); + } + + if (expr[1][0] === 26 + /* GetContextualFree */ + || expr[1][0] === 25 + /* GetFree */ + ) { + var head = expr[1][1]; + return meta.upvars[head]; + } + + throw new Error(`${desc}, got ${JSON.stringify(expr)}`); + } + + class WrappedBuilder { + constructor(layout) { + this.layout = layout; + this.compiled = null; + var { + block + } = layout; + var symbols = block.symbols.slice(); // ensure ATTRS_BLOCK is always included (only once) in the list of symbols + + var attrsBlockIndex = symbols.indexOf(ATTRS_BLOCK); + + if (attrsBlockIndex === -1) { + this.attrsBlockNumber = symbols.push(ATTRS_BLOCK); + } else { + this.attrsBlockNumber = attrsBlockIndex + 1; + } + + this.symbolTable = { + hasEval: block.hasEval, + symbols + }; + } + + compile(syntax) { + if (this.compiled !== null) return this.compiled; + var m = meta(this.layout); + var context = templateCompilationContext(syntax, m); + var actions = WrappedComponent(this.layout, this.attrsBlockNumber); + concatStatements(context, actions); + var handle = context.encoder.commit(context.syntax.program.heap, m.size); + + if (typeof handle !== 'number') { + return handle; + } + + this.compiled = handle; + (0, _program.patchStdlibs)(context.syntax.program); + return handle; + } + + } + + _exports.WrappedBuilder = WrappedBuilder; + var clientId = 0; + + function templateFactory({ + id: templateId, + meta, + block + }) { + var parsedBlock; + var id = templateId || `client-${clientId++}`; + + var create = envMeta => { + var newMeta = envMeta ? (0, _util.assign)({}, envMeta, meta) : meta; + + if (!parsedBlock) { + parsedBlock = JSON.parse(block); + } + + return new TemplateImpl({ + id, + block: parsedBlock, + referrer: newMeta + }); + }; + + return { + id, + meta, + create + }; + } + + class TemplateImpl { + constructor(parsedLayout) { + this.parsedLayout = parsedLayout; + this.result = 'ok'; + this.layout = null; + this.partial = null; + this.wrappedLayout = null; + var { + block + } = parsedLayout; + this.symbols = block.symbols; + this.hasEval = block.hasEval; + this.referrer = parsedLayout.referrer; + this.id = parsedLayout.id || `client-${clientId++}`; + } + + asLayout() { + if (this.layout) return this.layout; + return this.layout = compilable((0, _util.assign)({}, this.parsedLayout, { + asPartial: false + })); + } + + asPartial() { + if (this.partial) return this.partial; + return this.layout = compilable((0, _util.assign)({}, this.parsedLayout, { + asPartial: true + })); + } + + asWrappedLayout() { + if (this.wrappedLayout) return this.wrappedLayout; + return this.wrappedLayout = new WrappedBuilder((0, _util.assign)({}, this.parsedLayout, { + asPartial: false + })); + } + + } + + function Component(serialized, envMeta) { + var parsed = JSON.parse(serialized); + var factory = templateFactory(parsed); + var template = unwrapTemplate(factory.create(envMeta)); + return template.asLayout(); + } + + function unwrapTemplate(template) { + if (template.result === 'error') { + throw new Error(`Compile Error: ${template.problem} @ ${template.span.start}..${template.span.end}`); + } + + return template; + } + + function unwrapHandle(handle) { + if (typeof handle === 'number') { + return handle; + } else { + var _error = handle.errors[0]; + throw new Error(`Compile Error: ${_error.problem} @ ${_error.span.start}..${_error.span.end}`); + } + } + + function extractHandle(handle) { + if (typeof handle === 'number') { + return handle; + } else { + return handle.handle; + } + } + + function isOkHandle(handle) { + return typeof handle === 'number'; + } + + function isErrHandle(handle) { + return typeof handle === 'number'; } -}); -define("@ember/service/index", ["exports", "@ember/-internals/runtime", "@ember/-internals/metal"], function (_exports, _runtime, _metal) { - "use strict"; - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.inject = inject; - _exports.default = void 0; + function compileInline(sexp, context) { + return context.syntax.macros.inlines.compile(sexp, context); + } - /** - @module @ember/service - @public - */ + function compileBlock(block, context) { + var [, name, params, hash, named] = block; + var blocks = namedBlocks(named, context.meta); + var nameOrError = expectString(name, context.meta, 'Expected block head to be a string'); - /** - Creates a property that lazily looks up a service in the container. There are - no restrictions as to what objects a service can be injected into. - - Example: - - ```app/routes/application.js - import Route from '@ember/routing/route'; - import { inject as service } from '@ember/service'; - - export default class ApplicationRoute extends Route { - @service('auth') authManager; - - model() { - return this.authManager.findCurrentUser(); - } + if (typeof nameOrError !== 'string') { + return nameOrError; } - ``` - - Classic Class Example: - - ```app/routes/application.js - import Route from '@ember/routing/route'; - import { inject as service } from '@ember/service'; - - export default Route.extend({ - authManager: service('auth'), - - model() { - return this.get('authManager').findCurrentUser(); + + return context.syntax.macros.blocks.compile(nameOrError, params || [], hash, blocks, context); + } + + function commit(heap, scopeSize, buffer) { + var handle = heap.malloc(); + + for (var i = 0; i < buffer.length; i++) { + var value = buffer[i]; + + if (typeof value === 'function') { + heap.pushPlaceholder(value); + } else if (typeof value === 'object') { + heap.pushStdlib(value); + } else { + heap.push(value); } - }); - ``` - - This example will create an `authManager` property on the application route - that looks up the `auth` service in the container, making it easily accessible - in the `model` hook. - - @method inject - @static - @since 1.10.0 - @for @ember/service - @param {String} name (optional) name of the service to inject, defaults to - the property's name - @return {ComputedDecorator} injection decorator instance - @public - */ - function inject() { - return (0, _metal.inject)('service', ...arguments); + } + + heap.finishMalloc(handle, scopeSize); + return handle; } - /** - @class Service - @extends EmberObject - @since 1.10.0 - @public - */ + var debugCompiler; + _exports.debugCompiler = debugCompiler; - var Service = _runtime.FrameworkObject.extend(); + class LabelsImpl { + constructor() { + this.labels = (0, _util.dict)(); + this.targets = []; + } - Service.reopenClass({ - isServiceFactory: true - }); - (0, _runtime.setFrameworkClass)(Service); - var _default = Service; - _exports.default = _default; -}); -define("@ember/string/index", ["exports", "@ember/string/lib/string_registry", "@ember/-internals/environment", "@ember/-internals/utils"], function (_exports, _string_registry, _environment, _utils) { - "use strict"; + label(name, index) { + this.labels[name] = index; + } - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.loc = loc; - _exports.w = w; - _exports.decamelize = decamelize; - _exports.dasherize = dasherize; - _exports.camelize = camelize; - _exports.classify = classify; - _exports.underscore = underscore; - _exports.capitalize = capitalize; - Object.defineProperty(_exports, "_getStrings", { - enumerable: true, - get: function () { - return _string_registry.getStrings; + target(at, target) { + this.targets.push({ + at, + target + }); } - }); - Object.defineProperty(_exports, "_setStrings", { - enumerable: true, - get: function () { - return _string_registry.setStrings; + + patch(encoder) { + var { + targets, + labels + } = this; + + for (var i = 0; i < targets.length; i++) { + var { + at, + target + } = targets[i]; + var address = labels[target] - at; + encoder.patch(at, address); + } } - }); - /** - @module @ember/string - */ - var STRING_DASHERIZE_REGEXP = /[ _]/g; - var STRING_DASHERIZE_CACHE = new _utils.Cache(1000, key => decamelize(key).replace(STRING_DASHERIZE_REGEXP, '-')); - var STRING_CAMELIZE_REGEXP_1 = /(\-|\_|\.|\s)+(.)?/g; - var STRING_CAMELIZE_REGEXP_2 = /(^|\/)([A-Z])/g; - var CAMELIZE_CACHE = new _utils.Cache(1000, key => key.replace(STRING_CAMELIZE_REGEXP_1, (_match, _separator, chr) => chr ? chr.toUpperCase() : '').replace(STRING_CAMELIZE_REGEXP_2, (match - /*, separator, chr */ - ) => match.toLowerCase())); - var STRING_CLASSIFY_REGEXP_1 = /^(\-|_)+(.)?/; - var STRING_CLASSIFY_REGEXP_2 = /(.)(\-|\_|\.|\s)+(.)?/g; - var STRING_CLASSIFY_REGEXP_3 = /(^|\/|\.)([a-z])/g; - var CLASSIFY_CACHE = new _utils.Cache(1000, str => { - var replace1 = (_match, _separator, chr) => chr ? "_" + chr.toUpperCase() : ''; + } - var replace2 = (_match, initialChar, _separator, chr) => initialChar + (chr ? chr.toUpperCase() : ''); + function error(problem, start, end) { + return op('Error', { + problem, + start, + end + }); + } - var parts = str.split('/'); + function op(name, op1, op2, op3) { + if (typeof name === 'number') { + if (op3 !== undefined) { + return { + type: 'Number', + op: name, + op1, + op2, + op3 + }; + } else if (op2 !== undefined) { + return { + type: 'Number', + op: name, + op1, + op2 + }; + } else if (op1 !== undefined) { + return { + type: 'Number', + op: name, + op1: op1 + }; + } else { + return { + type: 'Number', + op: name + }; + } + } else { + var type; + + if (isCompileOpcode(name)) { + type = 'Compile'; + } else if (isResolutionOpcode(name)) { + type = 'Resolution'; + } else if (isSimpleOpcode(name)) { + type = 'Simple'; + } else if (isErrorOpcode(name)) { + type = 'Error'; + } else { + throw new Error(`Exhausted ${name}`); + } - for (var i = 0; i < parts.length; i++) { - parts[i] = parts[i].replace(STRING_CLASSIFY_REGEXP_1, replace1).replace(STRING_CLASSIFY_REGEXP_2, replace2); + if (op1 === undefined) { + return { + type, + op: name, + op1: undefined + }; + } else { + return { + type, + op: name, + op1 + }; + } } + } - return parts.join('/').replace(STRING_CLASSIFY_REGEXP_3, (match - /*, separator, chr */ - ) => match.toUpperCase()); - }); - var STRING_UNDERSCORE_REGEXP_1 = /([a-z\d])([A-Z]+)/g; - var STRING_UNDERSCORE_REGEXP_2 = /\-|\s+/g; - var UNDERSCORE_CACHE = new _utils.Cache(1000, str => str.replace(STRING_UNDERSCORE_REGEXP_1, '$1_$2').replace(STRING_UNDERSCORE_REGEXP_2, '_').toLowerCase()); - var STRING_CAPITALIZE_REGEXP = /(^|\/)([a-z\u00C0-\u024F])/g; - var CAPITALIZE_CACHE = new _utils.Cache(1000, str => str.replace(STRING_CAPITALIZE_REGEXP, (match - /*, separator, chr */ - ) => match.toUpperCase())); - var STRING_DECAMELIZE_REGEXP = /([a-z\d])([A-Z])/g; - var DECAMELIZE_CACHE = new _utils.Cache(1000, str => str.replace(STRING_DECAMELIZE_REGEXP, '$1_$2').toLowerCase()); - /** - Defines string helper methods including string formatting and localization. - Unless `EmberENV.EXTEND_PROTOTYPES.String` is `false` these methods will also be - added to the `String.prototype` as well. - - @class String - @public - */ + class EncoderImpl { + constructor() { + this.labelsStack = new _util.Stack(); + this.encoder = new _encoder.InstructionEncoderImpl([]); + this.errors = []; + } - function _fmt(str, formats) { - // first, replace any ORDERED replacements. - var idx = 0; // the current index for non-numerical replacements + error(error) { + this.encoder.encode(30 + /* Primitive */ + , 0); + this.errors.push(error); + } - return str.replace(/%@([0-9]+)?/g, (_s, argIndex) => { - var i = argIndex ? parseInt(argIndex, 10) - 1 : idx++; - var r = i < formats.length ? formats[i] : undefined; - return typeof r === 'string' ? r : r === null ? '(null)' : r === undefined ? '' : String(r); - }); - } - /** - Formats the passed string, but first looks up the string in the localized - strings hash. This is a convenient way to localize text. - - Note that it is traditional but not required to prefix localized string - keys with an underscore or other character so you can easily identify - localized strings. - - ```javascript - import { loc } from '@ember/string'; - - Ember.STRINGS = { - '_Hello World': 'Bonjour le monde', - '_Hello %@ %@': 'Bonjour %@ %@' - }; - - loc("_Hello World"); // 'Bonjour le monde'; - loc("_Hello %@ %@", ["John", "Smith"]); // "Bonjour John Smith"; - ``` - - @method loc - @param {String} str The string to format - @param {Array} formats Optional array of parameters to interpolate into string. - @return {String} formatted string - @public - */ + commit(heap, size) { + this.encoder.encode(5 + /* Return */ + , 1024 + /* MACHINE_MASK */ + ); + var handle = commit(heap, size, this.encoder.buffer); + + if (this.errors.length) { + return { + errors: this.errors, + handle + }; + } else { + return handle; + } + } + push(constants, name, ...args) { + if ((0, _vm.isMachineOp)(name)) { + var operands = args.map((operand, i) => this.operand(constants, operand, i)); + return this.encoder.encode(name, 1024 + /* MACHINE_MASK */ + , ...operands); + } else { + var _operands = args.map((operand, i) => this.operand(constants, operand, i)); - function loc(str, formats) { - if (!Array.isArray(formats) || arguments.length > 2) { - formats = Array.prototype.slice.call(arguments, 1); + return this.encoder.encode(name, 0, ..._operands); + } } - str = (0, _string_registry.getString)(str) || str; - return _fmt(str, formats); - } - /** - Splits a string into separate units separated by spaces, eliminating any - empty strings in the process. This is a convenience method for split that - is mostly useful when applied to the `String.prototype`. - - ```javascript - import { w } from '@ember/string'; - - w("alpha beta gamma").forEach(function(key) { - console.log(key); - }); - - // > alpha - // > beta - // > gamma - ``` - - @method w - @param {String} str The string to split - @return {Array} array containing the split strings - @public - */ + operand(constants, operand, index) { + if (operand && typeof operand === 'object' && operand.type === 'label') { + this.currentLabels.target(this.encoder.size + index, operand.value); + return -1; + } + return constant(constants, operand); + } - function w(str) { - return str.split(/\s+/); - } - /** - Converts a camelized string into all lower case separated by underscores. - - ```javascript - import { decamelize } from '@ember/string'; - - decamelize('innerHTML'); // 'inner_html' - decamelize('action_name'); // 'action_name' - decamelize('css-class-name'); // 'css-class-name' - decamelize('my favorite items'); // 'my favorite items' - ``` - - @method decamelize - @param {String} str The string to decamelize. - @return {String} the decamelized string. - @public - */ + get currentLabels() { + return this.labelsStack.current; + } + label(name) { + this.currentLabels.label(name, this.encoder.size); + } - function decamelize(str) { - return DECAMELIZE_CACHE.get(str); - } - /** - Replaces underscores, spaces, or camelCase with dashes. - - ```javascript - import { dasherize } from '@ember/string'; - - dasherize('innerHTML'); // 'inner-html' - dasherize('action_name'); // 'action-name' - dasherize('css-class-name'); // 'css-class-name' - dasherize('my favorite items'); // 'my-favorite-items' - dasherize('privateDocs/ownerInvoice'; // 'private-docs/owner-invoice' - ``` - - @method dasherize - @param {String} str The string to dasherize. - @return {String} the dasherized string. - @public - */ + startLabels() { + this.labelsStack.push(new LabelsImpl()); + } + stopLabels() { + var label = this.labelsStack.pop(); + label.patch(this.encoder); + } - function dasherize(str) { - return STRING_DASHERIZE_CACHE.get(str); } - /** - Returns the lowerCamelCase form of a string. - - ```javascript - import { camelize } from '@ember/string'; - - camelize('innerHTML'); // 'innerHTML' - camelize('action_name'); // 'actionName' - camelize('css-class-name'); // 'cssClassName' - camelize('my favorite items'); // 'myFavoriteItems' - camelize('My Favorite Items'); // 'myFavoriteItems' - camelize('private-docs/owner-invoice'); // 'privateDocs/ownerInvoice' - ``` - - @method camelize - @param {String} str The string to camelize. - @return {String} the camelized string. - @public - */ + function constant(constants, operand) { + if (typeof operand === 'number' || typeof operand === 'function') { + return operand; + } - function camelize(str) { - return CAMELIZE_CACHE.get(str); - } - /** - Returns the UpperCamelCase form of a string. - - ```javascript - import { classify } from '@ember/string'; - - classify('innerHTML'); // 'InnerHTML' - classify('action_name'); // 'ActionName' - classify('css-class-name'); // 'CssClassName' - classify('my favorite items'); // 'MyFavoriteItems' - classify('private-docs/owner-invoice'); // 'PrivateDocs/OwnerInvoice' - ``` - - @method classify - @param {String} str the string to classify - @return {String} the classified string - @public - */ + if (typeof operand === 'boolean') { + return operand === true ? 1 : 0; + } + if (typeof operand === 'string') { + return constants.string(operand); + } - function classify(str) { - return CLASSIFY_CACHE.get(str); - } - /** - More general than decamelize. Returns the lower\_case\_and\_underscored - form of a string. - - ```javascript - import { underscore } from '@ember/string'; - - underscore('innerHTML'); // 'inner_html' - underscore('action_name'); // 'action_name' - underscore('css-class-name'); // 'css_class_name' - underscore('my favorite items'); // 'my_favorite_items' - underscore('privateDocs/ownerInvoice'); // 'private_docs/owner_invoice' - ``` - - @method underscore - @param {String} str The string to underscore. - @return {String} the underscored string. - @public - */ + if (operand === null) { + return 0; + } + switch (operand.type) { + case 'array': + return constants.array(operand.value); - function underscore(str) { - return UNDERSCORE_CACHE.get(str); - } - /** - Returns the Capitalized form of a string - - ```javascript - import { capitalize } from '@ember/string'; - - capitalize('innerHTML') // 'InnerHTML' - capitalize('action_name') // 'Action_name' - capitalize('css-class-name') // 'Css-class-name' - capitalize('my favorite items') // 'My favorite items' - capitalize('privateDocs/ownerInvoice'); // 'PrivateDocs/ownerInvoice' - ``` - - @method capitalize - @param {String} str The string to capitalize. - @return {String} The capitalized string. - @public - */ + case 'string-array': + return constants.stringArray(operand.value); + case 'serializable': + return constants.serializable(operand.value); - function capitalize(str) { - return CAPITALIZE_CACHE.get(str); - } + case 'template-meta': + return constants.templateMeta(operand.value); - if (_environment.ENV.EXTEND_PROTOTYPES.String) { - Object.defineProperties(String.prototype, { - /** - See [String.w](/ember/release/classes/String/methods/w?anchor=w). - @method w - @for @ember/string - @static - @private - */ - w: { - configurable: true, - enumerable: false, - writeable: true, + case 'other': + // TODO: Bad cast + return constants.other(operand.value); - value() { - return w(this); + case 'stdlib': + return operand; + + case 'primitive': + { + switch (operand.value.type) { + case 1 + /* STRING */ + : + return (0, _util.encodeHandle)(constants.string(operand.value.primitive), 1073741823 + /* STRING_MAX_INDEX */ + , -1 + /* STRING_MAX_HANDLE */ + ); + + case 2 + /* NUMBER */ + : + return (0, _util.encodeHandle)(constants.number(operand.value.primitive), 1073741823 + /* NUMBER_MAX_INDEX */ + , -1073741825 + /* NUMBER_MAX_HANDLE */ + ); + + case 0 + /* IMMEDIATE */ + : + return (0, _util.encodeImmediate)(operand.value.primitive); + + default: + return (0, _util.exhausted)(operand.value); + } } - }, + case 'lookup': + throw (0, _util.unreachable)('lookup not reachable'); - /** - See [String.loc](/ember/release/classes/String/methods/loc?anchor=loc). - @method loc - @for @ember/string - @static - @private - */ - loc: { - configurable: true, - enumerable: false, - writeable: true, + default: + return (0, _util.exhausted)(operand); + } + } - value(...args) { - return loc(this, args); - } + function isSimpleOpcode(op) { + return op === 'Label' || op === 'Option' || op === 'GetComponentLayout' || op === 'StartLabels' || op === 'StopLabels' || op === 'SimpleArgs' || op === 'JitCompileBlock' || op === 'SetBlock'; + } - }, + function isCompileOpcode(op) { + return op === 'CompileInline' || op === 'CompileBlock' || op === 'InvokeStatic' || op === 'PushCompilable' || op === 'Args' || op === 'IfResolvedComponent' || op === 'DynamicComponent'; + } - /** - See [String.camelize](/ember/release/classes/String/methods/camelize?anchor=camelize). - @method camelize - @for @ember/string - @static - @private - */ - camelize: { - configurable: true, - enumerable: false, - writeable: true, + function isResolutionOpcode(op) { + return op === 'IfResolved' || op === 'Expr' || op === 'SimpleArgs' || op === 'ResolveFree' || op === 'ResolveContextualFree'; + } - value() { - return camelize(this); - } + function isErrorOpcode(op) { + return op === 'Error'; + } + /** + * Compile arguments, pushing an Arguments object onto the stack. + * + * @param args.params + * @param args.hash + * @param args.blocks + * @param args.atNames + */ - }, - /** - See [String.decamelize](/ember/release/classes/String/methods/decamelize?anchor=decamelize). - @method decamelize - @for @ember/string - @static - @private - */ - decamelize: { - configurable: true, - enumerable: false, - writeable: true, + function CompileArgs({ + params, + hash, + blocks, + atNames + }) { + var out = []; + + if (blocks.hasAny) { + out.push(PushYieldableBlock(blocks.get('default'))); + out.push(PushYieldableBlock(blocks.get('else'))); + out.push(PushYieldableBlock(blocks.get('attrs'))); + } + + var { + count, + actions + } = CompilePositional(params); + out.push(actions); + var flags = count << 4; + if (atNames) flags |= 0b1000; - value() { - return decamelize(this); - } + if (blocks) { + flags |= 0b111; + } - }, + var names = _util.EMPTY_ARRAY; - /** - See [String.dasherize](/ember/release/classes/String/methods/dasherize?anchor=dasherize). - @method dasherize - @for @ember/string - @static - @private - */ - dasherize: { - configurable: true, - enumerable: false, - writeable: true, + if (hash) { + names = hash[0]; + var val = hash[1]; - value() { - return dasherize(this); - } + for (var i = 0; i < val.length; i++) { + out.push(op('Expr', val[i])); + } + } - }, + out.push(op(84 + /* PushArgs */ + , strArray(names), flags)); + return out; + } + /** + * Compile an optional list of positional arguments, which pushes each argument + * onto the stack and returns the number of parameters compiled + * + * @param params an optional list of positional arguments + */ - /** - See [String.underscore](/ember/release/classes/String/methods/underscore?anchor=underscore). - @method underscore - @for @ember/string - @static - @private - */ - underscore: { - configurable: true, - enumerable: false, - writeable: true, - value() { - return underscore(this); - } + function CompilePositional(params) { + if (!params) return { + count: 0, + actions: NONE + }; + var actions = []; - }, + for (var i = 0; i < params.length; i++) { + actions.push(op('Expr', params[i])); + } - /** - See [String.classify](/ember/release/classes/String/methods/classify?anchor=classify). - @method classify - @for @ember/string - @static - @private - */ - classify: { - configurable: true, - enumerable: false, - writeable: true, + return { + count: params.length, + actions + }; + } - value() { - return classify(this); - } + function meta(layout) { + return { + asPartial: layout.asPartial || false, + evalSymbols: evalSymbols(layout), + upvars: layout.block.upvars, + referrer: layout.referrer, + size: layout.block.symbols.length + }; + } - }, + function evalSymbols(layout) { + var { + block + } = layout; + return block.hasEval ? block.symbols : null; + } - /** - See [String.capitalize](/ember/release/classes/String/methods/capitalize?anchor=capitalize). - @method capitalize - @for @ember/string - @static - @private - */ - capitalize: { - configurable: true, - enumerable: false, - writeable: true, + function StaticComponentHelper(context, tag, hash, template) { + var component = resolveLayoutForTag(tag, context); - value() { - return capitalize(this); + if (component !== null) { + var { + compilable: compilable$$1, + handle, + capabilities + } = component; + + if (compilable$$1) { + if (hash) { + for (var i = 0; i < hash.length; i = i + 2) { + hash[i][0] = `@${hash[i][0]}`; + } } + var out = [op(80 + /* PushComponentDefinition */ + , handle)]; + out.push(InvokeStaticComponent({ + capabilities, + layout: compilable$$1, + attrs: null, + params: null, + hash, + blocks: new NamedBlocksImpl({ + default: template + }) + })); + return out; } - }); + } + + return UNHANDLED; } -}); -define("@ember/string/lib/string_registry", ["exports"], function (_exports) { - "use strict"; - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.setStrings = setStrings; - _exports.getStrings = getStrings; - _exports.getString = getString; - // STATE within a module is frowned upon, this exists - // to support Ember.STRINGS but shield ember internals from this legacy global - // API. - var STRINGS = {}; + function InvokeStaticComponent({ + capabilities, + layout, + attrs, + params, + hash, + blocks + }) { + var { + symbolTable + } = layout; + var bailOut = symbolTable.hasEval || capabilities.prepareArgs; - function setStrings(strings) { - STRINGS = strings; - } + if (bailOut) { + return InvokeComponent({ + capabilities, + attrs, + params, + hash, + atNames: true, + blocks, + layout + }); + } - function getStrings() { - return STRINGS; - } + var out = [op(36 + /* Fetch */ + , _vm.$s0), op(33 + /* Dup */ + , _vm.$sp, 1), op(35 + /* Load */ + , _vm.$s0)]; + var { + symbols + } = symbolTable; - function getString(name) { - return STRINGS[name]; - } -}); -define("@glimmer/encoder", ["exports"], function (_exports) { - "use strict"; + if (capabilities.createArgs) { + out.push(op(0 + /* PushFrame */ + ), op('SimpleArgs', { + params, + hash, + atNames: true + })); + } - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.InstructionEncoder = void 0; + out.push(op(100 + /* BeginComponentTransaction */ + )); - class InstructionEncoder { - constructor(buffer) { - this.buffer = buffer; - this.typePos = 0; - this.size = 0; + if (capabilities.dynamicScope) { + out.push(op(59 + /* PushDynamicScope */ + )); } - encode(type, machine) { - if (type > 255 - /* TYPE_SIZE */ - ) { - throw new Error("Opcode type over 8-bits. Got " + type + "."); - } + if (capabilities.createInstance) { + out.push(op(89 + /* CreateComponent */ + , blocks.has('default') | 0, _vm.$s0)); + } - this.buffer.push(type | machine | arguments.length - 2 << 8 - /* ARG_SHIFT */ - ); - this.typePos = this.buffer.length - 1; + if (capabilities.createArgs) { + out.push(op(1 + /* PopFrame */ + )); + } - for (var i = 2; i < arguments.length; i++) { - var op = arguments[i]; + out.push(op(0 + /* PushFrame */ + ), op(90 + /* RegisterComponentDestructor */ + , _vm.$s0)); + var bindings = []; + out.push(op(92 + /* GetComponentSelf */ + , _vm.$s0)); + bindings.push({ + symbol: 0, + isBlock: false + }); - if (typeof op === 'number' && op > 4294967295 - /* MAX_SIZE */ - ) { - throw new Error("Operand over 32-bits. Got " + op + "."); + for (var i = 0; i < symbols.length; i++) { + var symbol = symbols[i]; + + switch (symbol.charAt(0)) { + case '&': + var callerBlock = void 0; + + if (symbol === ATTRS_BLOCK) { + callerBlock = attrs; + } else { + callerBlock = blocks.get(symbol.slice(1)); } - this.buffer.push(op); - } + if (callerBlock) { + out.push(PushYieldableBlock(callerBlock)); + bindings.push({ + symbol: i + 1, + isBlock: true + }); + } else { + out.push(PushYieldableBlock(null)); + bindings.push({ + symbol: i + 1, + isBlock: true + }); + } - this.size = this.buffer.length; - } + break; - patch(position, target) { - if (this.buffer[position + 1] === -1) { - this.buffer[position + 1] = target; - } else { - throw new Error('Trying to patch operand in populated slot instead of a reserved slot.'); + case '@': + if (!hash) { + break; + } + + var [keys, values] = hash; + var lookupName = symbol; + var index = keys.indexOf(lookupName); + + if (index !== -1) { + out.push(op('Expr', values[index])); + bindings.push({ + symbol: i + 1, + isBlock: false + }); + } + + break; } } - patchWith(position, target, operand) { - if (this.buffer[position + 1] === -1) { - this.buffer[position + 1] = target; - this.buffer[position + 2] = operand; + out.push(op(37 + /* RootScope */ + , symbols.length + 1, Object.keys(blocks).length > 0 ? 1 : 0)); + + for (var _i = bindings.length - 1; _i >= 0; _i--) { + var { + symbol: _symbol, + isBlock + } = bindings[_i]; + + if (isBlock) { + out.push(op('SetBlock', _symbol)); } else { - throw new Error('Trying to patch operand in populated slot instead of a reserved slot.'); + out.push(op(19 + /* SetVariable */ + , _symbol)); } } + out.push(op('InvokeStatic', layout)); + + if (capabilities.createInstance) { + out.push(op(103 + /* DidRenderLayout */ + , _vm.$s0)); + } + + out.push(op(1 + /* PopFrame */ + ), op(40 + /* PopScope */ + )); + + if (capabilities.dynamicScope) { + out.push(op(60 + /* PopDynamicScope */ + )); + } + + out.push(op(101 + /* CommitComponentTransaction */ + ), op(35 + /* Load */ + , _vm.$s0)); + return out; } - _exports.InstructionEncoder = InstructionEncoder; -}); -define("@glimmer/low-level", ["exports"], function (_exports) { - "use strict"; + function InvokeDynamicComponent(meta$$1, { + definition, + attrs, + params, + hash, + atNames, + blocks + }) { + return Replayable({ + args: () => { + return { + count: 2, + actions: [op('Expr', definition), op(33 + /* Dup */ + , _vm.$sp, 0)] + }; + }, + body: () => { + return [op(66 + /* JumpUnless */ + , label('ELSE')), op(83 + /* ResolveDynamicComponent */ + , templateMeta(meta$$1.referrer)), op(81 + /* PushDynamicComponentInstance */ + ), InvokeComponent({ + capabilities: true, + attrs, + params, + hash, + atNames, + blocks + }), op('Label', 'ELSE')]; + } + }); + } - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.Stack = _exports.Storage = void 0; + function WrappedComponent(layout, attrsBlockNumber) { + return [op('StartLabels'), WithSavedRegister(_vm.$s1, () => [op(93 + /* GetComponentTagName */ + , _vm.$s0), op(31 + /* PrimitiveReference */ + ), op(33 + /* Dup */ + , _vm.$sp, 0)]), op(66 + /* JumpUnless */ + , label('BODY')), op(36 + /* Fetch */ + , _vm.$s1), op(91 + /* PutComponentOperations */ + ), op(49 + /* OpenDynamicElement */ + ), op(102 + /* DidCreateElement */ + , _vm.$s0), YieldBlock(attrsBlockNumber, _util.EMPTY_ARRAY), op(54 + /* FlushElement */ + ), op('Label', 'BODY'), InvokeStaticBlock(blockForLayout(layout)), op(36 + /* Fetch */ + , _vm.$s1), op(66 + /* JumpUnless */ + , label('END')), op(55 + /* CloseElement */ + ), op('Label', 'END'), op(35 + /* Load */ + , _vm.$s1), op('StopLabels')]; + } + + function StaticComponent(component, args$$1) { + var [params, hash, blocks] = args$$1; + if (component === null) return NONE; + var { + compilable: compilable$$1, + capabilities, + handle + } = component; - class Storage { - constructor() { - this.array = []; - this.next = 0; + if (compilable$$1) { + return [op(80 + /* PushComponentDefinition */ + , handle), InvokeStaticComponent({ + capabilities: capabilities || _runtime.MINIMAL_CAPABILITIES, + layout: compilable$$1, + attrs: null, + params, + hash, + blocks + })]; + } else { + return [op(80 + /* PushComponentDefinition */ + , handle), InvokeComponent({ + capabilities: capabilities || _runtime.MINIMAL_CAPABILITIES, + attrs: null, + params, + hash, + atNames: true, + blocks + })]; } + } - add(element) { - var { - next: slot, - array - } = this; + function InvokeComponent({ + capabilities, + attrs, + params, + hash, + atNames, + blocks: namedBlocks$$1, + layout + }) { + var bindableBlocks = !!namedBlocks$$1; + var bindableAtNames = capabilities === true || capabilities.prepareArgs || !!(hash && hash[0].length !== 0); + var blocks = namedBlocks$$1.with('attrs', attrs); + return [op(36 + /* Fetch */ + , _vm.$s0), op(33 + /* Dup */ + , _vm.$sp, 1), op(35 + /* Load */ + , _vm.$s0), op(0 + /* PushFrame */ + ), op('Args', { + params, + hash, + blocks, + atNames + }), op(87 + /* PrepareArgs */ + , _vm.$s0), invokePreparedComponent(blocks.has('default'), bindableBlocks, bindableAtNames, () => { + var out; - if (slot === array.length) { - this.next++; + if (layout) { + out = [PushSymbolTable(layout.symbolTable), op('PushCompilable', layout), op('JitCompileBlock')]; } else { - var prev = array[slot]; - this.next = prev; + out = [op('GetComponentLayout', _vm.$s0)]; } - this.array[slot] = element; - return slot; + out.push(op(98 + /* PopulateLayout */ + , _vm.$s0)); + return out; + }), op(35 + /* Load */ + , _vm.$s0)]; + } + + function invokePreparedComponent(hasBlock, bindableBlocks, bindableAtNames, populateLayout = null) { + var out = [op(100 + /* BeginComponentTransaction */ + ), op(59 + /* PushDynamicScope */ + ), op(89 + /* CreateComponent */ + , hasBlock | 0, _vm.$s0)]; // this has to run after createComponent to allow + // for late-bound layouts, but a caller is free + // to populate the layout earlier if it wants to + // and do nothing here. + + if (populateLayout) { + out.push(populateLayout()); + } + + out.push(op(90 + /* RegisterComponentDestructor */ + , _vm.$s0), op(92 + /* GetComponentSelf */ + , _vm.$s0), op(38 + /* VirtualRootScope */ + , _vm.$s0), op(19 + /* SetVariable */ + , 0), op(97 + /* SetupForEval */ + , _vm.$s0), bindableAtNames ? op(17 + /* SetNamedVariables */ + , _vm.$s0) : NONE, bindableBlocks ? op(18 + /* SetBlocks */ + , _vm.$s0) : NONE, op(34 + /* Pop */ + , 1), op(99 + /* InvokeComponentLayout */ + , _vm.$s0), op(103 + /* DidRenderLayout */ + , _vm.$s0), op(1 + /* PopFrame */ + ), op(40 + /* PopScope */ + ), op(60 + /* PopDynamicScope */ + ), op(101 + /* CommitComponentTransaction */ + )); + return out; + } + + function InvokeBareComponent() { + return [op(36 + /* Fetch */ + , _vm.$s0), op(33 + /* Dup */ + , _vm.$sp, 1), op(35 + /* Load */ + , _vm.$s0), op(0 + /* PushFrame */ + ), op(85 + /* PushEmptyArgs */ + ), op(87 + /* PrepareArgs */ + , _vm.$s0), invokePreparedComponent(false, false, true, () => [op('GetComponentLayout', _vm.$s0), op(98 + /* PopulateLayout */ + , _vm.$s0)]), op(35 + /* Load */ + , _vm.$s0)]; + } + + function curryComponent({ + definition, + params, + hash, + atNames + }, referrer) { + return [op(0 + /* PushFrame */ + ), op('SimpleArgs', { + params, + hash, + atNames + }), op(88 + /* CaptureArgs */ + ), op('Expr', definition), op(79 + /* CurryComponent */ + , templateMeta(referrer)), op(1 + /* PopFrame */ + ), op(36 + /* Fetch */ + , _vm.$v0)]; + } + + function blockForLayout(layout) { + return compilableBlock(layout.block.statements, meta(layout)); + } + + function WithSavedRegister(register, block) { + return [op(36 + /* Fetch */ + , register), block(), op(35 + /* Load */ + , register)]; + } + + class StdLib { + constructor(main, trustingGuardedAppend, cautiousGuardedAppend) { + this.main = main; + this.trustingGuardedAppend = trustingGuardedAppend; + this.cautiousGuardedAppend = cautiousGuardedAppend; } - deref(pointer) { - return this.array[pointer]; + get 'trusting-append'() { + return this.trustingGuardedAppend; } - drop(pointer) { - this.array[pointer] = this.next; - this.next = pointer; + get 'cautious-append'() { + return this.cautiousGuardedAppend; + } + + getAppend(trusting) { + return trusting ? this.trustingGuardedAppend : this.cautiousGuardedAppend; } } - _exports.Storage = Storage; + _exports.StdLib = StdLib; - class Stack { - constructor(vec = []) { - this.vec = vec; - } + function main() { + return [op(76 + /* Main */ + , _vm.$s0), invokePreparedComponent(false, false, true)]; + } + /** + * Append content to the DOM. This standard function triages content and does the + * right thing based upon whether it's a string, safe string, component, fragment + * or node. + * + * @param trusting whether to interpolate a string as raw HTML (corresponds to + * triple curlies) + */ - clone() { - return new Stack(this.vec.slice()); - } - sliceFrom(start) { - return new Stack(this.vec.slice(start)); + function StdAppend(trusting) { + return [op(78 + /* ContentType */ + ), SwitchCases(when => { + when(1 + /* String */ + , () => { + if (trusting) { + return [op(68 + /* AssertSame */ + ), op(43 + /* AppendHTML */ + )]; + } else { + return op(47 + /* AppendText */ + ); + } + }); + when(0 + /* Component */ + , () => [op(82 + /* PushCurriedComponent */ + ), op(81 + /* PushDynamicComponentInstance */ + ), InvokeBareComponent()]); + when(3 + /* SafeString */ + , () => [op(68 + /* AssertSame */ + ), op(44 + /* AppendSafeHTML */ + )]); + when(4 + /* Fragment */ + , () => [op(68 + /* AssertSame */ + ), op(45 + /* AppendDocumentFragment */ + )]); + when(5 + /* Node */ + , () => [op(68 + /* AssertSame */ + ), op(46 + /* AppendNode */ + )]); + })]; + } + + function compileStd(context) { + var mainHandle = build(context, main); + var trustingGuardedAppend = build(context, () => StdAppend(true)); + var cautiousGuardedAppend = build(context, () => StdAppend(false)); + return new StdLib(mainHandle, trustingGuardedAppend, cautiousGuardedAppend); + } + + var STDLIB_META = { + asPartial: false, + evalSymbols: null, + upvars: null, + // TODO: ?? + referrer: {}, + size: 0 + }; + + function build(program, callback) { + var encoder = new EncoderImpl(); + var macros = new MacrosImpl(); + var stdContext = { + encoder, + meta: STDLIB_META, + syntax: { + macros, + program + } + }; + concat(stdContext, callback()); + var result = encoder.commit(program.heap, 0); + + if (typeof result !== 'number') { + // This shouldn't be possible + throw new Error(`Unexpected errors compiling std`); + } else { + return result; } + } - slice(start, end) { - return new Stack(this.vec.slice(start, end)); + class ProgramCompilationContext { + constructor(delegate, mode) { + this.mode = mode; + this.constants = new _program.WriteOnlyConstants(); + this.heap = new _program.HeapImpl(); + this.resolverDelegate = delegate; + this.stdlib = compileStd(this); } - copy(from, to) { - this.vec[to] = this.vec[from]; - } // TODO: how to model u64 argument? + } + _exports.ProgramCompilationContext = ProgramCompilationContext; - writeRaw(pos, value) { - // TODO: Grow? - this.vec[pos] = value; - } // TODO: partially decoded enum? + class JitProgramCompilationContext { + constructor(delegate) { + this.constants = new _program.JitConstants(); + this.heap = new _program.HeapImpl(); + this.mode = "jit" + /* jit */ + ; + this.resolverDelegate = delegate; + this.stdlib = compileStd(this); + } + } - getRaw(pos) { - return this.vec[pos]; - } + _exports.JitProgramCompilationContext = JitProgramCompilationContext; - reset() { - this.vec.length = 0; + class PartialDefinition { + constructor(name, // for debugging + template) { + this.name = name; + this.template = template; } - len() { - return this.vec.length; + getPartial(context) { + var partial = unwrapTemplate(this.template).asPartial(); + var handle = partial.compile(context); + return { + symbolTable: partial.symbolTable, + handle + }; } } - _exports.Stack = Stack; + _exports.PartialDefinition = PartialDefinition; }); -define("@glimmer/node", ["exports", "@glimmer/runtime"], function (_exports, _runtime) { +define("@glimmer/program", ["exports", "@glimmer/util"], function (_exports, _util) { "use strict"; Object.defineProperty(_exports, "__esModule", { value: true }); - _exports.serializeBuilder = serializeBuilder; - _exports.NodeDOMTreeConstruction = void 0; + _exports.hydrateHeap = hydrateHeap; + _exports.hydrateProgram = hydrateProgram; + _exports.patchStdlibs = patchStdlibs; + _exports.programArtifacts = programArtifacts; + _exports.artifacts = artifacts; + _exports.RuntimeOpImpl = _exports.RuntimeProgramImpl = _exports.HeapImpl = _exports.RuntimeHeapImpl = _exports.JitConstants = _exports.RuntimeConstantsImpl = _exports.WriteOnlyConstants = _exports.WELL_KNOWN_EMPTY_ARRAY_POSITION = void 0; + var UNRESOLVED = {}; + var WELL_KNOWN_EMPTY_ARRAY_POSITION = 0; + _exports.WELL_KNOWN_EMPTY_ARRAY_POSITION = WELL_KNOWN_EMPTY_ARRAY_POSITION; + var WELL_KNOW_EMPTY_ARRAY = Object.freeze([]); - class NodeDOMTreeConstruction extends _runtime.DOMTreeConstruction { - constructor(doc) { - super(doc); - } // override to prevent usage of `this.document` until after the constructor + class WriteOnlyConstants { + constructor() { + // `0` means NULL + this.strings = []; + this.arrays = [WELL_KNOW_EMPTY_ARRAY]; + this.tables = []; + this.handles = []; + this.resolved = []; + this.numbers = []; + this.others = []; + } + + other(other) { + return this.others.push(other) - 1; + } + string(value) { + var index = this.strings.indexOf(value); - setupUselessElement() {} // override to avoid SVG detection/work when in node (this is not needed in SSR) + if (index > -1) { + return index; + } + return this.strings.push(value) - 1; + } - createElement(tag) { - return this.document.createElement(tag); - } // override to avoid namespace shenanigans when in node (this is not needed in SSR) + stringArray(strings) { + var _strings = new Array(strings.length); + for (var i = 0; i < strings.length; i++) { + _strings[i] = this.string(strings[i]); + } - setAttribute(element, name, value) { - element.setAttribute(name, value); + return this.array(_strings); } - } - - _exports.NodeDOMTreeConstruction = NodeDOMTreeConstruction; - var TEXT_NODE = 3; + array(values) { + if (values.length === 0) { + return WELL_KNOWN_EMPTY_ARRAY_POSITION; + } - function currentNode(cursor) { - var { - element, - nextSibling - } = cursor; + var index = this.arrays.indexOf(values); - if (nextSibling === null) { - return element.lastChild; - } else { - return nextSibling.previousSibling; - } - } + if (index > -1) { + return index; + } - class SerializeBuilder extends _runtime.NewElementBuilder { - constructor() { - super(...arguments); - this.serializeBlockDepth = 0; + return this.arrays.push(values) - 1; } - __openBlock() { - var { - tagName - } = this.element; - - if (tagName !== 'TITLE' && tagName !== 'SCRIPT' && tagName !== 'STYLE') { - var depth = this.serializeBlockDepth++; + serializable(value) { + var str = JSON.stringify(value); + var index = this.strings.indexOf(str); - this.__appendComment("%+b:" + depth + "%"); + if (index > -1) { + return index; } - super.__openBlock(); + return this.strings.push(str) - 1; } - __closeBlock() { - var { - tagName - } = this.element; - - super.__closeBlock(); + templateMeta(value) { + return this.serializable(value); + } - if (tagName !== 'TITLE' && tagName !== 'SCRIPT' && tagName !== 'STYLE') { - var depth = --this.serializeBlockDepth; + number(number) { + var index = this.numbers.indexOf(number); - this.__appendComment("%-b:" + depth + "%"); + if (index > -1) { + return index; } + + return this.numbers.push(number) - 1; } - __appendHTML(html) { - var { - tagName - } = this.element; + toPool() { + return { + strings: this.strings, + arrays: this.arrays, + handles: this.handles, + numbers: this.numbers + }; + } - if (tagName === 'TITLE' || tagName === 'SCRIPT' || tagName === 'STYLE') { - return super.__appendHTML(html); - } // Do we need to run the html tokenizer here? + } + _exports.WriteOnlyConstants = WriteOnlyConstants; - var first = this.__appendComment('%glmr%'); + class RuntimeConstantsImpl { + constructor(pool) { + this.strings = pool.strings; + this.arrays = pool.arrays; + this.handles = pool.handles; + this.numbers = pool.numbers; + this.others = []; + } - if (tagName === 'TABLE') { - var openIndex = html.indexOf('<'); + getString(value) { + return this.strings[value]; + } - if (openIndex > -1) { - var tr = html.slice(openIndex + 1, openIndex + 3); + getNumber(value) { + return this.numbers[value]; + } - if (tr === 'tr') { - html = "" + html + ""; - } - } - } + getStringArray(value) { + var names = this.getArray(value); - if (html === '') { - this.__appendComment('% %'); - } else { - super.__appendHTML(html); + var _names = new Array(names.length); + + for (var i = 0; i < names.length; i++) { + var n = names[i]; + _names[i] = this.getString(n); } - var last = this.__appendComment('%glmr%'); + return _names; + } - return new _runtime.ConcreteBounds(this.element, first, last); + getArray(value) { + return this.arrays[value]; } - __appendText(string) { - var { - tagName - } = this.element; - var current = currentNode(this); + getSerializable(s) { + return JSON.parse(this.strings[s]); + } - if (tagName === 'TITLE' || tagName === 'SCRIPT' || tagName === 'STYLE') { - return super.__appendText(string); - } else if (string === '') { - return this.__appendComment('% %'); - } else if (current && current.nodeType === TEXT_NODE) { - this.__appendComment('%|%'); - } + getTemplateMeta(m) { + return this.getSerializable(m); + } - return super.__appendText(string); + getOther(value) { + return this.others[value]; } - closeElement() { - if (this.element['needsExtraClose'] === true) { - this.element['needsExtraClose'] = false; - super.closeElement(); + } + + _exports.RuntimeConstantsImpl = RuntimeConstantsImpl; + + class JitConstants extends WriteOnlyConstants { + constructor(pool) { + super(); + this.metas = []; + + if (pool) { + this.strings = pool.strings; + this.arrays = pool.arrays; + this.handles = pool.handles; + this.resolved = this.handles.map(() => UNRESOLVED); + this.numbers = pool.numbers; } - return super.closeElement(); + this.others = []; } - openElement(tag) { - if (tag === 'tr') { - if (this.element.tagName !== 'TBODY' && this.element.tagName !== 'THEAD' && this.element.tagName !== 'TFOOT') { - this.openElement('tbody'); // This prevents the closeBlock comment from being re-parented - // under the auto inserted tbody. Rehydration builder needs to - // account for the insertion since it is injected here and not - // really in the template. + templateMeta(meta) { + var index = this.metas.indexOf(meta); - this.constructing['needsExtraClose'] = true; - this.flushElement(null); - } + if (index > -1) { + return index; } - return super.openElement(tag); + return this.metas.push(meta) - 1; } - pushRemoteElement(element, cursorId, nextSibling = null) { - var { - dom - } = this; - var script = dom.createElement('script'); - script.setAttribute('glmr', cursorId); - dom.insertBefore(element, script, nextSibling); - super.pushRemoteElement(element, cursorId, nextSibling); + getNumber(value) { + return this.numbers[value]; } - } + getString(value) { + return this.strings[value]; + } - function serializeBuilder(env, cursor) { - return SerializeBuilder.forInitialRender(env, cursor); - } -}); -define("@glimmer/opcode-compiler", ["exports", "@ember/polyfills", "@glimmer/util", "@glimmer/vm", "@glimmer/wire-format", "@glimmer/encoder", "@glimmer/program"], function (_exports, _polyfills, _util, _vm, _wireFormat, _encoder, _program) { - "use strict"; + getStringArray(value) { + var names = this.getArray(value); - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.compile = compile; - _exports.templateFactory = templateFactory; - _exports.debug = debug; - _exports.debugSlice = debugSlice; - _exports.logOpcode = logOpcode; - _exports.PLACEHOLDER_HANDLE = _exports.WrappedBuilder = _exports.PartialDefinition = _exports.StdOpcodeBuilder = _exports.OpcodeBuilder = _exports.EagerOpcodeBuilder = _exports.LazyOpcodeBuilder = _exports.CompilableProgram = _exports.CompilableBlock = _exports.debugCompiler = _exports.AbstractCompiler = _exports.LazyCompiler = _exports.Macros = _exports.ATTRS_BLOCK = void 0; - var PLACEHOLDER_HANDLE = -1; - _exports.PLACEHOLDER_HANDLE = PLACEHOLDER_HANDLE; - var Ops$1; + var _names = new Array(names.length); - (function (Ops$$1) { - Ops$$1[Ops$$1["OpenComponentElement"] = 0] = "OpenComponentElement"; - Ops$$1[Ops$$1["DidCreateElement"] = 1] = "DidCreateElement"; - Ops$$1[Ops$$1["DidRenderLayout"] = 2] = "DidRenderLayout"; - Ops$$1[Ops$$1["Debugger"] = 3] = "Debugger"; - })(Ops$1 || (Ops$1 = {})); + for (var i = 0; i < names.length; i++) { + var n = names[i]; + _names[i] = this.getString(n); + } - var Ops$2 = _wireFormat.Ops; - var ATTRS_BLOCK = '&attrs'; - _exports.ATTRS_BLOCK = ATTRS_BLOCK; + return _names; + } - class Compilers { - constructor(offset = 0) { - this.offset = offset; - this.names = (0, _util.dict)(); - this.funcs = []; + getArray(value) { + return this.arrays[value]; } - add(name, func) { - this.funcs.push(func); - this.names[name] = this.funcs.length - 1; + getSerializable(s) { + return JSON.parse(this.strings[s]); } - compile(sexp, builder) { - var name = sexp[this.offset]; - var index = this.names[name]; - var func = this.funcs[index]; - func(sexp, builder); + getTemplateMeta(m) { + return this.metas[m]; + } + + getOther(value) { + return this.others[value]; } } - var _statementCompiler; + _exports.JitConstants = JitConstants; - function statementCompiler() { - if (_statementCompiler) { - return _statementCompiler; + class RuntimeOpImpl { + constructor(heap) { + this.heap = heap; + this.offset = 0; } - var STATEMENTS = _statementCompiler = new Compilers(); - STATEMENTS.add(Ops$2.Text, (sexp, builder) => { - builder.text(sexp[1]); - }); - STATEMENTS.add(Ops$2.Comment, (sexp, builder) => { - builder.comment(sexp[1]); - }); - STATEMENTS.add(Ops$2.CloseElement, (_sexp, builder) => { - builder.closeElement(); - }); - STATEMENTS.add(Ops$2.FlushElement, (_sexp, builder) => { - builder.flushElement(); - }); - STATEMENTS.add(Ops$2.Modifier, (sexp, builder) => { - var { - referrer - } = builder; - var [, name, params, hash] = sexp; - var handle = builder.compiler.resolveModifier(name, referrer); - - if (handle !== null) { - builder.modifier(handle, params, hash); - } else { - throw new Error("Compile Error " + name + " is not a modifier: Helpers may not be used in the element form."); - } - }); - STATEMENTS.add(Ops$2.StaticAttr, (sexp, builder) => { - var [, name, value, namespace] = sexp; - builder.staticAttr(name, namespace, value); - }); - STATEMENTS.add(Ops$2.DynamicAttr, (sexp, builder) => { - dynamicAttr(sexp, false, builder); - }); - STATEMENTS.add(Ops$2.ComponentAttr, (sexp, builder) => { - componentAttr(sexp, false, builder); - }); - STATEMENTS.add(Ops$2.TrustingAttr, (sexp, builder) => { - dynamicAttr(sexp, true, builder); - }); - STATEMENTS.add(Ops$2.TrustingComponentAttr, (sexp, builder) => { - componentAttr(sexp, true, builder); - }); - STATEMENTS.add(Ops$2.OpenElement, (sexp, builder) => { - var [, tag, simple] = sexp; + get size() { + var rawType = this.heap.getbyaddr(this.offset); + return ((rawType & 768 + /* OPERAND_LEN_MASK */ + ) >> 8 + /* ARG_SHIFT */ + ) + 1; + } - if (!simple) { - builder.putComponentOperations(); - } + get isMachine() { + var rawType = this.heap.getbyaddr(this.offset); + return rawType & 1024 + /* MACHINE_MASK */ + ? 1 : 0; + } - builder.openPrimitiveElement(tag); - }); - STATEMENTS.add(Ops$2.DynamicComponent, (sexp, builder) => { - var [, definition, attrs, args, template] = sexp; - var block = builder.template(template); - var attrsBlock = null; - - if (attrs.length > 0) { - attrsBlock = builder.inlineBlock({ - statements: attrs, - parameters: _util.EMPTY_ARRAY - }); - } + get type() { + return this.heap.getbyaddr(this.offset) & 255 + /* TYPE_MASK */ + ; + } - builder.dynamicComponent(definition, attrsBlock, null, args, false, block, null); - }); - STATEMENTS.add(Ops$2.Component, (sexp, builder) => { - var [, tag, attrs, args, block] = sexp; - var { - referrer - } = builder; - var { - handle, - capabilities, - compilable - } = builder.compiler.resolveLayoutForTag(tag, referrer); + get op1() { + return this.heap.getbyaddr(this.offset + 1); + } - if (handle !== null && capabilities !== null) { - var attrsBlock = null; + get op2() { + return this.heap.getbyaddr(this.offset + 2); + } - if (attrs.length > 0) { - attrsBlock = builder.inlineBlock({ - statements: attrs, - parameters: _util.EMPTY_ARRAY - }); - } + get op3() { + return this.heap.getbyaddr(this.offset + 3); + } - var child = builder.template(block); + } - if (compilable) { - builder.pushComponentDefinition(handle); - builder.invokeStaticComponent(capabilities, compilable, attrsBlock, null, args, false, child && child); - } else { - builder.pushComponentDefinition(handle); - builder.invokeComponent(capabilities, attrsBlock, null, args, false, child && child); - } - } else { - throw new Error("Compile Error: Cannot find component " + tag); - } - }); - STATEMENTS.add(Ops$2.Partial, (sexp, builder) => { - var [, name, evalInfo] = sexp; - var { - referrer - } = builder; - builder.replayableIf({ - args() { - builder.expr(name); - builder.dup(); - return 2; - }, + _exports.RuntimeOpImpl = RuntimeOpImpl; - ifTrue() { - builder.invokePartial(referrer, builder.evalSymbols(), evalInfo); - builder.popScope(); - builder.popFrame(); // FIXME: WAT - } + function encodeTableInfo(scopeSize, state) { + return state | scopeSize << 2; + } - }); - }); - STATEMENTS.add(Ops$2.Yield, (sexp, builder) => { - var [, to, params] = sexp; - builder.yield(to, params); - }); - STATEMENTS.add(Ops$2.AttrSplat, (sexp, builder) => { - var [, to] = sexp; - builder.yield(to, []); - }); - STATEMENTS.add(Ops$2.Debugger, (sexp, builder) => { - var [, evalInfo] = sexp; - builder.debugger(builder.evalSymbols(), evalInfo); - }); - STATEMENTS.add(Ops$2.ClientSideStatement, (sexp, builder) => { - CLIENT_SIDE.compile(sexp, builder); - }); - STATEMENTS.add(Ops$2.Append, (sexp, builder) => { - var [, value, trusting] = sexp; - var returned = builder.compileInline(sexp) || value; - if (returned === true) return; - builder.guardedAppend(value, trusting); - }); - STATEMENTS.add(Ops$2.Block, (sexp, builder) => { - var [, name, params, hash, _template, _inverse] = sexp; - var template = builder.template(_template); - var inverse = builder.template(_inverse); - var templateBlock = template && template; - var inverseBlock = inverse && inverse; - builder.compileBlock(name, params, hash, templateBlock, inverseBlock); - }); - var CLIENT_SIDE = new Compilers(1); - CLIENT_SIDE.add(Ops$1.OpenComponentElement, (sexp, builder) => { - builder.putComponentOperations(); - builder.openPrimitiveElement(sexp[2]); - }); - CLIENT_SIDE.add(Ops$1.DidCreateElement, (_sexp, builder) => { - builder.didCreateElement(_vm.Register.s0); - }); - CLIENT_SIDE.add(Ops$1.Debugger, () => { - // tslint:disable-next-line:no-debugger - debugger; - }); - CLIENT_SIDE.add(Ops$1.DidRenderLayout, (_sexp, builder) => { - builder.didRenderLayout(_vm.Register.s0); - }); - return STATEMENTS; + function changeState(info, newState) { + return info | newState << 30; } - function componentAttr(sexp, trusting, builder) { - var [, name, value, namespace] = sexp; - builder.expr(value); + var PAGE_SIZE = 0x100000; - if (namespace) { - builder.componentAttr(name, namespace, trusting); - } else { - builder.componentAttr(name, null, trusting); - } - } + class RuntimeHeapImpl { + constructor(serializedHeap) { + var { + buffer, + table + } = serializedHeap; + this.heap = new Int32Array(buffer); + this.table = table; + } // It is illegal to close over this address, as compaction + // may move it. However, it is legal to use this address + // multiple times between compactions. - function dynamicAttr(sexp, trusting, builder) { - var [, name, value, namespace] = sexp; - builder.expr(value); - if (namespace) { - builder.dynamicAttr(name, namespace, trusting); - } else { - builder.dynamicAttr(name, null, trusting); + getaddr(handle) { + return this.table[handle]; } - } - var _expressionCompiler; + getbyaddr(address) { + return this.heap[address]; + } - function expressionCompiler() { - if (_expressionCompiler) { - return _expressionCompiler; + sizeof(handle) { + return sizeof(this.table, handle); } - var EXPRESSIONS = _expressionCompiler = new Compilers(); - EXPRESSIONS.add(Ops$2.Unknown, (sexp, builder) => { - var { - compiler, - referrer, - containingLayout: { - asPartial - } - } = builder; - var name = sexp[1]; - var handle = compiler.resolveHelper(name, referrer); - - if (handle !== null) { - builder.helper(handle, null, null); - } else if (asPartial) { - builder.resolveMaybeLocal(name); - } else { - builder.getVariable(0); - builder.getProperty(name); - } - }); - EXPRESSIONS.add(Ops$2.Concat, (sexp, builder) => { - var parts = sexp[1]; + scopesizeof(handle) { + return scopesizeof(this.table, handle); + } - for (var i = 0; i < parts.length; i++) { - builder.expr(parts[i]); - } + } - builder.concat(parts.length); - }); - EXPRESSIONS.add(Ops$2.Helper, (sexp, builder) => { - var { - compiler, - referrer - } = builder; - var [, name, params, hash] = sexp; // TODO: triage this in the WF compiler - - if (name === 'component') { - var [definition, ...restArgs] = params; - builder.curryComponent(definition, restArgs, hash, true); - return; - } + _exports.RuntimeHeapImpl = RuntimeHeapImpl; - var handle = compiler.resolveHelper(name, referrer); + function hydrateHeap(serializedHeap) { + return new RuntimeHeapImpl(serializedHeap); + } + /** + * The Heap is responsible for dynamically allocating + * memory in which we read/write the VM's instructions + * from/to. When we malloc we pass out a VMHandle, which + * is used as an indirect way of accessing the memory during + * execution of the VM. Internally we track the different + * regions of the memory in an int array known as the table. + * + * The table 32-bit aligned and has the following layout: + * + * | ... | hp (u32) | info (u32) | size (u32) | + * | ... | Handle | Scope Size | State | Size | + * | ... | 32bits | 30bits | 2bits | 32bit | + * + * With this information we effectively have the ability to + * control when we want to free memory. That being said you + * can not free during execution as raw address are only + * valid during the execution. This means you cannot close + * over them as you will have a bad memory access exception. + */ - if (handle !== null) { - builder.helper(handle, params, hash); - } else { - throw new Error("Compile Error: " + name + " is not a helper"); - } - }); - EXPRESSIONS.add(Ops$2.Get, (sexp, builder) => { - var [, head, path] = sexp; - builder.getVariable(head); - for (var i = 0; i < path.length; i++) { - builder.getProperty(path[i]); - } - }); - EXPRESSIONS.add(Ops$2.MaybeLocal, (sexp, builder) => { - var [, path] = sexp; + class HeapImpl { + constructor() { + this.placeholders = []; + this.stdlibs = []; + this.offset = 0; + this.handle = 0; + this.capacity = PAGE_SIZE; + this.heap = new Int32Array(PAGE_SIZE); + this.table = []; + } - if (builder.containingLayout.asPartial) { - var head = path[0]; - path = path.slice(1); - builder.resolveMaybeLocal(head); - } else { - builder.getVariable(0); - } + push(item) { + this.sizeCheck(); + this.heap[this.offset++] = item; + } - for (var i = 0; i < path.length; i++) { - builder.getProperty(path[i]); + sizeCheck() { + if (this.capacity === 0) { + var heap = slice(this.heap, 0, this.offset); + this.heap = new Int32Array(heap.length + PAGE_SIZE); + this.heap.set(heap, 0); + this.capacity = PAGE_SIZE; } - }); - EXPRESSIONS.add(Ops$2.Undefined, (_sexp, builder) => { - return builder.pushPrimitiveReference(undefined); - }); - EXPRESSIONS.add(Ops$2.HasBlock, (sexp, builder) => { - builder.hasBlock(sexp[1]); - }); - EXPRESSIONS.add(Ops$2.HasBlockParams, (sexp, builder) => { - builder.hasBlockParams(sexp[1]); - }); - return EXPRESSIONS; - } - class Macros { - constructor() { - var { - blocks, - inlines - } = populateBuiltins(); - this.blocks = blocks; - this.inlines = inlines; + this.capacity--; } - } - - _exports.Macros = Macros; + getbyaddr(address) { + return this.heap[address]; + } - class Blocks { - constructor() { - this.names = (0, _util.dict)(); - this.funcs = []; + setbyaddr(address, value) { + this.heap[address] = value; } - add(name, func) { - this.funcs.push(func); - this.names[name] = this.funcs.length - 1; + malloc() { + // push offset, info, size + this.table.push(this.offset, 0, 0); + var handle = this.handle; + this.handle += 3 + /* ENTRY_SIZE */ + ; + return handle; } - addMissing(func) { - this.missing = func; + finishMalloc(handle, scopeSize) { + this.table[handle + 1 + /* INFO_OFFSET */ + ] = encodeTableInfo(scopeSize, 0 + /* Allocated */ + ); } - compile(name, params, hash, template, inverse, builder) { - var index = this.names[name]; + size() { + return this.offset; + } // It is illegal to close over this address, as compaction + // may move it. However, it is legal to use this address + // multiple times between compactions. - if (index === undefined) { - var func = this.missing; - var handled = func(name, params, hash, template, inverse, builder); - } else { - var _func = this.funcs[index]; - _func(params, hash, template, inverse, builder); - } + getaddr(handle) { + return this.table[handle]; } - } + gethandle(address) { + this.table.push(address, encodeTableInfo(0, 3 + /* Pointer */ + ), 0); + var handle = this.handle; + this.handle += 3 + /* ENTRY_SIZE */ + ; + return handle; + } - class Inlines { - constructor() { - this.names = (0, _util.dict)(); - this.funcs = []; + sizeof(handle) { + return sizeof(this.table, handle); } - add(name, func) { - this.funcs.push(func); - this.names[name] = this.funcs.length - 1; + scopesizeof(handle) { + return scopesizeof(this.table, handle); } - addMissing(func) { - this.missing = func; + free(handle) { + var info = this.table[handle + 1 + /* INFO_OFFSET */ + ]; + this.table[handle + 1 + /* INFO_OFFSET */ + ] = changeState(info, 1 + /* Freed */ + ); } + /** + * The heap uses the [Mark-Compact Algorithm](https://en.wikipedia.org/wiki/Mark-compact_algorithm) to shift + * reachable memory to the bottom of the heap and freeable + * memory to the top of the heap. When we have shifted all + * the reachable memory to the top of the heap, we move the + * offset to the next free position. + */ - compile(sexp, builder) { - var value = sexp[1]; // TODO: Fix this so that expression macros can return - // things like components, so that {{component foo}} - // is the same as {{(component foo)}} - if (!Array.isArray(value)) return ['expr', value]; - var name; - var params; - var hash; + compact() { + var compactedSize = 0; + var { + table, + table: { + length + }, + heap + } = this; - if (value[0] === Ops$2.Helper) { - name = value[1]; - params = value[2]; - hash = value[3]; - } else if (value[0] === Ops$2.Unknown) { - name = value[1]; - params = hash = null; - } else { - return ['expr', value]; - } + for (var i = 0; i < length; i += 3 + /* ENTRY_SIZE */ + ) { + var offset = table[i]; + var info = table[i + 1 + /* INFO_OFFSET */ + ]; // @ts-ignore (this whole function is currently unused) + + var size = info & Size.SIZE_MASK; + var state = info & 3 + /* STATE_MASK */ + >> 30; + + if (state === 2 + /* Purged */ + ) { + continue; + } else if (state === 1 + /* Freed */ + ) { + // transition to "already freed" aka "purged" + // a good improvement would be to reuse + // these slots + table[i + 1 + /* INFO_OFFSET */ + ] = changeState(info, 2 + /* Purged */ + ); + compactedSize += size; + } else if (state === 0 + /* Allocated */ + ) { + for (var j = offset; j <= i + size; j++) { + heap[j - compactedSize] = heap[j]; + } - var index = this.names[name]; + table[i] = offset - compactedSize; + } else if (state === 3 + /* Pointer */ + ) { + table[i] = offset - compactedSize; + } + } - if (index === undefined && this.missing) { - var func = this.missing; - var returned = func(name, params, hash, builder); - return returned === false ? ['expr', value] : returned; - } else if (index !== undefined) { - var _func2 = this.funcs[index]; + this.offset = this.offset - compactedSize; + } - var _returned = _func2(name, params, hash, builder); + pushPlaceholder(valueFunc) { + this.sizeCheck(); + var address = this.offset++; + this.heap[address] = 2147483647 + /* MAX_SIZE */ + ; + this.placeholders.push([address, valueFunc]); + } - return _returned === false ? ['expr', value] : _returned; - } else { - return ['expr', value]; - } + pushStdlib(operand) { + this.sizeCheck(); + var address = this.offset++; + this.heap[address] = 2147483647 + /* MAX_SIZE */ + ; + this.stdlibs.push([address, operand]); } - } + patchPlaceholders() { + var { + placeholders + } = this; - function populateBuiltins(blocks = new Blocks(), inlines = new Inlines()) { - blocks.add('if', (params, _hash, template, inverse, builder) => { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - if (!params || params.length !== 1) { - throw new Error("SYNTAX ERROR: #if requires a single argument"); + for (var i = 0; i < placeholders.length; i++) { + var [address, getValue] = placeholders[i]; + this.setbyaddr(address, getValue()); } + } - builder.replayableIf({ - args() { - builder.expr(params[0]); - builder.toBoolean(); - return 1; - }, - - ifTrue() { - builder.invokeStaticBlock(template); - }, - - ifFalse() { - if (inverse) { - builder.invokeStaticBlock(inverse); - } - } + patchStdlibs(stdlib) { + var { + stdlibs + } = this; - }); - }); - blocks.add('unless', (params, _hash, template, inverse, builder) => { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - if (!params || params.length !== 1) { - throw new Error("SYNTAX ERROR: #unless requires a single argument"); + for (var i = 0; i < stdlibs.length; i++) { + var [address, { + value + }] = stdlibs[i]; + this.setbyaddr(address, stdlib[value]); } - builder.replayableIf({ - args() { - builder.expr(params[0]); - builder.toBoolean(); - return 1; - }, - - ifTrue() { - if (inverse) { - builder.invokeStaticBlock(inverse); - } - }, - - ifFalse() { - builder.invokeStaticBlock(template); - } + this.stdlibs = []; + } - }); - }); - blocks.add('with', (params, _hash, template, inverse, builder) => { - // PutArgs - // Test(Environment) - // Enter(BEGIN, END) - // BEGIN: Noop - // JumpUnless(ELSE) - // Evaluate(default) - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - if (!params || params.length !== 1) { - throw new Error("SYNTAX ERROR: #with requires a single argument"); - } + capture(stdlib, offset = this.offset) { + this.patchPlaceholders(); + this.patchStdlibs(stdlib); // Only called in eager mode - builder.replayableIf({ - args() { - builder.expr(params[0]); - builder.dup(); - builder.toBoolean(); - return 2; - }, + var buffer = slice(this.heap, 0, offset).buffer; + return { + handle: this.handle, + table: this.table, + buffer: buffer + }; + } - ifTrue() { - builder.invokeStaticBlock(template, 1); - }, + } - ifFalse() { - if (inverse) { - builder.invokeStaticBlock(inverse); - } - } + _exports.HeapImpl = HeapImpl; - }); - }); - blocks.add('each', (params, hash, template, inverse, builder) => { - // Enter(BEGIN, END) - // BEGIN: Noop - // PutArgs - // PutIterable - // JumpUnless(ELSE) - // EnterList(BEGIN2, END2) - // ITER: Noop - // NextIter(BREAK) - // BEGIN2: Noop - // PushChildScope - // Evaluate(default) - // PopScope - // END2: Noop - // Exit - // Jump(ITER) - // BREAK: Noop - // ExitList - // Jump(END) - // ELSE: Noop - // Evalulate(inverse) - // END: Noop - // Exit - builder.replayable({ - args() { - if (hash && hash[0][0] === 'key') { - builder.expr(hash[1][0]); - } else { - builder.pushPrimitiveReference(null); - } + class RuntimeProgramImpl { + constructor(constants, heap) { + this.constants = constants; + this.heap = heap; + this._opcode = new RuntimeOpImpl(this.heap); + } - builder.expr(params[0]); - return 2; - }, + static hydrate(artifacts) { + var heap = new RuntimeHeapImpl(artifacts.heap); + var constants = new RuntimeConstantsImpl(artifacts.constants); + return new RuntimeProgramImpl(constants, heap); + } - body() { - builder.putIterator(); - builder.jumpUnless('ELSE'); - builder.pushFrame(); - builder.dup(_vm.Register.fp, 1); - builder.returnTo('ITER'); - builder.enterList('BODY'); - builder.label('ITER'); - builder.iterate('BREAK'); - builder.label('BODY'); - builder.invokeStaticBlock(template, 2); - builder.pop(2); - builder.jump('FINALLY'); - builder.label('BREAK'); - builder.exitList(); - builder.popFrame(); - builder.jump('FINALLY'); - builder.label('ELSE'); - - if (inverse) { - builder.invokeStaticBlock(inverse); - } - } + opcode(offset) { + this._opcode.offset = offset; + return this._opcode; + } - }); - }); - blocks.add('in-element', (params, hash, template, _inverse, builder) => { - if (!params || params.length !== 1) { - throw new Error("SYNTAX ERROR: #in-element requires a single argument"); - } + } - builder.replayableIf({ - args() { - var [keys, values] = hash; + _exports.RuntimeProgramImpl = RuntimeProgramImpl; - for (var i = 0; i < keys.length; i++) { - var key = keys[i]; + function hydrateProgram(artifacts) { + var heap = new RuntimeHeapImpl(artifacts.heap); + var constants = new RuntimeConstantsImpl(artifacts.constants); + return new RuntimeProgramImpl(constants, heap); + } - if (key === 'nextSibling' || key === 'guid') { - builder.expr(values[i]); - } else { - throw new Error("SYNTAX ERROR: #in-element does not take a `" + keys[0] + "` option"); - } - } + function slice(arr, start, end) { + if (arr.slice !== undefined) { + return arr.slice(start, end); + } - builder.expr(params[0]); - builder.dup(); - return 4; - }, + var ret = new Int32Array(end); - ifTrue() { - builder.pushRemoteElement(); - builder.invokeStaticBlock(template); - builder.popRemoteElement(); - } + for (; start < end; start++) { + ret[start] = arr[start]; + } - }); - }); - blocks.add('-with-dynamic-vars', (_params, hash, template, _inverse, builder) => { - if (hash) { - var [names, expressions] = hash; - builder.compileParams(expressions); - builder.pushDynamicScope(); - builder.bindDynamicScope(names); - builder.invokeStaticBlock(template); - builder.popDynamicScope(); - } else { - builder.invokeStaticBlock(template); - } - }); - blocks.add('component', (_params, hash, template, inverse, builder) => { - var tag = _params[0]; + return ret; + } - if (typeof tag === 'string') { - var returned = builder.staticComponentHelper(_params[0], hash, template); - if (returned) return; - } + function sizeof(table, handle) { + { + return -1; + } + } - var [definition, ...params] = _params; - builder.dynamicComponent(definition, null, params, hash, true, template, inverse); - }); - inlines.add('component', (_name, _params, hash, builder) => { - var tag = _params && _params[0]; + function scopesizeof(table, handle) { + var info = table[handle + 1 + /* INFO_OFFSET */ + ]; + return info >> 2; + } - if (typeof tag === 'string') { - var returned = builder.staticComponentHelper(tag, hash, null); - if (returned) return true; - } + function patchStdlibs(program) { + program.heap.patchStdlibs(program.stdlib); + } - var [definition, ...params] = _params; - builder.dynamicComponent(definition, null, params, hash, true, null, null); - return true; - }); + function programArtifacts(program) { + var heap = program.heap.capture(program.stdlib); + var constants = program.constants.toPool(); return { - blocks, - inlines + heap, + constants }; } - var PLACEHOLDER_HANDLE$1 = -1; + function artifacts(syntax) { + return programArtifacts(syntax.program); + } +}); +define("@glimmer/reference", ["exports", "@glimmer/util", "@glimmer/validator"], function (_exports, _util, _validator) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.isModified = isModified; + _exports.State = State; + _exports.StableState = StableState; + _exports.IterableImpl = _exports.UpdatableRootReference = _exports.IterationItemReference = _exports.PropertyReference = _exports.HelperRootReference = _exports.ComponentRootReference = _exports.RootReference = _exports.UPDATE_REFERENCED_VALUE = _exports.IteratorSynchronizer = _exports.ReferenceIterator = _exports.IterationArtifacts = _exports.END = _exports.ListItem = _exports.ConstReference = _exports.ReferenceCache = _exports.CachedReference = void 0; + + class CachedReference { + constructor() { + this.lastRevision = null; + this.lastValue = null; + } + + value() { + var { + tag, + lastRevision, + lastValue + } = this; + + if (lastRevision === null || !(0, _validator.validate)(tag, lastRevision)) { + lastValue = this.lastValue = this.compute(); + this.lastRevision = (0, _validator.value)(tag); + } - class CompilableProgram { - constructor(compiler, layout) { - this.compiler = compiler; - this.layout = layout; - this.compiled = null; + return lastValue; } - get symbolTable() { - return this.layout.block; + invalidate() { + this.lastRevision = null; } - compile() { - if (this.compiled !== null) return this.compiled; - this.compiled = PLACEHOLDER_HANDLE$1; - var { - block: { - statements - } - } = this.layout; - return this.compiled = this.compiler.add(statements, this.layout); - } + } ////////// - } - _exports.CompilableProgram = CompilableProgram; + _exports.CachedReference = CachedReference; - class CompilableBlock { - constructor(compiler, parsed) { - this.compiler = compiler; - this.parsed = parsed; - this.compiled = null; + class ReferenceCache { + constructor(reference) { + this.lastValue = null; + this.lastRevision = null; + this.initialized = false; + this.tag = reference.tag; + this.reference = reference; } - get symbolTable() { - return this.parsed.block; + peek() { + if (!this.initialized) { + return this.initialize(); + } + + return this.lastValue; } - compile() { - if (this.compiled !== null) return this.compiled; // Track that compilation has started but not yet finished by temporarily - // using a placeholder handle. In eager compilation mode, where compile() - // may be called recursively, we use this as a signal that the handle cannot - // be known synchronously and must be linked lazily. + revalidate() { + if (!this.initialized) { + return this.initialize(); + } - this.compiled = PLACEHOLDER_HANDLE$1; var { - block: { - statements - }, - containingLayout - } = this.parsed; - return this.compiled = this.compiler.add(statements, containingLayout); + reference, + lastRevision + } = this; + var tag = reference.tag; + if ((0, _validator.validate)(tag, lastRevision)) return NOT_MODIFIED; + var { + lastValue + } = this; + var currentValue = reference.value(); + this.lastRevision = (0, _validator.value)(tag); + if (currentValue === lastValue) return NOT_MODIFIED; + this.lastValue = currentValue; + return currentValue; } - } - - _exports.CompilableBlock = CompilableBlock; + initialize() { + var { + reference + } = this; + var currentValue = this.lastValue = reference.value(); + this.lastRevision = (0, _validator.value)(reference.tag); + this.initialized = true; + return currentValue; + } - function compile(statements, builder, compiler) { - var sCompiler = statementCompiler(); + } - for (var i = 0; i < statements.length; i++) { - sCompiler.compile(statements[i], builder); - } + _exports.ReferenceCache = ReferenceCache; + var NOT_MODIFIED = (0, _util.symbol)('NOT_MODIFIED'); - var handle = builder.commit(); - return handle; + function isModified(value$$1) { + return value$$1 !== NOT_MODIFIED; } - function debugSlice(program, start, end) {} + class PrimitiveReference { + constructor(inner) { + this.inner = inner; + this.tag = _validator.CONSTANT_TAG; + } - function logOpcode(type, params) { - var out = type; + value() { + return this.inner; + } - if (params) { - var args = Object.keys(params).map(p => " " + p + "=" + json(params[p])).join(''); - out += args; + get(_key) { + return UNDEFINED_REFERENCE; } - return "(" + out + ")"; } - function json(param) {} + var UNDEFINED_REFERENCE = new PrimitiveReference(undefined); - function debug(pos, c, op, ...operands) { - var metadata = null; + class ConstReference { + constructor(inner) { + this.inner = inner; + this.tag = _validator.CONSTANT_TAG; + } - if (!metadata) { - throw (0, _util.unreachable)("Missing Opcode Metadata for " + op); + value() { + return this.inner; } - var out = (0, _util.dict)(); - metadata.ops.forEach((operand, index) => { - var op = operands[index]; + get(_key) { + return UNDEFINED_REFERENCE; + } - switch (operand.type) { - case 'to': - out[operand.name] = pos + op; - break; + } - case 'i32': - case 'symbol': - case 'block': - out[operand.name] = op; - break; + _exports.ConstReference = ConstReference; - case 'handle': - out[operand.name] = c.resolveHandle(op); - break; + class ListItem extends _util.ListNode { + constructor(iterable, result) { + super(iterable.valueReferenceFor(result)); + this.retained = false; + this.seen = false; + this.key = result.key; + this.iterable = iterable; + this.memo = iterable.memoReferenceFor(result); + } - case 'str': - out[operand.name] = c.getString(op); - break; + update(item) { + this.retained = true; + this.iterable.updateValueReference(this.value, item); + this.iterable.updateMemoReference(this.memo, item); + } - case 'option-str': - out[operand.name] = op ? c.getString(op) : null; - break; + shouldRemove() { + return !this.retained; + } - case 'str-array': - out[operand.name] = c.getStringArray(op); - break; + reset() { + this.retained = false; + this.seen = false; + } - case 'array': - out[operand.name] = c.getArray(op); - break; + } - case 'bool': - out[operand.name] = !!op; - break; + _exports.ListItem = ListItem; - case 'primitive': - out[operand.name] = decodePrimitive(op, c); - break; + class IterationArtifacts { + constructor(iterable) { + this.iterator = null; + this.map = new Map(); + this.list = new _util.LinkedList(); + this.tag = iterable.tag; + this.iterable = iterable; + } - case 'register': - out[operand.name] = _vm.Register[op]; - break; + isEmpty() { + var iterator = this.iterator = this.iterable.iterate(); + return iterator.isEmpty(); + } - case 'serializable': - out[operand.name] = c.getSerializable(op); - break; + iterate() { + var iterator; - case 'lazy-constant': - out[operand.name] = c.getOther(op); - break; + if (this.iterator === null) { + iterator = this.iterable.iterate(); + } else { + iterator = this.iterator; } - }); - return [metadata.name, out]; - } - function decodePrimitive(primitive, constants) { - var flag = primitive & 7; // 111 + this.iterator = null; + return iterator; + } - var value = primitive >> 3; + advanceToKey(key, current) { + var seek = current; - switch (flag) { - case 0 - /* NUMBER */ - : - return value; + while (seek !== null && seek.key !== key) { + seek = this.advanceNode(seek); + } - case 1 - /* FLOAT */ - : - return constants.getNumber(value); + return seek; + } - case 2 - /* STRING */ - : - return constants.getString(value); + has(key) { + return this.map.has(key); + } - case 3 - /* BOOLEAN_OR_VOID */ - : - switch (value) { - case 0: - return false; + get(key) { + return this.map.get(key); + } - case 1: - return true; + wasSeen(key) { + var node = this.map.get(key); + return node !== undefined && node.seen; + } - case 2: - return null; + update(item) { + var found = this.get(item.key); + found.update(item); + return found; + } - case 3: - return undefined; - } + append(item) { + var { + map, + list, + iterable + } = this; + var node = new ListItem(iterable, item); + map.set(item.key, node); + list.append(node); + return node; + } - case 4 - /* NEGATIVE */ - : - case 5 - /* BIG_NUM */ - : - return constants.getNumber(value); + insertBefore(item, reference) { + var { + map, + list, + iterable + } = this; + var node = new ListItem(iterable, item); + map.set(item.key, node); + node.retained = true; + list.insertBefore(node, reference); + return node; + } - default: - throw (0, _util.unreachable)(); + move(item, reference) { + var { + list + } = this; + item.retained = true; + list.remove(item); + list.insertBefore(item, reference); } - } - class StdLib { - constructor(main, trustingGuardedAppend, cautiousGuardedAppend) { - this.main = main; - this.trustingGuardedAppend = trustingGuardedAppend; - this.cautiousGuardedAppend = cautiousGuardedAppend; + remove(item) { + var { + list + } = this; + list.remove(item); + this.map.delete(item.key); } - static compile(compiler) { - var main = this.std(compiler, b => b.main()); - var trustingGuardedAppend = this.std(compiler, b => b.stdAppend(true)); - var cautiousGuardedAppend = this.std(compiler, b => b.stdAppend(false)); - return new StdLib(main, trustingGuardedAppend, cautiousGuardedAppend); + nextNode(item) { + return this.list.nextNode(item); } - static std(compiler, callback) { - return StdOpcodeBuilder.build(compiler, callback); + advanceNode(item) { + item.seen = true; + return this.list.nextNode(item); } - getAppend(trusting) { - return trusting ? this.trustingGuardedAppend : this.cautiousGuardedAppend; + head() { + return this.list.head(); } } - class AbstractCompiler { - constructor(macros, program, resolver) { - this.macros = macros; - this.program = program; - this.resolver = resolver; - this.initialize(); - } - - initialize() { - this.stdLib = StdLib.compile(this); - } + _exports.IterationArtifacts = IterationArtifacts; - get constants() { - return this.program.constants; + class ReferenceIterator { + // if anyone needs to construct this object with something other than + // an iterable, let @wycats know. + constructor(iterable) { + this.iterator = null; + var artifacts = new IterationArtifacts(iterable); + this.artifacts = artifacts; } - compileInline(sexp, builder) { + next() { var { - inlines - } = this.macros; - return inlines.compile(sexp, builder); + artifacts + } = this; + var iterator = this.iterator = this.iterator || artifacts.iterate(); + var item = iterator.next(); + if (item === null) return null; + return artifacts.append(item); } - compileBlock(name, params, hash, template, inverse, builder) { - var { - blocks - } = this.macros; - blocks.compile(name, params, hash, template, inverse, builder); - } + } + + _exports.ReferenceIterator = ReferenceIterator; + var Phase; + + (function (Phase) { + Phase[Phase["Append"] = 0] = "Append"; + Phase[Phase["Prune"] = 1] = "Prune"; + Phase[Phase["Done"] = 2] = "Done"; + })(Phase || (Phase = {})); - add(statements, containingLayout) { - return compile(statements, this.builderFor(containingLayout), this); + var END = (0, _util.symbol)('END'); + _exports.END = END; + + class IteratorSynchronizer { + constructor({ + target, + artifacts, + env + }) { + this.target = target; + this.artifacts = artifacts; + this.iterator = artifacts.iterate(); + this.current = artifacts.head(); + this.env = env; } - commit(scopeSize, buffer) { - var heap = this.program.heap; // TODO: change the whole malloc API and do something more efficient + sync() { + var phase = Phase.Append; - var handle = heap.malloc(); + while (true) { + switch (phase) { + case Phase.Append: + phase = this.nextAppend(); + break; - for (var i = 0; i < buffer.length; i++) { - var value = buffer[i]; + case Phase.Prune: + phase = this.nextPrune(); + break; - if (typeof value === 'function') { - heap.pushPlaceholder(value); - } else { - heap.push(value); + case Phase.Done: + this.nextDone(); + return; } } - - heap.finishMalloc(handle, scopeSize); - return handle; - } - - resolveLayoutForTag(tag, referrer) { - var { - resolver - } = this; - var handle = resolver.lookupComponentDefinition(tag, referrer); - if (handle === null) return { - handle: null, - capabilities: null, - compilable: null - }; - return this.resolveLayoutForHandle(handle); } - resolveLayoutForHandle(handle) { + advanceToKey(key) { var { - resolver + current, + artifacts } = this; - var capabilities = resolver.getCapabilities(handle); - var compilable = null; + if (current === null) return; + var next = artifacts.advanceNode(current); - if (!capabilities.dynamicLayout) { - compilable = resolver.getLayout(handle); + if (next.key === key) { + this.current = artifacts.advanceNode(next); + return; } - return { - handle, - capabilities, - compilable - }; - } + var seek = artifacts.advanceToKey(key, current); - resolveModifier(name, referrer) { - return this.resolver.lookupModifier(name, referrer); + if (seek) { + this.move(seek, current); + this.current = artifacts.nextNode(current); + } } - resolveHelper(name, referrer) { - return this.resolver.lookupHelper(name, referrer); + move(item, reference) { + if (item.next !== reference) { + this.artifacts.move(item, reference); + this.target.move(this.env, item.key, item.value, item.memo, reference ? reference.key : END); + } } - } + nextAppend() { + var { + iterator, + current, + artifacts + } = this; + var item = iterator.next(); - _exports.AbstractCompiler = AbstractCompiler; - var debugCompiler; - _exports.debugCompiler = debugCompiler; + if (item === null) { + return this.startPrune(); + } - class WrappedBuilder { - constructor(compiler, layout) { - this.compiler = compiler; - this.layout = layout; - this.compiled = null; var { - block - } = layout; - var symbols = block.symbols.slice(); // ensure ATTRS_BLOCK is always included (only once) in the list of symbols - - var attrsBlockIndex = symbols.indexOf(ATTRS_BLOCK); + key + } = item; - if (attrsBlockIndex === -1) { - this.attrsBlockNumber = symbols.push(ATTRS_BLOCK); + if (current !== null && current.key === key) { + this.nextRetain(item, current); + } else if (artifacts.has(key)) { + this.nextMove(item); } else { - this.attrsBlockNumber = attrsBlockIndex + 1; + this.nextInsert(item); } - this.symbolTable = { - hasEval: block.hasEval, - symbols - }; + return Phase.Append; } - compile() { - if (this.compiled !== null) return this.compiled; //========DYNAMIC - // PutValue(TagExpr) - // Test - // JumpUnless(BODY) - // PutComponentOperations - // OpenDynamicPrimitiveElement - // DidCreateElement - // ...attr statements... - // FlushElement - // BODY: Noop - // ...body statements... - // PutValue(TagExpr) - // Test - // JumpUnless(END) - // CloseElement - // END: Noop - // DidRenderLayout - // Exit - // - //========STATIC - // OpenPrimitiveElementOpcode - // DidCreateElement - // ...attr statements... - // FlushElement - // ...body statements... - // CloseElement - // DidRenderLayout - // Exit - + nextRetain(item, current) { var { - compiler, - layout - } = this; - var b = compiler.builderFor(layout); - b.startLabels(); - b.fetch(_vm.Register.s1); - b.getComponentTagName(_vm.Register.s0); - b.primitiveReference(); - b.dup(); - b.load(_vm.Register.s1); - b.jumpUnless('BODY'); - b.fetch(_vm.Register.s1); - b.putComponentOperations(); - b.openDynamicElement(); - b.didCreateElement(_vm.Register.s0); - b.yield(this.attrsBlockNumber, []); - b.flushElement(); - b.label('BODY'); - b.invokeStaticBlock(blockFor(layout, compiler)); - b.fetch(_vm.Register.s1); - b.jumpUnless('END'); - b.closeElement(); - b.label('END'); - b.load(_vm.Register.s1); - b.stopLabels(); - var handle = b.commit(); - return this.compiled = handle; + artifacts + } = this; // current = expect(current, 'BUG: current is empty'); + + current.update(item); + this.current = artifacts.nextNode(current); + this.target.retain(this.env, item.key, current.value, current.memo); } - } + nextMove(item) { + var { + current, + artifacts + } = this; + var { + key + } = item; + var found = artifacts.update(item); - _exports.WrappedBuilder = WrappedBuilder; + if (artifacts.wasSeen(key)) { + this.move(found, current); + } else { + this.advanceToKey(key); + } + } - function blockFor(layout, compiler) { - return new CompilableBlock(compiler, { - block: { - statements: layout.block.statements, - parameters: _util.EMPTY_ARRAY - }, - containingLayout: layout - }); - } + nextInsert(item) { + var { + artifacts, + target, + current + } = this; + var node = artifacts.insertBefore(item, current); + target.insert(this.env, node.key, node.value, node.memo, current ? current.key : null); + } - class ComponentBuilder { - constructor(builder) { - this.builder = builder; + startPrune() { + this.current = this.artifacts.head(); + return Phase.Prune; } - static(handle, args) { - var [params, hash, _default, inverse] = args; + nextPrune() { var { - builder + artifacts, + target, + current } = this; - if (handle !== null) { - var { - capabilities, - compilable - } = builder.compiler.resolveLayoutForHandle(handle); + if (current === null) { + return Phase.Done; + } - if (compilable) { - builder.pushComponentDefinition(handle); - builder.invokeStaticComponent(capabilities, compilable, null, params, hash, false, _default, inverse); - } else { - builder.pushComponentDefinition(handle); - builder.invokeComponent(capabilities, null, params, hash, false, _default, inverse); - } + var node = current; + this.current = artifacts.nextNode(node); + + if (node.shouldRemove()) { + artifacts.remove(node); + target.delete(this.env, node.key); + } else { + node.reset(); } + + return Phase.Prune; + } + + nextDone() { + this.target.done(this.env); } } - class Labels { - constructor() { - this.labels = (0, _util.dict)(); - this.targets = []; - } + _exports.IteratorSynchronizer = IteratorSynchronizer; + var UPDATE_REFERENCED_VALUE = (0, _util.symbol)('UPDATE_REFERENCED_VALUE'); + /** + * RootReferences refer to a constant root value within a template. For + * instance, the `this` in `{{this.some.prop}}`. This is typically a: + * + * - Component + * - Controller + * - Helper + * + * Or another "top level" template construct, if you will. PropertyReferences + * chain off a root reference in the template, and can then be passed around and + * used at will. + */ - label(name, index) { - this.labels[name] = index; - } + _exports.UPDATE_REFERENCED_VALUE = UPDATE_REFERENCED_VALUE; - target(at, target) { - this.targets.push({ - at, - target - }); + class RootReference { + constructor(env) { + this.env = env; + this.children = (0, _util.dict)(); + this.tag = _validator.CONSTANT_TAG; } - patch(encoder) { - var { - targets, - labels - } = this; + get(key) { + // References should in general be identical to one another, so we can usually + // deduplicate them in production. However, in DEBUG we need unique references + // so we can properly key off them for the logging context. + if (true + /* DEBUG */ + ) { + // We register the template debug context now since the reference is + // created before the component itself. It shouldn't be possible to cause + // errors when accessing the root, only subproperties of the root, so this + // should be fine for the time being. The exception is helpers, but they + // set their context earlier. + // + // TODO: This points to a need for more first class support for arguments in + // the debugRenderTree. The fact that we can't accurately relate an argument + // reference to its component is problematic for debug tooling. + if (!this.didSetupDebugContext) { + this.didSetupDebugContext = true; + this.env.setTemplatePathDebugContext(this, this.debugLogName || 'this', null); + } - for (var i = 0; i < targets.length; i++) { - var { - at, - target - } = targets[i]; - var address = labels[target] - at; - encoder.patch(at, address); + return new PropertyReference(this, key, this.env); + } else { + var ref = this.children[key]; + + if (ref === undefined) { + ref = this.children[key] = new PropertyReference(this, key, this.env); + } + + return ref; } } } - class StdOpcodeBuilder { - constructor(compiler, size = 0) { - this.size = size; - this.encoder = new _encoder.InstructionEncoder([]); - this.labelsStack = new _util.Stack(); - this.compiler = compiler; + _exports.RootReference = RootReference; + + class ComponentRootReference extends RootReference { + constructor(inner, env) { + super(env); + this.inner = inner; } - static build(compiler, callback) { - var builder = new StdOpcodeBuilder(compiler); - callback(builder); - return builder.commit(); + value() { + return this.inner; } - push(name) { - switch (arguments.length) { - case 1: - return this.encoder.encode(name, 0); + } - case 2: - return this.encoder.encode(name, 0, arguments[1]); + _exports.ComponentRootReference = ComponentRootReference; - case 3: - return this.encoder.encode(name, 0, arguments[1], arguments[2]); + class HelperRootReference extends RootReference { + constructor(fn, args, env, debugName) { + super(env); + this.fn = fn; + this.args = args; + this.computeRevision = null; + this.computeTag = null; - default: - return this.encoder.encode(name, 0, arguments[1], arguments[2], arguments[3]); + if (true + /* DEBUG */ + ) { + var name = debugName || fn.name; + env.setTemplatePathDebugContext(this, `(result of a \`${name}\` helper)`, null); + this.didSetupDebugContext = true; } - } - pushMachine(name) { - switch (arguments.length) { - case 1: - return this.encoder.encode(name, 1024 - /* MACHINE_MASK */ - ); + if ((0, _validator.isConst)(args)) { + this.compute(); + } - case 2: - return this.encoder.encode(name, 1024 - /* MACHINE_MASK */ - , arguments[1]); + var { + tag, + computeTag + } = this; - case 3: - return this.encoder.encode(name, 1024 - /* MACHINE_MASK */ - , arguments[1], arguments[2]); + if (computeTag !== null && (0, _validator.isConstTag)(computeTag)) { + // If the args are constant, and the first computation is constant, then + // the helper itself is constant and will never update. + tag = this.tag = _validator.CONSTANT_TAG; + this.computeRevision = (0, _validator.value)(tag); + } else { + var valueTag = this.valueTag = (0, _validator.createUpdatableTag)(); + tag = this.tag = (0, _validator.combine)([args.tag, valueTag]); - default: - return this.encoder.encode(name, 1024 - /* MACHINE_MASK */ - , arguments[1], arguments[2], arguments[3]); + if (computeTag !== null) { + // We computed once, so setup the cache state correctly + (0, _validator.update)(valueTag, computeTag); + this.computeRevision = (0, _validator.value)(tag); + } } } - commit() { - this.pushMachine(24 - /* Return */ - ); - return this.compiler.commit(this.size, this.encoder.buffer); + compute() { + this.computeTag = (0, _validator.track)(() => { + this.computeValue = this.fn(this.args); + }, true + /* DEBUG */ + && this.env.getTemplatePathDebugContext(this)); } - reserve(name) { - this.encoder.encode(name, 0, -1); - } + value() { + var { + tag, + computeRevision + } = this; + + if (computeRevision === null || !(0, _validator.validate)(tag, computeRevision)) { + this.compute(); + (0, _validator.update)(this.valueTag, this.computeTag); + this.computeRevision = (0, _validator.value)(tag); + } - reserveWithOperand(name, operand) { - this.encoder.encode(name, 0, -1, operand); + return this.computeValue; } - reserveMachine(name) { - this.encoder.encode(name, 1024 - /* MACHINE_MASK */ - , -1); - } /// + } + /** + * PropertyReferences represent a property that has been accessed on a root, or + * another property (or iterable, see below). `some` and `prop` in + * `{{this.some.prop}}` are each property references, `some` being a property of + * `this`, and `prop` being a property of `some`. They are constructed by + * recursively calling `get` on the previous reference as a template chain is + * followed. + */ - main() { - this.push(68 - /* Main */ - , _vm.Register.s0); - this.invokePreparedComponent(false, false, true); - } + _exports.HelperRootReference = HelperRootReference; - appendHTML() { - this.push(28 - /* AppendHTML */ - ); - } + class PropertyReference { + constructor(parentReference, propertyKey, env) { + this.parentReference = parentReference; + this.propertyKey = propertyKey; + this.env = env; + this.children = (0, _util.dict)(); + this.lastRevision = null; - appendSafeHTML() { - this.push(29 - /* AppendSafeHTML */ - ); - } + if (true + /* DEBUG */ + ) { + env.setTemplatePathDebugContext(this, propertyKey, parentReference); + } - appendDocumentFragment() { - this.push(30 - /* AppendDocumentFragment */ - ); + var valueTag = this.valueTag = (0, _validator.createUpdatableTag)(); + var parentReferenceTag = parentReference.tag; + this.tag = (0, _validator.combine)([parentReferenceTag, valueTag]); } - appendNode() { - this.push(31 - /* AppendNode */ - ); - } + value() { + var { + tag, + lastRevision, + lastValue, + parentReference, + valueTag, + propertyKey + } = this; - appendText() { - this.push(32 - /* AppendText */ - ); - } + if (lastRevision === null || !(0, _validator.validate)(tag, lastRevision)) { + var parentValue = parentReference.value(); - beginComponentTransaction() { - this.push(91 - /* BeginComponentTransaction */ - ); - } + if ((0, _util.isDict)(parentValue)) { + var combined = (0, _validator.track)(() => { + lastValue = this.env.getPath(parentValue, propertyKey); + }, true + /* DEBUG */ + && this.env.getTemplatePathDebugContext(this)); + (0, _validator.update)(valueTag, combined); + } else { + lastValue = undefined; + } - commitComponentTransaction() { - this.push(92 - /* CommitComponentTransaction */ - ); - } + this.lastValue = lastValue; + this.lastRevision = (0, _validator.value)(tag); + } - pushDynamicScope() { - this.push(44 - /* PushDynamicScope */ - ); + return lastValue; } - popDynamicScope() { - this.push(45 - /* PopDynamicScope */ - ); - } + get(key) { + // References should in general be identical to one another, so we can usually + // deduplicate them in production. However, in DEBUG we need unique references + // so we can properly key off them for the logging context. + if (true + /* DEBUG */ + ) { + return new PropertyReference(this, key, this.env); + } else { + var ref = this.children[key]; - pushRemoteElement() { - this.push(41 - /* PushRemoteElement */ - ); - } + if (ref === undefined) { + ref = this.children[key] = new PropertyReference(this, key, this.env); + } - popRemoteElement() { - this.push(42 - /* PopRemoteElement */ - ); + return ref; + } } - pushRootScope(symbols, bindCallerScope) { - this.push(20 - /* RootScope */ - , symbols, bindCallerScope ? 1 : 0); + [UPDATE_REFERENCED_VALUE](value$$1) { + var { + parentReference, + propertyKey + } = this; + var parentValue = parentReference.value(); + this.env.setPath(parentValue, propertyKey, value$$1); } - pushVirtualRootScope(register) { - this.push(21 - /* VirtualRootScope */ - , register); - } + } ////////// - pushChildScope() { - this.push(22 - /* ChildScope */ - ); - } + /** + * IterationItemReferences represent an individual item in an iterable `each`. + * They are similar to PropertyReferences, but since iteration items need to be + * updated they have slightly different behavior. Concretely, they are the + * `item` in: + * + * ```hbs + * {{#each this.items as |item|}} + * {{item.foo}} + * {{/each}} + * ``` + * + * Properties can chain off an iteration item, just like with the other template + * reference types. + */ - popScope() { - this.push(23 - /* PopScope */ - ); - } - prepareArgs(state) { - this.push(79 - /* PrepareArgs */ - , state); - } + _exports.PropertyReference = PropertyReference; - createComponent(state, hasDefault) { - var flag = hasDefault | 0; - this.push(81 - /* CreateComponent */ - , flag, state); - } + class IterationItemReference { + constructor(parentReference, itemValue, itemKey, env) { + this.parentReference = parentReference; + this.itemValue = itemValue; + this.env = env; + this.tag = (0, _validator.createUpdatableTag)(); + this.children = (0, _util.dict)(); - registerComponentDestructor(state) { - this.push(82 - /* RegisterComponentDestructor */ - , state); + if (true + /* DEBUG */ + ) { + env.setTemplatePathDebugContext(this, (0, _util.debugToString)(itemKey), parentReference); + } } - putComponentOperations() { - this.push(83 - /* PutComponentOperations */ - ); + value() { + return this.itemValue; } - getComponentSelf(state) { - this.push(84 - /* GetComponentSelf */ - , state); + update(value$$1) { + (0, _validator.dirty)(this.tag); + this.itemValue = value$$1; } - getComponentTagName(state) { - this.push(85 - /* GetComponentTagName */ - , state); - } + get(key) { + // References should in general be identical to one another, so we can usually + // deduplicate them in production. However, in DEBUG we need unique references + // so we can properly key off them for the logging context. + if (true + /* DEBUG */ + ) { + return new PropertyReference(this, key, this.env); + } else { + var ref = this.children[key]; - getComponentLayout(state) { - this.push(86 - /* GetComponentLayout */ - , state); - } + if (ref === undefined) { + ref = this.children[key] = new PropertyReference(this, key, this.env); + } - setupForEval(state) { - this.push(87 - /* SetupForEval */ - , state); + return ref; + } } - invokeComponentLayout(state) { - this.push(90 - /* InvokeComponentLayout */ - , state); - } + } + /** + * UpdatableRootReferences aren't directly related to templates, but they are + * currently used in tests and the `State` helper used for embedding. + */ - didCreateElement(state) { - this.push(93 - /* DidCreateElement */ - , state); - } - didRenderLayout(state) { - this.push(94 - /* DidRenderLayout */ - , state); - } + _exports.IterationItemReference = IterationItemReference; - pushFrame() { - this.pushMachine(57 - /* PushFrame */ - ); + class UpdatableRootReference extends RootReference { + constructor(inner, env = DEFAULT_TEMPLATE_REF_ENV) { + super(env); + this.inner = inner; + this.tag = (0, _validator.createUpdatableTag)(); } - popFrame() { - this.pushMachine(58 - /* PopFrame */ - ); + value() { + return this.inner; } - pushSmallFrame() { - this.pushMachine(59 - /* PushSmallFrame */ - ); - } + update(value$$1) { + var { + inner + } = this; - popSmallFrame() { - this.pushMachine(60 - /* PopSmallFrame */ - ); + if (value$$1 !== inner) { + (0, _validator.dirty)(this.tag); + this.inner = value$$1; + } } - invokeVirtual() { - this.pushMachine(49 - /* InvokeVirtual */ - ); + forceUpdate(value$$1) { + (0, _validator.dirty)(this.tag); + this.inner = value$$1; } - invokeYield() { - this.push(51 - /* InvokeYield */ - ); + dirty() { + (0, _validator.dirty)(this.tag); } - toBoolean() { - this.push(63 - /* ToBoolean */ - ); + getDebugPath() { + return 'this'; } - invokePreparedComponent(hasBlock, bindableBlocks, bindableAtNames, populateLayout = null) { - this.beginComponentTransaction(); - this.pushDynamicScope(); - this.createComponent(_vm.Register.s0, hasBlock); // this has to run after createComponent to allow - // for late-bound layouts, but a caller is free - // to populate the layout earlier if it wants to - // and do nothing here. + } - if (populateLayout) populateLayout(); - this.registerComponentDestructor(_vm.Register.s0); - this.getComponentSelf(_vm.Register.s0); - this.pushVirtualRootScope(_vm.Register.s0); - this.setVariable(0); - this.setupForEval(_vm.Register.s0); - if (bindableAtNames) this.setNamedVariables(_vm.Register.s0); - if (bindableBlocks) this.setBlocks(_vm.Register.s0); - this.pop(); - this.invokeComponentLayout(_vm.Register.s0); - this.didRenderLayout(_vm.Register.s0); - this.popFrame(); - this.popScope(); - this.popDynamicScope(); - this.commitComponentTransaction(); - } + _exports.UpdatableRootReference = UpdatableRootReference; + var DEFAULT_TEMPLATE_REF_ENV = { + toIterator() { + return null; + }, - get pos() { - return this.encoder.typePos; - } + getPath(obj, key) { + return obj[key]; + }, - get nextPos() { - return this.encoder.size; - } /// + setPath(obj, key, value$$1) { + return obj[key] = value$$1; + }, + getTemplatePathDebugContext() { + return ''; + }, - compileInline(sexp) { - return this.compiler.compileInline(sexp, this); - } + setTemplatePathDebugContext() {} - compileBlock(name, params, hash, template, inverse) { - this.compiler.compileBlock(name, params, hash, template, inverse, this); - } + }; - label(name) { - this.labels.label(name, this.nextPos); - } // helpers + function State(data) { + return new UpdatableRootReference(data, DEFAULT_TEMPLATE_REF_ENV); + } + var STABLE_STATE = new WeakMap(); - get labels() { - return this.labelsStack.current; + function StableState(data) { + if (STABLE_STATE.has(data)) { + return STABLE_STATE.get(data); + } else { + var ref = new UpdatableRootReference(data, DEFAULT_TEMPLATE_REF_ENV); + STABLE_STATE.set(data, ref); + return ref; } + } - startLabels() { - this.labelsStack.push(new Labels()); - } + var NULL_IDENTITY = {}; - stopLabels() { - var label = this.labelsStack.pop(); - label.patch(this.encoder); - } // components + var KEY = (_, index) => index; + var INDEX = (_, index) => String(index); - pushCurriedComponent() { - this.push(74 - /* PushCurriedComponent */ - ); + var IDENTITY = item => { + if (item === null) { + // Returning null as an identity will cause failures since the iterator + // can't tell that it's actually supposed to be null + return NULL_IDENTITY; } - pushDynamicComponentInstance() { - this.push(73 - /* PushDynamicComponentInstance */ - ); - } // dom - + return item; + }; - openDynamicElement() { - this.push(34 - /* OpenDynamicElement */ - ); + function keyForPath(path, getPath) { + if (true + /* DEBUG */ + && path[0] === '@') { + throw new Error(`invalid keypath: '${keyForPath}'`); } - flushElement() { - this.push(38 - /* FlushElement */ - ); - } + return uniqueKeyFor(item => getPath(item, path)); + } - closeElement() { - this.push(39 - /* CloseElement */ - ); - } // lists + function makeKeyFor(key, getPath) { + switch (key) { + case '@key': + return uniqueKeyFor(KEY); + case '@index': + return uniqueKeyFor(INDEX); - putIterator() { - this.push(66 - /* PutIterator */ - ); - } + case '@identity': + return uniqueKeyFor(IDENTITY); - enterList(start) { - this.reserve(64 - /* EnterList */ - ); - this.labels.target(this.pos, start); + default: + return keyForPath(key, getPath); } + } - exitList() { - this.push(65 - /* ExitList */ - ); - } + class WeakMapWithPrimitives { + get weakMap() { + if (this._weakMap === undefined) { + this._weakMap = new WeakMap(); + } - iterate(breaks) { - this.reserve(67 - /* Iterate */ - ); - this.labels.target(this.pos, breaks); - } // expressions + return this._weakMap; + } + get primitiveMap() { + if (this._primitiveMap === undefined) { + this._primitiveMap = new Map(); + } - setNamedVariables(state) { - this.push(2 - /* SetNamedVariables */ - , state); + return this._primitiveMap; } - setBlocks(state) { - this.push(3 - /* SetBlocks */ - , state); + set(key, value$$1) { + if ((0, _util.isObject)(key) || typeof key === 'function') { + this.weakMap.set(key, value$$1); + } else { + this.primitiveMap.set(key, value$$1); + } } - setVariable(symbol) { - this.push(4 - /* SetVariable */ - , symbol); + get(key) { + if ((0, _util.isObject)(key) || typeof key === 'function') { + return this.weakMap.get(key); + } else { + return this.primitiveMap.get(key); + } } - setBlock(symbol) { - this.push(5 - /* SetBlock */ - , symbol); - } + } - getVariable(symbol) { - this.push(6 - /* GetVariable */ - , symbol); - } + var IDENTITIES = new WeakMapWithPrimitives(); - getBlock(symbol) { - this.push(8 - /* GetBlock */ - , symbol); - } + function identityForNthOccurence(value$$1, count) { + var identities = IDENTITIES.get(value$$1); - hasBlock(symbol) { - this.push(9 - /* HasBlock */ - , symbol); + if (identities === undefined) { + identities = []; + IDENTITIES.set(value$$1, identities); } - concat(size) { - this.push(11 - /* Concat */ - , size); - } + var identity = identities[count]; - load(register) { - this.push(18 - /* Load */ - , register); + if (identity === undefined) { + identity = { + value: value$$1, + count + }; + identities[count] = identity; } - fetch(register) { - this.push(19 - /* Fetch */ - , register); - } + return identity; + } + /** + * When iterating over a list, it's possible that an item with the same unique + * key could be encountered twice: + * + * ```js + * let arr = ['same', 'different', 'same', 'same']; + * ``` + * + * In general, we want to treat these items as _unique within the list_. To do + * this, we track the occurences of every item as we iterate the list, and when + * an item occurs more than once, we generate a new unique key just for that + * item, and that occurence within the list. The next time we iterate the list, + * and encounter an item for the nth time, we can get the _same_ key, and let + * Glimmer know that it should reuse the DOM for the previous nth occurence. + */ - dup(register = _vm.Register.sp, offset = 0) { - return this.push(16 - /* Dup */ - , register, offset); - } - pop(count = 1) { - return this.push(17 - /* Pop */ - , count); - } // vm + function uniqueKeyFor(keyFor) { + var seen = new WeakMapWithPrimitives(); + return (value$$1, memo) => { + var key = keyFor(value$$1, memo); + var count = seen.get(value$$1) || 0; + seen.set(key, count + 1); + if (count === 0) { + return key; + } - returnTo(label) { - this.reserveMachine(25 - /* ReturnTo */ - ); - this.labels.target(this.pos, label); - } + return identityForNthOccurence(key, count); + }; + } - primitiveReference() { - this.push(14 - /* PrimitiveReference */ - ); + class IterableImpl { + constructor(parentRef, key, env) { + this.parentRef = parentRef; + this.key = key; + this.env = env; + this.tag = parentRef.tag; } - reifyU32() { - this.push(15 - /* ReifyU32 */ - ); - } + iterate() { + var { + parentRef, + key, + env + } = this; + var iterable = parentRef.value(); + var keyFor = makeKeyFor(key, env.getPath); - enter(args) { - this.push(61 - /* Enter */ - , args); - } + if (Array.isArray(iterable)) { + return new ArrayIterator(iterable, keyFor); + } - exit() { - this.push(62 - /* Exit */ - ); - } + var maybeIterator = env.toIterator(iterable); - return() { - this.pushMachine(24 - /* Return */ - ); - } + if (maybeIterator === null) { + return new ArrayIterator(_util.EMPTY_ARRAY, () => null); + } - jump(target) { - this.reserveMachine(52 - /* Jump */ - ); - this.labels.target(this.pos, target); + return new IteratorWrapper(maybeIterator, keyFor); } - jumpIf(target) { - this.reserve(53 - /* JumpIf */ - ); - this.labels.target(this.pos, target); + valueReferenceFor(item) { + var { + parentRef, + env + } = this; + return new IterationItemReference(parentRef, item.value, item.memo, env); } - jumpUnless(target) { - this.reserve(54 - /* JumpUnless */ - ); - this.labels.target(this.pos, target); + updateValueReference(reference, item) { + reference.update(item.value); } - jumpEq(value, target) { - this.reserveWithOperand(55 - /* JumpEq */ - , value); - this.labels.target(this.pos, target); + memoReferenceFor(item) { + var { + parentRef, + env + } = this; + return new IterationItemReference(parentRef, item.memo, true + /* DEBUG */ + ? `(key: ${(0, _util.debugToString)(item.key)}` : '', env); } - assertSame() { - this.push(56 - /* AssertSame */ - ); + updateMemoReference(reference, item) { + reference.update(item.memo); } - pushEmptyArgs() { - this.push(77 - /* PushEmptyArgs */ - ); - } + } - switch(_opcode, callback) { - // Setup the switch DSL - var clauses = []; - var count = 0; + _exports.IterableImpl = IterableImpl; - function when(match, callback) { - clauses.push({ - match, - callback, - label: "CLAUSE" + count++ - }); - } // Call the callback + class IteratorWrapper { + constructor(inner, keyFor) { + this.inner = inner; + this.keyFor = keyFor; + } + + isEmpty() { + return this.inner.isEmpty(); + } + next() { + var nextValue = this.inner.next(); - callback(when); // Emit the opcodes for the switch + if (nextValue !== null) { + nextValue.key = this.keyFor(nextValue.value, nextValue.memo); + } - this.enter(2); - this.assertSame(); - this.reifyU32(); - this.startLabels(); // First, emit the jump opcodes. We don't need a jump for the last - // opcode, since it bleeds directly into its clause. + return nextValue; + } - clauses.slice(0, -1).forEach(clause => this.jumpEq(clause.match, clause.label)); // Enumerate the clauses in reverse order. Earlier matches will - // require fewer checks. + } - for (var i = clauses.length - 1; i >= 0; i--) { - var clause = clauses[i]; - this.label(clause.label); - this.pop(2); - clause.callback(); // The first match is special: it is placed directly before the END - // label, so no additional jump is needed at the end of it. + class ArrayIterator { + constructor(iterator, keyFor) { + this.iterator = iterator; + this.keyFor = keyFor; + this.pos = 0; - if (i !== 0) { - this.jump('END'); - } + if (iterator.length === 0) { + this.current = { + kind: 'empty' + }; + } else { + this.current = { + kind: 'first', + value: iterator[this.pos] + }; } - - this.label('END'); - this.stopLabels(); - this.exit(); } - stdAppend(trusting) { - this.switch(this.contentType(), when => { - when(1 - /* String */ - , () => { - if (trusting) { - this.assertSame(); - this.appendHTML(); - } else { - this.appendText(); - } - }); - when(0 - /* Component */ - , () => { - this.pushCurriedComponent(); - this.pushDynamicComponentInstance(); - this.invokeBareComponent(); - }); - when(3 - /* SafeString */ - , () => { - this.assertSame(); - this.appendSafeHTML(); - }); - when(4 - /* Fragment */ - , () => { - this.assertSame(); - this.appendDocumentFragment(); - }); - when(5 - /* Node */ - , () => { - this.assertSame(); - this.appendNode(); - }); - }); + isEmpty() { + return this.current.kind === 'empty'; } - populateLayout(state) { - this.push(89 - /* PopulateLayout */ - , state); - } - - invokeBareComponent() { - this.fetch(_vm.Register.s0); - this.dup(_vm.Register.sp, 1); - this.load(_vm.Register.s0); - this.pushFrame(); - this.pushEmptyArgs(); - this.prepareArgs(_vm.Register.s0); - this.invokePreparedComponent(false, false, true, () => { - this.getComponentLayout(_vm.Register.s0); - this.populateLayout(_vm.Register.s0); - }); - this.load(_vm.Register.s0); - } + next() { + var value$$1; + var current = this.current; - isComponent() { - this.push(69 - /* IsComponent */ - ); - } + if (current.kind === 'first') { + this.current = { + kind: 'progress' + }; + value$$1 = current.value; + } else if (this.pos >= this.iterator.length - 1) { + return null; + } else { + value$$1 = this.iterator[++this.pos]; + } - contentType() { - this.push(70 - /* ContentType */ - ); + var { + keyFor + } = this; + var key = keyFor(value$$1, this.pos); + var memo = this.pos; + return { + key, + value: value$$1, + memo + }; } - pushBlockScope() { - this.push(47 - /* PushBlockScope */ - ); + } +}); +define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@glimmer/program", "@glimmer/vm", "@glimmer/validator", "@glimmer/opcode-compiler", "@glimmer/runtime", "@glimmer/low-level"], function (_exports, _util, _reference, _program, _vm2, _validator, _opcodeCompiler, _runtime, _lowLevel) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.clear = clear; + _exports.capabilityFlagsFrom = capabilityFlagsFrom; + _exports.hasCapability = hasCapability; + _exports.resetDebuggerCallback = resetDebuggerCallback; + _exports.setDebuggerCallback = setDebuggerCallback; + _exports.curry = curry; + _exports.isCurriedComponentDefinition = isCurriedComponentDefinition; + _exports.isWhitespace = isWhitespace; + _exports.normalizeProperty = normalizeProperty; + _exports.AotRuntime = AotRuntime; + _exports.CustomJitRuntime = CustomJitRuntime; + _exports.JitRuntimeFromProgram = JitRuntimeFromProgram; + _exports.JitRuntime = JitRuntime; + _exports.inTransaction = inTransaction; + _exports.getDynamicVar = getDynamicVar; + _exports.renderAot = renderAot; + _exports.renderAotComponent = renderAotComponent; + _exports.renderAotMain = renderAotMain; + _exports.renderJitComponent = renderJitComponent; + _exports.renderJitMain = renderJitMain; + _exports.renderSync = renderSync; + _exports.dynamicAttribute = dynamicAttribute; + _exports.clientBuilder = clientBuilder; + _exports.isSerializationFirstNode = isSerializationFirstNode; + _exports.rehydrationBuilder = rehydrationBuilder; + _exports.TEMPLATE_ONLY_COMPONENT = _exports.SimpleComponentManager = _exports.SERIALIZATION_FIRST_NODE_STRING = _exports.RehydrateBuilder = _exports.RemoteLiveBlock = _exports.UpdatableBlockImpl = _exports.NewElementBuilder = _exports.SimpleDynamicAttribute = _exports.DynamicAttribute = _exports.CapturedPositionalArgumentsImpl = _exports.CapturedNamedArgumentsImpl = _exports.CapturedArgumentsImpl = _exports.EMPTY_ARGS = _exports.LowLevelVM = _exports.UpdatingVM = _exports.UNDEFINED_REFERENCE = _exports.PrimitiveReference = _exports.NULL_REFERENCE = _exports.ConditionalReference = _exports.ScopeImpl = _exports.EnvironmentImpl = _exports.DefaultDynamicScope = _exports.DOMTreeConstruction = _exports.IDOMChanges = _exports.DOMChanges = _exports.MINIMAL_CAPABILITIES = _exports.DEFAULT_CAPABILITIES = _exports.CurriedComponentDefinition = _exports.CursorImpl = _exports.ConcreteBounds = void 0; + // These symbols represent "friend" properties that are used inside of + // the VM in other classes, but are not intended to be a part of + // Glimmer's API. + var INNER_VM = (0, _util.symbol)('INNER_VM'); + var DESTRUCTOR_STACK = (0, _util.symbol)('DESTRUCTOR_STACK'); + var STACKS = (0, _util.symbol)('STACKS'); + var REGISTERS = (0, _util.symbol)('REGISTERS'); + var HEAP = (0, _util.symbol)('HEAP'); + var CONSTANTS = (0, _util.symbol)('CONSTANTS'); + var ARGS = (0, _util.symbol)('ARGS'); + var PC = (0, _util.symbol)('PC'); + + class CursorImpl { + constructor(element, nextSibling) { + this.element = element; + this.nextSibling = nextSibling; } } - _exports.StdOpcodeBuilder = StdOpcodeBuilder; + _exports.CursorImpl = CursorImpl; - class OpcodeBuilder extends StdOpcodeBuilder { - constructor(compiler, containingLayout) { - super(compiler, containingLayout ? containingLayout.block.symbols.length : 0); - this.containingLayout = containingLayout; - this.component = new ComponentBuilder(this); - this.expressionCompiler = expressionCompiler(); - this.constants = compiler.constants; - this.stdLib = compiler.stdLib; - } /// MECHANICS + class ConcreteBounds { + constructor(parentNode, first, last) { + this.parentNode = parentNode; + this.first = first; + this.last = last; + } + parentElement() { + return this.parentNode; + } - get referrer() { - return this.containingLayout && this.containingLayout.referrer; + firstNode() { + return this.first; } - expr(expression) { - if (Array.isArray(expression)) { - this.expressionCompiler.compile(expression, this); - } else { - this.pushPrimitiveReference(expression); - } - } /// - // args + lastNode() { + return this.last; + } + } - pushArgs(names, flags) { - var serialized = this.constants.stringArray(names); - this.push(76 - /* PushArgs */ - , serialized, flags); - } + _exports.ConcreteBounds = ConcreteBounds; - pushYieldableBlock(block) { - this.pushSymbolTable(block && block.symbolTable); - this.pushBlockScope(); - this.pushBlock(block); + class SingleNodeBounds { + constructor(parentNode, node) { + this.parentNode = parentNode; + this.node = node; } - curryComponent(definition, - /* TODO: attrs: Option, */ - params, hash, synthetic) { - var referrer = this.containingLayout.referrer; - this.pushFrame(); - this.compileArgs(params, hash, null, synthetic); - this.push(80 - /* CaptureArgs */ - ); - this.expr(definition); - this.push(71 - /* CurryComponent */ - , this.constants.serializable(referrer)); - this.popFrame(); - this.fetch(_vm.Register.v0); - } - - pushSymbolTable(table) { - if (table) { - var constant = this.constants.serializable(table); - this.push(48 - /* PushSymbolTable */ - , constant); - } else { - this.primitive(null); - } + parentElement() { + return this.parentNode; } - invokeComponent(capabilities, attrs, params, hash, synthetic, block, inverse = null, layout) { - this.fetch(_vm.Register.s0); - this.dup(_vm.Register.sp, 1); - this.load(_vm.Register.s0); - this.pushFrame(); - var bindableBlocks = !!(block || inverse || attrs); - var bindableAtNames = capabilities === true || capabilities.prepareArgs || !!(hash && hash[0].length !== 0); - var blocks = { - main: block, - else: inverse, - attrs - }; - this.compileArgs(params, hash, blocks, synthetic); - this.prepareArgs(_vm.Register.s0); - this.invokePreparedComponent(block !== null, bindableBlocks, bindableAtNames, () => { - if (layout) { - this.pushSymbolTable(layout.symbolTable); - this.pushLayout(layout); - this.resolveLayout(); - } else { - this.getComponentLayout(_vm.Register.s0); - } + firstNode() { + return this.node; + } - this.populateLayout(_vm.Register.s0); - }); - this.load(_vm.Register.s0); + lastNode() { + return this.node; } - invokeStaticComponent(capabilities, layout, attrs, params, hash, synthetic, block, inverse = null) { - var { - symbolTable - } = layout; - var bailOut = symbolTable.hasEval || capabilities.prepareArgs; + } - if (bailOut) { - this.invokeComponent(capabilities, attrs, params, hash, synthetic, block, inverse, layout); - return; - } + function move(bounds, reference) { + var parent = bounds.parentElement(); + var first = bounds.firstNode(); + var last = bounds.lastNode(); + var current = first; - this.fetch(_vm.Register.s0); - this.dup(_vm.Register.sp, 1); - this.load(_vm.Register.s0); - var { - symbols - } = symbolTable; + while (true) { + var next = current.nextSibling; + parent.insertBefore(current, reference); - if (capabilities.createArgs) { - this.pushFrame(); - this.compileArgs(params, hash, null, synthetic); + if (current === last) { + return next; } - this.beginComponentTransaction(); + current = next; + } + } - if (capabilities.dynamicScope) { - this.pushDynamicScope(); - } + function clear(bounds) { + var parent = bounds.parentElement(); + var first = bounds.firstNode(); + var last = bounds.lastNode(); + var current = first; - if (capabilities.createInstance) { - this.createComponent(_vm.Register.s0, block !== null); - } + while (true) { + var next = current.nextSibling; + parent.removeChild(current); - if (capabilities.createArgs) { - this.popFrame(); + if (current === last) { + return next; } - this.pushFrame(); - this.registerComponentDestructor(_vm.Register.s0); - var bindings = []; - this.getComponentSelf(_vm.Register.s0); - bindings.push({ - symbol: 0, - isBlock: false - }); - - for (var i = 0; i < symbols.length; i++) { - var symbol = symbols[i]; - - switch (symbol.charAt(0)) { - case '&': - var callerBlock = null; + current = next; + } + } - if (symbol === '&default') { - callerBlock = block; - } else if (symbol === '&inverse') { - callerBlock = inverse; - } else if (symbol === ATTRS_BLOCK) { - callerBlock = attrs; - } else { - throw (0, _util.unreachable)(); - } + function legacySyncReset(parent, env) { + var linked = (0, _util.peekAssociated)(parent); - if (callerBlock) { - this.pushYieldableBlock(callerBlock); - bindings.push({ - symbol: i + 1, - isBlock: true - }); - } else { - this.pushYieldableBlock(null); - bindings.push({ - symbol: i + 1, - isBlock: true - }); - } + if (linked !== null) { + env.willDestroy((0, _util.snapshot)(linked)); + } + } - break; + function asyncReset(parent, env) { + var linked = (0, _util.takeAssociated)(parent); - case '@': - if (!hash) { - break; - } + if (linked !== null) { + env.didDestroy((0, _util.snapshot)(linked)); + } + } - var [keys, values] = hash; - var lookupName = symbol; + function legacySyncDestroy(parent, env) { + env.willDestroy((0, _util.destructor)(parent)); + } - if (synthetic) { - lookupName = symbol.slice(1); - } + function asyncDestroy(parent, env) { + env.didDestroy((0, _util.destructor)(parent)); + } - var index = keys.indexOf(lookupName); + function detach(parent, env) { + legacySyncDestroy(parent, env); + clear(parent); + asyncDestroy(parent, env); + } - if (index !== -1) { - this.expr(values[index]); - bindings.push({ - symbol: i + 1, - isBlock: false - }); - } + function detachChildren(parent, env) { + legacySyncReset(parent, env); + asyncReset(parent, env); + return clear(parent); + } - break; - } - } + var _a; - this.pushRootScope(symbols.length + 1, !!(block || inverse || attrs)); + class First { + constructor(node) { + this.node = node; + } - for (var _i = bindings.length - 1; _i >= 0; _i--) { - var { - symbol: _symbol, - isBlock - } = bindings[_i]; + firstNode() { + return this.node; + } - if (isBlock) { - this.setBlock(_symbol); - } else { - this.setVariable(_symbol); - } - } + } - this.invokeStatic(layout); + class Last { + constructor(node) { + this.node = node; + } - if (capabilities.createInstance) { - this.didRenderLayout(_vm.Register.s0); - } + lastNode() { + return this.node; + } - this.popFrame(); - this.popScope(); + } - if (capabilities.dynamicScope) { - this.popDynamicScope(); - } + var CURSOR_STACK = (0, _util.symbol)('CURSOR_STACK'); - this.commitComponentTransaction(); - this.load(_vm.Register.s0); + class NewElementBuilder { + constructor(env, parentNode, nextSibling) { + this.constructing = null; + this.operations = null; + this[_a] = new _util.Stack(); + this.modifierStack = new _util.Stack(); + this.blockStack = new _util.Stack(); + this.pushElement(parentNode, nextSibling); + this.env = env; + this.dom = env.getAppendOperations(); + this.updateOperations = env.getDOM(); } - dynamicComponent(definition, attrs, params, hash, synthetic, block, inverse = null) { - this.replayable({ - args: () => { - this.expr(definition); - this.dup(); - return 2; - }, - body: () => { - this.jumpUnless('ELSE'); - this.resolveDynamicComponent(this.containingLayout.referrer); - this.pushDynamicComponentInstance(); - this.invokeComponent(true, attrs, params, hash, synthetic, block, inverse); - this.label('ELSE'); - } - }); + static forInitialRender(env, cursor) { + return new this(env, cursor.element, cursor.nextSibling).initialize(); } - yield(to, params) { - this.compileArgs(params, null, null, false); - this.getBlock(to); - this.resolveBlock(); - this.invokeYield(); - this.popScope(); - this.popFrame(); + static resume(env, block) { + var parentNode = block.parentElement(); + var nextSibling = block.reset(env); + var stack = new this(env, parentNode, nextSibling).initialize(); + stack.pushLiveBlock(block); + return stack; } - guardedAppend(expression, trusting) { - this.pushFrame(); - this.expr(expression); - this.pushMachine(50 - /* InvokeStatic */ - , this.stdLib.getAppend(trusting)); - this.popFrame(); + initialize() { + this.pushSimpleBlock(); + return this; } - invokeStaticBlock(block, callerCount = 0) { - var { - parameters - } = block.symbolTable; - var calleeCount = parameters.length; - var count = Math.min(callerCount, calleeCount); - this.pushFrame(); + debugBlocks() { + return this.blockStack.toArray(); + } - if (count) { - this.pushChildScope(); + get element() { + return this[CURSOR_STACK].current.element; + } - for (var i = 0; i < count; i++) { - this.dup(_vm.Register.fp, callerCount - i); - this.setVariable(parameters[i]); - } - } + get nextSibling() { + return this[CURSOR_STACK].current.nextSibling; + } - this.pushBlock(block); - this.resolveBlock(); - this.invokeVirtual(); + block() { + return this.blockStack.current; + } - if (count) { - this.popScope(); - } + popElement() { + this[CURSOR_STACK].pop(); + this[CURSOR_STACK].current; + } - this.popFrame(); - } /// CONVENIENCE - // internal helpers + pushSimpleBlock() { + return this.pushLiveBlock(new SimpleLiveBlock(this.element)); + } + pushUpdatableBlock() { + return this.pushLiveBlock(new UpdatableBlockImpl(this.element)); + } - string(_string) { - return this.constants.string(_string); + pushBlockList(list) { + return this.pushLiveBlock(new LiveBlockList(this.element, list)); } - names(_names) { - var names = []; + pushLiveBlock(block, isRemote = false) { + var current = this.blockStack.current; - for (var i = 0; i < _names.length; i++) { - var n = _names[i]; - names[i] = this.constants.string(n); + if (current !== null) { + if (!isRemote) { + current.didAppendBounds(block); + } } - return this.constants.array(names); - } - - symbols(symbols) { - return this.constants.array(symbols); - } // vm + this.__openBlock(); + this.blockStack.push(block); + return block; + } - primitive(_primitive) { - var type = 0 - /* NUMBER */ - ; - var primitive; + popBlock() { + this.block().finalize(this); - switch (typeof _primitive) { - case 'number': - if (_primitive % 1 === 0) { - if (_primitive > -1) { - primitive = _primitive; - } else { - primitive = this.constants.number(_primitive); - type = 4 - /* NEGATIVE */ - ; - } - } else { - primitive = this.constants.number(_primitive); - type = 1 - /* FLOAT */ - ; - } + this.__closeBlock(); - break; + return this.blockStack.pop(); + } - case 'string': - primitive = this.string(_primitive); - type = 2 - /* STRING */ - ; - break; + __openBlock() {} - case 'boolean': - primitive = _primitive | 0; - type = 3 - /* BOOLEAN_OR_VOID */ - ; - break; + __closeBlock() {} // todo return seems unused - case 'object': - // assume null - primitive = 2; - type = 3 - /* BOOLEAN_OR_VOID */ - ; - break; - case 'undefined': - primitive = 3; - type = 3 - /* BOOLEAN_OR_VOID */ - ; - break; + openElement(tag) { + var element = this.__openElement(tag); - default: - throw new Error('Invalid primitive passed to pushPrimitive'); - } + this.constructing = element; + return element; + } - var immediate = this.sizeImmediate(primitive << 3 | type, primitive); - this.push(13 - /* Primitive */ - , immediate); + __openElement(tag) { + return this.dom.createElement(tag, this.element); } - sizeImmediate(shifted, primitive) { - if (shifted >= 4294967295 - /* MAX_SIZE */ - || shifted < 0) { - return this.constants.number(primitive) << 3 | 5 - /* BIG_NUM */ - ; - } + flushElement(modifiers) { + var parent = this.element; + var element = this.constructing; - return shifted; - } + this.__flushElement(parent, element); - pushPrimitiveReference(primitive) { - this.primitive(primitive); - this.primitiveReference(); - } // components + this.constructing = null; + this.operations = null; + this.pushModifiers(modifiers); + this.pushElement(element, null); + this.didOpenElement(element); + } + __flushElement(parent, constructing) { + this.dom.insertBefore(parent, constructing, this.nextSibling); + } - pushComponentDefinition(handle) { - this.push(72 - /* PushComponentDefinition */ - , this.constants.handle(handle)); + closeElement() { + this.willCloseElement(); + this.popElement(); + return this.popModifiers(); } - resolveDynamicComponent(referrer) { - this.push(75 - /* ResolveDynamicComponent */ - , this.constants.serializable(referrer)); + pushRemoteElement(element, guid, insertBefore) { + return this.__pushRemoteElement(element, guid, insertBefore); } - staticComponentHelper(tag, hash, template) { - var { - handle, - capabilities, - compilable - } = this.compiler.resolveLayoutForTag(tag, this.referrer); - - if (handle !== null && capabilities !== null) { - if (compilable) { - if (hash) { - for (var i = 0; i < hash.length; i = i + 2) { - hash[i][0] = "@" + hash[i][0]; - } - } + __pushRemoteElement(element, _guid, insertBefore) { + this.pushElement(element, insertBefore); - this.pushComponentDefinition(handle); - this.invokeStaticComponent(capabilities, compilable, null, null, hash, false, template && template); - return true; + if (insertBefore === undefined) { + while (element.lastChild) { + element.removeChild(element.lastChild); } } - return false; - } // partial - - - invokePartial(referrer, symbols, evalInfo) { - var _meta = this.constants.serializable(referrer); - - var _symbols = this.constants.stringArray(symbols); - - var _evalInfo = this.constants.array(evalInfo); + var block = new RemoteLiveBlock(element); + return this.pushLiveBlock(block, true); + } - this.push(95 - /* InvokePartial */ - , _meta, _symbols, _evalInfo); + popRemoteElement() { + this.popBlock(); + this.popElement(); } - resolveMaybeLocal(name) { - this.push(96 - /* ResolveMaybeLocal */ - , this.string(name)); - } // debugger + pushElement(element, nextSibling = null) { + this[CURSOR_STACK].push(new CursorImpl(element, nextSibling)); + } + pushModifiers(modifiers) { + this.modifierStack.push(modifiers); + } - debugger(symbols, evalInfo) { - this.push(97 - /* Debugger */ - , this.constants.stringArray(symbols), this.constants.array(evalInfo)); - } // dom + popModifiers() { + return this.modifierStack.pop(); + } + didAppendBounds(bounds) { + this.block().didAppendBounds(bounds); + return bounds; + } - text(text) { - this.push(26 - /* Text */ - , this.constants.string(text)); + didAppendNode(node) { + this.block().didAppendNode(node); + return node; } - openPrimitiveElement(tag) { - this.push(33 - /* OpenElement */ - , this.constants.string(tag)); + didOpenElement(element) { + this.block().openElement(element); + return element; } - modifier(locator, params, hash) { - this.pushFrame(); - this.compileArgs(params, hash, null, true); - this.push(40 - /* Modifier */ - , this.constants.handle(locator)); - this.popFrame(); + willCloseElement() { + this.block().closeElement(); } - comment(_comment) { - var comment = this.constants.string(_comment); - this.push(27 - /* Comment */ - , comment); + appendText(string) { + return this.didAppendNode(this.__appendText(string)); } - dynamicAttr(_name, _namespace, trusting) { - var name = this.constants.string(_name); - var namespace = _namespace ? this.constants.string(_namespace) : 0; - this.push(36 - /* DynamicAttr */ - , name, trusting === true ? 1 : 0, namespace); + __appendText(text) { + var { + dom, + element, + nextSibling + } = this; + var node = dom.createTextNode(text); + dom.insertBefore(element, node, nextSibling); + return node; } - componentAttr(_name, _namespace, trusting) { - var name = this.constants.string(_name); - var namespace = _namespace ? this.constants.string(_namespace) : 0; - this.push(37 - /* ComponentAttr */ - , name, trusting === true ? 1 : 0, namespace); + __appendNode(node) { + this.dom.insertBefore(this.element, node, this.nextSibling); + return node; } - staticAttr(_name, _namespace, _value) { - var name = this.constants.string(_name); - var namespace = _namespace ? this.constants.string(_namespace) : 0; - var value = this.constants.string(_value); - this.push(35 - /* StaticAttr */ - , name, value, namespace); - } // expressions + __appendFragment(fragment) { + var first = fragment.firstChild; + if (first) { + var ret = new ConcreteBounds(this.element, first, fragment.lastChild); + this.dom.insertBefore(this.element, fragment, this.nextSibling); + return ret; + } else { + return new SingleNodeBounds(this.element, this.__appendComment('')); + } + } - hasBlockParams(to) { - this.getBlock(to); - this.resolveBlock(); - this.push(10 - /* HasBlockParams */ - ); + __appendHTML(html) { + return this.dom.insertHTMLBefore(this.element, this.nextSibling, html); } - getProperty(key) { - this.push(7 - /* GetProperty */ - , this.string(key)); + appendDynamicHTML(value$$1) { + var bounds = this.trustedContent(value$$1); + this.didAppendBounds(bounds); } - helper(helper, params, hash) { - this.pushFrame(); - this.compileArgs(params, hash, null, true); - this.push(1 - /* Helper */ - , this.constants.handle(helper)); - this.popFrame(); - this.fetch(_vm.Register.v0); + appendDynamicText(value$$1) { + var node = this.untrustedContent(value$$1); + this.didAppendNode(node); + return node; } - bindDynamicScope(_names) { - this.push(43 - /* BindDynamicScope */ - , this.names(_names)); - } // convenience methods + appendDynamicFragment(value$$1) { + var bounds = this.__appendFragment(value$$1); - /** - * A convenience for pushing some arguments on the stack and - * running some code if the code needs to be re-executed during - * updating execution if some of the arguments have changed. - * - * # Initial Execution - * - * The `args` function should push zero or more arguments onto - * the stack and return the number of arguments pushed. - * - * The `body` function provides the instructions to execute both - * during initial execution and during updating execution. - * - * Internally, this function starts by pushing a new frame, so - * that the body can return and sets the return point ($ra) to - * the ENDINITIAL label. - * - * It then executes the `args` function, which adds instructions - * responsible for pushing the arguments for the block to the - * stack. These arguments will be restored to the stack before - * updating execution. - * - * Next, it adds the Enter opcode, which marks the current position - * in the DOM, and remembers the current $pc (the next instruction) - * as the first instruction to execute during updating execution. - * - * Next, it runs `body`, which adds the opcodes that should - * execute both during initial execution and during updating execution. - * If the `body` wishes to finish early, it should Jump to the - * `FINALLY` label. - * - * Next, it adds the FINALLY label, followed by: - * - * - the Exit opcode, which finalizes the marked DOM started by the - * Enter opcode. - * - the Return opcode, which returns to the current return point - * ($ra). - * - * Finally, it adds the ENDINITIAL label followed by the PopFrame - * instruction, which restores $fp, $sp and $ra. - * - * # Updating Execution - * - * Updating execution for this `replayable` occurs if the `body` added an - * assertion, via one of the `JumpIf`, `JumpUnless` or `AssertSame` opcodes. - * - * If, during updating executon, the assertion fails, the initial VM is - * restored, and the stored arguments are pushed onto the stack. The DOM - * between the starting and ending markers is cleared, and the VM's cursor - * is set to the area just cleared. - * - * The return point ($ra) is set to -1, the exit instruction. - * - * Finally, the $pc is set to to the instruction saved off by the - * Enter opcode during initial execution, and execution proceeds as - * usual. - * - * The only difference is that when a `Return` instruction is - * encountered, the program jumps to -1 rather than the END label, - * and the PopFrame opcode is not needed. - */ + this.didAppendBounds(bounds); + } + appendDynamicNode(value$$1) { + var node = this.__appendNode(value$$1); - replayable({ - args, - body - }) { - // Start a new label frame, to give END and RETURN - // a unique meaning. - this.startLabels(); - this.pushFrame(); // If the body invokes a block, its return will return to - // END. Otherwise, the return in RETURN will return to END. - - this.returnTo('ENDINITIAL'); // Push the arguments onto the stack. The args() function - // tells us how many stack elements to retain for re-execution - // when updating. - - var count = args(); // Start a new updating closure, remembering `count` elements - // from the stack. Everything after this point, and before END, - // will execute both initially and to update the block. - // - // The enter and exit opcodes also track the area of the DOM - // associated with this block. If an assertion inside the block - // fails (for example, the test value changes from true to false - // in an #if), the DOM is cleared and the program is re-executed, - // restoring `count` elements to the stack and executing the - // instructions between the enter and exit. + var bounds = new SingleNodeBounds(this.element, node); + this.didAppendBounds(bounds); + } - this.enter(count); // Evaluate the body of the block. The body of the block may - // return, which will jump execution to END during initial - // execution, and exit the updating routine. + trustedContent(value$$1) { + return this.__appendHTML(value$$1); + } - body(); // All execution paths in the body should run the FINALLY once - // they are done. It is executed both during initial execution - // and during updating execution. + untrustedContent(value$$1) { + return this.__appendText(value$$1); + } - this.label('FINALLY'); // Finalize the DOM. + appendComment(string) { + return this.didAppendNode(this.__appendComment(string)); + } - this.exit(); // In initial execution, this is a noop: it returns to the - // immediately following opcode. In updating execution, this - // exits the updating routine. + __appendComment(string) { + var { + dom, + element, + nextSibling + } = this; + var node = dom.createComment(string); + dom.insertBefore(element, node, nextSibling); + return node; + } - this.return(); // Cleanup code for the block. Runs on initial execution - // but not on updating. + __setAttribute(name, value$$1, namespace) { + this.dom.setAttribute(this.constructing, name, value$$1, namespace); + } - this.label('ENDINITIAL'); - this.popFrame(); - this.stopLabels(); + __setProperty(name, value$$1) { + this.constructing[name] = value$$1; } - /** - * A specialized version of the `replayable` convenience that allows the - * caller to provide different code based upon whether the item at - * the top of the stack is true or false. - * - * As in `replayable`, the `ifTrue` and `ifFalse` code can invoke `return`. - * - * During the initial execution, a `return` will continue execution - * in the cleanup code, which finalizes the current DOM block and pops - * the current frame. - * - * During the updating execution, a `return` will exit the updating - * routine, as it can reuse the DOM block and is always only a single - * frame deep. - */ + setStaticAttribute(name, value$$1, namespace) { + this.__setAttribute(name, value$$1, namespace); + } - replayableIf({ - args, - ifTrue, - ifFalse - }) { - this.replayable({ - args, - body: () => { - // If the conditional is false, jump to the ELSE label. - this.jumpUnless('ELSE'); // Otherwise, execute the code associated with the true branch. - - ifTrue(); // We're done, so return. In the initial execution, this runs - // the cleanup code. In the updating VM, it exits the updating - // routine. - - this.jump('FINALLY'); - this.label('ELSE'); // If the conditional is false, and code associatied ith the - // false branch was provided, execute it. If there was no code - // associated with the false branch, jumping to the else statement - // has no other behavior. - - if (ifFalse) { - ifFalse(); - } - } - }); + setDynamicAttribute(name, value$$1, trusting, namespace) { + var element = this.constructing; + var attribute = this.env.attributeFor(element, name, trusting, namespace); + attribute.set(this, value$$1, this.env); + return attribute; } - inlineBlock(block) { - return new CompilableBlock(this.compiler, { - block, - containingLayout: this.containingLayout - }); + } + + _exports.NewElementBuilder = NewElementBuilder; + _a = CURSOR_STACK; + + class SimpleLiveBlock { + constructor(parent) { + this.parent = parent; + this.first = null; + this.last = null; + this.destroyables = null; + this.nesting = 0; } - evalSymbols() { - var { - containingLayout: { - block - } - } = this; - return block.hasEval ? block.symbols : null; + parentElement() { + return this.parent; } - compileParams(params) { - if (!params) return 0; + firstNode() { + var first = this.first; + return first.firstNode(); + } - for (var i = 0; i < params.length; i++) { - this.expr(params[i]); - } + lastNode() { + var last = this.last; + return last.lastNode(); + } - return params.length; + openElement(element) { + this.didAppendNode(element); + this.nesting++; } - compileArgs(params, hash, blocks, synthetic) { - if (blocks) { - this.pushYieldableBlock(blocks.main); - this.pushYieldableBlock(blocks.else); - this.pushYieldableBlock(blocks.attrs); - } + closeElement() { + this.nesting--; + } - var count = this.compileParams(params); - var flags = count << 4; - if (synthetic) flags |= 0b1000; + didAppendNode(node) { + if (this.nesting !== 0) return; - if (blocks) { - flags |= 0b111; + if (!this.first) { + this.first = new First(node); } - var names = _util.EMPTY_ARRAY; + this.last = new Last(node); + } - if (hash) { - names = hash[0]; - var val = hash[1]; + didAppendBounds(bounds) { + if (this.nesting !== 0) return; - for (var i = 0; i < val.length; i++) { - this.expr(val[i]); - } + if (!this.first) { + this.first = bounds; } - this.pushArgs(names, flags); + this.last = bounds; } - template(block) { - if (!block) return null; - return this.inlineBlock(block); + finalize(stack) { + if (this.first === null) { + stack.appendComment(''); + } } } - _exports.OpcodeBuilder = OpcodeBuilder; - - class LazyOpcodeBuilder extends OpcodeBuilder { - pushBlock(block) { - if (block) { - this.pushOther(block); - } else { - this.primitive(null); + class RemoteLiveBlock extends SimpleLiveBlock { + [_util.DESTROY]() { + // In general, you only need to clear the root of a hierarchy, and should never + // need to clear any child nodes. This is an important constraint that gives us + // a strong guarantee that clearing a subtree is a single DOM operation. + // + // Because remote blocks are not normally physically nested inside of the tree + // that they are logically nested inside, we manually clear remote blocks when + // a logical parent is cleared. + // + // HOWEVER, it is currently possible for a remote block to be physically nested + // inside of the block it is logically contained inside of. This happens when + // the remote block is appended to the end of the application's entire element. + // + // The problem with that scenario is that Glimmer believes that it owns more of + // the DOM than it actually does. The code is attempting to write past the end + // of the Glimmer-managed root, but Glimmer isn't aware of that. + // + // The correct solution to that problem is for Glimmer to be aware of the end + // of the bounds that it owns, and once we make that change, this check could + // be removed. + // + // For now, a more targeted fix is to check whether the node was already removed + // and avoid clearing the node if it was. In most cases this shouldn't happen, + // so this might hide bugs where the code clears nested nodes unnecessarily, + // so we should eventually try to do the correct fix. + if (this.parentElement() === this.firstNode().parentNode) { + clear(this); } } - resolveBlock() { - this.push(46 - /* CompileBlock */ - ); - } + } - pushLayout(layout) { - if (layout) { - this.pushOther(layout); - } else { - this.primitive(null); - } - } + _exports.RemoteLiveBlock = RemoteLiveBlock; - resolveLayout() { - this.push(46 - /* CompileBlock */ - ); - } + class UpdatableBlockImpl extends SimpleLiveBlock { + reset(env) { + var nextSibling = detachChildren(this, env); // let nextSibling = clear(this); - invokeStatic(compilable) { - this.pushOther(compilable); - this.push(46 - /* CompileBlock */ - ); - this.pushMachine(49 - /* InvokeVirtual */ - ); + this.first = null; + this.last = null; + this.destroyables = null; + this.nesting = 0; + return nextSibling; } - pushOther(value) { - this.push(12 - /* Constant */ - , this.other(value)); - } + } // FIXME: All the noops in here indicate a modelling problem - other(value) { - return this.constants.other(value); - } - } + _exports.UpdatableBlockImpl = UpdatableBlockImpl; - _exports.LazyOpcodeBuilder = LazyOpcodeBuilder; + class LiveBlockList { + constructor(parent, boundList) { + this.parent = parent; + this.boundList = boundList; + this.parent = parent; + this.boundList = boundList; + } - class EagerOpcodeBuilder extends OpcodeBuilder { - pushBlock(block) { - var handle = block ? block.compile() : null; - this.primitive(handle); + parentElement() { + return this.parent; } - resolveBlock() { - return; + firstNode() { + var head = this.boundList.head(); + return head.firstNode(); } - pushLayout(layout) { - if (layout) { - this.primitive(layout.compile()); - } else { - this.primitive(null); - } + lastNode() { + var tail = this.boundList.tail(); + return tail.lastNode(); } - resolveLayout() {} + openElement(_element) {} - invokeStatic(compilable) { - var handle = compilable.compile(); // If the handle for the invoked component is not yet known (for example, - // because this is a recursive invocation and we're still compiling), push a - // function that will produce the correct handle when the heap is - // serialized. + closeElement() {} - if (handle === PLACEHOLDER_HANDLE$1) { - this.pushMachine(50 - /* InvokeStatic */ - , () => compilable.compile()); - } else { - this.pushMachine(50 - /* InvokeStatic */ - , handle); - } - } + didAppendNode(_node) {} + + didAppendBounds(_bounds) {} + + finalize(_stack) {} } - _exports.EagerOpcodeBuilder = EagerOpcodeBuilder; + function clientBuilder(env, cursor) { + return NewElementBuilder.forInitialRender(env, cursor); + } // http://www.w3.org/TR/html/syntax.html#html-integration-point - class LazyCompiler extends AbstractCompiler { - // FIXME: turn to static method - constructor(lookup, resolver, macros) { - var constants = new _program.LazyConstants(resolver); - var program = new _program.Program(constants); - super(macros, program, lookup); - } - builderFor(containingLayout) { - return new LazyOpcodeBuilder(this, containingLayout); - } + var SVG_INTEGRATION_POINTS = { + foreignObject: 1, + desc: 1, + title: 1 + }; // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes + // TODO: Adjust SVG attributes + // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign + // TODO: Adjust SVG elements + // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - } + var BLACKLIST_TABLE = Object.create(null); - _exports.LazyCompiler = LazyCompiler; + class DOMOperations { + constructor(document) { + this.document = document; + this.setupUselessElement(); + } // split into seperate method so that NodeDOMTreeConstruction + // can override it. - class PartialDefinition { - constructor(name, // for debugging - template) { - this.name = name; - this.template = template; - } - getPartial() { - var partial = this.template.asPartial(); - var handle = partial.compile(); - return { - symbolTable: partial.symbolTable, - handle - }; + setupUselessElement() { + this.uselessElement = this.document.createElement('div'); } - } + createElement(tag, context) { + var isElementInSVGNamespace, isHTMLIntegrationPoint; - _exports.PartialDefinition = PartialDefinition; - var clientId = 0; + if (context) { + isElementInSVGNamespace = context.namespaceURI === "http://www.w3.org/2000/svg" + /* SVG */ + || tag === 'svg'; + isHTMLIntegrationPoint = !!SVG_INTEGRATION_POINTS[context.tagName]; + } else { + isElementInSVGNamespace = tag === 'svg'; + isHTMLIntegrationPoint = false; + } - function templateFactory({ - id: templateId, - meta, - block - }) { - var parsedBlock; - var id = templateId || "client-" + clientId++; + if (isElementInSVGNamespace && !isHTMLIntegrationPoint) { + // FIXME: This does not properly handle with color, face, or + // size attributes, which is also disallowed by the spec. We should fix + // this. + if (BLACKLIST_TABLE[tag]) { + throw new Error(`Cannot create a ${tag} inside an SVG context`); + } - var create = (compiler, envMeta) => { - var newMeta = envMeta ? (0, _util.assign)({}, envMeta, meta) : meta; + return this.document.createElementNS("http://www.w3.org/2000/svg" + /* SVG */ + , tag); + } else { + return this.document.createElement(tag); + } + } - if (!parsedBlock) { - parsedBlock = JSON.parse(block); + insertBefore(parent, node, reference) { + parent.insertBefore(node, reference); + } + + insertHTMLBefore(parent, nextSibling, html) { + if (html === '') { + var comment = this.createComment(''); + parent.insertBefore(comment, nextSibling); + return new ConcreteBounds(parent, comment, comment); } - return new TemplateImpl(compiler, { - id, - block: parsedBlock, - referrer: newMeta - }); - }; + var prev = nextSibling ? nextSibling.previousSibling : parent.lastChild; + var last; - return { - id, - meta, - create - }; - } + if (nextSibling === null) { + parent.insertAdjacentHTML("beforeend" + /* beforeend */ + , html); + last = parent.lastChild; + } else if (nextSibling instanceof HTMLElement) { + nextSibling.insertAdjacentHTML('beforebegin', html); + last = nextSibling.previousSibling; + } else { + // Non-element nodes do not support insertAdjacentHTML, so add an + // element and call it on that element. Then remove the element. + // + // This also protects Edge, IE and Firefox w/o the inspector open + // from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts + var { + uselessElement + } = this; + parent.insertBefore(uselessElement, nextSibling); + uselessElement.insertAdjacentHTML("beforebegin" + /* beforebegin */ + , html); + last = uselessElement.previousSibling; + parent.removeChild(uselessElement); + } - class TemplateImpl { - constructor(compiler, parsedLayout) { - this.compiler = compiler; - this.parsedLayout = parsedLayout; - this.layout = null; - this.partial = null; - this.wrappedLayout = null; - var { - block - } = parsedLayout; - this.symbols = block.symbols; - this.hasEval = block.hasEval; - this.referrer = parsedLayout.referrer; - this.id = parsedLayout.id || "client-" + clientId++; + var first = prev ? prev.nextSibling : parent.firstChild; + return new ConcreteBounds(parent, first, last); } - asLayout() { - if (this.layout) return this.layout; - return this.layout = new CompilableProgram(this.compiler, (0, _polyfills.assign)({}, this.parsedLayout, { - asPartial: false - })); + createTextNode(text) { + return this.document.createTextNode(text); } - asPartial() { - if (this.partial) return this.partial; - return this.layout = new CompilableProgram(this.compiler, (0, _polyfills.assign)({}, this.parsedLayout, { - asPartial: true - })); + createComment(data) { + return this.document.createComment(data); } - asWrappedLayout() { - if (this.wrappedLayout) return this.wrappedLayout; - return this.wrappedLayout = new WrappedBuilder(this.compiler, (0, _polyfills.assign)({}, this.parsedLayout, { - asPartial: false - })); + } + + function moveNodesBefore(source, target, nextSibling) { + var first = source.firstChild; + var last = first; + var current = first; + + while (current) { + var next = current.nextSibling; + target.insertBefore(current, nextSibling); + last = current; + current = next; } + return new ConcreteBounds(target, first, last); } -}); -define("@glimmer/program", ["exports", "@glimmer/util"], function (_exports, _util) { - "use strict"; - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.Opcode = _exports.Program = _exports.RuntimeProgram = _exports.WriteOnlyProgram = _exports.Heap = _exports.LazyConstants = _exports.Constants = _exports.RuntimeConstants = _exports.WriteOnlyConstants = _exports.WELL_KNOWN_EMPTY_ARRAY_POSITION = void 0; - var UNRESOLVED = {}; - var WELL_KNOWN_EMPTY_ARRAY_POSITION = 0; - _exports.WELL_KNOWN_EMPTY_ARRAY_POSITION = WELL_KNOWN_EMPTY_ARRAY_POSITION; - var WELL_KNOW_EMPTY_ARRAY = Object.freeze([]); + var SVG_NAMESPACE = "http://www.w3.org/2000/svg" + /* SVG */ + ; // Patch: insertAdjacentHTML on SVG Fix + // Browsers: Safari, IE, Edge, Firefox ~33-34 + // Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is + // present but throws an exception on IE and Edge. Old versions of + // Firefox create nodes in the incorrect namespace. + // Fix: Since IE and Edge silently fail to create SVG nodes using + // innerHTML, and because Firefox may create nodes in the incorrect + // namespace using innerHTML on SVG elements, an HTML-string wrapping + // approach is used. A pre/post SVG tag is added to the string, then + // that whole string is added to a div. The created nodes are plucked + // out and applied to the target location on DOM. - class WriteOnlyConstants { - constructor() { - // `0` means NULL - this.strings = []; - this.arrays = [WELL_KNOW_EMPTY_ARRAY]; - this.tables = []; - this.handles = []; - this.resolved = []; - this.numbers = []; + function applySVGInnerHTMLFix(document, DOMClass, svgNamespace) { + if (!document) return DOMClass; + + if (!shouldApplyFix(document, svgNamespace)) { + return DOMClass; } - string(value) { - var index = this.strings.indexOf(value); + var div = document.createElement('div'); + return class DOMChangesWithSVGInnerHTMLFix extends DOMClass { + insertHTMLBefore(parent, nextSibling, html) { + if (html === '') { + return super.insertHTMLBefore(parent, nextSibling, html); + } - if (index > -1) { - return index; + if (parent.namespaceURI !== svgNamespace) { + return super.insertHTMLBefore(parent, nextSibling, html); + } + + return fixSVG(parent, div, html, nextSibling); } - return this.strings.push(value) - 1; - } + }; + } - stringArray(strings) { - var _strings = new Array(strings.length); + function fixSVG(parent, div, html, reference) { + var source; // This is important, because decendants of the integration + // point are parsed in the HTML namespace - for (var i = 0; i < strings.length; i++) { - _strings[i] = this.string(strings[i]); - } + if (parent.tagName.toUpperCase() === 'FOREIGNOBJECT') { + // IE, Edge: also do not correctly support using `innerHTML` on SVG + // namespaced elements. So here a wrapper is used. + var wrappedHtml = '' + html + ''; + (0, _util.clearElement)(div); + div.insertAdjacentHTML("afterbegin" + /* afterbegin */ + , wrappedHtml); + source = div.firstChild.firstChild; + } else { + // IE, Edge: also do not correctly support using `innerHTML` on SVG + // namespaced elements. So here a wrapper is used. + var _wrappedHtml = '' + html + ''; - return this.array(_strings); + (0, _util.clearElement)(div); + div.insertAdjacentHTML("afterbegin" + /* afterbegin */ + , _wrappedHtml); + source = div.firstChild; } - array(values) { - if (values.length === 0) { - return WELL_KNOWN_EMPTY_ARRAY_POSITION; - } + return moveNodesBefore(source, parent, reference); + } - var index = this.arrays.indexOf(values); + function shouldApplyFix(document, svgNamespace) { + var svg = document.createElementNS(svgNamespace, 'svg'); - if (index > -1) { - return index; + try { + svg.insertAdjacentHTML("beforeend" + /* beforeend */ + , ''); + } catch (e) {// IE, Edge: Will throw, insertAdjacentHTML is unsupported on SVG + // Safari: Will throw, insertAdjacentHTML is not present on SVG + } finally { + // FF: Old versions will create a node in the wrong namespace + if (svg.childNodes.length === 1 && svg.firstChild.namespaceURI === SVG_NAMESPACE) { + // The test worked as expected, no fix required + return false; } - return this.arrays.push(values) - 1; + return true; + } + } // Patch: Adjacent text node merging fix + // Browsers: IE, Edge, Firefox w/o inspector open + // Reason: These browsers will merge adjacent text nodes. For exmaple given + //
Hello
with div.insertAdjacentHTML(' world') browsers + // with proper behavior will populate div.childNodes with two items. + // These browsers will populate it with one merged node instead. + // Fix: Add these nodes to a wrapper element, then iterate the childNodes + // of that wrapper and move the nodes to their target location. Note + // that potential SVG bugs will have been handled before this fix. + // Note that this fix must only apply to the previous text node, as + // the base implementation of `insertHTMLBefore` already handles + // following text nodes correctly. + + + function applyTextNodeMergingFix(document, DOMClass) { + if (!document) return DOMClass; + + if (!shouldApplyFix$1(document)) { + return DOMClass; } - handle(handle) { - var index = this.handles.indexOf(handle); - - if (index > -1) { - return index; + return class DOMChangesWithTextNodeMergingFix extends DOMClass { + constructor(document) { + super(document); + this.uselessComment = document.createComment(''); } - this.resolved.push(UNRESOLVED); - return this.handles.push(handle) - 1; - } + insertHTMLBefore(parent, nextSibling, html) { + if (html === '') { + return super.insertHTMLBefore(parent, nextSibling, html); + } - serializable(value) { - var str = JSON.stringify(value); - var index = this.strings.indexOf(str); + var didSetUselessComment = false; + var nextPrevious = nextSibling ? nextSibling.previousSibling : parent.lastChild; - if (index > -1) { - return index; - } + if (nextPrevious && nextPrevious instanceof Text) { + didSetUselessComment = true; + parent.insertBefore(this.uselessComment, nextSibling); + } - return this.strings.push(str) - 1; - } + var bounds = super.insertHTMLBefore(parent, nextSibling, html); - number(number) { - var index = this.numbers.indexOf(number); + if (didSetUselessComment) { + parent.removeChild(this.uselessComment); + } - if (index > -1) { - return index; + return bounds; } - return this.numbers.push(number) - 1; - } - - toPool() { - return { - strings: this.strings, - arrays: this.arrays, - handles: this.handles, - numbers: this.numbers - }; - } - + }; } - _exports.WriteOnlyConstants = WriteOnlyConstants; + function shouldApplyFix$1(document) { + var mergingTextDiv = document.createElement('div'); + mergingTextDiv.appendChild(document.createTextNode('first')); + mergingTextDiv.insertAdjacentHTML("beforeend" + /* beforeend */ + , 'second'); - class RuntimeConstants { - constructor(resolver, pool) { - this.resolver = resolver; - this.strings = pool.strings; - this.arrays = pool.arrays; - this.handles = pool.handles; - this.resolved = this.handles.map(() => UNRESOLVED); - this.numbers = pool.numbers; + if (mergingTextDiv.childNodes.length === 2) { + // It worked as expected, no fix required + return false; } - getString(value) { - return this.strings[value]; - } + return true; + } - getNumber(value) { - return this.numbers[value]; - } + ['b', 'big', 'blockquote', 'body', 'br', 'center', 'code', 'dd', 'div', 'dl', 'dt', 'em', 'embed', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'i', 'img', 'li', 'listing', 'main', 'meta', 'nobr', 'ol', 'p', 'pre', 'ruby', 's', 'small', 'span', 'strong', 'strike', 'sub', 'sup', 'table', 'tt', 'u', 'ul', 'var'].forEach(tag => BLACKLIST_TABLE[tag] = 1); + var WHITESPACE = /[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/; + var doc = typeof document === 'undefined' ? null : document; - getStringArray(value) { - var names = this.getArray(value); + function isWhitespace(string) { + return WHITESPACE.test(string); + } - var _names = new Array(names.length); + var DOM; - for (var i = 0; i < names.length; i++) { - var n = names[i]; - _names[i] = this.getString(n); + (function (DOM) { + class TreeConstruction extends DOMOperations { + createElementNS(namespace, tag) { + return this.document.createElementNS(namespace, tag); } - return _names; - } - - getArray(value) { - return this.arrays[value]; - } - - resolveHandle(index) { - var resolved = this.resolved[index]; - - if (resolved === UNRESOLVED) { - var handle = this.handles[index]; - resolved = this.resolved[index] = this.resolver.resolve(handle); + setAttribute(element, name, value$$1, namespace = null) { + if (namespace) { + element.setAttributeNS(namespace, name, value$$1); + } else { + element.setAttribute(name, value$$1); + } } - return resolved; - } - - getSerializable(s) { - return JSON.parse(this.strings[s]); } - } - - _exports.RuntimeConstants = RuntimeConstants; - - class Constants extends WriteOnlyConstants { - constructor(resolver, pool) { - super(); - this.resolver = resolver; + DOM.TreeConstruction = TreeConstruction; + var appliedTreeContruction = TreeConstruction; + appliedTreeContruction = applyTextNodeMergingFix(doc, appliedTreeContruction); + appliedTreeContruction = applySVGInnerHTMLFix(doc, appliedTreeContruction, "http://www.w3.org/2000/svg" + /* SVG */ + ); + DOM.DOMTreeConstruction = appliedTreeContruction; + })(DOM || (DOM = {})); - if (pool) { - this.strings = pool.strings; - this.arrays = pool.arrays; - this.handles = pool.handles; - this.resolved = this.handles.map(() => UNRESOLVED); - this.numbers = pool.numbers; - } + class DOMChangesImpl extends DOMOperations { + constructor(document) { + super(document); + this.document = document; + this.namespace = null; } - getNumber(value) { - return this.numbers[value]; + setAttribute(element, name, value$$1) { + element.setAttribute(name, value$$1); } - getString(value) { - return this.strings[value]; + removeAttribute(element, name) { + element.removeAttribute(name); } - getStringArray(value) { - var names = this.getArray(value); - - var _names = new Array(names.length); + insertAfter(element, node, reference) { + this.insertBefore(element, node, reference.nextSibling); + } - for (var i = 0; i < names.length; i++) { - var n = names[i]; - _names[i] = this.getString(n); - } + } - return _names; - } + _exports.IDOMChanges = DOMChangesImpl; + var helper = DOMChangesImpl; + helper = applyTextNodeMergingFix(doc, helper); + helper = applySVGInnerHTMLFix(doc, helper, "http://www.w3.org/2000/svg" + /* SVG */ + ); + var helper$1 = helper; + _exports.DOMChanges = helper$1; + var DOMTreeConstruction = DOM.DOMTreeConstruction; + _exports.DOMTreeConstruction = DOMTreeConstruction; - getArray(value) { - return this.arrays[value]; + class PrimitiveReference$1 extends _reference.ConstReference { + constructor(value$$1) { + super(value$$1); } - resolveHandle(index) { - var resolved = this.resolved[index]; - - if (resolved === UNRESOLVED) { - var handle = this.handles[index]; - resolved = this.resolved[index] = this.resolver.resolve(handle); + static create(value$$1) { + if (value$$1 === undefined) { + return UNDEFINED_REFERENCE; + } else if (value$$1 === null) { + return NULL_REFERENCE; + } else if (value$$1 === true) { + return TRUE_REFERENCE; + } else if (value$$1 === false) { + return FALSE_REFERENCE; + } else if (typeof value$$1 === 'number') { + return new ValueReference(value$$1); + } else { + return new StringReference(value$$1); } - - return resolved; } - getSerializable(s) { - return JSON.parse(this.strings[s]); + get(_key) { + return UNDEFINED_REFERENCE; } } - _exports.Constants = Constants; + _exports.PrimitiveReference = PrimitiveReference$1; - class LazyConstants extends Constants { + class StringReference extends PrimitiveReference$1 { constructor() { super(...arguments); - this.others = []; - this.serializables = []; + this.lengthReference = null; } - serializable(value) { - var index = this.serializables.indexOf(value); - - if (index > -1) { - return index; - } + get(key) { + if (key === 'length') { + var { + lengthReference + } = this; - return this.serializables.push(value) - 1; - } + if (lengthReference === null) { + lengthReference = this.lengthReference = new ValueReference(this.inner.length); + } - getSerializable(s) { - return this.serializables[s]; + return lengthReference; + } else { + return super.get(key); + } } - getOther(value) { - return this.others[value - 1]; - } + } - other(other) { - return this.others.push(other); + class ValueReference extends PrimitiveReference$1 { + constructor(value$$1) { + super(value$$1); } } - _exports.LazyConstants = LazyConstants; + var UNDEFINED_REFERENCE = new ValueReference(undefined); + _exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE; + var NULL_REFERENCE = new ValueReference(null); + _exports.NULL_REFERENCE = NULL_REFERENCE; + var TRUE_REFERENCE = new ValueReference(true); + var FALSE_REFERENCE = new ValueReference(false); - class Opcode { - constructor(heap) { - this.heap = heap; - this.offset = 0; + class ConditionalReference { + constructor(inner, toBool = defaultToBool) { + this.inner = inner; + this.toBool = toBool; + this.tag = inner.tag; } - get size() { - var rawType = this.heap.getbyaddr(this.offset); - return ((rawType & 768 - /* OPERAND_LEN_MASK */ - ) >> 8 - /* ARG_SHIFT */ - ) + 1; + value() { + return this.toBool(this.inner.value()); } - get isMachine() { - var rawType = this.heap.getbyaddr(this.offset); - return rawType & 1024 - /* MACHINE_MASK */ - ; - } + } - get type() { - return this.heap.getbyaddr(this.offset) & 255 - /* TYPE_MASK */ - ; - } + _exports.ConditionalReference = ConditionalReference; - get op1() { - return this.heap.getbyaddr(this.offset + 1); - } + function defaultToBool(value$$1) { + return !!value$$1; + } - get op2() { - return this.heap.getbyaddr(this.offset + 2); + function normalizeStringValue(value$$1) { + if (isEmpty(value$$1)) { + return ''; } - get op3() { - return this.heap.getbyaddr(this.offset + 3); - } + return String(value$$1); + } + + function shouldCoerce(value$$1) { + return isString(value$$1) || isEmpty(value$$1) || typeof value$$1 === 'boolean' || typeof value$$1 === 'number'; + } + function isEmpty(value$$1) { + return value$$1 === null || value$$1 === undefined || typeof value$$1.toString !== 'function'; } - _exports.Opcode = Opcode; + function isSafeString(value$$1) { + return typeof value$$1 === 'object' && value$$1 !== null && typeof value$$1.toHTML === 'function'; + } - function encodeTableInfo(scopeSize, state) { - return state | scopeSize << 2; + function isNode(value$$1) { + return typeof value$$1 === 'object' && value$$1 !== null && typeof value$$1.nodeType === 'number'; } - function changeState(info, newState) { - return info | newState << 30; + function isFragment(value$$1) { + return isNode(value$$1) && value$$1.nodeType === 11; } - var PAGE_SIZE = 0x100000; - /** - * The Heap is responsible for dynamically allocating - * memory in which we read/write the VM's instructions - * from/to. When we malloc we pass out a VMHandle, which - * is used as an indirect way of accessing the memory during - * execution of the VM. Internally we track the different - * regions of the memory in an int array known as the table. - * - * The table 32-bit aligned and has the following layout: - * - * | ... | hp (u32) | info (u32) | size (u32) | - * | ... | Handle | Scope Size | State | Size | - * | ... | 32bits | 30bits | 2bits | 32bit | - * - * With this information we effectively have the ability to - * control when we want to free memory. That being said you - * can not free during execution as raw address are only - * valid during the execution. This means you cannot close - * over them as you will have a bad memory access exception. + function isString(value$$1) { + return typeof value$$1 === 'string'; + } + /* + * @method normalizeProperty + * @param element {HTMLElement} + * @param slotName {String} + * @returns {Object} { name, type } */ - class Heap { - constructor(serializedHeap) { - this.placeholders = []; - this.offset = 0; - this.handle = 0; - this.capacity = PAGE_SIZE; - if (serializedHeap) { - var { - buffer, - table, - handle - } = serializedHeap; - this.heap = new Uint32Array(buffer); - this.table = table; - this.offset = this.heap.length; - this.handle = handle; - this.capacity = 0; + function normalizeProperty(element, slotName) { + var type, normalized; + + if (slotName in element) { + normalized = slotName; + type = 'prop'; + } else { + var lower = slotName.toLowerCase(); + + if (lower in element) { + type = 'prop'; + normalized = lower; } else { - this.heap = new Uint32Array(PAGE_SIZE); - this.table = []; + type = 'attr'; + normalized = slotName; } } - push(item) { - this.sizeCheck(); - this.heap[this.offset++] = item; + if (type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName, normalized))) { + type = 'attr'; } - sizeCheck() { - if (this.capacity === 0) { - var heap = slice(this.heap, 0, this.offset); - this.heap = new Uint32Array(heap.length + PAGE_SIZE); - this.heap.set(heap, 0); - this.capacity = PAGE_SIZE; - } + return { + normalized, + type + }; + } // properties that MUST be set as attributes, due to: + // * browser bug + // * strange spec outlier - this.capacity--; - } - getbyaddr(address) { - return this.heap[address]; + var ATTR_OVERRIDES = { + INPUT: { + form: true, + // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false + // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false + // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true + autocorrect: true, + // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true + // Safari 9.1.3: 'list' in document.createElement('input') === false + list: true + }, + // element.form is actually a legitimate readOnly property, that is to be + // mutated, but must be mutated by setAttribute... + SELECT: { + form: true + }, + OPTION: { + form: true + }, + TEXTAREA: { + form: true + }, + LABEL: { + form: true + }, + FIELDSET: { + form: true + }, + LEGEND: { + form: true + }, + OBJECT: { + form: true + }, + BUTTON: { + form: true } + }; - setbyaddr(address, value) { - this.heap[address] = value; - } + function preferAttr(tagName, propName) { + var tag = ATTR_OVERRIDES[tagName.toUpperCase()]; + return tag && tag[propName.toLowerCase()] || false; + } - malloc() { - // push offset, info, size - this.table.push(this.offset, 0, 0); - var handle = this.handle; - this.handle += 3 - /* ENTRY_SIZE */ - ; - return handle; - } + var badProtocols = ['javascript:', 'vbscript:']; + var badTags = ['A', 'BODY', 'LINK', 'IMG', 'IFRAME', 'BASE', 'FORM']; + var badTagsForDataURI = ['EMBED']; + var badAttributes = ['href', 'src', 'background', 'action']; + var badAttributesForDataURI = ['src']; - finishMalloc(handle, scopeSize) { - this.table[handle + 1 - /* INFO_OFFSET */ - ] = encodeTableInfo(scopeSize, 0 - /* Allocated */ - ); - } + function has(array, item) { + return array.indexOf(item) !== -1; + } - size() { - return this.offset; - } // It is illegal to close over this address, as compaction - // may move it. However, it is legal to use this address - // multiple times between compactions. + function checkURI(tagName, attribute) { + return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute); + } + function checkDataURI(tagName, attribute) { + if (tagName === null) return false; + return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute); + } - getaddr(handle) { - return this.table[handle]; - } + function requiresSanitization(tagName, attribute) { + return checkURI(tagName, attribute) || checkDataURI(tagName, attribute); + } - gethandle(address) { - this.table.push(address, encodeTableInfo(0, 3 - /* Pointer */ - ), 0); - var handle = this.handle; - this.handle += 3 - /* ENTRY_SIZE */ - ; - return handle; - } + function sanitizeAttributeValue(env, element, attribute, value$$1) { + var tagName = null; - sizeof(handle) { - return -1; + if (value$$1 === null || value$$1 === undefined) { + return value$$1; } - scopesizeof(handle) { - var info = this.table[handle + 1 - /* INFO_OFFSET */ - ]; - return info >> 2; + if (isSafeString(value$$1)) { + return value$$1.toHTML(); } - free(handle) { - var info = this.table[handle + 1 - /* INFO_OFFSET */ - ]; - this.table[handle + 1 - /* INFO_OFFSET */ - ] = changeState(info, 1 - /* Freed */ - ); + if (!element) { + tagName = null; + } else { + tagName = element.tagName.toUpperCase(); } - pushPlaceholder(valueFunc) { - this.sizeCheck(); - var address = this.offset++; - this.heap[address] = 2147483647 - /* MAX_SIZE */ - ; - this.placeholders.push([address, valueFunc]); - } + var str = normalizeStringValue(value$$1); - patchPlaceholders() { - var { - placeholders - } = this; + if (checkURI(tagName, attribute)) { + var protocol = env.protocolForURL(str); - for (var i = 0; i < placeholders.length; i++) { - var [address, getValue] = placeholders[i]; - this.setbyaddr(address, getValue()); + if (has(badProtocols, protocol)) { + return `unsafe:${str}`; } } - capture(offset = this.offset) { - this.patchPlaceholders(); // Only called in eager mode - - var buffer = slice(this.heap, 0, offset).buffer; - return { - handle: this.handle, - table: this.table, - buffer: buffer - }; + if (checkDataURI(tagName, attribute)) { + return `unsafe:${str}`; } + return str; } - _exports.Heap = Heap; + function dynamicAttribute(element, attr, namespace) { + var { + tagName, + namespaceURI + } = element; + var attribute = { + element, + name: attr, + namespace + }; + + if (namespaceURI === "http://www.w3.org/2000/svg" + /* SVG */ + ) { + return buildDynamicAttribute(tagName, attr, attribute); + } - class WriteOnlyProgram { - constructor(constants = new WriteOnlyConstants(), heap = new Heap()) { - this.constants = constants; - this.heap = heap; - this._opcode = new Opcode(this.heap); + var { + type, + normalized + } = normalizeProperty(element, attr); + + if (type === 'attr') { + return buildDynamicAttribute(tagName, normalized, attribute); + } else { + return buildDynamicProperty(tagName, normalized, attribute); } + } - opcode(offset) { - this._opcode.offset = offset; - return this._opcode; + function buildDynamicAttribute(tagName, name, attribute) { + if (requiresSanitization(tagName, name)) { + return new SafeDynamicAttribute(attribute); + } else { + return new SimpleDynamicAttribute(attribute); } - } - _exports.WriteOnlyProgram = WriteOnlyProgram; + function buildDynamicProperty(tagName, name, attribute) { + if (requiresSanitization(tagName, name)) { + return new SafeDynamicProperty(name, attribute); + } - class RuntimeProgram { - constructor(constants, heap) { - this.constants = constants; - this.heap = heap; - this._opcode = new Opcode(this.heap); + if (isUserInputValue(tagName, name)) { + return new InputValueDynamicAttribute(name, attribute); } - static hydrate(rawHeap, pool, resolver) { - var heap = new Heap(rawHeap); - var constants = new RuntimeConstants(resolver, pool); - return new RuntimeProgram(constants, heap); + if (isOptionSelected(tagName, name)) { + return new OptionSelectedDynamicAttribute(name, attribute); } - opcode(offset) { - this._opcode.offset = offset; - return this._opcode; + return new DefaultDynamicProperty(name, attribute); + } + + class DynamicAttribute { + constructor(attribute) { + this.attribute = attribute; } } - _exports.RuntimeProgram = RuntimeProgram; + _exports.DynamicAttribute = DynamicAttribute; - class Program extends WriteOnlyProgram {} + class SimpleDynamicAttribute extends DynamicAttribute { + set(dom, value$$1, _env) { + var normalizedValue = normalizeValue(value$$1); - _exports.Program = Program; + if (normalizedValue !== null) { + var { + name: _name2, + namespace + } = this.attribute; - function slice(arr, start, end) { - if (arr.slice !== undefined) { - return arr.slice(start, end); + dom.__setAttribute(_name2, normalizedValue, namespace); + } } - var ret = new Uint32Array(end); + update(value$$1, _env) { + var normalizedValue = normalizeValue(value$$1); + var { + element, + name + } = this.attribute; - for (; start < end; start++) { - ret[start] = arr[start]; + if (normalizedValue === null) { + element.removeAttribute(name); + } else { + element.setAttribute(name, normalizedValue); + } } - return ret; } -}); -define("@glimmer/reference", ["exports", "@glimmer/util"], function (_exports, _util) { - "use strict"; - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.map = map; - _exports.isModified = isModified; - _exports.bump = bump; - _exports.value = value; - _exports.validate = validate; - _exports.createTag = createTag; - _exports.createUpdatableTag = createUpdatableTag; - _exports.isConst = isConst; - _exports.isConstTag = isConstTag; - _exports.combineTagged = combineTagged; - _exports.combineSlice = combineSlice; - _exports.combine = combine; - _exports.CURRENT_TAG = _exports.VOLATILE_TAG = _exports.CONSTANT_TAG = _exports.update = _exports.dirty = _exports.MonomorphicTagImpl = _exports.ALLOW_CYCLES = _exports.COMPUTE = _exports.VOLATILE = _exports.INITIAL = _exports.CONSTANT = _exports.IteratorSynchronizer = _exports.ReferenceIterator = _exports.IterationArtifacts = _exports.ListItem = _exports.ConstReference = _exports.ReferenceCache = _exports.CachedReference = void 0; - var symbol = typeof Symbol !== 'undefined' ? Symbol : key => "__" + key + Math.floor(Math.random() * Date.now()) + "__"; - var CONSTANT = 0; - _exports.CONSTANT = CONSTANT; - var INITIAL = 1; - _exports.INITIAL = INITIAL; - var VOLATILE = 9007199254740991; // MAX_INT + _exports.SimpleDynamicAttribute = SimpleDynamicAttribute; - _exports.VOLATILE = VOLATILE; - var $REVISION = INITIAL; + class DefaultDynamicProperty extends DynamicAttribute { + constructor(normalizedName, attribute) { + super(attribute); + this.normalizedName = normalizedName; + } - function bump() { - $REVISION++; - } ////////// + set(dom, value$$1, _env) { + if (value$$1 !== null && value$$1 !== undefined) { + this.value = value$$1; + dom.__setProperty(this.normalizedName, value$$1); + } + } - var COMPUTE = symbol('TAG_COMPUTE'); ////////// + update(value$$1, _env) { + var { + element + } = this.attribute; - /** - * `value` receives a tag and returns an opaque Revision based on that tag. This - * snapshot can then later be passed to `validate` with the same tag to - * determine if the tag has changed at all since the time that `value` was - * called. - * - * The current implementation returns the global revision count directly for - * performance reasons. This is an implementation detail, and should not be - * relied on directly by users of these APIs. Instead, Revisions should be - * treated as if they are opaque/unknown, and should only be interacted with via - * the `value`/`validate` API. - * - * @param tag - */ + if (this.value !== value$$1) { + element[this.normalizedName] = this.value = value$$1; - _exports.COMPUTE = COMPUTE; + if (value$$1 === null || value$$1 === undefined) { + this.removeAttribute(); + } + } + } - function value(_tag) { - return $REVISION; - } - /** - * `validate` receives a tag and a snapshot from a previous call to `value` with - * the same tag, and determines if the tag is still valid compared to the - * snapshot. If the tag's state has changed at all since then, `validate` will - * return false, otherwise it will return true. This is used to determine if a - * calculation related to the tags should be rerun. - * - * @param tag - * @param snapshot - */ + removeAttribute() { + // TODO this sucks but to preserve properties first and to meet current + // semantics we must do this. + var { + element, + namespace + } = this.attribute; + if (namespace) { + element.removeAttributeNS(namespace, this.normalizedName); + } else { + element.removeAttribute(this.normalizedName); + } + } - function validate(tag, snapshot) { - return snapshot >= tag[COMPUTE](); } - var TYPE = symbol('TAG_TYPE'); - var ALLOW_CYCLES; - _exports.ALLOW_CYCLES = ALLOW_CYCLES; - - class MonomorphicTagImpl { - constructor(type) { - this.revision = INITIAL; - this.lastChecked = INITIAL; - this.lastValue = INITIAL; - this.isUpdating = false; - this.subtags = null; - this.subtag = null; - this.subtagBufferCache = null; - this[TYPE] = type; + class SafeDynamicProperty extends DefaultDynamicProperty { + set(dom, value$$1, env) { + var { + element, + name + } = this.attribute; + var sanitized = sanitizeAttributeValue(env, element, name, value$$1); + super.set(dom, sanitized, env); } - [COMPUTE]() { + update(value$$1, env) { var { - lastChecked - } = this; + element, + name + } = this.attribute; + var sanitized = sanitizeAttributeValue(env, element, name, value$$1); + super.update(sanitized, env); + } - if (lastChecked !== $REVISION) { - this.isUpdating = true; - this.lastChecked = $REVISION; + } - try { - var { - subtags, - subtag, - subtagBufferCache, - lastValue, - revision - } = this; + class SafeDynamicAttribute extends SimpleDynamicAttribute { + set(dom, value$$1, env) { + var { + element, + name + } = this.attribute; + var sanitized = sanitizeAttributeValue(env, element, name, value$$1); + super.set(dom, sanitized, env); + } - if (subtag !== null) { - var subtagValue = subtag[COMPUTE](); + update(value$$1, env) { + var { + element, + name + } = this.attribute; + var sanitized = sanitizeAttributeValue(env, element, name, value$$1); + super.update(sanitized, env); + } - if (subtagValue === subtagBufferCache) { - revision = Math.max(revision, lastValue); - } else { - // Clear the temporary buffer cache - this.subtagBufferCache = null; - revision = Math.max(revision, subtagValue); - } - } + } - if (subtags !== null) { - for (var i = 0; i < subtags.length; i++) { - var _value = subtags[i][COMPUTE](); + class InputValueDynamicAttribute extends DefaultDynamicProperty { + set(dom, value$$1) { + dom.__setProperty('value', normalizeStringValue(value$$1)); + } - revision = Math.max(_value, revision); - } - } + update(value$$1) { + var input = this.attribute.element; + var currentValue = input.value; + var normalizedValue = normalizeStringValue(value$$1); - this.lastValue = revision; - } finally { - this.isUpdating = false; - } + if (currentValue !== normalizedValue) { + input.value = normalizedValue; } + } - if (this.isUpdating === true) { - this.lastChecked = ++$REVISION; - } + } - return this.lastValue; + class OptionSelectedDynamicAttribute extends DefaultDynamicProperty { + set(dom, value$$1) { + if (value$$1 !== null && value$$1 !== undefined && value$$1 !== false) { + dom.__setProperty('selected', true); + } } - static update(_tag, _subtag) { - // TODO: TS 3.7 should allow us to do this via assertion - var tag = _tag; - var subtag = _subtag; + update(value$$1) { + var option = this.attribute.element; - if (subtag === CONSTANT_TAG) { - tag.subtag = null; + if (value$$1) { + option.selected = true; } else { - // There are two different possibilities when updating a subtag: - // - // 1. subtag[COMPUTE]() <= tag[COMPUTE](); - // 2. subtag[COMPUTE]() > tag[COMPUTE](); - // - // The first possibility is completely fine within our caching model, but - // the second possibility presents a problem. If the parent tag has - // already been read, then it's value is cached and will not update to - // reflect the subtag's greater value. Next time the cache is busted, the - // subtag's value _will_ be read, and it's value will be _greater_ than - // the saved snapshot of the parent, causing the resulting calculation to - // be rerun erroneously. - // - // In order to prevent this, when we first update to a new subtag we store - // its computed value, and then check against that computed value on - // subsequent updates. If its value hasn't changed, then we return the - // parent's previous value. Once the subtag changes for the first time, - // we clear the cache and everything is finally in sync with the parent. - tag.subtagBufferCache = subtag[COMPUTE](); - tag.subtag = subtag; + option.selected = false; } } - static dirty(tag) { - tag.revision = ++$REVISION; - } - } - _exports.MonomorphicTagImpl = MonomorphicTagImpl; - var dirty = MonomorphicTagImpl.dirty; - _exports.dirty = dirty; - var update = MonomorphicTagImpl.update; ////////// - - _exports.update = update; + function isOptionSelected(tagName, attribute) { + return tagName === 'OPTION' && attribute === 'selected'; + } - function createTag() { - return new MonomorphicTagImpl(0 - /* Dirtyable */ - ); + function isUserInputValue(tagName, attribute) { + return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value'; } - function createUpdatableTag() { - return new MonomorphicTagImpl(1 - /* Updatable */ - ); - } ////////// + function normalizeValue(value$$1) { + if (value$$1 === false || value$$1 === undefined || value$$1 === null || typeof value$$1.toString === 'undefined') { + return null; + } + if (value$$1 === true) { + return ''; + } // onclick function etc in SSR - var CONSTANT_TAG = new MonomorphicTagImpl(3 - /* Constant */ - ); - _exports.CONSTANT_TAG = CONSTANT_TAG; - function isConst({ - tag - }) { - return tag === CONSTANT_TAG; - } + if (typeof value$$1 === 'function') { + return null; + } - function isConstTag(tag) { - return tag === CONSTANT_TAG; - } ////////// + return String(value$$1); + } + var _a$1; - class VolatileTag { - [COMPUTE]() { - return VOLATILE; + class ScopeImpl { + constructor( // the 0th slot is `self` + slots, callerScope, // named arguments and blocks passed to a layout that uses eval + evalScope, // locals in scope when the partial was invoked + partialMap) { + this.slots = slots; + this.callerScope = callerScope; + this.evalScope = evalScope; + this.partialMap = partialMap; } - } - - var VOLATILE_TAG = new VolatileTag(); ////////// + static root(self, size = 0) { + var refs = new Array(size + 1); - _exports.VOLATILE_TAG = VOLATILE_TAG; + for (var i = 0; i <= size; i++) { + refs[i] = UNDEFINED_REFERENCE; + } - class CurrentTag { - [COMPUTE]() { - return $REVISION; + return new ScopeImpl(refs, null, null, null).init({ + self + }); } - } + static sized(size = 0) { + var refs = new Array(size + 1); - var CURRENT_TAG = new CurrentTag(); ////////// + for (var i = 0; i <= size; i++) { + refs[i] = UNDEFINED_REFERENCE; + } - _exports.CURRENT_TAG = CURRENT_TAG; + return new ScopeImpl(refs, null, null, null); + } - function combineTagged(tagged) { - var optimized = []; + init({ + self + }) { + this.slots[0] = self; + return this; + } - for (var i = 0, l = tagged.length; i < l; i++) { - var tag = tagged[i].tag; - if (tag === CONSTANT_TAG) continue; - optimized.push(tag); + getSelf() { + return this.get(0); } - return _combine(optimized); - } + getSymbol(symbol$$1) { + return this.get(symbol$$1); + } - function combineSlice(slice) { - var optimized = []; - var node = slice.head(); + getBlock(symbol$$1) { + var block = this.get(symbol$$1); + return block === UNDEFINED_REFERENCE ? null : block; + } - while (node !== null) { - var tag = node.tag; - if (tag !== CONSTANT_TAG) optimized.push(tag); - node = slice.nextNode(node); + getEvalScope() { + return this.evalScope; } - return _combine(optimized); - } + getPartialMap() { + return this.partialMap; + } - function combine(tags) { - var optimized = []; + bind(symbol$$1, value$$1) { + this.set(symbol$$1, value$$1); + } - for (var i = 0, l = tags.length; i < l; i++) { - var tag = tags[i]; - if (tag === CONSTANT_TAG) continue; - optimized.push(tag); + bindSelf(self) { + this.set(0, self); } - return _combine(optimized); - } + bindSymbol(symbol$$1, value$$1) { + this.set(symbol$$1, value$$1); + } - function _combine(tags) { - switch (tags.length) { - case 0: - return CONSTANT_TAG; + bindBlock(symbol$$1, value$$1) { + this.set(symbol$$1, value$$1); + } - case 1: - return tags[0]; + bindEvalScope(map) { + this.evalScope = map; + } - default: - var tag = new MonomorphicTagImpl(2 - /* Combinator */ - ); - tag.subtags = tags; - return tag; + bindPartialMap(map) { + this.partialMap = map; } - } - class CachedReference { - constructor() { - this.lastRevision = null; - this.lastValue = null; + bindCallerScope(scope) { + this.callerScope = scope; } - value() { - var { - tag, - lastRevision, - lastValue - } = this; + getCallerScope() { + return this.callerScope; + } - if (lastRevision === null || !validate(tag, lastRevision)) { - lastValue = this.lastValue = this.compute(); - this.lastRevision = value(tag); + child() { + return new ScopeImpl(this.slots.slice(), this.callerScope, this.evalScope, this.partialMap); + } + + get(index) { + if (index >= this.slots.length) { + throw new RangeError(`BUG: cannot get $${index} from scope; length=${this.slots.length}`); } - return lastValue; + return this.slots[index]; } - invalidate() { - this.lastRevision = null; + set(index, value$$1) { + if (index >= this.slots.length) { + throw new RangeError(`BUG: cannot get $${index} from scope; length=${this.slots.length}`); + } + + this.slots[index] = value$$1; } } - _exports.CachedReference = CachedReference; + _exports.ScopeImpl = ScopeImpl; + var TRANSACTION = (0, _util.symbol)('TRANSACTION'); - class MapperReference extends CachedReference { - constructor(reference, mapper) { - super(); - this.tag = reference.tag; - this.reference = reference; - this.mapper = mapper; + class TransactionImpl { + constructor() { + this.scheduledInstallManagers = []; + this.scheduledInstallModifiers = []; + this.scheduledUpdateModifierManagers = []; + this.scheduledUpdateModifiers = []; + this.createdComponents = []; + this.createdManagers = []; + this.updatedComponents = []; + this.updatedManagers = []; + this.destructors = []; } - compute() { - var { - reference, - mapper - } = this; - return mapper(reference.value()); + didCreate(component, manager) { + this.createdComponents.push(component); + this.createdManagers.push(manager); } - } + didUpdate(component, manager) { + this.updatedComponents.push(component); + this.updatedManagers.push(manager); + } - function map(reference, mapper) { - return new MapperReference(reference, mapper); - } ////////// + scheduleInstallModifier(modifier, manager) { + this.scheduledInstallModifiers.push(modifier); + this.scheduledInstallManagers.push(manager); + } + scheduleUpdateModifier(modifier, manager) { + this.scheduledUpdateModifiers.push(modifier); + this.scheduledUpdateModifierManagers.push(manager); + } - class ReferenceCache { - constructor(reference) { - this.lastValue = null; - this.lastRevision = null; - this.initialized = false; - this.tag = reference.tag; - this.reference = reference; + willDestroy(d) { + d[_util.WILL_DROP](); } - peek() { - if (!this.initialized) { - return this.initialize(); + didDestroy(d) { + this.destructors.push(d); + } + + commit() { + var { + createdComponents, + createdManagers + } = this; + + for (var i = 0; i < createdComponents.length; i++) { + var component = createdComponents[i]; + var manager = createdManagers[i]; + manager.didCreate(component); } - return this.lastValue; - } + var { + updatedComponents, + updatedManagers + } = this; + + for (var _i = 0; _i < updatedComponents.length; _i++) { + var _component = updatedComponents[_i]; + var _manager2 = updatedManagers[_i]; - revalidate() { - if (!this.initialized) { - return this.initialize(); + _manager2.didUpdate(_component); } var { - reference, - lastRevision + destructors } = this; - var tag = reference.tag; - if (validate(tag, lastRevision)) return NOT_MODIFIED; - this.lastRevision = value(tag); + + for (var _i2 = 0; _i2 < destructors.length; _i2++) { + destructors[_i2][_util.DID_DROP](); + } + var { - lastValue + scheduledInstallManagers, + scheduledInstallModifiers } = this; - var currentValue = reference.value(); - if (currentValue === lastValue) return NOT_MODIFIED; - this.lastValue = currentValue; - return currentValue; - } - initialize() { + for (var _i3 = 0; _i3 < scheduledInstallManagers.length; _i3++) { + var modifier = scheduledInstallModifiers[_i3]; + var _manager3 = scheduledInstallManagers[_i3]; + + _manager3.install(modifier); + } + var { - reference + scheduledUpdateModifierManagers, + scheduledUpdateModifiers } = this; - var currentValue = this.lastValue = reference.value(); - this.lastRevision = value(reference.tag); - this.initialized = true; - return currentValue; - } - } + for (var _i4 = 0; _i4 < scheduledUpdateModifierManagers.length; _i4++) { + var _modifier = scheduledUpdateModifiers[_i4]; + var _manager4 = scheduledUpdateModifierManagers[_i4]; - _exports.ReferenceCache = ReferenceCache; - var NOT_MODIFIED = 'adb3b78e-3d22-4e4b-877a-6317c2c5c145'; + _manager4.update(_modifier); + } + } - function isModified(value$$1) { - return value$$1 !== NOT_MODIFIED; } - class ConstReference { - constructor(inner) { - this.inner = inner; - this.tag = CONSTANT_TAG; - } + function defaultDelegateFn(delegateFn, delegateDefault) { + var defaultFn = delegateFn !== undefined ? delegateFn : delegateDefault; - value() { - return this.inner; + if (true + /* DEBUG */ + ) { + // Bind to `null` in DEBUG since these methods are assumed to be pure + // functions, so we can reassign them. + return defaultFn.bind(null); } + return defaultFn; } - _exports.ConstReference = ConstReference; - - class ListItem extends _util.ListNode { - constructor(iterable, result) { - super(iterable.valueReferenceFor(result)); - this.retained = false; - this.seen = false; - this.key = result.key; - this.iterable = iterable; - this.memo = iterable.memoReferenceFor(result); + class EnvironmentImpl { + constructor(options, delegate) { + this.delegate = delegate; + this[_a$1] = null; // Delegate methods and values + + this.extra = this.delegate.extra; + this.isInteractive = typeof this.delegate.isInteractive === 'boolean' ? this.delegate.isInteractive : true; + this.protocolForURL = defaultDelegateFn(this.delegate.protocolForURL, defaultGetProtocolForURL); + this.attributeFor = defaultDelegateFn(this.delegate.attributeFor, defaultAttributeFor); + this.getPath = defaultDelegateFn(this.delegate.getPath, defaultGetPath); + this.setPath = defaultDelegateFn(this.delegate.setPath, defaultSetPath); + this.toBool = defaultDelegateFn(this.delegate.toBool, defaultToBool$1); + this.toIterator = defaultDelegateFn(this.delegate.toIterator, defaultToIterator); + + if (options.appendOperations && options.updateOperations) { + this.appendOperations = options.appendOperations; + this.updateOperations = options.updateOperations; + } else if (options.document) { + this.appendOperations = new DOMTreeConstruction(options.document); + this.updateOperations = new DOMChangesImpl(options.document); + } else { + throw new Error('you must pass a document or append and update operations to a new runtime'); + } } - update(item) { - this.retained = true; - this.iterable.updateValueReference(this.value, item); - this.iterable.updateMemoReference(this.memo, item); - } + getTemplatePathDebugContext(ref) { + if (this.delegate.getTemplatePathDebugContext !== undefined) { + return this.delegate.getTemplatePathDebugContext(ref); + } - shouldRemove() { - return !this.retained; + return ''; } - reset() { - this.retained = false; - this.seen = false; + setTemplatePathDebugContext(ref, desc, parentRef) { + if (this.delegate.setTemplatePathDebugContext !== undefined) { + this.delegate.setTemplatePathDebugContext(ref, desc, parentRef); + } } - } - - _exports.ListItem = ListItem; + iterableFor(ref, inputKey) { + // TODO: We should add an assertion here to verify that we are passed a + // TemplatePathReference, but we can only do that once we remove + // or significantly rewrite @glimmer/object-reference + var key = inputKey === null ? '@identity' : String(inputKey); + return new _reference.IterableImpl(ref, key, this); + } - class IterationArtifacts { - constructor(iterable) { - this.iterator = null; - this.map = (0, _util.dict)(); - this.list = new _util.LinkedList(); - this.tag = iterable.tag; - this.iterable = iterable; + toConditionalReference(input) { + return new ConditionalReference(input, this.delegate.toBool); } - isEmpty() { - var iterator = this.iterator = this.iterable.iterate(); - return iterator.isEmpty(); + getAppendOperations() { + return this.appendOperations; } - iterate() { - var iterator; + getDOM() { + return this.updateOperations; + } - if (this.iterator === null) { - iterator = this.iterable.iterate(); - } else { - iterator = this.iterator; + begin() { + if (this.delegate.onTransactionBegin !== undefined) { + this.delegate.onTransactionBegin(); } - this.iterator = null; - return iterator; + this[TRANSACTION] = new TransactionImpl(); } - has(key) { - return !!this.map[key]; + get transaction() { + return this[TRANSACTION]; } - get(key) { - return this.map[key]; + didCreate(component, manager) { + this.transaction.didCreate(component, manager); } - wasSeen(key) { - var node = this.map[key]; - return node !== undefined && node.seen; + didUpdate(component, manager) { + this.transaction.didUpdate(component, manager); } - append(item) { - var { - map, - list, - iterable - } = this; - var node = map[item.key] = new ListItem(iterable, item); - list.append(node); - return node; + scheduleInstallModifier(modifier, manager) { + if (this.isInteractive) { + this.transaction.scheduleInstallModifier(modifier, manager); + } } - insertBefore(item, reference) { - var { - map, - list, - iterable - } = this; - var node = map[item.key] = new ListItem(iterable, item); - node.retained = true; - list.insertBefore(node, reference); - return node; + scheduleUpdateModifier(modifier, manager) { + if (this.isInteractive) { + this.transaction.scheduleUpdateModifier(modifier, manager); + } } - move(item, reference) { - var { - list - } = this; - item.retained = true; - list.remove(item); - list.insertBefore(item, reference); + willDestroy(d) { + this.transaction.willDestroy(d); } - remove(item) { - var { - list - } = this; - list.remove(item); - delete this.map[item.key]; + didDestroy(d) { + this.transaction.didDestroy(d); } - nextNode(item) { - return this.list.nextNode(item); - } + commit() { + var transaction = this.transaction; + this[TRANSACTION] = null; + transaction.commit(); - head() { - return this.list.head(); + if (this.delegate.onTransactionCommit !== undefined) { + this.delegate.onTransactionCommit(); + } } } - _exports.IterationArtifacts = IterationArtifacts; + _exports.EnvironmentImpl = EnvironmentImpl; + _a$1 = TRANSACTION; - class ReferenceIterator { - // if anyone needs to construct this object with something other than - // an iterable, let @wycats know. - constructor(iterable) { - this.iterator = null; - var artifacts = new IterationArtifacts(iterable); - this.artifacts = artifacts; + function defaultGetProtocolForURL(url) { + if (typeof URL === 'object' || typeof URL === 'undefined') { + return legacyProtocolForURL(url); + } else if (typeof document !== 'undefined') { + return new URL(url, document.baseURI).protocol; + } else { + return new URL(url, 'https://www.example.com').protocol; } + } - next() { - var { - artifacts - } = this; - var iterator = this.iterator = this.iterator || artifacts.iterate(); - var item = iterator.next(); - if (item === null) return null; - return artifacts.append(item); - } + function defaultAttributeFor(element, attr, _isTrusting, namespace) { + return dynamicAttribute(element, attr, namespace); + } + function defaultGetPath(obj, key) { + return obj[key]; } - _exports.ReferenceIterator = ReferenceIterator; - var Phase; + function defaultSetPath(obj, key, value$$1) { + return obj[key] = value$$1; + } - (function (Phase) { - Phase[Phase["Append"] = 0] = "Append"; - Phase[Phase["Prune"] = 1] = "Prune"; - Phase[Phase["Done"] = 2] = "Done"; - })(Phase || (Phase = {})); + function defaultToBool$1(value$$1) { + return Boolean(value$$1); + } - class IteratorSynchronizer { - constructor({ - target, - artifacts - }) { - this.target = target; - this.artifacts = artifacts; - this.iterator = artifacts.iterate(); - this.current = artifacts.head(); + function defaultToIterator(value$$1) { + if (value$$1 && value$$1[Symbol.iterator]) { + return value$$1[Symbol.iterator](); } - sync() { - var phase = Phase.Append; + return null; + } - while (true) { - switch (phase) { - case Phase.Append: - phase = this.nextAppend(); - break; + function legacyProtocolForURL(url) { + if (typeof window === 'undefined') { + var match = /^([a-z][a-z0-9.+-]*:)?(\/\/)?([\S\s]*)/i.exec(url); + return match && match[1] ? match[1].toLowerCase() : ''; + } - case Phase.Prune: - phase = this.nextPrune(); - break; + var anchor = window.document.createElement('a'); + anchor.href = url; + return anchor.protocol; + } - case Phase.Done: - this.nextDone(); - return; - } - } + class DefaultRuntimeResolver { + constructor(inner) { + this.inner = inner; } - advanceToKey(key) { - var { - current, - artifacts - } = this; - var seek = current; + lookupComponent(name, referrer) { + if (this.inner.lookupComponent) { + var component = this.inner.lookupComponent(name, referrer); - while (seek !== null && seek.key !== key) { - seek.seen = true; - seek = artifacts.nextNode(seek); - } + if (component === undefined) { + throw new Error(`Unexpected component ${name} (from ${referrer}) (lookupComponent returned undefined)`); + } - if (seek !== null) { - this.current = artifacts.nextNode(seek); + return component; + } else { + throw new Error('lookupComponent not implemented on RuntimeResolver.'); } } - nextAppend() { - var { - iterator, - current, - artifacts - } = this; - var item = iterator.next(); - - if (item === null) { - return this.startPrune(); - } + lookupPartial(name, referrer) { + if (this.inner.lookupPartial) { + var partial = this.inner.lookupPartial(name, referrer); - var { - key - } = item; + if (partial === undefined) { + throw new Error(`Unexpected partial ${name} (from ${referrer}) (lookupPartial returned undefined)`); + } - if (current !== null && current.key === key) { - this.nextRetain(item); - } else if (artifacts.has(key)) { - this.nextMove(item); + return partial; } else { - this.nextInsert(item); + throw new Error('lookupPartial not implemented on RuntimeResolver.'); } - - return Phase.Append; } - nextRetain(item) { - var { - artifacts, - current - } = this; - current = current; - current.update(item); - this.current = artifacts.nextNode(current); - this.target.retain(item.key, current.value, current.memo); - } + resolve(handle) { + if (this.inner.resolve) { + var resolved = this.inner.resolve(handle); - nextMove(item) { - var { - current, - artifacts, - target - } = this; - var { - key - } = item; - var found = artifacts.get(item.key); - found.update(item); + if (resolved === undefined) { + throw new Error(`Unexpected handle ${handle} (resolve returned undefined)`); + } - if (artifacts.wasSeen(item.key)) { - artifacts.move(found, current); - target.move(found.key, found.value, found.memo, current ? current.key : null); + return resolved; } else { - this.advanceToKey(key); + throw new Error('resolve not implemented on RuntimeResolver.'); } } - nextInsert(item) { - var { - artifacts, - target, - current - } = this; - var node = artifacts.insertBefore(item, current); - target.insert(node.key, node.value, node.memo, current ? current.key : null); - } - - startPrune() { - this.current = this.artifacts.head(); - return Phase.Prune; - } + compilable(locator) { + if (this.inner.compilable) { + var resolved = this.inner.compilable(locator); - nextPrune() { - var { - artifacts, - target, - current - } = this; + if (resolved === undefined) { + throw new Error(`Unable to compile ${name} (compilable returned undefined)`); + } - if (current === null) { - return Phase.Done; + return resolved; + } else { + throw new Error('compilable not implemented on RuntimeResolver.'); } + } - var node = current; - this.current = artifacts.nextNode(node); + getInvocation(locator) { + if (this.inner.getInvocation) { + var invocation = this.inner.getInvocation(locator); - if (node.shouldRemove()) { - artifacts.remove(node); - target.delete(node.key); + if (invocation === undefined) { + throw new Error(`Unable to get invocation for ${JSON.stringify(locator)} (getInvocation returned undefined)`); + } + + return invocation; } else { - node.reset(); + throw new Error('getInvocation not implemented on RuntimeResolver.'); } - - return Phase.Prune; } - nextDone() { - this.target.done(); - } + } + + function AotRuntime(options, program, resolver = {}, delegate = {}) { + var env = new EnvironmentImpl(options, delegate); + return { + env, + resolver: new DefaultRuntimeResolver(resolver), + program: _program.RuntimeProgramImpl.hydrate(program) + }; + } // TODO: There are a lot of variants here. Some are here for transitional purposes + // and some might be GCable once the design stabilizes. + + function CustomJitRuntime(resolver, context, env) { + var program = new _program.RuntimeProgramImpl(context.program.constants, context.program.heap); + return { + env, + resolver: new DefaultRuntimeResolver(resolver), + program + }; } - _exports.IteratorSynchronizer = IteratorSynchronizer; -}); -define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@glimmer/vm", "@glimmer/low-level"], function (_exports, _util, _reference2, _vm2, _lowLevel) { - "use strict"; + function JitRuntime(options, resolver = {}, delegate = {}) { + var env = new EnvironmentImpl(options, delegate); + var constants = new _program.JitConstants(); + var heap = new _program.HeapImpl(); + var program = new _program.RuntimeProgramImpl(constants, heap); + return { + env, + resolver: new DefaultRuntimeResolver(resolver), + program + }; + } - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.renderMain = renderMain; - _exports.renderComponent = renderComponent; - _exports.setDebuggerCallback = setDebuggerCallback; - _exports.resetDebuggerCallback = resetDebuggerCallback; - _exports.getDynamicVar = getDynamicVar; - _exports.isCurriedComponentDefinition = isCurriedComponentDefinition; - _exports.curry = curry; - _exports.isWhitespace = isWhitespace; - _exports.normalizeProperty = normalizeProperty; - _exports.clientBuilder = clientBuilder; - _exports.rehydrationBuilder = rehydrationBuilder; - _exports.isSerializationFirstNode = isSerializationFirstNode; - _exports.capabilityFlagsFrom = capabilityFlagsFrom; - _exports.hasCapability = hasCapability; - _exports.Cursor = _exports.ConcreteBounds = _exports.SERIALIZATION_FIRST_NODE_STRING = _exports.RehydrateBuilder = _exports.NewElementBuilder = _exports.DOMTreeConstruction = _exports.IDOMChanges = _exports.SVG_NAMESPACE = _exports.DOMChanges = _exports.CurriedComponentDefinition = _exports.MINIMAL_CAPABILITIES = _exports.DEFAULT_CAPABILITIES = _exports.DefaultEnvironment = _exports.Environment = _exports.Scope = _exports.EMPTY_ARGS = _exports.DynamicAttribute = _exports.SimpleDynamicAttribute = _exports.RenderResult = _exports.UpdatingVM = _exports.LowLevelVM = _exports.ConditionalReference = _exports.PrimitiveReference = _exports.UNDEFINED_REFERENCE = _exports.NULL_REFERENCE = void 0; + function JitRuntimeFromProgram(options, program, resolver = {}, delegate = {}) { + var env = new EnvironmentImpl(options, delegate); + return { + env, + resolver: new DefaultRuntimeResolver(resolver), + program + }; + } + + function inTransaction(env, cb) { + if (!env[TRANSACTION]) { + env.begin(); + + try { + cb(); + } finally { + env.commit(); + } + } else { + cb(); + } + } - // these import bindings will be stripped from build class AppendOpcodes { constructor() { - this.evaluateOpcode = (0, _util.fillNulls)(98 + this.evaluateOpcode = (0, _util.fillNulls)(107 /* Size */ ).slice(); } add(name, evaluate, kind = 'syscall') { this.evaluateOpcode[name] = { - syscall: kind === 'syscall', + syscall: kind !== 'machine', evaluate }; } - debugBefore(vm, opcode, type) { + debugBefore(vm, opcode) { + var params = undefined; + var opName = undefined; var sp; - var state; return { sp: sp, - state + pc: vm.fetchValue(_vm2.$pc), + name: opName, + params, + type: opcode.type, + isMachine: opcode.isMachine, + size: opcode.size, + state: undefined }; } - debugAfter(vm, opcode, type, pre) { - var expectedChange; - var { - sp, - state - } = pre; - var metadata = null; - - if (metadata !== null) { - if (typeof metadata.stackChange === 'number') { - expectedChange = metadata.stackChange; - } else { - expectedChange = metadata.stackChange({ - opcode, - constants: vm.constants, - state - }); - if (isNaN(expectedChange)) throw (0, _util.unreachable)(); - } - } - } + debugAfter(vm, pre) {} evaluate(vm, opcode, type) { var operation = this.evaluateOpcode[type]; @@ -48722,7 +50677,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ if (operation.syscall) { operation.evaluate(vm, opcode); } else { - operation.evaluate(vm.inner, opcode); + operation.evaluate(vm[INNER_VM], opcode); } } @@ -48745,97 +50700,45 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } } + /** + * These utility functions are related to @glimmer/validator, but they aren't + * meant to be consumed publicly. They exist as an optimization, and pull in + * types that are otherwise unrelated to the validation system. Keeping them + * here keeps the validation system isolated, and allows it to avoid pulling in + * extra type information (which can lead to issues in public types). + */ - class PrimitiveReference extends _reference2.ConstReference { - constructor(value$$1) { - super(value$$1); - } - - static create(value$$1) { - if (value$$1 === undefined) { - return UNDEFINED_REFERENCE; - } else if (value$$1 === null) { - return NULL_REFERENCE; - } else if (value$$1 === true) { - return TRUE_REFERENCE; - } else if (value$$1 === false) { - return FALSE_REFERENCE; - } else if (typeof value$$1 === 'number') { - return new ValueReference(value$$1); - } else { - return new StringReference(value$$1); - } - } - - get(_key) { - return UNDEFINED_REFERENCE; - } - - } - - _exports.PrimitiveReference = PrimitiveReference; - - class StringReference extends PrimitiveReference { - constructor() { - super(...arguments); - this.lengthReference = null; - } - - get(key) { - if (key === 'length') { - var { - lengthReference - } = this; - - if (lengthReference === null) { - lengthReference = this.lengthReference = new ValueReference(this.inner.length); - } - - return lengthReference; - } else { - return super.get(key); - } - } - } + function combineTagged(tagged) { + var optimized = []; - class ValueReference extends PrimitiveReference { - constructor(value$$1) { - super(value$$1); + for (var i = 0, l = tagged.length; i < l; i++) { + var tag = tagged[i].tag; + if (tag === _validator.CONSTANT_TAG) continue; + optimized.push(tag); } + return (0, _validator.createCombinatorTag)(optimized); } - var UNDEFINED_REFERENCE = new ValueReference(undefined); - _exports.UNDEFINED_REFERENCE = UNDEFINED_REFERENCE; - var NULL_REFERENCE = new ValueReference(null); - _exports.NULL_REFERENCE = NULL_REFERENCE; - var TRUE_REFERENCE = new ValueReference(true); - var FALSE_REFERENCE = new ValueReference(false); - - class ConditionalReference { - constructor(inner) { - this.inner = inner; - this.tag = inner.tag; - } - - value() { - return this.toBool(this.inner.value()); - } + function combineSlice(slice) { + var optimized = []; + var node = slice.head(); - toBool(value$$1) { - return !!value$$1; + while (node !== null) { + var tag = node.tag; + if (tag !== _validator.CONSTANT_TAG) optimized.push(tag); + node = slice.nextNode(node); } + return (0, _validator.createCombinatorTag)(optimized); } - _exports.ConditionalReference = ConditionalReference; - - class ConcatReference extends _reference2.CachedReference { + class ConcatReference extends _reference.CachedReference { constructor(parts) { super(); this.parts = parts; - this.tag = (0, _reference2.combineTagged)(parts); + this.tag = combineTagged(parts); } compute() { @@ -48866,51 +50769,61 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ return String(value$$1); } - APPEND_OPCODES.add(1 + APPEND_OPCODES.add(16 /* Helper */ , (vm, { op1: handle }) => { var stack = vm.stack; - var helper = vm.constants.resolveHandle(handle); + var helper = vm.runtime.resolver.resolve(handle); var args = stack.pop(); - var value$$1 = helper(vm, args); - vm.loadValue(_vm2.Register.v0, value$$1); + var value$$1 = helper(args, vm); + vm.loadValue(_vm2.$v0, value$$1); }); - APPEND_OPCODES.add(6 + APPEND_OPCODES.add(22 /* GetVariable */ , (vm, { - op1: symbol + op1: symbol$$1 }) => { - var expr = vm.referenceForSymbol(symbol); + var expr = vm.referenceForSymbol(symbol$$1); vm.stack.push(expr); }); - APPEND_OPCODES.add(4 + APPEND_OPCODES.add(19 /* SetVariable */ , (vm, { - op1: symbol + op1: symbol$$1 }) => { var expr = vm.stack.pop(); - vm.scope().bindSymbol(symbol, expr); + vm.scope().bindSymbol(symbol$$1, expr); }); - APPEND_OPCODES.add(5 - /* SetBlock */ + APPEND_OPCODES.add(21 + /* SetJitBlock */ , (vm, { - op1: symbol + op1: symbol$$1 }) => { var handle = vm.stack.pop(); - var scope = vm.stack.pop(); // FIXME(mmun): shouldn't need to cast this - + var scope = vm.stack.pop(); + var table = vm.stack.pop(); + var block = table ? [handle, scope, table] : null; + vm.scope().bindBlock(symbol$$1, block); + }, 'jit'); + APPEND_OPCODES.add(20 + /* SetAotBlock */ + , (vm, { + op1: symbol$$1 + }) => { + var handle = vm.stack.pop(); + var scope = vm.stack.pop(); var table = vm.stack.pop(); var block = table ? [handle, scope, table] : null; - vm.scope().bindBlock(symbol, block); + vm.scope().bindBlock(symbol$$1, block); }); - APPEND_OPCODES.add(96 + APPEND_OPCODES.add(105 /* ResolveMaybeLocal */ , (vm, { op1: _name }) => { - var name = vm.constants.getString(_name); + var name = vm[CONSTANTS].getString(_name); var locals = vm.scope().getPartialMap(); var ref = locals[name]; @@ -48920,24 +50833,23 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.stack.push(ref); }); - APPEND_OPCODES.add(20 + APPEND_OPCODES.add(37 /* RootScope */ , (vm, { - op1: symbols, - op2: bindCallerScope + op1: symbols }) => { - vm.pushRootScope(symbols, !!bindCallerScope); + vm.pushRootScope(symbols); }); - APPEND_OPCODES.add(7 + APPEND_OPCODES.add(23 /* GetProperty */ , (vm, { op1: _key }) => { - var key = vm.constants.getString(_key); + var key = vm[CONSTANTS].getString(_key); var expr = vm.stack.pop(); vm.stack.push(expr.get(key)); }); - APPEND_OPCODES.add(8 + APPEND_OPCODES.add(24 /* GetBlock */ , (vm, { op1: _block @@ -48946,6 +50858,15 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ stack } = vm; var block = vm.scope().getBlock(_block); + stack.push(block); + }); + APPEND_OPCODES.add(25 + /* JitSpreadBlock */ + , vm => { + var { + stack + } = vm; + var block = stack.pop(); if (block) { stack.push(block[2]); @@ -48957,15 +50878,21 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ stack.push(null); } }); - APPEND_OPCODES.add(9 + APPEND_OPCODES.add(26 /* HasBlock */ - , (vm, { - op1: _block - }) => { - var hasBlock = !!vm.scope().getBlock(_block); - vm.stack.push(hasBlock ? TRUE_REFERENCE : FALSE_REFERENCE); + , vm => { + var block = vm.stack.pop(); // TODO: We check if the block is null or UNDEFINED_REFERENCE here, but it should + // really only check if the block is null. The UNDEFINED_REFERENCE use case is for + // when we try to invoke a curry-component directly as a variable: + // + // {{bar}} + // + // This code path does not work the same way as most components. In the future, + // we should make sure that it does, so things are setup correctly. + + vm.stack.push(block === null || block === UNDEFINED_REFERENCE ? FALSE_REFERENCE : TRUE_REFERENCE); }); - APPEND_OPCODES.add(10 + APPEND_OPCODES.add(27 /* HasBlockParams */ , vm => { // FIXME(mmun): should only need to push the symbol table @@ -48975,7 +50902,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var hasBlockParams = table && table.parameters.length; vm.stack.push(hasBlockParams ? TRUE_REFERENCE : FALSE_REFERENCE); }); - APPEND_OPCODES.add(11 + APPEND_OPCODES.add(28 /* Concat */ , (vm, { op1: count @@ -48989,14 +50916,56 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.stack.push(new ConcatReference(out)); }); - var CURRIED_COMPONENT_DEFINITION_BRAND = 'CURRIED COMPONENT DEFINITION [id=6f00feb9-a0ef-4547-99ea-ac328f80acea]'; + /** + * Converts a ComponentCapabilities object into a 32-bit integer representation. + */ + + function capabilityFlagsFrom(capabilities) { + return 0 | (capabilities.dynamicLayout ? 1 + /* DynamicLayout */ + : 0) | (capabilities.dynamicTag ? 2 + /* DynamicTag */ + : 0) | (capabilities.prepareArgs ? 4 + /* PrepareArgs */ + : 0) | (capabilities.createArgs ? 8 + /* CreateArgs */ + : 0) | (capabilities.attributeHook ? 16 + /* AttributeHook */ + : 0) | (capabilities.elementHook ? 32 + /* ElementHook */ + : 0) | (capabilities.dynamicScope ? 64 + /* DynamicScope */ + : 0) | (capabilities.createCaller ? 128 + /* CreateCaller */ + : 0) | (capabilities.updateHook ? 256 + /* UpdateHook */ + : 0) | (capabilities.createInstance ? 512 + /* CreateInstance */ + : 0) | (capabilities.wrapped ? 1024 + /* Wrapped */ + : 0) | (capabilities.willDestroy ? 2048 + /* WillDestroy */ + : 0); + } + + function managerHasCapability(_manager, capabilities, capability) { + return !!(capabilities & capability); + } + + function hasCapability(capabilities, capability) { + return !!(capabilities & capability); + } + + var _a$2; + + var CURRIED_COMPONENT_DEFINITION_BRAND = (0, _util.symbol)('CURRIED COMPONENT DEFINITION'); function isCurriedComponentDefinition(definition) { return !!(definition && definition[CURRIED_COMPONENT_DEFINITION_BRAND]); } function isComponentDefinition(definition) { - return definition && definition[CURRIED_COMPONENT_DEFINITION_BRAND]; + return !!(definition && definition[CURRIED_COMPONENT_DEFINITION_BRAND]); } class CurriedComponentDefinition { @@ -49004,7 +50973,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ constructor(inner, args) { this.inner = inner; this.args = args; - this[CURRIED_COMPONENT_DEFINITION_BRAND] = true; + this[_a$2] = true; } unwrap(args) { @@ -49044,41 +51013,98 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } _exports.CurriedComponentDefinition = CurriedComponentDefinition; + _a$2 = CURRIED_COMPONENT_DEFINITION_BRAND; function curry(spec, args = null) { return new CurriedComponentDefinition(spec, args); } - function normalizeStringValue(value$$1) { - if (isEmpty(value$$1)) { - return ''; + function resolveComponent(resolver, name, meta) { + var definition = resolver.lookupComponent(name, meta); + return definition; + } + + class ClassListReference { + constructor(list) { + this.list = list; + this.tag = combineTagged(list); + this.list = list; } - return String(value$$1); - } + value() { + var ret = []; + var { + list + } = this; - function shouldCoerce(value$$1) { - return isString(value$$1) || isEmpty(value$$1) || typeof value$$1 === 'boolean' || typeof value$$1 === 'number'; - } + for (var i = 0; i < list.length; i++) { + var value$$1 = normalizeStringValue(list[i].value()); + if (value$$1) ret.push(value$$1); + } - function isEmpty(value$$1) { - return value$$1 === null || value$$1 === undefined || typeof value$$1.toString !== 'function'; - } + return ret.length === 0 ? null : ret.join(' '); + } - function isSafeString(value$$1) { - return typeof value$$1 === 'object' && value$$1 !== null && typeof value$$1.toHTML === 'function'; } - function isNode(value$$1) { - return typeof value$$1 === 'object' && value$$1 !== null && typeof value$$1.nodeType === 'number'; - } + class CurryComponentReference { + constructor(inner, resolver, meta, args) { + this.inner = inner; + this.resolver = resolver; + this.meta = meta; + this.args = args; + this.tag = inner.tag; + this.lastValue = null; + this.lastDefinition = null; + } - function isFragment(value$$1) { - return isNode(value$$1) && value$$1.nodeType === 11; - } + value() { + var { + inner, + lastValue + } = this; + var value$$1 = inner.value(); + + if (value$$1 === lastValue) { + return this.lastDefinition; + } + + var definition = null; + + if (isCurriedComponentDefinition(value$$1)) { + definition = value$$1; + } else if (typeof value$$1 === 'string' && value$$1) { + var { + resolver, + meta + } = this; + definition = resolveComponent(resolver, value$$1, meta); + } + + definition = this.curry(definition); + this.lastValue = value$$1; + this.lastDefinition = definition; + return definition; + } + + get() { + return UNDEFINED_REFERENCE; + } + + curry(definition) { + var { + args + } = this; + + if (!args && isCurriedComponentDefinition(definition)) { + return definition; + } else if (!definition) { + return null; + } else { + return new CurriedComponentDefinition(definition, args); + } + } - function isString(value$$1) { - return typeof value$$1 === 'string'; } class DynamicTextContent extends UpdatingOpcode { @@ -49089,7 +51115,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ this.lastValue = lastValue; this.type = 'dynamic-text'; this.tag = reference.tag; - this.lastRevision = (0, _reference2.value)(this.tag); + this.lastRevision = (0, _validator.value)(this.tag); } evaluate() { @@ -49098,8 +51124,8 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ tag } = this; - if (!(0, _reference2.validate)(tag, this.lastRevision)) { - this.lastRevision = (0, _reference2.value)(tag); + if (!(0, _validator.validate)(tag, this.lastRevision)) { + this.lastRevision = (0, _validator.value)(tag); this.update(reference.value()); } } @@ -49127,17 +51153,6 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } - class IsCurriedComponentDefinitionReference extends ConditionalReference { - static create(inner) { - return new IsCurriedComponentDefinitionReference(inner); - } - - toBool(value$$1) { - return isCurriedComponentDefinition(value$$1); - } - - } - class ContentTypeReference { constructor(inner) { this.inner = inner; @@ -49176,7 +51191,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } - APPEND_OPCODES.add(28 + APPEND_OPCODES.add(43 /* AppendHTML */ , vm => { var reference = vm.stack.pop(); @@ -49184,7 +51199,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var value$$1 = isEmpty(rawValue) ? '' : String(rawValue); vm.elements().appendDynamicHTML(value$$1); }); - APPEND_OPCODES.add(29 + APPEND_OPCODES.add(44 /* AppendSafeHTML */ , vm => { var reference = vm.stack.pop(); @@ -49192,7 +51207,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var value$$1 = isEmpty(rawValue) ? '' : rawValue; vm.elements().appendDynamicHTML(value$$1); }); - APPEND_OPCODES.add(32 + APPEND_OPCODES.add(47 /* AppendText */ , vm => { var reference = vm.stack.pop(); @@ -49200,104 +51215,84 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var value$$1 = isEmpty(rawValue) ? '' : String(rawValue); var node = vm.elements().appendDynamicText(value$$1); - if (!(0, _reference2.isConst)(reference)) { + if (!(0, _validator.isConst)(reference)) { vm.updateWith(new DynamicTextContent(node, reference, value$$1)); } }); - APPEND_OPCODES.add(30 + APPEND_OPCODES.add(45 /* AppendDocumentFragment */ , vm => { var reference = vm.stack.pop(); var value$$1 = reference.value(); vm.elements().appendDynamicFragment(value$$1); }); - APPEND_OPCODES.add(31 + APPEND_OPCODES.add(46 /* AppendNode */ , vm => { var reference = vm.stack.pop(); var value$$1 = reference.value(); vm.elements().appendDynamicNode(value$$1); }); - APPEND_OPCODES.add(22 + APPEND_OPCODES.add(39 /* ChildScope */ , vm => vm.pushChildScope()); - APPEND_OPCODES.add(23 + APPEND_OPCODES.add(40 /* PopScope */ , vm => vm.popScope()); - APPEND_OPCODES.add(44 + APPEND_OPCODES.add(59 /* PushDynamicScope */ , vm => vm.pushDynamicScope()); - APPEND_OPCODES.add(45 + APPEND_OPCODES.add(60 /* PopDynamicScope */ , vm => vm.popDynamicScope()); - APPEND_OPCODES.add(12 + APPEND_OPCODES.add(29 /* Constant */ , (vm, { op1: other }) => { - vm.stack.push(vm.constants.getOther(other)); + vm.stack.push(vm[CONSTANTS].getOther(other)); }); - APPEND_OPCODES.add(13 + APPEND_OPCODES.add(30 /* Primitive */ , (vm, { op1: primitive }) => { var stack = vm.stack; - var flag = primitive & 7; // 111 - - var value$$1 = primitive >> 3; - switch (flag) { - case 0 - /* NUMBER */ - : - stack.push(value$$1); - break; - - case 1 - /* FLOAT */ - : - stack.push(vm.constants.getNumber(value$$1)); - break; - - case 2 - /* STRING */ - : - stack.push(vm.constants.getString(value$$1)); - break; - - case 3 - /* BOOLEAN_OR_VOID */ - : - stack.pushEncodedImmediate(primitive); - break; + if ((0, _util.isHandle)(primitive)) { + var value$$1; - case 4 - /* NEGATIVE */ - : - stack.push(vm.constants.getNumber(value$$1)); - break; + if (primitive > -1073741825 + /* NUMBER_MAX_HANDLE */ + ) { + value$$1 = vm[CONSTANTS].getString((0, _util.decodeHandle)(primitive, -1 + /* STRING_MAX_HANDLE */ + )); + } else { + value$$1 = vm[CONSTANTS].getNumber((0, _util.decodeHandle)(primitive, -1073741825 + /* NUMBER_MAX_HANDLE */ + )); + } - case 5 - /* BIG_NUM */ - : - stack.push(vm.constants.getNumber(value$$1)); - break; + stack.pushJs(value$$1); + } else { + // is already an encoded immediate + stack.pushRaw(primitive); } }); - APPEND_OPCODES.add(14 + APPEND_OPCODES.add(31 /* PrimitiveReference */ , vm => { var stack = vm.stack; - stack.push(PrimitiveReference.create(stack.pop())); + stack.push(PrimitiveReference$1.create(stack.pop())); }); - APPEND_OPCODES.add(15 + APPEND_OPCODES.add(32 /* ReifyU32 */ , vm => { var stack = vm.stack; stack.push(stack.peek().value()); }); - APPEND_OPCODES.add(16 + APPEND_OPCODES.add(33 /* Dup */ , (vm, { op1: register, @@ -49306,82 +51301,81 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var position = vm.fetchValue(register) - offset; vm.stack.dup(position); }); - APPEND_OPCODES.add(17 + APPEND_OPCODES.add(34 /* Pop */ , (vm, { op1: count }) => { vm.stack.pop(count); }); - APPEND_OPCODES.add(18 + APPEND_OPCODES.add(35 /* Load */ , (vm, { op1: register }) => { vm.load(register); }); - APPEND_OPCODES.add(19 + APPEND_OPCODES.add(36 /* Fetch */ , (vm, { op1: register }) => { vm.fetch(register); }); - APPEND_OPCODES.add(43 + APPEND_OPCODES.add(58 /* BindDynamicScope */ , (vm, { op1: _names }) => { - var names = vm.constants.getArray(_names); + var names = vm[CONSTANTS].getArray(_names); vm.bindDynamicScope(names); }); - APPEND_OPCODES.add(61 + APPEND_OPCODES.add(69 /* Enter */ , (vm, { op1: args }) => { vm.enter(args); }); - APPEND_OPCODES.add(62 + APPEND_OPCODES.add(70 /* Exit */ , vm => { vm.exit(); }); - APPEND_OPCODES.add(48 + APPEND_OPCODES.add(63 /* PushSymbolTable */ , (vm, { op1: _table }) => { var stack = vm.stack; - stack.push(vm.constants.getSerializable(_table)); + stack.push(vm[CONSTANTS].getSerializable(_table)); }); - APPEND_OPCODES.add(47 + APPEND_OPCODES.add(62 /* PushBlockScope */ , vm => { var stack = vm.stack; stack.push(vm.scope()); }); - APPEND_OPCODES.add(46 + APPEND_OPCODES.add(61 /* CompileBlock */ , vm => { var stack = vm.stack; var block = stack.pop(); if (block) { - stack.push(block.compile()); + stack.push(vm.compile(block)); } else { - stack.pushNull(); + stack.push(null); } - }); - APPEND_OPCODES.add(51 + }, 'jit'); + APPEND_OPCODES.add(64 /* InvokeYield */ , vm => { var { stack } = vm; var handle = stack.pop(); - var scope = stack.pop(); // FIXME(mmun): shouldn't need to cast this - + var scope = stack.pop(); var table = stack.pop(); var args = stack.pop(); @@ -49411,19 +51405,19 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.pushScope(invokingScope); vm.call(handle); }); - APPEND_OPCODES.add(53 + APPEND_OPCODES.add(65 /* JumpIf */ , (vm, { op1: target }) => { var reference = vm.stack.pop(); - if ((0, _reference2.isConst)(reference)) { + if ((0, _validator.isConst)(reference)) { if (reference.value()) { vm.goto(target); } } else { - var cache = new _reference2.ReferenceCache(reference); + var cache = new _reference.ReferenceCache(reference); if (cache.peek()) { vm.goto(target); @@ -49432,19 +51426,19 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.updateWith(new Assert(cache)); } }); - APPEND_OPCODES.add(54 + APPEND_OPCODES.add(66 /* JumpUnless */ , (vm, { op1: target }) => { var reference = vm.stack.pop(); - if ((0, _reference2.isConst)(reference)) { + if ((0, _validator.isConst)(reference)) { if (!reference.value()) { vm.goto(target); } } else { - var cache = new _reference2.ReferenceCache(reference); + var cache = new _reference.ReferenceCache(reference); if (!cache.peek()) { vm.goto(target); @@ -49453,7 +51447,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.updateWith(new Assert(cache)); } }); - APPEND_OPCODES.add(55 + APPEND_OPCODES.add(67 /* JumpEq */ , (vm, { op1: target, @@ -49465,16 +51459,16 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.goto(target); } }); - APPEND_OPCODES.add(56 + APPEND_OPCODES.add(68 /* AssertSame */ , vm => { var reference = vm.stack.peek(); - if (!(0, _reference2.isConst)(reference)) { - vm.updateWith(Assert.initialize(new _reference2.ReferenceCache(reference))); + if (!(0, _validator.isConst)(reference)) { + vm.updateWith(Assert.initialize(new _reference.ReferenceCache(reference))); } }); - APPEND_OPCODES.add(63 + APPEND_OPCODES.add(71 /* ToBoolean */ , vm => { var { @@ -49503,7 +51497,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ cache } = this; - if ((0, _reference2.isModified)(cache.revalidate())) { + if ((0, _reference.isModified)(cache.revalidate())) { vm.throw(); } } @@ -49516,7 +51510,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ this.target = target; this.type = 'jump-if-not-modified'; this.tag = tag; - this.lastRevision = (0, _reference2.value)(tag); + this.lastRevision = (0, _validator.value)(tag); } evaluate(vm) { @@ -49526,13 +51520,13 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ lastRevision } = this; - if (!vm.alwaysRevalidate && (0, _reference2.validate)(tag, lastRevision)) { + if (!vm.alwaysRevalidate && (0, _validator.validate)(tag, lastRevision)) { vm.goto(target); } } didModify() { - this.lastRevision = (0, _reference2.value)(this.tag); + this.lastRevision = (0, _validator.value)(this.tag); } } @@ -49542,7 +51536,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ super(); this.target = target; this.type = 'did-modify'; - this.tag = _reference2.CONSTANT_TAG; + this.tag = _validator.CONSTANT_TAG; } evaluate() { @@ -49553,7 +51547,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ class LabelOpcode { constructor(label) { - this.tag = _reference2.CONSTANT_TAG; + this.tag = _validator.CONSTANT_TAG; this.type = 'label'; this.label = null; this.prev = null; @@ -49565,86 +51559,89 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ evaluate() {} inspect() { - return this.label + " [" + this._guid + "]"; + return `${this.label} [${this._guid}]`; } } - APPEND_OPCODES.add(26 + APPEND_OPCODES.add(41 /* Text */ , (vm, { op1: text }) => { - vm.elements().appendText(vm.constants.getString(text)); + vm.elements().appendText(vm[CONSTANTS].getString(text)); }); - APPEND_OPCODES.add(27 + APPEND_OPCODES.add(42 /* Comment */ , (vm, { op1: text }) => { - vm.elements().appendComment(vm.constants.getString(text)); + vm.elements().appendComment(vm[CONSTANTS].getString(text)); }); - APPEND_OPCODES.add(33 + APPEND_OPCODES.add(48 /* OpenElement */ , (vm, { op1: tag }) => { - vm.elements().openElement(vm.constants.getString(tag)); + vm.elements().openElement(vm[CONSTANTS].getString(tag)); }); - APPEND_OPCODES.add(34 + APPEND_OPCODES.add(49 /* OpenDynamicElement */ , vm => { var tagName = vm.stack.pop().value(); vm.elements().openElement(tagName); }); - APPEND_OPCODES.add(41 + APPEND_OPCODES.add(50 /* PushRemoteElement */ , vm => { var elementRef = vm.stack.pop(); - var nextSiblingRef = vm.stack.pop(); + var insertBeforeRef = vm.stack.pop(); var guidRef = vm.stack.pop(); var element; - var nextSibling; + var insertBefore; var guid = guidRef.value(); - if ((0, _reference2.isConst)(elementRef)) { + if ((0, _validator.isConst)(elementRef)) { element = elementRef.value(); } else { - var cache = new _reference2.ReferenceCache(elementRef); + var cache = new _reference.ReferenceCache(elementRef); element = cache.peek(); vm.updateWith(new Assert(cache)); } - if ((0, _reference2.isConst)(nextSiblingRef)) { - nextSibling = nextSiblingRef.value(); - } else { - var _cache = new _reference2.ReferenceCache(nextSiblingRef); + if (insertBeforeRef.value() !== undefined) { + if ((0, _validator.isConst)(insertBeforeRef)) { + insertBefore = insertBeforeRef.value(); + } else { + var _cache = new _reference.ReferenceCache(insertBeforeRef); - nextSibling = _cache.peek(); - vm.updateWith(new Assert(_cache)); + insertBefore = _cache.peek(); + vm.updateWith(new Assert(_cache)); + } } - vm.elements().pushRemoteElement(element, guid, nextSibling); + var block = vm.elements().pushRemoteElement(element, guid, insertBefore); + if (block) vm.associateDestroyable(block); }); - APPEND_OPCODES.add(42 + APPEND_OPCODES.add(56 /* PopRemoteElement */ , vm => { vm.elements().popRemoteElement(); }); - APPEND_OPCODES.add(38 + APPEND_OPCODES.add(54 /* FlushElement */ , vm => { - var operations = vm.fetchValue(_vm2.Register.t0); + var operations = vm.fetchValue(_vm2.$t0); var modifiers = null; if (operations) { modifiers = operations.flush(vm); - vm.loadValue(_vm2.Register.t0, null); + vm.loadValue(_vm2.$t0, null); } vm.elements().flushElement(modifiers); }); - APPEND_OPCODES.add(39 + APPEND_OPCODES.add(55 /* CloseElement */ , vm => { var modifiers = vm.elements().closeElement(); @@ -49652,15 +51649,15 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ if (modifiers) { modifiers.forEach(([manager, modifier]) => { vm.env.scheduleInstallModifier(modifier, manager); - var destructor = manager.getDestructor(modifier); + var d = manager.getDestructor(modifier); - if (destructor) { - vm.newDestroyable(destructor); + if (d) { + vm.associateDestroyable(d); } }); } }); - APPEND_OPCODES.add(40 + APPEND_OPCODES.add(57 /* Modifier */ , (vm, { op1: handle @@ -49668,7 +51665,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var { manager, state - } = vm.constants.resolveHandle(handle); + } = vm.runtime.resolver.resolve(handle); var stack = vm.stack; var args = stack.pop(); var { @@ -49677,11 +51674,11 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } = vm.elements(); var dynamicScope = vm.dynamicScope(); var modifier = manager.create(constructing, state, args, dynamicScope, updateOperations); - var operations = vm.fetchValue(_vm2.Register.t0); + var operations = vm.fetchValue(_vm2.$t0); operations.addModifier(manager, modifier); var tag = manager.getTag(modifier); - if (!(0, _reference2.isConstTag)(tag)) { + if (!(0, _validator.isConstTag)(tag)) { vm.updateWith(new UpdateModifierOpcode(tag, manager, modifier)); } }); @@ -49693,7 +51690,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ this.manager = manager; this.modifier = modifier; this.type = 'update-modifier'; - this.lastUpdated = (0, _reference2.value)(tag); + this.lastUpdated = (0, _validator.value)(tag); } evaluate(vm) { @@ -49704,40 +51701,40 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ lastUpdated } = this; - if (!(0, _reference2.validate)(tag, lastUpdated)) { + if (!(0, _validator.validate)(tag, lastUpdated)) { vm.env.scheduleUpdateModifier(modifier, manager); - this.lastUpdated = (0, _reference2.value)(tag); + this.lastUpdated = (0, _validator.value)(tag); } } } - APPEND_OPCODES.add(35 + APPEND_OPCODES.add(51 /* StaticAttr */ , (vm, { op1: _name, op2: _value, op3: _namespace }) => { - var name = vm.constants.getString(_name); - var value$$1 = vm.constants.getString(_value); - var namespace = _namespace ? vm.constants.getString(_namespace) : null; + var name = vm[CONSTANTS].getString(_name); + var value$$1 = vm[CONSTANTS].getString(_value); + var namespace = _namespace ? vm[CONSTANTS].getString(_namespace) : null; vm.elements().setStaticAttribute(name, value$$1, namespace); }); - APPEND_OPCODES.add(36 + APPEND_OPCODES.add(52 /* DynamicAttr */ , (vm, { op1: _name, op2: trusting, op3: _namespace }) => { - var name = vm.constants.getString(_name); + var name = vm[CONSTANTS].getString(_name); var reference = vm.stack.pop(); var value$$1 = reference.value(); - var namespace = _namespace ? vm.constants.getString(_namespace) : null; + var namespace = _namespace ? vm[CONSTANTS].getString(_namespace) : null; var attribute = vm.elements().setDynamicAttribute(name, value$$1, !!trusting, namespace); - if (!(0, _reference2.isConst)(reference)) { + if (!(0, _validator.isConst)(reference)) { vm.updateWith(new UpdateDynamicAttributeOpcode(reference, attribute)); } }); @@ -49752,7 +51749,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ tag } = reference; this.tag = tag; - this.lastRevision = (0, _reference2.value)(tag); + this.lastRevision = (0, _validator.value)(tag); } evaluate(vm) { @@ -49762,149 +51759,40 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ tag } = this; - if (!(0, _reference2.validate)(tag, this.lastRevision)) { - this.lastRevision = (0, _reference2.value)(tag); + if (!(0, _validator.validate)(tag, this.lastRevision)) { attribute.update(reference.value(), vm.env); + this.lastRevision = (0, _validator.value)(tag); } } - } - - function resolveComponent(resolver, name, meta) { - var definition = resolver.lookupComponentDefinition(name, meta); - return definition; - } - - class CurryComponentReference { - constructor(inner, resolver, meta, args) { - this.inner = inner; - this.resolver = resolver; - this.meta = meta; - this.args = args; - this.tag = inner.tag; - this.lastValue = null; - this.lastDefinition = null; - } - - value() { - var { - inner, - lastValue - } = this; - var value$$1 = inner.value(); - - if (value$$1 === lastValue) { - return this.lastDefinition; - } - - var definition = null; - - if (isCurriedComponentDefinition(value$$1)) { - definition = value$$1; - } else if (typeof value$$1 === 'string' && value$$1) { - var { - resolver, - meta - } = this; - definition = resolveComponent(resolver, value$$1, meta); - } - - definition = this.curry(definition); - this.lastValue = value$$1; - this.lastDefinition = definition; - return definition; - } - - get() { - return UNDEFINED_REFERENCE; - } - - curry(definition) { - var { - args - } = this; - - if (!args && isCurriedComponentDefinition(definition)) { - return definition; - } else if (!definition) { - return null; - } else { - return new CurriedComponentDefinition(definition, args); - } - } - - } - - class ClassListReference { - constructor(list) { - this.list = list; - this.tag = (0, _reference2.combineTagged)(list); - this.list = list; - } - - value() { - var ret = []; - var { - list - } = this; - - for (var i = 0; i < list.length; i++) { - var value$$1 = normalizeStringValue(list[i].value()); - if (value$$1) ret.push(value$$1); - } - - return ret.length === 0 ? null : ret.join(' '); - } - } /** - * Converts a ComponentCapabilities object into a 32-bit integer representation. + * The VM creates a new ComponentInstance data structure for every component + * invocation it encounters. + * + * Similar to how a ComponentDefinition contains state about all components of a + * particular type, a ComponentInstance contains state specific to a particular + * instance of a component type. It also contains a pointer back to its + * component type's ComponentDefinition. */ - function capabilityFlagsFrom(capabilities) { - return 0 | (capabilities.dynamicLayout ? 1 - /* DynamicLayout */ - : 0) | (capabilities.dynamicTag ? 2 - /* DynamicTag */ - : 0) | (capabilities.prepareArgs ? 4 - /* PrepareArgs */ - : 0) | (capabilities.createArgs ? 8 - /* CreateArgs */ - : 0) | (capabilities.attributeHook ? 16 - /* AttributeHook */ - : 0) | (capabilities.elementHook ? 32 - /* ElementHook */ - : 0) | (capabilities.dynamicScope ? 64 - /* DynamicScope */ - : 0) | (capabilities.createCaller ? 128 - /* CreateCaller */ - : 0) | (capabilities.updateHook ? 256 - /* UpdateHook */ - : 0) | (capabilities.createInstance ? 512 - /* CreateInstance */ - : 0); - } - - function hasCapability(capabilities, capability) { - return !!(capabilities & capability); - } - - APPEND_OPCODES.add(69 + var COMPONENT_INSTANCE = (0, _util.symbol)('COMPONENT_INSTANCE'); + APPEND_OPCODES.add(77 /* IsComponent */ , vm => { var stack = vm.stack; var ref = stack.pop(); - stack.push(IsCurriedComponentDefinitionReference.create(ref)); + stack.push(new ConditionalReference(ref, isCurriedComponentDefinition)); }); - APPEND_OPCODES.add(70 + APPEND_OPCODES.add(78 /* ContentType */ , vm => { var stack = vm.stack; var ref = stack.peek(); stack.push(new ContentTypeReference(ref)); }); - APPEND_OPCODES.add(71 + APPEND_OPCODES.add(79 /* CurryComponent */ , (vm, { op1: _meta @@ -49912,21 +51800,22 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var stack = vm.stack; var definition = stack.pop(); var capturedArgs = stack.pop(); - var meta = vm.constants.getSerializable(_meta); - var resolver = vm.constants.resolver; - vm.loadValue(_vm2.Register.v0, new CurryComponentReference(definition, resolver, meta, capturedArgs)); // expectStackChange(vm.stack, -args.length - 1, 'CurryComponent'); + var meta = vm[CONSTANTS].getTemplateMeta(_meta); + var resolver = vm.runtime.resolver; + vm.loadValue(_vm2.$v0, new CurryComponentReference(definition, resolver, meta, capturedArgs)); // expectStackChange(vm.stack, -args.length - 1, 'CurryComponent'); }); - APPEND_OPCODES.add(72 + APPEND_OPCODES.add(80 /* PushComponentDefinition */ , (vm, { op1: handle }) => { - var definition = vm.constants.resolveHandle(handle); + var definition = vm.runtime.resolver.resolve(handle); var { manager } = definition; var capabilities = capabilityFlagsFrom(manager.getCapabilities(definition.state)); var instance = { + [COMPONENT_INSTANCE]: true, definition, manager, capabilities, @@ -49937,25 +51826,20 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ }; vm.stack.push(instance); }); - APPEND_OPCODES.add(75 + APPEND_OPCODES.add(83 /* ResolveDynamicComponent */ , (vm, { op1: _meta }) => { var stack = vm.stack; var component = stack.pop().value(); - var meta = vm.constants.getSerializable(_meta); - vm.loadValue(_vm2.Register.t1, null); // Clear the temp register + var meta = vm[CONSTANTS].getTemplateMeta(_meta); + vm.loadValue(_vm2.$t1, null); // Clear the temp register var definition; if (typeof component === 'string') { - var { - constants: { - resolver - } - } = vm; - var resolvedDefinition = resolveComponent(resolver, component, meta); + var resolvedDefinition = resolveComponent(vm.runtime.resolver, component, meta); definition = resolvedDefinition; } else if (isCurriedComponentDefinition(component)) { definition = component; @@ -49965,7 +51849,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ stack.push(definition); }); - APPEND_OPCODES.add(73 + APPEND_OPCODES.add(81 /* PushDynamicComponentInstance */ , vm => { var { @@ -49990,9 +51874,9 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ table: null }); }); - APPEND_OPCODES.add(74 + APPEND_OPCODES.add(82 /* PushCurriedComponent */ - , (vm, {}) => { + , vm => { var stack = vm.stack; var component = stack.pop().value(); var definition; @@ -50005,32 +51889,32 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ stack.push(definition); }); - APPEND_OPCODES.add(76 + APPEND_OPCODES.add(84 /* PushArgs */ , (vm, { op1: _names, op2: flags }) => { var stack = vm.stack; - var names = vm.constants.getStringArray(_names); + var names = vm[CONSTANTS].getStringArray(_names); var positionalCount = flags >> 4; - var synthetic = flags & 0b1000; + var atNames = flags & 0b1000; var blockNames = []; if (flags & 0b0100) blockNames.push('main'); if (flags & 0b0010) blockNames.push('else'); if (flags & 0b0001) blockNames.push('attrs'); - vm.args.setup(stack, names, blockNames, positionalCount, !!synthetic); - stack.push(vm.args); + vm[ARGS].setup(stack, names, blockNames, positionalCount, !!atNames); + stack.push(vm[ARGS]); }); - APPEND_OPCODES.add(77 + APPEND_OPCODES.add(85 /* PushEmptyArgs */ , vm => { var { stack } = vm; - stack.push(vm.args.empty(stack)); + stack.push(vm[ARGS].empty(stack)); }); - APPEND_OPCODES.add(80 + APPEND_OPCODES.add(88 /* CaptureArgs */ , vm => { var stack = vm.stack; @@ -50038,7 +51922,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var capturedArgs = args.capture(); stack.push(capturedArgs); }); - APPEND_OPCODES.add(79 + APPEND_OPCODES.add(87 /* PrepareArgs */ , (vm, { op1: _state @@ -50060,9 +51944,9 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } = definition; var capabilities = instance.capabilities; - if (hasCapability(capabilities, 4 + if (!managerHasCapability(manager, capabilities, 4 /* PrepareArgs */ - ) !== true) { + )) { stack.push(args); return; } @@ -50084,17 +51968,17 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } = preparedArgs; var positionalCount = positional.length; - for (var _i = 0; _i < positionalCount; _i++) { - stack.push(positional[_i]); + for (var _i5 = 0; _i5 < positionalCount; _i5++) { + stack.push(positional[_i5]); } var names = Object.keys(named); - for (var _i2 = 0; _i2 < names.length; _i2++) { - stack.push(named[names[_i2]]); + for (var _i6 = 0; _i6 < names.length; _i6++) { + stack.push(named[names[_i6]]); } - args.setup(stack, names, blockNames, positionalCount, true); + args.setup(stack, names, blockNames, positionalCount, false); } stack.push(args); @@ -50111,7 +51995,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ return unwrappedDefinition; } - APPEND_OPCODES.add(81 + APPEND_OPCODES.add(89 /* CreateComponent */ , (vm, { op1: flags, @@ -50123,9 +52007,16 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ manager } = instance; var capabilities = instance.capabilities = capabilityFlagsFrom(manager.getCapabilities(definition.state)); + + if (!managerHasCapability(manager, capabilities, 512 + /* CreateInstance */ + )) { + throw new Error(`BUG`); + } + var dynamicScope = null; - if (hasCapability(capabilities, 64 + if (managerHasCapability(manager, capabilities, 64 /* DynamicScope */ )) { dynamicScope = vm.dynamicScope(); @@ -50134,7 +52025,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var hasDefaultBlock = flags & 1; var args = null; - if (hasCapability(capabilities, 8 + if (managerHasCapability(manager, capabilities, 8 /* CreateArgs */ )) { args = vm.stack.peek(); @@ -50142,7 +52033,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var self = null; - if (hasCapability(capabilities, 128 + if (managerHasCapability(manager, capabilities, 128 /* CreateCaller */ )) { self = vm.getSelf(); @@ -50154,46 +52045,68 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ instance.state = state; var tag = manager.getTag(state); - if (hasCapability(capabilities, 256 + if (managerHasCapability(manager, capabilities, 256 /* UpdateHook */ - ) && !(0, _reference2.isConstTag)(tag)) { + ) && !(0, _validator.isConstTag)(tag)) { vm.updateWith(new UpdateComponentOpcode(tag, state, manager, dynamicScope)); } }); - APPEND_OPCODES.add(82 + APPEND_OPCODES.add(90 /* RegisterComponentDestructor */ , (vm, { op1: _state }) => { var { manager, - state + state, + capabilities } = vm.fetchValue(_state); - var destructor = manager.getDestructor(state); - if (destructor) vm.newDestroyable(destructor); + var d = manager.getDestructor(state); + + if (true + /* DEBUG */ + && !hasCapability(capabilities, 2048 + /* WillDestroy */ + ) && d !== null && typeof 'willDestroy' in d) { + throw new Error('BUG: Destructor has willDestroy, but the willDestroy capability was not enabled for this component. Pre-destruction hooks must be explicitly opted into'); + } + + if (d) vm.associateDestroyable(d); }); - APPEND_OPCODES.add(91 + APPEND_OPCODES.add(100 /* BeginComponentTransaction */ , vm => { vm.beginCacheGroup(); vm.elements().pushSimpleBlock(); }); - APPEND_OPCODES.add(83 + APPEND_OPCODES.add(91 /* PutComponentOperations */ , vm => { - vm.loadValue(_vm2.Register.t0, new ComponentElementOperations()); + vm.loadValue(_vm2.$t0, new ComponentElementOperations()); }); - APPEND_OPCODES.add(37 + APPEND_OPCODES.add(53 /* ComponentAttr */ , (vm, { op1: _name, op2: trusting, op3: _namespace }) => { - var name = vm.constants.getString(_name); + var name = vm[CONSTANTS].getString(_name); var reference = vm.stack.pop(); - var namespace = _namespace ? vm.constants.getString(_namespace) : null; - vm.fetchValue(_vm2.Register.t0).setAttribute(name, reference, !!trusting, namespace); + var namespace = _namespace ? vm[CONSTANTS].getString(_namespace) : null; + vm.fetchValue(_vm2.$t0).setAttribute(name, reference, !!trusting, namespace); + }); + APPEND_OPCODES.add(108 + /* StaticComponentAttr */ + , (vm, { + op1: _name, + op2: _value, + op3: _namespace + }) => { + var name = vm[CONSTANTS].getString(_name); + var value$$1 = vm[CONSTANTS].getString(_value); + var namespace = _namespace ? vm[CONSTANTS].getString(_namespace) : null; + vm.fetchValue(_vm2.$t0).setStaticAttribute(name, value$$1, namespace); }); class ComponentElementOperations { @@ -50217,55 +52130,102 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ this.attributes[name] = deferred; } - addModifier(manager, modifier) { - this.modifiers.push([manager, modifier]); + setStaticAttribute(name, value$$1, namespace) { + var deferred = { + value: value$$1, + namespace + }; + + if (name === 'class') { + this.classes.push(value$$1); + } + + this.attributes[name] = deferred; } - flush(vm) { - for (var name in this.attributes) { - var attr = this.attributes[name]; - var { - value: reference, - namespace, - trusting - } = attr; + addModifier(manager, state) { + this.modifiers.push([manager, state]); + } - if (name === 'class') { - reference = new ClassListReference(this.classes); - } + flush(vm) { + var type; + var attributes = this.attributes; - if (name === 'type') { + for (var _name3 in this.attributes) { + if (_name3 === 'type') { + type = attributes[_name3]; continue; } - var attribute = vm.elements().setDynamicAttribute(name, reference.value(), trusting, namespace); + var attr = this.attributes[_name3]; - if (!(0, _reference2.isConst)(reference)) { - vm.updateWith(new UpdateDynamicAttributeOpcode(reference, attribute)); + if (_name3 === 'class') { + setDeferredAttr(vm, 'class', mergeClasses(this.classes), attr.namespace, attr.trusting); + } else { + setDeferredAttr(vm, _name3, attr.value, attr.namespace, attr.trusting); } } - if ('type' in this.attributes) { - var type = this.attributes.type; - var { - value: _reference, - namespace: _namespace2, - trusting: _trusting - } = type; + if (type !== undefined) { + setDeferredAttr(vm, 'type', type.value, type.namespace, type.trusting); + } + + return this.modifiers; + } - var _attribute = vm.elements().setDynamicAttribute('type', _reference.value(), _trusting, _namespace2); + } - if (!(0, _reference2.isConst)(_reference)) { - vm.updateWith(new UpdateDynamicAttributeOpcode(_reference, _attribute)); - } + function mergeClasses(classes) { + if (classes.length === 0) { + return ''; + } + + if (classes.length === 1) { + return classes[0]; + } + + if (allStringClasses(classes)) { + return classes.join(' '); + } + + return makeClassList(classes); + } + + function makeClassList(classes) { + for (var i = 0; i < classes.length; i++) { + var value$$1 = classes[i]; + + if (typeof value$$1 === 'string') { + classes[i] = _runtime.PrimitiveReference.create(value$$1); } + } - return this.modifiers; + return new ClassListReference(classes); + } + + function allStringClasses(classes) { + for (var i = 0; i < classes.length; i++) { + if (typeof classes[i] !== 'string') { + return false; + } } + return true; } - APPEND_OPCODES.add(93 + function setDeferredAttr(vm, name, value$$1, namespace, trusting = false) { + if (typeof value$$1 === 'string') { + vm.elements().setStaticAttribute(name, value$$1, namespace); + } else { + var attribute = vm.elements().setDynamicAttribute(name, value$$1.value(), trusting, namespace); + + if (!(0, _validator.isConst)(value$$1)) { + vm.updateWith(new UpdateDynamicAttributeOpcode(value$$1, attribute)); + } + } + } + + APPEND_OPCODES.add(102 /* DidCreateElement */ , (vm, { op1: _state @@ -50277,11 +52237,10 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var { manager } = definition; - var operations = vm.fetchValue(_vm2.Register.t0); - var action = 'DidCreateElementOpcode#evaluate'; - manager.didCreateElement(state, vm.elements().expectConstructing(action), operations); + var operations = vm.fetchValue(_vm2.$t0); + manager.didCreateElement(state, vm.elements().constructing, operations); }); - APPEND_OPCODES.add(84 + APPEND_OPCODES.add(92 /* GetComponentSelf */ , (vm, { op1: _state @@ -50295,7 +52254,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } = definition; vm.stack.push(manager.getSelf(state)); }); - APPEND_OPCODES.add(85 + APPEND_OPCODES.add(93 /* GetComponentTagName */ , (vm, { op1: _state @@ -50310,8 +52269,48 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.stack.push(manager.getTagName(state)); }); // Dynamic Invocation Only - APPEND_OPCODES.add(86 - /* GetComponentLayout */ + APPEND_OPCODES.add(95 + /* GetJitComponentLayout */ + , (vm, { + op1: _state + }) => { + var instance = vm.fetchValue(_state); + var manager = instance.manager; + var { + definition + } = instance; + var { + stack + } = vm; + var { + capabilities + } = instance; // let invoke: { handle: number; symbolTable: ProgramSymbolTable }; + + var layout; + + if (hasStaticLayoutCapability(capabilities, manager)) { + layout = manager.getJitStaticLayout(definition.state, vm.runtime.resolver); + } else if (hasDynamicLayoutCapability(capabilities, manager)) { + var template = (0, _opcodeCompiler.unwrapTemplate)(manager.getJitDynamicLayout(instance.state, vm.runtime.resolver)); + + if (hasCapability(capabilities, 1024 + /* Wrapped */ + )) { + layout = template.asWrappedLayout(); + } else { + layout = template.asLayout(); + } + } else { + throw (0, _util.unreachable)(); + } + + var handle = layout.compile(vm.context); + stack.push(layout.symbolTable); + stack.push(handle); + }, 'jit'); // Dynamic Invocation Only + + APPEND_OPCODES.add(94 + /* GetAotComponentLayout */ , (vm, { op1: _state }) => { @@ -50321,9 +52320,6 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ definition } = instance; var { - constants: { - resolver - }, stack } = vm; var { @@ -50336,30 +52332,30 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var invoke; if (hasStaticLayoutCapability(capabilities, manager)) { - invoke = manager.getLayout(definitionState, resolver); + invoke = manager.getAotStaticLayout(definitionState, vm.runtime.resolver); } else if (hasDynamicLayoutCapability(capabilities, manager)) { - invoke = manager.getDynamicLayout(instanceState, resolver); + invoke = manager.getAotDynamicLayout(instanceState, vm.runtime.resolver); } else { throw (0, _util.unreachable)(); } stack.push(invoke.symbolTable); stack.push(invoke.handle); - }); + }); // These types are absurd here function hasStaticLayoutCapability(capabilities, _manager) { - return hasCapability(capabilities, 1 + return managerHasCapability(_manager, capabilities, 1 /* DynamicLayout */ ) === false; } function hasDynamicLayoutCapability(capabilities, _manager) { - return hasCapability(capabilities, 1 + return managerHasCapability(_manager, capabilities, 1 /* DynamicLayout */ ) === true; } - APPEND_OPCODES.add(68 + APPEND_OPCODES.add(76 /* Main */ , (vm, { op1: register @@ -50371,6 +52367,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } = definition; var capabilities = capabilityFlagsFrom(manager.getCapabilities(definition.state)); var state = { + [COMPONENT_INSTANCE]: true, definition, manager, capabilities, @@ -50381,7 +52378,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ }; vm.loadValue(register, state); }); - APPEND_OPCODES.add(89 + APPEND_OPCODES.add(98 /* PopulateLayout */ , (vm, { op1: _state @@ -50395,7 +52392,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ state.handle = handle; state.table = table; }); - APPEND_OPCODES.add(21 + APPEND_OPCODES.add(38 /* VirtualRootScope */ , (vm, { op1: _state @@ -50403,9 +52400,9 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var { symbols } = vm.fetchValue(_state).table; - vm.pushRootScope(symbols.length + 1, true); + vm.pushRootScope(symbols.length + 1); }); - APPEND_OPCODES.add(87 + APPEND_OPCODES.add(97 /* SetupForEval */ , (vm, { op1: _state @@ -50417,7 +52414,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.scope().bindEvalScope(lookup); } }); - APPEND_OPCODES.add(2 + APPEND_OPCODES.add(17 /* SetNamedVariables */ , (vm, { op1: _state @@ -50429,25 +52426,25 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ for (var i = callerNames.length - 1; i >= 0; i--) { var atName = callerNames[i]; - var symbol = state.table.symbols.indexOf(callerNames[i]); - var value$$1 = args.named.get(atName, false); - if (symbol !== -1) scope.bindSymbol(symbol + 1, value$$1); + var symbol$$1 = state.table.symbols.indexOf(callerNames[i]); + var value$$1 = args.named.get(atName, true); + if (symbol$$1 !== -1) scope.bindSymbol(symbol$$1 + 1, value$$1); if (state.lookup) state.lookup[atName] = value$$1; } }); function bindBlock(symbolName, blockName, state, blocks, vm) { - var symbol = state.table.symbols.indexOf(symbolName); + var symbol$$1 = state.table.symbols.indexOf(symbolName); var block = blocks.get(blockName); - if (symbol !== -1) { - vm.scope().bindBlock(symbol + 1, block); + if (symbol$$1 !== -1) { + vm.scope().bindBlock(symbol$$1 + 1, block); } if (state.lookup) state.lookup[symbolName] = block; } - APPEND_OPCODES.add(3 + APPEND_OPCODES.add(18 /* SetBlocks */ , (vm, { op1: _state @@ -50457,11 +52454,11 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ blocks } = vm.stack.peek(); bindBlock('&attrs', 'attrs', state, blocks, vm); - bindBlock('&inverse', 'else', state, blocks, vm); + bindBlock('&else', 'else', state, blocks, vm); bindBlock('&default', 'main', state, blocks, vm); }); // Dynamic Invocation Only - APPEND_OPCODES.add(90 + APPEND_OPCODES.add(99 /* InvokeComponentLayout */ , (vm, { op1: _state @@ -50469,22 +52466,30 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ var state = vm.fetchValue(_state); vm.call(state.handle); }); - APPEND_OPCODES.add(94 + APPEND_OPCODES.add(103 /* DidRenderLayout */ , (vm, { op1: _state }) => { var { manager, - state + state, + capabilities } = vm.fetchValue(_state); var bounds = vm.elements().popBlock(); + + if (!managerHasCapability(manager, capabilities, 512 + /* CreateInstance */ + )) { + throw new Error(`BUG`); + } + var mgr = manager; mgr.didRenderLayout(state, bounds); vm.env.didCreate(state, manager); vm.updateWith(new DidUpdateLayoutOpcode(manager, state, bounds)); }); - APPEND_OPCODES.add(92 + APPEND_OPCODES.add(101 /* CommitComponentTransaction */ , vm => { vm.commitCacheGroup(); @@ -50518,7 +52523,7 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ this.component = component; this.bounds = bounds; this.type = 'did-update-layout'; - this.tag = _reference2.CONSTANT_TAG; + this.tag = _validator.CONSTANT_TAG; } evaluate(vm) { @@ -50532,17 +52537,15 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } } - /* tslint:disable */ - function debugCallback(context, get) { console.info('Use `context`, and `get()` to debug this template.'); // for example... + // eslint-disable-next-line no-unused-expressions + + context === get('this'); // eslint-disable-next-line no-debugger - context === get('this'); debugger; } - /* tslint:enable */ - var callback = debugCallback; // For testing purposes @@ -50561,9 +52564,9 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ for (var i = 0; i < evalInfo.length; i++) { var slot = evalInfo[i]; - var name = symbols[slot - 1]; + var _name4 = symbols[slot - 1]; var ref = scope.getSymbol(slot); - this.locals[name] = ref; + this.locals[_name4] = ref; } } @@ -50593,18 +52596,18 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } - APPEND_OPCODES.add(97 + APPEND_OPCODES.add(106 /* Debugger */ , (vm, { op1: _symbols, op2: _evalInfo }) => { - var symbols = vm.constants.getStringArray(_symbols); - var evalInfo = vm.constants.getArray(_evalInfo); + var symbols = vm[CONSTANTS].getStringArray(_symbols); + var evalInfo = vm[CONSTANTS].getArray(_evalInfo); var inspector = new ScopeInspector(vm.scope(), symbols, evalInfo); callback(vm.getSelf().value(), path => inspector.get(path).value()); }); - APPEND_OPCODES.add(95 + APPEND_OPCODES.add(104 /* InvokePartial */ , (vm, { op1: _meta, @@ -50612,54 +52615,50 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ op3: _evalInfo }) => { var { - constants, - constants: { - resolver - }, + [CONSTANTS]: constants, stack } = vm; var name = stack.pop().value(); - var meta = constants.getSerializable(_meta); + var meta = constants.getTemplateMeta(_meta); var outerSymbols = constants.getStringArray(_symbols); var evalInfo = constants.getArray(_evalInfo); - var handle = resolver.lookupPartial(name, meta); - var definition = resolver.resolve(handle); + var handle = vm.runtime.resolver.lookupPartial(name, meta); + var definition = vm.runtime.resolver.resolve(handle); var { symbolTable, handle: vmHandle - } = definition.getPartial(); + } = definition.getPartial(vm.context); { var partialSymbols = symbolTable.symbols; var outerScope = vm.scope(); - var partialScope = vm.pushRootScope(partialSymbols.length, false); + var partialScope = vm.pushRootScope(partialSymbols.length); var evalScope = outerScope.getEvalScope(); - partialScope.bindCallerScope(outerScope.getCallerScope()); partialScope.bindEvalScope(evalScope); partialScope.bindSelf(outerScope.getSelf()); var locals = Object.create(outerScope.getPartialMap()); for (var i = 0; i < evalInfo.length; i++) { var slot = evalInfo[i]; - var _name2 = outerSymbols[slot - 1]; + var _name5 = outerSymbols[slot - 1]; var ref = outerScope.getSymbol(slot); - locals[_name2] = ref; + locals[_name5] = ref; } if (evalScope) { - for (var _i3 = 0; _i3 < partialSymbols.length; _i3++) { - var _name3 = partialSymbols[_i3]; - var symbol = _i3 + 1; - var value$$1 = evalScope[_name3]; - if (value$$1 !== undefined) partialScope.bind(symbol, value$$1); + for (var _i7 = 0; _i7 < partialSymbols.length; _i7++) { + var _name6 = partialSymbols[_i7]; + var symbol$$1 = _i7 + 1; + var value$$1 = evalScope[_name6]; + if (value$$1 !== undefined) partialScope.bind(symbol$$1, value$$1); } } partialScope.bindPartialMap(locals); vm.pushFrame(); // sp += 2 - vm.call(vmHandle); + vm.call((0, _opcodeCompiler.unwrapHandle)(vmHandle)); } - }); + }, 'jit'); class IterablePresenceReference { constructor(artifacts) { @@ -50673,30 +52672,30 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } - APPEND_OPCODES.add(66 + APPEND_OPCODES.add(74 /* PutIterator */ , vm => { var stack = vm.stack; var listRef = stack.pop(); var key = stack.pop(); var iterable = vm.env.iterableFor(listRef, key.value()); - var iterator = new _reference2.ReferenceIterator(iterable); + var iterator = new _reference.ReferenceIterator(iterable); stack.push(iterator); stack.push(new IterablePresenceReference(iterator.artifacts)); }); - APPEND_OPCODES.add(64 + APPEND_OPCODES.add(72 /* EnterList */ , (vm, { op1: relativeStart }) => { vm.enterList(relativeStart); }); - APPEND_OPCODES.add(65 + APPEND_OPCODES.add(73 /* ExitList */ , vm => { vm.exitList(); }); - APPEND_OPCODES.add(67 + APPEND_OPCODES.add(75 /* Iterate */ , (vm, { op1: breaks @@ -50711,1155 +52710,803 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ vm.goto(breaks); } }); + /** @internal */ - class Cursor { - constructor(element, nextSibling) { - this.element = element; - this.nextSibling = nextSibling; - } - - } - - _exports.Cursor = Cursor; - - class ConcreteBounds { - constructor(parentNode, first, last) { - this.parentNode = parentNode; - this.first = first; - this.last = last; - } - - parentElement() { - return this.parentNode; - } - - firstNode() { - return this.first; - } - - lastNode() { - return this.last; - } - - } - - _exports.ConcreteBounds = ConcreteBounds; - - class SingleNodeBounds { - constructor(parentNode, node) { - this.parentNode = parentNode; - this.node = node; - } - - parentElement() { - return this.parentNode; - } - - firstNode() { - return this.node; - } - - lastNode() { - return this.node; - } - - } - - function move(bounds, reference) { - var parent = bounds.parentElement(); - var first = bounds.firstNode(); - var last = bounds.lastNode(); - var current = first; - - while (true) { - var next = current.nextSibling; - parent.insertBefore(current, reference); - - if (current === last) { - return next; - } - - current = next; - } - } - - function clear(bounds) { - var parent = bounds.parentElement(); - var first = bounds.firstNode(); - var last = bounds.lastNode(); - var current = first; - - while (true) { - var next = current.nextSibling; - parent.removeChild(current); - - if (current === last) { - return next; - } - - current = next; - } - } // Patch: insertAdjacentHTML on SVG Fix - // Browsers: Safari, IE, Edge, Firefox ~33-34 - // Reason: insertAdjacentHTML does not exist on SVG elements in Safari. It is - // present but throws an exception on IE and Edge. Old versions of - // Firefox create nodes in the incorrect namespace. - // Fix: Since IE and Edge silently fail to create SVG nodes using - // innerHTML, and because Firefox may create nodes in the incorrect - // namespace using innerHTML on SVG elements, an HTML-string wrapping - // approach is used. A pre/post SVG tag is added to the string, then - // that whole string is added to a div. The created nodes are plucked - // out and applied to the target location on DOM. - - - function applySVGInnerHTMLFix(document, DOMClass, svgNamespace) { - if (!document) return DOMClass; - - if (!shouldApplyFix(document, svgNamespace)) { - return DOMClass; - } - - var div = document.createElement('div'); - return class DOMChangesWithSVGInnerHTMLFix extends DOMClass { - insertHTMLBefore(parent, nextSibling, html) { - if (html === '') { - return super.insertHTMLBefore(parent, nextSibling, html); - } - - if (parent.namespaceURI !== svgNamespace) { - return super.insertHTMLBefore(parent, nextSibling, html); - } - - return fixSVG(parent, div, html, nextSibling); - } - - }; - } - - function fixSVG(parent, div, html, reference) { - var source; // This is important, because decendants of the integration - // point are parsed in the HTML namespace - - if (parent.tagName.toUpperCase() === 'FOREIGNOBJECT') { - // IE, Edge: also do not correctly support using `innerHTML` on SVG - // namespaced elements. So here a wrapper is used. - var wrappedHtml = '' + html + ''; - div.innerHTML = wrappedHtml; - source = div.firstChild.firstChild; - } else { - // IE, Edge: also do not correctly support using `innerHTML` on SVG - // namespaced elements. So here a wrapper is used. - var _wrappedHtml = '' + html + ''; - - div.innerHTML = _wrappedHtml; - source = div.firstChild; - } - - return moveNodesBefore(source, parent, reference); - } - - function shouldApplyFix(document, svgNamespace) { - var svg = document.createElementNS(svgNamespace, 'svg'); - - try { - svg['insertAdjacentHTML']('beforeend', ''); - } catch (e) {// IE, Edge: Will throw, insertAdjacentHTML is unsupported on SVG - // Safari: Will throw, insertAdjacentHTML is not present on SVG - } finally { - // FF: Old versions will create a node in the wrong namespace - if (svg.childNodes.length === 1 && svg.firstChild.namespaceURI === SVG_NAMESPACE) { - // The test worked as expected, no fix required - return false; - } - - return true; - } - } // Patch: Adjacent text node merging fix - // Browsers: IE, Edge, Firefox w/o inspector open - // Reason: These browsers will merge adjacent text nodes. For exmaple given - //
Hello
with div.insertAdjacentHTML(' world') browsers - // with proper behavior will populate div.childNodes with two items. - // These browsers will populate it with one merged node instead. - // Fix: Add these nodes to a wrapper element, then iterate the childNodes - // of that wrapper and move the nodes to their target location. Note - // that potential SVG bugs will have been handled before this fix. - // Note that this fix must only apply to the previous text node, as - // the base implementation of `insertHTMLBefore` already handles - // following text nodes correctly. - - - function applyTextNodeMergingFix(document, DOMClass) { - if (!document) return DOMClass; - - if (!shouldApplyFix$1(document)) { - return DOMClass; - } - - return class DOMChangesWithTextNodeMergingFix extends DOMClass { - constructor(document) { - super(document); - this.uselessComment = document.createComment(''); - } - - insertHTMLBefore(parent, nextSibling, html) { - if (html === '') { - return super.insertHTMLBefore(parent, nextSibling, html); - } - - var didSetUselessComment = false; - var nextPrevious = nextSibling ? nextSibling.previousSibling : parent.lastChild; - - if (nextPrevious && nextPrevious instanceof Text) { - didSetUselessComment = true; - parent.insertBefore(this.uselessComment, nextSibling); - } - - var bounds = super.insertHTMLBefore(parent, nextSibling, html); - - if (didSetUselessComment) { - parent.removeChild(this.uselessComment); - } - - return bounds; - } - - }; - } - - function shouldApplyFix$1(document) { - var mergingTextDiv = document.createElement('div'); - mergingTextDiv.innerHTML = 'first'; - mergingTextDiv.insertAdjacentHTML('beforeend', 'second'); - - if (mergingTextDiv.childNodes.length === 2) { - // It worked as expected, no fix required - return false; - } - - return true; - } - - var SVG_NAMESPACE = "http://www.w3.org/2000/svg" - /* SVG */ - ; // http://www.w3.org/TR/html/syntax.html#html-integration-point - - _exports.SVG_NAMESPACE = SVG_NAMESPACE; - var SVG_INTEGRATION_POINTS = { - foreignObject: 1, - desc: 1, - title: 1 - }; // http://www.w3.org/TR/html/syntax.html#adjust-svg-attributes - // TODO: Adjust SVG attributes - // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - // TODO: Adjust SVG elements - // http://www.w3.org/TR/html/syntax.html#parsing-main-inforeign - - var BLACKLIST_TABLE = Object.create(null); - ['b', 'big', 'blockquote', 'body', 'br', 'center', 'code', 'dd', 'div', 'dl', 'dt', 'em', 'embed', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'i', 'img', 'li', 'listing', 'main', 'meta', 'nobr', 'ol', 'p', 'pre', 'ruby', 's', 'small', 'span', 'strong', 'strike', 'sub', 'sup', 'table', 'tt', 'u', 'ul', 'var'].forEach(tag => BLACKLIST_TABLE[tag] = 1); - var WHITESPACE = /[\t-\r \xA0\u1680\u180E\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]/; - var doc = typeof document === 'undefined' ? null : document; - - function isWhitespace(string) { - return WHITESPACE.test(string); - } - - function moveNodesBefore(source, target, nextSibling) { - var first = source.firstChild; - var last = first; - var current = first; - - while (current) { - var next = current.nextSibling; - target.insertBefore(current, nextSibling); - last = current; - current = next; - } - - return new ConcreteBounds(target, first, last); - } - - class DOMOperations { - constructor(document) { - this.document = document; - this.setupUselessElement(); - } // split into seperate method so that NodeDOMTreeConstruction - // can override it. - - - setupUselessElement() { - this.uselessElement = this.document.createElement('div'); - } - - createElement(tag, context) { - var isElementInSVGNamespace, isHTMLIntegrationPoint; - - if (context) { - isElementInSVGNamespace = context.namespaceURI === SVG_NAMESPACE || tag === 'svg'; - isHTMLIntegrationPoint = SVG_INTEGRATION_POINTS[context.tagName]; - } else { - isElementInSVGNamespace = tag === 'svg'; - isHTMLIntegrationPoint = false; - } - - if (isElementInSVGNamespace && !isHTMLIntegrationPoint) { - // FIXME: This does not properly handle with color, face, or - // size attributes, which is also disallowed by the spec. We should fix - // this. - if (BLACKLIST_TABLE[tag]) { - throw new Error("Cannot create a " + tag + " inside an SVG context"); - } - - return this.document.createElementNS(SVG_NAMESPACE, tag); - } else { - return this.document.createElement(tag); - } - } - - insertBefore(parent, node, reference) { - parent.insertBefore(node, reference); - } - - insertHTMLBefore(parent, nextSibling, html) { - if (html === '') { - var comment = this.createComment(''); - parent.insertBefore(comment, nextSibling); - return new ConcreteBounds(parent, comment, comment); - } - - var prev = nextSibling ? nextSibling.previousSibling : parent.lastChild; - var last; - - if (nextSibling === null) { - parent.insertAdjacentHTML("beforeend" - /* beforeend */ - , html); - last = parent.lastChild; - } else if (nextSibling instanceof HTMLElement) { - nextSibling.insertAdjacentHTML("beforebegin" - /* beforebegin */ - , html); - last = nextSibling.previousSibling; - } else { - // Non-element nodes do not support insertAdjacentHTML, so add an - // element and call it on that element. Then remove the element. - // - // This also protects Edge, IE and Firefox w/o the inspector open - // from merging adjacent text nodes. See ./compat/text-node-merging-fix.ts - var { - uselessElement - } = this; - parent.insertBefore(uselessElement, nextSibling); - uselessElement.insertAdjacentHTML("beforebegin" - /* beforebegin */ - , html); - last = uselessElement.previousSibling; - parent.removeChild(uselessElement); - } - - var first = prev ? prev.nextSibling : parent.firstChild; - return new ConcreteBounds(parent, first, last); - } - - createTextNode(text) { - return this.document.createTextNode(text); - } - - createComment(data) { - return this.document.createComment(data); - } - - } - - var DOM; - - (function (DOM) { - class TreeConstruction extends DOMOperations { - createElementNS(namespace, tag) { - return this.document.createElementNS(namespace, tag); - } - - setAttribute(element, name, value$$1, namespace = null) { - if (namespace) { - element.setAttributeNS(namespace, name, value$$1); - } else { - element.setAttribute(name, value$$1); - } - } + var DEFAULT_CAPABILITIES = { + dynamicLayout: true, + dynamicTag: true, + prepareArgs: true, + createArgs: true, + attributeHook: false, + elementHook: false, + dynamicScope: true, + createCaller: false, + updateHook: true, + createInstance: true, + wrapped: false, + willDestroy: false + }; + _exports.DEFAULT_CAPABILITIES = DEFAULT_CAPABILITIES; + var MINIMAL_CAPABILITIES = { + dynamicLayout: false, + dynamicTag: false, + prepareArgs: false, + createArgs: false, + attributeHook: false, + elementHook: false, + dynamicScope: false, + createCaller: false, + updateHook: false, + createInstance: false, + wrapped: false, + willDestroy: false + }; + _exports.MINIMAL_CAPABILITIES = MINIMAL_CAPABILITIES; + class SimpleComponentManager { + getCapabilities(_state) { + return MINIMAL_CAPABILITIES; } - DOM.TreeConstruction = TreeConstruction; - var appliedTreeContruction = TreeConstruction; - appliedTreeContruction = applyTextNodeMergingFix(doc, appliedTreeContruction); - appliedTreeContruction = applySVGInnerHTMLFix(doc, appliedTreeContruction, SVG_NAMESPACE); - DOM.DOMTreeConstruction = appliedTreeContruction; - })(DOM || (DOM = {})); - - class DOMChanges extends DOMOperations { - constructor(document) { - super(document); - this.document = document; - this.namespace = null; + prepareArgs(_state, _args) { + throw new Error(`Unimplemented prepareArgs in SimpleComponentManager`); } - setAttribute(element, name, value$$1) { - element.setAttribute(name, value$$1); + create(_env, _state, _args, _dynamicScope, _caller, _hasDefaultBlock) { + throw new Error(`Unimplemented create in SimpleComponentManager`); } - removeAttribute(element, name) { - element.removeAttribute(name); + getSelf(_state) { + return UNDEFINED_REFERENCE; } - insertAfter(element, node, reference) { - this.insertBefore(element, node, reference.nextSibling); + getTag(_state) { + throw new Error(`Unimplemented getTag in SimpleComponentManager`); } - } - - _exports.IDOMChanges = DOMChanges; - var helper = DOMChanges; - helper = applyTextNodeMergingFix(doc, helper); - helper = applySVGInnerHTMLFix(doc, helper, SVG_NAMESPACE); - var helper$1 = helper; - _exports.DOMChanges = helper$1; - var DOMTreeConstruction = DOM.DOMTreeConstruction; - _exports.DOMTreeConstruction = DOMTreeConstruction; - var badProtocols = ['javascript:', 'vbscript:']; - var badTags = ['A', 'BODY', 'LINK', 'IMG', 'IFRAME', 'BASE', 'FORM']; - var badTagsForDataURI = ['EMBED']; - var badAttributes = ['href', 'src', 'background', 'action']; - var badAttributesForDataURI = ['src']; - - function has(array, item) { - return array.indexOf(item) !== -1; - } - - function checkURI(tagName, attribute) { - return (tagName === null || has(badTags, tagName)) && has(badAttributes, attribute); - } - - function checkDataURI(tagName, attribute) { - if (tagName === null) return false; - return has(badTagsForDataURI, tagName) && has(badAttributesForDataURI, attribute); - } - - function requiresSanitization(tagName, attribute) { - return checkURI(tagName, attribute) || checkDataURI(tagName, attribute); - } - - function sanitizeAttributeValue(env, element, attribute, value$$1) { - var tagName = null; - - if (value$$1 === null || value$$1 === undefined) { - return value$$1; + didRenderLayout(_state, _bounds) { + throw new Error(`Unimplemented didRenderLayout in SimpleComponentManager`); } - if (isSafeString(value$$1)) { - return value$$1.toHTML(); + didCreate(_state) { + throw new Error(`Unimplemented didCreate in SimpleComponentManager`); } - if (!element) { - tagName = null; - } else { - tagName = element.tagName.toUpperCase(); + update(_state, _dynamicScope) { + throw new Error(`Unimplemented update in SimpleComponentManager`); } - var str = normalizeStringValue(value$$1); - - if (checkURI(tagName, attribute)) { - var protocol = env.protocolForURL(str); + didUpdateLayout(_state, _bounds) { + throw new Error(`Unimplemented didUpdateLayout in SimpleComponentManager`); + } - if (has(badProtocols, protocol)) { - return "unsafe:" + str; - } + didUpdate(_state) { + throw new Error(`Unimplemented didUpdate in SimpleComponentManager`); } - if (checkDataURI(tagName, attribute)) { - return "unsafe:" + str; + getDestructor(_state) { + return null; } - return str; } - /* - * @method normalizeProperty - * @param element {HTMLElement} - * @param slotName {String} - * @returns {Object} { name, type } - */ - - - function normalizeProperty(element, slotName) { - var type, normalized; - if (slotName in element) { - normalized = slotName; - type = 'prop'; - } else { - var lower = slotName.toLowerCase(); + _exports.SimpleComponentManager = SimpleComponentManager; + var TEMPLATE_ONLY_COMPONENT = { + state: null, + manager: new SimpleComponentManager() + }; + _exports.TEMPLATE_ONLY_COMPONENT = TEMPLATE_ONLY_COMPONENT; - if (lower in element) { - type = 'prop'; - normalized = lower; + class DefaultDynamicScope { + constructor(bucket) { + if (bucket) { + this.bucket = (0, _util.assign)({}, bucket); } else { - type = 'attr'; - normalized = slotName; + this.bucket = {}; } } - if (type === 'prop' && (normalized.toLowerCase() === 'style' || preferAttr(element.tagName, normalized))) { - type = 'attr'; + get(key) { + return this.bucket[key]; } - return { - normalized, - type - }; - } // properties that MUST be set as attributes, due to: - // * browser bug - // * strange spec outlier - + set(key, reference) { + return this.bucket[key] = reference; + } - var ATTR_OVERRIDES = { - INPUT: { - form: true, - // Chrome 46.0.2464.0: 'autocorrect' in document.createElement('input') === false - // Safari 8.0.7: 'autocorrect' in document.createElement('input') === false - // Mobile Safari (iOS 8.4 simulator): 'autocorrect' in document.createElement('input') === true - autocorrect: true, - // Chrome 54.0.2840.98: 'list' in document.createElement('input') === true - // Safari 9.1.3: 'list' in document.createElement('input') === false - list: true - }, - // element.form is actually a legitimate readOnly property, that is to be - // mutated, but must be mutated by setAttribute... - SELECT: { - form: true - }, - OPTION: { - form: true - }, - TEXTAREA: { - form: true - }, - LABEL: { - form: true - }, - FIELDSET: { - form: true - }, - LEGEND: { - form: true - }, - OBJECT: { - form: true - }, - BUTTON: { - form: true + child() { + return new DefaultDynamicScope(this.bucket); } - }; - function preferAttr(tagName, propName) { - var tag = ATTR_OVERRIDES[tagName.toUpperCase()]; - return tag && tag[propName.toLowerCase()] || false; } - function dynamicAttribute(element, attr, namespace) { - var { - tagName, - namespaceURI - } = element; - var attribute = { - element, - name: attr, - namespace - }; + _exports.DefaultDynamicScope = DefaultDynamicScope; - if (namespaceURI === SVG_NAMESPACE) { - return buildDynamicAttribute(tagName, attr, attribute); + class DynamicVarReference { + constructor(scope, nameRef) { + this.scope = scope; + this.nameRef = nameRef; + var varTag = this.varTag = (0, _validator.createUpdatableTag)(); + this.tag = (0, _validator.combine)([nameRef.tag, varTag]); } - var { - type, - normalized - } = normalizeProperty(element, attr); + value() { + return this.getVar().value(); + } - if (type === 'attr') { - return buildDynamicAttribute(tagName, normalized, attribute); - } else { - return buildDynamicProperty(tagName, normalized, attribute); + get(key) { + return this.getVar().get(key); } - } - function buildDynamicAttribute(tagName, name, attribute) { - if (requiresSanitization(tagName, name)) { - return new SafeDynamicAttribute(attribute); - } else { - return new SimpleDynamicAttribute(attribute); + getVar() { + var name = String(this.nameRef.value()); + var ref = this.scope.get(name); + (0, _validator.update)(this.varTag, ref.tag); + return ref; } + } - function buildDynamicProperty(tagName, name, attribute) { - if (requiresSanitization(tagName, name)) { - return new SafeDynamicProperty(name, attribute); + function getDynamicVar(args, vm) { + var scope = vm.dynamicScope(); + var nameRef = args.positional.at(0); + return new DynamicVarReference(scope, nameRef); + } + /* + The calling convention is: + + * 0-N block arguments at the bottom + * 0-N positional arguments next (left-to-right) + * 0-N named arguments next + */ + + + class VMArgumentsImpl { + constructor() { + this.stack = null; + this.positional = new PositionalArgumentsImpl(); + this.named = new NamedArgumentsImpl(); + this.blocks = new BlockArgumentsImpl(); } - if (isUserInputValue(tagName, name)) { - return new InputValueDynamicAttribute(name, attribute); + empty(stack) { + var base = stack[REGISTERS][_vm2.$sp] + 1; + this.named.empty(stack, base); + this.positional.empty(stack, base); + this.blocks.empty(stack, base); + return this; } - if (isOptionSelected(tagName, name)) { - return new OptionSelectedDynamicAttribute(name, attribute); + setup(stack, names, blockNames, positionalCount, atNames) { + this.stack = stack; + /* + | ... | blocks | positional | named | + | ... | b0 b1 | p0 p1 p2 p3 | n0 n1 | + index | ... | 4/5/6 7/8/9 | 10 11 12 13 | 14 15 | + ^ ^ ^ ^ + bbase pbase nbase sp + */ + + var named = this.named; + var namedCount = names.length; + var namedBase = stack[REGISTERS][_vm2.$sp] - namedCount + 1; + named.setup(stack, namedBase, namedCount, names, atNames); + var positional = this.positional; + var positionalBase = namedBase - positionalCount; + positional.setup(stack, positionalBase, positionalCount); + var blocks = this.blocks; + var blocksCount = blockNames.length; + var blocksBase = positionalBase - blocksCount * 3; + blocks.setup(stack, blocksBase, blocksCount, blockNames); } - return new DefaultDynamicProperty(name, attribute); - } + get tag() { + return combineTagged([this.positional, this.named]); + } - class DynamicAttribute { - constructor(attribute) { - this.attribute = attribute; + get base() { + return this.blocks.base; } - } + get length() { + return this.positional.length + this.named.length + this.blocks.length * 3; + } - _exports.DynamicAttribute = DynamicAttribute; + at(pos) { + return this.positional.at(pos); + } - class SimpleDynamicAttribute extends DynamicAttribute { - set(dom, value$$1, _env) { - var normalizedValue = normalizeValue(value$$1); + realloc(offset) { + var { + stack + } = this; - if (normalizedValue !== null) { + if (offset > 0 && stack !== null) { var { - name, - namespace - } = this.attribute; + positional, + named + } = this; + var newBase = positional.base + offset; + var length = positional.length + named.length; + + for (var i = length - 1; i >= 0; i--) { + stack.copy(i + positional.base, i + newBase); + } - dom.__setAttribute(name, normalizedValue, namespace); + positional.base += offset; + named.base += offset; + stack[REGISTERS][_vm2.$sp] += offset; } } - update(value$$1, _env) { - var normalizedValue = normalizeValue(value$$1); - var { - element, - name - } = this.attribute; + capture() { + var positional = this.positional.length === 0 ? EMPTY_POSITIONAL : this.positional.capture(); + var named = this.named.length === 0 ? EMPTY_NAMED : this.named.capture(); + return new CapturedArgumentsImpl(this.tag, positional, named, this.length); + } - if (normalizedValue === null) { - element.removeAttribute(name); - } else { - element.setAttribute(name, normalizedValue); - } + clear() { + var { + stack, + length + } = this; + if (length > 0 && stack !== null) stack.pop(length); } } - _exports.SimpleDynamicAttribute = SimpleDynamicAttribute; + class PositionalArgumentsImpl { + constructor() { + this.base = 0; + this.length = 0; + this.stack = null; + this._tag = null; + this._references = null; + } - class DefaultDynamicProperty extends DynamicAttribute { - constructor(normalizedName, attribute) { - super(attribute); - this.normalizedName = normalizedName; + empty(stack, base) { + this.stack = stack; + this.base = base; + this.length = 0; + this._tag = _validator.CONSTANT_TAG; + this._references = _util.EMPTY_ARRAY; } - set(dom, value$$1, _env) { - if (value$$1 !== null && value$$1 !== undefined) { - this.value = value$$1; + setup(stack, base, length) { + this.stack = stack; + this.base = base; + this.length = length; - dom.__setProperty(this.normalizedName, value$$1); + if (length === 0) { + this._tag = _validator.CONSTANT_TAG; + this._references = _util.EMPTY_ARRAY; + } else { + this._tag = null; + this._references = null; } } - update(value$$1, _env) { - var { - element - } = this.attribute; - - if (this.value !== value$$1) { - element[this.normalizedName] = this.value = value$$1; + get tag() { + var tag = this._tag; - if (value$$1 === null || value$$1 === undefined) { - this.removeAttribute(); - } + if (!tag) { + tag = this._tag = combineTagged(this.references); } + + return tag; } - removeAttribute() { - // TODO this sucks but to preserve properties first and to meet current - // semantics we must do this. + at(position) { var { - element, - namespace - } = this.attribute; + base, + length, + stack + } = this; - if (namespace) { - element.removeAttributeNS(namespace, this.normalizedName); - } else { - element.removeAttribute(this.normalizedName); + if (position < 0 || position >= length) { + return UNDEFINED_REFERENCE; } - } - - } - class SafeDynamicProperty extends DefaultDynamicProperty { - set(dom, value$$1, env) { - var { - element, - name - } = this.attribute; - var sanitized = sanitizeAttributeValue(env, element, name, value$$1); - super.set(dom, sanitized, env); + return stack.get(position, base); } - update(value$$1, env) { - var { - element, - name - } = this.attribute; - var sanitized = sanitizeAttributeValue(env, element, name, value$$1); - super.update(sanitized, env); + capture() { + return new CapturedPositionalArgumentsImpl(this.tag, this.references); } - } - - class SafeDynamicAttribute extends SimpleDynamicAttribute { - set(dom, value$$1, env) { - var { - element, - name - } = this.attribute; - var sanitized = sanitizeAttributeValue(env, element, name, value$$1); - super.set(dom, sanitized, env); - } + prepend(other) { + var additions = other.length; - update(value$$1, env) { - var { - element, - name - } = this.attribute; - var sanitized = sanitizeAttributeValue(env, element, name, value$$1); - super.update(sanitized, env); - } + if (additions > 0) { + var { + base, + length, + stack + } = this; + this.base = base = base - additions; + this.length = length + additions; - } + for (var i = 0; i < additions; i++) { + stack.set(other.at(i), i, base); + } - class InputValueDynamicAttribute extends DefaultDynamicProperty { - set(dom, value$$1) { - dom.__setProperty('value', normalizeStringValue(value$$1)); + this._tag = null; + this._references = null; + } } - update(value$$1) { - var input = this.attribute.element; - var currentValue = input.value; - var normalizedValue = normalizeStringValue(value$$1); + get references() { + var references = this._references; - if (currentValue !== normalizedValue) { - input.value = normalizedValue; + if (!references) { + var { + stack, + base, + length + } = this; + references = this._references = stack.sliceArray(base, base + length); } + + return references; } } - class OptionSelectedDynamicAttribute extends DefaultDynamicProperty { - set(dom, value$$1) { - if (value$$1 !== null && value$$1 !== undefined && value$$1 !== false) { - dom.__setProperty('selected', true); - } + class CapturedPositionalArgumentsImpl { + constructor(tag, references, length = references.length) { + this.tag = tag; + this.references = references; + this.length = length; } - update(value$$1) { - var option = this.attribute.element; + static empty() { + return new CapturedPositionalArgumentsImpl(_validator.CONSTANT_TAG, _util.EMPTY_ARRAY, 0); + } - if (value$$1) { - option.selected = true; - } else { - option.selected = false; - } + at(position) { + return this.references[position]; } - } + value() { + return this.references.map(this.valueOf); + } - function isOptionSelected(tagName, attribute) { - return tagName === 'OPTION' && attribute === 'selected'; - } + get(name) { + var { + references, + length + } = this; - function isUserInputValue(tagName, attribute) { - return (tagName === 'INPUT' || tagName === 'TEXTAREA') && attribute === 'value'; - } + if (name === 'length') { + return PrimitiveReference$1.create(length); + } else { + var idx = parseInt(name, 10); - function normalizeValue(value$$1) { - if (value$$1 === false || value$$1 === undefined || value$$1 === null || typeof value$$1.toString === 'undefined') { - return null; + if (idx < 0 || idx >= length) { + return UNDEFINED_REFERENCE; + } else { + return references[idx]; + } + } } - if (value$$1 === true) { - return ''; - } // onclick function etc in SSR - - - if (typeof value$$1 === 'function') { - return null; + valueOf(reference) { + return reference.value(); } - return String(value$$1); } - class Scope { - constructor( // the 0th slot is `self` - slots, callerScope, // named arguments and blocks passed to a layout that uses eval - evalScope, // locals in scope when the partial was invoked - partialMap) { - this.slots = slots; - this.callerScope = callerScope; - this.evalScope = evalScope; - this.partialMap = partialMap; + _exports.CapturedPositionalArgumentsImpl = CapturedPositionalArgumentsImpl; + + class NamedArgumentsImpl { + constructor() { + this.base = 0; + this.length = 0; + this._references = null; + this._names = _util.EMPTY_ARRAY; + this._atNames = _util.EMPTY_ARRAY; + } + + empty(stack, base) { + this.stack = stack; + this.base = base; + this.length = 0; + this._references = _util.EMPTY_ARRAY; + this._names = _util.EMPTY_ARRAY; + this._atNames = _util.EMPTY_ARRAY; } - static root(self, size = 0) { - var refs = new Array(size + 1); + setup(stack, base, length, names, atNames) { + this.stack = stack; + this.base = base; + this.length = length; - for (var i = 0; i <= size; i++) { - refs[i] = UNDEFINED_REFERENCE; + if (length === 0) { + this._references = _util.EMPTY_ARRAY; + this._names = _util.EMPTY_ARRAY; + this._atNames = _util.EMPTY_ARRAY; + } else { + this._references = null; + + if (atNames) { + this._names = null; + this._atNames = names; + } else { + this._names = names; + this._atNames = null; + } } + } - return new Scope(refs, null, null, null).init({ - self - }); + get tag() { + return combineTagged(this.references); } - static sized(size = 0) { - var refs = new Array(size + 1); + get names() { + var names = this._names; - for (var i = 0; i <= size; i++) { - refs[i] = UNDEFINED_REFERENCE; + if (!names) { + names = this._names = this._atNames.map(this.toSyntheticName); } - return new Scope(refs, null, null, null); + return names; } - init({ - self - }) { - this.slots[0] = self; - return this; - } + get atNames() { + var atNames = this._atNames; - getSelf() { - return this.get(0); - } + if (!atNames) { + atNames = this._atNames = this._names.map(this.toAtName); + } - getSymbol(symbol) { - return this.get(symbol); + return atNames; } - getBlock(symbol) { - var block = this.get(symbol); - return block === UNDEFINED_REFERENCE ? null : block; + has(name) { + return this.names.indexOf(name) !== -1; } - getEvalScope() { - return this.evalScope; - } + get(name, atNames = false) { + var { + base, + stack + } = this; + var names = atNames ? this.atNames : this.names; + var idx = names.indexOf(name); - getPartialMap() { - return this.partialMap; - } + if (idx === -1) { + return UNDEFINED_REFERENCE; + } - bind(symbol, value$$1) { - this.set(symbol, value$$1); + return stack.get(idx, base); } - bindSelf(self) { - this.set(0, self); + capture() { + return new CapturedNamedArgumentsImpl(this.tag, this.names, this.references); } - bindSymbol(symbol, value$$1) { - this.set(symbol, value$$1); - } + merge(other) { + var { + length: extras + } = other; - bindBlock(symbol, value$$1) { - this.set(symbol, value$$1); - } + if (extras > 0) { + var { + names, + length, + stack + } = this; + var { + names: extraNames + } = other; - bindEvalScope(map) { - this.evalScope = map; - } + if (Object.isFrozen(names) && names.length === 0) { + names = []; + } - bindPartialMap(map) { - this.partialMap = map; - } + for (var i = 0; i < extras; i++) { + var _name7 = extraNames[i]; + var idx = names.indexOf(_name7); - bindCallerScope(scope) { - this.callerScope = scope; - } + if (idx === -1) { + length = names.push(_name7); + stack.push(other.references[i]); + } + } - getCallerScope() { - return this.callerScope; + this.length = length; + this._references = null; + this._names = names; + this._atNames = null; + } } - child() { - return new Scope(this.slots.slice(), this.callerScope, this.evalScope, this.partialMap); - } + get references() { + var references = this._references; - get(index) { - if (index >= this.slots.length) { - throw new RangeError("BUG: cannot get $" + index + " from scope; length=" + this.slots.length); + if (!references) { + var { + base, + length, + stack + } = this; + references = this._references = stack.sliceArray(base, base + length); } - return this.slots[index]; + return references; } - set(index, value$$1) { - if (index >= this.slots.length) { - throw new RangeError("BUG: cannot get $" + index + " from scope; length=" + this.slots.length); - } + toSyntheticName(name) { + return name.slice(1); + } - this.slots[index] = value$$1; + toAtName(name) { + return `@${name}`; } } - _exports.Scope = Scope; - - class Transaction { - constructor() { - this.scheduledInstallManagers = []; - this.scheduledInstallModifiers = []; - this.scheduledUpdateModifierManagers = []; - this.scheduledUpdateModifiers = []; - this.createdComponents = []; - this.createdManagers = []; - this.updatedComponents = []; - this.updatedManagers = []; - this.destructors = []; + class CapturedNamedArgumentsImpl { + constructor(tag, names, references) { + this.tag = tag; + this.names = names; + this.references = references; + this.length = names.length; + this._map = null; } - didCreate(component, manager) { - this.createdComponents.push(component); - this.createdManagers.push(manager); - } + get map() { + var map = this._map; - didUpdate(component, manager) { - this.updatedComponents.push(component); - this.updatedManagers.push(manager); - } + if (!map) { + var { + names, + references + } = this; + map = this._map = (0, _util.dict)(); - scheduleInstallModifier(modifier, manager) { - this.scheduledInstallModifiers.push(modifier); - this.scheduledInstallManagers.push(manager); - } + for (var i = 0; i < names.length; i++) { + var _name8 = names[i]; + map[_name8] = references[i]; + } + } - scheduleUpdateModifier(modifier, manager) { - this.scheduledUpdateModifiers.push(modifier); - this.scheduledUpdateModifierManagers.push(manager); + return map; } - didDestroy(d) { - this.destructors.push(d); + has(name) { + return this.names.indexOf(name) !== -1; } - commit() { + get(name) { var { - createdComponents, - createdManagers + names, + references } = this; + var idx = names.indexOf(name); - for (var i = 0; i < createdComponents.length; i++) { - var component = createdComponents[i]; - var manager = createdManagers[i]; - manager.didCreate(component); + if (idx === -1) { + return UNDEFINED_REFERENCE; + } else { + return references[idx]; } + } + value() { var { - updatedComponents, - updatedManagers + names, + references } = this; + var out = (0, _util.dict)(); - for (var _i4 = 0; _i4 < updatedComponents.length; _i4++) { - var _component = updatedComponents[_i4]; - var _manager2 = updatedManagers[_i4]; - - _manager2.didUpdate(_component); + for (var i = 0; i < names.length; i++) { + var _name9 = names[i]; + out[_name9] = references[i].value(); } - var { - destructors - } = this; - - for (var _i5 = 0; _i5 < destructors.length; _i5++) { - destructors[_i5].destroy(); - } + return out; + } - var { - scheduledInstallManagers, - scheduledInstallModifiers - } = this; + } - for (var _i6 = 0; _i6 < scheduledInstallManagers.length; _i6++) { - var modifier = scheduledInstallModifiers[_i6]; - var _manager3 = scheduledInstallManagers[_i6]; + _exports.CapturedNamedArgumentsImpl = CapturedNamedArgumentsImpl; - _manager3.install(modifier); - } + class BlockArgumentsImpl { + constructor() { + this.internalValues = null; + this.internalTag = null; + this.names = _util.EMPTY_ARRAY; + this.length = 0; + this.base = 0; + } - var { - scheduledUpdateModifierManagers, - scheduledUpdateModifiers - } = this; + empty(stack, base) { + this.stack = stack; + this.names = _util.EMPTY_ARRAY; + this.base = base; + this.length = 0; + this.internalTag = _validator.CONSTANT_TAG; + this.internalValues = _util.EMPTY_ARRAY; + } - for (var _i7 = 0; _i7 < scheduledUpdateModifierManagers.length; _i7++) { - var _modifier = scheduledUpdateModifiers[_i7]; - var _manager4 = scheduledUpdateModifierManagers[_i7]; + setup(stack, base, length, names) { + this.stack = stack; + this.names = names; + this.base = base; + this.length = length; - _manager4.update(_modifier); + if (length === 0) { + this.internalTag = _validator.CONSTANT_TAG; + this.internalValues = _util.EMPTY_ARRAY; + } else { + this.internalTag = null; + this.internalValues = null; } } - } + get values() { + var values = this.internalValues; - class Environment { - constructor({ - appendOperations, - updateOperations - }) { - this._transaction = null; - this.appendOperations = appendOperations; - this.updateOperations = updateOperations; - } + if (!values) { + var { + base, + length, + stack + } = this; + values = this.internalValues = stack.sliceArray(base, base + length * 3); + } - toConditionalReference(reference) { - return new ConditionalReference(reference); + return values; } - getAppendOperations() { - return this.appendOperations; + has(name) { + return this.names.indexOf(name) !== -1; } - getDOM() { - return this.updateOperations; - } + get(name) { + var idx = this.names.indexOf(name); - begin() { - this._transaction = new Transaction(); - } + if (idx === -1) { + return null; + } - get transaction() { - return this._transaction; + var { + base, + stack + } = this; + var table = stack.get(idx * 3, base); + var scope = stack.get(idx * 3 + 1, base); + var handle = stack.get(idx * 3 + 2, base); + return handle === null ? null : [handle, scope, table]; } - didCreate(component, manager) { - this.transaction.didCreate(component, manager); + capture() { + return new CapturedBlockArgumentsImpl(this.names, this.values); } - didUpdate(component, manager) { - this.transaction.didUpdate(component, manager); - } + } - scheduleInstallModifier(modifier, manager) { - this.transaction.scheduleInstallModifier(modifier, manager); + class CapturedBlockArgumentsImpl { + constructor(names, values) { + this.names = names; + this.values = values; + this.length = names.length; } - scheduleUpdateModifier(modifier, manager) { - this.transaction.scheduleUpdateModifier(modifier, manager); + has(name) { + return this.names.indexOf(name) !== -1; } - didDestroy(d) { - this.transaction.didDestroy(d); + get(name) { + var idx = this.names.indexOf(name); + if (idx === -1) return null; + return [this.values[idx * 3 + 2], this.values[idx * 3 + 1], this.values[idx * 3]]; } - commit() { - var transaction = this.transaction; - this._transaction = null; - transaction.commit(); + } + + class CapturedArgumentsImpl { + constructor(tag, positional, named, length) { + this.tag = tag; + this.positional = positional; + this.named = named; + this.length = length; } - attributeFor(element, attr, _isTrusting, namespace = null) { - return dynamicAttribute(element, attr, namespace); + value() { + return { + named: this.named.value(), + positional: this.positional.value() + }; } } - _exports.Environment = Environment; - - class DefaultEnvironment extends Environment { - constructor(options) { - if (!options) { - var _document = window.document; - var appendOperations = new DOMTreeConstruction(_document); - var updateOperations = new DOMChanges(_document); - options = { - appendOperations, - updateOperations - }; - } - - super(options); - } + _exports.CapturedArgumentsImpl = CapturedArgumentsImpl; + var EMPTY_NAMED = new CapturedNamedArgumentsImpl(_validator.CONSTANT_TAG, _util.EMPTY_ARRAY, _util.EMPTY_ARRAY); + var EMPTY_POSITIONAL = new CapturedPositionalArgumentsImpl(_validator.CONSTANT_TAG, _util.EMPTY_ARRAY); + var EMPTY_ARGS = new CapturedArgumentsImpl(_validator.CONSTANT_TAG, EMPTY_POSITIONAL, EMPTY_NAMED, 0); + _exports.EMPTY_ARGS = EMPTY_ARGS; + function initializeRegistersWithSP(sp) { + return [0, -1, sp, 0]; } - _exports.DefaultEnvironment = DefaultEnvironment; - class LowLevelVM { - constructor(stack, heap, program, externs, pc = -1, ra = -1) { + constructor(stack, heap, program, externs, registers) { this.stack = stack; this.heap = heap; this.program = program; this.externs = externs; - this.pc = pc; - this.ra = ra; + this.registers = registers; this.currentOpSize = 0; + } + + fetchRegister(register) { + return this.registers[register]; + } + + loadRegister(register, value$$1) { + this.registers[register] = value$$1; + } + + setPc(pc) { + this.registers[_vm2.$pc] = pc; } // Start a new frame and save $ra and $fp on the stack pushFrame() { - this.stack.push(this.ra); - this.stack.push(this.stack.fp); - this.stack.fp = this.stack.sp - 1; + this.stack.push(this.registers[_vm2.$ra]); + this.stack.push(this.registers[_vm2.$fp]); + this.registers[_vm2.$fp] = this.registers[_vm2.$sp] - 1; } // Restore $ra, $sp and $fp popFrame() { - this.stack.sp = this.stack.fp - 1; - this.ra = this.stack.get(0); - this.stack.fp = this.stack.get(1); + this.registers[_vm2.$sp] = this.registers[_vm2.$fp] - 1; + this.registers[_vm2.$ra] = this.stack.get(0); + this.registers[_vm2.$fp] = this.stack.get(1); } pushSmallFrame() { - this.stack.push(this.ra); + this.stack.push(this.registers[_vm2.$ra]); } popSmallFrame() { - this.ra = this.stack.popSmi(); + this.registers[_vm2.$ra] = this.stack.pop(); } // Jump to an address in `program` goto(offset) { - var addr = this.pc + offset - this.currentOpSize; - this.pc = addr; + this.setPc(this.target(offset)); + } + + target(offset) { + return this.registers[_vm2.$pc] + offset - this.currentOpSize; } // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS) call(handle) { - this.ra = this.pc; - this.pc = this.heap.getaddr(handle); + this.registers[_vm2.$ra] = this.registers[_vm2.$pc]; + this.setPc(this.heap.getaddr(handle)); } // Put a specific `program` address in $ra returnTo(offset) { - var addr = this.pc + offset - this.currentOpSize; - this.ra = addr; + this.registers[_vm2.$ra] = this.target(offset); } // Return to the `program` address stored in $ra return() { - this.pc = this.ra; + this.setPc(this.registers[_vm2.$ra]); } nextStatement() { var { - pc, + registers, program } = this; + var pc = registers[_vm2.$pc]; if (pc === -1) { return null; @@ -51870,12 +53517,10 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ // program counter to the next instruction prior to executing. - var { - size - } = this.program.opcode(pc); - var operationSize = this.currentOpSize = size; - this.pc += operationSize; - return program.opcode(pc); + var opcode = program.opcode(pc); + var operationSize = this.currentOpSize = opcode.size; + this.registers[_vm2.$pc] += operationSize; + return opcode; } evaluateOuter(opcode, vm) { @@ -51894,47 +53539,37 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ evaluateMachine(opcode) { switch (opcode.type) { - case 57 + case 0 /* PushFrame */ : return this.pushFrame(); - case 58 + case 1 /* PopFrame */ : return this.popFrame(); - case 59 - /* PushSmallFrame */ - : - return this.pushSmallFrame(); - - case 60 - /* PopSmallFrame */ - : - return this.popSmallFrame(); - - case 50 + case 3 /* InvokeStatic */ : return this.call(opcode.op1); - case 49 + case 2 /* InvokeVirtual */ : - return this.call(this.stack.popSmi()); + return this.call(this.stack.pop()); - case 52 + case 4 /* Jump */ : return this.goto(opcode.op1); - case 24 + case 5 /* Return */ : return this.return(); - case 25 + case 6 /* ReturnTo */ : return this.returnTo(opcode.op1); @@ -51947,2881 +53582,3225 @@ define("@glimmer/runtime", ["exports", "@glimmer/util", "@glimmer/reference", "@ } - class First { - constructor(node) { - this.node = node; + class UpdatingVM { + constructor(env, { + alwaysRevalidate = false + }) { + this.frameStack = new _util.Stack(); + this.env = env; + this.dom = env.getDOM(); + this.alwaysRevalidate = alwaysRevalidate; + } + + execute(opcodes, handler) { + var { + frameStack + } = this; + this.try(opcodes, handler); + + while (true) { + if (frameStack.isEmpty()) break; + var opcode = this.frame.nextStatement(); + + if (opcode === null) { + frameStack.pop(); + continue; + } + + opcode.evaluate(this); + } + } + + get frame() { + return this.frameStack.current; + } + + goto(op) { + this.frame.goto(op); + } + + try(ops, handler) { + this.frameStack.push(new UpdatingVMFrame(ops, handler)); + } + + throw() { + this.frame.handleException(); + this.frameStack.pop(); + } + + } + + _exports.UpdatingVM = UpdatingVM; + + class ResumableVMStateImpl { + constructor(state, resumeCallback) { + this.state = state; + this.resumeCallback = resumeCallback; + } + + resume(runtime, builder) { + return this.resumeCallback(runtime, this.state, builder); + } + + } + + class BlockOpcode extends UpdatingOpcode { + constructor(state, runtime, bounds, children) { + super(); + this.state = state; + this.runtime = runtime; + this.type = 'block'; + this.next = null; + this.prev = null; + this.children = children; + this.bounds = bounds; + } + + parentElement() { + return this.bounds.parentElement(); + } + + firstNode() { + return this.bounds.firstNode(); + } + + lastNode() { + return this.bounds.lastNode(); + } + + evaluate(vm) { + vm.try(this.children, null); + } + + } + + class TryOpcode extends BlockOpcode { + constructor(state, runtime, bounds, children) { + super(state, runtime, bounds, children); + this.type = 'try'; + this.tag = this._tag = (0, _validator.createUpdatableTag)(); + } + + didInitializeChildren() { + (0, _validator.update)(this._tag, combineSlice(this.children)); + } + + evaluate(vm) { + vm.try(this.children, this); + } + + handleException() { + var { + state, + bounds, + children, + prev, + next, + runtime + } = this; + legacySyncReset(this, runtime.env); + children.clear(); + asyncReset(this, runtime.env); + var elementStack = NewElementBuilder.resume(runtime.env, bounds); + var vm = state.resume(runtime, elementStack); + var updating = new _util.LinkedList(); + var result = vm.execute(vm => { + vm.pushUpdating(updating); + vm.updateWith(this); + vm.pushUpdating(children); + }); + (0, _util.associate)(this, result.drop); + this.prev = prev; + this.next = next; + } + + } + + class ListRevalidationDelegate { + constructor(opcode, marker) { + this.opcode = opcode; + this.marker = marker; + this.didInsert = false; + this.didDelete = false; + this.map = opcode.map; + this.updating = opcode['children']; + } + + insert(_env, key, item, memo, before) { + var { + map, + opcode, + updating + } = this; + var nextSibling = null; + var reference = null; + reference = map.get(before); + nextSibling = reference !== undefined ? reference['bounds'].firstNode() : this.marker; + var vm = opcode.vmForInsertion(nextSibling); + var tryOpcode = null; + vm.execute(vm => { + tryOpcode = vm.iterate(memo, item); + map.set(key, tryOpcode); + vm.pushUpdating(new _util.LinkedList()); + vm.updateWith(tryOpcode); + vm.pushUpdating(tryOpcode.children); + }); + updating.insertBefore(tryOpcode, reference); + this.didInsert = true; + } + + retain(_env, _key, _item, _memo) {} + + move(_env, key, _item, _memo, before) { + var { + map, + updating + } = this; + var entry = map.get(key); + + if (before === _reference.END) { + move(entry, this.marker); + updating.remove(entry); + updating.append(entry); + } else { + var reference = map.get(before); + move(entry, reference.firstNode()); + updating.remove(entry); + updating.insertBefore(entry, reference); + } + } + + delete(env, key) { + var { + map, + updating + } = this; + var opcode = map.get(key); + detach(opcode, env); + updating.remove(opcode); + map.delete(key); + this.didDelete = true; + } + + done() { + this.opcode.didInitializeChildren(this.didInsert || this.didDelete); + } + + } + + class ListBlockOpcode extends BlockOpcode { + constructor(state, runtime, bounds, children, artifacts) { + super(state, runtime, bounds, children); + this.type = 'list-block'; + this.map = new Map(); + this.lastIterated = _validator.INITIAL; + this.artifacts = artifacts; + + var _tag = this._tag = (0, _validator.createUpdatableTag)(); + + this.tag = (0, _validator.combine)([artifacts.tag, _tag]); } - firstNode() { - return this.node; + didInitializeChildren(listDidChange = true) { + this.lastIterated = (0, _validator.value)(this.artifacts.tag); + + if (listDidChange) { + (0, _validator.update)(this._tag, combineSlice(this.children)); + } } - } + evaluate(vm) { + var { + artifacts, + lastIterated + } = this; - class Last { - constructor(node) { - this.node = node; + if (!(0, _validator.validate)(artifacts.tag, lastIterated)) { + var { + bounds + } = this; + var { + dom + } = vm; + var marker = dom.createComment(''); + dom.insertAfter(bounds.parentElement(), marker, bounds.lastNode()); + var target = new ListRevalidationDelegate(this, marker); + var synchronizer = new _reference.IteratorSynchronizer({ + target, + artifacts, + env: vm.env + }); + synchronizer.sync(); + this.parentElement().removeChild(marker); + } // Run now-updated updating opcodes + + + super.evaluate(vm); } - lastNode() { - return this.node; + vmForInsertion(nextSibling) { + var { + bounds, + state, + runtime + } = this; + var elementStack = NewElementBuilder.forInitialRender(runtime.env, { + element: bounds.parentElement(), + nextSibling + }); + return state.resume(runtime, elementStack); } } - class NewElementBuilder { - constructor(env, parentNode, nextSibling) { - this.constructing = null; - this.operations = null; - this.cursorStack = new _util.Stack(); - this.modifierStack = new _util.Stack(); - this.blockStack = new _util.Stack(); - this.pushElement(parentNode, nextSibling); - this.env = env; - this.dom = env.getAppendOperations(); - this.updateOperations = env.getDOM(); + class UpdatingVMFrame { + constructor(ops, exceptionHandler) { + this.ops = ops; + this.exceptionHandler = exceptionHandler; + this.current = ops.head(); } - static forInitialRender(env, cursor) { - var builder = new this(env, cursor.element, cursor.nextSibling); - builder.pushSimpleBlock(); - return builder; + goto(op) { + this.current = op; } - static resume(env, tracker, nextSibling) { - var parentNode = tracker.parentElement(); - var stack = new this(env, parentNode, nextSibling); - stack.pushSimpleBlock(); - stack.pushBlockTracker(tracker); - return stack; + nextStatement() { + var { + current, + ops + } = this; + if (current) this.current = ops.nextNode(current); + return current; } - get element() { - return this.cursorStack.current.element; + handleException() { + if (this.exceptionHandler) { + this.exceptionHandler.handleException(); + } } - get nextSibling() { - return this.cursorStack.current.nextSibling; - } + } - expectConstructing(method) { - return this.constructing; + class RenderResultImpl { + constructor(env, updating, bounds, drop) { + this.env = env; + this.updating = updating; + this.bounds = bounds; + this.drop = drop; + (0, _util.associate)(this, drop); } - block() { - return this.blockStack.current; + rerender({ + alwaysRevalidate = false + } = { + alwaysRevalidate: false + }) { + var { + env, + updating + } = this; + var vm = new UpdatingVM(env, { + alwaysRevalidate + }); + vm.execute(updating, this); } - popElement() { - this.cursorStack.pop(); - this.cursorStack.current; + parentElement() { + return this.bounds.parentElement(); } - pushSimpleBlock() { - return this.pushBlockTracker(new SimpleBlockTracker(this.element)); + firstNode() { + return this.bounds.firstNode(); } - pushUpdatableBlock() { - return this.pushBlockTracker(new UpdatableBlockTracker(this.element)); + lastNode() { + return this.bounds.lastNode(); } - pushBlockList(list) { - return this.pushBlockTracker(new BlockListTracker(this.element, list)); + handleException() { + throw 'this should never happen'; } - pushBlockTracker(tracker, isRemote = false) { - var current = this.blockStack.current; - - if (current !== null) { - current.newDestroyable(tracker); - - if (!isRemote) { - current.didAppendBounds(tracker); - } - } + [_util.DESTROY]() { + clear(this.bounds); + } // compat, as this is a user-exposed API - this.__openBlock(); - this.blockStack.push(tracker); - return tracker; + destroy() { + inTransaction(this.env, () => { + legacySyncDestroy(this, this.env); + asyncDestroy(this, this.env); + }); } - popBlock() { - this.block().finalize(this); - - this.__closeBlock(); + } - return this.blockStack.pop(); + class InnerStack { + constructor(inner = new _lowLevel.Stack(), js = []) { + this.inner = inner; + this.js = js; } - __openBlock() {} - - __closeBlock() {} // todo return seems unused - + slice(start, end) { + var inner; - openElement(tag) { - var element = this.__openElement(tag); + if (typeof start === 'number' && typeof end === 'number') { + inner = this.inner.slice(start, end); + } else if (typeof start === 'number' && end === undefined) { + inner = this.inner.sliceFrom(start); + } else { + inner = this.inner.clone(); + } - this.constructing = element; - return element; + return new InnerStack(inner, this.js.slice(start, end)); } - __openElement(tag) { - return this.dom.createElement(tag, this.element); - } + sliceInner(start, end) { + var out = []; - flushElement(modifiers) { - var parent = this.element; - var element = this.constructing; + if (start === -1) { + return out; + } - this.__flushElement(parent, element); + for (var i = start; i < end; i++) { + out.push(this.get(i)); + } - this.constructing = null; - this.operations = null; - this.pushModifiers(modifiers); - this.pushElement(element, null); - this.didOpenElement(element); + return out; } - __flushElement(parent, constructing) { - this.dom.insertBefore(parent, constructing, this.nextSibling); + copy(from, to) { + this.inner.copy(from, to); } - closeElement() { - this.willCloseElement(); - this.popElement(); - return this.popModifiers(); - } + write(pos, value$$1) { + switch (typeof value$$1) { + case 'boolean': + case 'undefined': + this.writeRaw(pos, (0, _util.encodeImmediate)(value$$1)); + break; - pushRemoteElement(element, guid, nextSibling = null) { - this.__pushRemoteElement(element, guid, nextSibling); - } + case 'number': + if ((0, _util.isSmallInt)(value$$1)) { + this.writeRaw(pos, (0, _util.encodeImmediate)(value$$1)); + break; + } - __pushRemoteElement(element, _guid, nextSibling) { - this.pushElement(element, nextSibling); - var tracker = new RemoteBlockTracker(element); - this.pushBlockTracker(tracker, true); - } + case 'object': + if (value$$1 === null) { + this.writeRaw(pos, (0, _util.encodeImmediate)(value$$1)); + break; + } - popRemoteElement() { - this.popBlock(); - this.popElement(); + default: + this.writeJs(pos, value$$1); + } } - pushElement(element, nextSibling) { - this.cursorStack.push(new Cursor(element, nextSibling)); + writeJs(pos, value$$1) { + var idx = this.js.length; + this.js.push(value$$1); + this.inner.writeRaw(pos, (0, _util.encodeHandle)(idx)); } - pushModifiers(modifiers) { - this.modifierStack.push(modifiers); + writeRaw(pos, value$$1) { + this.inner.writeRaw(pos, value$$1); } - popModifiers() { - return this.modifierStack.pop(); - } + get(pos) { + var value$$1 = this.inner.getRaw(pos); - didAddDestroyable(d) { - this.block().newDestroyable(d); + if ((0, _util.isHandle)(value$$1)) { + return this.js[(0, _util.decodeHandle)(value$$1)]; + } else { + return (0, _util.decodeImmediate)(value$$1); + } } - didAppendBounds(bounds) { - this.block().didAppendBounds(bounds); - return bounds; + reset() { + this.inner.reset(); + this.js.length = 0; } - didAppendNode(node) { - this.block().didAppendNode(node); - return node; + get length() { + return this.inner.len(); } - didOpenElement(element) { - this.block().openElement(element); - return element; - } + } - willCloseElement() { - this.block().closeElement(); + class EvaluationStackImpl { + // fp -> sp + constructor(stack, registers) { + this.stack = stack; + this[REGISTERS] = registers; } - appendText(string) { - return this.didAppendNode(this.__appendText(string)); - } + static restore(snapshot$$1) { + var stack = new InnerStack(); - __appendText(text) { - var { - dom, - element, - nextSibling - } = this; - var node = dom.createTextNode(text); - dom.insertBefore(element, node, nextSibling); - return node; - } + for (var i = 0; i < snapshot$$1.length; i++) { + stack.write(i, snapshot$$1[i]); + } - __appendNode(node) { - this.dom.insertBefore(this.element, node, this.nextSibling); - return node; + return new this(stack, initializeRegistersWithSP(snapshot$$1.length - 1)); } - __appendFragment(fragment) { - var first = fragment.firstChild; - - if (first) { - var ret = new ConcreteBounds(this.element, first, fragment.lastChild); - this.dom.insertBefore(this.element, fragment, this.nextSibling); - return ret; - } else { - return new SingleNodeBounds(this.element, this.__appendComment('')); - } + push(value$$1) { + this.stack.write(++this[REGISTERS][_vm2.$sp], value$$1); } - __appendHTML(html) { - return this.dom.insertHTMLBefore(this.element, this.nextSibling, html); + pushJs(value$$1) { + this.stack.writeJs(++this[REGISTERS][_vm2.$sp], value$$1); } - appendDynamicHTML(value$$1) { - var bounds = this.trustedContent(value$$1); - this.didAppendBounds(bounds); + pushRaw(value$$1) { + this.stack.writeRaw(++this[REGISTERS][_vm2.$sp], value$$1); } - appendDynamicText(value$$1) { - var node = this.untrustedContent(value$$1); - this.didAppendNode(node); - return node; + dup(position = this[REGISTERS][_vm2.$sp]) { + this.stack.copy(position, ++this[REGISTERS][_vm2.$sp]); } - appendDynamicFragment(value$$1) { - var bounds = this.__appendFragment(value$$1); - - this.didAppendBounds(bounds); + copy(from, to) { + this.stack.copy(from, to); } - appendDynamicNode(value$$1) { - var node = this.__appendNode(value$$1); - - var bounds = new SingleNodeBounds(this.element, node); - this.didAppendBounds(bounds); + pop(n = 1) { + var top = this.stack.get(this[REGISTERS][_vm2.$sp]); + this[REGISTERS][_vm2.$sp] -= n; + return top; } - trustedContent(value$$1) { - return this.__appendHTML(value$$1); + peek(offset = 0) { + return this.stack.get(this[REGISTERS][_vm2.$sp] - offset); } - untrustedContent(value$$1) { - return this.__appendText(value$$1); + get(offset, base = this[REGISTERS][_vm2.$fp]) { + return this.stack.get(base + offset); } - appendComment(string) { - return this.didAppendNode(this.__appendComment(string)); + set(value$$1, offset, base = this[REGISTERS][_vm2.$fp]) { + this.stack.write(base + offset, value$$1); } - __appendComment(string) { - var { - dom, - element, - nextSibling - } = this; - var node = dom.createComment(string); - dom.insertBefore(element, node, nextSibling); - return node; + slice(start, end) { + return this.stack.slice(start, end); } - __setAttribute(name, value$$1, namespace) { - this.dom.setAttribute(this.constructing, name, value$$1, namespace); + sliceArray(start, end) { + return this.stack.sliceInner(start, end); } - __setProperty(name, value$$1) { - this.constructing[name] = value$$1; + capture(items) { + var end = this[REGISTERS][_vm2.$sp] + 1; + var start = end - items; + return this.stack.sliceInner(start, end); } - setStaticAttribute(name, value$$1, namespace) { - this.__setAttribute(name, value$$1, namespace); + reset() { + this.stack.reset(); } - setDynamicAttribute(name, value$$1, trusting, namespace) { - var element = this.constructing; - var attribute = this.env.attributeFor(element, name, trusting, namespace); - attribute.set(this, value$$1, this.env); - return attribute; + toArray() { + console.log(this[REGISTERS]); + return this.stack.sliceInner(this[REGISTERS][_vm2.$fp], this[REGISTERS][_vm2.$sp] + 1); } } - _exports.NewElementBuilder = NewElementBuilder; + var _a$3, _b; - class SimpleBlockTracker { - constructor(parent) { - this.parent = parent; - this.first = null; - this.last = null; - this.destroyables = null; - this.nesting = 0; + class Stacks { + constructor() { + this.scope = new _util.Stack(); + this.dynamicScope = new _util.Stack(); + this.updating = new _util.Stack(); + this.cache = new _util.Stack(); + this.list = new _util.Stack(); } - destroy() { - var { - destroyables - } = this; + } - if (destroyables && destroyables.length) { - for (var i = 0; i < destroyables.length; i++) { - destroyables[i].destroy(); + class VM { + /** + * End of migrated. + */ + constructor(runtime, { + pc, + scope, + dynamicScope, + stack + }, elementStack) { + this.runtime = runtime; + this.elementStack = elementStack; + this[_a$3] = new Stacks(); + this[_b] = new _util.Stack(); + this.s0 = null; + this.s1 = null; + this.t0 = null; + this.t1 = null; + this.v0 = null; + var evalStack = EvaluationStackImpl.restore(stack); + evalStack[REGISTERS][_vm2.$pc] = pc; + evalStack[REGISTERS][_vm2.$sp] = stack.length - 1; + evalStack[REGISTERS][_vm2.$fp] = -1; + this[HEAP] = this.program.heap; + this[CONSTANTS] = this.program.constants; + this.elementStack = elementStack; + this[STACKS].scope.push(scope); + this[STACKS].dynamicScope.push(dynamicScope); + this[ARGS] = new VMArgumentsImpl(); + this[INNER_VM] = new LowLevelVM(evalStack, this[HEAP], runtime.program, { + debugBefore: opcode => { + return APPEND_OPCODES.debugBefore(this, opcode); + }, + debugAfter: state => { + APPEND_OPCODES.debugAfter(this, state); } - } + }, evalStack[REGISTERS]); + this.destructor = {}; + this[DESTRUCTOR_STACK].push(this.destructor); } - parentElement() { - return this.parent; + get stack() { + return this[INNER_VM].stack; } - firstNode() { - var first = this.first; - return first.firstNode(); + currentBlock() { + return this.elements().block(); } + /* Registers */ - lastNode() { - var last = this.last; - return last.lastNode(); - } - openElement(element) { - this.didAppendNode(element); - this.nesting++; - } + get pc() { + return this[INNER_VM].fetchRegister(_vm2.$pc); + } // Fetch a value from a register onto the stack - closeElement() { - this.nesting--; - } - didAppendNode(node) { - if (this.nesting !== 0) return; + fetch(register) { + this.stack.push(this.fetchValue(register)); + } // Load a value from the stack into a register - if (!this.first) { - this.first = new First(node); - } - this.last = new Last(node); + load(register) { + var value$$1 = this.stack.pop(); + this.loadValue(register, value$$1); } - didAppendBounds(bounds) { - if (this.nesting !== 0) return; - - if (!this.first) { - this.first = bounds; + fetchValue(register) { + if ((0, _vm2.isLowLevelRegister)(register)) { + return this[INNER_VM].fetchRegister(register); } - this.last = bounds; - } - - newDestroyable(d) { - this.destroyables = this.destroyables || []; - this.destroyables.push(d); - } + switch (register) { + case _vm2.$s0: + return this.s0; - finalize(stack) { - if (this.first === null) { - stack.appendComment(''); - } - } + case _vm2.$s1: + return this.s1; - } + case _vm2.$t0: + return this.t0; - class RemoteBlockTracker extends SimpleBlockTracker { - destroy() { - super.destroy(); - clear(this); - } + case _vm2.$t1: + return this.t1; - } + case _vm2.$v0: + return this.v0; + } + } // Load a value into a register - class UpdatableBlockTracker extends SimpleBlockTracker { - reset(env) { - var { - destroyables - } = this; - if (destroyables && destroyables.length) { - for (var i = 0; i < destroyables.length; i++) { - env.didDestroy(destroyables[i]); - } + loadValue(register, value$$1) { + if ((0, _vm2.isLowLevelRegister)(register)) { + this[INNER_VM].loadRegister(register, value$$1); } - var nextSibling = clear(this); - this.first = null; - this.last = null; - this.destroyables = null; - this.nesting = 0; - return nextSibling; - } + switch (register) { + case _vm2.$s0: + this.s0 = value$$1; + break; - } + case _vm2.$s1: + this.s1 = value$$1; + break; - class BlockListTracker { - constructor(parent, boundList) { - this.parent = parent; - this.boundList = boundList; - this.parent = parent; - this.boundList = boundList; - } + case _vm2.$t0: + this.t0 = value$$1; + break; - destroy() { - this.boundList.forEachNode(node => node.destroy()); - } + case _vm2.$t1: + this.t1 = value$$1; + break; - parentElement() { - return this.parent; + case _vm2.$v0: + this.v0 = value$$1; + break; + } } + /** + * Migrated to Inner + */ + // Start a new frame and save $ra and $fp on the stack - firstNode() { - var head = this.boundList.head(); - return head.firstNode(); - } - lastNode() { - var tail = this.boundList.tail(); - return tail.lastNode(); - } + pushFrame() { + this[INNER_VM].pushFrame(); + } // Restore $ra, $sp and $fp - openElement(_element) {} - closeElement() {} + popFrame() { + this[INNER_VM].popFrame(); + } // Jump to an address in `program` - didAppendNode(_node) {} - didAppendBounds(_bounds) {} + goto(offset) { + this[INNER_VM].goto(offset); + } // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS) - newDestroyable(_d) {} - finalize(_stack) {} + call(handle) { + this[INNER_VM].call(handle); + } // Put a specific `program` address in $ra - } - function clientBuilder(env, cursor) { - return NewElementBuilder.forInitialRender(env, cursor); - } + returnTo(offset) { + this[INNER_VM].returnTo(offset); + } // Return to the `program` address stored in $ra - var MAX_SMI = 0xfffffff; - class InnerStack { - constructor(inner = new _lowLevel.Stack(), js = []) { - this.inner = inner; - this.js = js; + return() { + this[INNER_VM].return(); } - slice(start, end) { - var inner; - - if (typeof start === 'number' && typeof end === 'number') { - inner = this.inner.slice(start, end); - } else if (typeof start === 'number' && end === undefined) { - inner = this.inner.sliceFrom(start); - } else { - inner = this.inner.clone(); - } - - return new InnerStack(inner, this.js.slice(start, end)); + get program() { + return this.runtime.program; } - sliceInner(start, end) { - var out = []; - - for (var i = start; i < end; i++) { - out.push(this.get(i)); - } + get env() { + return this.runtime.env; + } - return out; + captureState(args, pc = this[INNER_VM].fetchRegister(_vm2.$pc)) { + return { + pc, + dynamicScope: this.dynamicScope(), + scope: this.scope(), + stack: this.stack.capture(args) + }; } - copy(from, to) { - this.inner.copy(from, to); + beginCacheGroup() { + this[STACKS].cache.push(this.updating().tail()); } - write(pos, value$$1) { - if (isImmediate(value$$1)) { - this.inner.writeRaw(pos, encodeImmediate(value$$1)); - } else { - var idx = this.js.length; - this.js.push(value$$1); - this.inner.writeRaw(pos, ~idx); - } + commitCacheGroup() { + var END$$1 = new LabelOpcode('END'); + var opcodes = this.updating(); + var marker = this[STACKS].cache.pop(); + var head = marker ? opcodes.nextNode(marker) : opcodes.head(); + var tail = opcodes.tail(); + var tag = combineSlice(new _util.ListSlice(head, tail)); + var guard = new JumpIfNotModifiedOpcode(tag, END$$1); + opcodes.insertBefore(guard, head); + opcodes.append(new DidModifyOpcode(guard)); + opcodes.append(END$$1); } - writeRaw(pos, value$$1) { - this.inner.writeRaw(pos, value$$1); + enter(args) { + var updating = new _util.LinkedList(); + var state = this.capture(args); + var block = this.elements().pushUpdatableBlock(); + var tryOpcode = new TryOpcode(state, this.runtime, block, updating); + this.didEnter(tryOpcode); } - get(pos) { - var value$$1 = this.inner.getRaw(pos); + iterate(memo, value$$1) { + var stack = this.stack; + stack.push(value$$1); + stack.push(memo); + var state = this.capture(2); + var block = this.elements().pushUpdatableBlock(); // let ip = this.ip; + // this.ip = end + 4; + // this.frames.push(ip); - if (value$$1 < 0) { - return this.js[~value$$1]; - } else { - return decodeImmediate(value$$1); - } + return new TryOpcode(state, this.runtime, block, new _util.LinkedList()); } - reset() { - this.inner.reset(); - this.js.length = 0; + enterItem(key, opcode) { + this.listBlock().map.set(key, opcode); + this.didEnter(opcode); } - get length() { - return this.inner.len(); + enterList(offset) { + var updating = new _util.LinkedList(); + var addr = this[INNER_VM].target(offset); + var state = this.capture(0, addr); + var list = this.elements().pushBlockList(updating); + var artifacts = this.stack.peek().artifacts; + var opcode = new ListBlockOpcode(state, this.runtime, list, updating, artifacts); + this[STACKS].list.push(opcode); + this.didEnter(opcode); } - } - - class EvaluationStack { - constructor(stack, fp, sp) { - this.stack = stack; - this.fp = fp; - this.sp = sp; + didEnter(opcode) { + this.associateDestructor((0, _util.destructor)(opcode)); + this[DESTRUCTOR_STACK].push(opcode); + this.updateWith(opcode); + this.pushUpdating(opcode.children); } - static empty() { - return new this(new InnerStack(), 0, -1); + exit() { + this[DESTRUCTOR_STACK].pop(); + this.elements().popBlock(); + this.popUpdating(); + var parent = this.updating().tail(); + parent.didInitializeChildren(); } - static restore(snapshot) { - var stack = new InnerStack(); - - for (var i = 0; i < snapshot.length; i++) { - stack.write(i, snapshot[i]); - } + exitList() { + this.exit(); + this[STACKS].list.pop(); + } - return new this(stack, 0, snapshot.length - 1); + pushUpdating(list = new _util.LinkedList()) { + this[STACKS].updating.push(list); } - push(value$$1) { - this.stack.write(++this.sp, value$$1); + popUpdating() { + return this[STACKS].updating.pop(); } - pushEncodedImmediate(value$$1) { - this.stack.writeRaw(++this.sp, value$$1); + updateWith(opcode) { + this.updating().append(opcode); } - pushNull() { - this.stack.write(++this.sp, null); + listBlock() { + return this[STACKS].list.current; } - dup(position = this.sp) { - this.stack.copy(position, ++this.sp); + associateDestructor(child) { + if (!(0, _util.isDrop)(child)) return; + var parent = this[DESTRUCTOR_STACK].current; + (0, _util.associateDestructor)(parent, child); } - copy(from, to) { - this.stack.copy(from, to); + associateDestroyable(child) { + this.associateDestructor((0, _util.destructor)(child)); } - pop(n = 1) { - var top = this.stack.get(this.sp); - this.sp -= n; - return top; + tryUpdating() { + return this[STACKS].updating.current; } - popSmi() { - return this.stack.get(this.sp--); + updating() { + return this[STACKS].updating.current; } - peek(offset = 0) { - return this.stack.get(this.sp - offset); + elements() { + return this.elementStack; } - get(offset, base = this.fp) { - return this.stack.get(base + offset); + scope() { + return this[STACKS].scope.current; } - set(value$$1, offset, base = this.fp) { - this.stack.write(base + offset, value$$1); + dynamicScope() { + return this[STACKS].dynamicScope.current; } - slice(start, end) { - return this.stack.slice(start, end); + pushChildScope() { + this[STACKS].scope.push(this.scope().child()); } - sliceArray(start, end) { - return this.stack.sliceInner(start, end); + pushDynamicScope() { + var child = this.dynamicScope().child(); + this[STACKS].dynamicScope.push(child); + return child; } - capture(items) { - var end = this.sp + 1; - var start = end - items; - return this.stack.sliceInner(start, end); + pushRootScope(size) { + var scope = ScopeImpl.sized(size); + this[STACKS].scope.push(scope); + return scope; } - reset() { - this.stack.reset(); + pushScope(scope) { + this[STACKS].scope.push(scope); } - toArray() { - return this.stack.sliceInner(this.fp, this.sp + 1); + popScope() { + this[STACKS].scope.pop(); } - } + popDynamicScope() { + this[STACKS].dynamicScope.pop(); + } /// SCOPE HELPERS - function isImmediate(value$$1) { - var type = typeof value$$1; - if (value$$1 === null || value$$1 === undefined) return true; - switch (type) { - case 'boolean': - case 'undefined': - return true; + getSelf() { + return this.scope().getSelf(); + } - case 'number': - // not an integer - if (value$$1 % 1 !== 0) return false; - var abs = Math.abs(value$$1); - if (abs > MAX_SMI) return false; - return true; + referenceForSymbol(symbol$$1) { + return this.scope().getSymbol(symbol$$1); + } /// EXECUTION - default: - return false; - } - } - function encodeSmi(primitive) { - if (primitive < 0) { - var abs = Math.abs(primitive); - if (abs > MAX_SMI) throw new Error('not smi'); - return Math.abs(primitive) << 3 | 4 - /* NEGATIVE */ - ; - } else { - if (primitive > MAX_SMI) throw new Error('not smi'); - return primitive << 3 | 0 - /* NUMBER */ - ; - } - } + execute(initialize) { + if (initialize) initialize(this); + var result; - function encodeImmediate(primitive) { - switch (typeof primitive) { - case 'number': - return encodeSmi(primitive); + while (true) { + result = this.next(); + if (result.done) break; + } - case 'boolean': - return primitive ? 11 - /* True */ - : 3 - /* False */ - ; + return result.value; + } - case 'object': - // assume null - return 19 - /* Null */ - ; + next() { + var { + env, + elementStack + } = this; + var opcode = this[INNER_VM].nextStatement(); + var result; - case 'undefined': - return 27 - /* Undef */ - ; + if (opcode !== null) { + this[INNER_VM].evaluateOuter(opcode, this); + result = { + done: false, + value: null + }; + } else { + // Unload the stack + this.stack.reset(); + result = { + done: true, + value: new RenderResultImpl(env, this.popUpdating(), elementStack.popBlock(), this.destructor) + }; + } - default: - throw (0, _util.unreachable)(); + return result; } - } - function decodeSmi(smi) { - switch (smi & 0b111) { - case 0 - /* NUMBER */ - : - return smi >> 3; + bindDynamicScope(names) { + var scope = this.dynamicScope(); - case 4 - /* NEGATIVE */ - : - return -(smi >> 3); + for (var i = names.length - 1; i >= 0; i--) { + var _name10 = this[CONSTANTS].getString(names[i]); - default: - throw (0, _util.unreachable)(); + scope.set(_name10, this.stack.pop()); + } } - } - - function decodeImmediate(immediate) { - switch (immediate) { - case 3 - /* False */ - : - return false; - case 11 - /* True */ - : - return true; + } - case 19 - /* Null */ - : - return null; + _exports.LowLevelVM = VM; + _a$3 = STACKS, _b = DESTRUCTOR_STACK; - case 27 - /* Undef */ - : - return undefined; + function vmState(pc, scope = ScopeImpl.root(UNDEFINED_REFERENCE, 0), dynamicScope) { + return { + pc, + scope, + dynamicScope, + stack: [] + }; + } - default: - return decodeSmi(immediate); + class AotVM extends VM { + static empty(runtime, { + handle, + treeBuilder, + dynamicScope + }) { + var vm = initAOT(runtime, vmState(runtime.program.heap.getaddr(handle), ScopeImpl.root(UNDEFINED_REFERENCE, 0), dynamicScope), treeBuilder); + vm.pushUpdating(); + return vm; } - } - class UpdatingVM { - constructor(env, program, { - alwaysRevalidate = false + static initial(runtime, { + handle, + self, + treeBuilder, + dynamicScope }) { - this.frameStack = new _util.Stack(); - this.env = env; - this.constants = program.constants; - this.dom = env.getDOM(); - this.alwaysRevalidate = alwaysRevalidate; + var scopeSize = runtime.program.heap.scopesizeof(handle); + var scope = ScopeImpl.root(self, scopeSize); + var pc = runtime.program.heap.getaddr(handle); + var state = vmState(pc, scope, dynamicScope); + var vm = initAOT(runtime, state, treeBuilder); + vm.pushUpdating(); + return vm; } - execute(opcodes, handler) { - var { - frameStack - } = this; - this.try(opcodes, handler); + capture(args, pc = this[INNER_VM].fetchRegister(_vm2.$pc)) { + return new ResumableVMStateImpl(this.captureState(args, pc), initAOT); + } - while (true) { - if (frameStack.isEmpty()) break; - var opcode = this.frame.nextStatement(); + } - if (opcode === null) { - this.frameStack.pop(); - continue; - } + function initAOT(runtime, state, builder) { + return new AotVM(runtime, state, builder); + } - opcode.evaluate(this); - } + function initJIT(context) { + return (runtime, state, builder) => new JitVM(runtime, state, builder, context); + } + + class JitVM extends VM { + constructor(runtime, state, elementStack, context) { + super(runtime, state, elementStack); + this.context = context; + this.resume = initJIT(this.context); } - get frame() { - return this.frameStack.current; + static initial(runtime, context, { + handle, + self, + dynamicScope, + treeBuilder + }) { + var scopeSize = runtime.program.heap.scopesizeof(handle); + var scope = ScopeImpl.root(self, scopeSize); + var state = vmState(runtime.program.heap.getaddr(handle), scope, dynamicScope); + var vm = initJIT(context)(runtime, state, treeBuilder); + vm.pushUpdating(); + return vm; } - goto(op) { - this.frame.goto(op); + static empty(runtime, { + handle, + treeBuilder, + dynamicScope + }, context) { + var vm = initJIT(context)(runtime, vmState(runtime.program.heap.getaddr(handle), ScopeImpl.root(UNDEFINED_REFERENCE, 0), dynamicScope), treeBuilder); + vm.pushUpdating(); + return vm; } - try(ops, handler) { - this.frameStack.push(new UpdatingVMFrame(ops, handler)); + capture(args, pc = this[INNER_VM].fetchRegister(_vm2.$pc)) { + return new ResumableVMStateImpl(this.captureState(args, pc), this.resume); } - throw() { - this.frame.handleException(); - this.frameStack.pop(); + compile(block) { + var handle = (0, _opcodeCompiler.unwrapHandle)(block.compile(this.context)); + return handle; } } - _exports.UpdatingVM = UpdatingVM; - - class BlockOpcode extends UpdatingOpcode { - constructor(start, state, runtime, bounds, children) { - super(); - this.start = start; - this.state = state; - this.runtime = runtime; - this.type = 'block'; - this.next = null; - this.prev = null; - this.children = children; - this.bounds = bounds; + class TemplateIteratorImpl { + constructor(vm) { + this.vm = vm; } - parentElement() { - return this.bounds.parentElement(); + next() { + return this.vm.next(); } - firstNode() { - return this.bounds.firstNode(); + sync() { + return renderSync(this.vm.runtime.env, this); } - lastNode() { - return this.bounds.lastNode(); - } + } - evaluate(vm) { - vm.try(this.children, null); - } + function renderSync(env, iterator) { + env.begin(); + var iteratorResult; - destroy() { - this.bounds.destroy(); - } + do { + iteratorResult = iterator.next(); + } while (!iteratorResult.done); - didDestroy() { - this.runtime.env.didDestroy(this.bounds); - } + var result = iteratorResult.value; + env.commit(); + return result; + } + function renderAotMain(runtime, self, treeBuilder, handle, dynamicScope = new DefaultDynamicScope()) { + var vm = AotVM.initial(runtime, { + self, + dynamicScope, + treeBuilder, + handle + }); + return new TemplateIteratorImpl(vm); } - class TryOpcode extends BlockOpcode { - constructor(start, state, runtime, bounds, children) { - super(start, state, runtime, bounds, children); - this.type = 'try'; - this.tag = this._tag = (0, _reference2.createUpdatableTag)(); - } + function renderAot(runtime, handle, cursor, self = UNDEFINED_REFERENCE) { + var treeBuilder = NewElementBuilder.forInitialRender(runtime.env, cursor); + var dynamicScope = new DefaultDynamicScope(); + var vm = AotVM.initial(runtime, { + self, + dynamicScope, + treeBuilder, + handle + }); + return new TemplateIteratorImpl(vm); + } - didInitializeChildren() { - (0, _reference2.update)(this._tag, (0, _reference2.combineSlice)(this.children)); - } + function renderJitMain(runtime, context, self, treeBuilder, handle, dynamicScope = new DefaultDynamicScope()) { + var vm = JitVM.initial(runtime, context, { + self, + dynamicScope, + treeBuilder, + handle + }); + return new TemplateIteratorImpl(vm); + } - evaluate(vm) { - vm.try(this.children, this); - } + function renderInvocation(vm, invocation, definition, args) { + // Get a list of tuples of argument names and references, like + // [['title', reference], ['name', reference]] + var argList = Object.keys(args).map(key => [key, args[key]]); + var blockNames = ['main', 'else', 'attrs']; // Prefix argument names with `@` symbol - handleException() { - var { - state, - bounds, - children, - start, - prev, - next, - runtime - } = this; - children.clear(); - var elementStack = NewElementBuilder.resume(runtime.env, bounds, bounds.reset(runtime.env)); - var vm = VM.resume(state, runtime, elementStack); - var updating = new _util.LinkedList(); - vm.execute(start, vm => { - vm.stack = EvaluationStack.restore(state.stack); - vm.updatingOpcodeStack.push(updating); - vm.updateWith(this); - vm.updatingOpcodeStack.push(children); - }); - this.prev = prev; - this.next = next; + var argNames = argList.map(([name]) => `@${name}`); + vm.pushFrame(); // Push blocks on to the stack, three stack values per block + + for (var i = 0; i < 3 * blockNames.length; i++) { + vm.stack.push(null); } - } + vm.stack.push(null); // For each argument, push its backing reference on to the stack - class ListRevalidationDelegate { - constructor(opcode, marker) { - this.opcode = opcode; - this.marker = marker; - this.didInsert = false; - this.didDelete = false; - this.map = opcode.map; - this.updating = opcode['children']; - } + argList.forEach(([, reference]) => { + vm.stack.push(reference); + }); // Configure VM based on blocks and args just pushed on to the stack. - insert(key, item, memo, before) { - var { - map, - opcode, - updating - } = this; - var nextSibling = null; - var reference = null; + vm[ARGS].setup(vm.stack, argNames, blockNames, 0, true); // Needed for the Op.Main opcode: arguments, component invocation object, and + // component definition. - if (typeof before === 'string') { - reference = map[before]; - nextSibling = reference['bounds'].firstNode(); - } else { - nextSibling = this.marker; - } + vm.stack.push(vm[ARGS]); + vm.stack.push(invocation); + vm.stack.push(definition); + return new TemplateIteratorImpl(vm); + } - var vm = opcode.vmForInsertion(nextSibling); - var tryOpcode = null; - var { - start - } = opcode; - vm.execute(start, vm => { - map[key] = tryOpcode = vm.iterate(memo, item); - vm.updatingOpcodeStack.push(new _util.LinkedList()); - vm.updateWith(tryOpcode); - vm.updatingOpcodeStack.push(tryOpcode.children); - }); - updating.insertBefore(tryOpcode, reference); - this.didInsert = true; + function renderAotComponent(runtime, treeBuilder, main, name, args = {}, dynamicScope = new DefaultDynamicScope()) { + var vm = AotVM.empty(runtime, { + treeBuilder, + handle: main, + dynamicScope + }); + var definition = resolveComponent(vm.runtime.resolver, name); + var { + manager, + state + } = definition; + var capabilities = capabilityFlagsFrom(manager.getCapabilities(state)); + var invocation; + + if (hasStaticLayoutCapability(capabilities, manager)) { + invocation = manager.getAotStaticLayout(state, vm.runtime.resolver); + } else { + throw new Error('Cannot invoke components with dynamic layouts as a root component.'); } - retain(_key, _item, _memo) {} + return renderInvocation(vm, invocation, definition, args); + } + + function renderJitComponent(runtime, treeBuilder, context, main, name, args = {}, dynamicScope = new DefaultDynamicScope()) { + var vm = JitVM.empty(runtime, { + treeBuilder, + handle: main, + dynamicScope + }, context); + var definition = resolveComponent(vm.runtime.resolver, name); + var { + manager, + state + } = definition; + var capabilities = capabilityFlagsFrom(manager.getCapabilities(state)); + var invocation; - move(key, _item, _memo, before) { - var { - map, - updating - } = this; - var entry = map[key]; - var reference = map[before] || null; + if (hasStaticLayoutCapability(capabilities, manager)) { + var layout = manager.getJitStaticLayout(state, vm.runtime.resolver); + var handle = (0, _opcodeCompiler.unwrapHandle)(layout.compile(context)); - if (typeof before === 'string') { - move(entry, reference.firstNode()); - } else { - move(entry, this.marker); + if (Array.isArray(handle)) { + var error = handle[0]; + throw new Error(`Compile Error: ${error.problem} ${error.span.start}..${error.span.end} :: TODO (thread better)`); } - updating.remove(entry); - updating.insertBefore(entry, reference); + invocation = { + handle, + symbolTable: layout.symbolTable + }; + } else { + throw new Error('Cannot invoke components with dynamic layouts as a root component.'); } - delete(key) { - var { - map - } = this; - var opcode = map[key]; - opcode.didDestroy(); - clear(opcode); - this.updating.remove(opcode); - delete map[key]; - this.didDelete = true; - } + return renderInvocation(vm, invocation, definition, args); + } - done() { - this.opcode.didInitializeChildren(this.didInsert || this.didDelete); - } + var SERIALIZATION_FIRST_NODE_STRING = '%+b:0%'; + _exports.SERIALIZATION_FIRST_NODE_STRING = SERIALIZATION_FIRST_NODE_STRING; + function isSerializationFirstNode(node) { + return node.nodeValue === SERIALIZATION_FIRST_NODE_STRING; } - class ListBlockOpcode extends BlockOpcode { - constructor(start, state, runtime, bounds, children, artifacts) { - super(start, state, runtime, bounds, children); - this.type = 'list-block'; - this.map = (0, _util.dict)(); - this.lastIterated = _reference2.INITIAL; - this.artifacts = artifacts; + class RehydratingCursor extends CursorImpl { + constructor(element, nextSibling, startingBlockDepth) { + super(element, nextSibling); + this.startingBlockDepth = startingBlockDepth; + this.candidate = null; + this.injectedOmittedNode = false; + this.openBlockDepth = startingBlockDepth - 1; + } - var _tag = this._tag = (0, _reference2.createUpdatableTag)(); + } - this.tag = (0, _reference2.combine)([artifacts.tag, _tag]); - } + class RehydrateBuilder extends NewElementBuilder { + constructor(env, parentNode, nextSibling) { + super(env, parentNode, nextSibling); + this.unmatchedAttributes = null; + this.blockDepth = 0; + if (nextSibling) throw new Error('Rehydration with nextSibling not supported'); + var node = this.currentCursor.element.firstChild; - didInitializeChildren(listDidChange = true) { - this.lastIterated = (0, _reference2.value)(this.artifacts.tag); + while (node !== null) { + if (isComment(node) && isSerializationFirstNode(node)) { + break; + } - if (listDidChange) { - (0, _reference2.update)(this._tag, (0, _reference2.combineSlice)(this.children)); + node = node.nextSibling; } - } - evaluate(vm) { - var { - artifacts, - lastIterated - } = this; + this.candidate = node; + } - if (!(0, _reference2.validate)(artifacts.tag, lastIterated)) { - var { - bounds - } = this; - var { - dom - } = vm; - var marker = dom.createComment(''); - dom.insertAfter(bounds.parentElement(), marker, bounds.lastNode()); - var target = new ListRevalidationDelegate(this, marker); - var synchronizer = new _reference2.IteratorSynchronizer({ - target, - artifacts - }); - synchronizer.sync(); - this.parentElement().removeChild(marker); - } // Run now-updated updating opcodes + get currentCursor() { + return this[CURSOR_STACK].current; + } + get candidate() { + if (this.currentCursor) { + return this.currentCursor.candidate; + } - super.evaluate(vm); + return null; } - vmForInsertion(nextSibling) { - var { - bounds, - state, - runtime - } = this; - var elementStack = NewElementBuilder.forInitialRender(runtime.env, { - element: bounds.parentElement(), - nextSibling - }); - return VM.resume(state, runtime, elementStack); + set candidate(node) { + var currentCursor = this.currentCursor; + currentCursor.candidate = node; } - } + disableRehydration(nextSibling) { + var currentCursor = this.currentCursor; // rehydration will be disabled until we either: + // * hit popElement (and return to using the parent elements cursor) + // * hit closeBlock and the next sibling is a close block comment + // matching the expected openBlockDepth - class UpdatingVMFrame { - constructor(ops, exceptionHandler) { - this.ops = ops; - this.exceptionHandler = exceptionHandler; - this.current = ops.head(); + currentCursor.candidate = null; + currentCursor.nextSibling = nextSibling; } - goto(op) { - this.current = op; + enableRehydration(candidate) { + var currentCursor = this.currentCursor; + currentCursor.candidate = candidate; + currentCursor.nextSibling = null; } - nextStatement() { - var { - current, - ops - } = this; - if (current) this.current = ops.nextNode(current); - return current; - } + pushElement(element, nextSibling = null) { + var cursor = new RehydratingCursor(element, nextSibling, this.blockDepth || 0); + /** + *
<--------------- currentCursor.element + * <------- would have been removed during openBlock + *
<--------------- currentCursor.candidate -> cursor.element + * <----- currentCursor.candidate.firstChild -> cursor.candidate + * Foo + * + *
+ * <------ becomes currentCursor.candidate + */ - handleException() { - if (this.exceptionHandler) { - this.exceptionHandler.handleException(); + if (this.candidate !== null) { + cursor.candidate = element.firstChild; + this.candidate = element.nextSibling; } - } - } + this[CURSOR_STACK].push(cursor); + } // clears until the end of the current container + // either the current open block or higher - class RenderResult { - constructor(env, program, updating, bounds) { - this.env = env; - this.program = program; - this.updating = updating; - this.bounds = bounds; - } - rerender({ - alwaysRevalidate = false - } = { - alwaysRevalidate: false - }) { - var { - env, - program, - updating - } = this; - var vm = new UpdatingVM(env, program, { - alwaysRevalidate - }); - vm.execute(updating, this); - } + clearMismatch(candidate) { + var current = candidate; + var currentCursor = this.currentCursor; - parentElement() { - return this.bounds.parentElement(); - } + if (currentCursor !== null) { + var openBlockDepth = currentCursor.openBlockDepth; - firstNode() { - return this.bounds.firstNode(); - } + if (openBlockDepth >= currentCursor.startingBlockDepth) { + while (current) { + if (isCloseBlock(current)) { + var closeBlockDepth = getBlockDepth(current); - lastNode() { - return this.bounds.lastNode(); - } + if (openBlockDepth >= closeBlockDepth) { + break; + } + } - handleException() { - throw 'this should never happen'; + current = this.remove(current); + } + } else { + while (current !== null) { + current = this.remove(current); + } + } // current cursor parentNode should be openCandidate if element + // or openCandidate.parentNode if comment + + + this.disableRehydration(current); + } } - destroy() { - this.bounds.destroy(); - clear(this.bounds); + __openBlock() { + var { + currentCursor + } = this; + if (currentCursor === null) return; + var blockDepth = this.blockDepth; + this.blockDepth++; + var { + candidate + } = currentCursor; + if (candidate === null) return; + var { + tagName + } = currentCursor.element; + + if (isOpenBlock(candidate) && getBlockDepth(candidate) === blockDepth) { + this.candidate = this.remove(candidate); + currentCursor.openBlockDepth = blockDepth; + } else if (tagName !== 'TITLE' && tagName !== 'SCRIPT' && tagName !== 'STYLE') { + this.clearMismatch(candidate); + } } - } + __closeBlock() { + var { + currentCursor + } = this; + if (currentCursor === null) return; // openBlock is the last rehydrated open block - _exports.RenderResult = RenderResult; + var openBlockDepth = currentCursor.openBlockDepth; // this currently is the expected next open block depth - class Arguments { - constructor() { - this.stack = null; - this.positional = new PositionalArguments(); - this.named = new NamedArguments(); - this.blocks = new BlockArguments(); - } + this.blockDepth--; + var { + candidate + } = currentCursor; + var isRehydrating = false; - empty(stack) { - var base = stack.sp + 1; - this.named.empty(stack, base); - this.positional.empty(stack, base); - this.blocks.empty(stack, base); - return this; - } + if (candidate !== null) { + isRehydrating = true; //assert( + // openBlockDepth === this.blockDepth, + // 'when rehydrating, openBlockDepth should match this.blockDepth here' + //); + + if (isCloseBlock(candidate) && getBlockDepth(candidate) === openBlockDepth) { + var nextSibling = this.remove(candidate); + this.candidate = nextSibling; + currentCursor.openBlockDepth--; + } else { + // close the block and clear mismatch in parent container + // we will be either at the end of the element + // or at the end of our containing block + this.clearMismatch(candidate); + isRehydrating = false; + } + } - setup(stack, names, blockNames, positionalCount, synthetic) { - this.stack = stack; - /* - | ... | blocks | positional | named | - | ... | b0 b1 | p0 p1 p2 p3 | n0 n1 | - index | ... | 4/5/6 7/8/9 | 10 11 12 13 | 14 15 | - ^ ^ ^ ^ - bbase pbase nbase sp - */ + if (isRehydrating === false) { + // check if nextSibling matches our expected close block + // if so, we remove the close block comment and + // restore rehydration after clearMismatch disabled + var _nextSibling = currentCursor.nextSibling; - var named = this.named; - var namedCount = names.length; - var namedBase = stack.sp - namedCount + 1; - named.setup(stack, namedBase, namedCount, names, synthetic); - var positional = this.positional; - var positionalBase = namedBase - positionalCount; - positional.setup(stack, positionalBase, positionalCount); - var blocks = this.blocks; - var blocksCount = blockNames.length; - var blocksBase = positionalBase - blocksCount * 3; - blocks.setup(stack, blocksBase, blocksCount, blockNames); - } + if (_nextSibling !== null && isCloseBlock(_nextSibling) && getBlockDepth(_nextSibling) === this.blockDepth) { + // restore rehydration state + var _candidate2 = this.remove(_nextSibling); - get tag() { - return (0, _reference2.combineTagged)([this.positional, this.named]); + this.enableRehydration(_candidate2); + currentCursor.openBlockDepth--; + } + } } - get base() { - return this.blocks.base; - } + __appendNode(node) { + var { + candidate + } = this; // This code path is only used when inserting precisely one node. It needs more + // comparison logic, but we can probably lean on the cases where this code path + // is actually used. - get length() { - return this.positional.length + this.named.length + this.blocks.length * 3; + if (candidate) { + return candidate; + } else { + return super.__appendNode(node); + } } - at(pos) { - return this.positional.at(pos); - } + __appendHTML(html) { + var candidateBounds = this.markerBounds(); - realloc(offset) { - var { - stack - } = this; + if (candidateBounds) { + var first = candidateBounds.firstNode(); + var last = candidateBounds.lastNode(); + var newBounds = new ConcreteBounds(this.element, first.nextSibling, last.previousSibling); + var possibleEmptyMarker = this.remove(first); + this.remove(last); - if (offset > 0 && stack !== null) { - var { - positional, - named - } = this; - var newBase = positional.base + offset; - var length = positional.length + named.length; + if (possibleEmptyMarker !== null && isEmpty$1(possibleEmptyMarker)) { + this.candidate = this.remove(possibleEmptyMarker); - for (var i = length - 1; i >= 0; i--) { - stack.copy(i + positional.base, i + newBase); + if (this.candidate !== null) { + this.clearMismatch(this.candidate); + } } - positional.base += offset; - named.base += offset; - stack.sp += offset; + return newBounds; + } else { + return super.__appendHTML(html); } } - capture() { - var positional = this.positional.length === 0 ? EMPTY_POSITIONAL : this.positional.capture(); - var named = this.named.length === 0 ? EMPTY_NAMED : this.named.capture(); - return new CapturedArguments(this.tag, positional, named, this.length); - } - - clear() { - var { - stack, - length - } = this; - if (length > 0 && stack !== null) stack.pop(length); + remove(node) { + var element = node.parentNode; + var next = node.nextSibling; + element.removeChild(node); + return next; } - } - - class CapturedArguments { - constructor(tag, positional, named, length) { - this.tag = tag; - this.positional = positional; - this.named = named; - this.length = length; - } + markerBounds() { + var _candidate = this.candidate; - value() { - return { - named: this.named.value(), - positional: this.positional.value() - }; - } + if (_candidate && isMarker(_candidate)) { + var first = _candidate; + var last = first.nextSibling; - } + while (last && !isMarker(last)) { + last = last.nextSibling; + } - class PositionalArguments { - constructor() { - this.base = 0; - this.length = 0; - this.stack = null; - this._tag = null; - this._references = null; + return new ConcreteBounds(this.element, first, last); + } else { + return null; + } } - empty(stack, base) { - this.stack = stack; - this.base = base; - this.length = 0; - this._tag = _reference2.CONSTANT_TAG; - this._references = _util.EMPTY_ARRAY; - } + __appendText(string) { + var { + candidate + } = this; - setup(stack, base, length) { - this.stack = stack; - this.base = base; - this.length = length; + if (candidate) { + if (isTextNode(candidate)) { + if (candidate.nodeValue !== string) { + candidate.nodeValue = string; + } - if (length === 0) { - this._tag = _reference2.CONSTANT_TAG; - this._references = _util.EMPTY_ARRAY; + this.candidate = candidate.nextSibling; + return candidate; + } else if (isSeparator(candidate)) { + this.candidate = this.remove(candidate); + return this.__appendText(string); + } else if (isEmpty$1(candidate) && string === '') { + this.candidate = this.remove(candidate); + return this.__appendText(string); + } else { + this.clearMismatch(candidate); + return super.__appendText(string); + } } else { - this._tag = null; - this._references = null; + return super.__appendText(string); } } - get tag() { - var tag = this._tag; + __appendComment(string) { + var _candidate = this.candidate; - if (!tag) { - tag = this._tag = (0, _reference2.combineTagged)(this.references); + if (_candidate && isComment(_candidate)) { + if (_candidate.nodeValue !== string) { + _candidate.nodeValue = string; + } + + this.candidate = _candidate.nextSibling; + return _candidate; + } else if (_candidate) { + this.clearMismatch(_candidate); } - return tag; + return super.__appendComment(string); } - at(position) { - var { - base, - length, - stack - } = this; + __openElement(tag) { + var _candidate = this.candidate; - if (position < 0 || position >= length) { - return UNDEFINED_REFERENCE; + if (_candidate && isElement(_candidate) && isSameNodeType(_candidate, tag)) { + this.unmatchedAttributes = [].slice.call(_candidate.attributes); + return _candidate; + } else if (_candidate) { + if (isElement(_candidate) && _candidate.tagName === 'TBODY') { + this.pushElement(_candidate, null); + this.currentCursor.injectedOmittedNode = true; + return this.__openElement(tag); + } + + this.clearMismatch(_candidate); } - return stack.get(position, base); + return super.__openElement(tag); } - capture() { - return new CapturedPositionalArguments(this.tag, this.references); - } + __setAttribute(name, value$$1, namespace) { + var unmatched = this.unmatchedAttributes; - prepend(other) { - var additions = other.length; + if (unmatched) { + var attr = findByName(unmatched, name); - if (additions > 0) { - var { - base, - length, - stack - } = this; - this.base = base = base - additions; - this.length = length + additions; + if (attr) { + if (attr.value !== value$$1) { + attr.value = value$$1; + } - for (var i = 0; i < additions; i++) { - stack.set(other.at(i), i, base); + unmatched.splice(unmatched.indexOf(attr), 1); + return; } - - this._tag = null; - this._references = null; } + + return super.__setAttribute(name, value$$1, namespace); } - get references() { - var references = this._references; + __setProperty(name, value$$1) { + var unmatched = this.unmatchedAttributes; - if (!references) { - var { - stack, - base, - length - } = this; - references = this._references = stack.sliceArray(base, base + length); - } + if (unmatched) { + var attr = findByName(unmatched, name); - return references; - } + if (attr) { + if (attr.value !== value$$1) { + attr.value = value$$1; + } - } + unmatched.splice(unmatched.indexOf(attr), 1); + return; + } + } - class CapturedPositionalArguments { - constructor(tag, references, length = references.length) { - this.tag = tag; - this.references = references; - this.length = length; + return super.__setProperty(name, value$$1); } - static empty() { - return new CapturedPositionalArguments(_reference2.CONSTANT_TAG, _util.EMPTY_ARRAY, 0); - } + __flushElement(parent, constructing) { + var { + unmatchedAttributes: unmatched + } = this; - at(position) { - return this.references[position]; - } + if (unmatched) { + for (var i = 0; i < unmatched.length; i++) { + this.constructing.removeAttribute(unmatched[i].name); + } - value() { - return this.references.map(this.valueOf); + this.unmatchedAttributes = null; + } else { + super.__flushElement(parent, constructing); + } } - get(name) { + willCloseElement() { var { - references, - length + candidate, + currentCursor } = this; - if (name === 'length') { - return PrimitiveReference.create(length); - } else { - var idx = parseInt(name, 10); + if (candidate !== null) { + this.clearMismatch(candidate); + } - if (idx < 0 || idx >= length) { - return UNDEFINED_REFERENCE; - } else { - return references[idx]; - } + if (currentCursor && currentCursor.injectedOmittedNode) { + this.popElement(); } - } - valueOf(reference) { - return reference.value(); + super.willCloseElement(); } - } + getMarker(element, guid) { + var marker = element.querySelector(`script[glmr="${guid}"]`); - class NamedArguments { - constructor() { - this.base = 0; - this.length = 0; - this._references = null; - this._names = _util.EMPTY_ARRAY; - this._atNames = _util.EMPTY_ARRAY; - } + if (marker) { + return marker; + } - empty(stack, base) { - this.stack = stack; - this.base = base; - this.length = 0; - this._references = _util.EMPTY_ARRAY; - this._names = _util.EMPTY_ARRAY; - this._atNames = _util.EMPTY_ARRAY; + return null; } - setup(stack, base, length, names, synthetic) { - this.stack = stack; - this.base = base; - this.length = length; - - if (length === 0) { - this._references = _util.EMPTY_ARRAY; - this._names = _util.EMPTY_ARRAY; - this._atNames = _util.EMPTY_ARRAY; - } else { - this._references = null; + __pushRemoteElement(element, cursorId, insertBefore) { + var marker = this.getMarker(element, cursorId); // when insertBefore is not present, we clear the element - if (synthetic) { - this._names = names; - this._atNames = null; - } else { - this._names = null; - this._atNames = names; + if (insertBefore === undefined) { + while (element.firstChild !== null && element.firstChild !== marker) { + this.remove(element.firstChild); } - } - } - get tag() { - return (0, _reference2.combineTagged)(this.references); - } + insertBefore = null; + } - get names() { - var names = this._names; + var cursor = new RehydratingCursor(element, null, this.blockDepth); + this[CURSOR_STACK].push(cursor); - if (!names) { - names = this._names = this._atNames.map(this.toSyntheticName); + if (marker === null) { + this.disableRehydration(insertBefore); + } else { + this.candidate = this.remove(marker); } - return names; + var block = new RemoteLiveBlock(element); + return this.pushLiveBlock(block, true); } - get atNames() { - var atNames = this._atNames; + didAppendBounds(bounds) { + super.didAppendBounds(bounds); - if (!atNames) { - atNames = this._atNames = this._names.map(this.toAtName); + if (this.candidate) { + var last = bounds.lastNode(); + this.candidate = last && last.nextSibling; } - return atNames; + return bounds; } - has(name) { - return this.names.indexOf(name) !== -1; - } + } - get(name, synthetic = true) { - var { - base, - stack - } = this; - var names = synthetic ? this.names : this.atNames; - var idx = names.indexOf(name); + _exports.RehydrateBuilder = RehydrateBuilder; - if (idx === -1) { - return UNDEFINED_REFERENCE; - } + function isTextNode(node) { + return node.nodeType === 3; + } - return stack.get(idx, base); - } + function isComment(node) { + return node.nodeType === 8; + } - capture() { - return new CapturedNamedArguments(this.tag, this.names, this.references); - } + function isOpenBlock(node) { + return node.nodeType === 8 + /* COMMENT_NODE */ + && node.nodeValue.lastIndexOf('%+b:', 0) === 0; + } - merge(other) { - var { - length: extras - } = other; + function isCloseBlock(node) { + return node.nodeType === 8 + /* COMMENT_NODE */ + && node.nodeValue.lastIndexOf('%-b:', 0) === 0; + } - if (extras > 0) { - var { - names, - length, - stack - } = this; - var { - names: extraNames - } = other; + function getBlockDepth(node) { + return parseInt(node.nodeValue.slice(4), 10); + } - if (Object.isFrozen(names) && names.length === 0) { - names = []; - } + function isElement(node) { + return node.nodeType === 1; + } - for (var i = 0; i < extras; i++) { - var name = extraNames[i]; - var idx = names.indexOf(name); + function isMarker(node) { + return node.nodeType === 8 && node.nodeValue === '%glmr%'; + } - if (idx === -1) { - length = names.push(name); - stack.push(other.references[i]); - } - } + function isSeparator(node) { + return node.nodeType === 8 && node.nodeValue === '%|%'; + } - this.length = length; - this._references = null; - this._names = names; - this._atNames = null; + function isEmpty$1(node) { + return node.nodeType === 8 && node.nodeValue === '% %'; + } + + function isSameNodeType(candidate, tag) { + if (candidate.namespaceURI === "http://www.w3.org/2000/svg" + /* SVG */ + ) { + return candidate.tagName === tag; } + + return candidate.tagName === tag.toUpperCase(); + } + + function findByName(array, name) { + for (var i = 0; i < array.length; i++) { + var attr = array[i]; + if (attr.name === name) return attr; } - get references() { - var references = this._references; + return undefined; + } - if (!references) { - var { - base, - length, - stack - } = this; - references = this._references = stack.sliceArray(base, base + length); - } + function rehydrationBuilder(env, cursor) { + return RehydrateBuilder.forInitialRender(env, cursor); + } +}); +define("@glimmer/util", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.assertNever = assertNever; + _exports.assert = debugAssert; + _exports.deprecate = deprecate; + _exports.dict = dict; + _exports.isDict = isDict; + _exports.isObject = isObject; + _exports.ensureGuid = ensureGuid; + _exports.initializeGuid = initializeGuid; + _exports.isSerializationFirstNode = isSerializationFirstNode; + _exports.assign = assign; + _exports.fillNulls = fillNulls; + _exports.values = values; + _exports.isDestroyable = isDestroyable; + _exports.isStringDestroyable = isStringDestroyable; + _exports.clearElement = clearElement; + _exports.isDrop = isDrop; + _exports.associate = associate; + _exports.associateDestructor = associateDestructor; + _exports.peekAssociated = peekAssociated; + _exports.takeAssociated = takeAssociated; + _exports.willDestroyAssociated = willDestroyAssociated; + _exports.didDestroyAssociated = didDestroyAssociated; + _exports.destructor = destructor; + _exports.snapshot = snapshot; + _exports.debugDropTree = debugDropTree; + _exports.printDropTree = printDropTree; + _exports.printDrop = printDrop; + _exports.keys = keys; + _exports.unwrap = unwrap; + _exports.expect = expect; + _exports.unreachable = unreachable; + _exports.exhausted = exhausted; + _exports.strip = strip; + _exports.encodeImmediate = encodeImmediate; + _exports.decodeImmediate = decodeImmediate; + _exports.isSmallInt = isSmallInt; + _exports.isHandle = isHandle; + _exports.encodeHandle = encodeHandle; + _exports.decodeHandle = decodeHandle; + _exports.symbol = _exports.tuple = _exports.ListContentsDestructor = _exports.DESTRUCTORS = _exports.CHILDREN = _exports.DID_DROP = _exports.WILL_DROP = _exports.LINKED = _exports.DESTROY = _exports.debugToString = _exports.ListSlice = _exports.ListNode = _exports.LinkedList = _exports.EMPTY_SLICE = _exports.SERIALIZATION_FIRST_NODE_STRING = _exports.Stack = _exports.DictSet = _exports.EMPTY_ARRAY = void 0; + var EMPTY_ARRAY = Object.freeze([]); // import Logger from './logger'; + // let alreadyWarned = false; + + _exports.EMPTY_ARRAY = EMPTY_ARRAY; + + function debugAssert(test, msg) { + // if (!alreadyWarned) { + // alreadyWarned = true; + // Logger.warn("Don't leave debug assertions on in public builds"); + // } + if (!test) { + throw new Error(msg || 'assertion failure'); + } + } + + function deprecate(desc) { + console.warn(`DEPRECATION: ${desc}`); + } + + var GUID = 0; + + function initializeGuid(object) { + return object._guid = ++GUID; + } + + function ensureGuid(object) { + return object._guid || initializeGuid(object); + } - return references; + function dict() { + return Object.create(null); + } + + function isDict(u) { + return u !== null && u !== undefined; + } + + function isObject(u) { + return typeof u === 'object' && u !== null; + } + + class DictSet { + constructor() { + this.dict = dict(); } - toSyntheticName(name) { - return name.slice(1); + add(obj) { + if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[ensureGuid(obj)] = obj; + return this; } - toAtName(name) { - return "@" + name; + delete(obj) { + if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; } } - class CapturedNamedArguments { - constructor(tag, names, references) { - this.tag = tag; - this.names = names; - this.references = references; - this.length = names.length; - this._map = null; - } + _exports.DictSet = DictSet; - get map() { - var map = this._map; + class StackImpl { + constructor() { + this.stack = []; + this.current = null; + } - if (!map) { - var { - names, - references - } = this; - map = this._map = (0, _util.dict)(); + get size() { + return this.stack.length; + } - for (var i = 0; i < names.length; i++) { - var name = names[i]; - map[name] = references[i]; - } - } + push(item) { + this.current = item; + this.stack.push(item); + } - return map; + pop() { + var item = this.stack.pop(); + var len = this.stack.length; + this.current = len === 0 ? null : this.stack[len - 1]; + return item === undefined ? null : item; } - has(name) { - return this.names.indexOf(name) !== -1; + nth(from) { + var len = this.stack.length; + return len < from ? null : this.stack[len - from]; } - get(name) { - var { - names, - references - } = this; - var idx = names.indexOf(name); + isEmpty() { + return this.stack.length === 0; + } - if (idx === -1) { - return UNDEFINED_REFERENCE; - } else { - return references[idx]; - } + toArray() { + return this.stack; } - value() { - var { - names, - references - } = this; - var out = (0, _util.dict)(); + } - for (var i = 0; i < names.length; i++) { - var name = names[i]; - out[name] = references[i].value(); - } + _exports.Stack = StackImpl; - return out; - } + function keys(obj) { + return Object.keys(obj); + } + function unwrap(val) { + if (val === null || val === undefined) throw new Error(`Expected value to be present`); + return val; } - class BlockArguments { - constructor() { - this.internalValues = null; - this.internalTag = null; - this.names = _util.EMPTY_ARRAY; - this.length = 0; - this.base = 0; - } + function expect(val, message) { + if (val === null || val === undefined) throw new Error(message); + return val; + } - empty(stack, base) { - this.stack = stack; - this.names = _util.EMPTY_ARRAY; - this.base = base; - this.length = 0; - this.internalTag = _reference2.CONSTANT_TAG; - this.internalValues = _util.EMPTY_ARRAY; - } + function unreachable(message = 'unreachable') { + return new Error(message); + } - setup(stack, base, length, names) { - this.stack = stack; - this.names = names; - this.base = base; - this.length = length; + function exhausted(value) { + throw new Error(`Exhausted ${value}`); + } - if (length === 0) { - this.internalTag = _reference2.CONSTANT_TAG; - this.internalValues = _util.EMPTY_ARRAY; - } else { - this.internalTag = null; - this.internalValues = null; - } - } + var tuple = (...args) => args; - get values() { - var values = this.internalValues; + _exports.tuple = tuple; + var symbol = typeof Symbol !== 'undefined' ? Symbol : key => `__${key}${Math.floor(Math.random() * Date.now())}__`; + _exports.symbol = symbol; + var DESTROY = symbol('DESTROY'); + _exports.DESTROY = DESTROY; - if (!values) { - var { - base, - length, - stack - } = this; - values = this.internalValues = stack.sliceArray(base, base + length * 3); - } + function isDestroyable(value) { + return !!(value && value[DESTROY] !== undefined); + } - return values; - } + function isStringDestroyable(value) { + return !!(value && typeof value === 'object' && typeof value.destroy === 'function'); + } - has(name) { - return this.names.indexOf(name) !== -1; + function clearElement(parent) { + var current = parent.firstChild; + + while (current) { + var next = current.nextSibling; + parent.removeChild(current); + current = next; } + } - get(name) { - var { - base, - stack, - names - } = this; - var idx = names.indexOf(name); + var SERIALIZATION_FIRST_NODE_STRING = '%+b:0%'; + _exports.SERIALIZATION_FIRST_NODE_STRING = SERIALIZATION_FIRST_NODE_STRING; - if (names.indexOf(name) === -1) { - return null; - } + function isSerializationFirstNode(node) { + return node.nodeValue === SERIALIZATION_FIRST_NODE_STRING; + } - var table = stack.get(idx * 3, base); - var scope = stack.get(idx * 3 + 1, base); // FIXME(mmun): shouldn't need to cast this + var LINKED = new WeakMap(); + _exports.LINKED = LINKED; + var WILL_DROP = symbol('WILL_DROP'); + _exports.WILL_DROP = WILL_DROP; + var DID_DROP = symbol('DID_DROP'); + _exports.DID_DROP = DID_DROP; + var CHILDREN = symbol('CHILDREN'); + _exports.CHILDREN = CHILDREN; + var DESTRUCTORS = new WeakMap(); + _exports.DESTRUCTORS = DESTRUCTORS; - var handle = stack.get(idx * 3 + 2, base); - return handle === null ? null : [handle, scope, table]; - } + function isDrop(value) { + if (value === null || typeof value !== 'object') return false; + return value[DID_DROP] !== undefined; + } - capture() { - return new CapturedBlockArguments(this.names, this.values); + function associate(parent, child) { + associateDestructor(parent, destructor(child)); + } + + function associateDestructor(parent, child) { + var associated = LINKED.get(parent); + + if (!associated) { + associated = new Set(); + LINKED.set(parent, associated); } + associated.add(child); } - class CapturedBlockArguments { - constructor(names, values) { - this.names = names; - this.values = values; - this.length = names.length; - } + function peekAssociated(parent) { + return LINKED.get(parent) || null; + } - has(name) { - return this.names.indexOf(name) !== -1; - } + function takeAssociated(parent) { + var linked = LINKED.get(parent); - get(name) { - var idx = this.names.indexOf(name); - if (idx === -1) return null; - return [this.values[idx * 3 + 2], this.values[idx * 3 + 1], this.values[idx * 3]]; + if (linked && linked.size > 0) { + LINKED.delete(parent); + return linked; + } else { + return null; } - } - var EMPTY_NAMED = new CapturedNamedArguments(_reference2.CONSTANT_TAG, _util.EMPTY_ARRAY, _util.EMPTY_ARRAY); - var EMPTY_POSITIONAL = new CapturedPositionalArguments(_reference2.CONSTANT_TAG, _util.EMPTY_ARRAY); - var EMPTY_ARGS = new CapturedArguments(_reference2.CONSTANT_TAG, EMPTY_POSITIONAL, EMPTY_NAMED, 0); - _exports.EMPTY_ARGS = EMPTY_ARGS; + function willDestroyAssociated(parent) { + var associated = LINKED.get(parent); - class VM { - constructor(runtime, scope, dynamicScope, elementStack) { - this.runtime = runtime; - this.elementStack = elementStack; - this.dynamicScopeStack = new _util.Stack(); - this.scopeStack = new _util.Stack(); - this.updatingOpcodeStack = new _util.Stack(); - this.cacheGroups = new _util.Stack(); - this.listBlockStack = new _util.Stack(); - this.s0 = null; - this.s1 = null; - this.t0 = null; - this.t1 = null; - this.v0 = null; - this.heap = this.program.heap; - this.constants = this.program.constants; - this.elementStack = elementStack; - this.scopeStack.push(scope); - this.dynamicScopeStack.push(dynamicScope); - this.args = new Arguments(); - this.inner = new LowLevelVM(EvaluationStack.empty(), this.heap, runtime.program, { - debugBefore: opcode => { - return APPEND_OPCODES.debugBefore(this, opcode, opcode.type); - }, - debugAfter: (opcode, state) => { - APPEND_OPCODES.debugAfter(this, opcode, opcode.type, state); - } + if (associated) { + associated.forEach(item => { + item[WILL_DROP](); }); } + } - get stack() { - return this.inner.stack; - } + function didDestroyAssociated(parent) { + var associated = LINKED.get(parent); - set stack(value$$1) { - this.inner.stack = value$$1; + if (associated) { + associated.forEach(item => { + item[DID_DROP](); + associated.delete(item); + }); } - /* Registers */ + } + function destructor(value) { + var d = DESTRUCTORS.get(value); - set currentOpSize(value$$1) { - this.inner.currentOpSize = value$$1; - } + if (!d) { + if (isDestroyable(value)) { + d = new DestroyableDestructor(value); + } else if (isStringDestroyable(value)) { + d = new StringDestroyableDestructor(value); + } else { + d = new SimpleDestructor(value); + } - get currentOpSize() { - return this.inner.currentOpSize; + DESTRUCTORS.set(value, d); } - get pc() { - return this.inner.pc; - } + return d; + } - set pc(value$$1) { - this.inner.pc = value$$1; + function snapshot(values) { + return new SnapshotDestructor(values); + } + + class SnapshotDestructor { + constructor(destructors) { + this.destructors = destructors; } - get ra() { - return this.inner.ra; + [WILL_DROP]() { + this.destructors.forEach(item => item[WILL_DROP]()); } - set ra(value$$1) { - this.inner.ra = value$$1; + [DID_DROP]() { + this.destructors.forEach(item => item[DID_DROP]()); } - get fp() { - return this.stack.fp; + get [CHILDREN]() { + return this.destructors; } - set fp(fp) { - this.stack.fp = fp; + toString() { + return 'SnapshotDestructor'; } - get sp() { - return this.stack.sp; + } + + class DestroyableDestructor { + constructor(inner) { + this.inner = inner; } - set sp(sp) { - this.stack.sp = sp; - } // Fetch a value from a register onto the stack + [WILL_DROP]() { + willDestroyAssociated(this.inner); + } + [DID_DROP]() { + this.inner[DESTROY](); + didDestroyAssociated(this.inner); + } - fetch(register) { - this.stack.push(this[_vm2.Register[register]]); - } // Load a value from the stack into a register + get [CHILDREN]() { + return LINKED.get(this.inner) || []; + } + toString() { + return 'DestroyableDestructor'; + } - load(register) { - this[_vm2.Register[register]] = this.stack.pop(); - } // Fetch a value from a register + } + class StringDestroyableDestructor { + constructor(inner) { + this.inner = inner; + } - fetchValue(register) { - return this[_vm2.Register[register]]; - } // Load a value into a register + [WILL_DROP]() { + if (typeof this.inner.willDestroy === 'function') { + this.inner.willDestroy(); + } + willDestroyAssociated(this.inner); + } - loadValue(register, value$$1) { - this[_vm2.Register[register]] = value$$1; + [DID_DROP]() { + this.inner.destroy(); + didDestroyAssociated(this.inner); } - /** - * Migrated to Inner - */ - // Start a new frame and save $ra and $fp on the stack + get [CHILDREN]() { + return LINKED.get(this.inner) || []; + } - pushFrame() { - this.inner.pushFrame(); - } // Restore $ra, $sp and $fp + toString() { + return 'StringDestroyableDestructor'; + } + } - popFrame() { - this.inner.popFrame(); - } // Jump to an address in `program` + class SimpleDestructor { + constructor(inner) { + this.inner = inner; + } + [WILL_DROP]() { + willDestroyAssociated(this.inner); + } - goto(offset) { - this.inner.goto(offset); - } // Save $pc into $ra, then jump to a new address in `program` (jal in MIPS) + [DID_DROP]() { + didDestroyAssociated(this.inner); + } + get [CHILDREN]() { + return LINKED.get(this.inner) || []; + } - call(handle) { - this.inner.call(handle); - } // Put a specific `program` address in $ra + toString() { + return 'SimpleDestructor'; + } + } - returnTo(offset) { - this.inner.returnTo(offset); - } // Return to the `program` address stored in $ra + class ListContentsDestructor { + constructor(inner) { + this.inner = inner; + } + [WILL_DROP]() { + this.inner.forEachNode(d => destructor(d)[WILL_DROP]()); + } - return() { - this.inner.return(); + [DID_DROP]() { + this.inner.forEachNode(d => destructor(d)[DID_DROP]()); } - /** - * End of migrated. - */ + get [CHILDREN]() { + var out = []; + this.inner.forEachNode(d => out.push(...destructor(d)[CHILDREN])); + return out; + } - static initial(program, env, self, dynamicScope, elementStack, handle) { - var scopeSize = program.heap.scopesizeof(handle); - var scope = Scope.root(self, scopeSize); - var vm = new VM({ - program, - env - }, scope, dynamicScope, elementStack); - vm.pc = vm.heap.getaddr(handle); - vm.updatingOpcodeStack.push(new _util.LinkedList()); - return vm; + toString() { + return 'ListContentsDestructor'; } - static empty(program, env, elementStack, handle) { - var dynamicScope = { - get() { - return UNDEFINED_REFERENCE; - }, + } - set() { - return UNDEFINED_REFERENCE; - }, + _exports.ListContentsDestructor = ListContentsDestructor; - child() { - return dynamicScope; - } + function debugDropTree(inner) { + var hasDrop = isDrop(inner); + var rawChildren = LINKED.get(inner) || null; + var children = null; - }; - var vm = new VM({ - program, - env - }, Scope.root(UNDEFINED_REFERENCE, 0), dynamicScope, elementStack); - vm.updatingOpcodeStack.push(new _util.LinkedList()); - vm.pc = vm.heap.getaddr(handle); - return vm; - } + if (rawChildren) { + children = []; - static resume({ - scope, - dynamicScope - }, runtime, stack) { - return new VM(runtime, scope, dynamicScope, stack); + for (var child of rawChildren) { + children.push(debugDropTree(child)); + } } - get program() { - return this.runtime.program; - } + var obj = Object.create(null); + obj.inner = inner; - get env() { - return this.runtime.env; + if (children) { + obj.children = children; } - capture(args) { - return { - dynamicScope: this.dynamicScope(), - scope: this.scope(), - stack: this.stack.capture(args) - }; - } + obj.hasDrop = hasDrop; + return obj; + } - beginCacheGroup() { - this.cacheGroups.push(this.updating().tail()); - } + function printDropTree(inner) { + printDrop(destructor(inner)); + } - commitCacheGroup() { - // JumpIfNotModified(END) - // (head) - // (....) - // (tail) - // DidModify - // END: Noop - var END = new LabelOpcode('END'); - var opcodes = this.updating(); - var marker = this.cacheGroups.pop(); - var head = marker ? opcodes.nextNode(marker) : opcodes.head(); - var tail = opcodes.tail(); - var tag = (0, _reference2.combineSlice)(new _util.ListSlice(head, tail)); - var guard = new JumpIfNotModifiedOpcode(tag, END); - opcodes.insertBefore(guard, head); - opcodes.append(new DidModifyOpcode(guard)); - opcodes.append(END); - } + function printDrop(inner) { + console.group(String(inner)); + console.log(inner); + var children = inner[CHILDREN] || null; - enter(args) { - var updating = new _util.LinkedList(); - var state = this.capture(args); - var tracker = this.elements().pushUpdatableBlock(); - var tryOpcode = new TryOpcode(this.heap.gethandle(this.pc), state, this.runtime, tracker, updating); - this.didEnter(tryOpcode); + if (children) { + for (var child of children) { + printDrop(child); + } } - iterate(memo, value$$1) { - var stack = this.stack; - stack.push(value$$1); - stack.push(memo); - var state = this.capture(2); - var tracker = this.elements().pushUpdatableBlock(); // let ip = this.ip; - // this.ip = end + 4; - // this.frames.push(ip); + console.groupEnd(); + } - return new TryOpcode(this.heap.gethandle(this.pc), state, this.runtime, tracker, new _util.LinkedList()); + class ListNode { + constructor(value) { + this.next = null; + this.prev = null; + this.value = value; } - enterItem(key, opcode) { - this.listBlock().map[key] = opcode; - this.didEnter(opcode); - } + } - enterList(relativeStart) { - var updating = new _util.LinkedList(); - var state = this.capture(0); - var tracker = this.elements().pushBlockList(updating); - var artifacts = this.stack.peek().artifacts; - var addr = this.pc + relativeStart - this.currentOpSize; - var start = this.heap.gethandle(addr); - var opcode = new ListBlockOpcode(start, state, this.runtime, tracker, updating, artifacts); - this.listBlockStack.push(opcode); - this.didEnter(opcode); - } + _exports.ListNode = ListNode; - didEnter(opcode) { - this.updateWith(opcode); - this.updatingOpcodeStack.push(opcode.children); + class LinkedList { + constructor() { + this.clear(); } - exit() { - this.elements().popBlock(); - this.updatingOpcodeStack.pop(); - var parent = this.updating().tail(); - parent.didInitializeChildren(); + head() { + return this._head; } - exitList() { - this.exit(); - this.listBlockStack.pop(); + tail() { + return this._tail; } - updateWith(opcode) { - this.updating().append(opcode); + clear() { + this._head = this._tail = null; } - listBlock() { - return this.listBlockStack.current; + toArray() { + var out = []; + this.forEachNode(n => out.push(n)); + return out; } - updating() { - return this.updatingOpcodeStack.current; + nextNode(node) { + return node.next; } - elements() { - return this.elementStack; - } + forEachNode(callback) { + var node = this._head; - scope() { - return this.scopeStack.current; + while (node !== null) { + callback(node); + node = node.next; + } } - dynamicScope() { - return this.dynamicScopeStack.current; + insertBefore(node, reference = null) { + if (reference === null) return this.append(node); + if (reference.prev) reference.prev.next = node;else this._head = node; + node.prev = reference.prev; + node.next = reference; + reference.prev = node; + return node; } - pushChildScope() { - this.scopeStack.push(this.scope().child()); - } + append(node) { + var tail = this._tail; - pushDynamicScope() { - var child = this.dynamicScope().child(); - this.dynamicScopeStack.push(child); - return child; + if (tail) { + tail.next = node; + node.prev = tail; + node.next = null; + } else { + this._head = node; + } + + return this._tail = node; } - pushRootScope(size, bindCaller) { - var scope = Scope.sized(size); - if (bindCaller) scope.bindCallerScope(this.scope()); - this.scopeStack.push(scope); - return scope; + remove(node) { + if (node.prev) node.prev.next = node.next;else this._head = node.next; + if (node.next) node.next.prev = node.prev;else this._tail = node.prev; + return node; } - pushScope(scope) { - this.scopeStack.push(scope); + [WILL_DROP]() { + this.forEachNode(d => destructor(d)[WILL_DROP]()); } - popScope() { - this.scopeStack.pop(); + [DID_DROP]() { + this.forEachNode(d => destructor(d)[DID_DROP]()); } - popDynamicScope() { - this.dynamicScopeStack.pop(); + get [CHILDREN]() { + var out = []; + this.forEachNode(d => out.push(...destructor(d)[CHILDREN])); + return out; } - newDestroyable(d) { - this.elements().didAddDestroyable(d); - } /// SCOPE HELPERS + } + _exports.LinkedList = LinkedList; - getSelf() { - return this.scope().getSelf(); + class ListSlice { + constructor(head, tail) { + this._head = head; + this._tail = tail; } - referenceForSymbol(symbol) { - return this.scope().getSymbol(symbol); - } /// EXECUTION - - - execute(start, initialize) { - this.pc = this.heap.getaddr(start); - if (initialize) initialize(this); - var result; + forEachNode(callback) { + var node = this._head; - while (true) { - result = this.next(); - if (result.done) break; + while (node !== null) { + callback(node); + node = this.nextNode(node); } - - return result.value; } - next() { - var { - env, - program, - updatingOpcodeStack, - elementStack - } = this; - var opcode = this.inner.nextStatement(); - var result; - - if (opcode !== null) { - this.inner.evaluateOuter(opcode, this); - result = { - done: false, - value: null - }; - } else { - // Unload the stack - this.stack.reset(); - result = { - done: true, - value: new RenderResult(env, program, updatingOpcodeStack.pop(), elementStack.popBlock()) - }; - } + head() { + return this._head; + } - return result; + tail() { + return this._tail; } - bindDynamicScope(names) { - var scope = this.dynamicScope(); + toArray() { + var out = []; + this.forEachNode(n => out.push(n)); + return out; + } - for (var i = names.length - 1; i >= 0; i--) { - var name = this.constants.getString(names[i]); - scope.set(name, this.stack.pop()); - } + nextNode(node) { + if (node === this._tail) return null; + return node.next; } } - _exports.LowLevelVM = VM; + _exports.ListSlice = ListSlice; + var EMPTY_SLICE = new ListSlice(null, null); + _exports.EMPTY_SLICE = EMPTY_SLICE; + var { + keys: objKeys + } = Object; - class TemplateIteratorImpl { - constructor(vm) { - this.vm = vm; - } + function assign(obj) { + for (var i = 1; i < arguments.length; i++) { + var assignment = arguments[i]; + if (assignment === null || typeof assignment !== 'object') continue; - next() { - return this.vm.next(); - } + var _keys = objKeys(assignment); - } + for (var j = 0; j < _keys.length; j++) { + var key = _keys[j]; + obj[key] = assignment[key]; + } + } - function renderMain(program, env, self, dynamicScope, builder, handle) { - var vm = VM.initial(program, env, self, dynamicScope, builder, handle); - return new TemplateIteratorImpl(vm); + return obj; } - /** - * Returns a TemplateIterator configured to render a root component. - */ - - - function renderComponent(program, env, builder, main, name, args = {}) { - var vm = VM.empty(program, env, builder, main); - var { - resolver - } = vm.constants; - var definition = resolveComponent(resolver, name, null); - var { - manager, - state - } = definition; - var capabilities = capabilityFlagsFrom(manager.getCapabilities(state)); - var invocation; - if (hasStaticLayoutCapability(capabilities, manager)) { - invocation = manager.getLayout(state, resolver); - } else { - throw new Error('Cannot invoke components with dynamic layouts as a root component.'); - } // Get a list of tuples of argument names and references, like - // [['title', reference], ['name', reference]] + function fillNulls(count) { + var arr = new Array(count); + for (var i = 0; i < count; i++) { + arr[i] = null; + } - var argList = Object.keys(args).map(key => [key, args[key]]); - var blockNames = ['main', 'else', 'attrs']; // Prefix argument names with `@` symbol + return arr; + } - var argNames = argList.map(([name]) => "@" + name); - vm.pushFrame(); // Push blocks on to the stack, three stack values per block + function values(obj) { + var vals = []; - for (var i = 0; i < 3 * blockNames.length; i++) { - vm.stack.push(null); + for (var key in obj) { + vals.push(obj[key]); } - vm.stack.push(null); // For each argument, push its backing reference on to the stack + return vals; + } - argList.forEach(([, reference]) => { - vm.stack.push(reference); - }); // Configure VM based on blocks and args just pushed on to the stack. + function strip(strings, ...args) { + var out = ''; - vm.args.setup(vm.stack, argNames, blockNames, 0, false); // Needed for the Op.Main opcode: arguments, component invocation object, and - // component definition. + for (var i = 0; i < strings.length; i++) { + var string = strings[i]; + var dynamic = args[i] !== undefined ? String(args[i]) : ''; + out += `${string}${dynamic}`; + } - vm.stack.push(vm.args); - vm.stack.push(invocation); - vm.stack.push(definition); - return new TemplateIteratorImpl(vm); - } + var lines = out.split('\n'); - class DynamicVarReference { - constructor(scope, nameRef) { - this.scope = scope; - this.nameRef = nameRef; - var varTag = this.varTag = (0, _reference2.createUpdatableTag)(); - this.tag = (0, _reference2.combine)([nameRef.tag, varTag]); + while (lines.length && lines[0].match(/^\s*$/)) { + lines.shift(); } - value() { - return this.getVar().value(); + while (lines.length && lines[lines.length - 1].match(/^\s*$/)) { + lines.pop(); } - get(key) { - return this.getVar().get(key); + var min = Infinity; + + for (var line of lines) { + var leading = line.match(/^\s*/)[0].length; + min = Math.min(min, leading); } - getVar() { - var name = String(this.nameRef.value()); - var ref = this.scope.get(name); - (0, _reference2.update)(this.varTag, ref.tag); - return ref; + var stripped = []; + + for (var _line of lines) { + stripped.push(_line.slice(min)); } + return stripped.join('\n'); } + /** + * Encodes a value that can be stored directly instead of being a handle. + * + * Immediates use the positive half of 32bits + * + * @param value - the value to be encoded. + */ - function getDynamicVar(vm, args) { - var scope = vm.dynamicScope(); - var nameRef = args.positional.at(0); - return new DynamicVarReference(scope, nameRef); - } - /** @internal */ + function encodeImmediate(value) { + if (typeof value === 'number') { + // map -1 to -1073741820 onto 1073741828 to 2147483647 + // 1073741827 - (-1) == 1073741828 + // 1073741827 - (-1073741820) == 2147483647 + // positive it stays as is + // 0 - 1073741823 + return value < 0 ? 1073741827 + /* NEGATIVE_BASE */ + - value : value; + } - var DEFAULT_CAPABILITIES = { - dynamicLayout: true, - dynamicTag: true, - prepareArgs: true, - createArgs: true, - attributeHook: false, - elementHook: false, - dynamicScope: true, - createCaller: false, - updateHook: true, - createInstance: true - }; - _exports.DEFAULT_CAPABILITIES = DEFAULT_CAPABILITIES; - var MINIMAL_CAPABILITIES = { - dynamicLayout: false, - dynamicTag: false, - prepareArgs: false, - createArgs: false, - attributeHook: false, - elementHook: false, - dynamicScope: false, - createCaller: false, - updateHook: false, - createInstance: false - }; - _exports.MINIMAL_CAPABILITIES = MINIMAL_CAPABILITIES; - var SERIALIZATION_FIRST_NODE_STRING = '%+b:0%'; - _exports.SERIALIZATION_FIRST_NODE_STRING = SERIALIZATION_FIRST_NODE_STRING; + if (value === false) { + return 1073741824 + /* FALSE */ + ; + } - function isSerializationFirstNode(node) { - return node.nodeValue === SERIALIZATION_FIRST_NODE_STRING; - } + if (value === true) { + return 1073741825 + /* TRUE */ + ; + } - class RehydratingCursor extends Cursor { - constructor(element, nextSibling, startingBlockDepth) { - super(element, nextSibling); - this.startingBlockDepth = startingBlockDepth; - this.candidate = null; - this.injectedOmittedNode = false; - this.openBlockDepth = startingBlockDepth - 1; + if (value === null) { + return 1073741826 + /* NULL */ + ; + } + + if (value === undefined) { + return 1073741827 + /* UNDEFINED */ + ; } + return exhausted(value); } + /** + * Decodes an immediate into its value. + * + * @param value - the encoded immediate value + */ - class RehydrateBuilder extends NewElementBuilder { - // private candidate: Option = null; - constructor(env, parentNode, nextSibling) { - super(env, parentNode, nextSibling); - this.unmatchedAttributes = null; - this.blockDepth = 0; - if (nextSibling) throw new Error('Rehydration with nextSibling not supported'); - var node = this.currentCursor.element.firstChild; - while (node !== null) { - if (isComment(node) && isSerializationFirstNode(node)) { - break; - } + function decodeImmediate(value) { + if (value > 1073741823 + /* MAX_INT */ + ) { + switch (value) { + case 1073741824 + /* FALSE */ + : + return false; - node = node.nextSibling; - } + case 1073741825 + /* TRUE */ + : + return true; - this.candidate = node; - } + case 1073741826 + /* NULL */ + : + return null; - get currentCursor() { - return this.cursorStack.current; - } + case 1073741827 + /* UNDEFINED */ + : + return undefined; - get candidate() { - if (this.currentCursor) { - return this.currentCursor.candidate; + default: + // map 1073741828 to 2147483647 to -1 to -1073741820 + // 1073741827 - 1073741828 == -1 + // 1073741827 - 2147483647 == -1073741820 + return 1073741827 + /* NEGATIVE_BASE */ + - value; + } } - return null; - } + return value; + } + /** + * True if the number can be stored directly or false if it needs a handle. + * + * This is used on any number type to see if it can be directly encoded. + */ - set candidate(node) { - this.currentCursor.candidate = node; - } - pushElement(element, nextSibling) { - var { - blockDepth = 0 - } = this; - var cursor = new RehydratingCursor(element, nextSibling, blockDepth); - var currentCursor = this.currentCursor; + function isSmallInt(num) { + return isInt(num, -1073741820 + /* MIN_INT */ + , 1073741823 + /* MAX_INT */ + ); + } + /** + * True if the encoded int32 operand or encoded stack int32 is a handle. + */ - if (currentCursor) { - if (currentCursor.candidate) { - /** - *
<--------------- currentCursor.element - * - *
<--------------- currentCursor.candidate -> cursor.element - * <- currentCursor.candidate.firstChild -> cursor.candidate - * Foo - * - *
- * <-- becomes currentCursor.candidate - */ - // where to rehydrate from if we are in rehydration mode - cursor.candidate = element.firstChild; // where to continue when we pop - currentCursor.candidate = element.nextSibling; - } - } + function isHandle(encoded) { + return encoded < 0; + } + /** + * Encodes an index to an operand or stack handle. + */ - this.cursorStack.push(cursor); - } - clearMismatch(candidate) { - var current = candidate; - var currentCursor = this.currentCursor; + function encodeHandle(index, maxIndex = 2147483647 + /* MAX_INDEX */ + , maxHandle = -1 + /* MAX_HANDLE */ + ) { + if (index > maxIndex) { + throw new Error(`index ${index} overflowed range 0 to ${maxIndex}`); + } // -1 - 0 == -1 + // -1 - 1073741823 == -1073741824 + // -1073741825 - 0 == -1073741825 + // -1073741825 - 1073741823 == -2147483648 - if (currentCursor !== null) { - var openBlockDepth = currentCursor.openBlockDepth; - if (openBlockDepth >= currentCursor.startingBlockDepth) { - while (current && !(isComment(current) && getCloseBlockDepth(current) === openBlockDepth)) { - current = this.remove(current); - } - } else { - while (current !== null) { - current = this.remove(current); - } - } // current cursor parentNode should be openCandidate if element - // or openCandidate.parentNode if comment + return maxHandle - index; + } + /** + * Decodes the index from the specified operand or stack handle. + */ - currentCursor.nextSibling = current; // disable rehydration until we popElement or closeBlock for openBlockDepth + function decodeHandle(handle, maxHandle = -1 + /* MAX_HANDLE */ + ) { + // -1 - -1 == 0 + // -1 - -1073741824 == 1073741823 + // -1073741825 - -1073741825 == 0 + // -1073741825 - -2147483648 == 1073741823 + return maxHandle - handle; + } - currentCursor.candidate = null; - } - } + function isInt(num, min, max) { + // this is the same as Math.floor(num) === num + // also NaN % 1 is NaN and Infinity % 1 is NaN so both should fail + return num % 1 === 0 && num >= min && num <= max; + } - __openBlock() { - var { - currentCursor - } = this; - if (currentCursor === null) return; - var blockDepth = this.blockDepth; - this.blockDepth++; - var { - candidate - } = currentCursor; - if (candidate === null) return; - var { - tagName - } = currentCursor.element; + var debugToString; - if (isComment(candidate) && getOpenBlockDepth(candidate) === blockDepth) { - currentCursor.candidate = this.remove(candidate); - currentCursor.openBlockDepth = blockDepth; - } else if (tagName !== 'TITLE' && tagName !== 'SCRIPT' && tagName !== 'STYLE') { - this.clearMismatch(candidate); + if (true + /* DEBUG */ + ) { + var getFunctionName = fn => { + var functionName = fn.name; + + if (functionName === undefined) { + var match = Function.prototype.toString.call(fn).match(/function (\w+)\s*\(/); + functionName = match && match[1] || ''; } - } - __closeBlock() { - var { - currentCursor - } = this; - if (currentCursor === null) return; // openBlock is the last rehydrated open block + return functionName.replace(/^bound /, ''); + }; - var openBlockDepth = currentCursor.openBlockDepth; // this currently is the expected next open block depth + var getObjectName = obj => { + var name; + var className; - this.blockDepth--; - var { - candidate - } = currentCursor; // rehydrating + if (obj.constructor && obj.constructor !== Object) { + className = getFunctionName(obj.constructor); + } - if (candidate !== null) { - if (isComment(candidate) && getCloseBlockDepth(candidate) === openBlockDepth) { - currentCursor.candidate = this.remove(candidate); - currentCursor.openBlockDepth--; - } else { - this.clearMismatch(candidate); - } // if the openBlockDepth matches the blockDepth we just closed to - // then restore rehydration + if ('toString' in obj && obj.toString !== Object.prototype.toString && obj.toString !== Function.prototype.toString) { + name = obj.toString(); + } // If the class has a decent looking name, and the `toString` is one of the + // default Ember toStrings, replace the constructor portion of the toString + // with the class name. We check the length of the class name to prevent doing + // this when the value is minified. - } - if (currentCursor.openBlockDepth === this.blockDepth) { - currentCursor.candidate = this.remove(currentCursor.nextSibling); - currentCursor.openBlockDepth--; + if (name && name.match(/<.*:ember\d+>/) && className && className[0] !== '_' && className.length > 2 && className !== 'Class') { + return name.replace(/<.*:/, `<${className}:`); } - } - __appendNode(node) { - var { - candidate - } = this; // This code path is only used when inserting precisely one node. It needs more - // comparison logic, but we can probably lean on the cases where this code path - // is actually used. + return name || className; + }; - if (candidate) { - return candidate; + var getPrimitiveName = value => { + return String(value); + }; + + debugToString = value => { + if (typeof value === 'function') { + return getFunctionName(value) || `(unknown function)`; + } else if (typeof value === 'object' && value !== null) { + return getObjectName(value) || `(unknown object)`; } else { - return super.__appendNode(node); + return getPrimitiveName(value); } - } + }; + } - __appendHTML(html) { - var candidateBounds = this.markerBounds(); + var debugToString$1 = debugToString; + _exports.debugToString = debugToString$1; - if (candidateBounds) { - var first = candidateBounds.firstNode(); - var last = candidateBounds.lastNode(); - var newBounds = new ConcreteBounds(this.element, first.nextSibling, last.previousSibling); - var possibleEmptyMarker = this.remove(first); - this.remove(last); + function assertNever(value, desc = 'unexpected unreachable branch') { + console.log('unreachable', value); + console.trace(`${desc} :: ${JSON.stringify(value)} (${value})`); + } +}); +define("@glimmer/validator", ["exports", "@ember/polyfills"], function (_exports, _polyfills) { + "use strict"; - if (possibleEmptyMarker !== null && isEmpty$1(possibleEmptyMarker)) { - this.candidate = this.remove(possibleEmptyMarker); + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.bump = bump; + _exports.combine = combine; + _exports.createCombinatorTag = createCombinatorTag; + _exports.createTag = createTag; + _exports.createUpdatableTag = createUpdatableTag; + _exports.isConst = isConst; + _exports.isConstTag = isConstTag; + _exports.validate = validate; + _exports.value = value; + _exports.dirtyTagFor = dirtyTagFor; + _exports.tagFor = tagFor; + _exports.setPropertyDidChange = setPropertyDidChange; + _exports.consume = consume; + _exports.isTracking = isTracking; + _exports.track = track; + _exports.trackedData = trackedData; + _exports.untrack = untrack; + _exports.deprecateMutationsInAutotrackingTransaction = _exports.runInAutotrackingTransaction = _exports.setAutotrackingTransactionEnv = _exports.EPOCH = _exports.VOLATILE = _exports.VOLATILE_TAG = _exports.update = _exports.INITIAL = _exports.dirty = _exports.CURRENT_TAG = _exports.CONSTANT = _exports.CONSTANT_TAG = _exports.COMPUTE = _exports.ALLOW_CYCLES = void 0; + // This is a duplicate utility from @glimmer/util because `@glimmer/validator` + // should not depend on any other @glimmer packages, in order to avoid pulling + // in types and prevent regressions in `@glimmer/tracking` (which has public types). + var symbol = typeof Symbol !== 'undefined' ? Symbol : key => `__${key}${Math.floor(Math.random() * Date.now())}__`; + var runInAutotrackingTransaction; + _exports.runInAutotrackingTransaction = runInAutotrackingTransaction; + var deprecateMutationsInAutotrackingTransaction; + _exports.deprecateMutationsInAutotrackingTransaction = deprecateMutationsInAutotrackingTransaction; + var setAutotrackingTransactionEnv; + _exports.setAutotrackingTransactionEnv = setAutotrackingTransactionEnv; + var assertTagNotConsumed; + var markTagAsConsumed; - if (this.candidate !== null) { - this.clearMismatch(this.candidate); - } + if (true + /* DEBUG */ + ) { + var DEPRECATE_IN_AUTOTRACKING_TRANSACTION = false; + var AUTOTRACKING_TRANSACTION = null; + var debuggingContexts = []; ///////// + + var TRANSACTION_ENV = { + assert(message) { + throw new Error(message); + }, + + deprecate(message) { + console.warn(message); + }, + + debugMessage(obj, keyName) { + var objName; + + if (typeof obj === 'function') { + objName = obj.name; + } else if (typeof obj === 'object' && obj !== null) { + var className = obj.constructor && obj.constructor.name || '(unknown class)'; + objName = `(an instance of ${className})`; + } else if (obj === undefined) { + objName = '(an unknown tag)'; + } else { + objName = String(obj); } - return newBounds; - } else { - return super.__appendHTML(html); + var dirtyString = keyName ? `\`${keyName}\` on \`${objName}\`` : `\`${objName}\``; + return `You attempted to update ${dirtyString}, but it had already been used previously in the same computation. Attempting to update a value after using it in a computation can cause logical errors, infinite revalidation bugs, and performance issues, and is not supported.`; } - } - remove(node) { - var element = node.parentNode; - var next = node.nextSibling; - element.removeChild(node); - return next; - } + }; - markerBounds() { - var _candidate = this.candidate; + _exports.setAutotrackingTransactionEnv = setAutotrackingTransactionEnv = env => (0, _polyfills.assign)(TRANSACTION_ENV, env); + /** + * Creates a global autotracking transaction. This will prevent any backflow + * in any `track` calls within the transaction, even if they are not + * externally consumed. + * + * `runInAutotrackingTransaction` can be called within itself, and it will add + * onto the existing transaction if one exists. + * + * TODO: Only throw an error if the `track` is consumed. + */ - if (_candidate && isMarker(_candidate)) { - var first = _candidate; - var last = first.nextSibling; - while (last && !isMarker(last)) { - last = last.nextSibling; + _exports.runInAutotrackingTransaction = runInAutotrackingTransaction = (fn, debuggingContext) => { + var previousDeprecateState = DEPRECATE_IN_AUTOTRACKING_TRANSACTION; + var previousTransactionState = AUTOTRACKING_TRANSACTION; + DEPRECATE_IN_AUTOTRACKING_TRANSACTION = false; + + if (previousTransactionState === null) { + // if there was no transaction start it. Otherwise, the transaction already exists. + AUTOTRACKING_TRANSACTION = new WeakMap(); + } + + if (debuggingContext) { + debuggingContexts.unshift(debuggingContext); + } + + try { + fn(); + } finally { + if (debuggingContext) { + debuggingContexts.shift(); } - return new ConcreteBounds(this.element, first, last); - } else { - return null; + DEPRECATE_IN_AUTOTRACKING_TRANSACTION = previousDeprecateState; + AUTOTRACKING_TRANSACTION = previousTransactionState; } - } + }; + /** + * Switches to deprecating within an autotracking transaction, if one exists. + * If `runInAutotrackingTransaction` is called within the callback of this + * method, it switches back to throwing an error, allowing zebra-striping of + * the types of errors that are thrown. + * + * Does not start an autotracking transaction. + * + * NOTE: For Ember usage only, in general you should assert that these + * invariants are true. + */ - __appendText(string) { - var { - candidate - } = this; - if (candidate) { - if (isTextNode(candidate)) { - if (candidate.nodeValue !== string) { - candidate.nodeValue = string; - } + _exports.deprecateMutationsInAutotrackingTransaction = deprecateMutationsInAutotrackingTransaction = fn => { + var previousDeprecateState = DEPRECATE_IN_AUTOTRACKING_TRANSACTION; + DEPRECATE_IN_AUTOTRACKING_TRANSACTION = true; - this.candidate = candidate.nextSibling; - return candidate; - } else if (candidate && (isSeparator(candidate) || isEmpty$1(candidate))) { - this.candidate = candidate.nextSibling; - this.remove(candidate); - return this.__appendText(string); - } else if (isEmpty$1(candidate)) { - var next = this.remove(candidate); - this.candidate = next; - var text = this.dom.createTextNode(string); - this.dom.insertBefore(this.element, text, next); - return text; - } else { - this.clearMismatch(candidate); - return super.__appendText(string); - } - } else { - return super.__appendText(string); + try { + fn(); + } finally { + DEPRECATE_IN_AUTOTRACKING_TRANSACTION = previousDeprecateState; } - } + }; - __appendComment(string) { - var _candidate = this.candidate; + var nthIndex = (str, pattern, n, startingPos = -1) => { + var i = startingPos; - if (_candidate && isComment(_candidate)) { - if (_candidate.nodeValue !== string) { - _candidate.nodeValue = string; - } + while (n-- > 0 && i++ < str.length) { + i = str.indexOf(pattern, i); + if (i < 0) break; + } - this.candidate = _candidate.nextSibling; - return _candidate; - } else if (_candidate) { - this.clearMismatch(_candidate); + return i; + }; + + var makeAutotrackingErrorMessage = (sourceData, obj, keyName) => { + var message = [TRANSACTION_ENV.debugMessage(obj, keyName && String(keyName))]; + + if (sourceData.context) { + message.push(`\`${String(keyName)}\` was first used:\n\n${sourceData.context}`); } - return super.__appendComment(string); - } + if (sourceData.error.stack) { + var sourceStack = sourceData.error.stack; + var thirdIndex = nthIndex(sourceStack, '\n', 3); + sourceStack = sourceStack.substr(thirdIndex); + message.push(`Stack trace for the first usage: ${sourceStack}`); + } - __openElement(tag) { - var _candidate = this.candidate; + message.push(`Stack trace for the update:`); + return message.join('\n\n'); + }; - if (_candidate && isElement(_candidate) && isSameNodeType(_candidate, tag)) { - this.unmatchedAttributes = [].slice.call(_candidate.attributes); - return _candidate; - } else if (_candidate) { - if (isElement(_candidate) && _candidate.tagName === 'TBODY') { - this.pushElement(_candidate, null); - this.currentCursor.injectedOmittedNode = true; - return this.__openElement(tag); - } + markTagAsConsumed = (_tag, sourceError) => { + if (!AUTOTRACKING_TRANSACTION || AUTOTRACKING_TRANSACTION.has(_tag)) return; + AUTOTRACKING_TRANSACTION.set(_tag, { + context: debuggingContexts.map(c => c.replace(/^/gm, ' ').replace(/^ /, '-')).join('\n\n'), + error: sourceError + }); // We need to mark the tag and all of its subtags as consumed, so we need to + // cast it and access its internals. In the future this shouldn't be necessary, + // this is only for computed properties. - this.clearMismatch(_candidate); + var tag = _tag; + + if (tag.subtag) { + markTagAsConsumed(tag.subtag, sourceError); } - return super.__openElement(tag); - } + if (tag.subtags) { + tag.subtags.forEach(tag => markTagAsConsumed(tag, sourceError)); + } + }; - __setAttribute(name, value$$1, namespace) { - var unmatched = this.unmatchedAttributes; + assertTagNotConsumed = (tag, obj, keyName, forceHardError = false) => { + if (AUTOTRACKING_TRANSACTION === null) return; + var sourceData = AUTOTRACKING_TRANSACTION.get(tag); + if (!sourceData) return; - if (unmatched) { - var attr = findByName(unmatched, name); + if (DEPRECATE_IN_AUTOTRACKING_TRANSACTION && !forceHardError) { + TRANSACTION_ENV.deprecate(makeAutotrackingErrorMessage(sourceData, obj, keyName)); + } else { + // This hack makes the assertion message nicer, we can cut off the first + // few lines of the stack trace and let users know where the actual error + // occurred. + try { + TRANSACTION_ENV.assert(makeAutotrackingErrorMessage(sourceData, obj, keyName)); + } catch (e) { + if (e.stack) { + var updateStackBegin = e.stack.indexOf('Stack trace for the update:'); - if (attr) { - if (attr.value !== value$$1) { - attr.value = value$$1; + if (updateStackBegin !== -1) { + var start = nthIndex(e.stack, '\n', 1, updateStackBegin); + var end = nthIndex(e.stack, '\n', 4, updateStackBegin); + e.stack = e.stack.substr(0, start) + e.stack.substr(end); + } } - unmatched.splice(unmatched.indexOf(attr), 1); - return; + throw e; } } + }; + } - return super.__setAttribute(name, value$$1, namespace); - } + var CONSTANT = 0; + _exports.CONSTANT = CONSTANT; + var INITIAL = 1; + _exports.INITIAL = INITIAL; + var VOLATILE = 9007199254740991; // MAX_INT + + _exports.VOLATILE = VOLATILE; + var $REVISION = INITIAL; + + function bump() { + $REVISION++; + } ////////// + + + var COMPUTE = symbol('TAG_COMPUTE'); ////////// + + /** + * `value` receives a tag and returns an opaque Revision based on that tag. This + * snapshot can then later be passed to `validate` with the same tag to + * determine if the tag has changed at all since the time that `value` was + * called. + * + * The current implementation returns the global revision count directly for + * performance reasons. This is an implementation detail, and should not be + * relied on directly by users of these APIs. Instead, Revisions should be + * treated as if they are opaque/unknown, and should only be interacted with via + * the `value`/`validate` API. + * + * @param tag + */ + + _exports.COMPUTE = COMPUTE; + + function value(_tag) { + return $REVISION; + } + /** + * `validate` receives a tag and a snapshot from a previous call to `value` with + * the same tag, and determines if the tag is still valid compared to the + * snapshot. If the tag's state has changed at all since then, `validate` will + * return false, otherwise it will return true. This is used to determine if a + * calculation related to the tags should be rerun. + * + * @param tag + * @param snapshot + */ - __setProperty(name, value$$1) { - var unmatched = this.unmatchedAttributes; - if (unmatched) { - var attr = findByName(unmatched, name); + function validate(tag, snapshot) { + return snapshot >= tag[COMPUTE](); + } - if (attr) { - if (attr.value !== value$$1) { - attr.value = value$$1; - } + var TYPE = symbol('TAG_TYPE'); + var ALLOW_CYCLES; + _exports.ALLOW_CYCLES = ALLOW_CYCLES; - unmatched.splice(unmatched.indexOf(attr), 1); - return; - } - } + if (true + /* DEBUG */ + ) { + _exports.ALLOW_CYCLES = ALLOW_CYCLES = new WeakMap(); + } - return super.__setProperty(name, value$$1); + class MonomorphicTagImpl { + constructor(type) { + this.revision = INITIAL; + this.lastChecked = INITIAL; + this.lastValue = INITIAL; + this.isUpdating = false; + this.subtags = null; + this.subtag = null; + this.subtagBufferCache = null; + this[TYPE] = type; } - __flushElement(parent, constructing) { + [COMPUTE]() { var { - unmatchedAttributes: unmatched + lastChecked } = this; - if (unmatched) { - for (var i = 0; i < unmatched.length; i++) { - this.constructing.removeAttribute(unmatched[i].name); + if (this.isUpdating === true) { + if (true + /* DEBUG */ + && !ALLOW_CYCLES.has(this)) { + throw new Error('Cycles in tags are not allowed'); } - this.unmatchedAttributes = null; - } else { - super.__flushElement(parent, constructing); - } - } + this.lastChecked = ++$REVISION; + } else if (lastChecked !== $REVISION) { + this.isUpdating = true; + this.lastChecked = $REVISION; - willCloseElement() { - var { - candidate, - currentCursor - } = this; + try { + var { + subtags, + subtag, + subtagBufferCache, + lastValue, + revision + } = this; - if (candidate !== null) { - this.clearMismatch(candidate); - } + if (subtag !== null) { + var subtagValue = subtag[COMPUTE](); - if (currentCursor && currentCursor.injectedOmittedNode) { - this.popElement(); - } + if (subtagValue === subtagBufferCache) { + revision = Math.max(revision, lastValue); + } else { + // Clear the temporary buffer cache + this.subtagBufferCache = null; + revision = Math.max(revision, subtagValue); + } + } - super.willCloseElement(); - } + if (subtags !== null) { + for (var i = 0; i < subtags.length; i++) { + var _value = subtags[i][COMPUTE](); - getMarker(element, guid) { - var marker = element.querySelector("script[glmr=\"" + guid + "\"]"); + revision = Math.max(_value, revision); + } + } - if (marker) { - return marker; + this.lastValue = revision; + } finally { + this.isUpdating = false; + } } - throw new Error('Cannot find serialized cursor for `in-element`'); + return this.lastValue; } - __pushRemoteElement(element, cursorId, nextSibling = null) { - var marker = this.getMarker(element, cursorId); + static update(_tag, _subtag) { + if (true + /* DEBUG */ + && _tag[TYPE] !== 1 + /* Updatable */ + ) { + throw new Error('Attempted to update a tag that was not updatable'); + } // TODO: TS 3.7 should allow us to do this via assertion - if (marker.parentNode === element) { - var currentCursor = this.currentCursor; - var candidate = currentCursor.candidate; - this.pushElement(element, nextSibling); - currentCursor.candidate = candidate; - this.candidate = this.remove(marker); - var tracker = new RemoteBlockTracker(element); - this.pushBlockTracker(tracker, true); - } - } - didAppendBounds(bounds) { - super.didAppendBounds(bounds); + var tag = _tag; + var subtag = _subtag; - if (this.candidate) { - var last = bounds.lastNode(); - this.candidate = last && last.nextSibling; + if (subtag === CONSTANT_TAG) { + tag.subtag = null; + } else { + // There are two different possibilities when updating a subtag: + // + // 1. subtag[COMPUTE]() <= tag[COMPUTE](); + // 2. subtag[COMPUTE]() > tag[COMPUTE](); + // + // The first possibility is completely fine within our caching model, but + // the second possibility presents a problem. If the parent tag has + // already been read, then it's value is cached and will not update to + // reflect the subtag's greater value. Next time the cache is busted, the + // subtag's value _will_ be read, and it's value will be _greater_ than + // the saved snapshot of the parent, causing the resulting calculation to + // be rerun erroneously. + // + // In order to prevent this, when we first update to a new subtag we store + // its computed value, and then check against that computed value on + // subsequent updates. If its value hasn't changed, then we return the + // parent's previous value. Once the subtag changes for the first time, + // we clear the cache and everything is finally in sync with the parent. + tag.subtagBufferCache = subtag[COMPUTE](); + tag.subtag = subtag; } - - return bounds; } - } + static dirty(tag) { + if (true + /* DEBUG */ + && !(tag[TYPE] === 1 + /* Updatable */ + || tag[TYPE] === 0 + /* Dirtyable */ + )) { + throw new Error('Attempted to dirty a tag that was not dirtyable'); + } - _exports.RehydrateBuilder = RehydrateBuilder; + if (true + /* DEBUG */ + ) { + // Usually by this point, we've already asserted with better error information, + // but this is our last line of defense. + assertTagNotConsumed(tag); + } - function isTextNode(node) { - return node.nodeType === 3; - } + tag.revision = ++$REVISION; + } - function isComment(node) { - return node.nodeType === 8; } - function getOpenBlockDepth(node) { - var boundsDepth = node.nodeValue.match(/^%\+b:(\d+)%$/); - - if (boundsDepth && boundsDepth[1]) { - return Number(boundsDepth[1]); - } else { - return null; - } - } + var dirty = MonomorphicTagImpl.dirty; + _exports.dirty = dirty; + var update = MonomorphicTagImpl.update; ////////// - function getCloseBlockDepth(node) { - var boundsDepth = node.nodeValue.match(/^%\-b:(\d+)%$/); + _exports.update = update; - if (boundsDepth && boundsDepth[1]) { - return Number(boundsDepth[1]); - } else { - return null; - } + function createTag() { + return new MonomorphicTagImpl(0 + /* Dirtyable */ + ); } - function isElement(node) { - return node.nodeType === 1; - } + function createUpdatableTag() { + return new MonomorphicTagImpl(1 + /* Updatable */ + ); + } ////////// - function isMarker(node) { - return node.nodeType === 8 && node.nodeValue === '%glmr%'; - } - function isSeparator(node) { - return node.nodeType === 8 && node.nodeValue === '%|%'; - } + var CONSTANT_TAG = new MonomorphicTagImpl(3 + /* Constant */ + ); + _exports.CONSTANT_TAG = CONSTANT_TAG; - function isEmpty$1(node) { - return node.nodeType === 8 && node.nodeValue === '% %'; + function isConst({ + tag + }) { + return tag === CONSTANT_TAG; } - function isSameNodeType(candidate, tag) { - if (candidate.namespaceURI === SVG_NAMESPACE) { - return candidate.tagName === tag; - } + function isConstTag(tag) { + return tag === CONSTANT_TAG; + } ////////// - return candidate.tagName === tag.toUpperCase(); - } - function findByName(array, name) { - for (var i = 0; i < array.length; i++) { - var attr = array[i]; - if (attr.name === name) return attr; + class VolatileTag { + [COMPUTE]() { + return VOLATILE; } - return undefined; } - function rehydrationBuilder(env, cursor) { - return RehydrateBuilder.forInitialRender(env, cursor); - } -}); -define("@glimmer/util", ["exports"], function (_exports) { - "use strict"; + var VOLATILE_TAG = new VolatileTag(); ////////// - Object.defineProperty(_exports, "__esModule", { - value: true - }); - _exports.assert = debugAssert; - _exports.assign = assign; - _exports.fillNulls = fillNulls; - _exports.ensureGuid = ensureGuid; - _exports.initializeGuid = initializeGuid; - _exports.dict = dict; - _exports.unwrap = unwrap; - _exports.expect = expect; - _exports.unreachable = unreachable; - _exports.EMPTY_ARRAY = _exports.ListSlice = _exports.ListNode = _exports.LinkedList = _exports.EMPTY_SLICE = _exports.DictSet = _exports.Stack = void 0; + _exports.VOLATILE_TAG = VOLATILE_TAG; - function unwrap(val) { - if (val === null || val === undefined) throw new Error("Expected value to be present"); - return val; - } + class CurrentTag { + [COMPUTE]() { + return $REVISION; + } - function expect(val, message) { - if (val === null || val === undefined) throw new Error(message); - return val; } - function unreachable(message = 'unreachable') { - return new Error(message); - } // import Logger from './logger'; - // let alreadyWarned = false; - - - function debugAssert(test, msg) { - // if (!alreadyWarned) { - // alreadyWarned = true; - // Logger.warn("Don't leave debug assertions on in public builds"); - // } - if (!test) { - throw new Error(msg || 'assertion failure'); - } - } + var CURRENT_TAG = new CurrentTag(); ////////// - var { - keys: objKeys - } = Object; + _exports.CURRENT_TAG = CURRENT_TAG; - function assign(obj) { - for (var i = 1; i < arguments.length; i++) { - var assignment = arguments[i]; - if (assignment === null || typeof assignment !== 'object') continue; - var keys = objKeys(assignment); + function combine(tags) { + var optimized = []; - for (var j = 0; j < keys.length; j++) { - var key = keys[j]; - obj[key] = assignment[key]; - } + for (var i = 0, l = tags.length; i < l; i++) { + var tag = tags[i]; + if (tag === CONSTANT_TAG) continue; + optimized.push(tag); } - return obj; + return createCombinatorTag(optimized); } - function fillNulls(count) { - var arr = new Array(count); + function createCombinatorTag(tags) { + switch (tags.length) { + case 0: + return CONSTANT_TAG; - for (var i = 0; i < count; i++) { - arr[i] = null; - } + case 1: + return tags[0]; - return arr; + default: + var tag = new MonomorphicTagImpl(2 + /* Combinator */ + ); + tag.subtags = tags; + return tag; + } } - var GUID = 0; - - function initializeGuid(object) { - return object._guid = ++GUID; - } + var propertyDidChange = function () {}; - function ensureGuid(object) { - return object._guid || initializeGuid(object); + function setPropertyDidChange(cb) { + propertyDidChange = cb; } - function dict() { - return Object.create(null); + function isObject(u) { + return typeof u === 'object' && u !== null || typeof u === 'function'; } - class DictSet { - constructor() { - this.dict = dict(); - } - - add(obj) { - if (typeof obj === 'string') this.dict[obj] = obj;else this.dict[ensureGuid(obj)] = obj; - return this; - } + var TRACKED_TAGS = new WeakMap(); - delete(obj) { - if (typeof obj === 'string') delete this.dict[obj];else if (obj._guid) delete this.dict[obj._guid]; - } + function dirtyTagFor(obj, key) { + if (isObject(obj)) { + var tags = TRACKED_TAGS.get(obj); // No tags have been setup for this object yet, return - } + if (tags === undefined) return; // Dirty the tag for the specific property if it exists - _exports.DictSet = DictSet; + var propertyTag = tags.get(key); - class Stack { - constructor() { - this.stack = []; - this.current = null; - } + if (propertyTag !== undefined) { + if (true + /* DEBUG */ + ) { + assertTagNotConsumed(propertyTag, obj, key); + } - get size() { - return this.stack.length; + dirty(propertyTag); + propertyDidChange(); + } + } else { + throw new Error(`BUG: Can't update a tag for a primitive`); } + } - push(item) { - this.current = item; - this.stack.push(item); - } + function tagFor(obj, key) { + if (isObject(obj)) { + var tags = TRACKED_TAGS.get(obj); - pop() { - var item = this.stack.pop(); - var len = this.stack.length; - this.current = len === 0 ? null : this.stack[len - 1]; - return item === undefined ? null : item; - } + if (tags === undefined) { + tags = new Map(); + TRACKED_TAGS.set(obj, tags); + } else if (tags.has(key)) { + return tags.get(key); + } - isEmpty() { - return this.stack.length === 0; + var tag = createUpdatableTag(); + tags.set(key, tag); + return tag; + } else { + return CONSTANT_TAG; } - } + /** + * Whenever a tracked computed property is entered, the current tracker is + * saved off and a new tracker is replaced. + * + * Any tracked properties consumed are added to the current tracker. + * + * When a tracked computed property is exited, the tracker's tags are + * combined and added to the parent tracker. + * + * The consequence is that each tracked computed property has a tag + * that corresponds to the tracked properties consumed inside of + * itself, including child tracked computed properties. + */ - _exports.Stack = Stack; - - class ListNode { - constructor(value) { - this.next = null; - this.prev = null; - this.value = value; - } - - } - _exports.ListNode = ListNode; + var CURRENT_TRACKER = null; + /** + * An object that that tracks @tracked properties that were consumed. + */ - class LinkedList { + class Tracker { constructor() { - this.clear(); - } - - head() { - return this._head; - } - - tail() { - return this._tail; + this.tags = new Set(); + this.last = null; } - clear() { - this._head = this._tail = null; - } + add(tag) { + this.tags.add(tag); - toArray() { - var out = []; - this.forEachNode(n => out.push(n)); - return out; - } + if (true + /* DEBUG */ + ) { + markTagAsConsumed(tag, new Error()); + } - nextNode(node) { - return node.next; + this.last = tag; } - forEachNode(callback) { - var node = this._head; + combine() { + var { + tags + } = this; - while (node !== null) { - callback(node); - node = node.next; + if (tags.size === 0) { + return CONSTANT_TAG; + } else if (tags.size === 1) { + return this.last; + } else { + var tagsArr = []; + tags.forEach(tag => tagsArr.push(tag)); + return combine(tagsArr); } } - insertBefore(node, reference = null) { - if (reference === null) return this.append(node); - if (reference.prev) reference.prev.next = node;else this._head = node; - node.prev = reference.prev; - node.next = reference; - reference.prev = node; - return node; - } + } ////////// - append(node) { - var tail = this._tail; - if (tail) { - tail.next = node; - node.prev = tail; - node.next = null; + function track(callback, debuggingContext) { + var parent = CURRENT_TRACKER; + var current = new Tracker(); + CURRENT_TRACKER = current; + + try { + if (true + /* DEBUG */ + ) { + runInAutotrackingTransaction(callback, debuggingContext); } else { - this._head = node; + callback(); } - - return this._tail = node; + } finally { + CURRENT_TRACKER = parent; } - remove(node) { - if (node.prev) node.prev.next = node.next;else this._head = node.next; - if (node.next) node.next.prev = node.prev;else this._tail = node.prev; - return node; + return current.combine(); + } + + function consume(tag) { + if (CURRENT_TRACKER !== null) { + CURRENT_TRACKER.add(tag); } + } + function isTracking() { + return CURRENT_TRACKER !== null; } - _exports.LinkedList = LinkedList; + function untrack(callback) { + var parent = CURRENT_TRACKER; + CURRENT_TRACKER = null; - class ListSlice { - constructor(head, tail) { - this._head = head; - this._tail = tail; + try { + callback(); + } finally { + CURRENT_TRACKER = parent; } + } ////////// - forEachNode(callback) { - var node = this._head; - while (node !== null) { - callback(node); - node = this.nextNode(node); - } - } + var EPOCH = createTag(); + _exports.EPOCH = EPOCH; - head() { - return this._head; - } + function trackedData(key, initializer) { + var values = new WeakMap(); + var hasInitializer = typeof initializer === 'function'; - tail() { - return this._tail; - } + function getter(self) { + consume(tagFor(self, key)); + var value$$1; // If the field has never been initialized, we should initialize it - toArray() { - var out = []; - this.forEachNode(n => out.push(n)); - return out; + if (hasInitializer && !values.has(self)) { + value$$1 = initializer.call(self); + values.set(self, value$$1); + } else { + value$$1 = values.get(self); + } + + return value$$1; } - nextNode(node) { - if (node === this._tail) return null; - return node.next; + function setter(self, value$$1) { + if (true + /* DEBUG */ + ) { + assertTagNotConsumed(tagFor(self, key), self, key, true); + } + + dirty(EPOCH); + dirtyTagFor(self, key); + values.set(self, value$$1); } + return { + getter, + setter + }; } - - _exports.ListSlice = ListSlice; - var EMPTY_SLICE = new ListSlice(null, null); - _exports.EMPTY_SLICE = EMPTY_SLICE; - var EMPTY_ARRAY = Object.freeze([]); - _exports.EMPTY_ARRAY = EMPTY_ARRAY; }); define("@glimmer/vm", ["exports"], function (_exports) { "use strict"; @@ -54829,35 +56808,72 @@ define("@glimmer/vm", ["exports"], function (_exports) { Object.defineProperty(_exports, "__esModule", { value: true }); - _exports.Register = void 0; + _exports.isMachineOp = isMachineOp; + _exports.isOp = isOp; + _exports.isLowLevelRegister = isLowLevelRegister; + _exports.$v0 = _exports.$t1 = _exports.$t0 = _exports.$s1 = _exports.$s0 = _exports.$sp = _exports.$ra = _exports.$fp = _exports.$pc = _exports.TemporaryRegister = _exports.SavedRegister = void 0; + + /* This file is generated by build/debug.js */ + function isMachineOp(value) { + return value >= 0 && value <= 15; + } + function isOp(value) { + return value >= 16; + } /** * Registers * * For the most part, these follows MIPS naming conventions, however the * register numbers are different. */ - var Register; - _exports.Register = Register; + // $0 or $pc (program counter): pointer into `program` for the next insturction; -1 means exit + + + var $pc = 0; // $1 or $ra (return address): pointer into `program` for the return + + _exports.$pc = $pc; + var $ra = 1; // $2 or $fp (frame pointer): pointer into the `evalStack` for the base of the stack - (function (Register) { - // $0 or $pc (program counter): pointer into `program` for the next insturction; -1 means exit - Register[Register["pc"] = 0] = "pc"; // $1 or $ra (return address): pointer into `program` for the return + _exports.$ra = $ra; + var $fp = 2; // $3 or $sp (stack pointer): pointer into the `evalStack` for the top of the stack - Register[Register["ra"] = 1] = "ra"; // $2 or $fp (frame pointer): pointer into the `evalStack` for the base of the stack + _exports.$fp = $fp; + var $sp = 3; // $4-$5 or $s0-$s1 (saved): callee saved general-purpose registers - Register[Register["fp"] = 2] = "fp"; // $3 or $sp (stack pointer): pointer into the `evalStack` for the top of the stack + _exports.$sp = $sp; + var $s0 = 4; + _exports.$s0 = $s0; + var $s1 = 5; // $6-$7 or $t0-$t1 (temporaries): caller saved general-purpose registers + + _exports.$s1 = $s1; + var $t0 = 6; + _exports.$t0 = $t0; + var $t1 = 7; // $8 or $v0 (return value) + + _exports.$t1 = $t1; + var $v0 = 8; + _exports.$v0 = $v0; + + function isLowLevelRegister(register) { + return register <= $sp; + } - Register[Register["sp"] = 3] = "sp"; // $4-$5 or $s0-$s1 (saved): callee saved general-purpose registers + var SavedRegister; + _exports.SavedRegister = SavedRegister; - Register[Register["s0"] = 4] = "s0"; - Register[Register["s1"] = 5] = "s1"; // $6-$7 or $t0-$t1 (temporaries): caller saved general-purpose registers + (function (SavedRegister) { + SavedRegister[SavedRegister["s0"] = 4] = "s0"; + SavedRegister[SavedRegister["s1"] = 5] = "s1"; + })(SavedRegister || (_exports.SavedRegister = SavedRegister = {})); - Register[Register["t0"] = 6] = "t0"; - Register[Register["t1"] = 7] = "t1"; // $8 or $v0 (return value) + var TemporaryRegister; + _exports.TemporaryRegister = TemporaryRegister; - Register[Register["v0"] = 8] = "v0"; - })(Register || (_exports.Register = Register = {})); + (function (TemporaryRegister) { + TemporaryRegister[TemporaryRegister["t0"] = 6] = "t0"; + TemporaryRegister[TemporaryRegister["t1"] = 7] = "t1"; + })(TemporaryRegister || (_exports.TemporaryRegister = TemporaryRegister = {})); }); define("@glimmer/wire-format", ["exports"], function (_exports) { "use strict"; @@ -54868,45 +56884,8 @@ define("@glimmer/wire-format", ["exports"], function (_exports) { _exports.is = is; _exports.isAttribute = isAttribute; _exports.isArgument = isArgument; - _exports.isMaybeLocal = _exports.isGet = _exports.isFlushElement = _exports.Ops = void 0; - var Opcodes; - _exports.Ops = Opcodes; - - (function (Opcodes) { - // Statements - Opcodes[Opcodes["Text"] = 0] = "Text"; - Opcodes[Opcodes["Append"] = 1] = "Append"; - Opcodes[Opcodes["Comment"] = 2] = "Comment"; - Opcodes[Opcodes["Modifier"] = 3] = "Modifier"; - Opcodes[Opcodes["Block"] = 4] = "Block"; - Opcodes[Opcodes["Component"] = 5] = "Component"; - Opcodes[Opcodes["DynamicComponent"] = 6] = "DynamicComponent"; - Opcodes[Opcodes["OpenElement"] = 7] = "OpenElement"; - Opcodes[Opcodes["FlushElement"] = 8] = "FlushElement"; - Opcodes[Opcodes["CloseElement"] = 9] = "CloseElement"; - Opcodes[Opcodes["StaticAttr"] = 10] = "StaticAttr"; - Opcodes[Opcodes["DynamicAttr"] = 11] = "DynamicAttr"; - Opcodes[Opcodes["ComponentAttr"] = 12] = "ComponentAttr"; - Opcodes[Opcodes["AttrSplat"] = 13] = "AttrSplat"; - Opcodes[Opcodes["Yield"] = 14] = "Yield"; - Opcodes[Opcodes["Partial"] = 15] = "Partial"; - Opcodes[Opcodes["DynamicArg"] = 16] = "DynamicArg"; - Opcodes[Opcodes["StaticArg"] = 17] = "StaticArg"; - Opcodes[Opcodes["TrustingAttr"] = 18] = "TrustingAttr"; - Opcodes[Opcodes["TrustingComponentAttr"] = 19] = "TrustingComponentAttr"; - Opcodes[Opcodes["Debugger"] = 20] = "Debugger"; - Opcodes[Opcodes["ClientSideStatement"] = 21] = "ClientSideStatement"; // Expressions - - Opcodes[Opcodes["Unknown"] = 22] = "Unknown"; - Opcodes[Opcodes["Get"] = 23] = "Get"; - Opcodes[Opcodes["MaybeLocal"] = 24] = "MaybeLocal"; - Opcodes[Opcodes["HasBlock"] = 25] = "HasBlock"; - Opcodes[Opcodes["HasBlockParams"] = 26] = "HasBlockParams"; - Opcodes[Opcodes["Undefined"] = 27] = "Undefined"; - Opcodes[Opcodes["Helper"] = 28] = "Helper"; - Opcodes[Opcodes["Concat"] = 29] = "Concat"; - Opcodes[Opcodes["ClientSideExpression"] = 30] = "ClientSideExpression"; - })(Opcodes || (_exports.Ops = Opcodes = {})); + _exports.isHelper = isHelper; + _exports.isGet = _exports.isFlushElement = void 0; function is(variant) { return function (value) { @@ -54915,22 +56894,552 @@ define("@glimmer/wire-format", ["exports"], function (_exports) { } // Statements - var isFlushElement = is(Opcodes.FlushElement); + var isFlushElement = is(10 + /* FlushElement */ + ); _exports.isFlushElement = isFlushElement; function isAttribute(val) { - return val[0] === Opcodes.StaticAttr || val[0] === Opcodes.DynamicAttr || val[0] === Opcodes.ComponentAttr || val[0] === Opcodes.TrustingAttr || val[0] === Opcodes.TrustingComponentAttr || val[0] === Opcodes.AttrSplat || val[0] === Opcodes.Modifier; + return val[0] === 12 + /* StaticAttr */ + || val[0] === 13 + /* DynamicAttr */ + || val[0] === 20 + /* TrustingDynamicAttr */ + || val[0] === 14 + /* ComponentAttr */ + || val[0] === 23 + /* StaticComponentAttr */ + || val[0] === 21 + /* TrustingComponentAttr */ + || val[0] === 15 + /* AttrSplat */ + || val[0] === 3 + /* Modifier */ + ; } function isArgument(val) { - return val[0] === Opcodes.StaticArg || val[0] === Opcodes.DynamicArg; + return val[0] === 19 + /* StaticArg */ + || val[0] === 18 + /* DynamicArg */ + ; + } + + function isHelper(expr) { + return Array.isArray(expr) && expr[0] === 31 + /* Call */ + ; } // Expressions - var isGet = is(Opcodes.Get); + var isGet = is(24 + /* GetSymbol */ + ); _exports.isGet = isGet; - var isMaybeLocal = is(Opcodes.MaybeLocal); - _exports.isMaybeLocal = isMaybeLocal; +}); +define("@simple-dom/document", ["exports"], function (_exports) { + "use strict"; + + Object.defineProperty(_exports, "__esModule", { + value: true + }); + _exports.default = void 0; + var EMPTY_ATTRS = []; + + function indexOfAttribute(attributes, namespaceURI, localName) { + for (var i = 0; i < attributes.length; i++) { + var attr = attributes[i]; + + if (attr.namespaceURI === namespaceURI && attr.localName === localName) { + return i; + } + } + + return -1; + } + + function adjustAttrName(namespaceURI, localName) { + return namespaceURI === "http://www.w3.org/1999/xhtml" + /* HTML */ + ? localName.toLowerCase() : localName; + } + + function getAttribute(attributes, namespaceURI, localName) { + var index = indexOfAttribute(attributes, namespaceURI, localName); + return index === -1 ? null : attributes[index].value; + } + + function removeAttribute(attributes, namespaceURI, localName) { + var index = indexOfAttribute(attributes, namespaceURI, localName); + + if (index !== -1) { + attributes.splice(index, 1); + } + } // https://dom.spec.whatwg.org/#dom-element-setattributens + + + function setAttribute(element, namespaceURI, prefix, localName, value) { + if (typeof value !== 'string') { + value = '' + value; + } + + var { + attributes + } = element; + + if (attributes === EMPTY_ATTRS) { + attributes = element.attributes = []; + } else { + var index = indexOfAttribute(attributes, namespaceURI, localName); + + if (index !== -1) { + attributes[index].value = value; + return; + } + } + + attributes.push({ + localName, + name: prefix === null ? localName : prefix + ':' + localName, + namespaceURI, + prefix, + specified: true, + value + }); + } + + class ChildNodes { + constructor(node) { + this.node = node; + this.stale = true; + this._length = 0; + } + + get length() { + if (this.stale) { + this.stale = false; + var len = 0; + var child = this.node.firstChild; + + for (; child !== null; len++) { + this[len] = child; + child = child.nextSibling; + } + + var oldLen = this._length; + this._length = len; + + for (; len < oldLen; len++) { + delete this[len]; + } + } + + return this._length; + } + + item(index) { + return index < this.length ? this[index] : null; + } + + } + + function cloneNode(node, deep) { + var clone = nodeFrom(node); + + if (deep) { + var child = node.firstChild; + var nextChild = child; + + while (child !== null) { + nextChild = child.nextSibling; + clone.appendChild(child.cloneNode(true)); + child = nextChild; + } + } + + return clone; + } + + function nodeFrom(node) { + var namespaceURI; + + if (node.nodeType === 1 + /* ELEMENT_NODE */ + ) { + namespaceURI = node.namespaceURI; + } + + var clone = new SimpleNodeImpl(node.ownerDocument, node.nodeType, node.nodeName, node.nodeValue, namespaceURI); + + if (node.nodeType === 1 + /* ELEMENT_NODE */ + ) { + clone.attributes = copyAttrs(node.attributes); + } + + return clone; + } + + function copyAttrs(attrs) { + if (attrs === EMPTY_ATTRS) { + return EMPTY_ATTRS; + } + + var copy = []; + + for (var i = 0; i < attrs.length; i++) { + var attr = attrs[i]; + copy.push({ + localName: attr.localName, + name: attr.name, + namespaceURI: attr.namespaceURI, + prefix: attr.prefix, + specified: true, + value: attr.value + }); + } + + return copy; + } + + function insertBefore(parentNode, newChild, refChild) { + invalidate(parentNode); + insertBetween(parentNode, newChild, refChild === null ? parentNode.lastChild : refChild.previousSibling, refChild); + } + + function removeChild(parentNode, oldChild) { + invalidate(parentNode); + removeBetween(parentNode, oldChild, oldChild.previousSibling, oldChild.nextSibling); + } + + function invalidate(parentNode) { + var childNodes = parentNode._childNodes; + + if (childNodes !== undefined) { + childNodes.stale = true; + } + } + + function insertBetween(parentNode, newChild, previousSibling, nextSibling) { + if (newChild.nodeType === 11 + /* DOCUMENT_FRAGMENT_NODE */ + ) { + insertFragment(newChild, parentNode, previousSibling, nextSibling); + return; + } + + if (newChild.parentNode !== null) { + removeChild(newChild.parentNode, newChild); + } + + newChild.parentNode = parentNode; + newChild.previousSibling = previousSibling; + newChild.nextSibling = nextSibling; + + if (previousSibling === null) { + parentNode.firstChild = newChild; + } else { + previousSibling.nextSibling = newChild; + } + + if (nextSibling === null) { + parentNode.lastChild = newChild; + } else { + nextSibling.previousSibling = newChild; + } + } + + function removeBetween(parentNode, oldChild, previousSibling, nextSibling) { + oldChild.parentNode = null; + oldChild.previousSibling = null; + oldChild.nextSibling = null; + + if (previousSibling === null) { + parentNode.firstChild = nextSibling; + } else { + previousSibling.nextSibling = nextSibling; + } + + if (nextSibling === null) { + parentNode.lastChild = previousSibling; + } else { + nextSibling.previousSibling = previousSibling; + } + } + + function insertFragment(fragment, parentNode, previousSibling, nextSibling) { + var firstChild = fragment.firstChild; + + if (firstChild === null) { + return; + } + + fragment.firstChild = null; + fragment.lastChild = null; + var lastChild = firstChild; + var newChild = firstChild; + firstChild.previousSibling = previousSibling; + + if (previousSibling === null) { + parentNode.firstChild = firstChild; + } else { + previousSibling.nextSibling = firstChild; + } + + while (newChild !== null) { + newChild.parentNode = parentNode; + lastChild = newChild; + newChild = newChild.nextSibling; + } + + lastChild.nextSibling = nextSibling; + + if (nextSibling === null) { + parentNode.lastChild = lastChild; + } else { + nextSibling.previousSibling = lastChild; + } + } + + function parseQualifiedName(qualifiedName) { + var localName = qualifiedName; + var prefix = null; + var i = qualifiedName.indexOf(':'); + + if (i !== -1) { + prefix = qualifiedName.slice(0, i); + localName = qualifiedName.slice(i + 1); + } + + return [prefix, localName]; + } + + class SimpleNodeImpl { + constructor(ownerDocument, nodeType, nodeName, nodeValue, namespaceURI) { + this.ownerDocument = ownerDocument; + this.nodeType = nodeType; + this.nodeName = nodeName; + this.nodeValue = nodeValue; + this.namespaceURI = namespaceURI; + this.parentNode = null; + this.previousSibling = null; + this.nextSibling = null; + this.firstChild = null; + this.lastChild = null; + this.attributes = EMPTY_ATTRS; + /** + * @internal + */ + + this._childNodes = undefined; + } + + get tagName() { + return this.nodeName; + } + + get childNodes() { + var children = this._childNodes; + + if (children === undefined) { + children = this._childNodes = new ChildNodes(this); + } + + return children; + } + + cloneNode(deep) { + return cloneNode(this, deep === true); + } + + appendChild(newChild) { + insertBefore(this, newChild, null); + return newChild; + } + + insertBefore(newChild, refChild) { + insertBefore(this, newChild, refChild); + return newChild; + } + + removeChild(oldChild) { + removeChild(this, oldChild); + return oldChild; + } + + insertAdjacentHTML(position, html) { + var raw = new SimpleNodeImpl(this.ownerDocument, -1 + /* RAW_NODE */ + , '#raw', html, void 0); + var parentNode; + var nextSibling; + + switch (position) { + case 'beforebegin': + parentNode = this.parentNode; + nextSibling = this; + break; + + case 'afterbegin': + parentNode = this; + nextSibling = this.firstChild; + break; + + case 'beforeend': + parentNode = this; + nextSibling = null; + break; + + case 'afterend': + parentNode = this.parentNode; + nextSibling = this.nextSibling; + break; + + default: + throw new Error('invalid position'); + } + + if (parentNode === null) { + throw new Error(`${position} requires a parentNode`); + } + + insertBefore(parentNode, raw, nextSibling); + } + + getAttribute(name) { + var localName = adjustAttrName(this.namespaceURI, name); + return getAttribute(this.attributes, null, localName); + } + + getAttributeNS(namespaceURI, localName) { + return getAttribute(this.attributes, namespaceURI, localName); + } + + setAttribute(name, value) { + var localName = adjustAttrName(this.namespaceURI, name); + setAttribute(this, null, null, localName, value); + } + + setAttributeNS(namespaceURI, qualifiedName, value) { + var [prefix, localName] = parseQualifiedName(qualifiedName); + setAttribute(this, namespaceURI, prefix, localName, value); + } + + removeAttribute(name) { + var localName = adjustAttrName(this.namespaceURI, name); + removeAttribute(this.attributes, null, localName); + } + + removeAttributeNS(namespaceURI, localName) { + removeAttribute(this.attributes, namespaceURI, localName); + } + + get doctype() { + return this.firstChild; + } + + get documentElement() { + return this.lastChild; + } + + get head() { + return this.documentElement.firstChild; + } + + get body() { + return this.documentElement.lastChild; + } + + createElement(name) { + return new SimpleNodeImpl(this, 1 + /* ELEMENT_NODE */ + , name.toUpperCase(), null, "http://www.w3.org/1999/xhtml" + /* HTML */ + ); + } + + createElementNS(namespace, qualifiedName) { + // Node name is case-preserving in XML contexts, but returns canonical uppercase form in HTML contexts + // https://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407/core.html#ID-104682815 + var nodeName = namespace === "http://www.w3.org/1999/xhtml" + /* HTML */ + ? qualifiedName.toUpperCase() : qualifiedName; // we don't care to parse the qualified name because we only support HTML documents + // which don't support prefixed elements + + return new SimpleNodeImpl(this, 1 + /* ELEMENT_NODE */ + , nodeName, null, namespace); + } + + createTextNode(text) { + return new SimpleNodeImpl(this, 3 + /* TEXT_NODE */ + , '#text', text, void 0); + } + + createComment(text) { + return new SimpleNodeImpl(this, 8 + /* COMMENT_NODE */ + , '#comment', text, void 0); + } + /** + * Backwards compat + * @deprecated + */ + + + createRawHTMLSection(text) { + return new SimpleNodeImpl(this, -1 + /* RAW_NODE */ + , '#raw', text, void 0); + } + + createDocumentFragment() { + return new SimpleNodeImpl(this, 11 + /* DOCUMENT_FRAGMENT_NODE */ + , '#document-fragment', null, void 0); + } + + } + + function createHTMLDocument() { + // dom.d.ts types ownerDocument as Document but for a document ownerDocument is null + var document = new SimpleNodeImpl(null, 9 + /* DOCUMENT_NODE */ + , '#document', null, "http://www.w3.org/1999/xhtml" + /* HTML */ + ); + var doctype = new SimpleNodeImpl(document, 10 + /* DOCUMENT_TYPE_NODE */ + , 'html', null, "http://www.w3.org/1999/xhtml" + /* HTML */ + ); + var html = new SimpleNodeImpl(document, 1 + /* ELEMENT_NODE */ + , 'HTML', null, "http://www.w3.org/1999/xhtml" + /* HTML */ + ); + var head = new SimpleNodeImpl(document, 1 + /* ELEMENT_NODE */ + , 'HEAD', null, "http://www.w3.org/1999/xhtml" + /* HTML */ + ); + var body = new SimpleNodeImpl(document, 1 + /* ELEMENT_NODE */ + , 'BODY', null, "http://www.w3.org/1999/xhtml" + /* HTML */ + ); + html.appendChild(head); + html.appendChild(body); + document.appendChild(doctype); + document.appendChild(html); + return document; + } + + var _default = createHTMLDocument; + _exports.default = _default; }); define("backburner", ["exports"], function (_exports) { "use strict"; @@ -55316,11 +57825,11 @@ define("backburner", ["exports"], function (_exports) { var queue = queues[queueName]; if (queue === undefined) { - throw new Error("You attempted to schedule an action in a queue (" + queueName + ") that doesn't exist"); + throw new Error(`You attempted to schedule an action in a queue (${queueName}) that doesn\'t exist`); } if (method === undefined || method === null) { - throw new Error("You attempted to schedule an action in a queue (" + queueName + ") for a method that doesn't exist"); + throw new Error(`You attempted to schedule an action in a queue (${queueName}) for a method that doesn\'t exist`); } this.queueNameIndex = 0; @@ -55646,7 +58155,7 @@ define("backburner", ["exports"], function (_exports) { on(eventName, callback) { if (typeof callback !== 'function') { - throw new TypeError("Callback must be a function"); + throw new TypeError(`Callback must be a function`); } var callbacks = this._eventCallbacks[eventName]; @@ -55654,7 +58163,7 @@ define("backburner", ["exports"], function (_exports) { if (callbacks !== undefined) { callbacks.push(callback); } else { - throw new TypeError("Cannot on() event " + eventName + " because it does not exist"); + throw new TypeError(`Cannot on() event ${eventName} because it does not exist`); } } @@ -55662,7 +58171,7 @@ define("backburner", ["exports"], function (_exports) { var callbacks = this._eventCallbacks[eventName]; if (!eventName || callbacks === undefined) { - throw new TypeError("Cannot off() event " + eventName + " because it does not exist"); + throw new TypeError(`Cannot off() event ${eventName} because it does not exist`); } var callbackFound = false; @@ -55678,7 +58187,7 @@ define("backburner", ["exports"], function (_exports) { } if (!callbackFound) { - throw new TypeError("Cannot off() callback that does not exist"); + throw new TypeError(`Cannot off() callback that does not exist`); } } @@ -55882,7 +58391,7 @@ define("backburner", ["exports"], function (_exports) { var nextInstance = null; if (currentInstance === null) { - throw new Error("end called without begin"); + throw new Error(`end called without begin`); } // Prevent double-finally bug in Safari 6.0.2 and iOS 6 // This bug appears to be resolved in Safari 6.0.5 and iOS 7 @@ -56433,7 +58942,7 @@ define("ember-babel", ["exports"], function (_exports) { Overrides default `inheritsLoose` to _also_ call `Object.setPrototypeOf`. This is needed so that we can use `loose` option with the `@babel/plugin-transform-classes` (because we want simple assignment to the - prototype whereever possible) but also keep our constructor based prototypal + prototype wherever possible) but also keep our constructor based prototypal inheritance working properly */ @@ -58151,7 +60660,7 @@ define("ember-testing/lib/test/promise", ["exports", "@ember/-internals/runtime" _exports.default = TestPromise; function promise(resolver, label) { - var fullLabel = "Ember.Test.promise: " + (label || ''); + var fullLabel = `Ember.Test.promise: ${label || ''}`; return new TestPromise(resolver, fullLabel); } /** @@ -58531,7 +61040,7 @@ define("ember/index", ["exports", "require", "@ember/-internals/environment", "n hasPropertyAccessors: true }; Ember.defineProperty = metal.defineProperty; - Ember.destroy = _meta.deleteMeta; + Ember.destroy = metal.destroy; Ember.libraries = metal.libraries; Ember.getProperties = metal.getProperties; Ember.setProperties = metal.setProperties; @@ -58615,7 +61124,7 @@ define("ember/index", ["exports", "require", "@ember/-internals/environment", "n */ Ember.inject = function inject() { - (true && !(false) && (0, EmberDebug.assert)("Injected properties must be created through helpers, see '" + Object.keys(inject).map(k => "'inject." + k + "'").join(' or ') + "'")); + (true && !(false) && (0, EmberDebug.assert)(`Injected properties must be created through helpers, see '${Object.keys(inject).map(k => `'inject.${k}'`).join(' or ')}'`)); }; Ember.inject.service = _service.inject; @@ -58880,7 +61389,7 @@ define("ember/version", ["exports"], function (_exports) { value: true }); _exports.default = void 0; - var _default = "3.16.2"; + var _default = "3.17.0"; _exports.default = _default; }); define("node-module/index", ["exports"], function (_exports) { @@ -59987,11 +62496,11 @@ define("router_js", ["exports", "@ember/polyfills", "rsvp", "route-recognizer"], return 'Router: ' + label; } - var STATE_SYMBOL = "__STATE__-2619860001345920-3322w3"; + var STATE_SYMBOL = `__STATE__-2619860001345920-3322w3`; _exports.STATE_SYMBOL = STATE_SYMBOL; - var PARAMS_SYMBOL = "__PARAMS__-261986232992830203-23323"; + var PARAMS_SYMBOL = `__PARAMS__-261986232992830203-23323`; _exports.PARAMS_SYMBOL = PARAMS_SYMBOL; - var QUERY_PARAMS_SYMBOL = "__QPS__-2619863929824844-32323"; + var QUERY_PARAMS_SYMBOL = `__QPS__-2619863929824844-32323`; /** A Transition is a thennable (a promise-like object) that represents an attempt to transition to another route. It can be aborted, either @@ -61096,7 +63605,7 @@ define("router_js", ["exports", "@ember/polyfills", "rsvp", "route-recognizer"], } if (missingParams.length > 0) { - throw new Error("You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route " + name + "." + (" Missing params: " + missingParams)); + throw new Error(`You didn't provide enough string/numeric parameters to satisfy all of the dynamic segments for route ${name}.` + ` Missing params: ${missingParams}`); } return new UnresolvedRouteInfoByParam(this.router, name, names, params); @@ -61285,7 +63794,7 @@ define("router_js", ["exports", "@ember/polyfills", "rsvp", "route-recognizer"], var newState = this.generateNewState(intent); if (newState === null) { - return _rsvp.Promise.reject("URL " + url + " was not recognized"); + return _rsvp.Promise.reject(`URL ${url} was not recognized`); } var newTransition = new Transition(this, intent, newState, undefined); @@ -68494,6 +71003,7 @@ define("@ember-data/adapter/rest", ["exports", "@ember-data/adapter", "@ember-da payload = responseData.errorThrown.payload; } else { responseData.errorThrown = errorThrown; + payload = adapter.parseErrorResponse(payload); } return ajaxError(adapter, payload, requestData, responseData); @@ -69517,7 +72027,7 @@ define("@ember-data/canary-features/default-features", ["exports"], function (_e IDENTIFIERS: true, REQUEST_SERVICE: null, CUSTOM_MODEL_CLASS: null, - FULL_LINKS_ON_RELATIONSHIPS: null + FULL_LINKS_ON_RELATIONSHIPS: true }; _exports.default = _default; }); @@ -73710,10 +76220,9 @@ define("@ember-data/record-data/-private/record-data", ["exports", "@ember-data/ let nextBfsId = 1; class RecordDataDefault { - /** - * @deprecated - */ - constructor(arg1, arg2) { + constructor(identifier, storeWrapper) { + this.identifier = identifier; + this.storeWrapper = storeWrapper; this._errors = void 0; this.__relationships = void 0; this.__implicitRelationships = void 0; @@ -73729,26 +76238,9 @@ define("@ember-data/record-data/-private/record-data", ["exports", "@ember-data/ this._scheduledDestroy = void 0; this._isDeleted = void 0; this._isDeletionCommited = void 0; - this.identifier = void 0; - this.storeWrapper = void 0; - - if (true - /* IDENTIFIERS */ - ) { - const [identifier, storeWrapper] = arguments; - this.identifier = identifier; - this.modelName = identifier.type; - this.clientId = identifier.lid; - this.id = identifier.id; - this.storeWrapper = storeWrapper; - } else { - const [modelName, id, clientId, storeWrapper] = arguments; - this.modelName = modelName; - this.clientId = clientId; - this.id = id; - this.storeWrapper = storeWrapper; - } - + this.modelName = identifier.type; + this.clientId = identifier.lid; + this.id = identifier.id; this.__relationships = null; this.__implicitRelationships = null; this.isDestroyed = false; @@ -73762,14 +76254,7 @@ define("@ember-data/record-data/-private/record-data", ["exports", "@ember-data/ getResourceIdentifier() { - return true - /* IDENTIFIERS */ - ? this.identifier : { - id: this.id, - type: this.modelName, - lid: this.clientId, - clientId: this.clientId - }; + return this.identifier; } pushData(data, calculateChange) { @@ -80624,9 +83109,7 @@ define("@ember-data/store/-private/system/coerce-id", ["exports"], function (_ex normalized = '' + id; } - if (true - /* DEBUG */ - && normalized === null) { + if (normalized === null) { throw new Error("Expected id to be a string or number, received ".concat(String(id))); } @@ -80652,7 +83135,6 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ const { ENV } = Ember; - let globalClientIdCounter = 1; let _Model; @@ -80951,13 +83433,7 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ } get identifierCache() { - if (true - /* IDENTIFIERS */ - ) { - return (0, _cache.identifierCacheFor)(this); - } - - assertInDebug("Store.identifierCache is unavailable in this build of EmberData", false); + return (0, _cache.identifierCacheFor)(this); } _instantiateRecord(internalModel, modelName, recordData, identifier, properties) { @@ -81601,13 +84077,9 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ let promise = this._fetchManager.scheduleFetch(identifier, options, generateStackTrace); return promise.then(payload => { - if (true - /* IDENTIFIERS */ - ) { - // ensure that regardless of id returned we assign to the correct record - if (payload.data && !Array.isArray(payload.data)) { - payload.data.lid = identifier.lid; - } + // ensure that regardless of id returned we assign to the correct record + if (payload.data && !Array.isArray(payload.data)) { + payload.data.lid = identifier.lid; } // Returning this._push here, breaks typing but not any tests, invesstigate potential missing tests @@ -81799,7 +84271,13 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ snapshots[i] = internalModels[i].createSnapshot(optionsMap.get(internalModel)); } - let groups = adapter.groupRecordsForFindMany(this, snapshots); + let groups; + + if (adapter.groupRecordsForFindMany) { + groups = adapter.groupRecordsForFindMany(this, snapshots); + } else { + groups = [snapshots]; + } for (var i = 0, l = groups.length; i < l; i++) { var group = groups[i]; @@ -82849,15 +85327,11 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ (true && Ember.assert("Your ".concat(internalModel.modelName, " record was saved to the server, but the response does not have an id and no id has been set client side. Records must have ids. Please update the server response to provide an id in the response or generate the id on the client side either before saving the record or while normalizing the response."), internalModel.id)); } - if (true - /* IDENTIFIERS */ - ) { - const cache = (0, _cache.identifierCacheFor)(this); - const identifier = internalModel.identifier; + const cache = (0, _cache.identifierCacheFor)(this); + const identifier = internalModel.identifier; - if (op !== 'deleteRecord' && data) { - cache.updateRecordIdentifier(identifier, data); - } + if (op !== 'deleteRecord' && data) { + cache.updateRecordIdentifier(identifier, data); } //We first make sure the primary data has been updated //TODO try to move notification to the user to the end of the runloop @@ -82948,25 +85422,20 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ // all else will be updates const isLoading = internalModel.currentState.stateName === 'root.loading'; - const isUpdate = internalModel.currentState.isEmpty === false && !isLoading; + const isUpdate = internalModel.currentState.isEmpty === false && !isLoading; // exclude store.push (root.empty) case - if (true - /* IDENTIFIERS */ - ) { - // exclude store.push (root.empty) case - if (isUpdate || isLoading) { - let identifier = internalModel.identifier; - let updatedIdentifier = (0, _cache.identifierCacheFor)(this).updateRecordIdentifier(identifier, data); - - if (updatedIdentifier !== identifier) { - // we encountered a merge of identifiers in which - // two identifiers (and likely two internalModels) - // existed for the same resource. Now that we have - // determined the correct identifier to use, make sure - // that we also use the correct internalModel. - identifier = updatedIdentifier; - internalModel = (0, _internalModelFactory.internalModelFactoryFor)(this).lookup(identifier); - } + if (isUpdate || isLoading) { + let identifier = internalModel.identifier; + let updatedIdentifier = (0, _cache.identifierCacheFor)(this).updateRecordIdentifier(identifier, data); + + if (updatedIdentifier !== identifier) { + // we encountered a merge of identifiers in which + // two identifiers (and likely two internalModels) + // existed for the same resource. Now that we have + // determined the correct identifier to use, make sure + // that we also use the correct internalModel. + identifier = updatedIdentifier; + internalModel = (0, _internalModelFactory.internalModelFactoryFor)(this).lookup(identifier); } } @@ -83399,18 +85868,12 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ _RecordData = (0, _require.default)("@ember-data/record-data/-private").RecordData; } - if (true - /* IDENTIFIERS */ - ) { - let identifier = (0, _cache.identifierCacheFor)(this).getOrCreateRecordIdentifier({ - type: modelName, - id, - lid: clientId - }); - return new _RecordData(identifier, storeWrapper); - } else { - return new _RecordData(modelName, id, clientId, storeWrapper); - } + let identifier = (0, _cache.identifierCacheFor)(this).getOrCreateRecordIdentifier({ + type: modelName, + id, + lid: clientId + }); + return new _RecordData(identifier, storeWrapper); } assertInDebug("Expected store.createRecordDataFor to be implemented but it wasn't", false); @@ -83480,12 +85943,6 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ } newClientId() { - if (!true - /* IDENTIFIERS */ - ) { - return globalClientIdCounter++; - } - assertInDebug("Private API Removed", false); } // ............... // . DESTRUCTION . @@ -83788,12 +86245,30 @@ define("@ember-data/store/-private/system/core-store", ["exports", "require", "@ } } + destroy() { + // enqueue destruction of any adapters/serializers we have created + for (let adapterName in this._adapterCache) { + let adapter = this._adapterCache[adapterName]; + + if (typeof adapter.destroy === 'function') { + adapter.destroy(); + } + } + + for (let serializerName in this._serializerCache) { + let serializer = this._serializerCache[serializerName]; + + if (typeof serializer.destroy === 'function') { + serializer.destroy(); + } + } + + return super.destroy(); + } + willDestroy() { super.willDestroy(); - this.recordArrayManager.destroy(); // Check if we need to null this out - // this._adapterCache = null; - // this._serializerCache = null; - + this.recordArrayManager.destroy(); (0, _cache.identifierCacheFor)(this).destroy(); this.unloadAll(); @@ -86657,6 +89132,11 @@ define("@ember-data/store/-private/system/snapshot", ["exports", "@ember-data/st changedAttributes() { let changedAttributes = Object.create(null); + + if (!this._changedAttributes) { + return changedAttributes; + } + let changedAttributeKeys = Object.keys(this._changedAttributes); for (let i = 0, length = changedAttributeKeys.length; i < length; i++) { @@ -86964,6 +89444,9 @@ define("@ember-data/store/-private/ts-interfaces/identifier", ["exports", "@embe const DEBUG_IDENTIFIER_BUCKET = (0, _symbol.symbol)('identifier-bucket'); _exports.DEBUG_IDENTIFIER_BUCKET = DEBUG_IDENTIFIER_BUCKET; }); +define("@ember-data/store/-private/ts-interfaces/minimum-adapter-interface", [], function () { + "use strict"; +}); define("@ember-data/store/-private/ts-interfaces/minimum-serializer-interface", [], function () { "use strict"; }); @@ -87312,32 +89795,18 @@ define("@ember-data/store/-private/system/model/internal-model", ["exports", "@e } get id() { - if (true - /* IDENTIFIERS */ - ) { - return this.identifier.id; // || this._id; - } - - return this._id; + return this.identifier.id; } set id(value) { - if (true - /* IDENTIFIERS */ - ) { - if (value !== this._id) { - let newIdentifier = { - type: this.identifier.type, - lid: this.identifier.lid, - id: value - }; - (0, _cache.identifierCacheFor)(this.store).updateRecordIdentifier(this.identifier, newIdentifier); - Ember.set(this, '_tag', this._tag + 1); // TODO Show deprecation for private api - } - } else if (!true - /* IDENTIFIERS */ - ) { - this._id = value; + if (value !== this._id) { + let newIdentifier = { + type: this.identifier.type, + lid: this.identifier.lid, + id: value + }; + (0, _cache.identifierCacheFor)(this.store).updateRecordIdentifier(this.identifier, newIdentifier); + Ember.set(this, '_tag', this._tag + 1); // TODO Show deprecation for private api } } @@ -88573,12 +91042,6 @@ define("@ember-data/store/-private/system/model/internal-model", ["exports", "@e } setId(id) { - if (!true - /* IDENTIFIERS */ - ) { - (true && Ember.assert("A record's id cannot be changed once it is in the loaded state", this.id === null || this.id === id)); - } - let didChange = id !== this._id; this._id = id; Ember.set(this, '_tag', this._tag + 1); @@ -88679,9 +91142,7 @@ define("@ember-data/store/-private/system/model/internal-model", ["exports", "@e /* RECORD_DATA_ERRORS */ ) { if (this._recordData.getErrors) { - return this._recordData.getErrors(true - /* IDENTIFIERS */ - ? this.identifier : {}).length > 0; + return this._recordData.getErrors(this.identifier).length > 0; } else { let errors = Ember.get(this.getRecord(), 'errors'); return errors.get('length') > 0; @@ -88726,15 +91187,11 @@ define("@ember-data/store/-private/system/model/internal-model", ["exports", "@e }]; } - this._recordData.commitWasRejected(true - /* IDENTIFIERS */ - ? this.identifier : {}, jsonApiErrors); + this._recordData.commitWasRejected(this.identifier, jsonApiErrors); } else { this.send('becameError'); - this._recordData.commitWasRejected(true - /* IDENTIFIERS */ - ? this.identifier : {}); + this._recordData.commitWasRejected(this.identifier); } } else { let attribute; @@ -88755,9 +91212,7 @@ define("@ember-data/store/-private/system/model/internal-model", ["exports", "@e let invalidErrors; if (this._recordData.getErrors) { - invalidErrors = this._recordData.getErrors(true - /* IDENTIFIERS */ - ? this.identifier : {}) || []; + invalidErrors = this._recordData.getErrors(this.identifier) || []; } else { return; } @@ -91285,15 +93740,9 @@ define("@ember-data/store/-private/system/store/finders", ["exports", "@ember-da (true && Ember.assert("Ember Data expected the primary data returned from a 'findRecord' response to be an object but instead it found an array.", !Array.isArray(payload.data))); (true && Ember.warn("You requested a record of type '".concat(modelName, "' with id '").concat(id, "' but the adapter returned a payload with primary data having an id of '").concat(payload.data.id, "'. Use 'store.findRecord()' when the requested id is the same as the one returned by the adapter. In other cases use 'store.queryRecord()' instead."), (0, _coerceId.default)(payload.data.id) === (0, _coerceId.default)(id), { id: 'ds.store.findRecord.id-mismatch' - })); - - if (true - /* IDENTIFIERS */ - ) { - // ensure that regardless of id returned we assign to the correct record - payload.data.lid = identifier.lid; - } + })); // ensure that regardless of id returned we assign to the correct record + payload.data.lid = identifier.lid; return store._push(payload); }, error => { internalModel.notFound(); @@ -91741,12 +94190,6 @@ define("@ember-data/store/-private/system/store/internal-model-factory", ["expor }); this._identityMap = new _identityMap.default(); - - if (!true - /* IDENTIFIERS */ - ) { - this._newlyCreated = new _identityMap.default(); - } } /** * Retrieve the InternalModel for a given { type, id, lid }. @@ -91761,9 +94204,7 @@ define("@ember-data/store/-private/system/store/internal-model-factory", ["expor lookup(resource, data) { - if (true - /* IDENTIFIERS */ - && data !== undefined) { + if (data !== undefined) { // if we've been given data associated with this lookup // we must first give secondary-caches for LIDs the // opportunity to populate based on it @@ -91799,42 +94240,12 @@ define("@ember-data/store/-private/system/store/internal-model-factory", ["expor peek(identifier) { - if (true - /* IDENTIFIERS */ - ) { - return this.modelMapFor(identifier.type).get(identifier.lid); - } else { - let internalModel = null; - internalModel = this._newlyCreatedModelsFor(identifier.type).get(identifier.lid); - - if (!internalModel && identifier.id) { - internalModel = this.modelMapFor(identifier.type).get(identifier.id); - } - - return internalModel; - } + return this.modelMapFor(identifier.type).get(identifier.lid); } getByResource(resource) { - if (true - /* IDENTIFIERS */ - ) { - const normalizedResource = (0, _constructResource.default)(resource.type, resource.id, resource.lid); - return this.lookup(normalizedResource); - } else { - let res = resource; - let internalModel = null; - - if (res.clientId) { - internalModel = this._newlyCreatedModelsFor(resource.type).get(res.clientId); - } - - if (internalModel === null) { - internalModel = this.lookup(resource); - } - - return internalModel; - } + const normalizedResource = (0, _constructResource.default)(resource.type, resource.id, resource.lid); + return this.lookup(normalizedResource); } setRecordId(type, id, lid) { @@ -91867,14 +94278,6 @@ define("@ember-data/store/-private/system/store/internal-model-factory", ["expor let existingInternalModel = this.peekById(modelName, id); (true && Ember.assert("'".concat(modelName, "' was saved to the server, but the response returned the new id '").concat(id, "', which has already been used with another record.'"), Ember.isNone(existingInternalModel) || existingInternalModel === internalModel)); - if (!true - /* IDENTIFIERS */ - ) { - this.modelMapFor(type).set(id, internalModel); - - this._newlyCreatedModelsFor(type).remove(internalModel, lid); - } - if (identifier.id === null) { this.identifierCache.updateRecordIdentifier(identifier, { type, @@ -91890,15 +94293,7 @@ define("@ember-data/store/-private/system/store/internal-model-factory", ["expor type, id }); - let internalModel; - - if (true - /* IDENTIFIERS */ - ) { - internalModel = identifier ? this.modelMapFor(type).get(identifier.lid) : null; - } else { - internalModel = this.modelMapFor(type).get(id); - } + let internalModel = identifier ? this.modelMapFor(type).get(identifier.lid) : null; if (internalModel && internalModel.hasScheduledDestroy()) { // unloadRecord is async, if one attempts to unload + then sync create, @@ -91938,39 +94333,14 @@ define("@ember-data/store/-private/system/store/internal-model-factory", ["expor let internalModel = new _internalModel.default(this.store, identifier); - - if (true - /* IDENTIFIERS */ - ) { - this.modelMapFor(resource.type).add(internalModel, identifier.lid); - } else { - if (isCreate === true) { - this._newlyCreatedModelsFor(identifier.type).add(internalModel, identifier.lid); - } // TODO @runspired really?! - - - this.modelMapFor(resource.type).add(internalModel, identifier.id); - } - + this.modelMapFor(resource.type).add(internalModel, identifier.lid); return internalModel; } remove(internalModel) { let recordMap = this.modelMapFor(internalModel.modelName); let clientId = internalModel.identifier.lid; - - if (true - /* IDENTIFIERS */ - ) { - recordMap.remove(internalModel, clientId); - } else { - if (internalModel.id) { - recordMap.remove(internalModel, internalModel.id); - } - - this._newlyCreatedModelsFor(internalModel.modelName).remove(internalModel, clientId); - } - + recordMap.remove(internalModel, clientId); const { identifier } = internalModel; @@ -92016,12 +94386,6 @@ define("@ember-data/store/-private/system/store/record-data-store-wrapper", ["ex } get identifierCache() { - if (!true - /* IDENTIFIERS */ - ) { - throw new Error("Store.identifierCache is unavailable in this build of EmberData"); - } - return (0, _cache.identifierCacheFor)(this._store); } /** @@ -92397,7 +94761,7 @@ define("@ember-data/store/-private/ts-interfaces/utils/symbol", ["exports"], fun }); define('ember-data/version', ['exports'], function (exports) { - exports.default = '3.16.0'; + exports.default = '3.17.0'; }); define("@ember-data/private-build-infra/available-packages", ["exports"], function (_exports) { diff --git a/vendor/full-ember-prod.js b/vendor/full-ember-prod.js index 5e3ece62..073ce9f8 100644 --- a/vendor/full-ember-prod.js +++ b/vendor/full-ember-prod.js @@ -107,7 +107,7 @@ Object.defineProperty(e,"__esModule",{value:!0}),Object.defineProperty(e,"setOwn * Portions Copyright 2008-2011 Apple Inc. All rights reserved. * @license Licensed under MIT license * See https://raw.github.com/emberjs/ember.js/master/LICENSE - * @version 3.16.2 + * @version 3.17.0 */ var e,t,r mainContext=this,function(){var i,n @@ -143,7 +143,7 @@ var s,a,o Object.defineProperty(e,"__esModule",{value:!0}),e.privatize=function([e]){var t=R[e] if(t)return t var[i,n]=e.split(":") -return R[e]=(0,r.intern)(i+":"+n+"-"+O)},e.FACTORY_FOR=e.Container=e.Registry=void 0 +return R[e]=(0,r.intern)(`${i}:${n}-${w}`)},e.FACTORY_FOR=e.Container=e.Registry=void 0 try{"function"==typeof gc&&(o=new Function("weakSet","return %GetWeakSetValues(weakSet, 0)"),a=new WeakSet,s={hasContainers:()=>(gc(),o(a).length>0),reset(){for(var e=o(a),t=0;ti.create(e)},s=new Proxy(n,t) +return a=function(e){if(r.HAS_NATIVE_PROXY){var t={set(e,t){throw new Error(`You attempted to set "${t}" on a factory manager created by container#factoryFor. A factory manager is a read-only construct.`)}},i=e,n={class:i.class,create:e=>i.create(e)},s=new Proxy(n,t) v.set(s,e)}return e}(a),e.factoryManagerCache[t]=a,a}}function p(e,t,r){e.registry.validateInjections(t) var i=r.injections void 0===i&&(i=r.injections={}) @@ -173,19 +173,19 @@ n.destroy&&n.destroy()}}function g(e){e.cache=(0,r.dictionary)(null),e.factoryMa var v=new WeakMap e.FACTORY_FOR=v class y{constructor(e,t,r,i){this.container=e,this.owner=e.owner,this.class=t,this.fullName=r,this.normalizedName=i,this.madeToString=void 0,this.injections=void 0,v.set(this,this)}toString(){return void 0===this.madeToString&&(this.madeToString=this.container.registry.makeToString(this.class,this.fullName)),this.madeToString}create(e){var{container:r}=this -if(r.isDestroyed)throw new Error("Can not create new instances after the owner has been destroyed (you attempted to create "+this.fullName+")") +if(r.isDestroyed)throw new Error(`Can not create new instances after the owner has been destroyed (you attempted to create ${this.fullName})`) var i=this.injections if(void 0===i){var{injections:s,isDynamic:a}=m(this.container,this.normalizedName) i=s,a||(this.injections=s)}var o=i void 0!==e&&(o=(0,n.assign)({},i,e)) var l,u=this.container.validationCache -if(!u[this.fullName]&&this.class&&"function"==typeof this.class._lazyInjections&&(l=this.class._lazyInjections(),l=this.container.registry.normalizeInjectionsHash(l),this.container.registry.validateInjections(l)),u[this.fullName]=!0,!this.class.create)throw new Error("Failed to create an instance of '"+this.normalizedName+"'. Most likely an improperly defined class or an invalid module export.") +if(!u[this.fullName]&&this.class&&"function"==typeof this.class._lazyInjections&&(l=this.class._lazyInjections(),l=this.container.registry.normalizeInjectionsHash(l),this.container.registry.validateInjections(l)),u[this.fullName]=!0,!this.class.create)throw new Error(`Failed to create an instance of '${this.normalizedName}'. Most likely an improperly defined class or an invalid module export.`) "function"==typeof this.class._initFactory?this.class._initFactory(this):(void 0!==e&&void 0!==o||(o=(0,n.assign)({},o)),(0,t.setOwner)(o,this.owner)) var c=this.class.create(o) return v.set(c,this),c}}var b=/^[^:]+:[^:]+$/ -class _{constructor(e={}){this.fallback=e.fallback||null,this.resolver=e.resolver||null,this.registrations=(0,r.dictionary)(e.registrations||null),this._typeInjections=(0,r.dictionary)(null),this._injections=(0,r.dictionary)(null),this._localLookupCache=Object.create(null),this._normalizeCache=(0,r.dictionary)(null),this._resolveCache=(0,r.dictionary)(null),this._failSet=new Set,this._options=(0,r.dictionary)(null),this._typeOptions=(0,r.dictionary)(null)}container(e){return new l(this,e)}register(e,t,r={}){!this.isValidFullName(e)&&(0,i.assert)("fullName must be a proper full name",this.isValidFullName(e)),void 0===t&&(0,i.assert)("Attempting to register an unknown factory: '"+e+"'",void 0!==t) +class _{constructor(e={}){this.fallback=e.fallback||null,this.resolver=e.resolver||null,this.registrations=(0,r.dictionary)(e.registrations||null),this._typeInjections=(0,r.dictionary)(null),this._injections=(0,r.dictionary)(null),this._localLookupCache=Object.create(null),this._normalizeCache=(0,r.dictionary)(null),this._resolveCache=(0,r.dictionary)(null),this._failSet=new Set,this._options=(0,r.dictionary)(null),this._typeOptions=(0,r.dictionary)(null)}container(e){return new l(this,e)}register(e,t,r={}){!this.isValidFullName(e)&&(0,i.assert)("fullName must be a proper full name",this.isValidFullName(e)),void 0===t&&(0,i.assert)(`Attempting to register an unknown factory: '${e}'`,void 0!==t) var n=this.normalize(e) -this._resolveCache[n]&&(0,i.assert)("Cannot re-register: '"+e+"', as it has already been resolved.",!this._resolveCache[n]),this._failSet.delete(n),this.registrations[n]=t,this._options[n]=r}unregister(e){!this.isValidFullName(e)&&(0,i.assert)("fullName must be a proper full name",this.isValidFullName(e)) +this._resolveCache[n]&&(0,i.assert)(`Cannot re-register: '${e}', as it has already been resolved.`,!this._resolveCache[n]),this._failSet.delete(n),this.registrations[n]=t,this._options[n]=r}unregister(e){!this.isValidFullName(e)&&(0,i.assert)("fullName must be a proper full name",this.isValidFullName(e)) var t=this.normalize(e) this._localLookupCache=Object.create(null),delete this.registrations[t],delete this._resolveCache[t],delete this._options[t],this._failSet.delete(t)}resolve(e,t){var r=function(e,t,r){var i=t if(void 0!==r&&(r.source||r.namespace)&&!(i=e.expandLocalLookup(t,r)))return @@ -206,7 +206,7 @@ if(void 0!==r&&void 0!==r[t])return r[t] var i=e.split(":")[0] return(r=this._typeOptions[i])&&void 0!==r[t]?r[t]:null!==this.fallback?this.fallback.getOption(e,t):void 0}typeInjection(e,t,r){!this.isValidFullName(r)&&(0,i.assert)("fullName must be a proper full name",this.isValidFullName(r)) var n=r.split(":")[0] -n===e&&(0,i.assert)("Cannot inject a '"+r+"' on other "+e+"(s).",n!==e),(this._typeInjections[e]||(this._typeInjections[e]=[])).push({property:t,specifier:r})}injection(e,t,r){!this.isValidFullName(r)&&(0,i.assert)("Invalid injectionName, expected: 'type:name' got: "+r,this.isValidFullName(r)) +n===e&&(0,i.assert)(`Cannot inject a '${r}' on other ${e}(s).`,n!==e),(this._typeInjections[e]||(this._typeInjections[e]=[])).push({property:t,specifier:r})}injection(e,t,r){!this.isValidFullName(r)&&(0,i.assert)(`Invalid injectionName, expected: 'type:name' got: ${r}`,this.isValidFullName(r)) var n=this.normalize(r) if(-1===e.indexOf(":"))return this.typeInjection(e,t,n) !this.isValidFullName(e)&&(0,i.assert)("fullName must be a proper full name",this.isValidFullName(e)) @@ -224,9 +224,9 @@ return s[a]=l}(this,this.normalize(e),this.normalize(t.source),t.namespace)):nul var E=_.prototype E.normalizeInjectionsHash=function(e){var t=[] for(var r in e)if(e.hasOwnProperty(r)){var{specifier:n,source:s,namespace:a}=e[r] -!this.isValidFullName(n)&&(0,i.assert)("Expected a proper full name, given '"+n+"'",this.isValidFullName(n)),t.push({property:r,specifier:n,source:s,namespace:a})}return t},E.validateInjections=function(e){if(e)for(var t=0;t"model"!==e&&"template"!==e,catalogEntriesByType(e){var i=(0,r.A)(r.Namespace.NAMESPACES),n=(0,r.A)(),s=new RegExp((0,t.classify)(e)+"$") +var i=r.Object.extend({resolver:null,canCatalogEntriesByType:e=>"model"!==e&&"template"!==e,catalogEntriesByType(e){var i=(0,r.A)(r.Namespace.NAMESPACES),n=(0,r.A)(),s=new RegExp(`${(0,t.classify)(e)}$`) return i.forEach(e=>{for(var i in e)if(e.hasOwnProperty(i)&&s.test(i)){var a=e[i] "class"===(0,r.typeOf)(a)&&n.push((0,t.dasherize)(i.replace(s,"")))}}),n}}) e.default=i})),e("@ember/-internals/extension-support/lib/data_adapter",["exports","@ember/-internals/owner","@ember/runloop","@ember/-internals/metal","@ember/string","@ember/-internals/runtime"],(function(e,t,r,i,n,s){"use strict" @@ -259,7 +259,7 @@ var a=s.Object.extend({init(){this._super(...arguments),this.releaseMethods=(0,s e(r.map(e=>{var r=e.klass,n=this.wrapModelType(r,e.name) return i.push(this.observeModelType(e.name,t)),n})) var n=()=>{i.forEach(e=>e()),this.releaseMethods.removeObject(n)} -return this.releaseMethods.pushObject(n),n},_nameToClass(e){if("string"==typeof e){var r=(0,t.getOwner)(this).factoryFor("model:"+e) +return this.releaseMethods.pushObject(n),n},_nameToClass(e){if("string"==typeof e){var r=(0,t.getOwner)(this).factoryFor(`model:${e}`) e=r&&r.class}return e},watchRecords(e,t,r,n){var a,o=(0,s.A)(),l=this._nameToClass(e),u=this.getRecords(l,e) function c(e){r([e])}var d=u.map(e=>(o.push(this.observeRecord(e,c)),this.wrapRecord(e))),h={didChange:(e,r,s,a)=>{for(var l=r;l{for(var r in e)if(e.hasOwnProperty(r)&&this.detect(e[r])){var i=(0,n.dasherize)(r) t.push(i)}}),t},getRecords:()=>(0,s.A)(),wrapRecord(e){var t={object:e} return t.columnValues=this.getRecordColumnValues(e),t.searchKeywords=this.getRecordKeywords(e),t.filterValues=this.getRecordFilterValues(e),t.color=this.getRecordColor(e),t},getRecordColumnValues:()=>({}),getRecordKeywords:()=>(0,s.A)(),getRecordFilterValues:()=>({}),getRecordColor:()=>null,observeRecord:()=>function(){}}) -e.default=a})),e("@ember/-internals/glimmer/index",["exports","ember-babel","@ember/polyfills","@ember/-internals/container","@glimmer/opcode-compiler","@ember/-internals/runtime","@ember/-internals/utils","@ember/runloop","@glimmer/reference","@ember/-internals/metal","@ember/debug","@glimmer/runtime","@ember/-internals/owner","@ember/-internals/views","@ember/-internals/browser-environment","@ember/instrumentation","@ember/service","@glimmer/util","@ember/-internals/environment","@ember/deprecated-features","@ember/string","@glimmer/wire-format","rsvp","@glimmer/node","@ember/-internals/routing","@ember/component/template-only","@ember/error"],(function(e,t,r,i,n,s,a,o,l,u,c,d,h,p,m,f,g,v,y,b,_,E,R,O,A,w,T){"use strict" -function S(){var e=(0,t.taggedTemplateLiteralLoose)(["component:-default"]) -return S=function(){return e},e}function P(){var e=(0,t.taggedTemplateLiteralLoose)(["template-compiler:main"]) -return P=function(){return e},e}function C(){var e=(0,t.taggedTemplateLiteralLoose)(["template-compiler:main"]) -return C=function(){return e},e}function M(){var e=(0,t.taggedTemplateLiteralLoose)(["template:components/-default"]) -return M=function(){return e},e}function k(){var e=(0,t.taggedTemplateLiteralLoose)(["template:-root"]) -return k=function(){return e},e}function D(){var e=(0,t.taggedTemplateLiteralLoose)(["template:-root"]) -return D=function(){return e},e}function x(){var e=(0,t.taggedTemplateLiteralLoose)(["component:-default"]) -return x=function(){return e},e}function j(){var e=(0,t.taggedTemplateLiteralLoose)(["template:components/-default"]) -return j=function(){return e},e}function N(){var e=(0,t.taggedTemplateLiteralLoose)(["template:components/-default"]) -return N=function(){return e},e}function I(){var e=(0,t.taggedTemplateLiteralLoose)(["template-compiler:main"]) -return I=function(){return e},e}function F(e){return"function"==typeof e}Object.defineProperty(e,"__esModule",{value:!0}),e.template=B,e.helper=Y,e.escapeExpression=function(e){if("string"!=typeof e){if(e&&e.toHTML)return e.toHTML() +e.default=a})),e("@ember/-internals/glimmer/index",["exports","@ember/polyfills","@glimmer/opcode-compiler","@ember/-internals/metal","@ember/-internals/owner","@ember/-internals/runtime","@ember/-internals/utils","@ember/-internals/views","@ember/debug","@glimmer/reference","@glimmer/runtime","@glimmer/validator","@ember/-internals/browser-environment","@ember/instrumentation","@ember/service","@ember/runloop","@ember/-internals/environment","@ember/deprecated-features","@ember/string","@ember/-internals/container","@glimmer/util","@glimmer/node","@ember/-internals/routing","@ember/component/template-only","@ember/error","@glimmer/program","rsvp"],(function(e,t,r,i,n,s,a,o,l,u,c,d,h,p,m,f,g,v,y,b,_,E,R,w,A,O,T){"use strict" +function S(e){return"function"==typeof e}Object.defineProperty(e,"__esModule",{value:!0}),e.template=P,e.helper=J,e.escapeExpression=function(e){if("string"!=typeof e){if(e&&e.toHTML)return e.toHTML() if(null==e)return"" if(!e)return String(e) -e=String(e)}if(!rt.test(e))return e -return e.replace(it,nt)},e.htmlSafe=st,e.isHTMLSafe=at,e._resetRenderers=function(){Jt.length=0},e.renderSettled=function(){null===er&&(er=R.default.defer(),(0,o.getCurrentRunLoop)()||o.backburner.schedule("actions",null,Zt)) -return er.promise},e.getTemplate=function(e){if(sr.hasOwnProperty(e))return sr[e]},e.setTemplate=function(e,t){return sr[e]=t},e.hasTemplate=function(e){return sr.hasOwnProperty(e)},e.getTemplates=function(){return sr},e.setTemplates=function(e){sr=e},e.setupEngineRegistry=function(e){e.optionsForType("template",{instantiate:!1}),e.register("view:-outlet",Vi),e.register("template:-outlet",Hi),e.injection("view:-outlet","template","template:-outlet"),e.injection("service:-dom-changes","document","service:-document"),e.injection("service:-dom-tree-construction","document","service:-document"),e.register((0,i.privatize)(M()),Bi),e.register("service:-glimmer-environment",ft),e.register((0,i.privatize)(C()),zi),e.injection((0,i.privatize)(P()),"environment","-environment:main"),e.optionsForType("helper",{instantiate:!1}),e.register("helper:loc",gr),e.register("component:-text-field",we),e.register("component:-checkbox",Re),e.register("component:link-to",Me),e.register("component:input",fr),e.register("template:components/input",Ui),e.register("component:textarea",Te),y.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS||e.register((0,i.privatize)(S()),_e)},e.setupApplicationRegistry=function(e){e.injection("service:-glimmer-environment","appendOperations","service:-dom-tree-construction"),e.injection("renderer","env","service:-glimmer-environment"),e.register("service:-dom-builder",{create({bootOptions:e}){var{_renderMode:t}=e -switch(t){case"serialize":return O.serializeBuilder.bind(null) -case"rehydrate":return d.rehydrationBuilder.bind(null) -default:return d.clientBuilder.bind(null)}}}),e.injection("service:-dom-builder","bootOptions","-environment:main"),e.injection("renderer","builder","service:-dom-builder"),e.register((0,i.privatize)(D()),U),e.injection("renderer","rootTemplate",(0,i.privatize)(k())),e.register("renderer:-dom",nr),e.register("renderer:-inert",ir),m.hasDOM&&e.injection("service:-glimmer-environment","updateOperations","service:-dom-changes") -e.register("service:-dom-changes",{create:({document:e})=>new d.DOMChanges(e)}),e.register("service:-dom-tree-construction",{create:({document:e})=>new(m.hasDOM?d.DOMTreeConstruction:O.NodeDOMTreeConstruction)(e)})},e._registerMacros=function(e){Ti.push(e)},e.iterableFor=xe,e.capabilities=function(e,t={}){"3.4"!==e&&"3.13"!==e&&(0,c.assert)("Invalid component manager compatibility specified","3.4"===e||"3.13"===e) +e=String(e)}if(!ee.test(e))return e +return e.replace(te,re)},e.htmlSafe=ie,e.isHTMLSafe=ne,e._resetRenderers=function(){Yr.length=0},e.renderSettled=function(){null===Kr&&(Kr=T.default.defer(),(0,f.getCurrentRunLoop)()||f.backburner.schedule("actions",null,Wr)) +return Kr.promise},e.getTemplate=function(e){if(ei.hasOwnProperty(e))return ei[e]},e.setTemplate=function(e,t){return ei[e]=t},e.hasTemplate=function(e){return ei.hasOwnProperty(e)},e.getTemplates=function(){return ei},e.setTemplates=function(e){ei=e},e.setupEngineRegistry=function(e){e.optionsForType("template",{instantiate:!1}),e.register("view:-outlet",ui),e.register("template:-outlet",li),e.injection("view:-outlet","template","template:-outlet"),e.register(b.privatize`template:components/-default`,ai),e.optionsForType("helper",{instantiate:!1}),e.register("helper:loc",si),e.register("component:-text-field",B),e.register("component:-checkbox",L),e.register("component:link-to",Y),e.register("component:input",ni),e.register("template:components/input",oi),e.register("component:textarea",$),g.ENV._TEMPLATE_ONLY_GLIMMER_COMPONENTS||e.register(b.privatize`component:-default`,I)},e.setupApplicationRegistry=function(e){e.injection("renderer","env","-environment:main"),e.register("service:-dom-builder",{create({bootOptions:e}){var{_renderMode:t}=e +switch(t){case"serialize":return E.serializeBuilder.bind(null) +case"rehydrate":return c.rehydrationBuilder.bind(null) +default:return c.clientBuilder.bind(null)}}}),e.injection("service:-dom-builder","bootOptions","-environment:main"),e.injection("renderer","builder","service:-dom-builder"),e.register(b.privatize`template:-root`,M),e.injection("renderer","rootTemplate",b.privatize`template:-root`),e.register("renderer:-dom",Zr),e.register("renderer:-inert",Xr),e.injection("renderer","document","service:-document")},e._registerMacros=function(e){Br.push(e)},e.capabilities=function(e,t={}){"3.4"!==e&&"3.13"!==e&&(0,l.assert)("Invalid component manager compatibility specified","3.4"===e||"3.13"===e) var r return r="3.13"!==e||Boolean(t.updateHook),{asyncLifeCycleCallbacks:Boolean(t.asyncLifecycleCallbacks),destructor:Boolean(t.destructor),updateHook:r}},e.setComponentManager=function(e,t){var r -b.COMPONENT_MANAGER_STRING_LOOKUP&&"string"==typeof e?((0,c.deprecate)('Passing the name of the component manager to "setupComponentManager" is deprecated. Please pass a function that produces an instance of the manager.',!1,{id:"deprecate-string-based-component-manager",until:"4.0.0",url:"https://emberjs.com/deprecations/v3.x/#toc_component-manager-string-lookup"}),r=function(t){return t.lookup("component-manager:"+e)}):r=e -return pr({factory:r,internal:!1,type:"component"},t)},e.getComponentManager=function(e){var t=mr(e) -return t&&!t.internal&&"component"===t.type?t.factory:void 0} -e.setModifierManager=function(e,t){return pr({factory:e,internal:!1,type:"modifier"},t)},e.getModifierManager=xi,e.modifierCapabilities=Xr,e.setComponentTemplate=function(e,t){return!(null!==t&&("object"==typeof t||"function"==typeof t))&&(0,c.assert)("Cannot call `setComponentTemplate` on `"+(0,a.toString)(t)+"`",null!==t&&("object"==typeof t||"function"==typeof t)),!!Mi.has(t)&&(0,c.assert)("Cannot call `setComponentTemplate` multiple times on the same class (`"+t+"`)",!Mi.has(t)),Mi.set(t,e),t},e.getComponentTemplate=Di,Object.defineProperty(e,"DOMChanges",{enumerable:!0,get:function(){return d.DOMChanges}}),Object.defineProperty(e,"DOMTreeConstruction",{enumerable:!0,get:function(){return d.DOMTreeConstruction}}),Object.defineProperty(e,"isSerializationFirstNode",{enumerable:!0,get:function(){return d.isSerializationFirstNode}}),Object.defineProperty(e,"NodeDOMTreeConstruction",{enumerable:!0,get:function(){return O.NodeDOMTreeConstruction}}),e.OutletView=e.INVOKE=e.UpdatableReference=e.AbstractComponentManager=e._experimentalMacros=e.InteractiveRenderer=e.InertRenderer=e.Renderer=e.SafeString=e.Environment=e.Helper=e.Component=e.LinkComponent=e.TextArea=e.TextField=e.Checkbox=e.templateCacheCounters=e.RootTemplate=void 0 -var L={cacheHit:0,cacheMiss:0} -e.templateCacheCounters=L -var z=(0,i.privatize)(I()) -function B(e){var t=(0,n.templateFactory)(e),r=new WeakMap,i=e=>{var i=r.get(e) -if(void 0===i){L.cacheMiss++ -var n=e.lookup(z) -i=t.create(n,{owner:e}),r.set(e,i)}else L.cacheHit++ -return i} -return i.__id=t.id,i.__meta=t.meta,i}var U=B({id:"hjhxUoru",block:'{"symbols":[],"statements":[[1,[28,"component",[[23,0,[]]],null],false]],"hasEval":false}',meta:{moduleName:"packages/@ember/-internals/glimmer/lib/templates/root.hbs"}}) -e.RootTemplate=U -var H=(0,a.symbol)("RECOMPUTE_TAG") -var V=s.FrameworkObject.extend({init(){this._super(...arguments),this[H]=(0,l.createTag)()},recompute(){(0,o.join)(()=>(0,l.dirty)(this[H]))}}) -e.Helper=V,V.isHelperFactory=!0,(0,s.setFrameworkClass)(V) -class q{constructor(e){this.compute=e,this.isHelperFactory=!0}create(){return{compute:this.compute}}}function Y(e){return new q(e)}var G=e=>"While rendering:\n----------------\n"+e.replace(/^/gm," ") -function K(e){return(0,s.isArray)(e)?0!==e.length:Boolean(e)}var W=(0,a.symbol)("UPDATE"),Q=(0,a.symbol)("INVOKE") -e.INVOKE=Q -var $=(0,a.symbol)("ACTION") -class J{get(e){return ee.create(this,e)}}class X extends J{constructor(){super(),this.lastRevision=null,this.lastValue=null}value(){var{tag:e,lastRevision:t,lastValue:r}=this -return null!==t&&(0,l.validate)(e,t)||(r=this.lastValue=this.compute(),this.lastRevision=(0,l.value)(e)),r}}class Z extends l.ConstReference{constructor(e,t){super(e),this.env=t,this.children=Object.create(null)}static create(e,t){return me(e,!0,t)}get(e){var t=this.children[e] -return void 0===t&&(t=this.children[e]=new te(this.inner,e,this.env)),t}}class ee extends X{static create(e,t){return(0,l.isConst)(e)?(r=e.value(),i=t,de(r)?new te(r,i):he(r)?new le(r[i]):(pe(r),d.UNDEFINED_REFERENCE)):new re(e,t) -var r,i}get(e){return new re(this,e)}}class te extends ee{constructor(e,t,r){super(),this.parentValue=e,this.propertyKey=t,this.debugStackLog=r?r.debugRenderTree.logCurrentRenderStack():"",this.propertyTag=(0,l.createUpdatableTag)(),this.tag=this.propertyTag}compute(){var e,{parentValue:t,propertyKey:r}=this,i=(0,u.track)(()=>e=(0,u.get)(t,r),G(this.debug())) -return(0,u.consume)(i),(0,l.update)(this.propertyTag,i),e}[W](e){(0,u.set)(this.parentValue,this.propertyKey,e)}}te.prototype.debug=function(e){var t="this."+this.propertyKey -return e&&(t+="."+e),""+this.debugStackLog+t} -class re extends ee{constructor(e,t){super(),this.parentReference=e,this.propertyKey=t -var r=e.tag,i=this.propertyTag=(0,l.createUpdatableTag)() -this.tag=(0,l.combine)([r,i])}compute(){var{parentReference:e,propertyTag:t,propertyKey:r}=this,i=e.value(),n=typeof i -if("string"===n&&"length"===r)return i.length -if("object"===n&&null!==i||"function"===n){var s,a=i,o=(0,u.track)(()=>s=(0,u.get)(a,r),G(this.debug())) -return(0,u.consume)(o),(0,l.update)(t,o),s}}[W](e){(0,u.set)(this.parentReference.value(),this.propertyKey,e)}}re.prototype.debug=function(e){var t=this.parentReference,r=e?this.propertyKey+"."+e:this.propertyKey -return"function"==typeof t.debug?t.debug(r):"unknownObject."+r} -class ie extends J{constructor(e){super(),this.tag=(0,l.createTag)(),this._value=e}value(){return this._value}update(e){var{_value:t}=this -e!==t&&((0,l.dirty)(this.tag),this._value=e)}}e.UpdatableReference=ie -class ne extends d.ConditionalReference{static create(e){if((0,l.isConst)(e)){var t=e.value() -if(!(0,a.isProxy)(t))return d.PrimitiveReference.create(K(t))}return new ne(e)}constructor(e){super(e),this.objectTag=(0,l.createUpdatableTag)(),this.tag=(0,l.combine)([e.tag,this.objectTag])}toBool(e){return(0,a.isProxy)(e)?((0,l.update)(this.objectTag,(0,u.tagForProperty)(e,"isTruthy")),Boolean((0,u.get)(e,"isTruthy"))):((0,l.update)(this.objectTag,(0,u.tagFor)(e)),K(e))}}class se extends X{constructor(e,t){super(),this.helper=e,this.args=t -var r=this.computeTag=(0,l.createUpdatableTag)() -this.tag=(0,l.combine)([t.tag,r])}static create(e,t){if((0,l.isConst)(t)){var{positional:r,named:i}=t,n=r.value(),s=i.value() -return(0,c.debugFreeze)(n),(0,c.debugFreeze)(s),me(e(n,s))}return new se(e,t)}compute(){var e,{helper:t,computeTag:r,args:{positional:i,named:n}}=this,s=i.value(),o=n.value();(0,c.debugFreeze)(s),(0,c.debugFreeze)(o) -var d=(0,u.track)(()=>{(0,u.deprecateMutationsInAutotrackingTransaction)(()=>{e=t(s,o)})},G("(result of a `"+(0,a.getDebugName)(t)+"` helper)")) -return(0,l.update)(r,d),e}}class ae extends X{constructor(e,t){super(),this.instance=e,this.args=t -var r=this.computeTag=(0,l.createUpdatableTag)() -this.tag=(0,l.combine)([e[H],t.tag,r])}static create(e,t){return new ae(e,t)}compute(){var e,{instance:t,computeTag:r,args:{positional:i,named:n}}=this,s=i.value(),o=n.value();(0,c.debugFreeze)(s),(0,c.debugFreeze)(o) -var d=(0,u.track)(()=>{(0,u.deprecateMutationsInAutotrackingTransaction)(()=>{e=t.compute(s,o)})},G("(result of a `"+(0,a.getDebugName)(t)+"` helper)")) -return(0,l.update)(r,d),e}}class oe extends X{constructor(e,t){super(),this.helper=e,this.args=t,this.tag=t.tag}compute(){var{helper:e,args:t}=this -return e(t)}}class le extends l.ConstReference{static create(e){return me(e,!1)}get(e){return me(this.inner[e],!1)}}class ue extends X{constructor(e){super(),this.inner=e,this.tag=e.tag}get[Q](){return this.inner[Q]}compute(){return this.inner.value()}get(e){return this.inner.get(e)}}function ce(e,t){for(var r=e,i=0;i{var r=n.get(e) +return void 0===r?(C.cacheMiss++,r=i.create((0,t.assign)({owner:e},s)),n.set(e,r)):C.cacheHit++,r} +return a.__id=i.id,a.__meta=s,a}e.templateCacheCounters=C +var M=P({id:"9Fedtpxe",block:'{"symbols":[],"statements":[[1,0,0,0,[31,2,9,[27,[26,0,"CallHead"],[]],[[27,[24,0],[]]],null]]],"hasEval":false,"upvars":["component"]}',meta:{moduleName:"packages/@ember/-internals/glimmer/lib/templates/root.hbs"}}) +e.RootTemplate=M +var x=(0,a.symbol)("DIRTY_TAG"),D=(0,a.symbol)("ARGS"),k=(0,a.symbol)("IS_DISPATCHING_ATTRS"),N=(0,a.symbol)("HAS_BLOCK"),j=(0,a.symbol)("BOUNDS"),I=o.CoreView.extend(o.ChildViewsSupport,o.ViewStateSupport,o.ClassNamesSupport,s.TargetActionSupport,o.ActionSupport,o.ViewMixin,{isComponent:!0,init(){if(this._super(...arguments),this[k]=!1,this[x]=(0,d.createTag)(),this[j]=null,this.renderer._destinedForDOM&&""===this.tagName){var e=[],t=(0,n.getOwner)(this).lookup("event_dispatcher:main"),r=t&&t._finalEvents||{} +for(var i in r){var s=r[i] +"function"==typeof this[s]&&e.push(s)}e.length&&(0,l.assert)(`You can not define \`${e}\` function(s) to handle DOM event in the \`${this}\` tagless component since it doesn't have any DOM element.`,!e.length)}void 0!==this.mouseEnter&&(0,l.deprecate)(`${this}: Using \`mouseEnter\` event handler methods in components has been deprecated.`,void 0===this.mouseEnter,{id:"ember-views.event-dispatcher.mouseenter-leave-move",until:"4.0.0",url:"https://emberjs.com/deprecations/v3.x#toc_component-mouseenter-leave-move"}),void 0!==this.mouseLeave&&(0,l.deprecate)(`${this}: Using \`mouseLeave\` event handler methods in components has been deprecated.`,void 0===this.mouseLeave,{id:"ember-views.event-dispatcher.mouseenter-leave-move",until:"4.0.0",url:"https://emberjs.com/deprecations/v3.x#toc_component-mouseenter-leave-move"}),void 0!==this.mouseMove&&(0,l.deprecate)(`${this}: Using \`mouseMove\` event handler methods in components has been deprecated.`,void 0===this.mouseMove,{id:"ember-views.event-dispatcher.mouseenter-leave-move",until:"4.0.0",url:"https://emberjs.com/deprecations/v3.x#toc_component-mouseenter-leave-move"})},rerender(){(0,d.dirty)(this[x]),this._super()},[i.PROPERTY_DID_CHANGE](e){if(!this[k]){var t=this[D],r=void 0!==t?t[e]:void 0 +void 0!==r&&void 0!==r[u.UPDATE_REFERENCED_VALUE]&&r[u.UPDATE_REFERENCED_VALUE]((0,i.get)(this,e))}},getAttr(e){return this.get(e)},readDOMAttr(e){var t=(0,o.getViewElement)(this) +null===t&&(0,l.assert)(`Cannot call \`readDOMAttr\` on ${this} which does not have an element`,null!==t) +var r=t,i="http://www.w3.org/2000/svg"===r.namespaceURI,{type:n,normalized:s}=(0,c.normalizeProperty)(r,e) return i||"attr"===n?r.getAttribute(s):r[s]},didReceiveAttrs(){},didRender(){},willRender(){},didUpdateAttrs(){},willUpdate(){},didUpdate(){}}) -e.Component=_e,_e.toString=()=>"@ember/component",_e.reopenClass({isComponentFactory:!0,positionalParams:[]}),(0,s.setFrameworkClass)(_e) -var Ee=B({id:"hvtsz7RF",block:'{"symbols":[],"statements":[],"hasEval":false}',meta:{moduleName:"packages/@ember/-internals/glimmer/lib/templates/empty.hbs"}}),Re=_e.extend({layout:Ee,classNames:["ember-checkbox"],tagName:"input",attributeBindings:["type","checked","indeterminate","disabled","tabindex","name","autofocus","required","form"],type:"checkbox",disabled:!1,indeterminate:!1,didInsertElement(){this._super(...arguments),this.element.indeterminate=Boolean(this.indeterminate)},change(){(0,u.set)(this,"checked",this.element.checked)}}) -e.Checkbox=Re -var Oe={} -Re.reopen({value:Oe,didReceiveAttrs(){this._super(),"checkbox"===this.type&&this.value!==Oe&&(0,c.assert)("`` is not supported; please use `` instead.",!("checkbox"===this.type&&this.value!==Oe))}}),Re.toString=()=>"@ember/component/checkbox" -var Ae=m.hasDOM?Object.create(null):null -var we=_e.extend(p.TextSupport,{layout:Ee,classNames:["ember-text-field"],tagName:"input",attributeBindings:["accept","autocomplete","autosave","dir","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","lang","list","type","max","min","multiple","name","pattern","size","step","value","width"],value:"",type:(0,u.computed)({get:()=>"text",set(e,t){var r="text" -return function(e){if(!m.hasDOM)return Boolean(e) -if(e in Ae)return Ae[e] +e.Component=I,I.toString=()=>"@ember/component",I.reopenClass({isComponentFactory:!0,positionalParams:[]}),(0,s.setFrameworkClass)(I) +var F=P({id:"SWbqsLhV",block:'{"symbols":[],"statements":[],"hasEval":false,"upvars":[]}',meta:{moduleName:"packages/@ember/-internals/glimmer/lib/templates/empty.hbs"}}),L=I.extend({layout:F,classNames:["ember-checkbox"],tagName:"input",attributeBindings:["type","checked","indeterminate","disabled","tabindex","name","autofocus","required","form"],type:"checkbox",disabled:!1,indeterminate:!1,didInsertElement(){this._super(...arguments),this.element.indeterminate=Boolean(this.indeterminate)},change(){(0,i.set)(this,"checked",this.element.checked)}}) +e.Checkbox=L +var z={} +L.reopen({value:z,didReceiveAttrs(){this._super(),"checkbox"===this.type&&this.value!==z&&(0,l.assert)("`` is not supported; please use `` instead.",!("checkbox"===this.type&&this.value!==z))}}),L.toString=()=>"@ember/component/checkbox" +var U=h.hasDOM?Object.create(null):null +var B=I.extend(o.TextSupport,{layout:F,classNames:["ember-text-field"],tagName:"input",attributeBindings:["accept","autocomplete","autosave","dir","formaction","formenctype","formmethod","formnovalidate","formtarget","height","inputmode","lang","list","type","max","min","multiple","name","pattern","size","step","value","width"],value:"",type:(0,i.computed)({get:()=>"text",set(e,t){var r="text" +return function(e){if(!h.hasDOM)return Boolean(e) +if(e in U)return U[e] var t=document.createElement("input") -try{t.type=e}catch(e){}return Ae[e]=t.type===e}(t)&&(r=t),r}}),size:null,pattern:null,min:null,max:null}) -e.TextField=we,we.toString=()=>"@ember/component/text-field" -var Te=_e.extend(p.TextSupport,{classNames:["ember-text-area"],layout:Ee,tagName:"textarea",attributeBindings:["rows","cols","name","selectionEnd","selectionStart","autocomplete","wrap","lang","dir","value"],rows:null,cols:null}) -e.TextArea=Te,Te.toString=()=>"@ember/component/text-area" -var Se=B({id:"giTNx+op",block:'{"symbols":["&default"],"statements":[[4,"if",[[25,1]],null,{"statements":[[14,1]],"parameters":[]},{"statements":[[1,[23,0,["linkTitle"]],false]],"parameters":[]}]],"hasEval":false}',meta:{moduleName:"packages/@ember/-internals/glimmer/lib/templates/link-to.hbs"}}),Pe=Object.freeze({toString:()=>"UNDEFINED"}),Ce=Object.freeze({}),Me=_e.extend({layout:Se,tagName:"a",route:Pe,model:Pe,models:Pe,query:Pe,"current-when":null,title:null,rel:null,tabindex:null,target:null,activeClass:"active",loadingClass:"loading",disabledClass:"disabled",replace:!1,attributeBindings:["href","title","rel","tabindex","target"],classNameBindings:["active","loading","disabled","transitioningIn","transitioningOut"],eventName:"click",init(){this._super(...arguments) +try{t.type=e}catch(e){}return U[e]=t.type===e}(t)&&(r=t),r}}),size:null,pattern:null,min:null,max:null}) +e.TextField=B,B.toString=()=>"@ember/component/text-field" +var $=I.extend(o.TextSupport,{classNames:["ember-text-area"],layout:F,tagName:"textarea",attributeBindings:["rows","cols","name","selectionEnd","selectionStart","autocomplete","wrap","lang","dir","value"],rows:null,cols:null}) +e.TextArea=$,$.toString=()=>"@ember/component/text-area" +var H=P({id:"oodT3nZ5",block:'{"symbols":["&default"],"statements":[[5,[27,[26,0,"BlockHead"],[]],[[28,[24,1]]],null,[["default","else"],[{"statements":[[16,1,null]],"parameters":[]},{"statements":[[1,0,0,0,[27,[24,0],["linkTitle"]]]],"parameters":[]}]]]],"hasEval":false,"upvars":["if"]}',meta:{moduleName:"packages/@ember/-internals/glimmer/lib/templates/link-to.hbs"}}),V=Object.freeze({toString:()=>"UNDEFINED"}),q=Object.freeze({}),Y=I.extend({layout:H,tagName:"a",route:V,model:V,models:V,query:V,"current-when":null,title:null,rel:null,tabindex:null,target:null,activeClass:"active",loadingClass:"loading",disabledClass:"disabled",replace:!1,attributeBindings:["href","title","rel","tabindex","target"],classNameBindings:["active","loading","disabled","transitioningIn","transitioningOut"],eventName:"click",init(){this._super(...arguments) var{eventName:e}=this -this.on(e,this,this._invoke)},_routing:(0,g.inject)("-routing"),_currentRoute:(0,u.alias)("_routing.currentRouteName"),_currentRouterState:(0,u.alias)("_routing.currentState"),_targetRouterState:(0,u.alias)("_routing.targetState"),_route:(0,u.computed)("route","_currentRouterState",(function(){var{route:e}=this -return e===Pe?this._currentRoute:e})),_models:(0,u.computed)("model","models",(function(){var{model:e,models:t}=this -return e!==Pe&&t!==Pe&&(0,c.assert)("You cannot provide both the `@model` and `@models` arguments to the component.",e===Pe||t===Pe),e!==Pe?[e]:t!==Pe?(!Array.isArray(t)&&(0,c.assert)("The `@models` argument must be an array.",Array.isArray(t)),t):[]})),_query:(0,u.computed)("query",(function(){var{query:e}=this -return e===Pe?Ce:(0,r.assign)({},e)})),disabled:(0,u.computed)({get:e=>!1,set(e,t){return this._isDisabled=t,!!t&&this.disabledClass}}),active:(0,u.computed)("activeClass","_active",(function(){return!!this._active&&this.activeClass})),_active:(0,u.computed)("_currentRouterState","_route","_models","_query","loading","current-when",(function(){var{_currentRouterState:e}=this -return!!e&&this._isActive(e)})),willBeActive:(0,u.computed)("_currentRouterState","_targetRouterState","_route","_models","_query","loading","current-when",(function(){var{_currentRouterState:e,_targetRouterState:t}=this +this.on(e,this,this._invoke)},_routing:(0,m.inject)("-routing"),_currentRoute:(0,i.alias)("_routing.currentRouteName"),_currentRouterState:(0,i.alias)("_routing.currentState"),_targetRouterState:(0,i.alias)("_routing.targetState"),_route:(0,i.computed)("route","_currentRouterState",(function(){var{route:e}=this +return e===V?this._currentRoute:e})),_models:(0,i.computed)("model","models",(function(){var{model:e,models:t}=this +return e!==V&&t!==V&&(0,l.assert)("You cannot provide both the `@model` and `@models` arguments to the component.",e===V||t===V),e!==V?[e]:t!==V?(!Array.isArray(t)&&(0,l.assert)("The `@models` argument must be an array.",Array.isArray(t)),t):[]})),_query:(0,i.computed)("query",(function(){var{query:e}=this +return e===V?q:(0,t.assign)({},e)})),disabled:(0,i.computed)({get:e=>!1,set(e,t){return this._isDisabled=t,!!t&&this.disabledClass}}),active:(0,i.computed)("activeClass","_active",(function(){return!!this._active&&this.activeClass})),_active:(0,i.computed)("_currentRouterState","_route","_models","_query","loading","current-when",(function(){var{_currentRouterState:e}=this +return!!e&&this._isActive(e)})),willBeActive:(0,i.computed)("_currentRouterState","_targetRouterState","_route","_models","_query","loading","current-when",(function(){var{_currentRouterState:e,_targetRouterState:t}=this if(e!==t)return this._isActive(t)})),_isActive(e){if(this.loading)return!1 var t=this["current-when"] if("boolean"==typeof t)return t var r=Boolean(t) t=r?t.split(" "):[this._route] for(var{_models:i,_query:n,_routing:s}=this,a=0;a{e.transition=s.transitionTo(t,r,i,n)}},href:(0,u.computed)("_currentRouterState","_route","_models","_query","tagName","loading","loadingHref",(function(){if("a"===this.tagName){if(this.loading)return this.loadingHref +var{_route:s,_models:a,_query:u,replace:c}=this,d={queryParams:u,routeName:s} +return(0,p.flaggedInstrument)("interaction.link-to",d,this._generateTransition(d,s,a,u,c)),!1},_generateTransition(e,t,r,i,n){var{_routing:s}=this +return()=>{e.transition=s.transitionTo(t,r,i,n)}},href:(0,i.computed)("_currentRouterState","_route","_models","_query","tagName","loading","loadingHref",(function(){if("a"===this.tagName){if(this.loading)return this.loadingHref var{_route:e,_models:t,_query:r,_routing:i}=this -try{return i.generateURL(e,t,r)}catch(e){(0,c.assert)('You attempted to generate a link for the "'+this.route+'" route, but did not pass the models required for generating its dynamic segments. '+e.message)}}})),loading:(0,u.computed)("_route","_modelsAreLoaded","loadingClass",(function(){var{_route:e,_modelsAreLoaded:t}=this -if(!t||null==e)return this.loadingClass})),_modelsAreLoaded:(0,u.computed)("_models",(function(){for(var{_models:e}=this,t=0;t`.",!(this.route===Pe&&this.model===Pe&&this.models===Pe&&this.query===Pe)) +r&&r.isQueryParams?this.set("query",t.pop().values):this.set("query",V),0===t.length?this.set("route",V):this.set("route",t.shift()),this.set("model",V),this.set("models",t)}else{this.route===V&&this.model===V&&this.models===V&&this.query===V&&(0,l.assert)("You must provide at least one of the `@route`, `@model`, `@models` or `@query` argument to ``.",!(this.route===V&&this.model===V&&this.models===V&&this.query===V)) var{_models:i}=this if(i.length>0){var n=i[i.length-1] "object"==typeof n&&null!==n&&n.isQueryParams&&(this.query=n.values,i.pop())}}}}) -e.LinkComponent=Me,Me.toString=()=>"@ember/routing/link-component",Me.reopenClass({positionalParams:"params"}) -var ke=(0,a.symbol)("EACH_IN") -class De{constructor(e){this.inner=e,this.tag=e.tag,this[ke]=!0}value(){return this.inner.value()}get(e){return this.inner.get(e)}}function xe(e,t){return function(e){return null!==e&&"object"==typeof e&&e[ke]}(e)?new He(e,t||"@key"):new Ve(e,t||"@identity")}class je{constructor(e,t){this.length=e,this.keyFor=t,this.position=0}isEmpty(){return!1}memoFor(e){return e}next(){var{length:e,keyFor:t,position:r}=this -if(r>=e)return null -var i=this.valueFor(r),n=this.memoFor(r),s=t(i,n,r) -return this.position++,{key:s,value:i,memo:n}}}class Ne extends je{constructor(e,t,r){super(t,r),this.array=e}static from(e,t){var{length:r}=e -return 0===r?Ue:new this(e,r,t)}static fromForEachable(e,t){var r=[] -return e.forEach(e=>r.push(e)),this.from(r,t)}valueFor(e){return this.array[e]}}class Ie extends je{constructor(e,t,r){super(t,r),this.array=e}static from(e,t){var{length:r}=e -return 0===r?Ue:new this(e,r,t)}valueFor(e){return(0,u.objectAt)(this.array,e)}}class Fe extends je{constructor(e,t,r,i){super(r,i),this.keys=e,this.values=t}static fromIndexable(e,t){var r=Object.keys(e),{length:i}=r -if(0===i)return Ue -for(var n=[],s=0;s{(s=s||arguments.length>=2)&&r.push(t),i.push(e),n++}),0===n?Ue:s?new this(r,i,n,t):new Ne(i,n,t)}valueFor(e){return this.values[e]}memoFor(e){return this.keys[e]}}class Le{constructor(e,t,r){this.iterable=e,this.result=t,this.keyFor=r,this.position=0}static from(e,t){var r=e[Symbol.iterator](),i=r.next(),{value:n,done:s}=i -return s?Ue:Array.isArray(n)&&2===n.length?new this(r,i,t):new ze(r,i,t)}isEmpty(){return!1}next(){var{iterable:e,result:t,position:r,keyFor:i}=this -if(t.done)return null -var n=this.valueFor(t,r),s=this.memoFor(t,r),a=i(n,s,r) -return this.position++,this.result=e.next(),{key:a,value:n,memo:s}}}class ze extends Le{valueFor(e){return e.value}memoFor(e,t){return t}}class Be extends Le{valueFor(e){return e.value[1]}memoFor(e){return e.value[0]}}var Ue={isEmpty:()=>!0,next:()=>((0,c.assert)("Cannot call next() on an empty iterator"),null)} -class He{constructor(e,t){this.ref=e,this.keyPath=t,this.valueTag=(0,l.createUpdatableTag)(),this.tag=(0,l.combine)([e.tag,this.valueTag])}iterate(){var e,{ref:t,valueTag:r}=this,i=t.value(),n=(0,u.tagFor)(i) -return(0,a.isProxy)(i)&&(i=(0,s._contentFor)(i)),(0,l.update)(r,n),null===(e=i)||"object"!=typeof e&&"function"!=typeof e?Ue:Array.isArray(i)||(0,a.isEmberArray)(i)?Fe.fromIndexable(i,this.keyFor(!0)):a.HAS_NATIVE_SYMBOL&&Ye(i)?Be.from(i,this.keyFor()):qe(i)?Fe.fromForEachable(i,this.keyFor()):Fe.fromIndexable(i,this.keyFor(!0))}valueReferenceFor(e){return new ie(e.value)}updateValueReference(e,t){e.update(t.value)}memoReferenceFor(e){return new ie(e.memo)}updateMemoReference(e,t){e.update(t.memo)}keyFor(e=!1){var{keyPath:t}=this -switch(t){case"@key":return e?Ke:Je(We) -case"@index":return Ge -case"@identity":return Je(Qe) -default:return"@"===t[0]&&(0,c.assert)("Invalid key: "+t,"@"!==t[0]),Je($e(t))}}}class Ve{constructor(e,t){this.ref=e,this.keyPath=t,this.valueTag=(0,l.createUpdatableTag)(),this.tag=(0,l.combine)([e.tag,this.valueTag])}iterate(){var{ref:e,valueTag:t}=this,r=e.value() -if((0,l.update)(t,(0,u.tagForProperty)(r,"[]")),null===r||"object"!=typeof r)return Ue -var i=this.keyFor() -return Array.isArray(r)?Ne.from(r,i):(0,a.isEmberArray)(r)?Ie.from(r,i):a.HAS_NATIVE_SYMBOL&&Ye(r)?ze.from(r,i):qe(r)?Ne.fromForEachable(r,i):Ue}valueReferenceFor(e){return new ie(e.value)}updateValueReference(e,t){e.update(t.value)}memoReferenceFor(e){return new ie(e.memo)}updateMemoReference(e,t){e.update(t.memo)}keyFor(){var{keyPath:e}=this -switch(e){case"@index":return Ge -case"@identity":return Je(Qe) -default:return"@"===e[0]&&(0,c.assert)("Invalid key: "+e,"@"!==e[0]),Je($e(e))}}}function qe(e){return"function"==typeof e.forEach}function Ye(e){return"function"==typeof e[Symbol.iterator]}function Ge(e,t,r){return String(r)}function Ke(e,t){return t}function We(e,t){return Qe(t)}function Qe(e){switch(typeof e){case"string":return e -case"number":return String(e) -default:return(0,a.guidFor)(e)}}function $e(e){return t=>String((0,u.get)(t,e))}function Je(e){var t={} -return(r,i,n)=>{var s=e(r,i,n),a=t[s] -return void 0===a?(t[s]=0,s):(t[s]=++a,s+"be277757-bbbe-4620-9fcb-213ef433cca2"+a)}}class Xe{constructor(e){this.string=e}toString(){return""+this.string}toHTML(){return this.toString()}}e.SafeString=Xe -var Ze,et,tt={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},rt=/[&<>"'`=]/,it=/[&<>"'`=]/g -function nt(e){return tt[e]}function st(e){return null==e?e="":"string"!=typeof e&&(e=String(e)),new Xe(e)}function at(e){return null!==e&&"object"==typeof e&&"function"==typeof e.toHTML}function ot(e){return et||(et=document.createElement("a")),et.href=e,et.protocol}function lt(e){var t=null -return"string"==typeof e&&(t=Ze.parse(e).protocol),null===t?":":t}var ut=0 -class ct{constructor(e){this.id=ut++,this.value=e}get(){return this.value}release(){null===this.value&&(0,c.assert)("BUG: double release?",null!==this.value),this.value=null}toString(){var e="Ref "+this.id -if(null===this.value)return e+" (released)" -try{return e+": "+this.value}catch(t){return e}}}var dt=String.prototype.repeat||function(e){return new Array(e+1).join(this)} -function ht(e,t){return dt.call(e,t)}class pt extends v.Stack{toArray(){return this.stack}}class mt{constructor(){this.stack=new pt,this.refs=new WeakMap,this.roots=new Set,this.nodes=new WeakMap}begin(){this.reset()}create(e,t){this.nodes.set(e,(0,r.assign)({},t,{bounds:null,refs:new Set})),this.appendChild(e),this.enter(e)}update(e){this.enter(e)}setTemplate(e,t){this.nodeFor(e).template=t}didRender(e,t){this.stack.current!==e&&(0,c.assert)("BUG: expecting "+this.stack.current+", got "+e,this.stack.current===e),this.nodeFor(e).bounds=t,this.exit()}willDestroy(e){(0,v.expect)(this.refs.get(e),"BUG: missing ref").release()}commit(){this.reset()}capture(){return this.captureRefs(this.roots)}logCurrentRenderStack(){var e=this.stack.toArray().map(e=>this.nodeFor(e)).filter(e=>"outlet"!==e.type&&"-top-level"!==e.name).map((e,t)=>""+ht(" ",2*t)+e.name) -return e.push(""+ht(" ",2*e.length)),e.join("\n")}reset(){if(0!==this.stack.size)for(;!this.stack.isEmpty();)this.stack.pop()}enter(e){this.stack.push(e)}exit(){0===this.stack.size&&(0,c.assert)("BUG: unbalanced pop",0!==this.stack.size),this.stack.pop()}nodeFor(e){return(0,v.expect)(this.nodes.get(e),"BUG: missing node")}appendChild(e){this.refs.has(e)&&(0,c.assert)("BUG: child already appended",!this.refs.has(e)) -var t=this.stack.current,r=new ct(e) -this.refs.set(e,r),t?this.nodeFor(t).refs.add(r):this.roots.add(r)}captureRefs(e){var t=[] -return e.forEach(r=>{var i=r.get() -i?t.push(this.captureNode("render-node:"+r.id,i)):e.delete(r)}),t}captureNode(e,t){var r=this.nodeFor(t),{type:i,name:n,args:s,instance:a,refs:o}=r,l=this.captureTemplate(r),u=this.captureBounds(r),c=this.captureRefs(o) -return{id:e,type:i,name:n,args:s.value(),instance:a,template:l,bounds:u,children:c}}captureTemplate({template:e}){return e&&e.referrer.moduleName||null}captureBounds(e){var t=(0,v.expect)(e.bounds,"BUG: missing bounds") -return{parentElement:t.parentElement(),firstNode:t.firstNode(),lastNode:t.lastNode()}}}class ft extends d.Environment{constructor(e){super(e),this.inTransaction=!1 -var t=e[h.OWNER] -this.owner=t,this.isInteractive=t.lookup("-environment:main").isInteractive,this.destroyedComponents=[],function(e){var t -if(m.hasDOM&&(t=ot.call(e,"foobar:baz")),"foobar:"===t)e.protocolForURL=ot -else if("object"==typeof URL)Ze=URL,e.protocolForURL=lt -else{if(void 0===typeof module||"function"!=typeof module.require)throw new Error("Could not find valid URL parsing mechanism for URL Sanitization") -Ze=module.require("url"),e.protocolForURL=lt}}(this),y.ENV._DEBUG_RENDER_TREE&&(this._debugRenderTree=new mt)}static create(e){return new this(e)}get debugRenderTree(){if(y.ENV._DEBUG_RENDER_TREE)return this._debugRenderTree -throw new Error("Can't access debug render tree outside of the inspector (_DEBUG_RENDER_TREE flag is disabled)")}protocolForURL(e){return e}toConditionalReference(e){return ne.create(e)}iterableFor(e,t){return xe(e,t)}scheduleInstallModifier(e,t){this.isInteractive&&super.scheduleInstallModifier(e,t)}scheduleUpdateModifier(e,t){this.isInteractive&&super.scheduleUpdateModifier(e,t)}didDestroy(e){e.destroy()}begin(){y.ENV._DEBUG_RENDER_TREE&&this.debugRenderTree.begin(),this.inTransaction=!0,super.begin()}commit(){var e=this.destroyedComponents -this.destroyedComponents=[] -for(var t=0;t"@ember/routing/link-component",Y.reopenClass({positionalParams:"params"}) +var G=(0,a.symbol)("RECOMPUTE_TAG") +function W(e){return void 0===e.destroy}var K=s.FrameworkObject.extend({init(){this._super(...arguments),this[G]=(0,d.createTag)()},recompute(){(0,f.join)(()=>(0,d.dirty)(this[G]))}}) +e.Helper=K,K.isHelperFactory=!0,(0,s.setFrameworkClass)(K) +class Q{constructor(e){this.compute=e,this.isHelperFactory=!0}create(){return{compute:this.compute}}}function J(e){return new Q(e)}class X{constructor(e){this.string=e}toString(){return`${this.string}`}toHTML(){return this.toString()}}e.SafeString=X +var Z={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},ee=/[&<>"'`=]/,te=/[&<>"'`=]/g +function re(e){return Z[e]}function ie(e){return null==e?e="":"string"!=typeof e&&(e=String(e)),new X(e)}function ne(e){return null!==e&&"object"==typeof e&&"function"==typeof e.toHTML}class se{constructor(e){this.resolver=e}lookupHelper(e,t){return this.resolver.lookupHelper(e,t)}lookupModifier(e,t){return this.resolver.lookupModifier(e,t)}lookupComponent(e,t){var r=this.resolver.lookupComponentHandle(e,t) +if(null===r)return null +var{manager:i,state:n}=this.resolver.resolve(r),s=i.getCapabilities(n) +return function(e,t){return!t.dynamicLayout}(0,s)?{handle:r,capabilities:s,compilable:i.getJitStaticLayout(n,this.resolver)}:{handle:r,capabilities:s,compilable:null}}lookupPartial(e,t){return this.resolver.lookupPartial(e,t)}resolve(e){return this.resolver.resolve(e)}}class ae{prepareArgs(e,t){return null}didCreateElement(e,t,r){}didRenderLayout(e,t){}didCreate(e){}update(e,t){}didUpdateLayout(e,t){}didUpdate(e){}}function oe(e){return{object:`${e.name}:${e.outlet}`}}e.AbstractComponentManager=ae +var le={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:g.ENV._DEBUG_RENDER_TREE,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!0,updateHook:g.ENV._DEBUG_RENDER_TREE,createInstance:!0,wrapped:!1,willDestroy:!1} +class ue extends ae{create(e,t,r,i){var n=i.outletState,s=t.ref i.outletState=s -var a={self:Z.create(t.controller),environment:e,finalize:(0,f._instrumentStart)("render.outlet",vt,t)} -if(y.ENV._DEBUG_RENDER_TREE){a.outlet={name:t.outlet},e.debugRenderTree.create(a.outlet,{type:"outlet",name:a.outlet.name,args:d.EMPTY_ARGS,instance:void 0,template:void 0}) -var o=n.value(),l=o&&o.render&&o.render.owner,u=s.value().render.owner -if(l&&l!==u){var h=u -"string"!=typeof u.mountPoint&&(0,c.assert)("invalid engine: missing mountPoint","string"==typeof u.mountPoint),!0!==u.routable&&(0,c.assert)("invalid engine: missing routable",!0===u.routable) -var p=h.mountPoint -a.engine={mountPoint:p},e.debugRenderTree.create(a.engine,{type:"engine",name:p,args:d.EMPTY_ARGS,instance:h,template:void 0})}e.debugRenderTree.create(a,{type:"route-template",name:t.name,args:r.capture(),instance:t.controller,template:t.template})}return a}getLayout({template:e},t){var r=e.asLayout() -return{handle:r.compile(),symbolTable:r.symbolTable}}getCapabilities(){return yt}getSelf({self:e}){return e}getTag(){return y.ENV._DEBUG_RENDER_TREE?(0,l.createTag)():l.CONSTANT_TAG}didRenderLayout(e,t){e.finalize(),y.ENV._DEBUG_RENDER_TREE&&(e.environment.debugRenderTree.didRender(e,t),e.engine&&e.environment.debugRenderTree.didRender(e.engine,t),e.environment.debugRenderTree.didRender(e.outlet,t))}update(e){y.ENV._DEBUG_RENDER_TREE&&(e.environment.debugRenderTree.update(e.outlet),e.engine&&e.environment.debugRenderTree.update(e.engine),e.environment.debugRenderTree.update(e))}didUpdateLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&(e.environment.debugRenderTree.didRender(e,t),e.engine&&e.environment.debugRenderTree.didRender(e.engine,t),e.environment.debugRenderTree.didRender(e.outlet,t))}getDestructor(e){return y.ENV._DEBUG_RENDER_TREE?{destroy(){e.environment.debugRenderTree.willDestroy(e),e.engine&&e.environment.debugRenderTree.willDestroy(e.engine),e.environment.debugRenderTree.willDestroy(e.outlet)}}:null}}var _t=new bt -class Et{constructor(e,t=_t){this.state=e,this.manager=t}}function Rt(){}class Ot{constructor(e,t,r,i,n){this.environment=e,this.component=t,this.args=r,this.finalizer=i,this.hasWrappedElement=n,this.classRef=null,this.classRef=null,this.argsRevision=null===r?0:(0,l.value)(r.tag),this.rootRef=new Z(t,e)}destroy(){var{component:e,environment:t}=this +var a={self:new u.ComponentRootReference(t.controller,e),environment:e,finalize:(0,p._instrumentStart)("render.outlet",oe,t)} +if(g.ENV._DEBUG_RENDER_TREE){a.outlet={name:t.outlet},e.extra.debugRenderTree.create(a.outlet,{type:"outlet",name:a.outlet.name,args:c.EMPTY_ARGS,instance:void 0,template:void 0}) +var o=n.value(),d=o&&o.render&&o.render.owner,h=s.value().render.owner +if(d&&d!==h){var m=h +"string"!=typeof h.mountPoint&&(0,l.assert)("invalid engine: missing mountPoint","string"==typeof h.mountPoint),!0!==h.routable&&(0,l.assert)("invalid engine: missing routable",!0===h.routable) +var f=m.mountPoint +a.engine={mountPoint:f},e.extra.debugRenderTree.create(a.engine,{type:"engine",name:f,args:c.EMPTY_ARGS,instance:m,template:void 0})}e.extra.debugRenderTree.create(a,{type:"route-template",name:t.name,args:r.capture(),instance:t.controller,template:t.template})}return a}getJitStaticLayout({template:e},t){return(0,r.unwrapTemplate)(e).asLayout()}getCapabilities(){return le}getSelf({self:e}){return e}getTag(){return g.ENV._DEBUG_RENDER_TREE?(0,d.createTag)():d.CONSTANT_TAG}didRenderLayout(e,t){e.finalize(),g.ENV._DEBUG_RENDER_TREE&&(e.environment.extra.debugRenderTree.didRender(e,t),e.engine&&e.environment.extra.debugRenderTree.didRender(e.engine,t),e.environment.extra.debugRenderTree.didRender(e.outlet,t))}update(e){g.ENV._DEBUG_RENDER_TREE&&(e.environment.extra.debugRenderTree.update(e.outlet),e.engine&&e.environment.extra.debugRenderTree.update(e.engine),e.environment.extra.debugRenderTree.update(e))}didUpdateLayout(e,t){g.ENV._DEBUG_RENDER_TREE&&(e.environment.extra.debugRenderTree.didRender(e,t),e.engine&&e.environment.extra.debugRenderTree.didRender(e.engine,t),e.environment.extra.debugRenderTree.didRender(e.outlet,t))}getDestructor(e){return g.ENV._DEBUG_RENDER_TREE?{destroy(){e.environment.extra.debugRenderTree.willDestroy(e),e.engine&&e.environment.extra.debugRenderTree.willDestroy(e.engine),e.environment.extra.debugRenderTree.willDestroy(e.outlet)}}:null}}var ce=new ue +class de{constructor(e,t=ce){this.state=e,this.manager=t}}function he(){}class pe{constructor(e,t,r,i,n){this.environment=e,this.component=t,this.args=r,this.finalizer=i,this.hasWrappedElement=n,this.classRef=null,this.classRef=null,this.argsRevision=null===r?0:(0,d.value)(r.tag),this.rootRef=new u.ComponentRootReference(t,e)}willDestroy(){var{component:e,environment:t}=this if(t.isInteractive){e.trigger("willDestroyElement"),e.trigger("willClearRender") -var r=(0,p.getViewElement)(e) -r&&((0,p.clearElementView)(r),(0,p.clearViewElement)(e))}t.destroyedComponents.push(e)}finalize(){var{finalizer:e}=this -e(),this.finalizer=Rt}}function At(e,t){return e.get(t)}function wt(e,t){return"attrs"===t[0]&&(t.shift(),1===t.length)?At(e,t[0]):ce(e,t)}var Tt,St,Pt={parse(e){var t=e.indexOf(":") -if(-1===t)return"class"===e&&(0,c.assert)("You cannot use class as an attributeBinding, use classNameBindings instead.","class"!==e),[e,e,!0] +var r=(0,o.getViewElement)(e) +r&&((0,o.clearElementView)(r),(0,o.clearViewElement)(e))}e.renderer.unregister(e)}destroy(){this.component.destroy()}finalize(){var{finalizer:e}=this +e(),this.finalizer=he}}class me extends u.HelperRootReference{constructor(e,t,r){var i=t=>{var r,{positional:i,named:n}=t,s=i.value(),a=n.value() +return(0,l.debugFreeze)(s),(0,l.debugFreeze)(a),(0,d.deprecateMutationsInAutotrackingTransaction)(()=>{r=e.compute(s,a)}),e[G]&&(0,d.consume)(e[G]),r} +super(i,t,r,W(e)?(0,a.getDebugName)(e.compute):(0,a.getDebugName)(e))}}class fe extends u.RootReference{constructor(e,t,r,i){super(t),this.inner=e,this.env=t,t.setTemplatePathDebugContext(this,i||"this",r||null)}value(){return this.inner}get(e){var t=this.value() +return(0,a.isObject)(t)?new ge(t[e],this.env,this,e):c.PrimitiveReference.create(t)}}class ge extends fe{}function ve(e,t){for(var r=e,i=0;i-1,p=h?wt(r,s.split(".")):At(r,s) -o&&h&&(0,c.assert)("Illegal attributeBinding: '"+s+"' is not a valid attribute name.",!(o&&h)),b.EMBER_COMPONENT_IS_VISIBLE&&"style"===a&&void 0!==Tt&&(p=new Tt(p,At(r,"isVisible"),t)),n.setAttribute(a,p,!1,null)}},Ct=st("display: none;") -b.EMBER_COMPONENT_IS_VISIBLE&&(Tt=class extends l.CachedReference{constructor(e,t,r){super(),this.inner=e,this.isVisible=t,this.component=r,this.tag=(0,l.combine)([e.tag,t.tag])}compute(){var e=this.inner.value(),t=this.isVisible.value() -if(void 0!==t&&(0,c.deprecate)('`isVisible` is deprecated (from "'+this.component._debugContainerKey+'")',!1,{id:"ember-component.is-visible",until:"4.0.0",url:"https://deprecations.emberjs.com/v3.x#toc_ember-component-is-visible"}),!1!==t)return e +return"class"===i&&(0,l.assert)("You cannot use class as an attributeBinding, use classNameBindings instead.","class"!==i),[r,i,!1]},install(e,t,r,n,s){var[a,o,u]=r +if("id"===o){var d=(0,i.get)(e,a) +return null==d&&(d=e.elementId),d=c.PrimitiveReference.create(d),void n.setAttribute("id",d,!0,null)}var h=a.indexOf(".")>-1,p=h?be(t,a.split(".")):ye(t,a) +u&&h&&(0,l.assert)(`Illegal attributeBinding: '${a}' is not a valid attribute name.`,!(u&&h)),v.EMBER_COMPONENT_IS_VISIBLE&&"style"===o&&void 0!==_e&&(p=new _e(t,p,ye(t,"isVisible"),s)),n.setAttribute(o,p,!1,null)}},we=ie("display: none;") +v.EMBER_COMPONENT_IS_VISIBLE&&(_e=class{constructor(e,t,r,i){this.inner=t,this.isVisible=r,this.env=i,this.tag=(0,d.combine)([t.tag,r.tag]),i.setTemplatePathDebugContext(this,"style",e)}value(){var e=this.inner.value(),t=this.isVisible.value() +if(void 0!==t&&(0,l.deprecate)(`The \`isVisible\` property on classic component classes is deprecated. Was accessed ${this.env.getTemplatePathDebugContext(this).replace(/^W/,"w")}`,!1,{id:"ember-component.is-visible",until:"4.0.0",url:"https://deprecations.emberjs.com/v3.x#toc_ember-component-is-visible"}),!1!==t)return e if(e){var r=e+" display: none;" -return at(e)?st(r):r}return Ct}}),b.EMBER_COMPONENT_IS_VISIBLE&&(St={install(e,t,r,i){i.setAttribute("style",(0,l.map)(At(r,"isVisible"),e=>this.mapStyleValue(e,t)),!1,null)},mapStyleValue:(e,t)=>(void 0!==e&&(0,c.deprecate)('`isVisible` is deprecated (from "'+t._debugContainerKey+'")',!1,{id:"ember-component.is-visible",until:"4.0.0",url:"https://deprecations.emberjs.com/v3.x#toc_ember-component-is-visible"}),!1===e?Ct:null)}) -var Mt={install(e,t,r,i){var[n,s,a]=r.split(":") -if(""===n)i.setAttribute("class",d.PrimitiveReference.create(s),!0,null) -else{var o,l=n.indexOf(".")>-1,u=l?n.split("."):[],c=l?wt(t,u):At(t,n) -o=void 0===s?new kt(c,l?u[u.length-1]:n):new Dt(c,s,a),i.setAttribute("class",o,!1,null)}}} -class kt extends l.CachedReference{constructor(e,t){super(),this.inner=e,this.path=t,this.tag=e.tag,this.inner=e,this.path=t,this.dasherizedPath=null}compute(){var e=this.inner.value() +return ne(e)?ie(r):r}return we}get(){return c.UNDEFINED_REFERENCE}},Ee=(e,t,r)=>{t.setAttribute("style",new _e(e,c.UNDEFINED_REFERENCE,e.get("isVisible"),r),!1,null)}) +var Ae={install(e,t,r,i){var[n,s,a]=r.split(":") +if(""===n)i.setAttribute("class",c.PrimitiveReference.create(s),!0,null) +else{var o,l=n.indexOf(".")>-1,u=l?n.split("."):[],d=l?be(t,u):ye(t,n) +o=void 0===s?new Oe(d,l?u[u.length-1]:n):new Te(d,s,a),i.setAttribute("class",o,!1,null)}}} +class Oe{constructor(e,t){this.inner=e,this.path=t,this.tag=e.tag,this.dasherizedPath=null}value(){var e=this.inner.value() if(!0===e){var{path:t,dasherizedPath:r}=this -return r||(this.dasherizedPath=(0,_.dasherize)(t))}return e||0===e?String(e):null}}class Dt extends l.CachedReference{constructor(e,t=null,r=null){super(),this.inner=e,this.truthy=t,this.falsy=r,this.tag=e.tag}compute(){var{inner:e,truthy:t,falsy:r}=this -return e.value()?t:r}}function xt(e){var t=e.names,r=e.value(),i=Object.create(null),n=Object.create(null) -i[ge]=n +return r||(this.dasherizedPath=(0,y.dasherize)(t))}return e||0===e?String(e):null}}class Te{constructor(e,t=null,r=null){this.inner=e,this.truthy=t,this.falsy=r,this.tag=e.tag}value(){var{inner:e,truthy:t,falsy:r}=this +return e.value()?t:r}}var Se=(0,a.symbol)("INVOKE") +e.INVOKE=Se +var Ce=(0,a.symbol)("SOURCE") +class Pe extends u.RootReference{constructor(e,t){super(t),this.inner=e,this.tag=e.tag,this[Ce]=e}value(){return this.inner.value()}get(e){return this.inner.get(e)}[u.UPDATE_REFERENCED_VALUE](e){return this.inner[u.UPDATE_REFERENCED_VALUE](e)}[Se](e){return this.inner[u.UPDATE_REFERENCED_VALUE](e)}}var Me=(0,a.symbol)("ACTION") +function xe(e){return e}function De(e,t,r,i,n){var s,a +if(null==r&&(0,l.assert)(`Action passed is null or undefined in (action) from ${t}.`,null!=r),"function"==typeof r[Se])s=r,a=r[Se] +else{var o=typeof r +"string"===o?(s=t,!(a=t.actions&&t.actions[r])&&(0,l.assert)(`An action named '${r}' was not found in ${t}`,a)):"function"===o?(s=e,a=r):(0,l.assert)(`An action could not be made for \`${n||r}\` in ${t}. Please confirm that you are using either a quoted action name (i.e. \`(action '${n||"myAction"}')\`) or a function available in ${t}.`,!1)}return(...e)=>{var t={target:s,args:e,label:"@glimmer/closure-action"} +return(0,p.flaggedInstrument)("interaction.ember-action",t,()=>(0,f.join)(s,a,...i(e)))}}function ke(e){var t=e.names,r=e.value(),i=Object.create(null),n=Object.create(null) +i[D]=n for(var s=0;s0))return null -var l=Math.min(o.length,t.positional.length) -a={},(0,r.assign)(a,t.named.capture().map) -for(var u=0;u{s.setAttribute("class",d.PrimitiveReference.create(e),!1,null)}),u&&u.length&&u.forEach(e=>{Mt.install(n,i,e,s)}),s.setAttribute("class",d.PrimitiveReference.create("ember-view"),!1,null),"ariaRole"in e&&s.setAttribute("role",At(i,"ariaRole"),!1,null),e._transitionTo("hasElement"),r.isInteractive&&e.trigger("willInsertElement")}didRenderLayout(e,t){e.component[be]=t,e.finalize(),y.ENV._DEBUG_RENDER_TREE&&e.environment.debugRenderTree.didRender(e,t)}getTag({args:e,component:t}){return e?(0,l.combine)([e.tag,t[fe]]):t[fe]}didCreate({component:e,environment:t}){t.isInteractive&&(e._transitionTo("inDOM"),e.trigger("didInsertElement"),e.trigger("didRender"))}update(e){var{component:t,args:r,argsRevision:i,environment:n}=e -if(y.ENV._DEBUG_RENDER_TREE&&n.debugRenderTree.update(e),e.finalizer=(0,f._instrumentStart)("render.component",Ht,t),r&&!(0,l.validate)(r.tag,i)){var s=xt(r) -e.argsRevision=(0,l.value)(r.tag),t[ve]=!0,t.setProperties(s),t[ve]=!1,t.trigger("didUpdateAttrs"),t.trigger("didReceiveAttrs")}n.isInteractive&&(t.trigger("willUpdate"),t.trigger("willRender"))}didUpdateLayout(e,t){e.finalize(),y.ENV._DEBUG_RENDER_TREE&&e.environment.debugRenderTree.didRender(e,t)}didUpdate({component:e,environment:t}){t.isInteractive&&(e.trigger("didUpdate"),e.trigger("didRender"))}getDestructor(e){return y.ENV._DEBUG_RENDER_TREE?{destroy(){e.environment.debugRenderTree.willDestroy(e),e.destroy()}}:e}}function Bt(e,t){!(()=>{for(var{classNameBindings:t}=e,r=0;r{for(var{classNameBindings:t}=e,r=0;r{for(var{classNameBindings:t}=e,r=0;r1)return!1}return!0})()&&(0,c.assert)("classNameBindings must not have spaces in them: "+e,(()=>{for(var{classNameBindings:t}=e,r=0;r1)return!1}return!0})()),""===e.tagName&&e.classNameBindings&&0!==e.classNameBindings.length&&(0,c.assert)("You cannot use `classNameBindings` on a tag-less component: "+e,""!==e.tagName||!e.classNameBindings||0===e.classNameBindings.length),""===e.tagName&&t.id!==e.elementId&&(e.elementId||""===e.elementId)&&(0,c.assert)("You cannot use `elementId` on a tag-less component: "+e,""!==e.tagName||t.id===e.elementId||!e.elementId&&""!==e.elementId),""===e.tagName&&e.attributeBindings&&0!==e.attributeBindings.length&&(0,c.assert)("You cannot use `attributeBindings` on a tag-less component: "+e,""!==e.tagName||!e.attributeBindings||0===e.attributeBindings.length)}function Ut(e){return e.instrumentDetails({initialRender:!0})}function Ht(e){return e.instrumentDetails({initialRender:!1})}var Vt={dynamicLayout:!0,dynamicTag:!0,prepareArgs:!0,createArgs:!0,attributeHook:!0,elementHook:!0,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0},qt=new zt -class Yt{constructor(e,t,r,i,n){this.name=e,this.ComponentClass=t,this.handle=r,this.template=i,this.manager=qt -var s=i&&i.asLayout(),a=s?s.symbolTable:void 0 -this.symbolTable=a,this.template=i,this.args=n,this.state={name:e,ComponentClass:t,handle:r,template:i,capabilities:Vt,symbolTable:a}}}class Gt extends zt{constructor(e){super(),this.component=e}getLayout(e){var t=this.templateFor(this.component).asWrappedLayout() -return{handle:t.compile(),symbolTable:t.symbolTable}}create(e,t,r,i){var n=this.component,s=(0,f._instrumentStart)("render.component",Ut,n) +var u=Math.min(o.length,r.positional.length) +a={},(0,t.assign)(a,r.named.capture().map) +for(var c=0;c{s.setAttribute("class",c.PrimitiveReference.create(e),!1,null)}),d&&d.length&&d.forEach(e=>{Ae.install(n,i,e,s)}),s.setAttribute("class",c.PrimitiveReference.create("ember-view"),!1,null),"ariaRole"in e&&s.setAttribute("role",ye(i,"ariaRole"),!1,null),e._transitionTo("hasElement"),r.isInteractive&&e.trigger("willInsertElement")}didRenderLayout(e,t){e.component[j]=t,e.finalize(),g.ENV._DEBUG_RENDER_TREE&&e.environment.extra.debugRenderTree.didRender(e,t)}getTag({args:e,component:t}){return e?(0,d.combine)([e.tag,t[x]]):t[x]}didCreate({component:e,environment:t}){t.isInteractive&&(e._transitionTo("inDOM"),e.trigger("didInsertElement"),e.trigger("didRender"))}update(e){var{component:t,args:r,argsRevision:i,environment:n}=e +if(g.ENV._DEBUG_RENDER_TREE&&n.extra.debugRenderTree.update(e),e.finalizer=(0,p._instrumentStart)("render.component",$e,t),r&&!(0,d.validate)(r.tag,i)){var s=ke(r) +e.argsRevision=(0,d.value)(r.tag),t[k]=!0,t.setProperties(s),t[k]=!1,t.trigger("didUpdateAttrs"),t.trigger("didReceiveAttrs")}n.isInteractive&&(t.trigger("willUpdate"),t.trigger("willRender"))}didUpdateLayout(e,t){e.finalize(),g.ENV._DEBUG_RENDER_TREE&&e.environment.extra.debugRenderTree.didRender(e,t)}didUpdate({component:e,environment:t}){t.isInteractive&&(e.trigger("didUpdate"),e.trigger("didRender"))}getDestructor(e){return g.ENV._DEBUG_RENDER_TREE?{willDestroy(){e.willDestroy()},destroy(){e.environment.extra.debugRenderTree.willDestroy(e),e.destroy()}}:e}}function Ue(e,t){!(()=>{for(var{classNameBindings:t}=e,r=0;r{for(var{classNameBindings:t}=e,r=0;r{for(var{classNameBindings:t}=e,r=0;r1)return!1}return!0})()&&(0,l.assert)(`classNameBindings must not have spaces in them: ${e}`,(()=>{for(var{classNameBindings:t}=e,r=0;r1)return!1}return!0})()),""===e.tagName&&e.classNameBindings&&0!==e.classNameBindings.length&&(0,l.assert)(`You cannot use \`classNameBindings\` on a tag-less component: ${e}`,""!==e.tagName||!e.classNameBindings||0===e.classNameBindings.length),""===e.tagName&&t.id!==e.elementId&&(e.elementId||""===e.elementId)&&(0,l.assert)(`You cannot use \`elementId\` on a tag-less component: ${e}`,""!==e.tagName||t.id===e.elementId||!e.elementId&&""!==e.elementId),""===e.tagName&&e.attributeBindings&&0!==e.attributeBindings.length&&(0,l.assert)(`You cannot use \`attributeBindings\` on a tag-less component: ${e}`,""!==e.tagName||!e.attributeBindings||0===e.attributeBindings.length)}function Be(e){return e.instrumentDetails({initialRender:!0})}function $e(e){return e.instrumentDetails({initialRender:!1})}var He={dynamicLayout:!0,dynamicTag:!0,prepareArgs:!0,createArgs:!0,attributeHook:!0,elementHook:!0,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!0,willDestroy:!0},Ve=new ze +class qe{constructor(e,t,r,i){this.name=e,this.ComponentClass=t,this.template=r,this.args=i,this.manager=Ve,this.state={name:e,ComponentClass:t,template:r,capabilities:He}}}class Ye extends ze{constructor(e){super(),this.component=e}getJitStaticLayout(e){var t=this.templateFor(this.component) +return(0,r.unwrapTemplate)(t).asWrappedLayout()}create(e,t,r,i){var n=this.component,s=(0,p._instrumentStart)("render.component",Be,n) i.view=n var a=""!==n.tagName -a||(e.isInteractive&&n.trigger("willRender"),n._transitionTo("hasElement"),e.isInteractive&&n.trigger("willInsertElement")),Bt(n,{}) -var o=new Ot(e,n,null,s,a) -return y.ENV._DEBUG_RENDER_TREE&&e.debugRenderTree.create(o,{type:"component",name:t.name,args:d.EMPTY_ARGS,instance:n,template:t.template}),o}}var Kt={dynamicLayout:!1,dynamicTag:!0,prepareArgs:!1,createArgs:!1,attributeHook:!0,elementHook:!0,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0} -class Wt{constructor(e){this.component=e -var t=new Gt(e) +a||(e.isInteractive&&n.trigger("willRender"),n._transitionTo("hasElement"),e.isInteractive&&n.trigger("willInsertElement")),Ue(n,{}) +var o=new pe(e,n,null,s,a) +return g.ENV._DEBUG_RENDER_TREE&&e.extra.debugRenderTree.create(o,{type:"component",name:t.name,args:c.EMPTY_ARGS,instance:n,template:t.template}),o}}var Ge,We,Ke={dynamicLayout:!1,dynamicTag:!0,prepareArgs:!1,createArgs:!1,attributeHook:!0,elementHook:!0,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!0,willDestroy:!1} +class Qe{constructor(e){this.component=e +var t=new Ye(e) this.manager=t -var r=i.FACTORY_FOR.get(e) -this.state={name:r.fullName.slice(10),capabilities:Kt,ComponentClass:r,handle:null}}getTag({component:e}){return e[fe]}}class Qt{constructor(e,t){this.view=e,this.outletState=t}child(){return new Qt(this.view,this.outletState)}get(e){return"outletState"!==e&&(0,c.assert)("Using `-get-dynamic-scope` is only supported for `outletState` (you used `"+e+"`).","outletState"===e),this.outletState}set(e,t){return"outletState"!==e&&(0,c.assert)("Using `-with-dynamic-scope` is only supported for `outletState` (you used `"+e+"`).","outletState"===e),this.outletState=t,t}}class $t{constructor(e,t,r,i,n,s,a){void 0===r&&(0,c.assert)("You cannot render `"+i.value()+"` without a template.",void 0!==r),this.id=(0,p.getViewId)(e),this.env=t,this.root=e,this.result=void 0,this.shouldReflush=!1,this.destroyed=!1,this.render=()=>{var e,o=r.asLayout(),l=o.compile(),u=(0,d.renderMain)(o.compiler.program,t,i,s,a(t,{element:n,nextSibling:null}),l) -do{e=u.next()}while(!e.done) -var c=this.result=e.value -this.render=()=>c.rerender({alwaysRevalidate:!1})}}isFor(e){return this.root===e}destroy(){var{result:e,env:t}=this -if(this.destroyed=!0,this.env=void 0,this.root=null,this.result=void 0,this.render=void 0,e){var r=!t.inTransaction -r&&t.begin() -try{e.destroy()}finally{r&&t.commit()}}}}var Jt=[] -function Xt(e){var t=Jt.indexOf(e);-1===t&&(0,c.assert)("Cannot deregister unknown unregistered renderer",-1!==t),Jt.splice(t,1)}function Zt(){}var er=null -var tr=0 -o.backburner.on("begin",(function(){for(var e=0;ey.ENV._RERENDER_LOOP_LIMIT)throw tr=0,Jt[e].destroy(),new Error("infinite rendering invalidation detected") -return tr++,o.backburner.join(null,Zt)}tr=0,function(){if(null!==er){var e=er.resolve -er=null,o.backburner.join(null,e)}}()})) -class rr{constructor(e,t,r,i=!1,n=d.clientBuilder){this._env=e,this._rootTemplate=t(e.owner),this._viewRegistry=r,this._destinedForDOM=i,this._destroyed=!1,this._roots=[],this._lastRevision=-1,this._isRenderingRoots=!1,this._removedRoots=[],this._builder=n}appendOutletView(e,t){var i=function(e){if(y.ENV._APPLICATION_TEMPLATE_WRAPPER){var t=(0,r.assign)({},yt,{dynamicTag:!0,elementHook:!0}),i=new class extends bt{getTagName(e){return"div"}getLayout(e){var t=e.template.asWrappedLayout() -return{handle:t.compile(),symbolTable:t.symbolTable}}getCapabilities(){return t}didCreateElement(e,t,r){t.setAttribute("class","ember-view"),t.setAttribute("id",(0,a.guidFor)(e))}} -return new Et(e.state,i)}return new Et(e.state)}(e) -this._appendDefinition(e,(0,d.curry)(i),t)}appendTo(e,t){var r=new Wt(e) -this._appendDefinition(e,(0,d.curry)(r),t)}_appendDefinition(e,t,r){var i=new le(t),n=new Qt(null,d.UNDEFINED_REFERENCE),s=new $t(e,this._env,this._rootTemplate,i,r,n,this._builder) -this._renderRoot(s)}rerender(){this._scheduleRevalidate()}register(e){var t=(0,p.getViewId)(e) -this._viewRegistry[t]&&(0,c.assert)("Attempted to register a view with an id already in use: "+t,!this._viewRegistry[t]),this._viewRegistry[t]=e}unregister(e){delete this._viewRegistry[(0,p.getViewId)(e)]}remove(e){e._transitionTo("destroying"),this.cleanupRootFor(e),this._destinedForDOM&&e.trigger("didDestroyElement")}cleanupRootFor(e){if(!this._destroyed)for(var t=this._roots,r=this._roots.length;r--;){var i=t[r] -i.isFor(e)&&(i.destroy(),t.splice(r,1))}}destroy(){this._destroyed||(this._destroyed=!0,this._clearAllRoots())}getBounds(e){var t=e[be] -return!Boolean(t)&&(0,c.assert)("object passed to getBounds must have the BOUNDS symbol as a property",Boolean(t)),{parentElement:t.parentElement(),firstNode:t.firstNode(),lastNode:t.lastNode()}}createElement(e){return this._env.getAppendOperations().createElement(e)}_renderRoot(e){var t,{_roots:r}=this -r.push(e),1===r.length&&(t=this,-1!==Jt.indexOf(t)&&(0,c.assert)("Cannot register the same renderer twice",-1===Jt.indexOf(t)),Jt.push(t)),this._renderRootsTransaction()}_renderRoots(){var e,{_roots:t,_env:r,_removedRoots:i}=this -do{r.begin() -try{e=t.length -for(var n=0;n=e||(0,u.runInAutotrackingTransaction)(s.render.bind(s))}this._lastRevision=(0,l.value)(l.CURRENT_TAG)}finally{r.commit()}}while(t.length>e) -for(;i.length;){var a=i.pop(),o=t.indexOf(a) -t.splice(o,1)}0===this._roots.length&&Xt(this)}_renderRootsTransaction(){if(!this._isRenderingRoots){this._isRenderingRoots=!0 -var e=!1 -try{this._renderRoots(),e=!0}finally{e||(this._lastRevision=(0,l.value)(l.CURRENT_TAG),!0===this._env.inTransaction&&this._env.commit()),this._isRenderingRoots=!1}}}_clearAllRoots(){for(var e=this._roots,t=0;t` component does not take any positional arguments",0===t.positional.length) -var r=t.named.capture().map -return{positional:ur,named:{__ARGS__:new Z(r),type:t.named.get("type")}}}create(e,{ComponentClass:t,layout:r},i,n,s){!(0,l.isConst)(s)&&(0,c.assert)("caller must be const",(0,l.isConst)(s)) -var a=i.named.get("type"),o=t.create({caller:s.value(),type:a.value()}),u={env:e,type:a,instance:o} -return y.ENV._DEBUG_RENDER_TREE&&e.debugRenderTree.create(u,{type:"component",name:"input",args:i.capture(),instance:o,template:r}),u}getSelf({env:e,instance:t}){return new Z(t,e)}getTag(){return y.ENV._DEBUG_RENDER_TREE?(0,l.createTag)():l.CONSTANT_TAG}didRenderLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&e.env.debugRenderTree.didRender(e,t)}update(e){(0,u.set)(e.instance,"type",e.type.value()),y.ENV._DEBUG_RENDER_TREE&&e.env.debugRenderTree.update(e)}didUpdateLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&e.env.debugRenderTree.didRender(e,t)}getDestructor(e){return y.ENV._DEBUG_RENDER_TREE?{destroy(){e.env.debugRenderTree.willDestroy(e),e.instance.destroy()}}:e.instance}}var dr=new WeakMap,hr=Object.getPrototypeOf -function pr(e,t){return dr.set(t,e),t}function mr(e){for(var t=e;null!=t;){var r=dr.get(t) -if(void 0!==r)return r -t=hr(t)}return null}var fr=s.Object.extend({isCheckbox:(0,u.computed)("type",(function(){return"checkbox"===this.type}))}) -pr({factory:e=>new cr(e),internal:!0,type:"component"},fr),fr.toString=()=>"@ember/component/input" -var gr=Y((function(e){return _.loc.apply(null,e)})) -class vr{constructor(e){this.resolver=e}getCapabilities(e){var t=this.resolver.resolve(e),{manager:r,state:i}=t -return r.getCapabilities(i)}getLayout(e){var{manager:t,state:r}=this.resolver.resolve(e) -if(t.getCapabilities(r).dynamicLayout)return null -var i=t.getLayout(r,this.resolver) -return{compile:()=>i.handle,symbolTable:i.symbolTable}}lookupHelper(e,t){return this.resolver.lookupHelper(e,t)}lookupModifier(e,t){return this.resolver.lookupModifier(e,t)}lookupComponentDefinition(e,t){return this.resolver.lookupComponentHandle(e,t)}lookupPartial(e,t){return this.resolver.lookupPartial(e,t)}}var yr={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!0,updateHook:!0,createInstance:!0} -function br(e){return e.capabilities.asyncLifeCycleCallbacks}function _r(e){return e.capabilities.updateHook}function Er(e){return e.capabilities.destructor}var Rr=new class extends gt{create(e,t,r){var i,{delegate:n}=t,s=r.capture(),o=s.named,l={},d=e=>o.get(e).tag -if(a.HAS_NATIVE_PROXY){var h={get(e,t){if(o.has(t)){var r=o.get(t) -return(0,u.consume)(r.tag),r.value()}if(t===u.CUSTOM_TAG_FOR)return d},has:(e,t)=>o.has(t),ownKeys:e=>o.names,getOwnPropertyDescriptor:(e,t)=>(!o.has(t)&&(0,c.assert)("args proxies do not have real property descriptors, so you should never need to call getOwnPropertyDescriptor yourself. This code exists for enumerability, such as in for-in loops and Object.keys()",o.has(t)),{enumerable:!0,configurable:!0}),set:function(e,r){return(0,c.assert)("You attempted to set "+t.ComponentClass.class+"#"+String(r)+" on a components arguments. Component arguments are immutable and cannot be updated directly, they always represent the values that are passed to your component. If you want to set default values, you should use a getter instead"),!1}} -l=new Proxy(l,h)}else Object.defineProperty(l,u.CUSTOM_TAG_FOR,{configurable:!1,enumerable:!1,value:d}),o.names.forEach(e=>{Object.defineProperty(l,e,{enumerable:!0,configurable:!0,get(){var t=o.get(e) -return(0,u.consume)(t.tag),t.value()}})}) -i={named:l,positional:s.positional.value()} -var p=n.createComponent(t.ComponentClass.class,i),m=new Or(n,p,s,e,l) -return y.ENV._DEBUG_RENDER_TREE&&e.debugRenderTree.create(m,{type:"component",name:t.name,args:r.capture(),instance:p,template:t.template}),m}update(e){y.ENV._DEBUG_RENDER_TREE&&e.env.debugRenderTree.update(e) +var r=b.FACTORY_FOR.get(e) +this.state={name:r.fullName.slice(10),capabilities:Ke,ComponentClass:r}}getTag({component:e}){return e[x]}}function Je(e){return We||(We=document.createElement("a")),We.href=e,We.protocol}function Xe(e){var t=null +return"string"==typeof e&&(t=Ge.parse(e).protocol),null===t?":":t}var Ze=0 +function et(e){return"root"===e.type||"argument"===e.type||"property"===e.type||"iterator"===e.type}class tt{constructor(e){this.id=Ze++,this.value=e}get(){return this.value}release(){null===this.value&&(0,l.assert)("BUG: double release?",null!==this.value),this.value=null}toString(){var e=`Ref ${this.id}` +if(null===this.value)return`${e} (released)` +try{return`${e}: ${this.value}`}catch(t){return e}}}var rt=String.prototype.repeat||function(e){return new Array(e+1).join(this)} +class it{constructor(){this.stack=new _.Stack,this.refs=new WeakMap,this.roots=new Set,this.nodes=new WeakMap,this.pathNodes=new WeakMap}begin(){this.reset()}create(e,r){var i=(0,t.assign)({},r,{bounds:null,refs:new Set,paths:new Set}) +this.nodes.set(e,i),this.appendChild(i,e),this.enter(e)}update(e){this.enter(e)}setTemplate(e,t){this.nodeFor(e).template=t}didRender(e,t){this.stack.current!==e&&(0,l.assert)(`BUG: expecting ${this.stack.current}, got ${e}`,this.stack.current===e),this.nodeFor(e).bounds=t,this.exit()}willDestroy(e){(0,_.expect)(this.refs.get(e),"BUG: missing ref").release()}commit(){this.reset()}capture(){return this.captureRefs(this.roots)}createPath(e,t,r,i){this.pathNodes.has(e)&&(0,l.assert)("BUG: Attempted to register a path that had already been registered",!this.pathNodes.has(e)) +var{current:n}=this.stack +if(null!==n){var s,a=(0,_.expect)(this.nodes.get(n),"BUG: Attempted to create a path, but there is no current render node") +if(null===i)s=a +else{var{named:o}=a.args,u=o.references.indexOf(i);-1!==u?s={parent:a,type:"argument",name:`@${o.names[u]}`,paths:new Set}:(this.pathNodes.has(i)||this.createPath(i,"this","root",null),s=this.pathNodes.get(i))}var c={name:t,type:r,parent:s,paths:new Set} +s.paths.add(c),this.pathNodes.set(e,c)}}logRenderStackForPath(e){for(var t=(0,_.expect)(this.pathNodes.get(e),"BUG: Attempted to create a log for a path reference, but no node exist for that reference"),r=[];void 0!==t&&et(t);){if("iterator"===t.type){var i=`${t.parent.name}[${t.name}]` +r.push(i),t=t.parent}else r.unshift(t.name) +t=t.parent}for(var n=[r.join(".")];void 0!==t;)"outlet"!==t.type&&"-top-level"!==t.name?(n.unshift(t.name),t=t.parent):t=t.parent +return n.map((e,t)=>{return`${r=" ",i=2*t,rt.call(r,i)}${e}` +var r,i}).join("\n")}reset(){if(0!==this.stack.size)for(;!this.stack.isEmpty();)this.stack.pop()}enter(e){this.stack.push(e)}exit(){0===this.stack.size&&(0,l.assert)("BUG: unbalanced pop",0!==this.stack.size),this.stack.pop()}nodeFor(e){return(0,_.expect)(this.nodes.get(e),"BUG: missing node")}appendChild(e,t){this.refs.has(t)&&(0,l.assert)("BUG: child already appended",!this.refs.has(t)) +var r=this.stack.current,i=new tt(t) +if(this.refs.set(t,i),r){var n=this.nodeFor(r) +n.refs.add(i),e.parent=n}else this.roots.add(i)}captureRefs(e){var t=[] +return e.forEach(r=>{var i=r.get() +i?t.push(this.captureNode(`render-node:${r.id}`,i)):e.delete(r)}),t}captureNode(e,t){var r=this.nodeFor(t),{type:i,name:n,args:s,instance:a,refs:o}=r,l=this.captureTemplate(r),u=this.captureBounds(r),c=this.captureRefs(o) +return{id:e,type:i,name:n,args:s.value(),instance:a,template:l,bounds:u,children:c}}captureTemplate({template:e}){return e&&(0,r.unwrapTemplate)(e).referrer.moduleName||null}captureBounds(e){var t=(0,_.expect)(e.bounds,"BUG: missing bounds") +return{parentElement:t.parentElement(),firstNode:t.firstNode(),lastNode:t.lastNode()}}}class nt{constructor(e){this.inner=e,this.valueTag=(0,d.createUpdatableTag)(),this.tag=(0,d.combine)([e.tag,this.valueTag])}value(){var e=this.inner.value(),t=(0,i.tagForObject)(e) +return(0,a.isProxy)(e)&&(e=(0,s._contentFor)(e)),(0,d.update)(this.valueTag,t),new st(e)}get(e){return this.inner.get(e)}}class st{constructor(e){this.inner=e}}function at(e){return e instanceof st?function(e){if(t=e,null===t||"object"!=typeof t&&"function"!=typeof t)return null +var t +return Array.isArray(e)||(0,a.isEmberArray)(e)?ct.fromIndexable(e):a.HAS_NATIVE_SYMBOL&&ft(e)?pt.from(e):mt(e)?ct.fromForEachable(e):ct.fromIndexable(e)}(e.inner):function(e){if(!(0,a.isObject)(e))return null +return Array.isArray(e)?lt.from(e):(0,a.isEmberArray)(e)?ut.from(e):a.HAS_NATIVE_SYMBOL&&ft(e)?ht.from(e):mt(e)?lt.fromForEachable(e):null}(e)}class ot{constructor(e){this.length=e,this.position=0}isEmpty(){return!1}memoFor(e){return e}next(){var{length:e,position:t}=this +if(t>=e)return null +var r=this.valueFor(t),i=this.memoFor(t) +return this.position++,{value:r,memo:i}}}class lt extends ot{constructor(e){super(e.length),this.array=e}static from(e){return e.length>0?new this(e):null}static fromForEachable(e){var t=[] +return e.forEach(e=>t.push(e)),this.from(t)}valueFor(e){return this.array[e]}}class ut extends ot{constructor(e){super(e.length),this.array=e}static from(e){return e.length>0?new this(e):null}valueFor(e){return(0,i.objectAt)(this.array,e)}}class ct extends ot{constructor(e,t){super(t.length),this.keys=e,this.values=t}static fromIndexable(e){var t=Object.keys(e),{length:r}=t +if(0===r)return null +for(var n=[],s=0;s=2)&&t.push(s),r.push(e),i++})),0===i?null:n?new this(t,r):new lt(r)}valueFor(e){return this.values[e]}memoFor(e){return this.keys[e]}}class dt{constructor(e,t){this.iterable=e,this.result=t,this.position=0}static from(e){var t=e[Symbol.iterator](),r=t.next(),{done:i}=r +return i?null:new this(t,r)}isEmpty(){return!1}next(){var{iterable:e,result:t,position:r}=this +if(t.done)return null +var i=this.valueFor(t,r),n=this.memoFor(t,r) +return this.position++,this.result=e.next(),{value:i,memo:n}}}class ht extends dt{valueFor(e){return e.value}memoFor(e,t){return t}}class pt extends dt{valueFor(e){return e.value[1]}memoFor(e){return e.value[0]}}function mt(e){return"function"==typeof e.forEach}function ft(e){return"function"==typeof e[Symbol.iterator]}function gt(e){return(0,a.isProxy)(e)?Boolean((0,i.get)(e,"isTruthy")):(0,s.isArray)(e)?0!==e.length:Boolean(e)}class vt{constructor(e){this.owner=e,g.ENV._DEBUG_RENDER_TREE&&(this._debugRenderTree=new it)}get debugRenderTree(){if(g.ENV._DEBUG_RENDER_TREE)return this._debugRenderTree +throw new Error("Can't access debug render tree outside of the inspector (_DEBUG_RENDER_TREE flag is disabled)")}begin(){g.ENV._DEBUG_RENDER_TREE&&this.debugRenderTree.begin()}commit(){g.ENV._DEBUG_RENDER_TREE&&this.debugRenderTree.commit()}}class yt{constructor(e,t){this.toBool=gt,this.toIterator=at,this.getPath=i.get,this.setPath=i.set,this.extra=new vt(e),this.isInteractive=t,function(e){var t +if(h.hasDOM&&(t=Je.call(e,"foobar:baz")),"foobar:"===t)e.protocolForURL=Je +else if("object"==typeof URL)Ge=URL,e.protocolForURL=Xe +else{if(void 0===typeof module||"function"!=typeof module.require)throw new Error("Could not find valid URL parsing mechanism for URL Sanitization") +Ge=module.require("url"),e.protocolForURL=Xe}}(this)}protocolForURL(e){return e}getTemplatePathDebugContext(e){return`While rendering:\n\n${this.extra.debugRenderTree.logRenderStackForPath(e)}`}setTemplatePathDebugContext(e,t,r){var i="root" +e instanceof u.IterationItemReference?i="iterator":e instanceof u.PropertyReference&&(i="property"),this.extra.debugRenderTree.createPath(e,t,i,r)}onTransactionBegin(){this.extra.begin()}onTransactionCommit(){this.extra.commit()}}{class e extends c.SimpleDynamicAttribute{set(e,t,r){(0,l.warn)((0,o.constructStyleDeprecationMessage)(t),!(null!=t&&!ne(t)),{id:"ember-htmlbars.style-xss-warning"}),super.set(e,t,r)}update(e,t){(0,l.warn)((0,o.constructStyleDeprecationMessage)(e),!(null!=e&&!ne(e)),{id:"ember-htmlbars.style-xss-warning"}),super.update(e,t)}}yt.prototype.attributeFor=function(t,r,i,n){return"style"!==r||i?(0,c.dynamicAttribute)(t,r,n):new e({element:t,name:r,namespace:n})}}var bt={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!1,willDestroy:!1} +function _t(e){return e.capabilities.asyncLifeCycleCallbacks}function Et(e){return e.capabilities.updateHook}function Rt(e){return e.capabilities.destructor}var wt=new class extends ae{create(e,t,r){var n,{delegate:s}=t,o=r.capture(),u=o.named,c={},h=e=>u.get(e).tag +if(a.HAS_NATIVE_PROXY){var p={get(e,t){if(u.has(t)){var r=u.get(t) +return(0,d.consume)(r.tag),r.value()}if(t===i.CUSTOM_TAG_FOR)return h},has:(e,t)=>u.has(t),ownKeys:e=>u.names,getOwnPropertyDescriptor:(e,t)=>(!u.has(t)&&(0,l.assert)("args proxies do not have real property descriptors, so you should never need to call getOwnPropertyDescriptor yourself. This code exists for enumerability, such as in for-in loops and Object.keys()",u.has(t)),{enumerable:!0,configurable:!0}),set:function(e,r){return(0,l.assert)(`You attempted to set ${t.ComponentClass.class}#${String(r)} on a components arguments. Component arguments are immutable and cannot be updated directly, they always represent the values that are passed to your component. If you want to set default values, you should use a getter instead`),!1}} +c=new Proxy(c,p)}else Object.defineProperty(c,i.CUSTOM_TAG_FOR,{configurable:!1,enumerable:!1,value:h}),u.names.forEach(e=>{Object.defineProperty(c,e,{enumerable:!0,configurable:!0,get(){var t=u.get(e) +return(0,d.consume)(t.tag),t.value()}})}) +n={named:c,positional:o.positional.value()} +var m=s.createComponent(t.ComponentClass.class,n),f=new At(s,m,o,e,c) +return g.ENV._DEBUG_RENDER_TREE&&e.extra.debugRenderTree.create(f,{type:"component",name:t.name,args:r.capture(),instance:m,template:t.template}),f}update(e){g.ENV._DEBUG_RENDER_TREE&&e.env.extra.debugRenderTree.update(e) var t,{delegate:r,component:i,args:n,namedArgsProxy:s}=e -t={named:s,positional:n.positional.value()},_r(r)&&r.updateComponent(i,t)}didCreate({delegate:e,component:t}){br(e)&&e.didCreateComponent(t)}didUpdate({delegate:e,component:t}){(function(e){return br(e)&&_r(e)})(e)&&e.didUpdateComponent(t)}getContext({delegate:e,component:t}){e.getContext(t)}getSelf({env:e,delegate:t,component:r}){return Z.create(t.getContext(r),e)}getDestructor(e){var t=null -if(Er(e.delegate)&&(t=e),y.ENV._DEBUG_RENDER_TREE){var r=t -t={destroy(){e.env.debugRenderTree.willDestroy(e),r&&r.destroy()}}}return t}getCapabilities({delegate:e}){return(0,r.assign)({},yr,{updateHook:y.ENV._DEBUG_RENDER_TREE||e.capabilities.updateHook})}getTag({args:e}){return(0,l.isConst)(e)?(0,l.createTag)():e.tag}didRenderLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&e.env.debugRenderTree.didRender(e,t)}didUpdateLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&e.env.debugRenderTree.didRender(e,t)}getLayout(e){return{handle:e.template.asLayout().compile(),symbolTable:e.symbolTable}}} -class Or{constructor(e,t,r,i,n){this.delegate=e,this.component=t,this.args=r,this.env=i,this.namedArgsProxy=n}destroy(){var{delegate:e,component:t}=this -Er(e)&&e.destroyComponent(t)}}class Ar{constructor(e,t,r,i){this.name=e,this.ComponentClass=t,this.delegate=r,this.template=i,this.manager=Rr -var n=i.asLayout().symbolTable -this.symbolTable=n,this.state={name:e,ComponentClass:t,template:i,symbolTable:n,delegate:r}}}var wr={dynamicLayout:!1,dynamicTag:!1,prepareArgs:!1,createArgs:y.ENV._DEBUG_RENDER_TREE,attributeHook:!1,elementHook:!1,createCaller:!1,dynamicScope:!1,updateHook:y.ENV._DEBUG_RENDER_TREE,createInstance:!0} -var Tr,Sr=new class extends gt{getLayout({template:e}){var t=e.asLayout() -return{handle:t.compile(),symbolTable:t.symbolTable}}getCapabilities(){return wr}create(e,{name:t,template:r},i){if(y.ENV._DEBUG_RENDER_TREE){var n={environment:e} -return e.debugRenderTree.create(n,{type:"component",name:t,args:i.capture(),instance:null,template:r}),n}return null}getSelf(){return d.NULL_REFERENCE}getTag(){return y.ENV._DEBUG_RENDER_TREE?(0,l.createTag)():l.CONSTANT_TAG}getDestructor(e){return y.ENV._DEBUG_RENDER_TREE?{destroy(){e.environment.debugRenderTree.willDestroy(e)}}:null}didRenderLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&e.environment.debugRenderTree.didRender(e,t)}update(e){y.ENV._DEBUG_RENDER_TREE&&e.environment.debugRenderTree.update(e)}didUpdateLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&e.environment.debugRenderTree.didRender(e,t)}} -class Pr{constructor(e,t){this.name=e,this.template=t,this.manager=Sr}get state(){return this}}{class e{constructor(e,t){this.component=e,this.message=t,this.tag=e.tag}value(){var e=this.component.value() -return"string"==typeof e&&(0,c.assert)(this.message,"string"!=typeof e),e}get(e){return this.component.get(e)}}Tr=(t,r)=>new e(r.positional.at(0),r.positional.at(1).value())}var Cr=Tr -function Mr({positional:e}){var t=e.at(0),r=e.length,i=t.value() -return!0===i?r>1?(0,_.dasherize)(e.at(1).value()):null:!1===i?r>2?(0,_.dasherize)(e.at(2).value()):null:i}function kr({positional:e}){return"checkbox"===e.at(0).value()?"-checkbox":"-text-field"}function Dr({positional:e}){var t=e.at(0).value().split("."),r=t[t.length-1],i=e.at(1).value() -return!0===i?(0,_.dasherize)(r):i||0===i?String(i):""}function xr(e){return e}function jr(e,t,r,i,n){var s,a -if(null==r&&(0,c.assert)("Action passed is null or undefined in (action) from "+t+".",null!=r),"function"==typeof r[Q])s=r,a=r[Q] -else{var l=typeof r -"string"===l?(s=t,!(a=t.actions&&t.actions[r])&&(0,c.assert)("An action named '"+r+"' was not found in "+t,a)):"function"===l?(s=e,a=r):(0,c.assert)("An action could not be made for `"+(n||r)+"` in "+t+". Please confirm that you are using either a quoted action name (i.e. `(action '"+(n||"myAction")+"')`) or a function available in "+t+".",!1)}return(...e)=>{var t={target:s,args:e,label:"@glimmer/closure-action"} -return(0,f.flaggedInstrument)("interaction.ember-action",t,()=>(0,o.join)(s,a,...i(e)))}}var Nr=e=>(e=>null==e||"function"!=typeof e.toString)(e)?"":String(e) -function Ir({positional:e}){return e.value().map(Nr).join("")}function Fr(e){var t=null -if(a.HAS_NATIVE_PROXY){var r=t=>{(0,c.assert)("You accessed `this."+String(t)+"` from a function passed to the "+e+", but the function itself was not bound to a valid `this` context. Consider updating to usage of `@action`.")} -t=new Proxy({},{get(e,t){r(t)},set:(e,t)=>(r(t),!1),has:(e,t)=>(r(t),!1)})}return t}var Lr=Fr("`fn` helper") -function zr({positional:e}){var t=e.at(0) -if("function"!=typeof t[Q]){var r=t.value() -"function"!=typeof r&&(0,c.assert)("You must pass a function as the `fn` helpers first argument, you passed "+r,"function"==typeof r)}return(...r)=>{var[i,...n]=e.value() -return"function"==typeof t[Q]?t[Q](...n,...r):i.call(Lr,...n,...r)}}function Br(e,t){return null==t||""===t?d.NULL_REFERENCE:"string"==typeof t&&t.indexOf(".")>-1?ce(e,t.split(".")):e.get(t)}class Ur extends X{static create(e,t){return(0,l.isConst)(t)?Br(e,t.value()):new Ur(e,t)}constructor(e,t){super(),this.sourceReference=e,this.pathReference=t,this.lastPath=null,this.innerReference=d.NULL_REFERENCE -var r=this.innerTag=(0,l.createUpdatableTag)() -this.tag=(0,l.combine)([e.tag,t.tag,r])}compute(){var{lastPath:e,innerReference:t,innerTag:r}=this,i=this.pathReference.value() -return i!==e&&(t=Br(this.sourceReference,i),(0,l.update)(r,t.tag),this.innerReference=t,this.lastPath=i),t.value()}[W](e){(0,u.set)(this.sourceReference.value(),this.pathReference.value(),e)}}class Hr extends X{static create(e,t,r){var i=ne.create(e) -return(0,l.isConst)(i)?i.value()?t:r:new Hr(i,t,r)}constructor(e,t,r){super(),this.branchTag=(0,l.createUpdatableTag)(),this.tag=(0,l.combine)([e.tag,this.branchTag]),this.cond=e,this.truthy=t,this.falsy=r}compute(){var e=this.cond.value()?this.truthy:this.falsy -return(0,l.update)(this.branchTag,e.tag),e.value()}}function Vr({positional:e}){console.log(...e.value())}var qr=(0,a.symbol)("MUT"),Yr=(0,a.symbol)("SOURCE") -function Gr({positional:e,named:t}){return 0!==e.value().length&&(0,c.assert)("The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName='foo') as opposed to just (query-params 'foo')",0===e.value().length),new A.QueryParams((0,r.assign)({},t.value()))}var Kr=["alt","shift","meta","ctrl"],Wr=/^click|mouse|touch/ -var Qr={registeredActions:p.ActionManager.registeredActions,registerAction(e){var{actionId:t}=e -return p.ActionManager.registeredActions[t]=e,t},unregisterAction(e){var{actionId:t}=e -delete p.ActionManager.registeredActions[t]}} -class $r{constructor(e,t,r,i,n,s,a,o,l){this.element=e,this.actionId=t,this.actionName=r,this.actionArgs=i,this.namedArgs=n,this.positional=s,this.implicitTarget=a,this.dom=o,this.eventName=this.getEventName(),this.tag=l}getEventName(){return this.namedArgs.get("on").value()||"click"}getActionArgs(){for(var e=new Array(this.actionArgs.length),t=0;tnew e(t.positional.at(0),t.positional.at(1).value())}var Dt=Pt +function kt({positional:e}){return"string"!=typeof e.at(0).value()&&(0,l.assert)("[BUG] -i takes a single string","string"==typeof e.at(0).value()),parseInt(e.at(0).value(),10)}function Nt({positional:e}){return"checkbox"===e.at(0).value()?"-checkbox":"-text-field"}function jt({positional:e}){var t=e.at(0).value().split("."),r=t[t.length-1],i=e.at(1).value() +return!0===i?(0,y.dasherize)(r):i||0===i?String(i):""}class It{constructor(e){this.inner=e,this.valueTag=(0,d.createUpdatableTag)(),this.tag=(0,d.combine)([e.tag,this.valueTag])}value(){var e=this.inner.value(),t=(0,i.tagForProperty)(e,"[]") +return(0,d.update)(this.valueTag,t),e}get(e){return this.inner.get(e)}}var Ft=e=>(e=>null==e||"function"!=typeof e.toString)(e)?"":String(e) +function Lt({positional:e}){return e.value().map(Ft).join("")}function zt(e){var t=null +if(a.HAS_NATIVE_PROXY){var r=t=>{(0,l.assert)(`You accessed \`this.${String(t)}\` from a function passed to the ${e}, but the function itself was not bound to a valid \`this\` context. Consider updating to usage of \`@action\`.`)} +t=new Proxy({},{get(e,t){r(t)},set:(e,t)=>(r(t),!1),has:(e,t)=>(r(t),!1)})}return t}var Ut=zt("`fn` helper") +function Bt({positional:e}){var t=e.at(0) +if("function"!=typeof t[Se]){var r=t.value() +"function"!=typeof r&&(0,l.assert)(`You must pass a function as the \`fn\` helpers first argument, you passed ${r}`,"function"==typeof r)}return(...r)=>{var[i,...n]=e.value() +return"function"==typeof t[Se]?t[Se](...n,...r):i.call(Ut,...n,...r)}}function $t({positional:e}){var t=e.at(0).value() +if((0,a.isObject)(t)){var r=e.at(1).value() +return(0,i.get)(t,String(r))}}class Ht extends u.HelperRootReference{constructor(e,t){super($t,e,t),this.sourceReference=e.positional.at(0),this.pathReference=e.positional.at(1)}[u.UPDATE_REFERENCED_VALUE](e){var t=this.sourceReference.value() +if((0,a.isObject)(t)){var r=String(this.pathReference.value());(0,i.set)(t,r,e)}}}function Vt(e){return e.named.capture()}function qt({positional:e}){3!==e.length&&2!==e.length&&(0,l.assert)('The inline form of the `if` helper expects two or three arguments, e.g. `{{if trialExpired "Expired" expiryDate}}`.',3===e.length||2===e.length) +var t=e.at(0),r=e.at(1),i=e.at(2) +return!0===gt(t.value())?r.value():void 0!==i?i.value():void 0}function Yt({positional:e}){3!==e.length&&2!==e.length&&(0,l.assert)('The inline form of the `unless` helper expects two or three arguments, e.g. `{{unless isFirstLogin "Welcome back!"}}`.',3===e.length||2===e.length) +var t=e.at(0),r=e.at(2),i=e.at(1) +return!0===gt(t.value())?void 0!==r?r.value():void 0:i.value()}function Gt({positional:e}){console.log(...e.value())}function Wt({positional:e,named:r}){return 0!==e.value().length&&(0,l.assert)("The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName='foo') as opposed to just (query-params 'foo')",0===e.value().length),new R.QueryParams((0,t.assign)({},r.value()))}class Kt extends u.RootReference{constructor(e,t){super(t),this.inner=e,this.tag=e.tag}get[Se](){return this.inner[Se]}value(){return this.inner.value()}get(e){return this.inner.get(e)}}var Qt=["alt","shift","meta","ctrl"],Jt=/^click|mouse|touch/ +var Xt={registeredActions:o.ActionManager.registeredActions,registerAction(e){var{actionId:t}=e +return o.ActionManager.registeredActions[t]=e,t},unregisterAction(e){var{actionId:t}=e +delete o.ActionManager.registeredActions[t]}} +class Zt{constructor(e,t,r,i,n,s,a,o,l){this.element=e,this.actionId=t,this.actionName=r,this.actionArgs=i,this.namedArgs=n,this.positional=s,this.implicitTarget=a,this.dom=o,this.eventName=this.getEventName(),this.tag=l}getEventName(){return this.namedArgs.get("on").value()||"click"}getActionArgs(){for(var e=new Array(this.actionArgs.length),t=0;t=0)return!0 -for(var r=0;r{var e=this.getActionArgs(),r={args:e,target:a,name:null} -"function"!=typeof t[Q]?"function"!=typeof t?(r.name=t,a.send?(0,f.flaggedInstrument)("interaction.ember-action",r,()=>{a.send.apply(a,[t,...e])}):("function"!=typeof a[t]&&(0,c.assert)("The action '"+t+"' did not exist on "+a,"function"==typeof a[t]),(0,f.flaggedInstrument)("interaction.ember-action",r,()=>{a[t].apply(a,e)}))):(0,f.flaggedInstrument)("interaction.ember-action",r,()=>{t.apply(a,e)}):(0,f.flaggedInstrument)("interaction.ember-action",r,()=>{t[Q].apply(t,e)})}),l)}destroy(){Qr.unregisterAction(this)}}class Jr{create(e,t,r,i,n){var s,o,l,{named:u,positional:d,tag:h}=r.capture() -if(d.length>1)if(s=d.at(0),(l=d.at(1))[Q])o=l -else{var p=l.propertyKey -"string"!=typeof(o=l.value())&&"function"!=typeof o&&(0,c.assert)("You specified a quoteless path, `"+p+'`, to the {{action}} helper which did not resolve to an action name (a string). Perhaps you meant to use a quoted actionName? (e.g. {{action "'+p+'"}}).',"string"==typeof o||"function"==typeof o)}for(var m=[],f=2;fi.installModifier(n,t,r.value())) -else{var c=(0,u.track)(()=>i.installModifier(n,t,r.value()),G("(instance of a `"+(0,a.getDebugName)(n)+"` modifier)"));(0,l.update)(s,c)}}update(e){var{args:t,delegate:r,modifier:i,tag:n}=e,{capabilities:s}=r -if(!0===s.disableAutoTracking)(0,u.untrack)(()=>r.updateModifier(i,t.value())) -else{var o=(0,u.track)(()=>r.updateModifier(i,t.value()),G("(instance of a `"+(0,a.getDebugName)(i)+"` modifier)"));(0,l.update)(n,o)}}getDestructor(e){return e}},ri=new class{create(){return null}getTag(){return l.CONSTANT_TAG}install(){}update(){}getDestructor(){return null}},ii=Fr("`on` modifier"),ni=(()=>{try{var e,t=document.createElement("div"),r=0 +for(var r=0;r{var e=this.getActionArgs(),r={args:e,target:a,name:null} +"function"!=typeof t[Se]?"function"!=typeof t?(r.name=t,a.send?(0,p.flaggedInstrument)("interaction.ember-action",r,()=>{a.send.apply(a,[t,...e])}):("function"!=typeof a[t]&&(0,l.assert)(`The action '${t}' did not exist on ${a}`,"function"==typeof a[t]),(0,p.flaggedInstrument)("interaction.ember-action",r,()=>{a[t].apply(a,e)}))):(0,p.flaggedInstrument)("interaction.ember-action",r,()=>{t.apply(a,e)}):(0,p.flaggedInstrument)("interaction.ember-action",r,()=>{t[Se].apply(t,e)})}),u)}destroy(){Xt.unregisterAction(this)}}class er{create(e,t,r,i,n){var s,o,u,{named:c,positional:d,tag:h}=r.capture() +if(d.length>1)if(s=d.at(0),(u=d.at(1))[Se])o=u +else{var p=u.propertyKey +"string"!=typeof(o=u.value())&&"function"!=typeof o&&(0,l.assert)("You specified a quoteless path, `"+p+'`, to the {{action}} helper which did not resolve to an action name (a string). Perhaps you meant to use a quoted actionName? (e.g. {{action "'+p+'"}}).',"string"==typeof o||"function"==typeof o)}for(var m=[],f=2;f`While rendering:\n----------------\n${e.replace(/^/gm," ")}` +function rr(e,t={}){return"3.13"!==e&&(e="3.13",(0,l.deprecate)("Modifier manager capabilities now require you to pass a valid version when being generated. Valid versions include: 3.13",!1,{until:"3.17.0",id:"implicit-modifier-manager-capabilities"})),"3.13"!==e&&(0,l.assert)("Invalid modifier manager compatibility specified","3.13"===e),{disableAutoTracking:Boolean(t.disableAutoTracking)}}class ir{constructor(e,t,r,i){this.name=e,this.ModifierClass=t,this.delegate=r,this.state={ModifierClass:t,name:e,delegate:r},this.manager=i?sr:ar}}class nr{constructor(e,t,r,i){this.element=e,this.delegate=t,this.modifier=r,this.args=i,this.tag=(0,d.createUpdatableTag)()}destroy(){var{delegate:e,modifier:t,args:r}=this +e.destroyModifier(t,r.value())}}var sr=new class{create(e,t,r){var{delegate:i,ModifierClass:n}=t,s=r.capture(),a=t.delegate.createModifier(n,s.value()) +return void 0===i.capabilities&&(i.capabilities=rr("3.13"),(0,l.deprecate)("Custom modifier managers must define their capabilities using the capabilities() helper function",!1,{until:"3.17.0",id:"implicit-modifier-manager-capabilities"})),new nr(e,i,a,s)}getTag({args:e,tag:t}){return(0,d.combine)([t,e.tag])}install(e){var{element:t,args:r,delegate:i,modifier:n,tag:s}=e,{capabilities:o}=i +if(!0===o.disableAutoTracking)(0,d.untrack)(()=>i.installModifier(n,t,r.value())) +else{var l=(0,d.track)(()=>i.installModifier(n,t,r.value()),tr(`(instance of a \`${(0,a.getDebugName)(n)}\` modifier)`));(0,d.update)(s,l)}}update(e){var{args:t,delegate:r,modifier:i,tag:n}=e,{capabilities:s}=r +if(!0===s.disableAutoTracking)(0,d.untrack)(()=>r.updateModifier(i,t.value())) +else{var o=(0,d.track)(()=>r.updateModifier(i,t.value()),tr(`(instance of a \`${(0,a.getDebugName)(i)}\` modifier)`));(0,d.update)(n,o)}}getDestructor(e){return e}},ar=new class{create(){return null}getTag(){return d.CONSTANT_TAG}install(){}update(){}getDestructor(){return null}},or=zt("`on` modifier"),lr=(()=>{try{var e,t=document.createElement("div"),r=0 return t.addEventListener("click",()=>r++,{once:!0}),"function"==typeof Event?e=new Event("click"):(e=document.createEvent("Event")).initEvent("click",!0,!0),t.dispatchEvent(e),t.dispatchEvent(e),1===r}catch(e){return!1}})() -class si{constructor(e,t){this.shouldUpdate=!0,this.element=e,this.args=t,this.tag=t.tag}updateFromArgs(){var e,{args:t}=this,{once:r,passive:i,capture:n}=t.named.value() -r!==this.once&&(this.once=r,this.shouldUpdate=!0),i!==this.passive&&(this.passive=i,this.shouldUpdate=!0),n!==this.capture&&(this.capture=n,this.shouldUpdate=!0),r||i||n?e=this.options={once:r,passive:i,capture:n}:this.options=void 0,(void 0===t.positional.at(0)||"string"!=typeof t.positional.at(0).value())&&(0,c.assert)("You must pass a valid DOM event name as the first argument to the `on` modifier",void 0!==t.positional.at(0)&&"string"==typeof t.positional.at(0).value()) +class ur{constructor(e,t){this.shouldUpdate=!0,this.element=e,this.args=t,this.tag=t.tag}updateFromArgs(){var e,{args:t}=this,{once:r,passive:i,capture:n}=t.named.value() +r!==this.once&&(this.once=r,this.shouldUpdate=!0),i!==this.passive&&(this.passive=i,this.shouldUpdate=!0),n!==this.capture&&(this.capture=n,this.shouldUpdate=!0),r||i||n?e=this.options={once:r,passive:i,capture:n}:this.options=void 0,(void 0===t.positional.at(0)||"string"!=typeof t.positional.at(0).value())&&(0,l.assert)("You must pass a valid DOM event name as the first argument to the `on` modifier",void 0!==t.positional.at(0)&&"string"==typeof t.positional.at(0).value()) var s=t.positional.at(0).value() -s!==this.eventName&&(this.eventName=s,this.shouldUpdate=!0),(void 0===t.positional.at(1)||"function"!=typeof t.positional.at(1).value())&&(0,c.assert)("You must pass a function as the second argument to the `on` modifier",void 0!==t.positional.at(1)&&"function"==typeof t.positional.at(1).value()) +s!==this.eventName&&(this.eventName=s,this.shouldUpdate=!0),(void 0===t.positional.at(1)||"function"!=typeof t.positional.at(1).value())&&(0,l.assert)("You must pass a function as the second argument to the `on` modifier",void 0!==t.positional.at(1)&&"function"==typeof t.positional.at(1).value()) var a=t.positional.at(1).value() -a!==this.userProvidedCallback&&(this.userProvidedCallback=a,this.shouldUpdate=!0),2!==t.positional.length&&(0,c.assert)("You can only pass two positional arguments (event name and callback) to the `on` modifier, but you provided "+t.positional.length+". Consider using the `fn` helper to provide additional arguments to the `on` callback.",2===t.positional.length) -var o=!1===ni&&r||i -if(this.shouldUpdate)if(o)var l=this.callback=function(t){return i&&(t.preventDefault=()=>{(0,c.assert)("You marked this listener as 'passive', meaning that you must not call 'event.preventDefault()': \n\n"+a)}),!ni&&r&&li(this,s,l,e),a.call(ii,t)} -else this.callback=a.bind(ii)}destroy(){var{element:e,eventName:t,callback:r,options:i}=this -li(e,t,r,i)}}var ai=0,oi=0 -function li(e,t,r,i){oi++,ni?e.removeEventListener(t,r,i):void 0!==i&&i.capture?e.removeEventListener(t,r,!0):e.removeEventListener(t,r)}function ui(e,t,r,i){ai++,ni?e.addEventListener(t,r,i):void 0!==i&&i.capture?e.addEventListener(t,r,!0):e.addEventListener(t,r)}class ci{constructor(e){this.SUPPORTS_EVENT_OPTIONS=ni,this.isInteractive=e}get counters(){return{adds:ai,removes:oi}}create(e,t,r){if(!this.isInteractive)return null +a!==this.userProvidedCallback&&(this.userProvidedCallback=a,this.shouldUpdate=!0),2!==t.positional.length&&(0,l.assert)(`You can only pass two positional arguments (event name and callback) to the \`on\` modifier, but you provided ${t.positional.length}. Consider using the \`fn\` helper to provide additional arguments to the \`on\` callback.`,2===t.positional.length) +var o=!1===lr&&r||i +if(this.shouldUpdate)if(o)var u=this.callback=function(t){return i&&(t.preventDefault=()=>{(0,l.assert)(`You marked this listener as 'passive', meaning that you must not call 'event.preventDefault()': \n\n${a}`)}),!lr&&r&&hr(this,s,u,e),a.call(or,t)} +else this.callback=a.bind(or)}destroy(){var{element:e,eventName:t,callback:r,options:i}=this +hr(e,t,r,i)}}var cr=0,dr=0 +function hr(e,t,r,i){dr++,lr?e.removeEventListener(t,r,i):void 0!==i&&i.capture?e.removeEventListener(t,r,!0):e.removeEventListener(t,r)}function pr(e,t,r,i){cr++,lr?e.addEventListener(t,r,i):void 0!==i&&i.capture?e.addEventListener(t,r,!0):e.addEventListener(t,r)}class mr{constructor(e){this.SUPPORTS_EVENT_OPTIONS=lr,this.isInteractive=e}get counters(){return{adds:cr,removes:dr}}create(e,t,r){if(!this.isInteractive)return null var i=r.capture() -return new si(e,i)}getTag(e){return null===e?l.CONSTANT_TAG:e.tag}install(e){if(null!==e){e.updateFromArgs() +return new ur(e,i)}getTag(e){return null===e?d.CONSTANT_TAG:e.tag}install(e){if(null!==e){e.updateFromArgs() var{element:t,eventName:r,callback:i,options:n}=e -ui(t,r,i,n),e.shouldUpdate=!1}}update(e){if(null!==e){var{element:t,eventName:r,callback:i,options:n}=e -e.updateFromArgs(),e.shouldUpdate&&(li(t,r,i,n),ui(e.element,e.eventName,e.callback,e.options),e.shouldUpdate=!1)}}getDestructor(e){return e}}function di(e,t,r,i,n){return null!==r&&(null!==e?(n.compileParams(e),n.invokeStaticBlock(r,e.length)):n.invokeStatic(r)),!0}var hi={dynamicLayout:!0,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0} -var pi=new class extends gt{getDynamicLayout(e,t){var r=e.engine.lookup("template:application")(e.engine),i=r.asLayout() -return y.ENV._DEBUG_RENDER_TREE&&e.environment.debugRenderTree.setTemplate(e.controller,r),{handle:i.compile(),symbolTable:i.symbolTable}}getCapabilities(){return hi}create(e,{name:t},r){var i=e.owner.buildChildEngineInstance(t) +pr(t,r,i,n),e.shouldUpdate=!1}}update(e){if(null!==e){var{element:t,eventName:r,callback:i,options:n}=e +e.updateFromArgs(),e.shouldUpdate&&(hr(t,r,i,n),pr(e.element,e.eventName,e.callback,e.options),e.shouldUpdate=!1)}}getDestructor(e){return e}}var fr={dynamicLayout:!0,dynamicTag:!1,prepareArgs:!1,createArgs:!0,attributeHook:!1,elementHook:!1,createCaller:!0,dynamicScope:!0,updateHook:!0,createInstance:!0,wrapped:!1,willDestroy:!1} +var gr=new class extends ae{getJitDynamicLayout(e,t){var r=e.engine.lookup("template:application")(e.engine) +return g.ENV._DEBUG_RENDER_TREE&&e.environment.extra.debugRenderTree.setTemplate(e.controller,r),r}getCapabilities(){return fr}create(e,{name:t},r){var i=e.extra.owner.buildChildEngineInstance(t) i.boot() -var n,s,a,o=i.factoryFor("controller:application")||(0,A.generateControllerFactory)(i,"application") -if(r.named.has("model")&&(a=r.named.get("model")),void 0===a)s={engine:i,controller:n=o.create(),self:new Z(n,e),environment:e} +var n,s,a,o=i.factoryFor("controller:application")||(0,R.generateControllerFactory)(i,"application") +if(r.named.has("model")&&(a=r.named.get("model")),void 0===a)s={engine:i,controller:n=o.create(),self:new u.ComponentRootReference(n,e),environment:e} else{var l=a.value() -s={engine:i,controller:n=o.create({model:l}),self:new Z(n,e),modelRef:a,environment:e}}return y.ENV._DEBUG_RENDER_TREE&&(e.debugRenderTree.create(s,{type:"engine",name:t,args:r.capture(),instance:i,template:void 0}),e.debugRenderTree.create(n,{type:"route-template",name:"application",args:r.capture(),instance:n,template:void 0})),s}getSelf({self:e}){return e}getTag(e){var t=l.CONSTANT_TAG -return e.modelRef&&(t=e.modelRef.tag),y.ENV._DEBUG_RENDER_TREE&&(0,l.isConstTag)(t)&&(t=(0,l.createTag)()),t}getDestructor(e){var{engine:t,environment:r,controller:i}=e -return y.ENV._DEBUG_RENDER_TREE?{destroy(){r.debugRenderTree.willDestroy(i),r.debugRenderTree.willDestroy(e),t.destroy()}}:t}didRenderLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&(e.environment.debugRenderTree.didRender(e.controller,t),e.environment.debugRenderTree.didRender(e,t))}update(e){var{controller:t,environment:r,modelRef:i}=e -void 0!==i&&t.set("model",i.value()),y.ENV._DEBUG_RENDER_TREE&&(r.debugRenderTree.update(e),r.debugRenderTree.update(e.controller))}didUpdateLayout(e,t){y.ENV._DEBUG_RENDER_TREE&&(e.environment.debugRenderTree.didRender(e.controller,t),e.environment.debugRenderTree.didRender(e,t))}} -class mi{constructor(e){this.manager=pi,this.state={name:e}}}function fi(e,t,r,i){if(1!==t.length&&(0,c.assert)('You can only pass a single positional argument to the {{mount}} helper, e.g. {{mount "chat-engine"}}.',1===t.length),r){var n=r[0].filter(e=>"model"!==e) -0!==n.length&&(0,c.assert)('You can only pass a `model` argument to the {{mount}} helper, e.g. {{mount "profile-engine" model=this.profile}}. You passed '+n.join(",")+".",0===n.length)}var s=[E.Ops.Helper,"-mount",t||[],r] -return i.dynamicComponent(s,null,[],null,!1,null,null),!0}class gi{constructor(e,t,r){this.nameRef=e,this.env=t,this.args=r,this._lastName=null,this._lastDef=null,this.tag=e.tag}value(){var{env:e,nameRef:t,args:r}=this,i=t.value() -return"string"==typeof i?this._lastName===i?this._lastDef:(!e.owner.hasRegistration("engine:"+i)&&(0,c.assert)("You used `{{mount '"+i+"'}}`, but the engine '"+i+"' can not be found.",e.owner.hasRegistration("engine:"+i)),e.owner.hasRegistration("engine:"+i)?(this._lastName=i,this._lastDef=(0,d.curry)(new mi(i),r),this._lastDef):null):(null!=i&&(0,c.assert)("Invalid engine name '"+i+"' specified, engine name must be either a string, null or undefined.",null==i),this._lastDef=null,this._lastName=null,null)}get(){return d.UNDEFINED_REFERENCE}}class vi{constructor(e){this.outletState=e,this.tag=(0,l.createTag)()}get(e){return new bi(this,e)}value(){return this.outletState}update(e){this.outletState.outlets.main=e,(0,l.dirty)(this.tag)}}class yi{constructor(e,t){this.parentStateRef=e,this.outletNameRef=t,this.tag=(0,l.combine)([e.tag,t.tag])}value(){var e=this.parentStateRef.value(),t=void 0===e?void 0:e.outlets -return void 0===t?void 0:t[this.outletNameRef.value()]}get(e){return new bi(this,e)}}class bi{constructor(e,t){this.parent=e,this.key=t,this.tag=e.tag}get(e){return new bi(this,e)}value(){var e=this.parent.value() -return e&&e[this.key]}}function _i(e,t,r,i){var n=[E.Ops.Helper,"-outlet",t||[],r] -return i.dynamicComponent(n,null,[],null,!1,null,null),!0}class Ei{constructor(e,t){this.parent=e,this.env=t,this.tag=e.tag}value(){var e=this.parent.value() +s={engine:i,controller:n=o.create({model:l}),self:new u.ComponentRootReference(n,e),modelRef:a,environment:e}}return g.ENV._DEBUG_RENDER_TREE&&(e.extra.debugRenderTree.create(s,{type:"engine",name:t,args:r.capture(),instance:i,template:void 0}),e.extra.debugRenderTree.create(n,{type:"route-template",name:"application",args:r.capture(),instance:n,template:void 0})),s}getSelf({self:e}){return e}getTag(e){var t=d.CONSTANT_TAG +return e.modelRef&&(t=e.modelRef.tag),g.ENV._DEBUG_RENDER_TREE&&(0,d.isConstTag)(t)&&(t=(0,d.createTag)()),t}getDestructor(e){var{engine:t,environment:r,controller:i}=e +return g.ENV._DEBUG_RENDER_TREE?{destroy(){r.extra.debugRenderTree.willDestroy(i),r.extra.debugRenderTree.willDestroy(e),t.destroy()}}:t}didRenderLayout(e,t){g.ENV._DEBUG_RENDER_TREE&&(e.environment.extra.debugRenderTree.didRender(e.controller,t),e.environment.extra.debugRenderTree.didRender(e,t))}update(e){var{controller:t,environment:r,modelRef:i}=e +void 0!==i&&t.set("model",i.value()),g.ENV._DEBUG_RENDER_TREE&&(r.extra.debugRenderTree.update(e),r.extra.debugRenderTree.update(e.controller))}didUpdateLayout(e,t){g.ENV._DEBUG_RENDER_TREE&&(e.environment.extra.debugRenderTree.didRender(e.controller,t),e.environment.extra.debugRenderTree.didRender(e,t))}} +class vr{constructor(e){this.manager=gr,this.state={name:e}}}class yr{constructor(e,t,r){this.nameRef=e,this.env=t,this.args=r,this._lastName=null,this._lastDef=null,this.tag=e.tag}value(){var{env:e,nameRef:t,args:r}=this,i=t.value() +return"string"==typeof i?this._lastName===i?this._lastDef:(!e.extra.owner.hasRegistration(`engine:${i}`)&&(0,l.assert)(`You used \`{{mount '${i}'}}\`, but the engine '${i}' can not be found.`,e.extra.owner.hasRegistration(`engine:${i}`)),e.extra.owner.hasRegistration(`engine:${i}`)?(this._lastName=i,this._lastDef=(0,c.curry)(new vr(i),r),this._lastDef):null):(null!=i&&(0,l.assert)(`Invalid engine name '${i}' specified, engine name must be either a string, null or undefined.`,null==i),this._lastDef=null,this._lastName=null,null)}get(){return c.UNDEFINED_REFERENCE}}class br{constructor(e){this.outletState=e,this.tag=(0,d.createTag)()}get(e){return new Er(this,e)}value(){return this.outletState}update(e){this.outletState.outlets.main=e,(0,d.dirty)(this.tag)}}class _r{constructor(e,t){this.parentStateRef=e,this.outletNameRef=t,this.tag=(0,d.combine)([e.tag,t.tag])}value(){var e=this.parentStateRef.value(),t=void 0===e?void 0:e.outlets +return void 0===t?void 0:t[this.outletNameRef.value()]}get(e){return new Er(this,e)}}class Er{constructor(e,t){this.parent=e,this.key=t,this.tag=e.tag}get(e){return new Er(this,e)}value(){var e=this.parent.value() +return e&&e[this.key]}}class Rr extends u.RootReference{constructor(e,t){super(t),this.parent=e,this.tag=e.tag}value(){var e=this.parent.value() if(void 0!==e){var{render:t}=e -if(void 0!==t)return t.model}}get(e){return this.debugStackLog=this.env.debugRenderTree.logCurrentRenderStack(),new re(this,e)}}Ei.prototype.debug=function(e){return this.debugStackLog+"@model."+e} -class Ri{constructor(e,t){this.outletRef=e,this.args=null,this.definition=null,this.lastState=null -var r=this.tag=e.tag,i=new Ei(e,t),n=(0,v.dict)() -n.model=i,this.args={tag:r,positional:d.EMPTY_ARGS.positional,named:{tag:r,map:n,names:["model"],references:[i],length:1,has:e=>"model"===e,get:e=>"model"===e?i:d.UNDEFINED_REFERENCE,value:()=>({model:i.value()})},length:1,value(){return{named:this.named.value(),positional:this.positional.value()}}}}value(){var e=function(e){var t=e.value() +if(void 0!==t)return t.model}}}Rr.prototype.debugLogName="@model" +class wr{constructor(e,t){this.outletRef=e,this.env=t,this.definition=null,this.lastState=null,this.tag=e.tag}value(){var e=function(e){var t=e.value() if(void 0===t)return null var r=t.render if(void 0===r)return null var i=r.template if(void 0===i)return null -F(i)&&(i=i(r.owner)) +S(i)&&(i=i(r.owner)) return{ref:e,name:r.name,outlet:r.outlet,template:i,controller:r.controller,model:r.model}}(this.outletRef) if(function(e,t){if(null===e)return null===t if(null===t)return!1 return e.template===t.template&&e.controller===t.controller}(e,this.lastState))return this.definition this.lastState=e -var t=null -return null!==e&&(t=(0,d.curry)(new Et(e),this.args)),this.definition=t}get(e){return d.UNDEFINED_REFERENCE}}function Oi(e){return null===e?null:[e[0].map(e=>"@"+e),e[1]]}function Ai(e,t,r,i){i.compiler.resolver.resolver.builtInHelpers[e]&&i.referrer.owner.hasRegistration("helper:"+e)&&(0,c.assert)('You attempted to overwrite the built-in helper "'+e+'" which is not allowed. Please rename the helper.',!(i.compiler.resolver.resolver.builtInHelpers[e]&&i.referrer.owner.hasRegistration("helper:"+e))) -var n=i.compiler.resolver.lookupComponentDefinition(e,i.referrer) -return null!==n&&(i.component.static(n,[null===t?[]:t,Oi(r),null,null]),!0)}function wi(e,t,r,i,n,s){var a=s.compiler.resolver.lookupComponentDefinition(e,s.referrer) -return null!==a?(function(e){if(null!==e){var[t,r]=e,i=null===t?-1:t.indexOf("class") -if(-1!==i){var n=r[i] -if(!Array.isArray(n))return -var[s]=n -if(s===E.Ops.Get||s===E.Ops.MaybeLocal){var a=n[n.length-1],o=a[a.length-1] -r[i]=[E.Ops.Helper,"-class",[n,o],null]}}}}(r),s.component.static(a,[t,Oi(r),i,n]),!0):(!s.referrer.owner.hasRegistration("helper:"+e)&&(0,c.assert)('A component or helper named "'+e+'" could not be found',s.referrer.owner.hasRegistration("helper:"+e)),(()=>{var t=s.compiler.resolver.resolver,{owner:r,moduleName:i}=s.referrer -if("component"===e||t.builtInHelpers[e])return!0 -var n={source:"template:"+i} -return r.hasRegistration("helper:"+e,n)||r.hasRegistration("helper:"+e)})()&&(0,c.assert)("Helpers may not be used in the block form, for example {{#"+e+"}}{{/"+e+"}}. Please use a component, or alternatively use the helper in combination with a built-in Ember helper, for example {{#if ("+e+")}}{{/if}}.",!(()=>{var t=s.compiler.resolver.resolver,{owner:r,moduleName:i}=s.referrer -if("component"===e||t.builtInHelpers[e])return!0 -var n={source:"template:"+i} -return r.hasRegistration("helper:"+e,n)||r.hasRegistration("helper:"+e)})()),!1)}var Ti=[] -e._experimentalMacros=Ti -var Si,Pi,Ci,Mi=new WeakMap,ki=Object.getPrototypeOf -function Di(e){for(var t=e;null!=t;){var r=Mi.get(t) +var t,r,i,n,s,a=null +if(null!==e){var o=(t=this.outletRef,r=this.env,i=t.tag,n=new Rr(t,r),(s=(0,_.dict)()).model=n,{tag:i,positional:c.EMPTY_ARGS.positional,named:{tag:i,map:s,names:["model"],references:[n],length:1,has:e=>"model"===e,get:e=>"model"===e?n:c.UNDEFINED_REFERENCE,value:()=>({model:n.value()})},length:1,value(){return{named:this.named.value(),positional:this.positional.value()}}}) +a=(0,c.curry)(new de(e),o)}return this.definition=a}get(e){return c.UNDEFINED_REFERENCE}}var Ar=new WeakMap,Or=Object.getPrototypeOf +function Tr(e){for(var t=e;null!=t;){var r=Ar.get(t) if(void 0!==r)return r -t=ki(t)}return null}function xi(e){var t=mr(e) -return t&&!t.internal&&"modifier"===t.type?t.factory:void 0}function ji(e){return{object:"component:"+e}}function Ni(e,t){return{source:void 0!==e?"template:"+e:void 0,namespace:t}}function Ii(e,t,r){var i=function(e,t,r){var i="component:"+e +t=Or(t)}return null}var Sr,Cr,Pr,Mr=new WeakMap,xr=Object.getPrototypeOf +function Dr(e,t){return Mr.set(t,e),t}function kr(e){for(var t=e;null!=t;){var r=Mr.get(t) +if(void 0!==r)return r +t=xr(t)}return null}function Nr(e){var t=kr(e) +return t&&!t.internal&&"modifier"===t.type?t.factory:void 0}function jr(e){return{object:`component:${e}`}}function Ir(e,t){return{source:void 0!==e?`template:${e}`:void 0,namespace:t}}function Fr(e,t,r){var i=function(e,t,r){var i=`component:${e}` return t.factoryFor(i,r)||null}(t,e,r) -if(null!==i&&void 0!==i.class){var n=Di(i.class) -if(null!==n)return{component:i,layout:n}}var s=function(e,t,r){var i="template:components/"+e +if(null!==i&&void 0!==i.class){var n=Tr(i.class) +if(null!==n)return{component:i,layout:n}}var s=function(e,t,r){var i=`template:components/${e}` return t.lookup(i,r)||null}(t,e,r) -return null===i&&null===s?null:{component:i,layout:s}}b.PARTIALS&&(Si=function(e,t){if((0,c.deprecate)('The use of `{{partial}}` is deprecated, please refactor the "'+e+'" partial to a component',!1,{id:"ember-views.partial",until:"4.0.0",url:"https://deprecations.emberjs.com/v3.x#toc_ember-views-partial"}),null!==e){var r=Pi(t,Ci(e),e) -return!Boolean(r)&&(0,c.assert)('Unable to find partial with name "'+e+'"',Boolean(r)),r}},Pi=function(e,t,r){if(b.PARTIALS){if(!r)return -if(-1!==r.indexOf(".")&&(0,c.assert)("templateNames are not allowed to contain periods: "+r,-1===r.indexOf(".")),!e)throw new T.default("Container was not found when looking up a views template. This is most likely due to manually instantiating an Ember.View. See: http://git.io/EKPpnA") -return e.lookup("template:"+t)||e.lookup("template:"+r)}},Ci=function(e){var t=e.split("/"),r=t[t.length-1] -return t[t.length-1]="_"+r,t.join("/")}) -var Fi={if:function(e,{positional:t}){return 3!==t.length&&2!==t.length&&(0,c.assert)('The inline form of the `if` helper expects two or three arguments, e.g. `{{if trialExpired "Expired" expiryDate}}`.',3===t.length||2===t.length),Hr.create(t.at(0),t.at(1),t.at(2))},action:function(e,t){var r,{named:i,positional:n}=t,s=n.capture(),[a,o,...c]=s.references,d=o.propertyKey,h=i.has("target")?i.get("target"):a,p=function(e,t){var r,i +return null===i&&null===s?null:{component:i,layout:s}}v.PARTIALS&&(Sr=function(e,t){if((0,l.deprecate)(`The use of \`{{partial}}\` is deprecated, please refactor the "${e}" partial to a component`,!1,{id:"ember-views.partial",until:"4.0.0",url:"https://deprecations.emberjs.com/v3.x#toc_ember-views-partial"}),null!==e){var r=Cr(t,Pr(e),e) +return!Boolean(r)&&(0,l.assert)(`Unable to find partial with name "${e}"`,Boolean(r)),r}},Cr=function(e,t,r){if(v.PARTIALS){if(!r)return +if(-1!==r.indexOf(".")&&(0,l.assert)(`templateNames are not allowed to contain periods: ${r}`,-1===r.indexOf(".")),!e)throw new A.default("Container was not found when looking up a views template. This is most likely due to manually instantiating an Ember.View. See: http://git.io/EKPpnA") +return e.lookup(`template:${t}`)||e.lookup(`template:${r}`)}},Pr=function(e){var t=e.split("/"),r=t[t.length-1] +return t[t.length-1]=`_${r}`,t.join("/")}) +var Lr={if:function(e,t){return new u.HelperRootReference(qt,e.capture(),t.env)},action:function(e,t){var r,{named:n,positional:s}=e,a=s.capture(),[o,l,...u]=a.references,c=l.propertyKey,h=n.has("target")?n.get("target"):o,p=function(e,t){var r,n t.length>0&&(r=e=>t.map(e=>e.value()).concat(e)) -e&&(i=t=>{var r=e.value() -return r&&t.length>0&&(t[0]=(0,u.get)(t[0],r)),t}) -return r&&i?e=>i(r(e)):r||i||xr}(i.has("value")&&i.get("value"),c) -return(r="function"==typeof o[Q]?jr(o,o,o[Q],p,d):(0,l.isConst)(h)&&(0,l.isConst)(o)?jr(a.value(),h.value(),o.value(),p,d):function(e,t,r,i,n){jr(e,t.value(),r.value(),i,n) -return(...s)=>jr(e,t.value(),r.value(),i,n)(...s)}(a.value(),h,o,p,d))[$]=!0,new le(r)},array:function(e,t){return t.positional.capture()},concat:function(e,t){return new oe(Ir,t.capture())},fn:function(e,t){return new oe(zr,t.capture())},get:function(e,t){return Ur.create(t.positional.at(0),t.positional.at(1))},hash:function(e,t){return t.named.capture()},log:function(e,t){return new oe(Vr,t.capture())},mut:function(e,t){var r,i=t.positional.at(0) -if((r=i)&&r[qr])return i -!i[W]&&(0,c.assert)("You can only pass a path to mut",i[W]) -var n=Object.create(i) -return n[Yr]=i,n[Q]=i[W],n[qr]=!0,n},"query-params":function(e,t){return new oe(Gr,t.capture())},readonly:function(e,t){var r=function(e){return e[Yr]||e}(t.positional.at(0)) -return new ue(r)},unbound:function(e,t){return(1!==t.positional.length||0!==t.named.length)&&(0,c.assert)("unbound helper cannot be called with multiple params or hash params",1===t.positional.length&&0===t.named.length),le.create(t.positional.at(0).value())},unless:function(e,{positional:t}){return 3!==t.length&&2!==t.length&&(0,c.assert)('The inline form of the `unless` helper expects two or three arguments, e.g. `{{unless isFirstLogin "Welcome back!"}}`.',3===t.length||2===t.length),Hr.create(t.at(0),t.at(2),t.at(1))},"-class":function(e,t){return new oe(Mr,t.capture())},"-each-in":function(e,t){return new De(t.positional.at(0))},"-input-type":function(e,t){return new oe(kr,t.capture())},"-normalize-class":function(e,t){return new oe(Dr,t.capture())},"-get-dynamic-var":d.getDynamicVar,"-mount":function(e,t){var r=e.env,i=t.positional.at(0),n=null -if(t.named.has("model")){1!==t.named.length&&(0,c.assert)("[BUG] this should already be checked by the macro",1===t.named.length) -var s=t.named.capture(),{tag:a}=s -0,n={tag:a,positional:d.EMPTY_ARGS.positional,named:s,length:1,value(){return{named:this.named.value(),positional:this.positional.value()}}}}return new gi(i,r,n)},"-outlet":function(e,t){var r,i=e.dynamicScope() -return r=0===t.positional.length?new l.ConstReference("main"):t.positional.at(0),new Ri(new yi(i.outletState,r),e.env)},"-assert-implicit-component-helper-argument":Cr} -class Li{constructor(e){this.handles=[void 0],this.objToHandle=new WeakMap,this.builtInHelpers=Fi,this.componentDefinitionCache=new Map,this.componentDefinitionCount=0,this.helperDefinitionCount=0 -var t=new n.Macros;(function(e){var{inlines:t,blocks:r}=e -t.add("outlet",_i),t.add("mount",fi),t.addMissing(Ai),r.add("let",di),r.addMissing(wi) -for(var i=0;i` (did you mean `