/**
@license
Copyright (c) 2017 The Polymer Project Authors. All rights reserved.
This code may only be used under the BSD style license found at http://polymer.github.io/LICENSE.txt
The complete set of authors may be found at http://polymer.github.io/AUTHORS.txt
The complete set of contributors may be found at http://polymer.github.io/CONTRIBUTORS.txt
Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/
import t from"./document-wait.js";export let CustomStyleProvider;const e="__seenByShadyCSS",o="__shadyCSSCachedStyle";let s=null,l=null;export default class CustomStyleInterface{constructor(){this.customStyles=[],this.enqueued=!1,t((()=>{window.ShadyCSS.flushCustomStyles&&window.ShadyCSS.flushCustomStyles()}))}enqueueDocumentValidation(){!this.enqueued&&l&&(this.enqueued=!0,t(l))}addCustomStyle(t){t[e]||(t[e]=!0,this.customStyles.push(t),this.enqueueDocumentValidation())}getStyleForCustomStyle(t){if(t[o])return t[o];let e;return e=t.getStyle?t.getStyle():t,e}processStyles(){const t=this.customStyles;for(let e=0;e<t.length;e++){const l=t[e];if(l[o])continue;const u=this.getStyleForCustomStyle(l);if(u){const t=u.__appliedElement||u;s&&s(t),l[o]=t}}return t}}CustomStyleInterface.prototype.addCustomStyle=CustomStyleInterface.prototype.addCustomStyle,CustomStyleInterface.prototype.getStyleForCustomStyle=CustomStyleInterface.prototype.getStyleForCustomStyle,CustomStyleInterface.prototype.processStyles=CustomStyleInterface.prototype.processStyles,Object.defineProperties(CustomStyleInterface.prototype,{transformCallback:{get:()=>s,set(t){s=t}},validateCallback:{get:()=>l,set(t){let e=!1;l||(e=!0),l=t,e&&this.enqueueDocumentValidation()}}});export const CustomStyleInterfaceInterface={};