import{b as o,r as l}from"./index-Cjq2zQnM.js";import{_ as D}from"./tslib.es6-CFMGCLkz.js";import{r as L,u as q,a as R,b as A,C as H,M as V}from"./render-to-body-BakZz7UH.js";import{w as T,m as C,c as k}from"./index-y6zaawED.js";function $(e){const t=o.forwardRef((r,s)=>{const[d,v]=l.useState(!1),S=l.useRef(!1),[p,B]=l.useState(e),h=l.useRef(0);l.useEffect(()=>{S.current?x():v(!0)},[]);function _(){var f,i;S.current=!0,v(!1),(i=(f=p.props).onClose)===null||i===void 0||i.call(f)}function x(){var f,i;a(),(i=(f=p.props).afterClose)===null||i===void 0||i.call(f)}return l.useImperativeHandle(s,()=>({close:_,replace:f=>{var i,y;h.current++,(y=(i=p.props).afterClose)===null||y===void 0||y.call(i),B(f)}})),o.cloneElement(p,Object.assign(Object.assign({},p.props),{key:h.current,visible:d,onClose:_,afterClose:x}))}),n=o.createRef(),a=L(o.createElement(t,{ref:n}));return{close:()=>D(this,void 0,void 0,function*(){var r,s,d;n.current?(d=n.current)===null||d===void 0||d.close():(a(),(s=(r=e.props).afterClose)===null||s===void 0||s.call(r))}),replace:r=>{var s;(s=n.current)===null||s===void 0||s.replace(r)},isRendered:()=>!!n.current}}const N="adm-auto-center",W=e=>T(e,o.createElement("div",{className:N},o.createElement("div",{className:`${N}-content`},e.children)));var j={exports:{}},M={};/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var m=l;function z(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var F=typeof Object.is=="function"?Object.is:z,G=m.useState,J=m.useEffect,K=m.useLayoutEffect,Q=m.useDebugValue;function U(e,t){var n=t(),a=G({inst:{value:n,getSnapshot:t}}),r=a[0].inst,s=a[1];return K(function(){r.value=n,r.getSnapshot=t,b(r)&&s({inst:r})},[e,n,t]),J(function(){return b(r)&&s({inst:r}),e(function(){b(r)&&s({inst:r})})},[e]),Q(n),n}function b(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!F(e,n)}catch{return!0}}function X(e,t){return t()}var Y=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?X:U;M.useSyncExternalStore=m.useSyncExternalStore!==void 0?m.useSyncExternalStore:Y;j.exports=M;var Z=j.exports;let ee=!1;const P=new Set;function O(){return ee}function te(e){return P.add(e),()=>{P.delete(e)}}function ne(){return Z.useSyncExternalStore(te,O,O)}const g="adm-spin-loading",re={default:"var(--adm-color-weak)",primary:"var(--adm-color-primary)",white:"var(--adm-color-white)"},oe={color:"default"},se=15*3.14159265358979*2,ae=l.memo(e=>{var t;const n=C(oe,e),a=ne(),{percent:r}=q({cancel:a,loop:{reverse:!0},from:{percent:80},to:{percent:30},config:{duration:1200}});return T(n,o.createElement(R.div,{className:g,style:{"--color":(t=re[n.color])!==null&&t!==void 0?t:n.color,"--percent":r}},o.createElement("svg",{className:`${g}-svg`,viewBox:"0 0 32 32"},o.createElement(R.circle,{className:`${g}-fill`,fill:"transparent",strokeWidth:"2",strokeDasharray:se,strokeDashoffset:r,strokeLinecap:"square",r:15,cx:16,cy:16}))))}),u="adm-toast",ce={maskClickable:!0,stopPropagation:["click"]},ie=e=>{const t=C(ce,e),{maskClickable:n,content:a,icon:r,position:s}=t,d=l.useMemo(()=>{if(r==null)return null;switch(r){case"success":return o.createElement(H,{className:`${u}-icon-success`});case"fail":return o.createElement(A,{className:`${u}-icon-fail`});case"loading":return o.createElement(ae,{color:"white",className:`${u}-loading`});default:return r}},[r]),v=l.useMemo(()=>{switch(s){case"top":return"20%";case"bottom":return"80%";default:return"50%"}},[s]);return o.createElement(V,{visible:t.visible,destroyOnClose:!0,opacity:0,disableBodyScroll:!n,getContainer:t.getContainer,afterClose:t.afterClose,style:Object.assign({pointerEvents:n?"none":"auto"},t.maskStyle),className:k(`${u}-mask`,t.maskClassName),stopPropagation:t.stopPropagation},o.createElement("div",{className:k(`${u}-wrap`)},o.createElement("div",{style:{top:v},className:k(`${u}-main`,r?`${u}-main-icon`:`${u}-main-text`)},d&&o.createElement("div",{className:`${u}-icon`},d),o.createElement(W,null,a))))};let c=null,w=null;const E={duration:2e3,position:"center",maskClickable:!0},le=e=>o.createElement(ie,Object.assign({},e));function ue(e){var t;const n=C(E,typeof e=="string"?{content:e}:e),a=o.createElement(le,Object.assign({},n,{onClose:()=>{c=null}}));return c?!((t=c.isRendered)===null||t===void 0)&&t.call(c)?c.replace(a):(c.close(),c=$(a)):c=$(a),w&&window.clearTimeout(w),n.duration!==0&&(w=window.setTimeout(()=>{I()},n.duration)),c}function I(){c==null||c.close(),c=null}function de(e){e.duration!==void 0&&(E.duration=e.duration),e.position!==void 0&&(E.position=e.position),e.maskClickable!==void 0&&(E.maskClickable=e.maskClickable)}const Ee={show:ue,clear:I,config:de};export{W as A,ae as S,Ee as T,$ as r};
