UNPKG

ranui

Version:

A framework-agnostic Web Components UI library built on native custom elements, with TypeScript types, light/dark theming, SSR and PWA support.

1 lines 40.8 kB
var ranui_modal=(function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var t=`:host{position:var(--ran-modal-host-position,static)}:host([hidden]){display:none}.ran-modal-root{position:var(--ran-modal-root-position,fixed);inset:var(--ran-modal-root-inset,0);z-index:var(--ran-modal-root-z-index,var(--ran-z-modal,1000));opacity:0;visibility:hidden;justify-content:center;align-items:center;transition:opacity .3s,visibility .3s;display:flex}.ran-modal-root[open]{opacity:1;visibility:visible}.ran-modal-mask{position:var(--ran-modal-mask-position,absolute);inset:var(--ran-modal-mask-inset,0);background:var(--ran-modal-mask-background,#00000073)}.ran-modal-dialog{position:var(--ran-modal-dialog-position,relative);width:var(--ran-modal-dialog-width,min(560px, calc(100vw - 32px)));margin:var(--ran-modal-dialog-margin,0 auto);background:var(--ran-modal-dialog-background,var(--ran-color-bg-elevated,#fff));border-image-source:var(--ran-modal-dialog-border-image-source,none);border-image-slice:var(--ran-modal-dialog-border-image-slice,8);border-image-width:var(--ran-modal-dialog-border-image-width,var(--ran-skin-border-image-width,4px));border-radius:var(--ran-modal-dialog-border-radius,var(--ran-radius-md,12px));box-shadow:var(--ran-modal-dialog-box-shadow,var(--ran-shadow-modal,var(--ran-shadow-elevated,0 10px 32px #0003)));outline:var(--ran-modal-dialog-outline,none);max-height:var(--ran-modal-dialog-max-height,calc(100vh - 20vh));overflow:var(--ran-modal-dialog-overflow,hidden);transform:translateY(var(--ran-modal-dialog-offset-y,clamp(-56px, -6vh, -24px))) scale(.9);border-image-outset:0;border-image-repeat:stretch;transition:transform .3s cubic-bezier(.075,.82,.165,1)}.ran-modal-root[open] .ran-modal-dialog{transform:translateY(var(--ran-modal-dialog-offset-y,clamp(-56px, -6vh, -24px))) scale(1)}.ran-modal-header{display:var(--ran-modal-header-display,flex);align-items:var(--ran-modal-header-align-items,center);justify-content:var(--ran-modal-header-justify-content,space-between);padding:var(--ran-modal-header-padding,var(--ran-space-4,16px));border-bottom:var(--ran-modal-header-border-bottom,1px solid var(--ran-color-border-secondary,#f0f0f0))}.ran-modal-root.hide-header .ran-modal-header{z-index:1;padding:var(--ran-modal-header-hidden-padding,var(--ran-space-3,12px));background:0 0;border-bottom:none;position:absolute;top:0;right:0}.ran-modal-root.hide-header .ran-modal-title{display:none}.ran-modal-title{margin:var(--ran-modal-title-margin,0);font-size:var(--ran-modal-title-font-size,var(--ran-text-heading-4,16px));font-weight:var(--ran-modal-title-font-weight,var(--ran-text-heading-weight,600));letter-spacing:var(--ran-modal-title-letter-spacing,var(--ran-text-heading-tracking,-.03em));line-height:var(--ran-modal-title-line-height,1.5);color:var(--ran-modal-title-color,var(--ran-color-text,#111827))}.ran-modal-close{border:var(--ran-modal-close-border,none);background:var(--ran-modal-close-background,transparent);color:var(--ran-modal-close-color,var(--ran-color-text-secondary,#667085));font-size:var(--ran-modal-close-font-size,18px);cursor:var(--ran-modal-close-cursor,pointer);padding:var(--ran-modal-close-padding,0 4px)}.ran-modal-body{padding:var(--ran-modal-body-padding,var(--ran-space-4,16px));max-height:var(--ran-modal-body-max-height,calc(100vh - 32vh));overflow:var(--ran-modal-body-overflow,auto);color:var(--ran-modal-body-color,var(--ran-color-text-secondary,#344054))}.ran-modal-footer{align-items:var(--ran-modal-footer-align-items,center);justify-content:var(--ran-modal-footer-justify-content,flex-end);gap:var(--ran-modal-footer-gap,var(--ran-space-3,12px));padding:var(--ran-modal-footer-padding,var(--ran-space-3,12px) var(--ran-space-4,16px) var(--ran-space-4,16px));border-top:var(--ran-modal-footer-border-top,1px solid var(--ran-color-border-secondary,#f0f0f0));display:none}.ran-modal-root.has-footer .ran-modal-footer{display:flex}.ran-modal-footer::slotted(.ran-modal-actions){justify-content:flex-end;align-items:center;gap:var(--ran-modal-actions-gap,var(--ran-space-3,12px));display:inline-flex}.ran-modal-footer::slotted(.ran-modal-action){border:1px solid var(--ran-color-border,#d0d5dd);background:var(--ran-color-bg-elevated,#fff);border-radius:var(--ran-radius-sm,6px);height:34px;padding:0 var(--ran-modal-action-padding-inline,var(--ran-space-4,16px));cursor:pointer;line-height:32px;font-size:var(--ran-modal-action-font-size,var(--ran-text-button-size,14px));font-weight:var(--ran-modal-action-font-weight,var(--ran-text-button-weight,500));color:var(--ran-color-text-secondary,#344054)}.ran-modal-footer::slotted(.ran-modal-action-confirm){border-color:var(--ran-color-primary,#171717);background:var(--ran-color-primary,#171717);color:var(--ran-color-primary-text,#fff)}.ran-modal-footer::slotted(.ran-modal-action:disabled){opacity:.6;cursor:not-allowed}`,n=typeof document>`u`,r=class{ac=null;get signal(){return this.ac??=new AbortController,this.ac.signal}on(e,t,n,r){return e.addEventListener(t,n,{...r,signal:this.signal}),this}delegate(e,t,n,r,i){return e.addEventListener(n,n=>{let i=n.target?.closest(t);i&&e.contains(i)&&r(n,i)},{...i,signal:this.signal}),this}abort(){this.ac?.abort(),this.ac=null}},i=0,a=1,o=2,s=null,c=null,l=0,u=new Set,d=!1;function f(e,t){let n=t?.equals??Object.is,r={value:e,observers:new Set};return[()=>(v(r),r.value),e=>{let t=typeof e==`function`?e(r.value):e;if(!n(r.value,t)){r.value=t;for(let e of r.observers)y(e,o);l===0&&ee()}}]}function p(e){let t=g(e,!0);return _(t),x(t),()=>C(t)}function m(e){let t={owned:[],cleanups:[],owner:c},n=c,r=s;c=t,s=null;try{return e(()=>w(t))}finally{c=n,s=r}}function h(e){c&&c.cleanups.push(e)}function g(e,t,n){return{fn:e,sources:new Set,isEffect:t,running:!1,disposed:!1,state:o,observers:new Set,value:void 0,equals:n??Object.is,owned:[],cleanups:[],owner:c}}function _(e){c&&c.owned.push(e)}function v(e){s&&(s.sources.add(e),e.observers.add(s))}function y(e,t){if(e.disposed||e.state>=t)return;let n=e.state===i;if(e.state=t,e.isEffect)u.add(e);else if(n)for(let t of e.observers)y(t,a)}function ee(){if(!(l>0||d)){d=!0;try{for(;u.size>0;){let e=[...u];u.clear();for(let t of e)t.disposed||b(t)}}finally{d=!1}}}function b(e){if(!(e.disposed||e.state===i)){if(e.state===a)for(let t of e.sources)`fn`in t&&b(t);e.state===o&&x(e),e.state=i}}function x(e){if(e.running)throw Error(`ranui reactivity: cyclic dependency detected (a computation triggered itself).`);S(e);let t=s,n=c;s=e,c=e,e.running=!0,e.state=i;try{let t=e.fn();if(e.isEffect)typeof t==`function`&&e.cleanups.push(t);else{let n=e.value;if(e.value=t,e.observers.size>0&&!e.equals(n,t))for(let t of e.observers)y(t,o)}}finally{e.running=!1,s=t,c=n}}function S(e){for(let t of e.owned)C(t);e.owned.length=0;for(let t of e.cleanups)t();e.cleanups.length=0;for(let t of e.sources)t.observers.delete(e);e.sources.clear()}function C(e){e.disposed||(e.disposed=!0,S(e),e.observers.clear())}function w(e){for(let t of e.owned)C(t);e.owned.length=0;for(let t of e.cleanups)t();e.cleanups.length=0}var T=class{_events=new Map;tap=(e,t)=>{this._events.get(e)&&e!==Symbol.for(`NEW_LISTENER`)&&this.call(Symbol.for(`NEW_LISTENER`),e);let n=this._events.get(e)||new Set;return typeof t==`function`?n.add({name:e,callback:t}):n.add(t),this._events.set(e,n),this};call=(e,...t)=>((this._events.get(e)||new Set).forEach(e=>{let{callback:n}=e;n(...t)}),this);callSync=async(e,...t)=>{let n=this._events.get(e)||new Set;for(let e of n){let{callback:n}=e;await n(...t)}return this};once=(e,t)=>{let n;if(typeof t==`function`)n={name:e,callback:(...r)=>{t(...r),this.off(e,n)},initialCallback:t};else{let{callback:r}=t;n={name:e,callback:(...t)=>{r(...t),this.off(e,n)},initialCallback:r}}return this.tap(e,n),this};off=(e,t)=>{let n=[...this._events.get(e)||new Set].filter(e=>{if(typeof t==`function`)return e.callback!==t&&e.initialCallback!==t;{let{callback:n}=t;return e.callback!==n&&e.initialCallback!==n}});return this._events.set(e,new Set(n)),this}};Math.PI/180,180/Math.PI,2*Math.PI;var E=(e=8)=>Math.random().toString(36).substring(2,e+2);Object.freeze({});var te=e=>typeof e==`function`,ne=12e4,re=`__ranuts_bridge__`,ie=`default`,D=new class{bridges=new Set;attachedWindow=null;handleMessage=e=>{for(let t of Array.from(this.bridges))t.receive(e)};add(e){this.bridges.add(e),typeof window<`u`&&this.attachedWindow!==window&&(window.addEventListener(`message`,this.handleMessage),this.attachedWindow=window)}remove(e){this.bridges.delete(e),this.bridges.size===0&&this.attachedWindow&&(this.attachedWindow.removeEventListener(`message`,this.handleMessage),this.attachedWindow=null)}},O=class{targetWindow;targetOrigin;messageHandlers;pendingRequests;channel;senderId;available;constructor(e,t=`*`,n=ie){this.targetOrigin=t,this.channel=n,this.senderId=E(12),this.messageHandlers=new Map,this.pendingRequests=new Map,this.available=typeof window<`u`,this.available?(this.targetWindow=e??window,D.add(this)):this.targetWindow=void 0}post(e,t){let n={...t,__bridge:re,channel:this.channel,senderId:this.senderId};e.postMessage(n,this.targetOrigin)}receive=e=>{if(!this.available||this.targetOrigin!==`*`&&e.origin!==this.targetOrigin||e.source&&e.source!==this.targetWindow)return;let t=e.data;if(!t||typeof t!=`object`||t.__bridge!==`__ranuts_bridge__`||(t.channel??`default`)!==this.channel)return;let{type:n,payload:r,id:i,isResponse:a,isError:o,senderId:s}=t;if(a&&i){let e=this.pendingRequests.get(i);e&&(o?e.reject(Error(typeof r==`string`?r:`Bridge request failed`)):e.resolve(r),this.pendingRequests.delete(i));return}if(s&&s===this.senderId||typeof n!=`string`||!this.messageHandlers.has(n))return;let c=this.messageHandlers.get(n);if(te(c)){let t=e.source??this.targetWindow;Promise.resolve(c(r)).then(e=>{i&&this.post(t,{type:n,payload:e,id:i,isResponse:!0})}).catch(e=>{i&&this.post(t,{type:n,payload:e instanceof Error?e.message:String(e),id:i,isResponse:!0,isError:!0})})}};on=(e,t)=>{this.messageHandlers.set(e,t)};off=e=>{this.messageHandlers.delete(e)};send=async(e,t)=>{if(!this.available)return Promise.reject(Error(`PostMessageBridge is unavailable outside a browser environment`));let n=E(10);return new Promise((r,i)=>{let a=setTimeout(()=>{this.pendingRequests.has(n)&&(this.pendingRequests.delete(n),i(Error(`Request timeout`)))},ne),o=e=>{clearTimeout(a),i(e)};this.pendingRequests.set(n,{resolve:e=>{clearTimeout(a),r(e)},reject:o});try{this.post(this.targetWindow,{type:e,payload:t,id:n})}catch(e){this.pendingRequests.delete(n),o(e instanceof Error?e:Error(`Failed to post message`))}})};broadcast=e=>{if(this.available)try{this.post(this.targetWindow,{type:e.type,payload:e.payload})}catch{}};destroy=()=>{D.remove(this),this.messageHandlers.clear(),this.pendingRequests.forEach(e=>{e.reject(Error(`Bridge destroyed`))}),this.pendingRequests.clear()}};(class e{static instance;bridges=new Map;constructor(){}static getInstance(){return e.instance||=new e,e.instance}connectClient=({id:e,targetOrigin:t,targetWindow:n,channel:r})=>{let i=new O(n,t,r);if(e||=E(10),this.bridges.has(e))throw Error(`Bridge ${e} already exists`);return this.bridges.set(e,i),{bridge:i,id:e}};getClient=e=>this.bridges.get(e);removeClient=e=>{let t=this.bridges.get(e);t&&(t.destroy(),this.bridges.delete(e))};removeAllClient=()=>{this.bridges.forEach(e=>{e.destroy()}),this.bridges.clear()};broadcast=e=>{this.bridges.forEach(t=>{t.broadcast(e)})};sendTo=(e,t,n)=>{let r=this.getClient(e);return r?r.send(t,n):Promise.reject(Error(`Bridge ${e} not found`))}}).getInstance(),new T;var k=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],A=class{highOrder;lowOrder;constructor(e,t){this.highOrder=e,this.lowOrder=t}};new A(k[0],3609767458),new A(k[1],602891725),new A(k[2],3964484399),new A(k[3],2173295548),new A(k[4],4081628472),new A(k[5],3053834265),new A(k[6],2937671579),new A(k[7],3664609560),new A(k[8],2734883394),new A(k[9],1164996542),new A(k[10],1323610764),new A(k[11],3590304994),new A(k[12],4068182383),new A(k[13],991336113),new A(k[14],633803317),new A(k[15],3479774868),new A(k[16],2666613458),new A(k[17],944711139),new A(k[18],2341262773),new A(k[19],2007800933),new A(k[20],1495990901),new A(k[21],1856431235),new A(k[22],3175218132),new A(k[23],2198950837),new A(k[24],3999719339),new A(k[25],766784016),new A(k[26],2566594879),new A(k[27],3203337956),new A(k[28],1034457026),new A(k[29],2466948901),new A(k[30],3758326383),new A(k[31],168717936),new A(k[32],1188179964),new A(k[33],1546045734),new A(k[34],1522805485),new A(k[35],2643833823),new A(k[36],2343527390),new A(k[37],1014477480),new A(k[38],1206759142),new A(k[39],344077627),new A(k[40],1290863460),new A(k[41],3158454273),new A(k[42],3505952657),new A(k[43],106217008),new A(k[44],3606008344),new A(k[45],1432725776),new A(k[46],1467031594),new A(k[47],851169720),new A(k[48],3100823752),new A(k[49],1363258195),new A(k[50],3750685593),new A(k[51],3785050280),new A(k[52],3318307427),new A(k[53],3812723403),new A(k[54],2003034995),new A(k[55],3602036899),new A(k[56],1575990012),new A(k[57],1125592928),new A(k[58],2716904306),new A(k[59],442776044),new A(k[60],593698344),new A(k[61],3733110249),new A(k[62],2999351573),new A(k[63],3815920427),new A(3391569614,3928383900),new A(3515267271,566280711),new A(3940187606,3454069534),new A(4118630271,4000239992),new A(116418474,1914138554),new A(174292421,2731055270),new A(289380356,3203993006),new A(460393269,320620315),new A(685471733,587496836),new A(852142971,1086792851),new A(1017036298,365543100),new A(1126000580,2618297676),new A(1288033470,3409855158),new A(1501505948,4234509866),new A(1607167915,987167468),new A(1816402316,1246189591),new A(0,1),new A(0,32898),new A(2147483648,32906),new A(2147483648,2147516416),new A(0,32907),new A(0,2147483649),new A(2147483648,2147516545),new A(2147483648,32777),new A(0,138),new A(0,136),new A(0,2147516425),new A(0,2147483658),new A(0,2147516555),new A(2147483648,139),new A(2147483648,32905),new A(2147483648,32771),new A(2147483648,32770),new A(2147483648,128),new A(0,32778),new A(2147483648,2147483658),new A(2147483648,2147516545),new A(2147483648,32896),new A(0,2147483649),new A(2147483648,2147516424);var ae=/["'&<>]/;function j(e){let t=``+e,n=ae.exec(t);if(!n)return t;let r,i=``,a=0,o=0;for(a=n.index;a<t.length;a++){switch(t.charCodeAt(a)){case 34:r=`&quot;`;break;case 38:r=`&amp;`;break;case 39:r=`&#39;`;break;case 60:r=`&lt;`;break;case 62:r=`&gt;`;break;default:continue}o!==a&&(i+=t.substring(o,a)),o=a+1,i+=r}return o===a?i:i+t.substring(o,a)}var oe=new Map,se=new Map,ce=`data-adopted-style`,le=`data-adopted-sheet`,M=(e,t,n)=>{if(typeof CSSStyleSheet>`u`)return!1;try{if(!n.has(t)){let e=new CSSStyleSheet;e.replaceSync(t),n.set(t,e)}let r=n.get(t);return e.adoptedStyleSheets.includes(r)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,r]),!0}catch{return!1}},ue=(e,t,n=ce)=>{if(typeof document<`u`&&t&&!M(e,t,oe)&&!e.querySelector(`style[${n}]`)){let r=document.createElement(`style`);r.setAttribute(n,``),r.textContent=t,e.appendChild(r)}},de=(e,t,n=le)=>{if(typeof document<`u`&&t&&!M(e,t,se)&&!Array.from(e.querySelectorAll(`style[${n}]`)).some(e=>e.textContent===t)){let r=document.createElement(`style`);r.setAttribute(n,``),r.textContent=t,e.appendChild(r)}};(()=>{let e=new Uint8Array(128);for(let t=0;t<78;t++)e[`abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_-.,!?;:'"()[]{}`.charCodeAt(t)]=1;return e})();var N=new Map([[100,`Continue`],[101,`Switching Protocols`],[102,`Processing`],[103,`Early Hints`],[200,`OK`],[201,`Created`],[202,`Accepted`],[203,`Non-Authoritative Information`],[204,`No Content`],[205,`Reset Content`],[206,`Partial Content`],[207,`Multi-Status`],[208,`Already Reported`],[226,`IM Used`],[300,`Multiple Choices`],[301,`Moved Permanently`],[302,`Found`],[303,`See Other`],[304,`Not Modified`],[305,`Use Proxy`],[307,`Temporary Redirect`],[308,`Permanent Redirect`],[400,`Bad Request`],[401,`Unauthorized`],[402,`Payment Required`],[403,`Forbidden`],[404,`Not Found`],[405,`Method Not Allowed`],[406,`Not Acceptable`],[407,`Proxy Authentication Required`],[408,`Request Timeout`],[409,`Conflict`],[410,`Gone`],[411,`Length Required`],[412,`Precondition Failed`],[413,`Payload Too Large`],[414,`URI Too Long`],[415,`Unsupported Media Type`],[416,`Range Not Satisfiable`],[417,`Expectation Failed`],[418,`I'm a Teapot`],[421,`Misdirected Request`],[422,`Unprocessable Entity`],[423,`Locked`],[424,`Failed Dependency`],[425,`Too Early`],[426,`Upgrade Required`],[428,`Precondition Required`],[429,`Too Many Requests`],[431,`Request Header Fields Too Large`],[451,`Unavailable For Legal Reasons`],[500,`Internal Server Error`],[501,`Not Implemented`],[502,`Bad Gateway`],[503,`Service Unavailable`],[504,`Gateway Timeout`],[505,`HTTP Version Not Supported`],[506,`Variant Also Negotiates`],[507,`Insufficient Storage`],[508,`Loop Detected`],[509,`Bandwidth Limit Exceeded`],[510,`Not Extended`],[511,`Network Authentication Required`]]);(function(e){let t=new Map;for(let[n,r]of e)t.set(r.toLowerCase(),n);return t})(N),function(e){let t=[];for(let[n,r]of e)t.push(n);return t}(N);function P(e){return j(e)}var fe=e=>typeof e!=`string`&&`tagName`in e&&`childrenList`in e,pe=`.#[`;function me(e){let t=[],n=0,r=/^[a-zA-Z][\w-]*/.exec(e);for(r!==null&&(t.push(r[0]),n=r[0].length);n<e.length;){let r=e[n];if(r===`[`){let r=e.indexOf(`]`,n+1);if(r===-1)return null;t.push(e.slice(n,r+1)),n=r+1;continue}if(r!==`.`&&r!==`#`)return null;let i=n+1;for(;i<e.length&&!pe.includes(e[i]);)i+=1;if(i===n+1)return null;t.push(e.slice(n,i)),n=i}return t.length>0?t:null}var he=(e,t)=>{let n=t;if(n.startsWith(`.`))return e.classList.contains(n.slice(1));if(n.startsWith(`#`))return e.getAttribute(`id`)===n.slice(1);if(n.startsWith(`[`)&&n.endsWith(`]`)){let[t,r]=n.slice(1,-1).trim().split(`=`),i=(t||``).trim();if(!i)return!1;if(r==null)return e.hasAttribute(i);let a=r.trim().replace(/^['"]|['"]$/g,``);return e.getAttribute(i)===a}return e.tagName===n.toLowerCase()},F=(e,t)=>{let n=t.trim();if(!n)return!1;let r=me(n);return r!==null&&r.every(t=>he(e,t))},I=(e,t,n)=>{for(let r of e)fe(r)&&(F(r,t)&&n.push(r),I(r.childrenList,t,n))},L=class{childrenList=[];appendChild(e){return this.childrenList.push(e),e}serialize(){return this.childrenList.map(e=>typeof e==`string`?j(e):e.serialize()).join(``)}querySelector(e){let t=this.querySelectorAll(e);return t.length>0?t[0]:null}querySelectorAll(e){let t=[];return I(this.childrenList,e,t),t}},R=class{tagName;attributes=new Map;inlineStyles=new Map;childrenList=[];shadowRoot=null;textContent=null;content;eventListeners=new Map;style={setProperty:(e,t)=>{let n=e.startsWith(`--`)?e:e.replace(/([A-Z])/g,`-$1`).toLowerCase();this.inlineStyles.set(n,t)},removeProperty:e=>this.inlineStyles.delete(e)};classList={add:(...e)=>{let t=this.attributes.get(`class`)||``,n=new Set([...t.split(` `).filter(Boolean),...e]);this.attributes.set(`class`,Array.from(n).join(` `))},remove:(...e)=>{let t=(this.attributes.get(`class`)||``).split(` `).filter(t=>!e.includes(t));this.attributes.set(`class`,t.join(` `))},toggle:e=>{this.classList.contains(e)?this.classList.remove(e):this.classList.add(e)},contains:e=>(this.attributes.get(`class`)||``).split(` `).includes(e)};_innerHTML=``;get innerHTML(){return this._innerHTML}set innerHTML(e){this._innerHTML=e,this.tagName===`template`&&this.content&&(this.content.childrenList=[e])}constructor(e=`div`){this.tagName=e.toLowerCase(),this.tagName===`template`&&(this.content=new L)}get hidden(){return this.hasAttribute(`hidden`)}set hidden(e){e?this.setAttribute(`hidden`,``):this.removeAttribute(`hidden`)}setAttribute(e,t){this.attributes.set(e,t)}getAttribute(e){return this.attributes.get(e)||null}removeAttribute(e){this.attributes.delete(e)}hasAttribute(e){return this.attributes.has(e)}appendChild(e){return this.childrenList.push(e),e}attachShadow(e){return this.shadowRoot=new ge(this,e),this.shadowRoot}querySelector(e){let t=this.querySelectorAll(e);return t.length>0?t[0]:null}querySelectorAll(e){let t=[];return I(this.childrenList,e,t),t}addEventListener(e,t){let n=this.eventListeners.get(e)||new Set;n.add(t),this.eventListeners.set(e,n)}removeEventListener(e,t){let n=this.eventListeners.get(e);n&&(n.delete(t),n.size===0&&this.eventListeners.delete(e))}dispatchEvent(e){let t=this.eventListeners.get(e.type);if(!t||t.size===0)return!0;for(let n of t)typeof n==`function`?n.call(this,e):n.handleEvent(e);return!e.defaultPrevented}serialize(e){typeof this._preSerialize==`function`&&this._preSerialize();let t=e||this._ssrTag||this.tagName,n=Array.from(this.attributes.entries()).map(([e,t])=>` ${e}="${P(t)}"`).join(``),r=Array.from(this.inlineStyles.entries()).map(([e,t])=>`${e}:${t}`).join(`;`),i=r?` style="${P(r)}"`:``,a=``;return this.shadowRoot&&(a+=this.shadowRoot.serialize()),this.textContent===null?this._innerHTML?a+=this._innerHTML:a+=this.childrenList.map(e=>typeof e==`string`?j(e):(e instanceof L,e.serialize())).join(``):a+=j(this.textContent),[`area`,`base`,`br`,`col`,`embed`,`hr`,`img`,`input`,`link`,`meta`,`param`,`source`,`track`,`wbr`].includes(t)&&!a?`<${t}${n}${i} />`:`<${t}${n}${i}>${a}</${t}>`}},ge=class{host;options;childrenList=[];adoptedStyleSheets=[];constructor(e,t){this.host=e,this.options=t}appendChild(e){return this.childrenList.push(e),e}querySelector(e){let t=this.querySelectorAll(e);return t.length>0?t[0]:null}querySelectorAll(e){let t=[];return I(this.childrenList,e,t),t}serialize(){return`<template shadowrootmode="${this.options.mode}"${this.options.delegatesFocus?` shadowrootdelegatesfocus`:``}>${this.adoptedStyleSheets.map(e=>`<style>${j(e)}</style>`).join(``)}${this.childrenList.map(e=>typeof e==`string`?j(e):(e instanceof L,e.serialize())).join(``)}</template>`}},z=e=>e.reduce((e,t)=>Array.isArray(t)?e.concat(z(t)):e.concat(t),[]),B=e=>e==null?null:e instanceof U?e.build():typeof e==`string`?n?e:document.createTextNode(e):e,_e=(e,t)=>{if(n){H(e,[t()]);return}let r=document.createComment(``),i=document.createComment(``);e.appendChild(r),e.appendChild(i);let a=null,o=()=>{a?.(),a=null;let e=r.nextSibling;for(;e&&e!==i;){let t=e.nextSibling;e.parentNode?.removeChild(e),e=t}};p(()=>{let e=t();o();let n=document.createDocumentFragment();a=m(t=>(H(n,[e]),t)),i.parentNode?.insertBefore(n,i)}),h(()=>a?.())},ve=`__ranFor`,ye=e=>typeof e==`object`&&!!e&&e[ve]===!0,be=(e,t,n)=>{let[r,i]=f(t),a=null,o=m(t=>{let i=B(n(e,r));return a=typeof i==`string`?document.createTextNode(i):i,t});return{node:a,index:i,dispose:o}},V=(e,t)=>{let n=e.parentNode;if(!n)return;let r=e;for(let e of t)r.nextSibling!==e&&n.insertBefore(e,r.nextSibling),r=e},xe=(e,t)=>{if(n){(t.each()??[]).forEach((n,r)=>{let i=B(t.render(n,()=>r));i!=null&&e.appendChild(i)});return}let r=document.createComment(``);e.appendChild(r);let i=new Map;h(()=>{for(let e of i.values())e.dispose();i.clear()}),p(()=>{let e=t.each()??[],n=new Map,a=[];e.forEach((e,r)=>{let o=t.key(e,r);if(n.has(o))return;let s=i.get(o);s?(i.delete(o),s.index(r)):s=be(e,r,t.render),n.set(o,s),s.node&&a.push(s.node)});for(let e of i.values())e.node?.parentNode?.removeChild(e.node),e.dispose();V(r,a),i=n})},Se=`__ranIndex`,Ce=e=>typeof e==`object`&&!!e&&e[Se]===!0,we=(e,t,n)=>{let[r,i]=f(e),a=null,o=m(e=>{let i=B(n(r,t));return a=typeof i==`string`?document.createTextNode(i):i,e});return{node:a,setItem:i,dispose:o}},Te=(e,t)=>{if(n){(t.each()??[]).forEach((n,r)=>{let i=B(t.render(()=>n,r));i!=null&&e.appendChild(i)});return}let r=document.createComment(``);e.appendChild(r);let i=[];h(()=>{for(let e of i)e.dispose();i=[]}),p(()=>{let e=t.each()??[];for(let n=0;n<e.length;n++)n<i.length?i[n].setItem(e[n]):i.push(we(e[n],n,t.render));for(let t=i.length-1;t>=e.length;t--){let{node:e}=i[t];e?.parentNode?.removeChild(e),i[t].dispose(),i.pop()}V(r,i.map(e=>e.node).filter(e=>e!=null))})},H=(e,t)=>{z(t).forEach(t=>{if(ye(t)){xe(e,t);return}if(Ce(t)){Te(e,t);return}if(typeof t==`function`){_e(e,t);return}let n=B(t);n!=null&&e.appendChild(n)})},Ee=new Set(`svg.circle.clipPath.defs.desc.ellipse.feBlend.feColorMatrix.feComposite.feDropShadow.feFlood.feGaussianBlur.feMerge.feMergeNode.feOffset.filter.foreignObject.g.image.line.linearGradient.marker.mask.path.pattern.polygon.polyline.radialGradient.rect.stop.switch.symbol.text.textPath.tspan.use`.split(`.`)),U=class{el;constructor(e,t){let r=t??(Ee.has(e)?`http://www.w3.org/2000/svg`:void 0);this.el=n?new R(e):r?document.createElementNS(r,e):document.createElement(e)}id(e){return this.el.setAttribute(`id`,e),this}bind(e,t){typeof e==`function`?p(()=>t(e())):t(e)}class(e){return this.bind(e,e=>{n?this.el.attributes.set(`class`,e):this.el.className=e}),this}addClass(...e){return e.forEach(e=>this.el.classList.add(e)),this}removeClass(...e){return e.forEach(e=>this.el.classList.remove(e)),this}attr(e,t){return this.bind(t,t=>this.el.setAttribute(e,t)),this}attrs(e){return Object.entries(e).forEach(([e,t])=>{t!=null&&this.el.setAttribute(e,String(t))}),this}boolAttr(e,t,n=``){return this.bind(t,t=>{t?this.el.setAttribute(e,n):this.el.removeAttribute(e)}),this}part(e){return this.attr(`part`,e)}data(e,t){return this.attr(`data-${e}`,t)}style(e,t){return typeof e==`string`?this.bind(t??``,t=>this.el.style.setProperty(e,t)):Object.entries(e).forEach(([e,t])=>this.el.style.setProperty(e,t)),this}cssVar(e,t){let n=e.startsWith(`--`)?e:`--${e}`;return this.style(n,t)}aria(e,t){return this.attr(`aria-${e}`,t)}role(e){return this.attr(`role`,e)}tabIndex(e){return this.attr(`tabindex`,String(e))}label(e){return this.aria(`label`,e)}labelledBy(e){return this.aria(`labelledby`,e)}describedBy(e){return this.aria(`describedby`,e)}ariaHidden(e=!0){return this.aria(`hidden`,String(e))}on(e,t,n){return this.el.addEventListener(e,t,n),this}listen(e,t,n,r){return e.on(this.el,t,n,r),this}delegate(e,t,n,r,i){return e.delegate(this.el,t,n,r,i),this}children(...e){return H(this.el,e),this}replaceChildren(...e){if(n){let e=this.el;e.childrenList=[]}else this.el.replaceChildren();return this.children(...e)}text(e){return this.bind(e,e=>{this.el.textContent=e}),this}ref(e){return e.current=this.el,this}shadow(e={mode:`closed`}){let t=this.el.attachShadow(e);return new De(this.el,t,e)}build(){return this.el}serialize(){if(n)return this.el.serialize();let e=document.createElement(`div`);return e.appendChild(this.el.cloneNode(!0)),e.innerHTML}},De=class{root;hostEl;options;constructor(e,t,n){this.hostEl=e,this.root=t,this.options=n}children(...e){return H(this.root,e),this}adoptSheet(...e){return this.root.adoptedStyleSheets=[...this.root.adoptedStyleSheets,...e],this}css(e){if(n)return this.root.adoptedStyleSheets.push(e),this;if(typeof CSSStyleSheet<`u`)try{let t=new CSSStyleSheet;return t.replaceSync(e),this.root.adoptedStyleSheets=[...this.root.adoptedStyleSheets,t],this}catch{}let t=document.createElement(`style`);return t.textContent=e,this.root.appendChild(t),this}done(){return{host:this.hostEl,shadow:this.root}}serialize(){return n?this.root.serialize():this.root.innerHTML}},W=e=>new U(e),G=()=>W(`div`),K=()=>W(`slot`),q=()=>W(`button`),Oe=[!1,`false`,null,void 0],ke=new Map;function Ae(e,t){n?(ke.set(e,t),t.prototype._ssrTag=e):customElements.get(e)||customElements.define(e,t)}var je=typeof document<`u`?HTMLElement:R,Me=`data-ranui`,J=`data-ranui-sheet`,Ne=(e,t)=>ue(e,t,Me),Pe=(e,t)=>de(e,t,J),Y=new WeakMap,X=`@media (prefers-reduced-motion: reduce){*,*::before,*::after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important;scroll-behavior:auto !important}}`,Z=new Map,Fe=e=>{let t=Z.get(e);if(t!==void 0)return t;let n=e?`${e}\n${X}`:X;return Z.set(e,n),n},Ie=(e,t=``,n={mode:`closed`})=>{let r=e.shadowRoot||Y.get(e)||e.attachShadow(n);return Y.set(e,r),Ne(r,Fe(t)),r},Le=(e,t,n=``)=>e.getAttribute(t)??n,Re=(e,t,n,r={})=>{if(r.removeEmpty&&!n){e.removeAttribute(t);return}e.setAttribute(t,n??``)},ze=(e,t,n,r,i)=>{if(n!==`sheet`||r===i)return;let a=e.getAttribute(`sheet`)||``;a&&Pe(t,a)},Q=`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`,$=class e extends je{static _openStack=[];static _bodyScrollLockCount=0;static _bodyOverflow=``;static _bodyPaddingRight=``;static _inertSnapshot=new Map;_events=new r;_shadowDom;_root;_mask;_dialog;_title;_closeBtn;_slot;_footer;_footerSlot;_labelId;_previousActiveElement;_isDialogOpen;_scrollLocked;_afterOpenTimer;_afterCloseTimer;static get observedAttributes(){return[`open`,`heading`,`maskClosable`,`closeOnEsc`,`lockScroll`,`autoFocus`,`closable`,`hide-header`,`sheet`]}constructor(){super(),this._labelId=`ran-modal-title-${Math.random().toString(36).slice(2,9)}`,this._previousActiveElement=null,this._isDialogOpen=!1,this._scrollLocked=!1,this._afterOpenTimer=null,this._afterCloseTimer=null,this._shadowDom=Ie(this,t);let e=G().class(`ran-modal-root`).part(`root`).children(G().class(`ran-modal-mask`).part(`mask`),G().class(`ran-modal-dialog`).part(`dialog`).role(`dialog`).attr(`aria-modal`,`true`).tabIndex(-1).labelledBy(this._labelId).children(W(`header`).class(`ran-modal-header`).part(`header`).children(W(`h3`).class(`ran-modal-title`).part(`title`).id(this._labelId),W(`button`).class(`ran-modal-close`).part(`close`).attr(`type`,`button`).label(`Close dialog`).text(`x`)),G().class(`ran-modal-body`).part(`body`).children(K()),W(`footer`).class(`ran-modal-footer`).part(`footer`).children(K().attr(`name`,`footer`)))).build();this._shadowDom.appendChild(e),this._root=e,this._mask=this._root.querySelector(`.ran-modal-mask`),this._dialog=this._root.querySelector(`.ran-modal-dialog`),this._title=this._root.querySelector(`.ran-modal-title`),this._closeBtn=this._root.querySelector(`.ran-modal-close`),this._slot=this._root.querySelector(`slot`),this._footer=this._root.querySelector(`.ran-modal-footer`),this._footerSlot=this._root.querySelector(`slot[name="footer"]`),this.syncTitle(),this.syncClosable(),this.syncFooter(),this.syncHeader()}get open(){return this.hasAttribute(`open`)&&!Oe.includes(this.getAttribute(`open`))}set open(e){!e||e===`false`?this.removeAttribute(`open`):this.setAttribute(`open`,``)}get heading(){return this.getAttribute(`heading`)||``}set heading(e){this.setAttribute(`heading`,e||``)}get maskClosable(){let e=this.getAttribute(`maskClosable`);return e!==`false`&&e!==`0`}set maskClosable(e){!e||e===`false`||e===`0`?this.setAttribute(`maskClosable`,`false`):this.setAttribute(`maskClosable`,`true`)}get sheet(){return Le(this,`sheet`)}set sheet(e){Re(this,`sheet`,e)}get closeOnEsc(){let e=this.getAttribute(`closeOnEsc`);return e!==`false`&&e!==`0`}set closeOnEsc(e){!e||e===`false`||e===`0`?this.setAttribute(`closeOnEsc`,`false`):this.setAttribute(`closeOnEsc`,`true`)}get lockScroll(){let e=this.getAttribute(`lockScroll`);return e!==`false`&&e!==`0`}set lockScroll(e){!e||e===`false`||e===`0`?this.setAttribute(`lockScroll`,`false`):this.setAttribute(`lockScroll`,`true`)}get autoFocus(){let e=this.getAttribute(`autoFocus`);return e!==`false`&&e!==`0`}set autoFocus(e){!e||e===`false`||e===`0`?this.setAttribute(`autoFocus`,`false`):this.setAttribute(`autoFocus`,`true`)}get closable(){let e=this.getAttribute(`closable`);return e!==`false`&&e!==`0`}set closable(e){!e||e===`false`||e===`0`?this.setAttribute(`closable`,`false`):this.setAttribute(`closable`,`true`)}get hideHeader(){let e=this.getAttribute(`hide-header`);return e!==null&&e!==`false`&&e!==`0`}set hideHeader(e){!e||e===`false`||e===`0`?this.removeAttribute(`hide-header`):this.setAttribute(`hide-header`,``)}handlerExternalCss=()=>{ze(this,this._shadowDom,`sheet`,null,this.sheet)};syncTitle=()=>{this._title.textContent=this.heading||`Modal`,this.hideHeader&&this._dialog.setAttribute(`aria-label`,this.heading||`Modal`)};syncClosable=()=>{let e=this.closable;this._closeBtn.hidden=!e,this._closeBtn.setAttribute(`aria-hidden`,e?`false`:`true`),this._closeBtn.tabIndex=e?0:-1};syncHeader=()=>{let e=this.hideHeader;this._root.classList.toggle(`hide-header`,e),e?(this._dialog.setAttribute(`aria-label`,this.heading||`Modal`),this._dialog.removeAttribute(`aria-labelledby`)):(this._dialog.setAttribute(`aria-labelledby`,this._labelId),this._dialog.removeAttribute(`aria-label`))};syncFooter=()=>{let e=(this._footerSlot?.assignedNodes({flatten:!0})||[]).some(e=>e.nodeType===Node.ELEMENT_NODE||e.nodeType===Node.TEXT_NODE&&(e.textContent||``).trim().length>0);this._root.classList.toggle(`has-footer`,e)};getFocusableElements=()=>{let e=Array.from(this._dialog.querySelectorAll(Q)),t=Array.from(this.querySelectorAll(Q));return[...e,...t].filter(e=>{if(e.hasAttribute(`disabled`))return!1;let t=e;return t.offsetParent!==null||t.getClientRects().length>0})};static getTopModal=()=>e._openStack.length===0?null:e._openStack[e._openStack.length-1]||null;static pushOpenModal=t=>{e._openStack.includes(t)||e._openStack.push(t)};static removeOpenModal=t=>{e._openStack=e._openStack.filter(e=>e!==t)};static syncBackgroundInert=()=>{if(typeof document>`u`)return;let t=document.body;if(!t)return;for(let[t,n]of e._inertSnapshot.entries())t.inert=n.inert,n.ariaHidden===null?t.removeAttribute(`aria-hidden`):t.setAttribute(`aria-hidden`,n.ariaHidden);if(e._inertSnapshot.clear(),e._openStack.length===0)return;let n=e._openStack.map(e=>e);Array.from(t.children).forEach(t=>{n.some(e=>t===e||t.contains(e))||(e._inertSnapshot.set(t,{inert:t.inert,ariaHidden:t.getAttribute(`aria-hidden`)}),t.inert=!0,t.setAttribute(`aria-hidden`,`true`))})};static lockBodyScroll=()=>{if(typeof document>`u`)return;let t=document.body;if(t){if(e._bodyScrollLockCount===0){e._bodyOverflow=t.style.overflow,e._bodyPaddingRight=t.style.paddingRight;let n=Math.max(0,window.innerWidth-document.documentElement.clientWidth);if(n>0){let e=Number.parseFloat(window.getComputedStyle(t).paddingRight)||0;t.style.paddingRight=`${e+n}px`}t.style.overflow=`hidden`}e._bodyScrollLockCount+=1}};static unlockBodyScroll=()=>{if(typeof document>`u`)return;let t=document.body;!t||e._bodyScrollLockCount===0||(--e._bodyScrollLockCount,e._bodyScrollLockCount===0&&(t.style.overflow=e._bodyOverflow,t.style.paddingRight=e._bodyPaddingRight))};clearAfterTimers=()=>{this._afterOpenTimer!==null&&(window.clearTimeout(this._afterOpenTimer),this._afterOpenTimer=null),this._afterCloseTimer!==null&&(window.clearTimeout(this._afterCloseTimer),this._afterCloseTimer=null)};getTransitionTimeout=()=>{let e=window.getComputedStyle(this._dialog),t=e=>{let t=e.split(`,`)[0]?.trim()||`0s`;return t.endsWith(`ms`)?Number.parseFloat(t):t.endsWith(`s`)?Number.parseFloat(t)*1e3:Number.parseFloat(t)||0},n=t(e.transitionDelay),r=t(e.transitionDuration);return Math.max(0,n+r)};emitAfterOpen=()=>{let e=this.getTransitionTimeout();this._afterOpenTimer=window.setTimeout(()=>{this._afterOpenTimer=null,this.dispatchEvent(new CustomEvent(`afteropen`))},e)};emitAfterClose=e=>{let t=this.getTransitionTimeout();this._afterCloseTimer=window.setTimeout(()=>{this._afterCloseTimer=null,this.removeAttribute(`closing`),this.dispatchEvent(new CustomEvent(`afterclose`,{detail:{trigger:e}}))},t)};trapFocus=e=>{if(e.key!==`Tab`)return;let t=this.getFocusableElements();if(t.length===0){e.preventDefault(),this._dialog.focus();return}let n=t[0],r=t[t.length-1],i=this._shadowDom.activeElement||document.activeElement;if(e.shiftKey&&i===n){e.preventDefault(),r.focus();return}!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())};close=(e=`program`)=>{if(!this.open)return;let t=new CustomEvent(`beforeclose`,{cancelable:!0,detail:{trigger:e}});this.dispatchEvent(t)&&(this.removeAttribute(`open`),this.dispatchEvent(new CustomEvent(`close`,{detail:{trigger:e}})),this.emitAfterClose(e))};openDialog=()=>{if(this._isDialogOpen||this._root.hasAttribute(`open`))return;let t=new CustomEvent(`beforeopen`,{cancelable:!0});if(!this.dispatchEvent(t)){this.removeAttribute(`open`);return}this._previousActiveElement=document.activeElement,e.pushOpenModal(this),e.syncBackgroundInert(),this.lockScroll&&(e.lockBodyScroll(),this._scrollLocked=!0),this._isDialogOpen=!0,this._root.setAttribute(`open`,``),this._dialog.setAttribute(`aria-hidden`,`false`),this.removeAttribute(`closing`),this.dispatchEvent(new CustomEvent(`open`)),this.clearAfterTimers(),this.emitAfterOpen(),requestAnimationFrame(()=>{this.autoFocus&&(this.getFocusableElements()[0]||this._dialog).focus()})};closeDialog=()=>{if(!this._isDialogOpen){this._root.removeAttribute(`open`),this._dialog.setAttribute(`aria-hidden`,`true`);return}this._isDialogOpen=!1,e.removeOpenModal(this),e.syncBackgroundInert(),this._scrollLocked&&=(e.unlockBodyScroll(),!1),this._root.removeAttribute(`open`),this._dialog.setAttribute(`aria-hidden`,`true`),this.setAttribute(`closing`,``),this._previousActiveElement instanceof HTMLElement&&this._previousActiveElement.focus()};onMaskClick=e=>{this.maskClosable&&(e.composedPath().includes(this._dialog)||this.close(`mask`))};onCloseButtonClick=()=>{this.close(`button`)};onKeydown=t=>{if(this.open&&e.getTopModal()===this){if(t.key===`Escape`&&this.closeOnEsc){t.preventDefault(),this.close(`escape`);return}this.trapFocus(t)}};onDocumentFocusIn=t=>{if(!this.open||e.getTopModal()!==this)return;let n=t.composedPath();n.includes(this)||n.includes(this._dialog)||(this.getFocusableElements()[0]||this._dialog).focus()};connectedCallback(){this.handlerExternalCss(),this._events.on(this._mask,`click`,this.onMaskClick).on(this._closeBtn,`click`,this.onCloseButtonClick).on(document,`keydown`,this.onKeydown).on(document,`focusin`,this.onDocumentFocusIn).on(this._footerSlot,`slotchange`,this.syncFooter),this.syncTitle(),this.syncClosable(),this.syncFooter(),this.syncHeader(),this.open?this.openDialog():this.closeDialog()}disconnectedCallback(){this._root.hasAttribute(`open`)&&this.closeDialog(),this._events.abort(),this.clearAfterTimers()}attributeChangedCallback(e,t,n){if(t!==n){if(e===`heading`){this.syncTitle();return}if(e===`closable`){this.syncClosable();return}if(e===`hide-header`){this.syncHeader();return}if(e===`open`){this.open?this.openDialog():this.closeDialog();return}e===`sheet`&&this.handlerExternalCss()}}static normalizeProgrammaticOptions=e=>typeof e==`string`?{content:e}:e||{};static open=t=>{if(typeof document>`u`)return Promise.resolve({action:`dismiss`,trigger:`program`});let{title:n=`Confirm`,content:r=``,okText:i=`OK`,cancelText:a=`Cancel`,showCancel:o=!1,maskClosable:s=!1,closeOnEsc:c=!0,lockScroll:l=!0,autoFocus:u=!0,closable:d=!0,onConfirm:f,onCancel:p}=e.normalizeProgrammaticOptions(t);return new Promise(e=>{let t=W(`r-modal`).build();t.heading=n,t.maskClosable=s,t.closeOnEsc=c,t.lockScroll=l,t.autoFocus=u,t.closable=d;let m=G().build();typeof r==`string`?m.textContent=r:r instanceof Node&&m.appendChild(r),t.appendChild(m);let h=`dismiss`,g=G().attr(`slot`,`footer`).class(`ran-modal-actions`);if(o){let e=q().attr(`type`,`button`).class(`ran-modal-action ran-modal-action-cancel`).text(a).build();e.addEventListener(`click`,async()=>{await p?.()!==!1&&(h=`cancel`,t.close(`program`))}),g.children(e)}let _=q().attr(`type`,`button`).class(`ran-modal-action ran-modal-action-confirm`).text(i).build();_.addEventListener(`click`,async()=>{_.disabled=!0;try{if(await f?.()===!1)return;h=`confirm`,t.close(`program`)}finally{_.disabled=!1}}),g.children(_),t.appendChild(g.build());let v=n=>{let r=n.detail?.trigger||`program`;t.removeEventListener(`afterclose`,v),t.parentElement&&t.parentElement.removeChild(t),e({action:h,trigger:r})};t.addEventListener(`afterclose`,v),document.body.appendChild(t),t.open=!0})};static confirm=t=>{let n=e.normalizeProgrammaticOptions(t);return e.open({...n,showCancel:!0})};static info=t=>{let n=e.normalizeProgrammaticOptions(t);return e.open({...n,showCancel:!1,title:n.title||`Info`})};static success=t=>{let n=e.normalizeProgrammaticOptions(t);return e.open({...n,showCancel:!1,title:n.title||`Success`})};static warning=t=>{let n=e.normalizeProgrammaticOptions(t);return e.open({...n,showCancel:!1,title:n.title||`Warning`})};static error=t=>{let n=e.normalizeProgrammaticOptions(t);return e.open({...n,showCancel:!1,title:n.title||`Error`})}};return Ae(`r-modal`,$),e.Modal=$,e.default=$,e})({});