ha-supervisor/supervisor/api/panel/chunk.9d371c8143226d4eaaee....

1 line
46 KiB
Plaintext

{"version":3,"sources":["webpack:///./src/data/auth.ts","webpack:///./hassio/src/dialogs/snapshot/dialog-hassio-snapshot.ts","webpack:///./node_modules/@polymer/paper-dialog-behavior/paper-dialog-behavior.js","webpack:///./node_modules/@polymer/paper-dialog-scrollable/paper-dialog-scrollable.js","webpack:///./node_modules/@polymer/paper-dialog-behavior/paper-dialog-shared-styles.js","webpack:///./node_modules/@polymer/paper-dialog/paper-dialog.js","webpack:///./src/components/dialog/ha-iron-focusables-helper.js","webpack:///./src/components/dialog/ha-paper-dialog.ts"],"names":["concat","location","protocol","host","customElement","property","query","params","regeneratorRuntime","async","_context","prev","next","awrap","fetchHassioSnapshotInfo","this","hass","slug","snapshot","sent","_folders","folders","list","includes","push","name","checked","sort","a","b","_addons","addons","map","addon","version","_dialogParams","_dialog","open","t0","showDialog","stop","_this2","html","_templateObject2","_dialogClosed","_computeName","type","_computeSize","_formatDatetime","date","_restoreHass","ev","target","homeassistant","length","_templateObject3","item","_templateObject4","_updateFolders","_templateObject5","_templateObject6","_updateAddons","_templateObject7","_passwordInput","_snapshotPassword","_error","_templateObject8","_downloadClicked","_partialRestoreClicked","_templateObject9","_fullRestoreClicked","_deleteClicked","_templateObject","haStyleDialog","css","_templateObject10","value","folder","detail","_this3","confirm","filter","data","password","callApi","then","alert","close","error","body","message","_this4","undefined","_this5","onDelete","signedPath","_context2","path","callWS","abrupt","replace","document","createElement","href","download","appendChild","click","removeChild","Math","ceil","size","datetime","Date","toLocaleDateString","navigator","language","weekday","year","month","day","hour","minute","LitElement","__webpack_require__","d","__webpack_exports__","PaperDialogBehaviorImpl","PaperDialogBehavior","_polymer_iron_overlay_behavior_iron_overlay_behavior_js__WEBPACK_IMPORTED_MODULE_1__","_polymer_polymer_lib_legacy_polymer_dom_js__WEBPACK_IMPORTED_MODULE_2__","hostAttributes","role","tabindex","properties","modal","Boolean","__readied","observers","listeners","tap","ready","__prevNoCancelOnOutsideClick","noCancelOnOutsideClick","__prevNoCancelOnEscKey","noCancelOnEscKey","__prevWithBackdrop","withBackdrop","_modalChanged","readied","_updateClosingReasonConfirmed","confirmed","closingReason","_onDialogClick","event","dom","i","l","indexOf","hasAttribute","stopPropagation","IronOverlayBehavior","Polymer","_template","is","dialogElement","Object","scrollTarget","$","scrollable","_ensureTarget","classList","add","attached","requestAnimationFrame","updateScrollState","bind","toggleClass","scrollTop","offsetHeight","scrollHeight","parentElement","behaviors","sizingTarget","remove","$_documentContainer","setAttribute","innerHTML","head","content","NeonAnimationRunnerBehavior","neon-animation-finish","_renderOpened","cancelAnimation","playAnimation","_renderClosed","_onNeonAnimationFinish","opened","_finishRenderOpened","_finishRenderClosed","HaIronFocusablesHelper","getTabbableNodes","node","result","_collectTabbableNodes","IronFocusablesHelper","_sortByTabIndex","nodeType","Node","ELEMENT_NODE","_isVisible","children","element","tabIndex","_normalizedTabIndex","needsSort","localName","getDistributedNodes","shadowRoot","root","paperDialogClass","customElements","get","haTabFixBehaviorImpl","_focusableNodes","HaPaperDialog","_mixinBehaviors","_classCallCheck","_possibleConstructorReturn","_getPrototypeOf","apply","arguments","_inherits","mixinBehaviors","define"],"mappings":";wJAgBoB,GAAAA,OAAMC,SAASC,SAAf,MAAAF,OAA4BC,SAASE,wyYC0DxDC,YAAc,2oBAEZC,kEACAA,oEACAA,sEACAA,sEACAA,qEACAA,2EACAA,+EACAA,0DAA8D,8BAC9DC,YAAM,8EAEP,SAAwBC,GAAxB,OAAAC,mBAAAC,MAAA,SAAAC,GAAA,cAAAA,EAAAC,KAAAD,EAAAE,MAAA,cAAAF,EAAAE,KAAA,EAAAJ,mBAAAK,MACwBC,YAAwBC,KAAKC,KAAMT,EAAOU,OADlE,OACEF,KAAKG,SADPR,EAAAS,KAEEJ,KAAKK,UAzDgBC,EA0DnBN,KAAKG,SAASG,QAzDZC,WAAgE,GAClED,EAAQE,SAAS,kBACnBD,EAAKE,KAAK,CACRP,KAAM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EAET,IAoBIS,EApBAC,EAAuCV,EACvCW,EAAWR,IAAqBS,oBAAoBF,GACpDG,EAAYF,EAAW,EACvBA,GAAY,GACdV,EAAOlL,KAAK2L,GAkBZD,EADwB,YAAtBC,EAAQI,WAAiD,SAAtBJ,EAAQI,UAClC7D,YAAIyD,GAASK,sBAKb9D,YAAIyD,EAAQM,YAAcN,EAAQO,MAAQP,GAASD,SAGhE,IAAK,IAAIvD,EAAI,EAAGA,EAAIuD,EAAS5J,OAAQqG,IAEnC2D,EAAYvM,KAAK4L,sBAAsBO,EAASvD,GAAI+C,IAAWY,EAEjE,OAAOA,qoBCjFX,IAAMK,EAAmBC,eAAeC,IAAI,gBAGtCC,EAAuB,CAC3BC,sBACE,OAAOxB,EAAuBC,iBAAiBzL,QAOtCiN,EAAb,SAAAC,GAAA,SAAAD,IAAA,mGAAAE,CAAAnN,KAAAiN,GAAAG,EAAApN,KAAAqN,EAAAJ,GAAAK,MAAAtN,KAAAuN,YAAA,yOAAAC,CAAAP,EACUQ,eAAe,CAACV,GAAuBH,IADjDK,EAAA,GASAJ,eAAea,OAAO,kBAAmBT","file":"chunk.9d371c8143226d4eaaee.js","sourcesContent":["import { HomeAssistant } from \"../types\";\n\nexport interface AuthProvider {\n name: string;\n id: string;\n type: string;\n}\n\nexport interface Credential {\n type: string;\n}\n\nexport interface SignedPath {\n path: string;\n}\n\nexport const hassUrl = `${location.protocol}//${location.host}`;\n\nexport const getSignedPath = (\n hass: HomeAssistant,\n path: string\n): Promise<SignedPath> => hass.callWS({ type: \"auth/sign_path\", path });\n\nexport const fetchAuthProviders = () =>\n fetch(\"/auth/providers\", {\n credentials: \"same-origin\",\n });\n","import \"@material/mwc-button\";\nimport \"@polymer/app-layout/app-toolbar/app-toolbar\";\nimport \"@polymer/iron-icon/iron-icon\";\nimport \"@polymer/paper-dialog-scrollable/paper-dialog-scrollable\";\nimport \"@polymer/paper-icon-button/paper-icon-button\";\nimport \"@polymer/paper-input/paper-input\";\nimport { PaperDialogElement } from \"@polymer/paper-dialog\";\nimport { PaperCheckboxElement } from \"@polymer/paper-checkbox/paper-checkbox\";\nimport {\n css,\n CSSResult,\n customElement,\n html,\n LitElement,\n property,\n TemplateResult,\n query,\n} from \"lit-element\";\n\nimport {\n fetchHassioSnapshotInfo,\n HassioSnapshotDetail,\n} from \"../../../../src/data/hassio/snapshot\";\nimport { getSignedPath } from \"../../../../src/data/auth\";\nimport { HassioSnapshotDialogParams } from \"./show-dialog-hassio-snapshot\";\nimport { haStyleDialog } from \"../../../../src/resources/styles\";\nimport { HomeAssistant } from \"../../../../src/types\";\nimport { PolymerChangedEvent } from \"../../../../src/polymer-types\";\n\nimport \"../../../../src/components/dialog/ha-paper-dialog\";\n\nconst _computeFolders = (folders) => {\n const list: Array<{ slug: string; name: string; checked: boolean }> = [];\n if (folders.includes(\"homeassistant\")) {\n list.push({\n slug: \"homeassistant\",\n name: \"Home Assistant configuration\",\n checked: true,\n });\n }\n if (folders.includes(\"ssl\")) {\n list.push({ slug: \"ssl\", name: \"SSL\", checked: true });\n }\n if (folders.includes(\"share\")) {\n list.push({ slug: \"share\", name: \"Share\", checked: true });\n }\n if (folders.includes(\"addons/local\")) {\n list.push({ slug: \"addons/local\", name: \"Local add-ons\", checked: true });\n }\n return list;\n};\n\nconst _computeAddons = (addons) => {\n return addons.map((addon) => ({\n slug: addon.slug,\n name: addon.name,\n version: addon.version,\n checked: true,\n }));\n};\n\ninterface AddonItem {\n slug: string;\n name: string;\n version: string;\n checked: boolean | null | undefined;\n}\n\ninterface FolderItem {\n slug: string;\n name: string;\n checked: boolean | null | undefined;\n}\n\n@customElement(\"dialog-hassio-snapshot\")\nclass HassioSnapshotDialog extends LitElement {\n @property() public hass!: HomeAssistant;\n @property() private _error?: string;\n @property() private snapshot?: HassioSnapshotDetail;\n @property() private _folders!: FolderItem[];\n @property() private _addons!: AddonItem[];\n @property() private _dialogParams?: HassioSnapshotDialogParams;\n @property() private _snapshotPassword!: string;\n @property() private _restoreHass: boolean | null | undefined = true;\n @query(\"#dialog\") private _dialog!: PaperDialogElement;\n\n public async showDialog(params: HassioSnapshotDialogParams) {\n this.snapshot = await fetchHassioSnapshotInfo(this.hass, params.slug);\n this._folders = _computeFolders(\n this.snapshot.folders\n ).sort((a: FolderItem, b: FolderItem) => (a.name > b.name ? 1 : -1));\n this._addons = _computeAddons(\n this.snapshot.addons\n ).sort((a: AddonItem, b: AddonItem) => (a.name > b.name ? 1 : -1));\n\n this._dialogParams = params;\n\n try {\n this._dialog.open();\n } catch {\n await this.showDialog(params);\n }\n }\n\n protected render(): TemplateResult {\n if (!this.snapshot) {\n return html``;\n }\n return html`\n <ha-paper-dialog\n id=\"dialog\"\n with-backdrop=\"\"\n .on-iron-overlay-closed=${this._dialogClosed}\n >\n <app-toolbar>\n <paper-icon-button\n icon=\"hassio:close\"\n dialog-dismiss=\"\"\n ></paper-icon-button>\n <div main-title=\"\">${this._computeName}</div>\n </app-toolbar>\n <div class=\"details\">\n ${this.snapshot.type === \"full\"\n ? \"Full snapshot\"\n : \"Partial snapshot\"}\n (${this._computeSize})<br />\n ${this._formatDatetime(this.snapshot.date)}\n </div>\n <div>Home Assistant:</div>\n <paper-checkbox\n .checked=${this._restoreHass}\n @change=\"${(ev: Event) =>\n (this._restoreHass = (ev.target as PaperCheckboxElement).checked)}\"\n >\n Home Assistant ${this.snapshot.homeassistant}\n </paper-checkbox>\n ${this._folders.length\n ? html`\n <div>Folders:</div>\n <paper-dialog-scrollable class=\"no-margin-top\">\n ${this._folders.map((item) => {\n return html`\n <paper-checkbox\n .checked=${item.checked}\n @change=\"${(ev: Event) =>\n this._updateFolders(\n item,\n (ev.target as PaperCheckboxElement).checked\n )}\"\n >\n ${item.name}\n </paper-checkbox>\n `;\n })}\n </paper-dialog-scrollable>\n `\n : \"\"}\n ${this._addons.length\n ? html`\n <div>Add-on:</div>\n <paper-dialog-scrollable class=\"no-margin-top\">\n ${this._addons.map((item) => {\n return html`\n <paper-checkbox\n .checked=${item.checked}\n @change=\"${(ev: Event) =>\n this._updateAddons(\n item,\n (ev.target as PaperCheckboxElement).checked\n )}\"\n >\n ${item.name}\n </paper-checkbox>\n `;\n })}\n </paper-dialog-scrollable>\n `\n : \"\"}\n ${this.snapshot.protected\n ? html`\n <paper-input\n autofocus=\"\"\n label=\"Password\"\n type=\"password\"\n @value-changed=${this._passwordInput}\n .value=${this._snapshotPassword}\n ></paper-input>\n `\n : \"\"}\n ${this._error\n ? html`\n <p class=\"error\">Error: ${this._error}</p>\n `\n : \"\"}\n\n <div>Actions:</div>\n <ul class=\"buttons\">\n <li>\n <mwc-button @click=${this._downloadClicked}>\n <iron-icon icon=\"hassio:download\" class=\"icon\"></iron-icon>\n Download Snapshot\n </mwc-button>\n </li>\n <li>\n <mwc-button @click=${this._partialRestoreClicked}>\n <iron-icon icon=\"hassio:history\" class=\"icon\"> </iron-icon>\n Restore Selected\n </mwc-button>\n </li>\n ${this.snapshot.type === \"full\"\n ? html`\n <li>\n <mwc-button @click=${this._fullRestoreClicked}>\n <iron-icon icon=\"hassio:history\" class=\"icon\"> </iron-icon>\n Wipe &amp; restore\n </mwc-button>\n </li>\n `\n : \"\"}\n <li>\n <mwc-button @click=${this._deleteClicked}>\n <iron-icon icon=\"hassio:delete\" class=\"icon warning\"> </iron-icon>\n <span class=\"warning\">Delete Snapshot</span>\n </mwc-button>\n </li>\n </ul>\n </ha-paper-dialog>\n `;\n }\n\n static get styles(): CSSResult[] {\n return [\n haStyleDialog,\n css`\n ha-paper-dialog {\n min-width: 350px;\n font-size: 14px;\n border-radius: 2px;\n }\n app-toolbar {\n margin: 0;\n padding: 0 16px;\n color: var(--primary-text-color);\n background-color: var(--secondary-background-color);\n }\n app-toolbar [main-title] {\n margin-left: 16px;\n }\n ha-paper-dialog-scrollable {\n margin: 0;\n }\n paper-checkbox {\n display: block;\n margin: 4px;\n }\n @media all and (max-width: 450px), all and (max-height: 500px) {\n ha-paper-dialog {\n max-height: 100%;\n height: 100%;\n }\n app-toolbar {\n color: var(--text-primary-color);\n background-color: var(--primary-color);\n }\n }\n .details {\n color: var(--secondary-text-color);\n }\n .warning,\n .error {\n color: var(--google-red-500);\n }\n .buttons {\n display: flex;\n flex-direction: column;\n }\n .buttons li {\n list-style-type: none;\n }\n .buttons .icon {\n margin-right: 16px;\n }\n .no-margin-top {\n margin-top: 0;\n }\n `,\n ];\n }\n\n private _updateFolders(item: FolderItem, value: boolean | null | undefined) {\n this._folders = this._folders.map((folder) => {\n if (folder.slug === item.slug) {\n folder.checked = value;\n }\n return folder;\n });\n }\n\n private _updateAddons(item: AddonItem, value: boolean | null | undefined) {\n this._addons = this._addons.map((addon) => {\n if (addon.slug === item.slug) {\n addon.checked = value;\n }\n return addon;\n });\n }\n\n private _passwordInput(ev: PolymerChangedEvent<string>) {\n this._snapshotPassword = ev.detail.value;\n }\n\n private _partialRestoreClicked() {\n if (!confirm(\"Are you sure you want to restore this snapshot?\")) {\n return;\n }\n\n const addons = this._addons\n .filter((addon) => addon.checked)\n .map((addon) => addon.slug);\n\n const folders = this._folders\n .filter((folder) => folder.checked)\n .map((folder) => folder.slug);\n\n const data: {\n homeassistant: boolean | null | undefined;\n addons: any;\n folders: any;\n password?: string;\n } = {\n homeassistant: this._restoreHass,\n addons,\n folders,\n };\n\n if (this.snapshot!.protected) {\n data.password = this._snapshotPassword;\n }\n\n this.hass\n .callApi(\n \"POST\",\n\n `hassio/snapshots/${this.snapshot!.slug}/restore/partial`,\n data\n )\n .then(\n () => {\n alert(\"Snapshot restored!\");\n this._dialog.close();\n },\n (error) => {\n this._error = error.body.message;\n }\n );\n }\n\n private _fullRestoreClicked() {\n if (!confirm(\"Are you sure you want to restore this snapshot?\")) {\n return;\n }\n\n const data = this.snapshot!.protected\n ? { password: this._snapshotPassword }\n : undefined;\n\n this.hass\n .callApi(\n \"POST\",\n `hassio/snapshots/${this.snapshot!.slug}/restore/full`,\n data\n )\n .then(\n () => {\n alert(\"Snapshot restored!\");\n this._dialog.close();\n },\n (error) => {\n this._error = error.body.message;\n }\n );\n }\n\n private _deleteClicked() {\n if (!confirm(\"Are you sure you want to delete this snapshot?\")) {\n return;\n }\n\n this.hass\n\n .callApi(\"POST\", `hassio/snapshots/${this.snapshot!.slug}/remove`)\n .then(\n () => {\n this._dialog.close();\n this._dialogParams!.onDelete();\n },\n (error) => {\n this._error = error.body.message;\n }\n );\n }\n\n private async _downloadClicked() {\n let signedPath: { path: string };\n try {\n signedPath = await getSignedPath(\n this.hass,\n `/api/hassio/snapshots/${this.snapshot!.slug}/download`\n );\n } catch (err) {\n alert(`Error: ${err.message}`);\n return;\n }\n\n const name = this._computeName.replace(/[^a-z0-9]+/gi, \"_\");\n const a = document.createElement(\"a\");\n a.href = signedPath.path;\n a.download = `Hass_io_${name}.tar`;\n this._dialog.appendChild(a);\n a.click();\n this._dialog.removeChild(a);\n }\n\n private get _computeName() {\n return this.snapshot\n ? this.snapshot.name || this.snapshot.slug\n : \"Unnamed snapshot\";\n }\n\n private get _computeSize() {\n return Math.ceil(this.snapshot!.size * 10) / 10 + \" MB\";\n }\n\n private _formatDatetime(datetime) {\n return new Date(datetime).toLocaleDateString(navigator.language, {\n weekday: \"long\",\n year: \"numeric\",\n month: \"short\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n });\n }\n\n private _dialogClosed() {\n this._dialogParams = undefined;\n this.snapshot = undefined;\n this._snapshotPassword = \"\";\n this._folders = [];\n this._addons = [];\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"dialog-hassio-snapshot\": HassioSnapshotDialog;\n }\n}\n","/**\n@license\nCopyright (c) 2015 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at\nhttp://polymer.github.io/LICENSE.txt The complete set of authors may be found at\nhttp://polymer.github.io/AUTHORS.txt The complete set of contributors may be\nfound at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as\npart of the polymer project is also subject to an additional IP rights grant\nfound at http://polymer.github.io/PATENTS.txt\n*/\nimport '@polymer/polymer/polymer-legacy.js';\n\nimport {IronOverlayBehavior} from '@polymer/iron-overlay-behavior/iron-overlay-behavior.js';\nimport {dom} from '@polymer/polymer/lib/legacy/polymer.dom.js';\n\n/**\n Use `Polymer.PaperDialogBehavior` and `paper-dialog-shared-styles.html` to\n implement a Material Design dialog.\n\n For example, if `<paper-dialog-impl>` implements this behavior:\n\n <paper-dialog-impl>\n <h2>Header</h2>\n <div>Dialog body</div>\n <div class=\"buttons\">\n <paper-button dialog-dismiss>Cancel</paper-button>\n <paper-button dialog-confirm>Accept</paper-button>\n </div>\n </paper-dialog-impl>\n\n `paper-dialog-shared-styles.html` provide styles for a header, content area,\n and an action area for buttons. Use the `<h2>` tag for the header and the\n `buttons` class for the action area. You can use the `paper-dialog-scrollable`\n element (in its own repository) if you need a scrolling content area.\n\n Use the `dialog-dismiss` and `dialog-confirm` attributes on interactive\n controls to close the dialog. If the user dismisses the dialog with\n `dialog-confirm`, the `closingReason` will update to include `confirmed:\n true`.\n\n ### Accessibility\n\n This element has `role=\"dialog\"` by default. Depending on the context, it may\n be more appropriate to override this attribute with `role=\"alertdialog\"`.\n\n If `modal` is set, the element will prevent the focus from exiting the\n element. It will also ensure that focus remains in the dialog.\n\n @hero hero.svg\n @demo demo/index.html\n @polymerBehavior PaperDialogBehavior\n */\nexport const PaperDialogBehaviorImpl = {\n\n hostAttributes: {'role': 'dialog', 'tabindex': '-1'},\n\n properties: {\n\n /**\n * If `modal` is true, this implies `no-cancel-on-outside-click`,\n * `no-cancel-on-esc-key` and `with-backdrop`.\n */\n modal: {type: Boolean, value: false},\n\n __readied: {type: Boolean, value: false}\n\n },\n\n observers: ['_modalChanged(modal, __readied)'],\n\n listeners: {'tap': '_onDialogClick'},\n\n /**\n * @return {void}\n */\n ready: function() {\n // Only now these properties can be read.\n this.__prevNoCancelOnOutsideClick = this.noCancelOnOutsideClick;\n this.__prevNoCancelOnEscKey = this.noCancelOnEscKey;\n this.__prevWithBackdrop = this.withBackdrop;\n this.__readied = true;\n },\n\n _modalChanged: function(modal, readied) {\n // modal implies noCancelOnOutsideClick, noCancelOnEscKey and withBackdrop.\n // We need to wait for the element to be ready before we can read the\n // properties values.\n if (!readied) {\n return;\n }\n\n if (modal) {\n this.__prevNoCancelOnOutsideClick = this.noCancelOnOutsideClick;\n this.__prevNoCancelOnEscKey = this.noCancelOnEscKey;\n this.__prevWithBackdrop = this.withBackdrop;\n this.noCancelOnOutsideClick = true;\n this.noCancelOnEscKey = true;\n this.withBackdrop = true;\n } else {\n // If the value was changed to false, let it false.\n this.noCancelOnOutsideClick =\n this.noCancelOnOutsideClick && this.__prevNoCancelOnOutsideClick;\n this.noCancelOnEscKey =\n this.noCancelOnEscKey && this.__prevNoCancelOnEscKey;\n this.withBackdrop = this.withBackdrop && this.__prevWithBackdrop;\n }\n },\n\n _updateClosingReasonConfirmed: function(confirmed) {\n this.closingReason = this.closingReason || {};\n this.closingReason.confirmed = confirmed;\n },\n\n /**\n * Will dismiss the dialog if user clicked on an element with dialog-dismiss\n * or dialog-confirm attribute.\n */\n _onDialogClick: function(event) {\n // Search for the element with dialog-confirm or dialog-dismiss,\n // from the root target until this (excluded).\n var path = dom(event).path;\n for (var i = 0, l = path.indexOf(this); i < l; i++) {\n var target = path[i];\n if (target.hasAttribute &&\n (target.hasAttribute('dialog-dismiss') ||\n target.hasAttribute('dialog-confirm'))) {\n this._updateClosingReasonConfirmed(\n target.hasAttribute('dialog-confirm'));\n this.close();\n event.stopPropagation();\n break;\n }\n }\n }\n\n};\n\n/** @polymerBehavior */\nexport const PaperDialogBehavior =\n [IronOverlayBehavior, PaperDialogBehaviorImpl];\n","/**\n@license\nCopyright (c) 2015 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at\nhttp://polymer.github.io/LICENSE.txt The complete set of authors may be found at\nhttp://polymer.github.io/AUTHORS.txt The complete set of contributors may be\nfound at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as\npart of the polymer project is also subject to an additional IP rights grant\nfound at http://polymer.github.io/PATENTS.txt\n*/\nimport '@polymer/polymer/polymer-legacy.js';\nimport '@polymer/iron-flex-layout/iron-flex-layout.js';\nimport '@polymer/paper-styles/default-theme.js';\n\nimport {PaperDialogBehaviorImpl} from '@polymer/paper-dialog-behavior/paper-dialog-behavior.js';\nimport {Polymer} from '@polymer/polymer/lib/legacy/polymer-fn.js';\nimport {html} from '@polymer/polymer/lib/utils/html-tag.js';\n\n/**\nMaterial design:\n[Dialogs](https://www.google.com/design/spec/components/dialogs.html)\n\n`paper-dialog-scrollable` implements a scrolling area used in a Material Design\ndialog. It shows a divider at the top and/or bottom indicating more content,\ndepending on scroll position. Use this together with elements implementing\n`Polymer.PaperDialogBehavior`.\n\n <paper-dialog-impl>\n <h2>Header</h2>\n <paper-dialog-scrollable>\n Lorem ipsum...\n </paper-dialog-scrollable>\n <div class=\"buttons\">\n <paper-button>OK</paper-button>\n </div>\n </paper-dialog-impl>\n\nIt shows a top divider after scrolling if it is not the first child in its\nparent container, indicating there is more content above. It shows a bottom\ndivider if it is scrollable and it is not the last child in its parent\ncontainer, indicating there is more content below. The bottom divider is hidden\nif it is scrolled to the bottom.\n\nIf `paper-dialog-scrollable` is not a direct child of the element implementing\n`Polymer.PaperDialogBehavior`, remember to set the `dialogElement`:\n\n <paper-dialog-impl id=\"myDialog\">\n <h2>Header</h2>\n <div class=\"my-content-wrapper\">\n <h4>Sub-header</h4>\n <paper-dialog-scrollable>\n Lorem ipsum...\n </paper-dialog-scrollable>\n </div>\n <div class=\"buttons\">\n <paper-button>OK</paper-button>\n </div>\n </paper-dialog-impl>\n\n <script>\n var scrollable =\nPolymer.dom(myDialog).querySelector('paper-dialog-scrollable');\n scrollable.dialogElement = myDialog;\n </script>\n\n### Styling\nThe following custom properties and mixins are available for styling:\n\nCustom property | Description | Default\n----------------|-------------|----------\n`--paper-dialog-scrollable` | Mixin for the scrollable content | {}\n\n@group Paper Elements\n@element paper-dialog-scrollable\n@demo demo/index.html\n@hero hero.svg\n*/\nPolymer({\n _template: html`\n <style>\n\n :host {\n display: block;\n @apply --layout-relative;\n }\n\n :host(.is-scrolled:not(:first-child))::before {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n right: 0;\n height: 1px;\n background: var(--divider-color);\n }\n\n :host(.can-scroll:not(.scrolled-to-bottom):not(:last-child))::after {\n content: '';\n position: absolute;\n bottom: 0;\n left: 0;\n right: 0;\n height: 1px;\n background: var(--divider-color);\n }\n\n .scrollable {\n padding: 0 24px;\n\n @apply --layout-scroll;\n @apply --paper-dialog-scrollable;\n }\n\n .fit {\n @apply --layout-fit;\n }\n </style>\n\n <div id=\"scrollable\" class=\"scrollable\" on-scroll=\"updateScrollState\">\n <slot></slot>\n </div>\n`,\n\n is: 'paper-dialog-scrollable',\n\n properties: {\n\n /**\n * The dialog element that implements `Polymer.PaperDialogBehavior`\n * containing this element.\n * @type {?Node}\n */\n dialogElement: {type: Object}\n\n },\n\n /**\n * Returns the scrolling element.\n */\n get scrollTarget() {\n return this.$.scrollable;\n },\n\n ready: function() {\n this._ensureTarget();\n this.classList.add('no-padding');\n },\n\n attached: function() {\n this._ensureTarget();\n requestAnimationFrame(this.updateScrollState.bind(this));\n },\n\n updateScrollState: function() {\n this.toggleClass('is-scrolled', this.scrollTarget.scrollTop > 0);\n this.toggleClass(\n 'can-scroll',\n this.scrollTarget.offsetHeight < this.scrollTarget.scrollHeight);\n this.toggleClass(\n 'scrolled-to-bottom',\n this.scrollTarget.scrollTop + this.scrollTarget.offsetHeight >=\n this.scrollTarget.scrollHeight);\n },\n\n _ensureTarget: function() {\n // Read parentElement instead of parentNode in order to skip shadowRoots.\n this.dialogElement = this.dialogElement || this.parentElement;\n // Check if dialog implements paper-dialog-behavior. If not, fit\n // scrollTarget to host.\n if (this.dialogElement && this.dialogElement.behaviors &&\n this.dialogElement.behaviors.indexOf(PaperDialogBehaviorImpl) >= 0) {\n this.dialogElement.sizingTarget = this.scrollTarget;\n this.scrollTarget.classList.remove('fit');\n } else if (this.dialogElement) {\n this.scrollTarget.classList.add('fit');\n }\n }\n});\n","/**\n@license\nCopyright (c) 2015 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at\nhttp://polymer.github.io/LICENSE.txt The complete set of authors may be found at\nhttp://polymer.github.io/AUTHORS.txt The complete set of contributors may be\nfound at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as\npart of the polymer project is also subject to an additional IP rights grant\nfound at http://polymer.github.io/PATENTS.txt\n*/\n/*\n### Styling\n\nThe following custom properties and mixins are available for styling.\n\nCustom property | Description | Default\n----------------|-------------|----------\n`--paper-dialog-background-color` | Dialog background color | `--primary-background-color`\n`--paper-dialog-color` | Dialog foreground color | `--primary-text-color`\n`--paper-dialog` | Mixin applied to the dialog | `{}`\n`--paper-dialog-title` | Mixin applied to the title (`<h2>`) element | `{}`\n`--paper-dialog-button-color` | Button area foreground color | `--default-primary-color`\n*/\nimport '@polymer/polymer/polymer-legacy.js';\nimport '@polymer/iron-flex-layout/iron-flex-layout.js';\nimport '@polymer/paper-styles/default-theme.js';\nimport '@polymer/paper-styles/typography.js';\nimport '@polymer/paper-styles/shadow.js';\nconst $_documentContainer = document.createElement('template');\n$_documentContainer.setAttribute('style', 'display: none;');\n\n$_documentContainer.innerHTML = `<dom-module id=\"paper-dialog-shared-styles\">\n <template>\n <style>\n :host {\n display: block;\n margin: 24px 40px;\n\n background: var(--paper-dialog-background-color, var(--primary-background-color));\n color: var(--paper-dialog-color, var(--primary-text-color));\n\n @apply --paper-font-body1;\n @apply --shadow-elevation-16dp;\n @apply --paper-dialog;\n }\n\n :host > ::slotted(*) {\n margin-top: 20px;\n padding: 0 24px;\n }\n\n :host > ::slotted(.no-padding) {\n padding: 0;\n }\n\n \n :host > ::slotted(*:first-child) {\n margin-top: 24px;\n }\n\n :host > ::slotted(*:last-child) {\n margin-bottom: 24px;\n }\n\n /* In 1.x, this selector was \\`:host > ::content h2\\`. In 2.x <slot> allows\n to select direct children only, which increases the weight of this\n selector, so we have to re-define first-child/last-child margins below. */\n :host > ::slotted(h2) {\n position: relative;\n margin: 0;\n\n @apply --paper-font-title;\n @apply --paper-dialog-title;\n }\n\n /* Apply mixin again, in case it sets margin-top. */\n :host > ::slotted(h2:first-child) {\n margin-top: 24px;\n @apply --paper-dialog-title;\n }\n\n /* Apply mixin again, in case it sets margin-bottom. */\n :host > ::slotted(h2:last-child) {\n margin-bottom: 24px;\n @apply --paper-dialog-title;\n }\n\n :host > ::slotted(.paper-dialog-buttons),\n :host > ::slotted(.buttons) {\n position: relative;\n padding: 8px 8px 8px 24px;\n margin: 0;\n\n color: var(--paper-dialog-button-color, var(--primary-color));\n\n @apply --layout-horizontal;\n @apply --layout-end-justified;\n }\n </style>\n </template>\n</dom-module>`;\n\ndocument.head.appendChild($_documentContainer.content);\n","/**\n@license\nCopyright (c) 2015 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at\nhttp://polymer.github.io/LICENSE.txt The complete set of authors may be found at\nhttp://polymer.github.io/AUTHORS.txt The complete set of contributors may be\nfound at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as\npart of the polymer project is also subject to an additional IP rights grant\nfound at http://polymer.github.io/PATENTS.txt\n*/\nimport '@polymer/polymer/polymer-legacy.js';\nimport '@polymer/paper-dialog-behavior/paper-dialog-shared-styles.js';\n\nimport {NeonAnimationRunnerBehavior} from '@polymer/neon-animation/neon-animation-runner-behavior.js';\nimport {PaperDialogBehavior} from '@polymer/paper-dialog-behavior/paper-dialog-behavior.js';\nimport {Polymer} from '@polymer/polymer/lib/legacy/polymer-fn.js';\nimport {html} from '@polymer/polymer/lib/utils/html-tag.js';\n\n/**\nMaterial design:\n[Dialogs](https://www.google.com/design/spec/components/dialogs.html)\n\n`<paper-dialog>` is a dialog with Material Design styling and optional\nanimations when it is opened or closed. It provides styles for a header, content\narea, and an action area for buttons. You can use the\n`<paper-dialog-scrollable>` element (in its own repository) if you need a\nscrolling content area. To autofocus a specific child element after opening the\ndialog, give it the `autofocus` attribute. See `Polymer.PaperDialogBehavior` and\n`Polymer.IronOverlayBehavior` for specifics.\n\nFor example, the following code implements a dialog with a header, scrolling\ncontent area and buttons. Focus will be given to the `dialog-confirm` button\nwhen the dialog is opened.\n\n <paper-dialog>\n <h2>Header</h2>\n <paper-dialog-scrollable>\n Lorem ipsum...\n </paper-dialog-scrollable>\n <div class=\"buttons\">\n <paper-button dialog-dismiss>Cancel</paper-button>\n <paper-button dialog-confirm autofocus>Accept</paper-button>\n </div>\n </paper-dialog>\n\n### Styling\n\nSee the docs for `Polymer.PaperDialogBehavior` for the custom properties\navailable for styling this element.\n\n### Animations\n\nSet the `entry-animation` and/or `exit-animation` attributes to add an animation\nwhen the dialog is opened or closed. See the documentation in\n[PolymerElements/neon-animation](https://github.com/PolymerElements/neon-animation)\nfor more info.\n\nFor example:\n\n <script type=\"module\">\n import '@polymer/neon-animation/animations/fade-out-animation.js';\n import '@polymer/neon-animation/animations/scale-up-animation.js';\n </script>\n\n <paper-dialog entry-animation=\"scale-up-animation\"\n exit-animation=\"fade-out-animation\">\n <h2>Header</h2>\n <div>Dialog body</div>\n </paper-dialog>\n\n### Accessibility\n\nSee the docs for `Polymer.PaperDialogBehavior` for accessibility features\nimplemented by this element.\n\n@group Paper Elements\n@element paper-dialog\n@hero hero.svg\n@demo demo/index.html\n*/\nPolymer({\n _template: html`\n <style include=\"paper-dialog-shared-styles\"></style>\n <slot></slot>\n`,\n\n is: 'paper-dialog',\n behaviors: [PaperDialogBehavior, NeonAnimationRunnerBehavior],\n listeners: {'neon-animation-finish': '_onNeonAnimationFinish'},\n\n _renderOpened: function() {\n this.cancelAnimation();\n this.playAnimation('entry');\n },\n\n _renderClosed: function() {\n this.cancelAnimation();\n this.playAnimation('exit');\n },\n\n _onNeonAnimationFinish: function() {\n if (this.opened) {\n this._finishRenderOpened();\n } else {\n this._finishRenderClosed();\n }\n }\n});\n","/**\n@license\nCopyright (c) 2016 The Polymer Project Authors. All rights reserved.\nThis code may only be used under the BSD style license found at\nhttp://polymer.github.io/LICENSE.txt The complete set of authors may be found at\nhttp://polymer.github.io/AUTHORS.txt The complete set of contributors may be\nfound at http://polymer.github.io/CONTRIBUTORS.txt Code distributed by Google as\npart of the polymer project is also subject to an additional IP rights grant\nfound at http://polymer.github.io/PATENTS.txt\n*/\n/*\n Fixes issue with not using shadow dom properly in iron-overlay-behavior/icon-focusables-helper.js\n*/\nimport { dom } from \"@polymer/polymer/lib/legacy/polymer.dom.js\";\n\nimport { IronFocusablesHelper } from \"@polymer/iron-overlay-behavior/iron-focusables-helper.js\";\n\nexport const HaIronFocusablesHelper = {\n /**\n * Returns a sorted array of tabbable nodes, including the root node.\n * It searches the tabbable nodes in the light and shadow dom of the chidren,\n * sorting the result by tabindex.\n * @param {!Node} node\n * @return {!Array<!HTMLElement>}\n */\n getTabbableNodes: function(node) {\n var result = [];\n // If there is at least one element with tabindex > 0, we need to sort\n // the final array by tabindex.\n var needsSortByTabIndex = this._collectTabbableNodes(node, result);\n if (needsSortByTabIndex) {\n return IronFocusablesHelper._sortByTabIndex(result);\n }\n return result;\n },\n\n /**\n * Searches for nodes that are tabbable and adds them to the `result` array.\n * Returns if the `result` array needs to be sorted by tabindex.\n * @param {!Node} node The starting point for the search; added to `result`\n * if tabbable.\n * @param {!Array<!HTMLElement>} result\n * @return {boolean}\n * @private\n */\n _collectTabbableNodes: function(node, result) {\n // If not an element or not visible, no need to explore children.\n if (\n node.nodeType !== Node.ELEMENT_NODE ||\n !IronFocusablesHelper._isVisible(node)\n ) {\n return false;\n }\n var element = /** @type {!HTMLElement} */ (node);\n var tabIndex = IronFocusablesHelper._normalizedTabIndex(element);\n var needsSort = tabIndex > 0;\n if (tabIndex >= 0) {\n result.push(element);\n }\n\n // In ShadowDOM v1, tab order is affected by the order of distrubution.\n // E.g. getTabbableNodes(#root) in ShadowDOM v1 should return [#A, #B];\n // in ShadowDOM v0 tab order is not affected by the distrubution order,\n // in fact getTabbableNodes(#root) returns [#B, #A].\n // <div id=\"root\">\n // <!-- shadow -->\n // <slot name=\"a\">\n // <slot name=\"b\">\n // <!-- /shadow -->\n // <input id=\"A\" slot=\"a\">\n // <input id=\"B\" slot=\"b\" tabindex=\"1\">\n // </div>\n // TODO(valdrin) support ShadowDOM v1 when upgrading to Polymer v2.0.\n var children;\n if (element.localName === \"content\" || element.localName === \"slot\") {\n children = dom(element).getDistributedNodes();\n } else {\n // /////////////////////////\n // Use shadow root if possible, will check for distributed nodes.\n // THIS IS THE CHANGED LINE\n children = dom(element.shadowRoot || element.root || element).children;\n // /////////////////////////\n }\n for (var i = 0; i < children.length; i++) {\n // Ensure method is always invoked to collect tabbable children.\n needsSort = this._collectTabbableNodes(children[i], result) || needsSort;\n }\n return needsSort;\n },\n};\n","import \"@polymer/paper-dialog/paper-dialog\";\nimport { mixinBehaviors } from \"@polymer/polymer/lib/legacy/class\";\nimport { HaIronFocusablesHelper } from \"./ha-iron-focusables-helper.js\";\n// tslint:disable-next-line\nimport { PaperDialogElement } from \"@polymer/paper-dialog/paper-dialog\";\n\nconst paperDialogClass = customElements.get(\"paper-dialog\");\n\n// behavior that will override existing iron-overlay-behavior and call the fixed implementation\nconst haTabFixBehaviorImpl = {\n get _focusableNodes() {\n return HaIronFocusablesHelper.getTabbableNodes(this);\n },\n};\n\n// paper-dialog that uses the haTabFixBehaviorImpl behvaior\n// export class HaPaperDialog extends paperDialogClass {}\n// @ts-ignore\nexport class HaPaperDialog\n extends mixinBehaviors([haTabFixBehaviorImpl], paperDialogClass)\n implements PaperDialogElement {}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"ha-paper-dialog\": HaPaperDialog;\n }\n}\ncustomElements.define(\"ha-paper-dialog\", HaPaperDialog);\n"],"sourceRoot":""}