import*as e from"../../legacy/theme_support/theme_support.js";import*as t from"../../lit/lit.js";import*as r from"../render_coordinator/render_coordinator.js";var o=Object.freeze({__proto__:null,setup:async function(){const t={get:()=>"default",addChangeListener:()=>{}};e.ThemeSupport.instance({forceNew:!0,setting:t})}});class n extends t.Directive.Directive{constructor(e){if(super(e),e.type!==t.Directive.PartType.ATTRIBUTE)throw new Error("Node rendered callback directive must be used as an attribute.")}update(e,[t]){t(e.element)}render(e){}}const a=t.Directive.directive(n);var d=Object.freeze({__proto__:null,nodeRenderedCallback:a});var c=Object.freeze({__proto__:null,getRootNode:function(e){const t=e.getRootNode();if(!(t instanceof Document||t instanceof ShadowRoot))throw new Error(`Expected root of widget to be a document or shadowRoot, but was "${t.nodeName}"`);return t}});const s=new WeakSet,i=new WeakSet,l=new WeakMap,u=new WeakMap;var p=Object.freeze({__proto__:null,isScheduledRender:function(e){return i.has(e)},scheduleRender:async function e(t,o){if(i.has(t))return void l.set(t,o);if(s.has(t))return;s.add(t);let n=u.get(o);if(n||(n=async()=>{s.delete(t),i.add(t);try{await o.call(t)}catch(e){throw console.error(`ScheduledRender: rendering ${t.nodeName.toLowerCase()}:`),console.error(e),e}finally{i.delete(t)}},u.set(o,n)),await r.write(n),l.has(t)){const r=l.get(t);if(l.delete(t),!r)return;e(t,r)}}});export{o as ComponentServerSetup,d as Directives,c as GetRootNode,p as ScheduledRender};
