var __awaiter=this&&this.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function a(e){try{l(r.next(e))}catch(t){o(t)}}function u(e){try{l(r["throw"](e))}catch(t){o(t)}}function l(e){e.done?n(e.value):i(e.value).then(a,u)}l((r=r.apply(e,t||[])).next())}))};var __generator=this&&this.__generator||function(e,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},r,i,o,a;return a={next:u(0),throw:u(1),return:u(2)},typeof Symbol==="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(e){return function(t){return l([e,t])}}function l(a){if(r)throw new TypeError("Generator is already executing.");while(n)try{if(r=1,i&&(o=a[0]&2?i["return"]:a[0]?i["throw"]||((o=i["return"])&&o.call(i),0):i.next)&&!(o=o.call(i,a[1])).done)return o;if(i=0,o)a=[a[0]&2,o.value];switch(a[0]){case 0:case 1:o=a;break;case 4:n.label++;return{value:a[1],done:false};case 5:n.label++;i=a[1];a=[0];continue;case 7:a=n.ops.pop();n.trys.pop();continue;default:if(!(o=n.trys,o=o.length>0&&o[o.length-1])&&(a[0]===6||a[0]===2)){n=0;continue}if(a[0]===3&&(!o||a[1]>o[0]&&a[1]<o[3])){n.label=a[1];break}if(a[0]===6&&n.label<o[1]){n.label=o[1];o=a;break}if(o&&n.label<o[2]){n.label=o[2];n.ops.push(a);break}if(o[2])n.ops.pop();n.trys.pop();continue}a=t.call(e,n)}catch(u){a=[6,u];i=0}finally{r=o=0}if(a[0]&5)throw a[1];return{value:a[0]?a[1]:void 0,done:true}}};var presence=function(e,t){if(t===void 0){t={}}var n=t.afterSelf;return new Promise((function(t){return __awaiter(void 0,void 0,void 0,(function(){function r(t){e.addEventListener(t+"end",i(t))}function i(r){return function(i){var o;if(i.target!==e)return;e.removeEventListener(r+"end",this);(o=n)===null||o===void 0?void 0:o();t();return}}var o,a,u,l,s,c;return __generator(this,(function(i){if(typeof e.dataset.hold!=="undefined"&&"MutationObserver"in window){a=new MutationObserver((function(e){var r=e[0];var i;if(typeof r.target.dataset.hold==="undefined"){(i=n)===null||i===void 0?void 0:i();t()}}));a.observe(e,{attributeFilter:["data-hold"],attributes:true});return[2]}if(typeof e.getAnimations!=="undefined"){Promise.all(e.getAnimations().map((function(e){return e.finished}))).then((function(){var e;(e=n)===null||e===void 0?void 0:e();t();return}))}else{u=window.getComputedStyle(e),l=u.animationName,s=u.animationDuration,c=u.transitionDuration;if(l!=="none"&&s!=="0s"){r("animation")}else if(c!=="0s"){r("transition")}else{(o=n)===null||o===void 0?void 0:o();t()}}return[2]}))}))}))};var kebab=function(e){return e.replace(/([A-Z])/g,"-$1").toLowerCase()};var setCustomProperties=function(e,t){var n=convertToCustomProperties(t);for(var r=0,i=Object.entries(n);r<i.length;r++){var o=i[r],a=o[0],u=o[1];e.style.setProperty(a,u)}};var convertToCustomProperties=function(e,t,n){if(t===void 0){t="--"}if(n===void 0){n={}}if(e==null)return n;switch(typeof e){case"string":{n[kebab(t)]=e;return n}case"number":{n[kebab(t)]=e.toString(10);return n}case"boolean":{n[kebab(t)]=e?"1":"0";return n}}if(Array.isArray(e)||typeof e==="object"){for(var r=0,i=Object.entries(e);r<i.length;r++){var o=i[r],a=o[0],u=o[1];var l=[t,!t.endsWith("-")&&"-",a].filter(Boolean).join("");convertToCustomProperties(u,l,n)}return n}return n};var isHTMLElement=function(e){return e&&e.nodeType===e.ELEMENT_NODE&&typeof e.tagName!=="undefined"};var hasData=function(e,t){return typeof e.dataset[t]!=="undefined"};function closest(e,t){if(t===void 0){t=this}try{function n(t){if(!t||t===document||t===window)return null;var r=t.closest(e);return r?r:n(t.getRootNode().host)}return n(t)}catch(r){return null}}var getTopLevelChildren=function(e){var t=Array.from(e.querySelectorAll("animate-presence"));var n=Array.from(e.querySelectorAll(":scope animate-presence animate-presence"));return t.filter((function(e){return!n.includes(e)}))};var exitChildren=function(e){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,Promise.all(getTopLevelChildren(e).map((function(e){return e.exit()})))]}))}))};var enterChildren=function(e){return __awaiter(void 0,void 0,void 0,(function(){return __generator(this,(function(t){return[2,Promise.all(getTopLevelChildren(e).map((function(e){return e.enter()})))]}))}))};var injectGlobalStyle=function(){var e=document.head.querySelector("[data-ap-global]");if(e)return;e=document.createElement("style");e.dataset.apGlobal="";e.textContent='animate-presence>[data-enter][style*="--i:"],animate-presence>[data-exit][style*="--i:"]{animation-fill-mode:both;}';document.head.appendChild(e)};export{enterChildren as a,isHTMLElement as b,closest as c,exitChildren as e,hasData as h,injectGlobalStyle as i,presence as p,setCustomProperties as s};
//# sourceMappingURL=index-af0083ae.js.map