import{noChange as t}from"../lit-html.js";import{isPrimitive as e}from"../directive-helpers.js";import{AsyncDirective as s}from"../async-directive.js";import{PseudoWeakRef as i,Pauser as r}from"./private-async-helpers.js";import{directive as o}from"../directive.js";
/**
 * @license
 * Copyright 2017 Google LLC
 * SPDX-License-Identifier: BSD-3-Clause
 */const n=t=>!e(t)&&"function"==typeof t.then,h=1073741823;class c extends s{constructor(){super(...arguments),this._$Cwt=h,this._$Cbt=[],this._$CK=new i(this),this._$CX=new r}render(...e){return e.find((t=>!n(t)))??t}update(e,s){const i=this._$Cbt;let r=i.length;this._$Cbt=s;const o=this._$CK,a=this._$CX;this.isConnected||this.disconnected();for(let t=0;t<s.length&&!(t>this._$Cwt);t++){const e=s[t];if(!n(e))return this._$Cwt=t,e;t<r&&e===i[t]||(this._$Cwt=h,r=0,Promise.resolve(e).then((async t=>{for(;a.get();)await a.get();const s=o.deref();if(void 0!==s){const i=s._$Cbt.indexOf(e);i>-1&&i<s._$Cwt&&(s._$Cwt=i,s.setValue(t))}})))}return t}disconnected(){this._$CK.disconnect(),this._$CX.pause()}reconnected(){this._$CK.reconnect(this),this._$CX.resume()}}const a=o(c);export{c as UntilDirective,a as until};