2 lines
11 KiB
JavaScript
2 lines
11 KiB
JavaScript
import{i as Ce,a as xe,n as Pe,t as w,b as C,c as x,m as P,d as k,e as D,f as ke,w as E,u as ae,g as _,h as Se,s as Te,p as Ee,j as _e}from"./DkKOCi34.js";import{aT as se,af as ce,k as L,r as y,I as Z,aU as N,a9 as re,bx as Ae,dd as U,bj as Be,$,o as le,ae as V,d2 as ie,J as G,d as A,C as d,de as T,e as ze,T as ue,cU as de,a5 as fe,a6 as ve,a0 as De}from"./CqMGdh3i.js";var H=typeof window<"u";function xn(e){const n=se(e,null);if(n){const t=N(),{link:a,unlink:s,internalChildren:r}=n;a(t),ce(()=>s(t));const l=L(()=>r.indexOf(t));return{parent:n,index:l}}return{parent:null,index:y(-1)}}function Le(e){const n=[],t=a=>{Array.isArray(a)&&a.forEach(s=>{var r;Ae(s)&&(n.push(s),(r=s.component)!=null&&r.subTree&&(n.push(s.component.subTree),t(s.component.subTree.children)),s.children&&t(s.children))})};return t(e),n}var J=(e,n)=>{const t=e.indexOf(n);return t===-1?e.findIndex(a=>n.key!==void 0&&n.key!==null&&a.type===n.type&&a.key===n.key):t};function Ne(e,n,t){const a=Le(e.subTree.children);t.sort((r,l)=>J(a,r.vnode)-J(a,l.vnode));const s=t.map(r=>r.proxy);n.sort((r,l)=>{const o=s.indexOf(r),i=s.indexOf(l);return o-i})}function Pn(e){const n=Z([]),t=Z([]),a=N();return{children:n,linkChildren:r=>{re(e,Object.assign({link:i=>{i.proxy&&(t.push(i),n.push(i.proxy),Ne(a,n,t))},unlink:i=>{const u=t.indexOf(i);n.splice(u,1),t.splice(u,1)},children:n,internalChildren:t},r))}}}function me(e){let n;le(()=>{e(),V(()=>{n=!0})}),ie(()=>{n&&e()})}function ye(e,n,t={}){if(!H)return;const{target:a=window,passive:s=!1,capture:r=!1}=t;let l=!1,o;const i=c=>{if(l)return;const v=G(c);v&&!o&&(v.addEventListener(e,n,{capture:r,passive:s}),o=!0)},u=c=>{if(l)return;const v=G(c);v&&o&&(v.removeEventListener(e,n,r),o=!1)};ce(()=>u(a)),U(()=>u(a)),me(()=>i(a));let f;return Be(a)&&(f=$(a,(c,v)=>{u(v),i(c)})),()=>{f?.(),u(a),l=!0}}var z,M;function $e(){if(!z&&(z=y(0),M=y(0),H)){const e=()=>{z.value=window.innerWidth,M.value=window.innerHeight};e(),window.addEventListener("resize",e,{passive:!0}),window.addEventListener("orientationchange",e,{passive:!0})}return{width:z,height:M}}var Re=/scroll|auto|overlay/i,Ye=H?window:void 0;function je(e){return e.tagName!=="HTML"&&e.tagName!=="BODY"&&e.nodeType===1}function Me(e,n=Ye){let t=e;for(;t&&t!==n&&je(t);){const{overflowY:a}=window.getComputedStyle(t);if(Re.test(a))return t;t=t.parentNode}return n}Ce();const Ke=e=>e.stopPropagation();function he(e,n){(typeof e.cancelable!="boolean"||e.cancelable)&&e.preventDefault(),Ke(e)}$e();const kn="van-hairline",ge="van-haptics-feedback",q=5;function Ue(e,{args:n=[],done:t,canceled:a,error:s}){if(e){const r=e.apply(null,n);xe(r)?r.then(l=>{l?t():a&&a()}).catch(s||Pe):r?t():a&&a()}else t()}const[Ve,Q]=k("badge"),He={dot:Boolean,max:C,tag:P("div"),color:String,offset:Array,content:C,showZero:w,position:P("top-right")};var Xe=A({name:Ve,props:He,setup(e,{slots:n}){const t=()=>{if(n.content)return!0;const{content:o,showZero:i}=e;return D(o)&&o!==""&&(i||o!==0&&o!=="0")},a=()=>{const{dot:o,max:i,content:u}=e;if(!o&&t())return n.content?n.content():D(i)&&ke(u)&&+u>+i?`${i}+`:u},s=o=>o.startsWith("-")?o.replace("-",""):`-${o}`,r=L(()=>{const o={background:e.color};if(e.offset){const[i,u]=e.offset,{position:f}=e,[c,v]=f.split("-");n.default?(typeof u=="number"?o[c]=x(c==="top"?u:-u):o[c]=c==="top"?x(u):s(u),typeof i=="number"?o[v]=x(v==="left"?i:-i):o[v]=v==="left"?x(i):s(i)):(o.marginTop=x(u),o.marginLeft=x(i))}return o}),l=()=>{if(t()||e.dot)return d("div",{class:Q([e.position,{dot:e.dot,fixed:!!n.default}]),style:r.value},[a()])};return()=>{if(n.default){const{tag:o}=e;return d(o,{class:Q("wrapper")},{default:()=>[n.default(),l()]})}return l()}}});const Fe=E(Xe);let We=2e3;const Ze=()=>++We,[Ge]=k("config-provider"),Je=Symbol(Ge),[qe,ee]=k("icon"),Qe=e=>e?.includes("/"),en={dot:Boolean,tag:P("i"),name:String,size:C,badge:C,color:String,badgeProps:Object,classPrefix:String};var nn=A({name:qe,props:en,setup(e,{slots:n}){const t=se(Je,null),a=L(()=>e.classPrefix||t?.iconPrefix||ee());return()=>{const{tag:s,dot:r,name:l,size:o,badge:i,color:u}=e,f=Qe(l);return d(Fe,T({dot:r,tag:s,class:[a.value,f?"":`${a.value}-${l}`],style:{color:u,fontSize:x(o)},content:i},e.badgeProps),{default:()=>{var c;return[(c=n.default)==null?void 0:c.call(n),f&&d("img",{class:ee("image"),src:l},null)]}})}}});const K=E(nn),X={show:Boolean,zIndex:C,overlay:w,duration:C,teleport:[String,Object],lockScroll:w,lazyRender:w,beforeClose:Function,overlayProps:Object,overlayStyle:Object,overlayClass:ae,transitionAppear:Boolean,closeOnClickOverlay:w},tn=Object.keys(X);function on(e){const n=N();n&&_(n.proxy,e)}function an(e,n){return e>n?"horizontal":n>e?"vertical":""}function sn(){const e=y(0),n=y(0),t=y(0),a=y(0),s=y(0),r=y(0),l=y(""),o=y(!0),i=()=>l.value==="vertical",u=()=>l.value==="horizontal",f=()=>{t.value=0,a.value=0,s.value=0,r.value=0,l.value="",o.value=!0};return{move:(h=>{const b=h.touches[0];t.value=(b.clientX<0?0:b.clientX)-e.value,a.value=b.clientY-n.value,s.value=Math.abs(t.value),r.value=Math.abs(a.value);const I=10;(!l.value||s.value<I&&r.value<I)&&(l.value=an(s.value,r.value)),o.value&&(s.value>q||r.value>q)&&(o.value=!1)}),start:(h=>{f(),e.value=h.touches[0].clientX,n.value=h.touches[0].clientY}),reset:f,startX:e,startY:n,deltaX:t,deltaY:a,offsetX:s,offsetY:r,direction:l,isVertical:i,isHorizontal:u,isTap:o}}let S=0;const ne="van-overflow-hidden";function cn(e,n){const t=sn(),a="01",s="10",r=f=>{t.move(f);const c=t.deltaY.value>0?s:a,v=Me(f.target,e.value),{scrollHeight:h,offsetHeight:b,scrollTop:I}=v;let p="11";I===0?p=b>=h?"00":"01":I+b>=h&&(p="10"),p!=="11"&&t.isVertical()&&!(parseInt(p,2)&parseInt(c,2))&&he(f)},l=()=>{document.addEventListener("touchstart",t.start),document.addEventListener("touchmove",r,{passive:!1}),S||document.body.classList.add(ne),S++},o=()=>{S&&(document.removeEventListener("touchstart",t.start),document.removeEventListener("touchmove",r),S--,S||document.body.classList.remove(ne))},i=()=>n()&&l(),u=()=>n()&&o();me(i),U(u),ze(u),$(n,f=>{f?l():o()})}function be(e){const n=y(!1);return $(e,t=>{t&&(n.value=t)},{immediate:!0}),t=>()=>n.value?t():null}const rn=Symbol(),te=()=>{var e;const{scopeId:n}=((e=N())==null?void 0:e.vnode)||{};return n?{[n]:""}:null},[ln,un]=k("overlay"),dn={show:Boolean,zIndex:C,duration:C,className:ae,lockScroll:w,lazyRender:w,customStyle:Object,teleport:[String,Object]};var fn=A({name:ln,inheritAttrs:!1,props:dn,setup(e,{attrs:n,slots:t}){const a=y(),s=be(()=>e.show||!e.lazyRender),r=o=>{e.lockScroll&&he(o)},l=s(()=>{var o;const i=_(Se(e.zIndex),e.customStyle);return D(e.duration)&&(i.animationDuration=`${e.duration}s`),fe(d("div",T({ref:a,style:i,class:[un(),e.className]},n),[(o=t.default)==null?void 0:o.call(t)]),[[ve,e.show]])});return ye("touchmove",r,{target:a}),()=>{const o=d(ue,{name:"van-fade",appear:!0},{default:l});return e.teleport?d(de,{to:e.teleport},{default:()=>[o]}):o}}});const vn=E(fn),mn=_({},X,{round:Boolean,position:P("center"),closeIcon:P("cross"),closeable:Boolean,transition:String,iconPrefix:String,closeOnPopstate:Boolean,closeIconPosition:P("top-right"),destroyOnClose:Boolean,safeAreaInsetTop:Boolean,safeAreaInsetBottom:Boolean}),[yn,oe]=k("popup");var hn=A({name:yn,inheritAttrs:!1,props:mn,emits:["open","close","opened","closed","keydown","update:show","clickOverlay","clickCloseIcon"],setup(e,{emit:n,attrs:t,slots:a}){let s,r;const l=y(),o=y(),i=be(()=>e.show||!e.lazyRender),u=L(()=>{const m={zIndex:l.value};if(D(e.duration)){const O=e.position==="center"?"animationDuration":"transitionDuration";m[O]=`${e.duration}s`}return m}),f=()=>{s||(s=!0,l.value=e.zIndex!==void 0?+e.zIndex:Ze(),n("open"))},c=()=>{s&&Ue(e.beforeClose,{done(){s=!1,n("close"),n("update:show",!1)}})},v=m=>{n("clickOverlay",m),e.closeOnClickOverlay&&c()},h=()=>{if(e.overlay){const m=_({show:e.show,class:e.overlayClass,zIndex:l.value,duration:e.duration,customStyle:e.overlayStyle,role:e.closeOnClickOverlay?"button":void 0,tabindex:e.closeOnClickOverlay?0:void 0},e.overlayProps);return d(vn,T(m,te(),{onClick:v}),{default:a["overlay-content"]})}},b=m=>{n("clickCloseIcon",m),c()},I=()=>{if(e.closeable)return d(K,{role:"button",tabindex:0,name:e.closeIcon,class:[oe("close-icon",e.closeIconPosition),ge],classPrefix:e.iconPrefix,onClick:b},null)};let p;const R=()=>{p&&clearTimeout(p),p=setTimeout(()=>{n("opened")})},Y=()=>n("closed"),pe=m=>n("keydown",m),we=i(()=>{var m;const{destroyOnClose:O,round:j,position:B,safeAreaInsetTop:Ie,safeAreaInsetBottom:Oe,show:W}=e;if(!(!W&&O))return fe(d("div",T({ref:o,style:u.value,role:"dialog",tabindex:0,class:[oe({round:j,[B]:B}),{"van-safe-area-top":Ie,"van-safe-area-bottom":Oe}],onKeydown:pe},t,te()),[(m=a.default)==null?void 0:m.call(a),I()]),[[ve,W]])}),F=()=>{const{position:m,transition:O,transitionAppear:j}=e,B=m==="center"?"van-fade":`van-popup-slide-${m}`;return d(ue,{name:O||B,appear:j,onAfterEnter:R,onAfterLeave:Y},{default:we})};return $(()=>e.show,m=>{m&&!s&&(f(),t.tabindex===0&&V(()=>{var O;(O=o.value)==null||O.focus()})),!m&&s&&(s=!1,n("close"))}),on({popupRef:o}),cn(o,()=>e.show&&e.lockScroll),ye("popstate",()=>{e.closeOnPopstate&&(c(),r=!1)}),le(()=>{e.show&&f()}),ie(()=>{r&&(n("update:show",!0),r=!1)}),U(()=>{e.show&&e.teleport&&(c(),r=!0)}),re(rn,()=>e.show),()=>e.teleport?d(de,{to:e.teleport},{default:()=>[h(),F()]}):d(De,null,[h(),F()])}});const gn=E(hn),bn=E(Te),[pn,g]=k("action-sheet"),wn=_({},X,{title:String,round:w,actions:_e(),closeIcon:P("cross"),closeable:w,cancelText:String,description:String,closeOnPopstate:w,closeOnClickAction:Boolean,safeAreaInsetBottom:w}),In=[...tn,"round","closeOnPopstate","safeAreaInsetBottom"];var Sn=A({name:pn,props:wn,emits:["select","cancel","update:show"],setup(e,{slots:n,emit:t}){const a=c=>t("update:show",c),s=()=>{a(!1),t("cancel")},r=()=>{if(e.title)return d("div",{class:g("header")},[e.title,e.closeable&&d(K,{name:e.closeIcon,class:[g("close"),ge],onClick:s},null)])},l=()=>{if(n.cancel||e.cancelText)return[d("div",{class:g("gap")},null),d("button",{type:"button",class:g("cancel"),onClick:s},[n.cancel?n.cancel():e.cancelText])]},o=c=>{if(c.icon)return d(K,{class:g("item-icon"),name:c.icon},null)},i=(c,v)=>c.loading?d(bn,{class:g("loading-icon")},null):n.action?n.action({action:c,index:v}):[d("span",{class:g("name")},[c.name]),c.subname&&d("div",{class:g("subname")},[c.subname])],u=(c,v)=>{const{color:h,loading:b,callback:I,disabled:p,className:R}=c,Y=()=>{p||b||(I&&I(c),e.closeOnClickAction&&a(!1),V(()=>t("select",c,v)))};return d("button",{type:"button",style:{color:h},class:[g("item",{loading:b,disabled:p}),R],onClick:Y},[o(c),i(c,v)])},f=()=>{if(e.description||n.description){const c=n.description?n.description():e.description;return d("div",{class:g("description")},[c])}};return()=>d(gn,T({class:g(),position:"bottom","onUpdate:show":a},Ee(e,In)),{default:()=>{var c;return[r(),f(),d("div",{class:g("content")},[e.actions.map(u),(c=n.default)==null?void 0:c.call(n)]),l()]}})}});export{kn as B,K as I,xn as a,Sn as s,Pn as u};
|