const e=require("../_util/type.js"),t=require("../_util/classNames.js"),n=require("../_util/props-util/initDefaultProps.js"),r=require("../_util/PortalWrapper.js"),i=require("../vc-trigger/interface.js"),a=require("../vc-trigger/index.js"),o=require("../_util/hooks/useMergedState.js"),s=require("./Mask.js"),c=require("./TourStep/index.js"),l=require("./hooks/useTarget.js"),u=require("./placements.js");let d=require("vue");var f={left:`50%`,top:`50%`,width:`1px`,height:`1px`},p=()=>{let{builtinPlacements:t,popupAlign:n}=i.triggerProps();return{builtinPlacements:t,popupAlign:n,steps:e.arrayType(),open:e.booleanType(),defaultCurrent:{type:Number},current:{type:Number},onChange:e.functionType(),onClose:e.functionType(),onFinish:e.functionType(),mask:e.someType([Boolean,Object],!0),arrow:e.someType([Boolean,Object],!0),rootClassName:{type:String},placement:e.stringType(`bottom`),prefixCls:{type:String,default:`rc-tour`},renderPanel:e.functionType(),gap:e.objectType(),animated:e.someType([Boolean,Object]),scrollIntoViewOptions:e.someType([Boolean,Object],!0),zIndex:{type:Number,default:1001}}},m=(0,d.defineComponent)({name:`Tour`,inheritAttrs:!1,props:n.default(p(),{}),setup(e){let{defaultCurrent:n,placement:i,mask:p,scrollIntoViewOptions:m,open:h,gap:g,arrow:_}=(0,d.toRefs)(e),v=(0,d.ref)(),[y,b]=o.default(0,{value:(0,d.computed)(()=>e.current),defaultValue:n.value}),[x,S]=o.default(void 0,{value:(0,d.computed)(()=>e.open),postState:t=>y.value<0||y.value>=e.steps.length?!1:t??!0}),C=(0,d.shallowRef)(x.value);(0,d.watchEffect)(()=>{x.value&&!C.value&&b(0),C.value=x.value});let w=(0,d.computed)(()=>e.steps[y.value]||{}),T=(0,d.computed)(()=>w.value.placement??i.value),E=(0,d.computed)(()=>x.value&&(w.value.mask??p.value)),D=(0,d.computed)(()=>w.value.scrollIntoViewOptions??m.value),[O,k]=l.default((0,d.computed)(()=>w.value.target),h,g,D),A=(0,d.computed)(()=>k.value?w.value.arrow===void 0?_.value:w.value.arrow:!1),j=(0,d.computed)(()=>typeof A.value==`object`&&A.value.pointAtCenter);(0,d.watch)(j,()=>{v.value?.forcePopupAlign()}),(0,d.watch)(y,()=>{v.value?.forcePopupAlign()});let M=t=>{b(t),e.onChange?.(t)};return()=>{let{prefixCls:n,steps:i,onClose:o,onFinish:l,rootClassName:p,renderPanel:m,animated:h,zIndex:g,..._}=e;if(k.value===void 0)return null;let b=()=>{S(!1),o?.(y.value)},C=typeof E.value==`boolean`?E.value:!!E.value,D=typeof E.value==`boolean`?void 0:E.value,N=()=>k.value||document.body,P=()=>(0,d.createVNode)(c.default,{arrow:A.value,key:`content`,prefixCls:n,total:i.length,renderPanel:m,onPrev:()=>{M(y.value-1)},onNext:()=>{M(y.value+1)},onClose:b,current:y.value,onFinish:()=>{b(),l?.()},...w.value},null),F=(0,d.computed)(()=>{let e=O.value||f,t={};return Object.keys(e).forEach(n=>{typeof e[n]==`number`?t[n]=`${e[n]}px`:t[n]=e[n]}),t});return x.value?(0,d.createVNode)(d.Fragment,null,[(0,d.createVNode)(s.default,{zIndex:g,prefixCls:n,pos:O.value,showMask:C,style:D?.style,fill:D?.color,open:x.value,animated:h,rootClassName:p},null),(0,d.createVNode)(a.default,{..._,arrow:!!_.arrow,builtinPlacements:w.value.target?_.builtinPlacements??u.getPlacements(j.value):void 0,ref:v,popupStyle:w.value.target?w.value.style:{...w.value.style,position:`fixed`,left:f.left,top:f.top,transform:`translate(-50%, -50%)`},popupPlacement:T.value,popupVisible:x.value,popupClassName:t.default(p,w.value.className),prefixCls:n,popup:P,forceRender:!1,destroyPopupOnHide:!0,zIndex:g,mask:!1,getTriggerDOMNode:N},{default:()=>[(0,d.createVNode)(r.default,{visible:x.value,autoLock:!0},{default:()=>[(0,d.createVNode)(`div`,{class:t.default(p,`${n}-target-placeholder`),style:{...F.value,position:`fixed`,pointerEvents:`none`}},null)]})]})]):null}}});exports.default=m,exports.tourProps=p;