All checks were successful
ci/woodpecker/push/check_format Pipeline was successful
31514 lines
952 KiB
JavaScript
31514 lines
952 KiB
JavaScript
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/paomadeng.js","assets/use-houdini.js","assets/Alert.js","assets/paomadeng.css","assets/menu.js","assets/index2.js","assets/Wrench.js","assets/Tooltip.js","assets/Icon.js","assets/next-frame-once.js","assets/use-compitable.js","assets/Dropdown.js","assets/create.js","assets/tabs.js","assets/Add.js","assets/Flex.js","assets/get-slot.js","assets/throttle.js","assets/DesktopSettings.js","assets/HelpText.js","assets/HelpText.css","assets/LongTasks.js","assets/use-message.js","assets/SlickOperatorSelect.js","assets/Image.js","assets/utils.js","assets/use-locale.js","assets/download.js","assets/Checkbox.js","assets/common.js","assets/Select.js","assets/Tag.js","assets/Avatar.js","assets/SlickOperatorSelect.css","assets/text.js","assets/headers.js","assets/RadioGroup.js","assets/Slider.js","assets/Table.js","assets/LongTasks.css","assets/DesktopSettings.css","assets/Log.js","assets/DropDown2.js","assets/Scrollbar.js","assets/Forward.js","assets/DropDown.css","assets/Log.css","assets/Plan.js","assets/IosArrowForward.js","assets/Plan.css","assets/MobileSettings.js","assets/Material_all_in_one.js","assets/Doc.js","assets/Doc.css","assets/BasementSkill.js","assets/BasementSkill.css","assets/DebugConsole.js","assets/DebugConsole.css","assets/RecordLine.js","assets/record.js","assets/index3.js","assets/install.js","assets/Grid.js","assets/RecordLine.css","assets/depot.js","assets/depot.css","assets/RecordPie.js","assets/install2.js","assets/report.js","assets/report.css","assets/NotFound.js"])))=>i.map(i=>d[i]);
|
|
(function polyfill() {
|
|
const relList = document.createElement("link").relList;
|
|
if (relList && relList.supports && relList.supports("modulepreload")) {
|
|
return;
|
|
}
|
|
for (const link of document.querySelectorAll('link[rel="modulepreload"]')) {
|
|
processPreload(link);
|
|
}
|
|
new MutationObserver((mutations) => {
|
|
for (const mutation of mutations) {
|
|
if (mutation.type !== "childList") {
|
|
continue;
|
|
}
|
|
for (const node of mutation.addedNodes) {
|
|
if (node.tagName === "LINK" && node.rel === "modulepreload")
|
|
processPreload(node);
|
|
}
|
|
}
|
|
}).observe(document, { childList: true, subtree: true });
|
|
function getFetchOpts(link) {
|
|
const fetchOpts = {};
|
|
if (link.integrity) fetchOpts.integrity = link.integrity;
|
|
if (link.referrerPolicy) fetchOpts.referrerPolicy = link.referrerPolicy;
|
|
if (link.crossOrigin === "use-credentials")
|
|
fetchOpts.credentials = "include";
|
|
else if (link.crossOrigin === "anonymous") fetchOpts.credentials = "omit";
|
|
else fetchOpts.credentials = "same-origin";
|
|
return fetchOpts;
|
|
}
|
|
function processPreload(link) {
|
|
if (link.ep)
|
|
return;
|
|
link.ep = true;
|
|
const fetchOpts = getFetchOpts(link);
|
|
fetch(link.href, fetchOpts);
|
|
}
|
|
})();
|
|
/**
|
|
* @vue/shared v3.5.13
|
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
* @license MIT
|
|
**/
|
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
// @__NO_SIDE_EFFECTS__
|
|
function makeMap(str) {
|
|
const map = /* @__PURE__ */ Object.create(null);
|
|
for (const key of str.split(",")) map[key] = 1;
|
|
return (val) => val in map;
|
|
}
|
|
const EMPTY_OBJ = {};
|
|
const EMPTY_ARR = [];
|
|
const NOOP = () => {
|
|
};
|
|
const NO = () => false;
|
|
const isOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // uppercase letter
|
|
(key.charCodeAt(2) > 122 || key.charCodeAt(2) < 97);
|
|
const isModelListener = (key) => key.startsWith("onUpdate:");
|
|
const extend$1 = Object.assign;
|
|
const remove = (arr, el) => {
|
|
const i = arr.indexOf(el);
|
|
if (i > -1) {
|
|
arr.splice(i, 1);
|
|
}
|
|
};
|
|
const hasOwnProperty$c = Object.prototype.hasOwnProperty;
|
|
const hasOwn = (val, key) => hasOwnProperty$c.call(val, key);
|
|
const isArray$3 = Array.isArray;
|
|
const isMap = (val) => toTypeString(val) === "[object Map]";
|
|
const isSet = (val) => toTypeString(val) === "[object Set]";
|
|
const isDate$1 = (val) => toTypeString(val) === "[object Date]";
|
|
const isRegExp$1 = (val) => toTypeString(val) === "[object RegExp]";
|
|
const isFunction$2 = (val) => typeof val === "function";
|
|
const isString$1 = (val) => typeof val === "string";
|
|
const isSymbol$1 = (val) => typeof val === "symbol";
|
|
const isObject$2 = (val) => val !== null && typeof val === "object";
|
|
const isPromise = (val) => {
|
|
return (isObject$2(val) || isFunction$2(val)) && isFunction$2(val.then) && isFunction$2(val.catch);
|
|
};
|
|
const objectToString$1 = Object.prototype.toString;
|
|
const toTypeString = (value) => objectToString$1.call(value);
|
|
const toRawType = (value) => {
|
|
return toTypeString(value).slice(8, -1);
|
|
};
|
|
const isPlainObject$3 = (val) => toTypeString(val) === "[object Object]";
|
|
const isIntegerKey = (key) => isString$1(key) && key !== "NaN" && key[0] !== "-" && "" + parseInt(key, 10) === key;
|
|
const isReservedProp = /* @__PURE__ */ makeMap(
|
|
// the leading comma is intentional so empty string "" is also included
|
|
",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
|
|
);
|
|
const isBuiltInDirective = /* @__PURE__ */ makeMap(
|
|
"bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
|
|
);
|
|
const cacheStringFunction = (fn) => {
|
|
const cache2 = /* @__PURE__ */ Object.create(null);
|
|
return (str) => {
|
|
const hit = cache2[str];
|
|
return hit || (cache2[str] = fn(str));
|
|
};
|
|
};
|
|
const camelizeRE = /-(\w)/g;
|
|
const camelize = cacheStringFunction(
|
|
(str) => {
|
|
return str.replace(camelizeRE, (_, c2) => c2 ? c2.toUpperCase() : "");
|
|
}
|
|
);
|
|
const hyphenateRE = /\B([A-Z])/g;
|
|
const hyphenate = cacheStringFunction(
|
|
(str) => str.replace(hyphenateRE, "-$1").toLowerCase()
|
|
);
|
|
const capitalize = cacheStringFunction((str) => {
|
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
});
|
|
const toHandlerKey = cacheStringFunction(
|
|
(str) => {
|
|
const s = str ? `on${capitalize(str)}` : ``;
|
|
return s;
|
|
}
|
|
);
|
|
const hasChanged = (value, oldValue) => !Object.is(value, oldValue);
|
|
const invokeArrayFns = (fns, ...arg) => {
|
|
for (let i = 0; i < fns.length; i++) {
|
|
fns[i](...arg);
|
|
}
|
|
};
|
|
const def = (obj, key, value, writable = false) => {
|
|
Object.defineProperty(obj, key, {
|
|
configurable: true,
|
|
enumerable: false,
|
|
writable,
|
|
value
|
|
});
|
|
};
|
|
const looseToNumber = (val) => {
|
|
const n = parseFloat(val);
|
|
return isNaN(n) ? val : n;
|
|
};
|
|
const toNumber = (val) => {
|
|
const n = isString$1(val) ? Number(val) : NaN;
|
|
return isNaN(n) ? val : n;
|
|
};
|
|
let _globalThis;
|
|
const getGlobalThis = () => {
|
|
return _globalThis || (_globalThis = typeof globalThis !== "undefined" ? globalThis : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : {});
|
|
};
|
|
const identRE = /^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/;
|
|
function genPropsAccessExp(name) {
|
|
return identRE.test(name) ? `__props.${name}` : `__props[${JSON.stringify(name)}]`;
|
|
}
|
|
function genCacheKey(source, options) {
|
|
return source + JSON.stringify(
|
|
options,
|
|
(_, val) => typeof val === "function" ? val.toString() : val
|
|
);
|
|
}
|
|
const PatchFlags = {
|
|
"TEXT": 1,
|
|
"1": "TEXT",
|
|
"CLASS": 2,
|
|
"2": "CLASS",
|
|
"STYLE": 4,
|
|
"4": "STYLE",
|
|
"PROPS": 8,
|
|
"8": "PROPS",
|
|
"FULL_PROPS": 16,
|
|
"16": "FULL_PROPS",
|
|
"NEED_HYDRATION": 32,
|
|
"32": "NEED_HYDRATION",
|
|
"STABLE_FRAGMENT": 64,
|
|
"64": "STABLE_FRAGMENT",
|
|
"KEYED_FRAGMENT": 128,
|
|
"128": "KEYED_FRAGMENT",
|
|
"UNKEYED_FRAGMENT": 256,
|
|
"256": "UNKEYED_FRAGMENT",
|
|
"NEED_PATCH": 512,
|
|
"512": "NEED_PATCH",
|
|
"DYNAMIC_SLOTS": 1024,
|
|
"1024": "DYNAMIC_SLOTS",
|
|
"DEV_ROOT_FRAGMENT": 2048,
|
|
"2048": "DEV_ROOT_FRAGMENT",
|
|
"CACHED": -1,
|
|
"-1": "CACHED",
|
|
"BAIL": -2,
|
|
"-2": "BAIL"
|
|
};
|
|
const PatchFlagNames = {
|
|
[1]: `TEXT`,
|
|
[2]: `CLASS`,
|
|
[4]: `STYLE`,
|
|
[8]: `PROPS`,
|
|
[16]: `FULL_PROPS`,
|
|
[32]: `NEED_HYDRATION`,
|
|
[64]: `STABLE_FRAGMENT`,
|
|
[128]: `KEYED_FRAGMENT`,
|
|
[256]: `UNKEYED_FRAGMENT`,
|
|
[512]: `NEED_PATCH`,
|
|
[1024]: `DYNAMIC_SLOTS`,
|
|
[2048]: `DEV_ROOT_FRAGMENT`,
|
|
[-1]: `HOISTED`,
|
|
[-2]: `BAIL`
|
|
};
|
|
const ShapeFlags = {
|
|
"ELEMENT": 1,
|
|
"1": "ELEMENT",
|
|
"FUNCTIONAL_COMPONENT": 2,
|
|
"2": "FUNCTIONAL_COMPONENT",
|
|
"STATEFUL_COMPONENT": 4,
|
|
"4": "STATEFUL_COMPONENT",
|
|
"TEXT_CHILDREN": 8,
|
|
"8": "TEXT_CHILDREN",
|
|
"ARRAY_CHILDREN": 16,
|
|
"16": "ARRAY_CHILDREN",
|
|
"SLOTS_CHILDREN": 32,
|
|
"32": "SLOTS_CHILDREN",
|
|
"TELEPORT": 64,
|
|
"64": "TELEPORT",
|
|
"SUSPENSE": 128,
|
|
"128": "SUSPENSE",
|
|
"COMPONENT_SHOULD_KEEP_ALIVE": 256,
|
|
"256": "COMPONENT_SHOULD_KEEP_ALIVE",
|
|
"COMPONENT_KEPT_ALIVE": 512,
|
|
"512": "COMPONENT_KEPT_ALIVE",
|
|
"COMPONENT": 6,
|
|
"6": "COMPONENT"
|
|
};
|
|
const SlotFlags = {
|
|
"STABLE": 1,
|
|
"1": "STABLE",
|
|
"DYNAMIC": 2,
|
|
"2": "DYNAMIC",
|
|
"FORWARDED": 3,
|
|
"3": "FORWARDED"
|
|
};
|
|
const slotFlagsText = {
|
|
[1]: "STABLE",
|
|
[2]: "DYNAMIC",
|
|
[3]: "FORWARDED"
|
|
};
|
|
const GLOBALS_ALLOWED = "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error,Symbol";
|
|
const isGloballyAllowed = /* @__PURE__ */ makeMap(GLOBALS_ALLOWED);
|
|
const isGloballyWhitelisted = isGloballyAllowed;
|
|
const range = 2;
|
|
function generateCodeFrame(source, start = 0, end = source.length) {
|
|
start = Math.max(0, Math.min(start, source.length));
|
|
end = Math.max(0, Math.min(end, source.length));
|
|
if (start > end) return "";
|
|
let lines = source.split(/(\r?\n)/);
|
|
const newlineSequences = lines.filter((_, idx) => idx % 2 === 1);
|
|
lines = lines.filter((_, idx) => idx % 2 === 0);
|
|
let count = 0;
|
|
const res = [];
|
|
for (let i = 0; i < lines.length; i++) {
|
|
count += lines[i].length + (newlineSequences[i] && newlineSequences[i].length || 0);
|
|
if (count >= start) {
|
|
for (let j = i - range; j <= i + range || end > count; j++) {
|
|
if (j < 0 || j >= lines.length) continue;
|
|
const line = j + 1;
|
|
res.push(
|
|
`${line}${" ".repeat(Math.max(3 - String(line).length, 0))}| ${lines[j]}`
|
|
);
|
|
const lineLength = lines[j].length;
|
|
const newLineSeqLength = newlineSequences[j] && newlineSequences[j].length || 0;
|
|
if (j === i) {
|
|
const pad = start - (count - (lineLength + newLineSeqLength));
|
|
const length = Math.max(
|
|
1,
|
|
end > count ? lineLength - pad : end - start
|
|
);
|
|
res.push(` | ` + " ".repeat(pad) + "^".repeat(length));
|
|
} else if (j > i) {
|
|
if (end > count) {
|
|
const length = Math.max(Math.min(end - count, lineLength), 1);
|
|
res.push(` | ` + "^".repeat(length));
|
|
}
|
|
count += lineLength + newLineSeqLength;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
return res.join("\n");
|
|
}
|
|
function normalizeStyle(value) {
|
|
if (isArray$3(value)) {
|
|
const res = {};
|
|
for (let i = 0; i < value.length; i++) {
|
|
const item = value[i];
|
|
const normalized = isString$1(item) ? parseStringStyle(item) : normalizeStyle(item);
|
|
if (normalized) {
|
|
for (const key in normalized) {
|
|
res[key] = normalized[key];
|
|
}
|
|
}
|
|
}
|
|
return res;
|
|
} else if (isString$1(value) || isObject$2(value)) {
|
|
return value;
|
|
}
|
|
}
|
|
const listDelimiterRE = /;(?![^(]*\))/g;
|
|
const propertyDelimiterRE = /:([^]+)/;
|
|
const styleCommentRE = /\/\*[^]*?\*\//g;
|
|
function parseStringStyle(cssText) {
|
|
const ret = {};
|
|
cssText.replace(styleCommentRE, "").split(listDelimiterRE).forEach((item) => {
|
|
if (item) {
|
|
const tmp = item.split(propertyDelimiterRE);
|
|
tmp.length > 1 && (ret[tmp[0].trim()] = tmp[1].trim());
|
|
}
|
|
});
|
|
return ret;
|
|
}
|
|
function stringifyStyle(styles) {
|
|
if (!styles) return "";
|
|
if (isString$1(styles)) return styles;
|
|
let ret = "";
|
|
for (const key in styles) {
|
|
const value = styles[key];
|
|
if (isString$1(value) || typeof value === "number") {
|
|
const normalizedKey = key.startsWith(`--`) ? key : hyphenate(key);
|
|
ret += `${normalizedKey}:${value};`;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
function normalizeClass(value) {
|
|
let res = "";
|
|
if (isString$1(value)) {
|
|
res = value;
|
|
} else if (isArray$3(value)) {
|
|
for (let i = 0; i < value.length; i++) {
|
|
const normalized = normalizeClass(value[i]);
|
|
if (normalized) {
|
|
res += normalized + " ";
|
|
}
|
|
}
|
|
} else if (isObject$2(value)) {
|
|
for (const name in value) {
|
|
if (value[name]) {
|
|
res += name + " ";
|
|
}
|
|
}
|
|
}
|
|
return res.trim();
|
|
}
|
|
function normalizeProps(props) {
|
|
if (!props) return null;
|
|
let { class: klass, style: style2 } = props;
|
|
if (klass && !isString$1(klass)) {
|
|
props.class = normalizeClass(klass);
|
|
}
|
|
if (style2) {
|
|
props.style = normalizeStyle(style2);
|
|
}
|
|
return props;
|
|
}
|
|
const HTML_TAGS = "html,body,base,head,link,meta,style,title,address,article,aside,footer,header,hgroup,h1,h2,h3,h4,h5,h6,nav,section,div,dd,dl,dt,figcaption,figure,picture,hr,img,li,main,ol,p,pre,ul,a,b,abbr,bdi,bdo,br,cite,code,data,dfn,em,i,kbd,mark,q,rp,rt,ruby,s,samp,small,span,strong,sub,sup,time,u,var,wbr,area,audio,map,track,video,embed,object,param,source,canvas,script,noscript,del,ins,caption,col,colgroup,table,thead,tbody,td,th,tr,button,datalist,fieldset,form,input,label,legend,meter,optgroup,option,output,progress,select,textarea,details,dialog,menu,summary,template,blockquote,iframe,tfoot";
|
|
const SVG_TAGS = "svg,animate,animateMotion,animateTransform,circle,clipPath,color-profile,defs,desc,discard,ellipse,feBlend,feColorMatrix,feComponentTransfer,feComposite,feConvolveMatrix,feDiffuseLighting,feDisplacementMap,feDistantLight,feDropShadow,feFlood,feFuncA,feFuncB,feFuncG,feFuncR,feGaussianBlur,feImage,feMerge,feMergeNode,feMorphology,feOffset,fePointLight,feSpecularLighting,feSpotLight,feTile,feTurbulence,filter,foreignObject,g,hatch,hatchpath,image,line,linearGradient,marker,mask,mesh,meshgradient,meshpatch,meshrow,metadata,mpath,path,pattern,polygon,polyline,radialGradient,rect,set,solidcolor,stop,switch,symbol,text,textPath,title,tspan,unknown,use,view";
|
|
const MATH_TAGS = "annotation,annotation-xml,maction,maligngroup,malignmark,math,menclose,merror,mfenced,mfrac,mfraction,mglyph,mi,mlabeledtr,mlongdiv,mmultiscripts,mn,mo,mover,mpadded,mphantom,mprescripts,mroot,mrow,ms,mscarries,mscarry,msgroup,msline,mspace,msqrt,msrow,mstack,mstyle,msub,msubsup,msup,mtable,mtd,mtext,mtr,munder,munderover,none,semantics";
|
|
const VOID_TAGS = "area,base,br,col,embed,hr,img,input,link,meta,param,source,track,wbr";
|
|
const isHTMLTag = /* @__PURE__ */ makeMap(HTML_TAGS);
|
|
const isSVGTag = /* @__PURE__ */ makeMap(SVG_TAGS);
|
|
const isMathMLTag = /* @__PURE__ */ makeMap(MATH_TAGS);
|
|
const isVoidTag = /* @__PURE__ */ makeMap(VOID_TAGS);
|
|
const specialBooleanAttrs = `itemscope,allowfullscreen,formnovalidate,ismap,nomodule,novalidate,readonly`;
|
|
const isSpecialBooleanAttr = /* @__PURE__ */ makeMap(specialBooleanAttrs);
|
|
const isBooleanAttr = /* @__PURE__ */ makeMap(
|
|
specialBooleanAttrs + `,async,autofocus,autoplay,controls,default,defer,disabled,hidden,inert,loop,open,required,reversed,scoped,seamless,checked,muted,multiple,selected`
|
|
);
|
|
function includeBooleanAttr(value) {
|
|
return !!value || value === "";
|
|
}
|
|
const unsafeAttrCharRE = /[>/="'\u0009\u000a\u000c\u0020]/;
|
|
const attrValidationCache = {};
|
|
function isSSRSafeAttrName(name) {
|
|
if (attrValidationCache.hasOwnProperty(name)) {
|
|
return attrValidationCache[name];
|
|
}
|
|
const isUnsafe = unsafeAttrCharRE.test(name);
|
|
if (isUnsafe) {
|
|
console.error(`unsafe attribute name: ${name}`);
|
|
}
|
|
return attrValidationCache[name] = !isUnsafe;
|
|
}
|
|
const propsToAttrMap = {
|
|
acceptCharset: "accept-charset",
|
|
className: "class",
|
|
htmlFor: "for",
|
|
httpEquiv: "http-equiv"
|
|
};
|
|
const isKnownHtmlAttr = /* @__PURE__ */ makeMap(
|
|
`accept,accept-charset,accesskey,action,align,allow,alt,async,autocapitalize,autocomplete,autofocus,autoplay,background,bgcolor,border,buffered,capture,challenge,charset,checked,cite,class,code,codebase,color,cols,colspan,content,contenteditable,contextmenu,controls,coords,crossorigin,csp,data,datetime,decoding,default,defer,dir,dirname,disabled,download,draggable,dropzone,enctype,enterkeyhint,for,form,formaction,formenctype,formmethod,formnovalidate,formtarget,headers,height,hidden,high,href,hreflang,http-equiv,icon,id,importance,inert,integrity,ismap,itemprop,keytype,kind,label,lang,language,loading,list,loop,low,manifest,max,maxlength,minlength,media,min,multiple,muted,name,novalidate,open,optimum,pattern,ping,placeholder,poster,preload,radiogroup,readonly,referrerpolicy,rel,required,reversed,rows,rowspan,sandbox,scope,scoped,selected,shape,size,sizes,slot,span,spellcheck,src,srcdoc,srclang,srcset,start,step,style,summary,tabindex,target,title,translate,type,usemap,value,width,wrap`
|
|
);
|
|
const isKnownSvgAttr = /* @__PURE__ */ makeMap(
|
|
`xmlns,accent-height,accumulate,additive,alignment-baseline,alphabetic,amplitude,arabic-form,ascent,attributeName,attributeType,azimuth,baseFrequency,baseline-shift,baseProfile,bbox,begin,bias,by,calcMode,cap-height,class,clip,clipPathUnits,clip-path,clip-rule,color,color-interpolation,color-interpolation-filters,color-profile,color-rendering,contentScriptType,contentStyleType,crossorigin,cursor,cx,cy,d,decelerate,descent,diffuseConstant,direction,display,divisor,dominant-baseline,dur,dx,dy,edgeMode,elevation,enable-background,end,exponent,fill,fill-opacity,fill-rule,filter,filterRes,filterUnits,flood-color,flood-opacity,font-family,font-size,font-size-adjust,font-stretch,font-style,font-variant,font-weight,format,from,fr,fx,fy,g1,g2,glyph-name,glyph-orientation-horizontal,glyph-orientation-vertical,glyphRef,gradientTransform,gradientUnits,hanging,height,href,hreflang,horiz-adv-x,horiz-origin-x,id,ideographic,image-rendering,in,in2,intercept,k,k1,k2,k3,k4,kernelMatrix,kernelUnitLength,kerning,keyPoints,keySplines,keyTimes,lang,lengthAdjust,letter-spacing,lighting-color,limitingConeAngle,local,marker-end,marker-mid,marker-start,markerHeight,markerUnits,markerWidth,mask,maskContentUnits,maskUnits,mathematical,max,media,method,min,mode,name,numOctaves,offset,opacity,operator,order,orient,orientation,origin,overflow,overline-position,overline-thickness,panose-1,paint-order,path,pathLength,patternContentUnits,patternTransform,patternUnits,ping,pointer-events,points,pointsAtX,pointsAtY,pointsAtZ,preserveAlpha,preserveAspectRatio,primitiveUnits,r,radius,referrerPolicy,refX,refY,rel,rendering-intent,repeatCount,repeatDur,requiredExtensions,requiredFeatures,restart,result,rotate,rx,ry,scale,seed,shape-rendering,slope,spacing,specularConstant,specularExponent,speed,spreadMethod,startOffset,stdDeviation,stemh,stemv,stitchTiles,stop-color,stop-opacity,strikethrough-position,strikethrough-thickness,string,stroke,stroke-dasharray,stroke-dashoffset,stroke-linecap,stroke-linejoin,stroke-miterlimit,stroke-opacity,stroke-width,style,surfaceScale,systemLanguage,tabindex,tableValues,target,targetX,targetY,text-anchor,text-decoration,text-rendering,textLength,to,transform,transform-origin,type,u1,u2,underline-position,underline-thickness,unicode,unicode-bidi,unicode-range,units-per-em,v-alphabetic,v-hanging,v-ideographic,v-mathematical,values,vector-effect,version,vert-adv-y,vert-origin-x,vert-origin-y,viewBox,viewTarget,visibility,width,widths,word-spacing,writing-mode,x,x-height,x1,x2,xChannelSelector,xlink:actuate,xlink:arcrole,xlink:href,xlink:role,xlink:show,xlink:title,xlink:type,xmlns:xlink,xml:base,xml:lang,xml:space,y,y1,y2,yChannelSelector,z,zoomAndPan`
|
|
);
|
|
const isKnownMathMLAttr = /* @__PURE__ */ makeMap(
|
|
`accent,accentunder,actiontype,align,alignmentscope,altimg,altimg-height,altimg-valign,altimg-width,alttext,bevelled,close,columnsalign,columnlines,columnspan,denomalign,depth,dir,display,displaystyle,encoding,equalcolumns,equalrows,fence,fontstyle,fontweight,form,frame,framespacing,groupalign,height,href,id,indentalign,indentalignfirst,indentalignlast,indentshift,indentshiftfirst,indentshiftlast,indextype,justify,largetop,largeop,lquote,lspace,mathbackground,mathcolor,mathsize,mathvariant,maxsize,minlabelspacing,mode,other,overflow,position,rowalign,rowlines,rowspan,rquote,rspace,scriptlevel,scriptminsize,scriptsizemultiplier,selection,separator,separators,shift,side,src,stackalign,stretchy,subscriptshift,superscriptshift,symmetric,voffset,width,widths,xlink:href,xlink:show,xlink:type,xmlns`
|
|
);
|
|
function isRenderableAttrValue(value) {
|
|
if (value == null) {
|
|
return false;
|
|
}
|
|
const type = typeof value;
|
|
return type === "string" || type === "number" || type === "boolean";
|
|
}
|
|
const escapeRE = /["'&<>]/;
|
|
function escapeHtml(string) {
|
|
const str = "" + string;
|
|
const match2 = escapeRE.exec(str);
|
|
if (!match2) {
|
|
return str;
|
|
}
|
|
let html = "";
|
|
let escaped;
|
|
let index;
|
|
let lastIndex = 0;
|
|
for (index = match2.index; index < str.length; index++) {
|
|
switch (str.charCodeAt(index)) {
|
|
case 34:
|
|
escaped = """;
|
|
break;
|
|
case 38:
|
|
escaped = "&";
|
|
break;
|
|
case 39:
|
|
escaped = "'";
|
|
break;
|
|
case 60:
|
|
escaped = "<";
|
|
break;
|
|
case 62:
|
|
escaped = ">";
|
|
break;
|
|
default:
|
|
continue;
|
|
}
|
|
if (lastIndex !== index) {
|
|
html += str.slice(lastIndex, index);
|
|
}
|
|
lastIndex = index + 1;
|
|
html += escaped;
|
|
}
|
|
return lastIndex !== index ? html + str.slice(lastIndex, index) : html;
|
|
}
|
|
const commentStripRE = /^-?>|<!--|-->|--!>|<!-$/g;
|
|
function escapeHtmlComment(src) {
|
|
return src.replace(commentStripRE, "");
|
|
}
|
|
const cssVarNameEscapeSymbolsRE = /[ !"#$%&'()*+,./:;<=>?@[\\\]^`{|}~]/g;
|
|
function getEscapedCssVarName(key, doubleEscape) {
|
|
return key.replace(
|
|
cssVarNameEscapeSymbolsRE,
|
|
(s) => doubleEscape ? s === '"' ? '\\\\\\"' : `\\\\${s}` : `\\${s}`
|
|
);
|
|
}
|
|
function looseCompareArrays(a, b) {
|
|
if (a.length !== b.length) return false;
|
|
let equal = true;
|
|
for (let i = 0; equal && i < a.length; i++) {
|
|
equal = looseEqual(a[i], b[i]);
|
|
}
|
|
return equal;
|
|
}
|
|
function looseEqual(a, b) {
|
|
if (a === b) return true;
|
|
let aValidType = isDate$1(a);
|
|
let bValidType = isDate$1(b);
|
|
if (aValidType || bValidType) {
|
|
return aValidType && bValidType ? a.getTime() === b.getTime() : false;
|
|
}
|
|
aValidType = isSymbol$1(a);
|
|
bValidType = isSymbol$1(b);
|
|
if (aValidType || bValidType) {
|
|
return a === b;
|
|
}
|
|
aValidType = isArray$3(a);
|
|
bValidType = isArray$3(b);
|
|
if (aValidType || bValidType) {
|
|
return aValidType && bValidType ? looseCompareArrays(a, b) : false;
|
|
}
|
|
aValidType = isObject$2(a);
|
|
bValidType = isObject$2(b);
|
|
if (aValidType || bValidType) {
|
|
if (!aValidType || !bValidType) {
|
|
return false;
|
|
}
|
|
const aKeysCount = Object.keys(a).length;
|
|
const bKeysCount = Object.keys(b).length;
|
|
if (aKeysCount !== bKeysCount) {
|
|
return false;
|
|
}
|
|
for (const key in a) {
|
|
const aHasKey = a.hasOwnProperty(key);
|
|
const bHasKey = b.hasOwnProperty(key);
|
|
if (aHasKey && !bHasKey || !aHasKey && bHasKey || !looseEqual(a[key], b[key])) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return String(a) === String(b);
|
|
}
|
|
function looseIndexOf(arr, val) {
|
|
return arr.findIndex((item) => looseEqual(item, val));
|
|
}
|
|
const isRef$1 = (val) => {
|
|
return !!(val && val["__v_isRef"] === true);
|
|
};
|
|
const toDisplayString = (val) => {
|
|
return isString$1(val) ? val : val == null ? "" : isArray$3(val) || isObject$2(val) && (val.toString === objectToString$1 || !isFunction$2(val.toString)) ? isRef$1(val) ? toDisplayString(val.value) : JSON.stringify(val, replacer, 2) : String(val);
|
|
};
|
|
const replacer = (_key, val) => {
|
|
if (isRef$1(val)) {
|
|
return replacer(_key, val.value);
|
|
} else if (isMap(val)) {
|
|
return {
|
|
[`Map(${val.size})`]: [...val.entries()].reduce(
|
|
(entries, [key, val2], i) => {
|
|
entries[stringifySymbol(key, i) + " =>"] = val2;
|
|
return entries;
|
|
},
|
|
{}
|
|
)
|
|
};
|
|
} else if (isSet(val)) {
|
|
return {
|
|
[`Set(${val.size})`]: [...val.values()].map((v) => stringifySymbol(v))
|
|
};
|
|
} else if (isSymbol$1(val)) {
|
|
return stringifySymbol(val);
|
|
} else if (isObject$2(val) && !isArray$3(val) && !isPlainObject$3(val)) {
|
|
return String(val);
|
|
}
|
|
return val;
|
|
};
|
|
const stringifySymbol = (v, i = "") => {
|
|
var _a;
|
|
return (
|
|
// Symbol.description in es2019+ so we need to cast here to pass
|
|
// the lib: es2016 check
|
|
isSymbol$1(v) ? `Symbol(${(_a = v.description) != null ? _a : i})` : v
|
|
);
|
|
};
|
|
const shared_esmBundler = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
EMPTY_ARR,
|
|
EMPTY_OBJ,
|
|
NO,
|
|
NOOP,
|
|
PatchFlagNames,
|
|
PatchFlags,
|
|
ShapeFlags,
|
|
SlotFlags,
|
|
camelize,
|
|
capitalize,
|
|
cssVarNameEscapeSymbolsRE,
|
|
def,
|
|
escapeHtml,
|
|
escapeHtmlComment,
|
|
extend: extend$1,
|
|
genCacheKey,
|
|
genPropsAccessExp,
|
|
generateCodeFrame,
|
|
getEscapedCssVarName,
|
|
getGlobalThis,
|
|
hasChanged,
|
|
hasOwn,
|
|
hyphenate,
|
|
includeBooleanAttr,
|
|
invokeArrayFns,
|
|
isArray: isArray$3,
|
|
isBooleanAttr,
|
|
isBuiltInDirective,
|
|
isDate: isDate$1,
|
|
isFunction: isFunction$2,
|
|
isGloballyAllowed,
|
|
isGloballyWhitelisted,
|
|
isHTMLTag,
|
|
isIntegerKey,
|
|
isKnownHtmlAttr,
|
|
isKnownMathMLAttr,
|
|
isKnownSvgAttr,
|
|
isMap,
|
|
isMathMLTag,
|
|
isModelListener,
|
|
isObject: isObject$2,
|
|
isOn,
|
|
isPlainObject: isPlainObject$3,
|
|
isPromise,
|
|
isRegExp: isRegExp$1,
|
|
isRenderableAttrValue,
|
|
isReservedProp,
|
|
isSSRSafeAttrName,
|
|
isSVGTag,
|
|
isSet,
|
|
isSpecialBooleanAttr,
|
|
isString: isString$1,
|
|
isSymbol: isSymbol$1,
|
|
isVoidTag,
|
|
looseEqual,
|
|
looseIndexOf,
|
|
looseToNumber,
|
|
makeMap,
|
|
normalizeClass,
|
|
normalizeProps,
|
|
normalizeStyle,
|
|
objectToString: objectToString$1,
|
|
parseStringStyle,
|
|
propsToAttrMap,
|
|
remove,
|
|
slotFlagsText,
|
|
stringifyStyle,
|
|
toDisplayString,
|
|
toHandlerKey,
|
|
toNumber,
|
|
toRawType,
|
|
toTypeString
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
/**
|
|
* @vue/reactivity v3.5.13
|
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
* @license MIT
|
|
**/
|
|
let activeEffectScope;
|
|
class EffectScope {
|
|
constructor(detached = false) {
|
|
this.detached = detached;
|
|
this._active = true;
|
|
this.effects = [];
|
|
this.cleanups = [];
|
|
this._isPaused = false;
|
|
this.parent = activeEffectScope;
|
|
if (!detached && activeEffectScope) {
|
|
this.index = (activeEffectScope.scopes || (activeEffectScope.scopes = [])).push(
|
|
this
|
|
) - 1;
|
|
}
|
|
}
|
|
get active() {
|
|
return this._active;
|
|
}
|
|
pause() {
|
|
if (this._active) {
|
|
this._isPaused = true;
|
|
let i, l;
|
|
if (this.scopes) {
|
|
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
this.scopes[i].pause();
|
|
}
|
|
}
|
|
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
this.effects[i].pause();
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* Resumes the effect scope, including all child scopes and effects.
|
|
*/
|
|
resume() {
|
|
if (this._active) {
|
|
if (this._isPaused) {
|
|
this._isPaused = false;
|
|
let i, l;
|
|
if (this.scopes) {
|
|
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
this.scopes[i].resume();
|
|
}
|
|
}
|
|
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
this.effects[i].resume();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
run(fn) {
|
|
if (this._active) {
|
|
const currentEffectScope = activeEffectScope;
|
|
try {
|
|
activeEffectScope = this;
|
|
return fn();
|
|
} finally {
|
|
activeEffectScope = currentEffectScope;
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* This should only be called on non-detached scopes
|
|
* @internal
|
|
*/
|
|
on() {
|
|
activeEffectScope = this;
|
|
}
|
|
/**
|
|
* This should only be called on non-detached scopes
|
|
* @internal
|
|
*/
|
|
off() {
|
|
activeEffectScope = this.parent;
|
|
}
|
|
stop(fromParent) {
|
|
if (this._active) {
|
|
this._active = false;
|
|
let i, l;
|
|
for (i = 0, l = this.effects.length; i < l; i++) {
|
|
this.effects[i].stop();
|
|
}
|
|
this.effects.length = 0;
|
|
for (i = 0, l = this.cleanups.length; i < l; i++) {
|
|
this.cleanups[i]();
|
|
}
|
|
this.cleanups.length = 0;
|
|
if (this.scopes) {
|
|
for (i = 0, l = this.scopes.length; i < l; i++) {
|
|
this.scopes[i].stop(true);
|
|
}
|
|
this.scopes.length = 0;
|
|
}
|
|
if (!this.detached && this.parent && !fromParent) {
|
|
const last = this.parent.scopes.pop();
|
|
if (last && last !== this) {
|
|
this.parent.scopes[this.index] = last;
|
|
last.index = this.index;
|
|
}
|
|
}
|
|
this.parent = void 0;
|
|
}
|
|
}
|
|
}
|
|
function effectScope(detached) {
|
|
return new EffectScope(detached);
|
|
}
|
|
function getCurrentScope() {
|
|
return activeEffectScope;
|
|
}
|
|
function onScopeDispose(fn, failSilently = false) {
|
|
if (activeEffectScope) {
|
|
activeEffectScope.cleanups.push(fn);
|
|
}
|
|
}
|
|
let activeSub;
|
|
const pausedQueueEffects = /* @__PURE__ */ new WeakSet();
|
|
class ReactiveEffect {
|
|
constructor(fn) {
|
|
this.fn = fn;
|
|
this.deps = void 0;
|
|
this.depsTail = void 0;
|
|
this.flags = 1 | 4;
|
|
this.next = void 0;
|
|
this.cleanup = void 0;
|
|
this.scheduler = void 0;
|
|
if (activeEffectScope && activeEffectScope.active) {
|
|
activeEffectScope.effects.push(this);
|
|
}
|
|
}
|
|
pause() {
|
|
this.flags |= 64;
|
|
}
|
|
resume() {
|
|
if (this.flags & 64) {
|
|
this.flags &= -65;
|
|
if (pausedQueueEffects.has(this)) {
|
|
pausedQueueEffects.delete(this);
|
|
this.trigger();
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* @internal
|
|
*/
|
|
notify() {
|
|
if (this.flags & 2 && !(this.flags & 32)) {
|
|
return;
|
|
}
|
|
if (!(this.flags & 8)) {
|
|
batch(this);
|
|
}
|
|
}
|
|
run() {
|
|
if (!(this.flags & 1)) {
|
|
return this.fn();
|
|
}
|
|
this.flags |= 2;
|
|
cleanupEffect(this);
|
|
prepareDeps(this);
|
|
const prevEffect = activeSub;
|
|
const prevShouldTrack = shouldTrack;
|
|
activeSub = this;
|
|
shouldTrack = true;
|
|
try {
|
|
return this.fn();
|
|
} finally {
|
|
cleanupDeps(this);
|
|
activeSub = prevEffect;
|
|
shouldTrack = prevShouldTrack;
|
|
this.flags &= -3;
|
|
}
|
|
}
|
|
stop() {
|
|
if (this.flags & 1) {
|
|
for (let link = this.deps; link; link = link.nextDep) {
|
|
removeSub(link);
|
|
}
|
|
this.deps = this.depsTail = void 0;
|
|
cleanupEffect(this);
|
|
this.onStop && this.onStop();
|
|
this.flags &= -2;
|
|
}
|
|
}
|
|
trigger() {
|
|
if (this.flags & 64) {
|
|
pausedQueueEffects.add(this);
|
|
} else if (this.scheduler) {
|
|
this.scheduler();
|
|
} else {
|
|
this.runIfDirty();
|
|
}
|
|
}
|
|
/**
|
|
* @internal
|
|
*/
|
|
runIfDirty() {
|
|
if (isDirty(this)) {
|
|
this.run();
|
|
}
|
|
}
|
|
get dirty() {
|
|
return isDirty(this);
|
|
}
|
|
}
|
|
let batchDepth = 0;
|
|
let batchedSub;
|
|
let batchedComputed;
|
|
function batch(sub, isComputed2 = false) {
|
|
sub.flags |= 8;
|
|
if (isComputed2) {
|
|
sub.next = batchedComputed;
|
|
batchedComputed = sub;
|
|
return;
|
|
}
|
|
sub.next = batchedSub;
|
|
batchedSub = sub;
|
|
}
|
|
function startBatch() {
|
|
batchDepth++;
|
|
}
|
|
function endBatch() {
|
|
if (--batchDepth > 0) {
|
|
return;
|
|
}
|
|
if (batchedComputed) {
|
|
let e = batchedComputed;
|
|
batchedComputed = void 0;
|
|
while (e) {
|
|
const next = e.next;
|
|
e.next = void 0;
|
|
e.flags &= -9;
|
|
e = next;
|
|
}
|
|
}
|
|
let error2;
|
|
while (batchedSub) {
|
|
let e = batchedSub;
|
|
batchedSub = void 0;
|
|
while (e) {
|
|
const next = e.next;
|
|
e.next = void 0;
|
|
e.flags &= -9;
|
|
if (e.flags & 1) {
|
|
try {
|
|
;
|
|
e.trigger();
|
|
} catch (err) {
|
|
if (!error2) error2 = err;
|
|
}
|
|
}
|
|
e = next;
|
|
}
|
|
}
|
|
if (error2) throw error2;
|
|
}
|
|
function prepareDeps(sub) {
|
|
for (let link = sub.deps; link; link = link.nextDep) {
|
|
link.version = -1;
|
|
link.prevActiveLink = link.dep.activeLink;
|
|
link.dep.activeLink = link;
|
|
}
|
|
}
|
|
function cleanupDeps(sub) {
|
|
let head;
|
|
let tail = sub.depsTail;
|
|
let link = tail;
|
|
while (link) {
|
|
const prev = link.prevDep;
|
|
if (link.version === -1) {
|
|
if (link === tail) tail = prev;
|
|
removeSub(link);
|
|
removeDep(link);
|
|
} else {
|
|
head = link;
|
|
}
|
|
link.dep.activeLink = link.prevActiveLink;
|
|
link.prevActiveLink = void 0;
|
|
link = prev;
|
|
}
|
|
sub.deps = head;
|
|
sub.depsTail = tail;
|
|
}
|
|
function isDirty(sub) {
|
|
for (let link = sub.deps; link; link = link.nextDep) {
|
|
if (link.dep.version !== link.version || link.dep.computed && (refreshComputed(link.dep.computed) || link.dep.version !== link.version)) {
|
|
return true;
|
|
}
|
|
}
|
|
if (sub._dirty) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function refreshComputed(computed2) {
|
|
if (computed2.flags & 4 && !(computed2.flags & 16)) {
|
|
return;
|
|
}
|
|
computed2.flags &= -17;
|
|
if (computed2.globalVersion === globalVersion) {
|
|
return;
|
|
}
|
|
computed2.globalVersion = globalVersion;
|
|
const dep = computed2.dep;
|
|
computed2.flags |= 2;
|
|
if (dep.version > 0 && !computed2.isSSR && computed2.deps && !isDirty(computed2)) {
|
|
computed2.flags &= -3;
|
|
return;
|
|
}
|
|
const prevSub = activeSub;
|
|
const prevShouldTrack = shouldTrack;
|
|
activeSub = computed2;
|
|
shouldTrack = true;
|
|
try {
|
|
prepareDeps(computed2);
|
|
const value = computed2.fn(computed2._value);
|
|
if (dep.version === 0 || hasChanged(value, computed2._value)) {
|
|
computed2._value = value;
|
|
dep.version++;
|
|
}
|
|
} catch (err) {
|
|
dep.version++;
|
|
throw err;
|
|
} finally {
|
|
activeSub = prevSub;
|
|
shouldTrack = prevShouldTrack;
|
|
cleanupDeps(computed2);
|
|
computed2.flags &= -3;
|
|
}
|
|
}
|
|
function removeSub(link, soft = false) {
|
|
const { dep, prevSub, nextSub } = link;
|
|
if (prevSub) {
|
|
prevSub.nextSub = nextSub;
|
|
link.prevSub = void 0;
|
|
}
|
|
if (nextSub) {
|
|
nextSub.prevSub = prevSub;
|
|
link.nextSub = void 0;
|
|
}
|
|
if (dep.subs === link) {
|
|
dep.subs = prevSub;
|
|
if (!prevSub && dep.computed) {
|
|
dep.computed.flags &= -5;
|
|
for (let l = dep.computed.deps; l; l = l.nextDep) {
|
|
removeSub(l, true);
|
|
}
|
|
}
|
|
}
|
|
if (!soft && !--dep.sc && dep.map) {
|
|
dep.map.delete(dep.key);
|
|
}
|
|
}
|
|
function removeDep(link) {
|
|
const { prevDep, nextDep } = link;
|
|
if (prevDep) {
|
|
prevDep.nextDep = nextDep;
|
|
link.prevDep = void 0;
|
|
}
|
|
if (nextDep) {
|
|
nextDep.prevDep = prevDep;
|
|
link.nextDep = void 0;
|
|
}
|
|
}
|
|
function effect(fn, options) {
|
|
if (fn.effect instanceof ReactiveEffect) {
|
|
fn = fn.effect.fn;
|
|
}
|
|
const e = new ReactiveEffect(fn);
|
|
if (options) {
|
|
extend$1(e, options);
|
|
}
|
|
try {
|
|
e.run();
|
|
} catch (err) {
|
|
e.stop();
|
|
throw err;
|
|
}
|
|
const runner = e.run.bind(e);
|
|
runner.effect = e;
|
|
return runner;
|
|
}
|
|
function stop(runner) {
|
|
runner.effect.stop();
|
|
}
|
|
let shouldTrack = true;
|
|
const trackStack = [];
|
|
function pauseTracking() {
|
|
trackStack.push(shouldTrack);
|
|
shouldTrack = false;
|
|
}
|
|
function resetTracking() {
|
|
const last = trackStack.pop();
|
|
shouldTrack = last === void 0 ? true : last;
|
|
}
|
|
function cleanupEffect(e) {
|
|
const { cleanup } = e;
|
|
e.cleanup = void 0;
|
|
if (cleanup) {
|
|
const prevSub = activeSub;
|
|
activeSub = void 0;
|
|
try {
|
|
cleanup();
|
|
} finally {
|
|
activeSub = prevSub;
|
|
}
|
|
}
|
|
}
|
|
let globalVersion = 0;
|
|
class Link {
|
|
constructor(sub, dep) {
|
|
this.sub = sub;
|
|
this.dep = dep;
|
|
this.version = dep.version;
|
|
this.nextDep = this.prevDep = this.nextSub = this.prevSub = this.prevActiveLink = void 0;
|
|
}
|
|
}
|
|
class Dep {
|
|
constructor(computed2) {
|
|
this.computed = computed2;
|
|
this.version = 0;
|
|
this.activeLink = void 0;
|
|
this.subs = void 0;
|
|
this.map = void 0;
|
|
this.key = void 0;
|
|
this.sc = 0;
|
|
}
|
|
track(debugInfo) {
|
|
if (!activeSub || !shouldTrack || activeSub === this.computed) {
|
|
return;
|
|
}
|
|
let link = this.activeLink;
|
|
if (link === void 0 || link.sub !== activeSub) {
|
|
link = this.activeLink = new Link(activeSub, this);
|
|
if (!activeSub.deps) {
|
|
activeSub.deps = activeSub.depsTail = link;
|
|
} else {
|
|
link.prevDep = activeSub.depsTail;
|
|
activeSub.depsTail.nextDep = link;
|
|
activeSub.depsTail = link;
|
|
}
|
|
addSub(link);
|
|
} else if (link.version === -1) {
|
|
link.version = this.version;
|
|
if (link.nextDep) {
|
|
const next = link.nextDep;
|
|
next.prevDep = link.prevDep;
|
|
if (link.prevDep) {
|
|
link.prevDep.nextDep = next;
|
|
}
|
|
link.prevDep = activeSub.depsTail;
|
|
link.nextDep = void 0;
|
|
activeSub.depsTail.nextDep = link;
|
|
activeSub.depsTail = link;
|
|
if (activeSub.deps === link) {
|
|
activeSub.deps = next;
|
|
}
|
|
}
|
|
}
|
|
return link;
|
|
}
|
|
trigger(debugInfo) {
|
|
this.version++;
|
|
globalVersion++;
|
|
this.notify(debugInfo);
|
|
}
|
|
notify(debugInfo) {
|
|
startBatch();
|
|
try {
|
|
if (false) ;
|
|
for (let link = this.subs; link; link = link.prevSub) {
|
|
if (link.sub.notify()) {
|
|
;
|
|
link.sub.dep.notify();
|
|
}
|
|
}
|
|
} finally {
|
|
endBatch();
|
|
}
|
|
}
|
|
}
|
|
function addSub(link) {
|
|
link.dep.sc++;
|
|
if (link.sub.flags & 4) {
|
|
const computed2 = link.dep.computed;
|
|
if (computed2 && !link.dep.subs) {
|
|
computed2.flags |= 4 | 16;
|
|
for (let l = computed2.deps; l; l = l.nextDep) {
|
|
addSub(l);
|
|
}
|
|
}
|
|
const currentTail = link.dep.subs;
|
|
if (currentTail !== link) {
|
|
link.prevSub = currentTail;
|
|
if (currentTail) currentTail.nextSub = link;
|
|
}
|
|
link.dep.subs = link;
|
|
}
|
|
}
|
|
const targetMap = /* @__PURE__ */ new WeakMap();
|
|
const ITERATE_KEY = Symbol(
|
|
""
|
|
);
|
|
const MAP_KEY_ITERATE_KEY = Symbol(
|
|
""
|
|
);
|
|
const ARRAY_ITERATE_KEY = Symbol(
|
|
""
|
|
);
|
|
function track(target, type, key) {
|
|
if (shouldTrack && activeSub) {
|
|
let depsMap = targetMap.get(target);
|
|
if (!depsMap) {
|
|
targetMap.set(target, depsMap = /* @__PURE__ */ new Map());
|
|
}
|
|
let dep = depsMap.get(key);
|
|
if (!dep) {
|
|
depsMap.set(key, dep = new Dep());
|
|
dep.map = depsMap;
|
|
dep.key = key;
|
|
}
|
|
{
|
|
dep.track();
|
|
}
|
|
}
|
|
}
|
|
function trigger$1(target, type, key, newValue, oldValue, oldTarget) {
|
|
const depsMap = targetMap.get(target);
|
|
if (!depsMap) {
|
|
globalVersion++;
|
|
return;
|
|
}
|
|
const run = (dep) => {
|
|
if (dep) {
|
|
{
|
|
dep.trigger();
|
|
}
|
|
}
|
|
};
|
|
startBatch();
|
|
if (type === "clear") {
|
|
depsMap.forEach(run);
|
|
} else {
|
|
const targetIsArray = isArray$3(target);
|
|
const isArrayIndex = targetIsArray && isIntegerKey(key);
|
|
if (targetIsArray && key === "length") {
|
|
const newLength = Number(newValue);
|
|
depsMap.forEach((dep, key2) => {
|
|
if (key2 === "length" || key2 === ARRAY_ITERATE_KEY || !isSymbol$1(key2) && key2 >= newLength) {
|
|
run(dep);
|
|
}
|
|
});
|
|
} else {
|
|
if (key !== void 0 || depsMap.has(void 0)) {
|
|
run(depsMap.get(key));
|
|
}
|
|
if (isArrayIndex) {
|
|
run(depsMap.get(ARRAY_ITERATE_KEY));
|
|
}
|
|
switch (type) {
|
|
case "add":
|
|
if (!targetIsArray) {
|
|
run(depsMap.get(ITERATE_KEY));
|
|
if (isMap(target)) {
|
|
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
}
|
|
} else if (isArrayIndex) {
|
|
run(depsMap.get("length"));
|
|
}
|
|
break;
|
|
case "delete":
|
|
if (!targetIsArray) {
|
|
run(depsMap.get(ITERATE_KEY));
|
|
if (isMap(target)) {
|
|
run(depsMap.get(MAP_KEY_ITERATE_KEY));
|
|
}
|
|
}
|
|
break;
|
|
case "set":
|
|
if (isMap(target)) {
|
|
run(depsMap.get(ITERATE_KEY));
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
endBatch();
|
|
}
|
|
function getDepFromReactive(object, key) {
|
|
const depMap = targetMap.get(object);
|
|
return depMap && depMap.get(key);
|
|
}
|
|
function reactiveReadArray(array) {
|
|
const raw = toRaw(array);
|
|
if (raw === array) return raw;
|
|
track(raw, "iterate", ARRAY_ITERATE_KEY);
|
|
return isShallow(array) ? raw : raw.map(toReactive);
|
|
}
|
|
function shallowReadArray(arr) {
|
|
track(arr = toRaw(arr), "iterate", ARRAY_ITERATE_KEY);
|
|
return arr;
|
|
}
|
|
const arrayInstrumentations = {
|
|
__proto__: null,
|
|
[Symbol.iterator]() {
|
|
return iterator(this, Symbol.iterator, toReactive);
|
|
},
|
|
concat(...args) {
|
|
return reactiveReadArray(this).concat(
|
|
...args.map((x) => isArray$3(x) ? reactiveReadArray(x) : x)
|
|
);
|
|
},
|
|
entries() {
|
|
return iterator(this, "entries", (value) => {
|
|
value[1] = toReactive(value[1]);
|
|
return value;
|
|
});
|
|
},
|
|
every(fn, thisArg) {
|
|
return apply$1(this, "every", fn, thisArg, void 0, arguments);
|
|
},
|
|
filter(fn, thisArg) {
|
|
return apply$1(this, "filter", fn, thisArg, (v) => v.map(toReactive), arguments);
|
|
},
|
|
find(fn, thisArg) {
|
|
return apply$1(this, "find", fn, thisArg, toReactive, arguments);
|
|
},
|
|
findIndex(fn, thisArg) {
|
|
return apply$1(this, "findIndex", fn, thisArg, void 0, arguments);
|
|
},
|
|
findLast(fn, thisArg) {
|
|
return apply$1(this, "findLast", fn, thisArg, toReactive, arguments);
|
|
},
|
|
findLastIndex(fn, thisArg) {
|
|
return apply$1(this, "findLastIndex", fn, thisArg, void 0, arguments);
|
|
},
|
|
// flat, flatMap could benefit from ARRAY_ITERATE but are not straight-forward to implement
|
|
forEach(fn, thisArg) {
|
|
return apply$1(this, "forEach", fn, thisArg, void 0, arguments);
|
|
},
|
|
includes(...args) {
|
|
return searchProxy(this, "includes", args);
|
|
},
|
|
indexOf(...args) {
|
|
return searchProxy(this, "indexOf", args);
|
|
},
|
|
join(separator) {
|
|
return reactiveReadArray(this).join(separator);
|
|
},
|
|
// keys() iterator only reads `length`, no optimisation required
|
|
lastIndexOf(...args) {
|
|
return searchProxy(this, "lastIndexOf", args);
|
|
},
|
|
map(fn, thisArg) {
|
|
return apply$1(this, "map", fn, thisArg, void 0, arguments);
|
|
},
|
|
pop() {
|
|
return noTracking(this, "pop");
|
|
},
|
|
push(...args) {
|
|
return noTracking(this, "push", args);
|
|
},
|
|
reduce(fn, ...args) {
|
|
return reduce(this, "reduce", fn, args);
|
|
},
|
|
reduceRight(fn, ...args) {
|
|
return reduce(this, "reduceRight", fn, args);
|
|
},
|
|
shift() {
|
|
return noTracking(this, "shift");
|
|
},
|
|
// slice could use ARRAY_ITERATE but also seems to beg for range tracking
|
|
some(fn, thisArg) {
|
|
return apply$1(this, "some", fn, thisArg, void 0, arguments);
|
|
},
|
|
splice(...args) {
|
|
return noTracking(this, "splice", args);
|
|
},
|
|
toReversed() {
|
|
return reactiveReadArray(this).toReversed();
|
|
},
|
|
toSorted(comparer) {
|
|
return reactiveReadArray(this).toSorted(comparer);
|
|
},
|
|
toSpliced(...args) {
|
|
return reactiveReadArray(this).toSpliced(...args);
|
|
},
|
|
unshift(...args) {
|
|
return noTracking(this, "unshift", args);
|
|
},
|
|
values() {
|
|
return iterator(this, "values", toReactive);
|
|
}
|
|
};
|
|
function iterator(self2, method, wrapValue) {
|
|
const arr = shallowReadArray(self2);
|
|
const iter = arr[method]();
|
|
if (arr !== self2 && !isShallow(self2)) {
|
|
iter._next = iter.next;
|
|
iter.next = () => {
|
|
const result = iter._next();
|
|
if (result.value) {
|
|
result.value = wrapValue(result.value);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
return iter;
|
|
}
|
|
const arrayProto$1 = Array.prototype;
|
|
function apply$1(self2, method, fn, thisArg, wrappedRetFn, args) {
|
|
const arr = shallowReadArray(self2);
|
|
const needsWrap = arr !== self2 && !isShallow(self2);
|
|
const methodFn = arr[method];
|
|
if (methodFn !== arrayProto$1[method]) {
|
|
const result2 = methodFn.apply(self2, args);
|
|
return needsWrap ? toReactive(result2) : result2;
|
|
}
|
|
let wrappedFn = fn;
|
|
if (arr !== self2) {
|
|
if (needsWrap) {
|
|
wrappedFn = function(item, index) {
|
|
return fn.call(this, toReactive(item), index, self2);
|
|
};
|
|
} else if (fn.length > 2) {
|
|
wrappedFn = function(item, index) {
|
|
return fn.call(this, item, index, self2);
|
|
};
|
|
}
|
|
}
|
|
const result = methodFn.call(arr, wrappedFn, thisArg);
|
|
return needsWrap && wrappedRetFn ? wrappedRetFn(result) : result;
|
|
}
|
|
function reduce(self2, method, fn, args) {
|
|
const arr = shallowReadArray(self2);
|
|
let wrappedFn = fn;
|
|
if (arr !== self2) {
|
|
if (!isShallow(self2)) {
|
|
wrappedFn = function(acc, item, index) {
|
|
return fn.call(this, acc, toReactive(item), index, self2);
|
|
};
|
|
} else if (fn.length > 3) {
|
|
wrappedFn = function(acc, item, index) {
|
|
return fn.call(this, acc, item, index, self2);
|
|
};
|
|
}
|
|
}
|
|
return arr[method](wrappedFn, ...args);
|
|
}
|
|
function searchProxy(self2, method, args) {
|
|
const arr = toRaw(self2);
|
|
track(arr, "iterate", ARRAY_ITERATE_KEY);
|
|
const res = arr[method](...args);
|
|
if ((res === -1 || res === false) && isProxy(args[0])) {
|
|
args[0] = toRaw(args[0]);
|
|
return arr[method](...args);
|
|
}
|
|
return res;
|
|
}
|
|
function noTracking(self2, method, args = []) {
|
|
pauseTracking();
|
|
startBatch();
|
|
const res = toRaw(self2)[method].apply(self2, args);
|
|
endBatch();
|
|
resetTracking();
|
|
return res;
|
|
}
|
|
const isNonTrackableKeys = /* @__PURE__ */ makeMap(`__proto__,__v_isRef,__isVue`);
|
|
const builtInSymbols = new Set(
|
|
/* @__PURE__ */ Object.getOwnPropertyNames(Symbol).filter((key) => key !== "arguments" && key !== "caller").map((key) => Symbol[key]).filter(isSymbol$1)
|
|
);
|
|
function hasOwnProperty$b(key) {
|
|
if (!isSymbol$1(key)) key = String(key);
|
|
const obj = toRaw(this);
|
|
track(obj, "has", key);
|
|
return obj.hasOwnProperty(key);
|
|
}
|
|
class BaseReactiveHandler {
|
|
constructor(_isReadonly = false, _isShallow = false) {
|
|
this._isReadonly = _isReadonly;
|
|
this._isShallow = _isShallow;
|
|
}
|
|
get(target, key, receiver) {
|
|
if (key === "__v_skip") return target["__v_skip"];
|
|
const isReadonly2 = this._isReadonly, isShallow2 = this._isShallow;
|
|
if (key === "__v_isReactive") {
|
|
return !isReadonly2;
|
|
} else if (key === "__v_isReadonly") {
|
|
return isReadonly2;
|
|
} else if (key === "__v_isShallow") {
|
|
return isShallow2;
|
|
} else if (key === "__v_raw") {
|
|
if (receiver === (isReadonly2 ? isShallow2 ? shallowReadonlyMap : readonlyMap : isShallow2 ? shallowReactiveMap : reactiveMap).get(target) || // receiver is not the reactive proxy, but has the same prototype
|
|
// this means the receiver is a user proxy of the reactive proxy
|
|
Object.getPrototypeOf(target) === Object.getPrototypeOf(receiver)) {
|
|
return target;
|
|
}
|
|
return;
|
|
}
|
|
const targetIsArray = isArray$3(target);
|
|
if (!isReadonly2) {
|
|
let fn;
|
|
if (targetIsArray && (fn = arrayInstrumentations[key])) {
|
|
return fn;
|
|
}
|
|
if (key === "hasOwnProperty") {
|
|
return hasOwnProperty$b;
|
|
}
|
|
}
|
|
const res = Reflect.get(
|
|
target,
|
|
key,
|
|
// if this is a proxy wrapping a ref, return methods using the raw ref
|
|
// as receiver so that we don't have to call `toRaw` on the ref in all
|
|
// its class methods
|
|
isRef(target) ? target : receiver
|
|
);
|
|
if (isSymbol$1(key) ? builtInSymbols.has(key) : isNonTrackableKeys(key)) {
|
|
return res;
|
|
}
|
|
if (!isReadonly2) {
|
|
track(target, "get", key);
|
|
}
|
|
if (isShallow2) {
|
|
return res;
|
|
}
|
|
if (isRef(res)) {
|
|
return targetIsArray && isIntegerKey(key) ? res : res.value;
|
|
}
|
|
if (isObject$2(res)) {
|
|
return isReadonly2 ? readonly(res) : reactive(res);
|
|
}
|
|
return res;
|
|
}
|
|
}
|
|
class MutableReactiveHandler extends BaseReactiveHandler {
|
|
constructor(isShallow2 = false) {
|
|
super(false, isShallow2);
|
|
}
|
|
set(target, key, value, receiver) {
|
|
let oldValue = target[key];
|
|
if (!this._isShallow) {
|
|
const isOldValueReadonly = isReadonly(oldValue);
|
|
if (!isShallow(value) && !isReadonly(value)) {
|
|
oldValue = toRaw(oldValue);
|
|
value = toRaw(value);
|
|
}
|
|
if (!isArray$3(target) && isRef(oldValue) && !isRef(value)) {
|
|
if (isOldValueReadonly) {
|
|
return false;
|
|
} else {
|
|
oldValue.value = value;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
const hadKey = isArray$3(target) && isIntegerKey(key) ? Number(key) < target.length : hasOwn(target, key);
|
|
const result = Reflect.set(
|
|
target,
|
|
key,
|
|
value,
|
|
isRef(target) ? target : receiver
|
|
);
|
|
if (target === toRaw(receiver)) {
|
|
if (!hadKey) {
|
|
trigger$1(target, "add", key, value);
|
|
} else if (hasChanged(value, oldValue)) {
|
|
trigger$1(target, "set", key, value);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
deleteProperty(target, key) {
|
|
const hadKey = hasOwn(target, key);
|
|
target[key];
|
|
const result = Reflect.deleteProperty(target, key);
|
|
if (result && hadKey) {
|
|
trigger$1(target, "delete", key, void 0);
|
|
}
|
|
return result;
|
|
}
|
|
has(target, key) {
|
|
const result = Reflect.has(target, key);
|
|
if (!isSymbol$1(key) || !builtInSymbols.has(key)) {
|
|
track(target, "has", key);
|
|
}
|
|
return result;
|
|
}
|
|
ownKeys(target) {
|
|
track(
|
|
target,
|
|
"iterate",
|
|
isArray$3(target) ? "length" : ITERATE_KEY
|
|
);
|
|
return Reflect.ownKeys(target);
|
|
}
|
|
}
|
|
class ReadonlyReactiveHandler extends BaseReactiveHandler {
|
|
constructor(isShallow2 = false) {
|
|
super(true, isShallow2);
|
|
}
|
|
set(target, key) {
|
|
return true;
|
|
}
|
|
deleteProperty(target, key) {
|
|
return true;
|
|
}
|
|
}
|
|
const mutableHandlers = /* @__PURE__ */ new MutableReactiveHandler();
|
|
const readonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler();
|
|
const shallowReactiveHandlers = /* @__PURE__ */ new MutableReactiveHandler(true);
|
|
const shallowReadonlyHandlers = /* @__PURE__ */ new ReadonlyReactiveHandler(true);
|
|
const toShallow = (value) => value;
|
|
const getProto = (v) => Reflect.getPrototypeOf(v);
|
|
function createIterableMethod(method, isReadonly2, isShallow2) {
|
|
return function(...args) {
|
|
const target = this["__v_raw"];
|
|
const rawTarget = toRaw(target);
|
|
const targetIsMap = isMap(rawTarget);
|
|
const isPair = method === "entries" || method === Symbol.iterator && targetIsMap;
|
|
const isKeyOnly = method === "keys" && targetIsMap;
|
|
const innerIterator = target[method](...args);
|
|
const wrap = isShallow2 ? toShallow : isReadonly2 ? toReadonly : toReactive;
|
|
!isReadonly2 && track(
|
|
rawTarget,
|
|
"iterate",
|
|
isKeyOnly ? MAP_KEY_ITERATE_KEY : ITERATE_KEY
|
|
);
|
|
return {
|
|
// iterator protocol
|
|
next() {
|
|
const { value, done } = innerIterator.next();
|
|
return done ? { value, done } : {
|
|
value: isPair ? [wrap(value[0]), wrap(value[1])] : wrap(value),
|
|
done
|
|
};
|
|
},
|
|
// iterable protocol
|
|
[Symbol.iterator]() {
|
|
return this;
|
|
}
|
|
};
|
|
};
|
|
}
|
|
function createReadonlyMethod(type) {
|
|
return function(...args) {
|
|
return type === "delete" ? false : type === "clear" ? void 0 : this;
|
|
};
|
|
}
|
|
function createInstrumentations(readonly2, shallow) {
|
|
const instrumentations = {
|
|
get(key) {
|
|
const target = this["__v_raw"];
|
|
const rawTarget = toRaw(target);
|
|
const rawKey = toRaw(key);
|
|
if (!readonly2) {
|
|
if (hasChanged(key, rawKey)) {
|
|
track(rawTarget, "get", key);
|
|
}
|
|
track(rawTarget, "get", rawKey);
|
|
}
|
|
const { has } = getProto(rawTarget);
|
|
const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
|
|
if (has.call(rawTarget, key)) {
|
|
return wrap(target.get(key));
|
|
} else if (has.call(rawTarget, rawKey)) {
|
|
return wrap(target.get(rawKey));
|
|
} else if (target !== rawTarget) {
|
|
target.get(key);
|
|
}
|
|
},
|
|
get size() {
|
|
const target = this["__v_raw"];
|
|
!readonly2 && track(toRaw(target), "iterate", ITERATE_KEY);
|
|
return Reflect.get(target, "size", target);
|
|
},
|
|
has(key) {
|
|
const target = this["__v_raw"];
|
|
const rawTarget = toRaw(target);
|
|
const rawKey = toRaw(key);
|
|
if (!readonly2) {
|
|
if (hasChanged(key, rawKey)) {
|
|
track(rawTarget, "has", key);
|
|
}
|
|
track(rawTarget, "has", rawKey);
|
|
}
|
|
return key === rawKey ? target.has(key) : target.has(key) || target.has(rawKey);
|
|
},
|
|
forEach(callback, thisArg) {
|
|
const observed = this;
|
|
const target = observed["__v_raw"];
|
|
const rawTarget = toRaw(target);
|
|
const wrap = shallow ? toShallow : readonly2 ? toReadonly : toReactive;
|
|
!readonly2 && track(rawTarget, "iterate", ITERATE_KEY);
|
|
return target.forEach((value, key) => {
|
|
return callback.call(thisArg, wrap(value), wrap(key), observed);
|
|
});
|
|
}
|
|
};
|
|
extend$1(
|
|
instrumentations,
|
|
readonly2 ? {
|
|
add: createReadonlyMethod("add"),
|
|
set: createReadonlyMethod("set"),
|
|
delete: createReadonlyMethod("delete"),
|
|
clear: createReadonlyMethod("clear")
|
|
} : {
|
|
add(value) {
|
|
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
value = toRaw(value);
|
|
}
|
|
const target = toRaw(this);
|
|
const proto = getProto(target);
|
|
const hadKey = proto.has.call(target, value);
|
|
if (!hadKey) {
|
|
target.add(value);
|
|
trigger$1(target, "add", value, value);
|
|
}
|
|
return this;
|
|
},
|
|
set(key, value) {
|
|
if (!shallow && !isShallow(value) && !isReadonly(value)) {
|
|
value = toRaw(value);
|
|
}
|
|
const target = toRaw(this);
|
|
const { has, get } = getProto(target);
|
|
let hadKey = has.call(target, key);
|
|
if (!hadKey) {
|
|
key = toRaw(key);
|
|
hadKey = has.call(target, key);
|
|
}
|
|
const oldValue = get.call(target, key);
|
|
target.set(key, value);
|
|
if (!hadKey) {
|
|
trigger$1(target, "add", key, value);
|
|
} else if (hasChanged(value, oldValue)) {
|
|
trigger$1(target, "set", key, value);
|
|
}
|
|
return this;
|
|
},
|
|
delete(key) {
|
|
const target = toRaw(this);
|
|
const { has, get } = getProto(target);
|
|
let hadKey = has.call(target, key);
|
|
if (!hadKey) {
|
|
key = toRaw(key);
|
|
hadKey = has.call(target, key);
|
|
}
|
|
get ? get.call(target, key) : void 0;
|
|
const result = target.delete(key);
|
|
if (hadKey) {
|
|
trigger$1(target, "delete", key, void 0);
|
|
}
|
|
return result;
|
|
},
|
|
clear() {
|
|
const target = toRaw(this);
|
|
const hadItems = target.size !== 0;
|
|
const result = target.clear();
|
|
if (hadItems) {
|
|
trigger$1(
|
|
target,
|
|
"clear",
|
|
void 0,
|
|
void 0
|
|
);
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
);
|
|
const iteratorMethods = [
|
|
"keys",
|
|
"values",
|
|
"entries",
|
|
Symbol.iterator
|
|
];
|
|
iteratorMethods.forEach((method) => {
|
|
instrumentations[method] = createIterableMethod(method, readonly2, shallow);
|
|
});
|
|
return instrumentations;
|
|
}
|
|
function createInstrumentationGetter(isReadonly2, shallow) {
|
|
const instrumentations = createInstrumentations(isReadonly2, shallow);
|
|
return (target, key, receiver) => {
|
|
if (key === "__v_isReactive") {
|
|
return !isReadonly2;
|
|
} else if (key === "__v_isReadonly") {
|
|
return isReadonly2;
|
|
} else if (key === "__v_raw") {
|
|
return target;
|
|
}
|
|
return Reflect.get(
|
|
hasOwn(instrumentations, key) && key in target ? instrumentations : target,
|
|
key,
|
|
receiver
|
|
);
|
|
};
|
|
}
|
|
const mutableCollectionHandlers = {
|
|
get: /* @__PURE__ */ createInstrumentationGetter(false, false)
|
|
};
|
|
const shallowCollectionHandlers = {
|
|
get: /* @__PURE__ */ createInstrumentationGetter(false, true)
|
|
};
|
|
const readonlyCollectionHandlers = {
|
|
get: /* @__PURE__ */ createInstrumentationGetter(true, false)
|
|
};
|
|
const shallowReadonlyCollectionHandlers = {
|
|
get: /* @__PURE__ */ createInstrumentationGetter(true, true)
|
|
};
|
|
const reactiveMap = /* @__PURE__ */ new WeakMap();
|
|
const shallowReactiveMap = /* @__PURE__ */ new WeakMap();
|
|
const readonlyMap = /* @__PURE__ */ new WeakMap();
|
|
const shallowReadonlyMap = /* @__PURE__ */ new WeakMap();
|
|
function targetTypeMap(rawType) {
|
|
switch (rawType) {
|
|
case "Object":
|
|
case "Array":
|
|
return 1;
|
|
case "Map":
|
|
case "Set":
|
|
case "WeakMap":
|
|
case "WeakSet":
|
|
return 2;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
function getTargetType(value) {
|
|
return value["__v_skip"] || !Object.isExtensible(value) ? 0 : targetTypeMap(toRawType(value));
|
|
}
|
|
function reactive(target) {
|
|
if (isReadonly(target)) {
|
|
return target;
|
|
}
|
|
return createReactiveObject(
|
|
target,
|
|
false,
|
|
mutableHandlers,
|
|
mutableCollectionHandlers,
|
|
reactiveMap
|
|
);
|
|
}
|
|
function shallowReactive(target) {
|
|
return createReactiveObject(
|
|
target,
|
|
false,
|
|
shallowReactiveHandlers,
|
|
shallowCollectionHandlers,
|
|
shallowReactiveMap
|
|
);
|
|
}
|
|
function readonly(target) {
|
|
return createReactiveObject(
|
|
target,
|
|
true,
|
|
readonlyHandlers,
|
|
readonlyCollectionHandlers,
|
|
readonlyMap
|
|
);
|
|
}
|
|
function shallowReadonly(target) {
|
|
return createReactiveObject(
|
|
target,
|
|
true,
|
|
shallowReadonlyHandlers,
|
|
shallowReadonlyCollectionHandlers,
|
|
shallowReadonlyMap
|
|
);
|
|
}
|
|
function createReactiveObject(target, isReadonly2, baseHandlers, collectionHandlers, proxyMap) {
|
|
if (!isObject$2(target)) {
|
|
return target;
|
|
}
|
|
if (target["__v_raw"] && !(isReadonly2 && target["__v_isReactive"])) {
|
|
return target;
|
|
}
|
|
const existingProxy = proxyMap.get(target);
|
|
if (existingProxy) {
|
|
return existingProxy;
|
|
}
|
|
const targetType = getTargetType(target);
|
|
if (targetType === 0) {
|
|
return target;
|
|
}
|
|
const proxy = new Proxy(
|
|
target,
|
|
targetType === 2 ? collectionHandlers : baseHandlers
|
|
);
|
|
proxyMap.set(target, proxy);
|
|
return proxy;
|
|
}
|
|
function isReactive(value) {
|
|
if (isReadonly(value)) {
|
|
return isReactive(value["__v_raw"]);
|
|
}
|
|
return !!(value && value["__v_isReactive"]);
|
|
}
|
|
function isReadonly(value) {
|
|
return !!(value && value["__v_isReadonly"]);
|
|
}
|
|
function isShallow(value) {
|
|
return !!(value && value["__v_isShallow"]);
|
|
}
|
|
function isProxy(value) {
|
|
return value ? !!value["__v_raw"] : false;
|
|
}
|
|
function toRaw(observed) {
|
|
const raw = observed && observed["__v_raw"];
|
|
return raw ? toRaw(raw) : observed;
|
|
}
|
|
function markRaw(value) {
|
|
if (!hasOwn(value, "__v_skip") && Object.isExtensible(value)) {
|
|
def(value, "__v_skip", true);
|
|
}
|
|
return value;
|
|
}
|
|
const toReactive = (value) => isObject$2(value) ? reactive(value) : value;
|
|
const toReadonly = (value) => isObject$2(value) ? readonly(value) : value;
|
|
function isRef(r) {
|
|
return r ? r["__v_isRef"] === true : false;
|
|
}
|
|
function ref(value) {
|
|
return createRef(value, false);
|
|
}
|
|
function shallowRef(value) {
|
|
return createRef(value, true);
|
|
}
|
|
function createRef(rawValue, shallow) {
|
|
if (isRef(rawValue)) {
|
|
return rawValue;
|
|
}
|
|
return new RefImpl(rawValue, shallow);
|
|
}
|
|
class RefImpl {
|
|
constructor(value, isShallow2) {
|
|
this.dep = new Dep();
|
|
this["__v_isRef"] = true;
|
|
this["__v_isShallow"] = false;
|
|
this._rawValue = isShallow2 ? value : toRaw(value);
|
|
this._value = isShallow2 ? value : toReactive(value);
|
|
this["__v_isShallow"] = isShallow2;
|
|
}
|
|
get value() {
|
|
{
|
|
this.dep.track();
|
|
}
|
|
return this._value;
|
|
}
|
|
set value(newValue) {
|
|
const oldValue = this._rawValue;
|
|
const useDirectValue = this["__v_isShallow"] || isShallow(newValue) || isReadonly(newValue);
|
|
newValue = useDirectValue ? newValue : toRaw(newValue);
|
|
if (hasChanged(newValue, oldValue)) {
|
|
this._rawValue = newValue;
|
|
this._value = useDirectValue ? newValue : toReactive(newValue);
|
|
{
|
|
this.dep.trigger();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function triggerRef(ref2) {
|
|
if (ref2.dep) {
|
|
{
|
|
ref2.dep.trigger();
|
|
}
|
|
}
|
|
}
|
|
function unref(ref2) {
|
|
return isRef(ref2) ? ref2.value : ref2;
|
|
}
|
|
function toValue(source) {
|
|
return isFunction$2(source) ? source() : unref(source);
|
|
}
|
|
const shallowUnwrapHandlers = {
|
|
get: (target, key, receiver) => key === "__v_raw" ? target : unref(Reflect.get(target, key, receiver)),
|
|
set: (target, key, value, receiver) => {
|
|
const oldValue = target[key];
|
|
if (isRef(oldValue) && !isRef(value)) {
|
|
oldValue.value = value;
|
|
return true;
|
|
} else {
|
|
return Reflect.set(target, key, value, receiver);
|
|
}
|
|
}
|
|
};
|
|
function proxyRefs(objectWithRefs) {
|
|
return isReactive(objectWithRefs) ? objectWithRefs : new Proxy(objectWithRefs, shallowUnwrapHandlers);
|
|
}
|
|
class CustomRefImpl {
|
|
constructor(factory) {
|
|
this["__v_isRef"] = true;
|
|
this._value = void 0;
|
|
const dep = this.dep = new Dep();
|
|
const { get, set } = factory(dep.track.bind(dep), dep.trigger.bind(dep));
|
|
this._get = get;
|
|
this._set = set;
|
|
}
|
|
get value() {
|
|
return this._value = this._get();
|
|
}
|
|
set value(newVal) {
|
|
this._set(newVal);
|
|
}
|
|
}
|
|
function customRef(factory) {
|
|
return new CustomRefImpl(factory);
|
|
}
|
|
function toRefs(object) {
|
|
const ret = isArray$3(object) ? new Array(object.length) : {};
|
|
for (const key in object) {
|
|
ret[key] = propertyToRef(object, key);
|
|
}
|
|
return ret;
|
|
}
|
|
class ObjectRefImpl {
|
|
constructor(_object, _key, _defaultValue) {
|
|
this._object = _object;
|
|
this._key = _key;
|
|
this._defaultValue = _defaultValue;
|
|
this["__v_isRef"] = true;
|
|
this._value = void 0;
|
|
}
|
|
get value() {
|
|
const val = this._object[this._key];
|
|
return this._value = val === void 0 ? this._defaultValue : val;
|
|
}
|
|
set value(newVal) {
|
|
this._object[this._key] = newVal;
|
|
}
|
|
get dep() {
|
|
return getDepFromReactive(toRaw(this._object), this._key);
|
|
}
|
|
}
|
|
class GetterRefImpl {
|
|
constructor(_getter) {
|
|
this._getter = _getter;
|
|
this["__v_isRef"] = true;
|
|
this["__v_isReadonly"] = true;
|
|
this._value = void 0;
|
|
}
|
|
get value() {
|
|
return this._value = this._getter();
|
|
}
|
|
}
|
|
function toRef(source, key, defaultValue) {
|
|
if (isRef(source)) {
|
|
return source;
|
|
} else if (isFunction$2(source)) {
|
|
return new GetterRefImpl(source);
|
|
} else if (isObject$2(source) && arguments.length > 1) {
|
|
return propertyToRef(source, key, defaultValue);
|
|
} else {
|
|
return ref(source);
|
|
}
|
|
}
|
|
function propertyToRef(source, key, defaultValue) {
|
|
const val = source[key];
|
|
return isRef(val) ? val : new ObjectRefImpl(source, key, defaultValue);
|
|
}
|
|
class ComputedRefImpl {
|
|
constructor(fn, setter, isSSR) {
|
|
this.fn = fn;
|
|
this.setter = setter;
|
|
this._value = void 0;
|
|
this.dep = new Dep(this);
|
|
this.__v_isRef = true;
|
|
this.deps = void 0;
|
|
this.depsTail = void 0;
|
|
this.flags = 16;
|
|
this.globalVersion = globalVersion - 1;
|
|
this.next = void 0;
|
|
this.effect = this;
|
|
this["__v_isReadonly"] = !setter;
|
|
this.isSSR = isSSR;
|
|
}
|
|
/**
|
|
* @internal
|
|
*/
|
|
notify() {
|
|
this.flags |= 16;
|
|
if (!(this.flags & 8) && // avoid infinite self recursion
|
|
activeSub !== this) {
|
|
batch(this, true);
|
|
return true;
|
|
}
|
|
}
|
|
get value() {
|
|
const link = this.dep.track();
|
|
refreshComputed(this);
|
|
if (link) {
|
|
link.version = this.dep.version;
|
|
}
|
|
return this._value;
|
|
}
|
|
set value(newValue) {
|
|
if (this.setter) {
|
|
this.setter(newValue);
|
|
}
|
|
}
|
|
}
|
|
function computed$1(getterOrOptions, debugOptions, isSSR = false) {
|
|
let getter;
|
|
let setter;
|
|
if (isFunction$2(getterOrOptions)) {
|
|
getter = getterOrOptions;
|
|
} else {
|
|
getter = getterOrOptions.get;
|
|
setter = getterOrOptions.set;
|
|
}
|
|
const cRef = new ComputedRefImpl(getter, setter, isSSR);
|
|
return cRef;
|
|
}
|
|
const TrackOpTypes = {
|
|
"GET": "get",
|
|
"HAS": "has",
|
|
"ITERATE": "iterate"
|
|
};
|
|
const TriggerOpTypes = {
|
|
"SET": "set",
|
|
"ADD": "add",
|
|
"DELETE": "delete",
|
|
"CLEAR": "clear"
|
|
};
|
|
const INITIAL_WATCHER_VALUE = {};
|
|
const cleanupMap = /* @__PURE__ */ new WeakMap();
|
|
let activeWatcher = void 0;
|
|
function getCurrentWatcher() {
|
|
return activeWatcher;
|
|
}
|
|
function onWatcherCleanup(cleanupFn, failSilently = false, owner = activeWatcher) {
|
|
if (owner) {
|
|
let cleanups = cleanupMap.get(owner);
|
|
if (!cleanups) cleanupMap.set(owner, cleanups = []);
|
|
cleanups.push(cleanupFn);
|
|
}
|
|
}
|
|
function watch$1(source, cb, options = EMPTY_OBJ) {
|
|
const { immediate, deep, once, scheduler: scheduler2, augmentJob, call: call2 } = options;
|
|
const reactiveGetter = (source2) => {
|
|
if (deep) return source2;
|
|
if (isShallow(source2) || deep === false || deep === 0)
|
|
return traverse(source2, 1);
|
|
return traverse(source2);
|
|
};
|
|
let effect2;
|
|
let getter;
|
|
let cleanup;
|
|
let boundCleanup;
|
|
let forceTrigger = false;
|
|
let isMultiSource = false;
|
|
if (isRef(source)) {
|
|
getter = () => source.value;
|
|
forceTrigger = isShallow(source);
|
|
} else if (isReactive(source)) {
|
|
getter = () => reactiveGetter(source);
|
|
forceTrigger = true;
|
|
} else if (isArray$3(source)) {
|
|
isMultiSource = true;
|
|
forceTrigger = source.some((s) => isReactive(s) || isShallow(s));
|
|
getter = () => source.map((s) => {
|
|
if (isRef(s)) {
|
|
return s.value;
|
|
} else if (isReactive(s)) {
|
|
return reactiveGetter(s);
|
|
} else if (isFunction$2(s)) {
|
|
return call2 ? call2(s, 2) : s();
|
|
} else ;
|
|
});
|
|
} else if (isFunction$2(source)) {
|
|
if (cb) {
|
|
getter = call2 ? () => call2(source, 2) : source;
|
|
} else {
|
|
getter = () => {
|
|
if (cleanup) {
|
|
pauseTracking();
|
|
try {
|
|
cleanup();
|
|
} finally {
|
|
resetTracking();
|
|
}
|
|
}
|
|
const currentEffect = activeWatcher;
|
|
activeWatcher = effect2;
|
|
try {
|
|
return call2 ? call2(source, 3, [boundCleanup]) : source(boundCleanup);
|
|
} finally {
|
|
activeWatcher = currentEffect;
|
|
}
|
|
};
|
|
}
|
|
} else {
|
|
getter = NOOP;
|
|
}
|
|
if (cb && deep) {
|
|
const baseGetter = getter;
|
|
const depth = deep === true ? Infinity : deep;
|
|
getter = () => traverse(baseGetter(), depth);
|
|
}
|
|
const scope = getCurrentScope();
|
|
const watchHandle = () => {
|
|
effect2.stop();
|
|
if (scope && scope.active) {
|
|
remove(scope.effects, effect2);
|
|
}
|
|
};
|
|
if (once && cb) {
|
|
const _cb = cb;
|
|
cb = (...args) => {
|
|
_cb(...args);
|
|
watchHandle();
|
|
};
|
|
}
|
|
let oldValue = isMultiSource ? new Array(source.length).fill(INITIAL_WATCHER_VALUE) : INITIAL_WATCHER_VALUE;
|
|
const job = (immediateFirstRun) => {
|
|
if (!(effect2.flags & 1) || !effect2.dirty && !immediateFirstRun) {
|
|
return;
|
|
}
|
|
if (cb) {
|
|
const newValue = effect2.run();
|
|
if (deep || forceTrigger || (isMultiSource ? newValue.some((v, i) => hasChanged(v, oldValue[i])) : hasChanged(newValue, oldValue))) {
|
|
if (cleanup) {
|
|
cleanup();
|
|
}
|
|
const currentWatcher = activeWatcher;
|
|
activeWatcher = effect2;
|
|
try {
|
|
const args = [
|
|
newValue,
|
|
// pass undefined as the old value when it's changed for the first time
|
|
oldValue === INITIAL_WATCHER_VALUE ? void 0 : isMultiSource && oldValue[0] === INITIAL_WATCHER_VALUE ? [] : oldValue,
|
|
boundCleanup
|
|
];
|
|
call2 ? call2(cb, 3, args) : (
|
|
// @ts-expect-error
|
|
cb(...args)
|
|
);
|
|
oldValue = newValue;
|
|
} finally {
|
|
activeWatcher = currentWatcher;
|
|
}
|
|
}
|
|
} else {
|
|
effect2.run();
|
|
}
|
|
};
|
|
if (augmentJob) {
|
|
augmentJob(job);
|
|
}
|
|
effect2 = new ReactiveEffect(getter);
|
|
effect2.scheduler = scheduler2 ? () => scheduler2(job, false) : job;
|
|
boundCleanup = (fn) => onWatcherCleanup(fn, false, effect2);
|
|
cleanup = effect2.onStop = () => {
|
|
const cleanups = cleanupMap.get(effect2);
|
|
if (cleanups) {
|
|
if (call2) {
|
|
call2(cleanups, 4);
|
|
} else {
|
|
for (const cleanup2 of cleanups) cleanup2();
|
|
}
|
|
cleanupMap.delete(effect2);
|
|
}
|
|
};
|
|
if (cb) {
|
|
if (immediate) {
|
|
job(true);
|
|
} else {
|
|
oldValue = effect2.run();
|
|
}
|
|
} else if (scheduler2) {
|
|
scheduler2(job.bind(null, true), true);
|
|
} else {
|
|
effect2.run();
|
|
}
|
|
watchHandle.pause = effect2.pause.bind(effect2);
|
|
watchHandle.resume = effect2.resume.bind(effect2);
|
|
watchHandle.stop = watchHandle;
|
|
return watchHandle;
|
|
}
|
|
function traverse(value, depth = Infinity, seen2) {
|
|
if (depth <= 0 || !isObject$2(value) || value["__v_skip"]) {
|
|
return value;
|
|
}
|
|
seen2 = seen2 || /* @__PURE__ */ new Set();
|
|
if (seen2.has(value)) {
|
|
return value;
|
|
}
|
|
seen2.add(value);
|
|
depth--;
|
|
if (isRef(value)) {
|
|
traverse(value.value, depth, seen2);
|
|
} else if (isArray$3(value)) {
|
|
for (let i = 0; i < value.length; i++) {
|
|
traverse(value[i], depth, seen2);
|
|
}
|
|
} else if (isSet(value) || isMap(value)) {
|
|
value.forEach((v) => {
|
|
traverse(v, depth, seen2);
|
|
});
|
|
} else if (isPlainObject$3(value)) {
|
|
for (const key in value) {
|
|
traverse(value[key], depth, seen2);
|
|
}
|
|
for (const key of Object.getOwnPropertySymbols(value)) {
|
|
if (Object.prototype.propertyIsEnumerable.call(value, key)) {
|
|
traverse(value[key], depth, seen2);
|
|
}
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
/**
|
|
* @vue/runtime-core v3.5.13
|
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
* @license MIT
|
|
**/
|
|
const stack$1 = [];
|
|
function pushWarningContext(vnode) {
|
|
stack$1.push(vnode);
|
|
}
|
|
function popWarningContext() {
|
|
stack$1.pop();
|
|
}
|
|
let isWarning = false;
|
|
function warn$1$1(msg2, ...args) {
|
|
if (isWarning) return;
|
|
isWarning = true;
|
|
pauseTracking();
|
|
const instance = stack$1.length ? stack$1[stack$1.length - 1].component : null;
|
|
const appWarnHandler = instance && instance.appContext.config.warnHandler;
|
|
const trace = getComponentTrace();
|
|
if (appWarnHandler) {
|
|
callWithErrorHandling(
|
|
appWarnHandler,
|
|
instance,
|
|
11,
|
|
[
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
msg2 + args.map((a) => {
|
|
var _a, _b;
|
|
return (_b = (_a = a.toString) == null ? void 0 : _a.call(a)) != null ? _b : JSON.stringify(a);
|
|
}).join(""),
|
|
instance && instance.proxy,
|
|
trace.map(
|
|
({ vnode }) => `at <${formatComponentName(instance, vnode.type)}>`
|
|
).join("\n"),
|
|
trace
|
|
]
|
|
);
|
|
} else {
|
|
const warnArgs = [`[Vue warn]: ${msg2}`, ...args];
|
|
if (trace.length && // avoid spamming console during tests
|
|
true) {
|
|
warnArgs.push(`
|
|
`, ...formatTrace(trace));
|
|
}
|
|
console.warn(...warnArgs);
|
|
}
|
|
resetTracking();
|
|
isWarning = false;
|
|
}
|
|
function getComponentTrace() {
|
|
let currentVNode = stack$1[stack$1.length - 1];
|
|
if (!currentVNode) {
|
|
return [];
|
|
}
|
|
const normalizedStack = [];
|
|
while (currentVNode) {
|
|
const last = normalizedStack[0];
|
|
if (last && last.vnode === currentVNode) {
|
|
last.recurseCount++;
|
|
} else {
|
|
normalizedStack.push({
|
|
vnode: currentVNode,
|
|
recurseCount: 0
|
|
});
|
|
}
|
|
const parentInstance = currentVNode.component && currentVNode.component.parent;
|
|
currentVNode = parentInstance && parentInstance.vnode;
|
|
}
|
|
return normalizedStack;
|
|
}
|
|
function formatTrace(trace) {
|
|
const logs = [];
|
|
trace.forEach((entry, i) => {
|
|
logs.push(...i === 0 ? [] : [`
|
|
`], ...formatTraceEntry(entry));
|
|
});
|
|
return logs;
|
|
}
|
|
function formatTraceEntry({ vnode, recurseCount }) {
|
|
const postfix = recurseCount > 0 ? `... (${recurseCount} recursive calls)` : ``;
|
|
const isRoot = vnode.component ? vnode.component.parent == null : false;
|
|
const open = ` at <${formatComponentName(
|
|
vnode.component,
|
|
vnode.type,
|
|
isRoot
|
|
)}`;
|
|
const close = `>` + postfix;
|
|
return vnode.props ? [open, ...formatProps(vnode.props), close] : [open + close];
|
|
}
|
|
function formatProps(props) {
|
|
const res = [];
|
|
const keys = Object.keys(props);
|
|
keys.slice(0, 3).forEach((key) => {
|
|
res.push(...formatProp(key, props[key]));
|
|
});
|
|
if (keys.length > 3) {
|
|
res.push(` ...`);
|
|
}
|
|
return res;
|
|
}
|
|
function formatProp(key, value, raw) {
|
|
if (isString$1(value)) {
|
|
value = JSON.stringify(value);
|
|
return raw ? value : [`${key}=${value}`];
|
|
} else if (typeof value === "number" || typeof value === "boolean" || value == null) {
|
|
return raw ? value : [`${key}=${value}`];
|
|
} else if (isRef(value)) {
|
|
value = formatProp(key, toRaw(value.value), true);
|
|
return raw ? value : [`${key}=Ref<`, value, `>`];
|
|
} else if (isFunction$2(value)) {
|
|
return [`${key}=fn${value.name ? `<${value.name}>` : ``}`];
|
|
} else {
|
|
value = toRaw(value);
|
|
return raw ? value : [`${key}=`, value];
|
|
}
|
|
}
|
|
function assertNumber(val, type) {
|
|
return;
|
|
}
|
|
const ErrorCodes = {
|
|
"SETUP_FUNCTION": 0,
|
|
"0": "SETUP_FUNCTION",
|
|
"RENDER_FUNCTION": 1,
|
|
"1": "RENDER_FUNCTION",
|
|
"NATIVE_EVENT_HANDLER": 5,
|
|
"5": "NATIVE_EVENT_HANDLER",
|
|
"COMPONENT_EVENT_HANDLER": 6,
|
|
"6": "COMPONENT_EVENT_HANDLER",
|
|
"VNODE_HOOK": 7,
|
|
"7": "VNODE_HOOK",
|
|
"DIRECTIVE_HOOK": 8,
|
|
"8": "DIRECTIVE_HOOK",
|
|
"TRANSITION_HOOK": 9,
|
|
"9": "TRANSITION_HOOK",
|
|
"APP_ERROR_HANDLER": 10,
|
|
"10": "APP_ERROR_HANDLER",
|
|
"APP_WARN_HANDLER": 11,
|
|
"11": "APP_WARN_HANDLER",
|
|
"FUNCTION_REF": 12,
|
|
"12": "FUNCTION_REF",
|
|
"ASYNC_COMPONENT_LOADER": 13,
|
|
"13": "ASYNC_COMPONENT_LOADER",
|
|
"SCHEDULER": 14,
|
|
"14": "SCHEDULER",
|
|
"COMPONENT_UPDATE": 15,
|
|
"15": "COMPONENT_UPDATE",
|
|
"APP_UNMOUNT_CLEANUP": 16,
|
|
"16": "APP_UNMOUNT_CLEANUP"
|
|
};
|
|
const ErrorTypeStrings$1 = {
|
|
["sp"]: "serverPrefetch hook",
|
|
["bc"]: "beforeCreate hook",
|
|
["c"]: "created hook",
|
|
["bm"]: "beforeMount hook",
|
|
["m"]: "mounted hook",
|
|
["bu"]: "beforeUpdate hook",
|
|
["u"]: "updated",
|
|
["bum"]: "beforeUnmount hook",
|
|
["um"]: "unmounted hook",
|
|
["a"]: "activated hook",
|
|
["da"]: "deactivated hook",
|
|
["ec"]: "errorCaptured hook",
|
|
["rtc"]: "renderTracked hook",
|
|
["rtg"]: "renderTriggered hook",
|
|
[0]: "setup function",
|
|
[1]: "render function",
|
|
[2]: "watcher getter",
|
|
[3]: "watcher callback",
|
|
[4]: "watcher cleanup function",
|
|
[5]: "native event handler",
|
|
[6]: "component event handler",
|
|
[7]: "vnode hook",
|
|
[8]: "directive hook",
|
|
[9]: "transition hook",
|
|
[10]: "app errorHandler",
|
|
[11]: "app warnHandler",
|
|
[12]: "ref function",
|
|
[13]: "async component loader",
|
|
[14]: "scheduler flush",
|
|
[15]: "component update",
|
|
[16]: "app unmount cleanup function"
|
|
};
|
|
function callWithErrorHandling(fn, instance, type, args) {
|
|
try {
|
|
return args ? fn(...args) : fn();
|
|
} catch (err) {
|
|
handleError(err, instance, type);
|
|
}
|
|
}
|
|
function callWithAsyncErrorHandling(fn, instance, type, args) {
|
|
if (isFunction$2(fn)) {
|
|
const res = callWithErrorHandling(fn, instance, type, args);
|
|
if (res && isPromise(res)) {
|
|
res.catch((err) => {
|
|
handleError(err, instance, type);
|
|
});
|
|
}
|
|
return res;
|
|
}
|
|
if (isArray$3(fn)) {
|
|
const values = [];
|
|
for (let i = 0; i < fn.length; i++) {
|
|
values.push(callWithAsyncErrorHandling(fn[i], instance, type, args));
|
|
}
|
|
return values;
|
|
}
|
|
}
|
|
function handleError(err, instance, type, throwInDev = true) {
|
|
const contextVNode = instance ? instance.vnode : null;
|
|
const { errorHandler, throwUnhandledErrorInProduction } = instance && instance.appContext.config || EMPTY_OBJ;
|
|
if (instance) {
|
|
let cur = instance.parent;
|
|
const exposedInstance = instance.proxy;
|
|
const errorInfo = `https://vuejs.org/error-reference/#runtime-${type}`;
|
|
while (cur) {
|
|
const errorCapturedHooks = cur.ec;
|
|
if (errorCapturedHooks) {
|
|
for (let i = 0; i < errorCapturedHooks.length; i++) {
|
|
if (errorCapturedHooks[i](err, exposedInstance, errorInfo) === false) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
cur = cur.parent;
|
|
}
|
|
if (errorHandler) {
|
|
pauseTracking();
|
|
callWithErrorHandling(errorHandler, null, 10, [
|
|
err,
|
|
exposedInstance,
|
|
errorInfo
|
|
]);
|
|
resetTracking();
|
|
return;
|
|
}
|
|
}
|
|
logError(err, type, contextVNode, throwInDev, throwUnhandledErrorInProduction);
|
|
}
|
|
function logError(err, type, contextVNode, throwInDev = true, throwInProd = false) {
|
|
if (throwInProd) {
|
|
throw err;
|
|
} else {
|
|
console.error(err);
|
|
}
|
|
}
|
|
const queue = [];
|
|
let flushIndex = -1;
|
|
const pendingPostFlushCbs = [];
|
|
let activePostFlushCbs = null;
|
|
let postFlushIndex = 0;
|
|
const resolvedPromise = /* @__PURE__ */ Promise.resolve();
|
|
let currentFlushPromise = null;
|
|
function nextTick(fn) {
|
|
const p2 = currentFlushPromise || resolvedPromise;
|
|
return fn ? p2.then(this ? fn.bind(this) : fn) : p2;
|
|
}
|
|
function findInsertionIndex$1(id) {
|
|
let start = flushIndex + 1;
|
|
let end = queue.length;
|
|
while (start < end) {
|
|
const middle = start + end >>> 1;
|
|
const middleJob = queue[middle];
|
|
const middleJobId = getId(middleJob);
|
|
if (middleJobId < id || middleJobId === id && middleJob.flags & 2) {
|
|
start = middle + 1;
|
|
} else {
|
|
end = middle;
|
|
}
|
|
}
|
|
return start;
|
|
}
|
|
function queueJob(job) {
|
|
if (!(job.flags & 1)) {
|
|
const jobId = getId(job);
|
|
const lastJob = queue[queue.length - 1];
|
|
if (!lastJob || // fast path when the job id is larger than the tail
|
|
!(job.flags & 2) && jobId >= getId(lastJob)) {
|
|
queue.push(job);
|
|
} else {
|
|
queue.splice(findInsertionIndex$1(jobId), 0, job);
|
|
}
|
|
job.flags |= 1;
|
|
queueFlush();
|
|
}
|
|
}
|
|
function queueFlush() {
|
|
if (!currentFlushPromise) {
|
|
currentFlushPromise = resolvedPromise.then(flushJobs);
|
|
}
|
|
}
|
|
function queuePostFlushCb(cb) {
|
|
if (!isArray$3(cb)) {
|
|
if (activePostFlushCbs && cb.id === -1) {
|
|
activePostFlushCbs.splice(postFlushIndex + 1, 0, cb);
|
|
} else if (!(cb.flags & 1)) {
|
|
pendingPostFlushCbs.push(cb);
|
|
cb.flags |= 1;
|
|
}
|
|
} else {
|
|
pendingPostFlushCbs.push(...cb);
|
|
}
|
|
queueFlush();
|
|
}
|
|
function flushPreFlushCbs(instance, seen2, i = flushIndex + 1) {
|
|
for (; i < queue.length; i++) {
|
|
const cb = queue[i];
|
|
if (cb && cb.flags & 2) {
|
|
if (instance && cb.id !== instance.uid) {
|
|
continue;
|
|
}
|
|
queue.splice(i, 1);
|
|
i--;
|
|
if (cb.flags & 4) {
|
|
cb.flags &= -2;
|
|
}
|
|
cb();
|
|
if (!(cb.flags & 4)) {
|
|
cb.flags &= -2;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function flushPostFlushCbs(seen2) {
|
|
if (pendingPostFlushCbs.length) {
|
|
const deduped = [...new Set(pendingPostFlushCbs)].sort(
|
|
(a, b) => getId(a) - getId(b)
|
|
);
|
|
pendingPostFlushCbs.length = 0;
|
|
if (activePostFlushCbs) {
|
|
activePostFlushCbs.push(...deduped);
|
|
return;
|
|
}
|
|
activePostFlushCbs = deduped;
|
|
for (postFlushIndex = 0; postFlushIndex < activePostFlushCbs.length; postFlushIndex++) {
|
|
const cb = activePostFlushCbs[postFlushIndex];
|
|
if (cb.flags & 4) {
|
|
cb.flags &= -2;
|
|
}
|
|
if (!(cb.flags & 8)) cb();
|
|
cb.flags &= -2;
|
|
}
|
|
activePostFlushCbs = null;
|
|
postFlushIndex = 0;
|
|
}
|
|
}
|
|
const getId = (job) => job.id == null ? job.flags & 2 ? -1 : Infinity : job.id;
|
|
function flushJobs(seen2) {
|
|
try {
|
|
for (flushIndex = 0; flushIndex < queue.length; flushIndex++) {
|
|
const job = queue[flushIndex];
|
|
if (job && !(job.flags & 8)) {
|
|
if (false) ;
|
|
if (job.flags & 4) {
|
|
job.flags &= ~1;
|
|
}
|
|
callWithErrorHandling(
|
|
job,
|
|
job.i,
|
|
job.i ? 15 : 14
|
|
);
|
|
if (!(job.flags & 4)) {
|
|
job.flags &= ~1;
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
for (; flushIndex < queue.length; flushIndex++) {
|
|
const job = queue[flushIndex];
|
|
if (job) {
|
|
job.flags &= -2;
|
|
}
|
|
}
|
|
flushIndex = -1;
|
|
queue.length = 0;
|
|
flushPostFlushCbs();
|
|
currentFlushPromise = null;
|
|
if (queue.length || pendingPostFlushCbs.length) {
|
|
flushJobs();
|
|
}
|
|
}
|
|
}
|
|
let devtools$1;
|
|
let buffer = [];
|
|
function setDevtoolsHook$1(hook, target) {
|
|
var _a, _b;
|
|
devtools$1 = hook;
|
|
if (devtools$1) {
|
|
devtools$1.enabled = true;
|
|
buffer.forEach(({ event, args }) => devtools$1.emit(event, ...args));
|
|
buffer = [];
|
|
} else if (
|
|
// handle late devtools injection - only do this if we are in an actual
|
|
// browser environment to avoid the timer handle stalling test runner exit
|
|
// (#4815)
|
|
typeof window !== "undefined" && // some envs mock window but not fully
|
|
window.HTMLElement && // also exclude jsdom
|
|
// eslint-disable-next-line no-restricted-syntax
|
|
!((_b = (_a = window.navigator) == null ? void 0 : _a.userAgent) == null ? void 0 : _b.includes("jsdom"))
|
|
) {
|
|
const replay = target.__VUE_DEVTOOLS_HOOK_REPLAY__ = target.__VUE_DEVTOOLS_HOOK_REPLAY__ || [];
|
|
replay.push((newHook) => {
|
|
setDevtoolsHook$1(newHook, target);
|
|
});
|
|
setTimeout(() => {
|
|
if (!devtools$1) {
|
|
target.__VUE_DEVTOOLS_HOOK_REPLAY__ = null;
|
|
buffer = [];
|
|
}
|
|
}, 3e3);
|
|
} else {
|
|
buffer = [];
|
|
}
|
|
}
|
|
let currentRenderingInstance = null;
|
|
let currentScopeId = null;
|
|
function setCurrentRenderingInstance(instance) {
|
|
const prev = currentRenderingInstance;
|
|
currentRenderingInstance = instance;
|
|
currentScopeId = instance && instance.type.__scopeId || null;
|
|
return prev;
|
|
}
|
|
function pushScopeId(id) {
|
|
currentScopeId = id;
|
|
}
|
|
function popScopeId() {
|
|
currentScopeId = null;
|
|
}
|
|
const withScopeId = (_id) => withCtx;
|
|
function withCtx(fn, ctx2 = currentRenderingInstance, isNonScopedSlot) {
|
|
if (!ctx2) return fn;
|
|
if (fn._n) {
|
|
return fn;
|
|
}
|
|
const renderFnWithContext = (...args) => {
|
|
if (renderFnWithContext._d) {
|
|
setBlockTracking(-1);
|
|
}
|
|
const prevInstance = setCurrentRenderingInstance(ctx2);
|
|
let res;
|
|
try {
|
|
res = fn(...args);
|
|
} finally {
|
|
setCurrentRenderingInstance(prevInstance);
|
|
if (renderFnWithContext._d) {
|
|
setBlockTracking(1);
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
renderFnWithContext._n = true;
|
|
renderFnWithContext._c = true;
|
|
renderFnWithContext._d = true;
|
|
return renderFnWithContext;
|
|
}
|
|
function withDirectives(vnode, directives) {
|
|
if (currentRenderingInstance === null) {
|
|
return vnode;
|
|
}
|
|
const instance = getComponentPublicInstance(currentRenderingInstance);
|
|
const bindings = vnode.dirs || (vnode.dirs = []);
|
|
for (let i = 0; i < directives.length; i++) {
|
|
let [dir, value, arg, modifiers = EMPTY_OBJ] = directives[i];
|
|
if (dir) {
|
|
if (isFunction$2(dir)) {
|
|
dir = {
|
|
mounted: dir,
|
|
updated: dir
|
|
};
|
|
}
|
|
if (dir.deep) {
|
|
traverse(value);
|
|
}
|
|
bindings.push({
|
|
dir,
|
|
instance,
|
|
value,
|
|
oldValue: void 0,
|
|
arg,
|
|
modifiers
|
|
});
|
|
}
|
|
}
|
|
return vnode;
|
|
}
|
|
function invokeDirectiveHook(vnode, prevVNode, instance, name) {
|
|
const bindings = vnode.dirs;
|
|
const oldBindings = prevVNode && prevVNode.dirs;
|
|
for (let i = 0; i < bindings.length; i++) {
|
|
const binding = bindings[i];
|
|
if (oldBindings) {
|
|
binding.oldValue = oldBindings[i].value;
|
|
}
|
|
let hook = binding.dir[name];
|
|
if (hook) {
|
|
pauseTracking();
|
|
callWithAsyncErrorHandling(hook, instance, 8, [
|
|
vnode.el,
|
|
binding,
|
|
vnode,
|
|
prevVNode
|
|
]);
|
|
resetTracking();
|
|
}
|
|
}
|
|
}
|
|
const TeleportEndKey = Symbol("_vte");
|
|
const isTeleport = (type) => type.__isTeleport;
|
|
const isTeleportDisabled = (props) => props && (props.disabled || props.disabled === "");
|
|
const isTeleportDeferred = (props) => props && (props.defer || props.defer === "");
|
|
const isTargetSVG = (target) => typeof SVGElement !== "undefined" && target instanceof SVGElement;
|
|
const isTargetMathML = (target) => typeof MathMLElement === "function" && target instanceof MathMLElement;
|
|
const resolveTarget = (props, select) => {
|
|
const targetSelector = props && props.to;
|
|
if (isString$1(targetSelector)) {
|
|
if (!select) {
|
|
return null;
|
|
} else {
|
|
const target = select(targetSelector);
|
|
return target;
|
|
}
|
|
} else {
|
|
return targetSelector;
|
|
}
|
|
};
|
|
const TeleportImpl = {
|
|
name: "Teleport",
|
|
__isTeleport: true,
|
|
process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized, internals) {
|
|
const {
|
|
mc: mountChildren,
|
|
pc: patchChildren,
|
|
pbc: patchBlockChildren,
|
|
o: { insert, querySelector, createText, createComment }
|
|
} = internals;
|
|
const disabled = isTeleportDisabled(n2.props);
|
|
let { shapeFlag, children, dynamicChildren } = n2;
|
|
if (n1 == null) {
|
|
const placeholder = n2.el = createText("");
|
|
const mainAnchor = n2.anchor = createText("");
|
|
insert(placeholder, container, anchor);
|
|
insert(mainAnchor, container, anchor);
|
|
const mount2 = (container2, anchor2) => {
|
|
if (shapeFlag & 16) {
|
|
if (parentComponent && parentComponent.isCE) {
|
|
parentComponent.ce._teleportTarget = container2;
|
|
}
|
|
mountChildren(
|
|
children,
|
|
container2,
|
|
anchor2,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
};
|
|
const mountToTarget = () => {
|
|
const target = n2.target = resolveTarget(n2.props, querySelector);
|
|
const targetAnchor = prepareAnchor(target, n2, createText, insert);
|
|
if (target) {
|
|
if (namespace2 !== "svg" && isTargetSVG(target)) {
|
|
namespace2 = "svg";
|
|
} else if (namespace2 !== "mathml" && isTargetMathML(target)) {
|
|
namespace2 = "mathml";
|
|
}
|
|
if (!disabled) {
|
|
mount2(target, targetAnchor);
|
|
updateCssVars(n2, false);
|
|
}
|
|
}
|
|
};
|
|
if (disabled) {
|
|
mount2(container, mainAnchor);
|
|
updateCssVars(n2, true);
|
|
}
|
|
if (isTeleportDeferred(n2.props)) {
|
|
queuePostRenderEffect(() => {
|
|
mountToTarget();
|
|
n2.el.__isMounted = true;
|
|
}, parentSuspense);
|
|
} else {
|
|
mountToTarget();
|
|
}
|
|
} else {
|
|
if (isTeleportDeferred(n2.props) && !n1.el.__isMounted) {
|
|
queuePostRenderEffect(() => {
|
|
TeleportImpl.process(
|
|
n1,
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized,
|
|
internals
|
|
);
|
|
delete n1.el.__isMounted;
|
|
}, parentSuspense);
|
|
return;
|
|
}
|
|
n2.el = n1.el;
|
|
n2.targetStart = n1.targetStart;
|
|
const mainAnchor = n2.anchor = n1.anchor;
|
|
const target = n2.target = n1.target;
|
|
const targetAnchor = n2.targetAnchor = n1.targetAnchor;
|
|
const wasDisabled = isTeleportDisabled(n1.props);
|
|
const currentContainer = wasDisabled ? container : target;
|
|
const currentAnchor = wasDisabled ? mainAnchor : targetAnchor;
|
|
if (namespace2 === "svg" || isTargetSVG(target)) {
|
|
namespace2 = "svg";
|
|
} else if (namespace2 === "mathml" || isTargetMathML(target)) {
|
|
namespace2 = "mathml";
|
|
}
|
|
if (dynamicChildren) {
|
|
patchBlockChildren(
|
|
n1.dynamicChildren,
|
|
dynamicChildren,
|
|
currentContainer,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds
|
|
);
|
|
traverseStaticChildren(n1, n2, true);
|
|
} else if (!optimized) {
|
|
patchChildren(
|
|
n1,
|
|
n2,
|
|
currentContainer,
|
|
currentAnchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
false
|
|
);
|
|
}
|
|
if (disabled) {
|
|
if (!wasDisabled) {
|
|
moveTeleport(
|
|
n2,
|
|
container,
|
|
mainAnchor,
|
|
internals,
|
|
1
|
|
);
|
|
} else {
|
|
if (n2.props && n1.props && n2.props.to !== n1.props.to) {
|
|
n2.props.to = n1.props.to;
|
|
}
|
|
}
|
|
} else {
|
|
if ((n2.props && n2.props.to) !== (n1.props && n1.props.to)) {
|
|
const nextTarget = n2.target = resolveTarget(
|
|
n2.props,
|
|
querySelector
|
|
);
|
|
if (nextTarget) {
|
|
moveTeleport(
|
|
n2,
|
|
nextTarget,
|
|
null,
|
|
internals,
|
|
0
|
|
);
|
|
}
|
|
} else if (wasDisabled) {
|
|
moveTeleport(
|
|
n2,
|
|
target,
|
|
targetAnchor,
|
|
internals,
|
|
1
|
|
);
|
|
}
|
|
}
|
|
updateCssVars(n2, disabled);
|
|
}
|
|
},
|
|
remove(vnode, parentComponent, parentSuspense, { um: unmount2, o: { remove: hostRemove } }, doRemove) {
|
|
const {
|
|
shapeFlag,
|
|
children,
|
|
anchor,
|
|
targetStart,
|
|
targetAnchor,
|
|
target,
|
|
props
|
|
} = vnode;
|
|
if (target) {
|
|
hostRemove(targetStart);
|
|
hostRemove(targetAnchor);
|
|
}
|
|
doRemove && hostRemove(anchor);
|
|
if (shapeFlag & 16) {
|
|
const shouldRemove = doRemove || !isTeleportDisabled(props);
|
|
for (let i = 0; i < children.length; i++) {
|
|
const child = children[i];
|
|
unmount2(
|
|
child,
|
|
parentComponent,
|
|
parentSuspense,
|
|
shouldRemove,
|
|
!!child.dynamicChildren
|
|
);
|
|
}
|
|
}
|
|
},
|
|
move: moveTeleport,
|
|
hydrate: hydrateTeleport
|
|
};
|
|
function moveTeleport(vnode, container, parentAnchor, { o: { insert }, m: move }, moveType = 2) {
|
|
if (moveType === 0) {
|
|
insert(vnode.targetAnchor, container, parentAnchor);
|
|
}
|
|
const { el, anchor, shapeFlag, children, props } = vnode;
|
|
const isReorder = moveType === 2;
|
|
if (isReorder) {
|
|
insert(el, container, parentAnchor);
|
|
}
|
|
if (!isReorder || isTeleportDisabled(props)) {
|
|
if (shapeFlag & 16) {
|
|
for (let i = 0; i < children.length; i++) {
|
|
move(
|
|
children[i],
|
|
container,
|
|
parentAnchor,
|
|
2
|
|
);
|
|
}
|
|
}
|
|
}
|
|
if (isReorder) {
|
|
insert(anchor, container, parentAnchor);
|
|
}
|
|
}
|
|
function hydrateTeleport(node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized, {
|
|
o: { nextSibling, parentNode, querySelector, insert, createText }
|
|
}, hydrateChildren) {
|
|
const target = vnode.target = resolveTarget(
|
|
vnode.props,
|
|
querySelector
|
|
);
|
|
if (target) {
|
|
const disabled = isTeleportDisabled(vnode.props);
|
|
const targetNode = target._lpa || target.firstChild;
|
|
if (vnode.shapeFlag & 16) {
|
|
if (disabled) {
|
|
vnode.anchor = hydrateChildren(
|
|
nextSibling(node),
|
|
vnode,
|
|
parentNode(node),
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
vnode.targetStart = targetNode;
|
|
vnode.targetAnchor = targetNode && nextSibling(targetNode);
|
|
} else {
|
|
vnode.anchor = nextSibling(node);
|
|
let targetAnchor = targetNode;
|
|
while (targetAnchor) {
|
|
if (targetAnchor && targetAnchor.nodeType === 8) {
|
|
if (targetAnchor.data === "teleport start anchor") {
|
|
vnode.targetStart = targetAnchor;
|
|
} else if (targetAnchor.data === "teleport anchor") {
|
|
vnode.targetAnchor = targetAnchor;
|
|
target._lpa = vnode.targetAnchor && nextSibling(vnode.targetAnchor);
|
|
break;
|
|
}
|
|
}
|
|
targetAnchor = nextSibling(targetAnchor);
|
|
}
|
|
if (!vnode.targetAnchor) {
|
|
prepareAnchor(target, vnode, createText, insert);
|
|
}
|
|
hydrateChildren(
|
|
targetNode && nextSibling(targetNode),
|
|
vnode,
|
|
target,
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
}
|
|
updateCssVars(vnode, disabled);
|
|
}
|
|
return vnode.anchor && nextSibling(vnode.anchor);
|
|
}
|
|
const Teleport = TeleportImpl;
|
|
function updateCssVars(vnode, isDisabled) {
|
|
const ctx2 = vnode.ctx;
|
|
if (ctx2 && ctx2.ut) {
|
|
let node, anchor;
|
|
if (isDisabled) {
|
|
node = vnode.el;
|
|
anchor = vnode.anchor;
|
|
} else {
|
|
node = vnode.targetStart;
|
|
anchor = vnode.targetAnchor;
|
|
}
|
|
while (node && node !== anchor) {
|
|
if (node.nodeType === 1) node.setAttribute("data-v-owner", ctx2.uid);
|
|
node = node.nextSibling;
|
|
}
|
|
ctx2.ut();
|
|
}
|
|
}
|
|
function prepareAnchor(target, vnode, createText, insert) {
|
|
const targetStart = vnode.targetStart = createText("");
|
|
const targetAnchor = vnode.targetAnchor = createText("");
|
|
targetStart[TeleportEndKey] = targetAnchor;
|
|
if (target) {
|
|
insert(targetStart, target);
|
|
insert(targetAnchor, target);
|
|
}
|
|
return targetAnchor;
|
|
}
|
|
const leaveCbKey = Symbol("_leaveCb");
|
|
const enterCbKey$1 = Symbol("_enterCb");
|
|
function useTransitionState() {
|
|
const state = {
|
|
isMounted: false,
|
|
isLeaving: false,
|
|
isUnmounting: false,
|
|
leavingVNodes: /* @__PURE__ */ new Map()
|
|
};
|
|
onMounted(() => {
|
|
state.isMounted = true;
|
|
});
|
|
onBeforeUnmount(() => {
|
|
state.isUnmounting = true;
|
|
});
|
|
return state;
|
|
}
|
|
const TransitionHookValidator = [Function, Array];
|
|
const BaseTransitionPropsValidators = {
|
|
mode: String,
|
|
appear: Boolean,
|
|
persisted: Boolean,
|
|
// enter
|
|
onBeforeEnter: TransitionHookValidator,
|
|
onEnter: TransitionHookValidator,
|
|
onAfterEnter: TransitionHookValidator,
|
|
onEnterCancelled: TransitionHookValidator,
|
|
// leave
|
|
onBeforeLeave: TransitionHookValidator,
|
|
onLeave: TransitionHookValidator,
|
|
onAfterLeave: TransitionHookValidator,
|
|
onLeaveCancelled: TransitionHookValidator,
|
|
// appear
|
|
onBeforeAppear: TransitionHookValidator,
|
|
onAppear: TransitionHookValidator,
|
|
onAfterAppear: TransitionHookValidator,
|
|
onAppearCancelled: TransitionHookValidator
|
|
};
|
|
const recursiveGetSubtree = (instance) => {
|
|
const subTree = instance.subTree;
|
|
return subTree.component ? recursiveGetSubtree(subTree.component) : subTree;
|
|
};
|
|
const BaseTransitionImpl = {
|
|
name: `BaseTransition`,
|
|
props: BaseTransitionPropsValidators,
|
|
setup(props, { slots }) {
|
|
const instance = getCurrentInstance();
|
|
const state = useTransitionState();
|
|
return () => {
|
|
const children = slots.default && getTransitionRawChildren(slots.default(), true);
|
|
if (!children || !children.length) {
|
|
return;
|
|
}
|
|
const child = findNonCommentChild(children);
|
|
const rawProps = toRaw(props);
|
|
const { mode } = rawProps;
|
|
if (state.isLeaving) {
|
|
return emptyPlaceholder(child);
|
|
}
|
|
const innerChild = getInnerChild$1(child);
|
|
if (!innerChild) {
|
|
return emptyPlaceholder(child);
|
|
}
|
|
let enterHooks = resolveTransitionHooks(
|
|
innerChild,
|
|
rawProps,
|
|
state,
|
|
instance,
|
|
// #11061, ensure enterHooks is fresh after clone
|
|
(hooks) => enterHooks = hooks
|
|
);
|
|
if (innerChild.type !== Comment) {
|
|
setTransitionHooks(innerChild, enterHooks);
|
|
}
|
|
let oldInnerChild = instance.subTree && getInnerChild$1(instance.subTree);
|
|
if (oldInnerChild && oldInnerChild.type !== Comment && !isSameVNodeType(innerChild, oldInnerChild) && recursiveGetSubtree(instance).type !== Comment) {
|
|
let leavingHooks = resolveTransitionHooks(
|
|
oldInnerChild,
|
|
rawProps,
|
|
state,
|
|
instance
|
|
);
|
|
setTransitionHooks(oldInnerChild, leavingHooks);
|
|
if (mode === "out-in" && innerChild.type !== Comment) {
|
|
state.isLeaving = true;
|
|
leavingHooks.afterLeave = () => {
|
|
state.isLeaving = false;
|
|
if (!(instance.job.flags & 8)) {
|
|
instance.update();
|
|
}
|
|
delete leavingHooks.afterLeave;
|
|
oldInnerChild = void 0;
|
|
};
|
|
return emptyPlaceholder(child);
|
|
} else if (mode === "in-out" && innerChild.type !== Comment) {
|
|
leavingHooks.delayLeave = (el, earlyRemove, delayedLeave) => {
|
|
const leavingVNodesCache = getLeavingNodesForType(
|
|
state,
|
|
oldInnerChild
|
|
);
|
|
leavingVNodesCache[String(oldInnerChild.key)] = oldInnerChild;
|
|
el[leaveCbKey] = () => {
|
|
earlyRemove();
|
|
el[leaveCbKey] = void 0;
|
|
delete enterHooks.delayedLeave;
|
|
oldInnerChild = void 0;
|
|
};
|
|
enterHooks.delayedLeave = () => {
|
|
delayedLeave();
|
|
delete enterHooks.delayedLeave;
|
|
oldInnerChild = void 0;
|
|
};
|
|
};
|
|
} else {
|
|
oldInnerChild = void 0;
|
|
}
|
|
} else if (oldInnerChild) {
|
|
oldInnerChild = void 0;
|
|
}
|
|
return child;
|
|
};
|
|
}
|
|
};
|
|
function findNonCommentChild(children) {
|
|
let child = children[0];
|
|
if (children.length > 1) {
|
|
for (const c2 of children) {
|
|
if (c2.type !== Comment) {
|
|
child = c2;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return child;
|
|
}
|
|
const BaseTransition = BaseTransitionImpl;
|
|
function getLeavingNodesForType(state, vnode) {
|
|
const { leavingVNodes } = state;
|
|
let leavingVNodesCache = leavingVNodes.get(vnode.type);
|
|
if (!leavingVNodesCache) {
|
|
leavingVNodesCache = /* @__PURE__ */ Object.create(null);
|
|
leavingVNodes.set(vnode.type, leavingVNodesCache);
|
|
}
|
|
return leavingVNodesCache;
|
|
}
|
|
function resolveTransitionHooks(vnode, props, state, instance, postClone) {
|
|
const {
|
|
appear,
|
|
mode,
|
|
persisted = false,
|
|
onBeforeEnter,
|
|
onEnter,
|
|
onAfterEnter,
|
|
onEnterCancelled,
|
|
onBeforeLeave,
|
|
onLeave,
|
|
onAfterLeave,
|
|
onLeaveCancelled,
|
|
onBeforeAppear,
|
|
onAppear,
|
|
onAfterAppear,
|
|
onAppearCancelled
|
|
} = props;
|
|
const key = String(vnode.key);
|
|
const leavingVNodesCache = getLeavingNodesForType(state, vnode);
|
|
const callHook2 = (hook, args) => {
|
|
hook && callWithAsyncErrorHandling(
|
|
hook,
|
|
instance,
|
|
9,
|
|
args
|
|
);
|
|
};
|
|
const callAsyncHook = (hook, args) => {
|
|
const done = args[1];
|
|
callHook2(hook, args);
|
|
if (isArray$3(hook)) {
|
|
if (hook.every((hook2) => hook2.length <= 1)) done();
|
|
} else if (hook.length <= 1) {
|
|
done();
|
|
}
|
|
};
|
|
const hooks = {
|
|
mode,
|
|
persisted,
|
|
beforeEnter(el) {
|
|
let hook = onBeforeEnter;
|
|
if (!state.isMounted) {
|
|
if (appear) {
|
|
hook = onBeforeAppear || onBeforeEnter;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
if (el[leaveCbKey]) {
|
|
el[leaveCbKey](
|
|
true
|
|
/* cancelled */
|
|
);
|
|
}
|
|
const leavingVNode = leavingVNodesCache[key];
|
|
if (leavingVNode && isSameVNodeType(vnode, leavingVNode) && leavingVNode.el[leaveCbKey]) {
|
|
leavingVNode.el[leaveCbKey]();
|
|
}
|
|
callHook2(hook, [el]);
|
|
},
|
|
enter(el) {
|
|
let hook = onEnter;
|
|
let afterHook = onAfterEnter;
|
|
let cancelHook = onEnterCancelled;
|
|
if (!state.isMounted) {
|
|
if (appear) {
|
|
hook = onAppear || onEnter;
|
|
afterHook = onAfterAppear || onAfterEnter;
|
|
cancelHook = onAppearCancelled || onEnterCancelled;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
let called = false;
|
|
const done = el[enterCbKey$1] = (cancelled) => {
|
|
if (called) return;
|
|
called = true;
|
|
if (cancelled) {
|
|
callHook2(cancelHook, [el]);
|
|
} else {
|
|
callHook2(afterHook, [el]);
|
|
}
|
|
if (hooks.delayedLeave) {
|
|
hooks.delayedLeave();
|
|
}
|
|
el[enterCbKey$1] = void 0;
|
|
};
|
|
if (hook) {
|
|
callAsyncHook(hook, [el, done]);
|
|
} else {
|
|
done();
|
|
}
|
|
},
|
|
leave(el, remove2) {
|
|
const key2 = String(vnode.key);
|
|
if (el[enterCbKey$1]) {
|
|
el[enterCbKey$1](
|
|
true
|
|
/* cancelled */
|
|
);
|
|
}
|
|
if (state.isUnmounting) {
|
|
return remove2();
|
|
}
|
|
callHook2(onBeforeLeave, [el]);
|
|
let called = false;
|
|
const done = el[leaveCbKey] = (cancelled) => {
|
|
if (called) return;
|
|
called = true;
|
|
remove2();
|
|
if (cancelled) {
|
|
callHook2(onLeaveCancelled, [el]);
|
|
} else {
|
|
callHook2(onAfterLeave, [el]);
|
|
}
|
|
el[leaveCbKey] = void 0;
|
|
if (leavingVNodesCache[key2] === vnode) {
|
|
delete leavingVNodesCache[key2];
|
|
}
|
|
};
|
|
leavingVNodesCache[key2] = vnode;
|
|
if (onLeave) {
|
|
callAsyncHook(onLeave, [el, done]);
|
|
} else {
|
|
done();
|
|
}
|
|
},
|
|
clone(vnode2) {
|
|
const hooks2 = resolveTransitionHooks(
|
|
vnode2,
|
|
props,
|
|
state,
|
|
instance,
|
|
postClone
|
|
);
|
|
if (postClone) postClone(hooks2);
|
|
return hooks2;
|
|
}
|
|
};
|
|
return hooks;
|
|
}
|
|
function emptyPlaceholder(vnode) {
|
|
if (isKeepAlive(vnode)) {
|
|
vnode = cloneVNode(vnode);
|
|
vnode.children = null;
|
|
return vnode;
|
|
}
|
|
}
|
|
function getInnerChild$1(vnode) {
|
|
if (!isKeepAlive(vnode)) {
|
|
if (isTeleport(vnode.type) && vnode.children) {
|
|
return findNonCommentChild(vnode.children);
|
|
}
|
|
return vnode;
|
|
}
|
|
const { shapeFlag, children } = vnode;
|
|
if (children) {
|
|
if (shapeFlag & 16) {
|
|
return children[0];
|
|
}
|
|
if (shapeFlag & 32 && isFunction$2(children.default)) {
|
|
return children.default();
|
|
}
|
|
}
|
|
}
|
|
function setTransitionHooks(vnode, hooks) {
|
|
if (vnode.shapeFlag & 6 && vnode.component) {
|
|
vnode.transition = hooks;
|
|
setTransitionHooks(vnode.component.subTree, hooks);
|
|
} else if (vnode.shapeFlag & 128) {
|
|
vnode.ssContent.transition = hooks.clone(vnode.ssContent);
|
|
vnode.ssFallback.transition = hooks.clone(vnode.ssFallback);
|
|
} else {
|
|
vnode.transition = hooks;
|
|
}
|
|
}
|
|
function getTransitionRawChildren(children, keepComment = false, parentKey) {
|
|
let ret = [];
|
|
let keyedFragmentCount = 0;
|
|
for (let i = 0; i < children.length; i++) {
|
|
let child = children[i];
|
|
const key = parentKey == null ? child.key : String(parentKey) + String(child.key != null ? child.key : i);
|
|
if (child.type === Fragment) {
|
|
if (child.patchFlag & 128) keyedFragmentCount++;
|
|
ret = ret.concat(
|
|
getTransitionRawChildren(child.children, keepComment, key)
|
|
);
|
|
} else if (keepComment || child.type !== Comment) {
|
|
ret.push(key != null ? cloneVNode(child, { key }) : child);
|
|
}
|
|
}
|
|
if (keyedFragmentCount > 1) {
|
|
for (let i = 0; i < ret.length; i++) {
|
|
ret[i].patchFlag = -2;
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
// @__NO_SIDE_EFFECTS__
|
|
function defineComponent(options, extraOptions) {
|
|
return isFunction$2(options) ? (
|
|
// #8236: extend call and options.name access are considered side-effects
|
|
// by Rollup, so we have to wrap it in a pure-annotated IIFE.
|
|
/* @__PURE__ */ (() => extend$1({ name: options.name }, extraOptions, { setup: options }))()
|
|
) : options;
|
|
}
|
|
function useId() {
|
|
const i = getCurrentInstance();
|
|
if (i) {
|
|
return (i.appContext.config.idPrefix || "v") + "-" + i.ids[0] + i.ids[1]++;
|
|
}
|
|
return "";
|
|
}
|
|
function markAsyncBoundary(instance) {
|
|
instance.ids = [instance.ids[0] + instance.ids[2]++ + "-", 0, 0];
|
|
}
|
|
function useTemplateRef(key) {
|
|
const i = getCurrentInstance();
|
|
const r = shallowRef(null);
|
|
if (i) {
|
|
const refs = i.refs === EMPTY_OBJ ? i.refs = {} : i.refs;
|
|
{
|
|
Object.defineProperty(refs, key, {
|
|
enumerable: true,
|
|
get: () => r.value,
|
|
set: (val) => r.value = val
|
|
});
|
|
}
|
|
}
|
|
const ret = r;
|
|
return ret;
|
|
}
|
|
function setRef(rawRef, oldRawRef, parentSuspense, vnode, isUnmount = false) {
|
|
if (isArray$3(rawRef)) {
|
|
rawRef.forEach(
|
|
(r, i) => setRef(
|
|
r,
|
|
oldRawRef && (isArray$3(oldRawRef) ? oldRawRef[i] : oldRawRef),
|
|
parentSuspense,
|
|
vnode,
|
|
isUnmount
|
|
)
|
|
);
|
|
return;
|
|
}
|
|
if (isAsyncWrapper(vnode) && !isUnmount) {
|
|
if (vnode.shapeFlag & 512 && vnode.type.__asyncResolved && vnode.component.subTree.component) {
|
|
setRef(rawRef, oldRawRef, parentSuspense, vnode.component.subTree);
|
|
}
|
|
return;
|
|
}
|
|
const refValue = vnode.shapeFlag & 4 ? getComponentPublicInstance(vnode.component) : vnode.el;
|
|
const value = isUnmount ? null : refValue;
|
|
const { i: owner, r: ref3 } = rawRef;
|
|
const oldRef = oldRawRef && oldRawRef.r;
|
|
const refs = owner.refs === EMPTY_OBJ ? owner.refs = {} : owner.refs;
|
|
const setupState = owner.setupState;
|
|
const rawSetupState = toRaw(setupState);
|
|
const canSetSetupRef = setupState === EMPTY_OBJ ? () => false : (key) => {
|
|
return hasOwn(rawSetupState, key);
|
|
};
|
|
if (oldRef != null && oldRef !== ref3) {
|
|
if (isString$1(oldRef)) {
|
|
refs[oldRef] = null;
|
|
if (canSetSetupRef(oldRef)) {
|
|
setupState[oldRef] = null;
|
|
}
|
|
} else if (isRef(oldRef)) {
|
|
oldRef.value = null;
|
|
}
|
|
}
|
|
if (isFunction$2(ref3)) {
|
|
callWithErrorHandling(ref3, owner, 12, [value, refs]);
|
|
} else {
|
|
const _isString = isString$1(ref3);
|
|
const _isRef = isRef(ref3);
|
|
if (_isString || _isRef) {
|
|
const doSet = () => {
|
|
if (rawRef.f) {
|
|
const existing = _isString ? canSetSetupRef(ref3) ? setupState[ref3] : refs[ref3] : ref3.value;
|
|
if (isUnmount) {
|
|
isArray$3(existing) && remove(existing, refValue);
|
|
} else {
|
|
if (!isArray$3(existing)) {
|
|
if (_isString) {
|
|
refs[ref3] = [refValue];
|
|
if (canSetSetupRef(ref3)) {
|
|
setupState[ref3] = refs[ref3];
|
|
}
|
|
} else {
|
|
ref3.value = [refValue];
|
|
if (rawRef.k) refs[rawRef.k] = ref3.value;
|
|
}
|
|
} else if (!existing.includes(refValue)) {
|
|
existing.push(refValue);
|
|
}
|
|
}
|
|
} else if (_isString) {
|
|
refs[ref3] = value;
|
|
if (canSetSetupRef(ref3)) {
|
|
setupState[ref3] = value;
|
|
}
|
|
} else if (_isRef) {
|
|
ref3.value = value;
|
|
if (rawRef.k) refs[rawRef.k] = value;
|
|
} else ;
|
|
};
|
|
if (value) {
|
|
doSet.id = -1;
|
|
queuePostRenderEffect(doSet, parentSuspense);
|
|
} else {
|
|
doSet();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
let hasLoggedMismatchError = false;
|
|
const logMismatchError = () => {
|
|
if (hasLoggedMismatchError) {
|
|
return;
|
|
}
|
|
console.error("Hydration completed but contains mismatches.");
|
|
hasLoggedMismatchError = true;
|
|
};
|
|
const isSVGContainer = (container) => container.namespaceURI.includes("svg") && container.tagName !== "foreignObject";
|
|
const isMathMLContainer = (container) => container.namespaceURI.includes("MathML");
|
|
const getContainerType = (container) => {
|
|
if (container.nodeType !== 1) return void 0;
|
|
if (isSVGContainer(container)) return "svg";
|
|
if (isMathMLContainer(container)) return "mathml";
|
|
return void 0;
|
|
};
|
|
const isComment = (node) => node.nodeType === 8;
|
|
function createHydrationFunctions(rendererInternals) {
|
|
const {
|
|
mt: mountComponent,
|
|
p: patch,
|
|
o: {
|
|
patchProp: patchProp2,
|
|
createText,
|
|
nextSibling,
|
|
parentNode,
|
|
remove: remove2,
|
|
insert,
|
|
createComment
|
|
}
|
|
} = rendererInternals;
|
|
const hydrate2 = (vnode, container) => {
|
|
if (!container.hasChildNodes()) {
|
|
patch(null, vnode, container);
|
|
flushPostFlushCbs();
|
|
container._vnode = vnode;
|
|
return;
|
|
}
|
|
hydrateNode(container.firstChild, vnode, null, null, null);
|
|
flushPostFlushCbs();
|
|
container._vnode = vnode;
|
|
};
|
|
const hydrateNode = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized = false) => {
|
|
optimized = optimized || !!vnode.dynamicChildren;
|
|
const isFragmentStart = isComment(node) && node.data === "[";
|
|
const onMismatch = () => handleMismatch(
|
|
node,
|
|
vnode,
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
isFragmentStart
|
|
);
|
|
const { type, ref: ref3, shapeFlag, patchFlag } = vnode;
|
|
let domType = node.nodeType;
|
|
vnode.el = node;
|
|
if (patchFlag === -2) {
|
|
optimized = false;
|
|
vnode.dynamicChildren = null;
|
|
}
|
|
let nextNode = null;
|
|
switch (type) {
|
|
case Text:
|
|
if (domType !== 3) {
|
|
if (vnode.children === "") {
|
|
insert(vnode.el = createText(""), parentNode(node), node);
|
|
nextNode = node;
|
|
} else {
|
|
nextNode = onMismatch();
|
|
}
|
|
} else {
|
|
if (node.data !== vnode.children) {
|
|
logMismatchError();
|
|
node.data = vnode.children;
|
|
}
|
|
nextNode = nextSibling(node);
|
|
}
|
|
break;
|
|
case Comment:
|
|
if (isTemplateNode(node)) {
|
|
nextNode = nextSibling(node);
|
|
replaceNode(
|
|
vnode.el = node.content.firstChild,
|
|
node,
|
|
parentComponent
|
|
);
|
|
} else if (domType !== 8 || isFragmentStart) {
|
|
nextNode = onMismatch();
|
|
} else {
|
|
nextNode = nextSibling(node);
|
|
}
|
|
break;
|
|
case Static:
|
|
if (isFragmentStart) {
|
|
node = nextSibling(node);
|
|
domType = node.nodeType;
|
|
}
|
|
if (domType === 1 || domType === 3) {
|
|
nextNode = node;
|
|
const needToAdoptContent = !vnode.children.length;
|
|
for (let i = 0; i < vnode.staticCount; i++) {
|
|
if (needToAdoptContent)
|
|
vnode.children += nextNode.nodeType === 1 ? nextNode.outerHTML : nextNode.data;
|
|
if (i === vnode.staticCount - 1) {
|
|
vnode.anchor = nextNode;
|
|
}
|
|
nextNode = nextSibling(nextNode);
|
|
}
|
|
return isFragmentStart ? nextSibling(nextNode) : nextNode;
|
|
} else {
|
|
onMismatch();
|
|
}
|
|
break;
|
|
case Fragment:
|
|
if (!isFragmentStart) {
|
|
nextNode = onMismatch();
|
|
} else {
|
|
nextNode = hydrateFragment(
|
|
node,
|
|
vnode,
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
break;
|
|
default:
|
|
if (shapeFlag & 1) {
|
|
if ((domType !== 1 || vnode.type.toLowerCase() !== node.tagName.toLowerCase()) && !isTemplateNode(node)) {
|
|
nextNode = onMismatch();
|
|
} else {
|
|
nextNode = hydrateElement(
|
|
node,
|
|
vnode,
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
} else if (shapeFlag & 6) {
|
|
vnode.slotScopeIds = slotScopeIds;
|
|
const container = parentNode(node);
|
|
if (isFragmentStart) {
|
|
nextNode = locateClosingAnchor(node);
|
|
} else if (isComment(node) && node.data === "teleport start") {
|
|
nextNode = locateClosingAnchor(node, node.data, "teleport end");
|
|
} else {
|
|
nextNode = nextSibling(node);
|
|
}
|
|
mountComponent(
|
|
vnode,
|
|
container,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
getContainerType(container),
|
|
optimized
|
|
);
|
|
if (isAsyncWrapper(vnode) && !vnode.type.__asyncResolved) {
|
|
let subTree;
|
|
if (isFragmentStart) {
|
|
subTree = createVNode(Fragment);
|
|
subTree.anchor = nextNode ? nextNode.previousSibling : container.lastChild;
|
|
} else {
|
|
subTree = node.nodeType === 3 ? createTextVNode("") : createVNode("div");
|
|
}
|
|
subTree.el = node;
|
|
vnode.component.subTree = subTree;
|
|
}
|
|
} else if (shapeFlag & 64) {
|
|
if (domType !== 8) {
|
|
nextNode = onMismatch();
|
|
} else {
|
|
nextNode = vnode.type.hydrate(
|
|
node,
|
|
vnode,
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
optimized,
|
|
rendererInternals,
|
|
hydrateChildren
|
|
);
|
|
}
|
|
} else if (shapeFlag & 128) {
|
|
nextNode = vnode.type.hydrate(
|
|
node,
|
|
vnode,
|
|
parentComponent,
|
|
parentSuspense,
|
|
getContainerType(parentNode(node)),
|
|
slotScopeIds,
|
|
optimized,
|
|
rendererInternals,
|
|
hydrateNode
|
|
);
|
|
} else ;
|
|
}
|
|
if (ref3 != null) {
|
|
setRef(ref3, null, parentSuspense, vnode);
|
|
}
|
|
return nextNode;
|
|
};
|
|
const hydrateElement = (el, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
|
optimized = optimized || !!vnode.dynamicChildren;
|
|
const { type, props, patchFlag, shapeFlag, dirs, transition } = vnode;
|
|
const forcePatch = type === "input" || type === "option";
|
|
if (forcePatch || patchFlag !== -1) {
|
|
if (dirs) {
|
|
invokeDirectiveHook(vnode, null, parentComponent, "created");
|
|
}
|
|
let needCallTransitionHooks = false;
|
|
if (isTemplateNode(el)) {
|
|
needCallTransitionHooks = needTransition(
|
|
null,
|
|
// no need check parentSuspense in hydration
|
|
transition
|
|
) && parentComponent && parentComponent.vnode.props && parentComponent.vnode.props.appear;
|
|
const content = el.content.firstChild;
|
|
if (needCallTransitionHooks) {
|
|
transition.beforeEnter(content);
|
|
}
|
|
replaceNode(content, el, parentComponent);
|
|
vnode.el = el = content;
|
|
}
|
|
if (shapeFlag & 16 && // skip if element has innerHTML / textContent
|
|
!(props && (props.innerHTML || props.textContent))) {
|
|
let next = hydrateChildren(
|
|
el.firstChild,
|
|
vnode,
|
|
el,
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
while (next) {
|
|
if (!isMismatchAllowed(
|
|
el,
|
|
1
|
|
/* CHILDREN */
|
|
)) {
|
|
logMismatchError();
|
|
}
|
|
const cur = next;
|
|
next = next.nextSibling;
|
|
remove2(cur);
|
|
}
|
|
} else if (shapeFlag & 8) {
|
|
let clientText = vnode.children;
|
|
if (clientText[0] === "\n" && (el.tagName === "PRE" || el.tagName === "TEXTAREA")) {
|
|
clientText = clientText.slice(1);
|
|
}
|
|
if (el.textContent !== clientText) {
|
|
if (!isMismatchAllowed(
|
|
el,
|
|
0
|
|
/* TEXT */
|
|
)) {
|
|
logMismatchError();
|
|
}
|
|
el.textContent = vnode.children;
|
|
}
|
|
}
|
|
if (props) {
|
|
if (forcePatch || !optimized || patchFlag & (16 | 32)) {
|
|
const isCustomElement = el.tagName.includes("-");
|
|
for (const key in props) {
|
|
if (forcePatch && (key.endsWith("value") || key === "indeterminate") || isOn(key) && !isReservedProp(key) || // force hydrate v-bind with .prop modifiers
|
|
key[0] === "." || isCustomElement) {
|
|
patchProp2(el, key, null, props[key], void 0, parentComponent);
|
|
}
|
|
}
|
|
} else if (props.onClick) {
|
|
patchProp2(
|
|
el,
|
|
"onClick",
|
|
null,
|
|
props.onClick,
|
|
void 0,
|
|
parentComponent
|
|
);
|
|
} else if (patchFlag & 4 && isReactive(props.style)) {
|
|
for (const key in props.style) props.style[key];
|
|
}
|
|
}
|
|
let vnodeHooks;
|
|
if (vnodeHooks = props && props.onVnodeBeforeMount) {
|
|
invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
|
}
|
|
if (dirs) {
|
|
invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
|
}
|
|
if ((vnodeHooks = props && props.onVnodeMounted) || dirs || needCallTransitionHooks) {
|
|
queueEffectWithSuspense(() => {
|
|
vnodeHooks && invokeVNodeHook(vnodeHooks, parentComponent, vnode);
|
|
needCallTransitionHooks && transition.enter(el);
|
|
dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
|
}, parentSuspense);
|
|
}
|
|
}
|
|
return el.nextSibling;
|
|
};
|
|
const hydrateChildren = (node, parentVNode, container, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
|
optimized = optimized || !!parentVNode.dynamicChildren;
|
|
const children = parentVNode.children;
|
|
const l = children.length;
|
|
for (let i = 0; i < l; i++) {
|
|
const vnode = optimized ? children[i] : children[i] = normalizeVNode(children[i]);
|
|
const isText = vnode.type === Text;
|
|
if (node) {
|
|
if (isText && !optimized) {
|
|
if (i + 1 < l && normalizeVNode(children[i + 1]).type === Text) {
|
|
insert(
|
|
createText(
|
|
node.data.slice(vnode.children.length)
|
|
),
|
|
container,
|
|
nextSibling(node)
|
|
);
|
|
node.data = vnode.children;
|
|
}
|
|
}
|
|
node = hydrateNode(
|
|
node,
|
|
vnode,
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else if (isText && !vnode.children) {
|
|
insert(vnode.el = createText(""), container);
|
|
} else {
|
|
if (!isMismatchAllowed(
|
|
container,
|
|
1
|
|
/* CHILDREN */
|
|
)) {
|
|
logMismatchError();
|
|
}
|
|
patch(
|
|
null,
|
|
vnode,
|
|
container,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
getContainerType(container),
|
|
slotScopeIds
|
|
);
|
|
}
|
|
}
|
|
return node;
|
|
};
|
|
const hydrateFragment = (node, vnode, parentComponent, parentSuspense, slotScopeIds, optimized) => {
|
|
const { slotScopeIds: fragmentSlotScopeIds } = vnode;
|
|
if (fragmentSlotScopeIds) {
|
|
slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
|
}
|
|
const container = parentNode(node);
|
|
const next = hydrateChildren(
|
|
nextSibling(node),
|
|
vnode,
|
|
container,
|
|
parentComponent,
|
|
parentSuspense,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
if (next && isComment(next) && next.data === "]") {
|
|
return nextSibling(vnode.anchor = next);
|
|
} else {
|
|
logMismatchError();
|
|
insert(vnode.anchor = createComment(`]`), container, next);
|
|
return next;
|
|
}
|
|
};
|
|
const handleMismatch = (node, vnode, parentComponent, parentSuspense, slotScopeIds, isFragment) => {
|
|
if (!isMismatchAllowed(
|
|
node.parentElement,
|
|
1
|
|
/* CHILDREN */
|
|
)) {
|
|
logMismatchError();
|
|
}
|
|
vnode.el = null;
|
|
if (isFragment) {
|
|
const end = locateClosingAnchor(node);
|
|
while (true) {
|
|
const next2 = nextSibling(node);
|
|
if (next2 && next2 !== end) {
|
|
remove2(next2);
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
const next = nextSibling(node);
|
|
const container = parentNode(node);
|
|
remove2(node);
|
|
patch(
|
|
null,
|
|
vnode,
|
|
container,
|
|
next,
|
|
parentComponent,
|
|
parentSuspense,
|
|
getContainerType(container),
|
|
slotScopeIds
|
|
);
|
|
if (parentComponent) {
|
|
parentComponent.vnode.el = vnode.el;
|
|
updateHOCHostEl(parentComponent, vnode.el);
|
|
}
|
|
return next;
|
|
};
|
|
const locateClosingAnchor = (node, open = "[", close = "]") => {
|
|
let match2 = 0;
|
|
while (node) {
|
|
node = nextSibling(node);
|
|
if (node && isComment(node)) {
|
|
if (node.data === open) match2++;
|
|
if (node.data === close) {
|
|
if (match2 === 0) {
|
|
return nextSibling(node);
|
|
} else {
|
|
match2--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return node;
|
|
};
|
|
const replaceNode = (newNode, oldNode, parentComponent) => {
|
|
const parentNode2 = oldNode.parentNode;
|
|
if (parentNode2) {
|
|
parentNode2.replaceChild(newNode, oldNode);
|
|
}
|
|
let parent = parentComponent;
|
|
while (parent) {
|
|
if (parent.vnode.el === oldNode) {
|
|
parent.vnode.el = parent.subTree.el = newNode;
|
|
}
|
|
parent = parent.parent;
|
|
}
|
|
};
|
|
const isTemplateNode = (node) => {
|
|
return node.nodeType === 1 && node.tagName === "TEMPLATE";
|
|
};
|
|
return [hydrate2, hydrateNode];
|
|
}
|
|
const allowMismatchAttr = "data-allow-mismatch";
|
|
const MismatchTypeString = {
|
|
[
|
|
0
|
|
/* TEXT */
|
|
]: "text",
|
|
[
|
|
1
|
|
/* CHILDREN */
|
|
]: "children",
|
|
[
|
|
2
|
|
/* CLASS */
|
|
]: "class",
|
|
[
|
|
3
|
|
/* STYLE */
|
|
]: "style",
|
|
[
|
|
4
|
|
/* ATTRIBUTE */
|
|
]: "attribute"
|
|
};
|
|
function isMismatchAllowed(el, allowedType) {
|
|
if (allowedType === 0 || allowedType === 1) {
|
|
while (el && !el.hasAttribute(allowMismatchAttr)) {
|
|
el = el.parentElement;
|
|
}
|
|
}
|
|
const allowedAttr = el && el.getAttribute(allowMismatchAttr);
|
|
if (allowedAttr == null) {
|
|
return false;
|
|
} else if (allowedAttr === "") {
|
|
return true;
|
|
} else {
|
|
const list = allowedAttr.split(",");
|
|
if (allowedType === 0 && list.includes("children")) {
|
|
return true;
|
|
}
|
|
return allowedAttr.split(",").includes(MismatchTypeString[allowedType]);
|
|
}
|
|
}
|
|
const requestIdleCallback = getGlobalThis().requestIdleCallback || ((cb) => setTimeout(cb, 1));
|
|
const cancelIdleCallback = getGlobalThis().cancelIdleCallback || ((id) => clearTimeout(id));
|
|
const hydrateOnIdle = (timeout2 = 1e4) => (hydrate2) => {
|
|
const id = requestIdleCallback(hydrate2, { timeout: timeout2 });
|
|
return () => cancelIdleCallback(id);
|
|
};
|
|
function elementIsVisibleInViewport(el) {
|
|
const { top, left, bottom, right } = el.getBoundingClientRect();
|
|
const { innerHeight, innerWidth } = window;
|
|
return (top > 0 && top < innerHeight || bottom > 0 && bottom < innerHeight) && (left > 0 && left < innerWidth || right > 0 && right < innerWidth);
|
|
}
|
|
const hydrateOnVisible = (opts) => (hydrate2, forEach2) => {
|
|
const ob = new IntersectionObserver((entries) => {
|
|
for (const e of entries) {
|
|
if (!e.isIntersecting) continue;
|
|
ob.disconnect();
|
|
hydrate2();
|
|
break;
|
|
}
|
|
}, opts);
|
|
forEach2((el) => {
|
|
if (!(el instanceof Element)) return;
|
|
if (elementIsVisibleInViewport(el)) {
|
|
hydrate2();
|
|
ob.disconnect();
|
|
return false;
|
|
}
|
|
ob.observe(el);
|
|
});
|
|
return () => ob.disconnect();
|
|
};
|
|
const hydrateOnMediaQuery = (query) => (hydrate2) => {
|
|
if (query) {
|
|
const mql = matchMedia(query);
|
|
if (mql.matches) {
|
|
hydrate2();
|
|
} else {
|
|
mql.addEventListener("change", hydrate2, { once: true });
|
|
return () => mql.removeEventListener("change", hydrate2);
|
|
}
|
|
}
|
|
};
|
|
const hydrateOnInteraction = (interactions = []) => (hydrate2, forEach2) => {
|
|
if (isString$1(interactions)) interactions = [interactions];
|
|
let hasHydrated = false;
|
|
const doHydrate = (e) => {
|
|
if (!hasHydrated) {
|
|
hasHydrated = true;
|
|
teardown();
|
|
hydrate2();
|
|
e.target.dispatchEvent(new e.constructor(e.type, e));
|
|
}
|
|
};
|
|
const teardown = () => {
|
|
forEach2((el) => {
|
|
for (const i of interactions) {
|
|
el.removeEventListener(i, doHydrate);
|
|
}
|
|
});
|
|
};
|
|
forEach2((el) => {
|
|
for (const i of interactions) {
|
|
el.addEventListener(i, doHydrate, { once: true });
|
|
}
|
|
});
|
|
return teardown;
|
|
};
|
|
function forEachElement(node, cb) {
|
|
if (isComment(node) && node.data === "[") {
|
|
let depth = 1;
|
|
let next = node.nextSibling;
|
|
while (next) {
|
|
if (next.nodeType === 1) {
|
|
const result = cb(next);
|
|
if (result === false) {
|
|
break;
|
|
}
|
|
} else if (isComment(next)) {
|
|
if (next.data === "]") {
|
|
if (--depth === 0) break;
|
|
} else if (next.data === "[") {
|
|
depth++;
|
|
}
|
|
}
|
|
next = next.nextSibling;
|
|
}
|
|
} else {
|
|
cb(node);
|
|
}
|
|
}
|
|
const isAsyncWrapper = (i) => !!i.type.__asyncLoader;
|
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
// @__NO_SIDE_EFFECTS__
|
|
function defineAsyncComponent(source) {
|
|
if (isFunction$2(source)) {
|
|
source = { loader: source };
|
|
}
|
|
const {
|
|
loader,
|
|
loadingComponent,
|
|
errorComponent,
|
|
delay = 200,
|
|
hydrate: hydrateStrategy,
|
|
timeout: timeout2,
|
|
// undefined = never times out
|
|
suspensible = true,
|
|
onError: userOnError
|
|
} = source;
|
|
let pendingRequest = null;
|
|
let resolvedComp;
|
|
let retries = 0;
|
|
const retry = () => {
|
|
retries++;
|
|
pendingRequest = null;
|
|
return load();
|
|
};
|
|
const load = () => {
|
|
let thisRequest;
|
|
return pendingRequest || (thisRequest = pendingRequest = loader().catch((err) => {
|
|
err = err instanceof Error ? err : new Error(String(err));
|
|
if (userOnError) {
|
|
return new Promise((resolve2, reject) => {
|
|
const userRetry = () => resolve2(retry());
|
|
const userFail = () => reject(err);
|
|
userOnError(err, userRetry, userFail, retries + 1);
|
|
});
|
|
} else {
|
|
throw err;
|
|
}
|
|
}).then((comp) => {
|
|
if (thisRequest !== pendingRequest && pendingRequest) {
|
|
return pendingRequest;
|
|
}
|
|
if (comp && (comp.__esModule || comp[Symbol.toStringTag] === "Module")) {
|
|
comp = comp.default;
|
|
}
|
|
resolvedComp = comp;
|
|
return comp;
|
|
}));
|
|
};
|
|
return /* @__PURE__ */ defineComponent({
|
|
name: "AsyncComponentWrapper",
|
|
__asyncLoader: load,
|
|
__asyncHydrate(el, instance, hydrate2) {
|
|
const doHydrate = hydrateStrategy ? () => {
|
|
const teardown = hydrateStrategy(
|
|
hydrate2,
|
|
(cb) => forEachElement(el, cb)
|
|
);
|
|
if (teardown) {
|
|
(instance.bum || (instance.bum = [])).push(teardown);
|
|
}
|
|
} : hydrate2;
|
|
if (resolvedComp) {
|
|
doHydrate();
|
|
} else {
|
|
load().then(() => !instance.isUnmounted && doHydrate());
|
|
}
|
|
},
|
|
get __asyncResolved() {
|
|
return resolvedComp;
|
|
},
|
|
setup() {
|
|
const instance = currentInstance;
|
|
markAsyncBoundary(instance);
|
|
if (resolvedComp) {
|
|
return () => createInnerComp(resolvedComp, instance);
|
|
}
|
|
const onError = (err) => {
|
|
pendingRequest = null;
|
|
handleError(
|
|
err,
|
|
instance,
|
|
13,
|
|
!errorComponent
|
|
);
|
|
};
|
|
if (suspensible && instance.suspense || isInSSRComponentSetup) {
|
|
return load().then((comp) => {
|
|
return () => createInnerComp(comp, instance);
|
|
}).catch((err) => {
|
|
onError(err);
|
|
return () => errorComponent ? createVNode(errorComponent, {
|
|
error: err
|
|
}) : null;
|
|
});
|
|
}
|
|
const loaded = ref(false);
|
|
const error2 = ref();
|
|
const delayed = ref(!!delay);
|
|
if (delay) {
|
|
setTimeout(() => {
|
|
delayed.value = false;
|
|
}, delay);
|
|
}
|
|
if (timeout2 != null) {
|
|
setTimeout(() => {
|
|
if (!loaded.value && !error2.value) {
|
|
const err = new Error(
|
|
`Async component timed out after ${timeout2}ms.`
|
|
);
|
|
onError(err);
|
|
error2.value = err;
|
|
}
|
|
}, timeout2);
|
|
}
|
|
load().then(() => {
|
|
loaded.value = true;
|
|
if (instance.parent && isKeepAlive(instance.parent.vnode)) {
|
|
instance.parent.update();
|
|
}
|
|
}).catch((err) => {
|
|
onError(err);
|
|
error2.value = err;
|
|
});
|
|
return () => {
|
|
if (loaded.value && resolvedComp) {
|
|
return createInnerComp(resolvedComp, instance);
|
|
} else if (error2.value && errorComponent) {
|
|
return createVNode(errorComponent, {
|
|
error: error2.value
|
|
});
|
|
} else if (loadingComponent && !delayed.value) {
|
|
return createVNode(loadingComponent);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
}
|
|
function createInnerComp(comp, parent) {
|
|
const { ref: ref22, props, children, ce } = parent.vnode;
|
|
const vnode = createVNode(comp, props, children);
|
|
vnode.ref = ref22;
|
|
vnode.ce = ce;
|
|
delete parent.vnode.ce;
|
|
return vnode;
|
|
}
|
|
const isKeepAlive = (vnode) => vnode.type.__isKeepAlive;
|
|
const KeepAliveImpl = {
|
|
name: `KeepAlive`,
|
|
// Marker for special handling inside the renderer. We are not using a ===
|
|
// check directly on KeepAlive in the renderer, because importing it directly
|
|
// would prevent it from being tree-shaken.
|
|
__isKeepAlive: true,
|
|
props: {
|
|
include: [String, RegExp, Array],
|
|
exclude: [String, RegExp, Array],
|
|
max: [String, Number]
|
|
},
|
|
setup(props, { slots }) {
|
|
const instance = getCurrentInstance();
|
|
const sharedContext = instance.ctx;
|
|
if (!sharedContext.renderer) {
|
|
return () => {
|
|
const children = slots.default && slots.default();
|
|
return children && children.length === 1 ? children[0] : children;
|
|
};
|
|
}
|
|
const cache2 = /* @__PURE__ */ new Map();
|
|
const keys = /* @__PURE__ */ new Set();
|
|
let current = null;
|
|
const parentSuspense = instance.suspense;
|
|
const {
|
|
renderer: {
|
|
p: patch,
|
|
m: move,
|
|
um: _unmount,
|
|
o: { createElement: createElement2 }
|
|
}
|
|
} = sharedContext;
|
|
const storageContainer = createElement2("div");
|
|
sharedContext.activate = (vnode, container, anchor, namespace2, optimized) => {
|
|
const instance2 = vnode.component;
|
|
move(vnode, container, anchor, 0, parentSuspense);
|
|
patch(
|
|
instance2.vnode,
|
|
vnode,
|
|
container,
|
|
anchor,
|
|
instance2,
|
|
parentSuspense,
|
|
namespace2,
|
|
vnode.slotScopeIds,
|
|
optimized
|
|
);
|
|
queuePostRenderEffect(() => {
|
|
instance2.isDeactivated = false;
|
|
if (instance2.a) {
|
|
invokeArrayFns(instance2.a);
|
|
}
|
|
const vnodeHook = vnode.props && vnode.props.onVnodeMounted;
|
|
if (vnodeHook) {
|
|
invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
|
}
|
|
}, parentSuspense);
|
|
};
|
|
sharedContext.deactivate = (vnode) => {
|
|
const instance2 = vnode.component;
|
|
invalidateMount(instance2.m);
|
|
invalidateMount(instance2.a);
|
|
move(vnode, storageContainer, null, 1, parentSuspense);
|
|
queuePostRenderEffect(() => {
|
|
if (instance2.da) {
|
|
invokeArrayFns(instance2.da);
|
|
}
|
|
const vnodeHook = vnode.props && vnode.props.onVnodeUnmounted;
|
|
if (vnodeHook) {
|
|
invokeVNodeHook(vnodeHook, instance2.parent, vnode);
|
|
}
|
|
instance2.isDeactivated = true;
|
|
}, parentSuspense);
|
|
};
|
|
function unmount2(vnode) {
|
|
resetShapeFlag(vnode);
|
|
_unmount(vnode, instance, parentSuspense, true);
|
|
}
|
|
function pruneCache(filter2) {
|
|
cache2.forEach((vnode, key) => {
|
|
const name = getComponentName(vnode.type);
|
|
if (name && !filter2(name)) {
|
|
pruneCacheEntry(key);
|
|
}
|
|
});
|
|
}
|
|
function pruneCacheEntry(key) {
|
|
const cached = cache2.get(key);
|
|
if (cached && (!current || !isSameVNodeType(cached, current))) {
|
|
unmount2(cached);
|
|
} else if (current) {
|
|
resetShapeFlag(current);
|
|
}
|
|
cache2.delete(key);
|
|
keys.delete(key);
|
|
}
|
|
watch(
|
|
() => [props.include, props.exclude],
|
|
([include, exclude]) => {
|
|
include && pruneCache((name) => matches(include, name));
|
|
exclude && pruneCache((name) => !matches(exclude, name));
|
|
},
|
|
// prune post-render after `current` has been updated
|
|
{ flush: "post", deep: true }
|
|
);
|
|
let pendingCacheKey = null;
|
|
const cacheSubtree = () => {
|
|
if (pendingCacheKey != null) {
|
|
if (isSuspense(instance.subTree.type)) {
|
|
queuePostRenderEffect(() => {
|
|
cache2.set(pendingCacheKey, getInnerChild(instance.subTree));
|
|
}, instance.subTree.suspense);
|
|
} else {
|
|
cache2.set(pendingCacheKey, getInnerChild(instance.subTree));
|
|
}
|
|
}
|
|
};
|
|
onMounted(cacheSubtree);
|
|
onUpdated(cacheSubtree);
|
|
onBeforeUnmount(() => {
|
|
cache2.forEach((cached) => {
|
|
const { subTree, suspense } = instance;
|
|
const vnode = getInnerChild(subTree);
|
|
if (cached.type === vnode.type && cached.key === vnode.key) {
|
|
resetShapeFlag(vnode);
|
|
const da = vnode.component.da;
|
|
da && queuePostRenderEffect(da, suspense);
|
|
return;
|
|
}
|
|
unmount2(cached);
|
|
});
|
|
});
|
|
return () => {
|
|
pendingCacheKey = null;
|
|
if (!slots.default) {
|
|
return current = null;
|
|
}
|
|
const children = slots.default();
|
|
const rawVNode = children[0];
|
|
if (children.length > 1) {
|
|
current = null;
|
|
return children;
|
|
} else if (!isVNode(rawVNode) || !(rawVNode.shapeFlag & 4) && !(rawVNode.shapeFlag & 128)) {
|
|
current = null;
|
|
return rawVNode;
|
|
}
|
|
let vnode = getInnerChild(rawVNode);
|
|
if (vnode.type === Comment) {
|
|
current = null;
|
|
return vnode;
|
|
}
|
|
const comp = vnode.type;
|
|
const name = getComponentName(
|
|
isAsyncWrapper(vnode) ? vnode.type.__asyncResolved || {} : comp
|
|
);
|
|
const { include, exclude, max } = props;
|
|
if (include && (!name || !matches(include, name)) || exclude && name && matches(exclude, name)) {
|
|
vnode.shapeFlag &= -257;
|
|
current = vnode;
|
|
return rawVNode;
|
|
}
|
|
const key = vnode.key == null ? comp : vnode.key;
|
|
const cachedVNode = cache2.get(key);
|
|
if (vnode.el) {
|
|
vnode = cloneVNode(vnode);
|
|
if (rawVNode.shapeFlag & 128) {
|
|
rawVNode.ssContent = vnode;
|
|
}
|
|
}
|
|
pendingCacheKey = key;
|
|
if (cachedVNode) {
|
|
vnode.el = cachedVNode.el;
|
|
vnode.component = cachedVNode.component;
|
|
if (vnode.transition) {
|
|
setTransitionHooks(vnode, vnode.transition);
|
|
}
|
|
vnode.shapeFlag |= 512;
|
|
keys.delete(key);
|
|
keys.add(key);
|
|
} else {
|
|
keys.add(key);
|
|
if (max && keys.size > parseInt(max, 10)) {
|
|
pruneCacheEntry(keys.values().next().value);
|
|
}
|
|
}
|
|
vnode.shapeFlag |= 256;
|
|
current = vnode;
|
|
return isSuspense(rawVNode.type) ? rawVNode : vnode;
|
|
};
|
|
}
|
|
};
|
|
const KeepAlive = KeepAliveImpl;
|
|
function matches(pattern, name) {
|
|
if (isArray$3(pattern)) {
|
|
return pattern.some((p2) => matches(p2, name));
|
|
} else if (isString$1(pattern)) {
|
|
return pattern.split(",").includes(name);
|
|
} else if (isRegExp$1(pattern)) {
|
|
pattern.lastIndex = 0;
|
|
return pattern.test(name);
|
|
}
|
|
return false;
|
|
}
|
|
function onActivated(hook, target) {
|
|
registerKeepAliveHook(hook, "a", target);
|
|
}
|
|
function onDeactivated(hook, target) {
|
|
registerKeepAliveHook(hook, "da", target);
|
|
}
|
|
function registerKeepAliveHook(hook, type, target = currentInstance) {
|
|
const wrappedHook = hook.__wdc || (hook.__wdc = () => {
|
|
let current = target;
|
|
while (current) {
|
|
if (current.isDeactivated) {
|
|
return;
|
|
}
|
|
current = current.parent;
|
|
}
|
|
return hook();
|
|
});
|
|
injectHook(type, wrappedHook, target);
|
|
if (target) {
|
|
let current = target.parent;
|
|
while (current && current.parent) {
|
|
if (isKeepAlive(current.parent.vnode)) {
|
|
injectToKeepAliveRoot(wrappedHook, type, target, current);
|
|
}
|
|
current = current.parent;
|
|
}
|
|
}
|
|
}
|
|
function injectToKeepAliveRoot(hook, type, target, keepAliveRoot) {
|
|
const injected = injectHook(
|
|
type,
|
|
hook,
|
|
keepAliveRoot,
|
|
true
|
|
/* prepend */
|
|
);
|
|
onUnmounted(() => {
|
|
remove(keepAliveRoot[type], injected);
|
|
}, target);
|
|
}
|
|
function resetShapeFlag(vnode) {
|
|
vnode.shapeFlag &= -257;
|
|
vnode.shapeFlag &= -513;
|
|
}
|
|
function getInnerChild(vnode) {
|
|
return vnode.shapeFlag & 128 ? vnode.ssContent : vnode;
|
|
}
|
|
function injectHook(type, hook, target = currentInstance, prepend = false) {
|
|
if (target) {
|
|
const hooks = target[type] || (target[type] = []);
|
|
const wrappedHook = hook.__weh || (hook.__weh = (...args) => {
|
|
pauseTracking();
|
|
const reset = setCurrentInstance(target);
|
|
const res = callWithAsyncErrorHandling(hook, target, type, args);
|
|
reset();
|
|
resetTracking();
|
|
return res;
|
|
});
|
|
if (prepend) {
|
|
hooks.unshift(wrappedHook);
|
|
} else {
|
|
hooks.push(wrappedHook);
|
|
}
|
|
return wrappedHook;
|
|
}
|
|
}
|
|
const createHook = (lifecycle) => (hook, target = currentInstance) => {
|
|
if (!isInSSRComponentSetup || lifecycle === "sp") {
|
|
injectHook(lifecycle, (...args) => hook(...args), target);
|
|
}
|
|
};
|
|
const onBeforeMount = createHook("bm");
|
|
const onMounted = createHook("m");
|
|
const onBeforeUpdate = createHook(
|
|
"bu"
|
|
);
|
|
const onUpdated = createHook("u");
|
|
const onBeforeUnmount = createHook(
|
|
"bum"
|
|
);
|
|
const onUnmounted = createHook("um");
|
|
const onServerPrefetch = createHook(
|
|
"sp"
|
|
);
|
|
const onRenderTriggered = createHook("rtg");
|
|
const onRenderTracked = createHook("rtc");
|
|
function onErrorCaptured(hook, target = currentInstance) {
|
|
injectHook("ec", hook, target);
|
|
}
|
|
const COMPONENTS = "components";
|
|
const DIRECTIVES = "directives";
|
|
function resolveComponent(name, maybeSelfReference) {
|
|
return resolveAsset(COMPONENTS, name, true, maybeSelfReference) || name;
|
|
}
|
|
const NULL_DYNAMIC_COMPONENT = Symbol.for("v-ndc");
|
|
function resolveDynamicComponent(component) {
|
|
if (isString$1(component)) {
|
|
return resolveAsset(COMPONENTS, component, false) || component;
|
|
} else {
|
|
return component || NULL_DYNAMIC_COMPONENT;
|
|
}
|
|
}
|
|
function resolveDirective(name) {
|
|
return resolveAsset(DIRECTIVES, name);
|
|
}
|
|
function resolveAsset(type, name, warnMissing = true, maybeSelfReference = false) {
|
|
const instance = currentRenderingInstance || currentInstance;
|
|
if (instance) {
|
|
const Component = instance.type;
|
|
if (type === COMPONENTS) {
|
|
const selfName = getComponentName(
|
|
Component,
|
|
false
|
|
);
|
|
if (selfName && (selfName === name || selfName === camelize(name) || selfName === capitalize(camelize(name)))) {
|
|
return Component;
|
|
}
|
|
}
|
|
const res = (
|
|
// local registration
|
|
// check instance[type] first which is resolved for options API
|
|
resolve(instance[type] || Component[type], name) || // global registration
|
|
resolve(instance.appContext[type], name)
|
|
);
|
|
if (!res && maybeSelfReference) {
|
|
return Component;
|
|
}
|
|
return res;
|
|
}
|
|
}
|
|
function resolve(registry, name) {
|
|
return registry && (registry[name] || registry[camelize(name)] || registry[capitalize(camelize(name))]);
|
|
}
|
|
function renderList(source, renderItem, cache2, index) {
|
|
let ret;
|
|
const cached = cache2 && cache2[index];
|
|
const sourceIsArray = isArray$3(source);
|
|
if (sourceIsArray || isString$1(source)) {
|
|
const sourceIsReactiveArray = sourceIsArray && isReactive(source);
|
|
let needsWrap = false;
|
|
if (sourceIsReactiveArray) {
|
|
needsWrap = !isShallow(source);
|
|
source = shallowReadArray(source);
|
|
}
|
|
ret = new Array(source.length);
|
|
for (let i = 0, l = source.length; i < l; i++) {
|
|
ret[i] = renderItem(
|
|
needsWrap ? toReactive(source[i]) : source[i],
|
|
i,
|
|
void 0,
|
|
cached && cached[i]
|
|
);
|
|
}
|
|
} else if (typeof source === "number") {
|
|
ret = new Array(source);
|
|
for (let i = 0; i < source; i++) {
|
|
ret[i] = renderItem(i + 1, i, void 0, cached && cached[i]);
|
|
}
|
|
} else if (isObject$2(source)) {
|
|
if (source[Symbol.iterator]) {
|
|
ret = Array.from(
|
|
source,
|
|
(item, i) => renderItem(item, i, void 0, cached && cached[i])
|
|
);
|
|
} else {
|
|
const keys = Object.keys(source);
|
|
ret = new Array(keys.length);
|
|
for (let i = 0, l = keys.length; i < l; i++) {
|
|
const key = keys[i];
|
|
ret[i] = renderItem(source[key], key, i, cached && cached[i]);
|
|
}
|
|
}
|
|
} else {
|
|
ret = [];
|
|
}
|
|
if (cache2) {
|
|
cache2[index] = ret;
|
|
}
|
|
return ret;
|
|
}
|
|
function createSlots(slots, dynamicSlots) {
|
|
for (let i = 0; i < dynamicSlots.length; i++) {
|
|
const slot = dynamicSlots[i];
|
|
if (isArray$3(slot)) {
|
|
for (let j = 0; j < slot.length; j++) {
|
|
slots[slot[j].name] = slot[j].fn;
|
|
}
|
|
} else if (slot) {
|
|
slots[slot.name] = slot.key ? (...args) => {
|
|
const res = slot.fn(...args);
|
|
if (res) res.key = slot.key;
|
|
return res;
|
|
} : slot.fn;
|
|
}
|
|
}
|
|
return slots;
|
|
}
|
|
function renderSlot(slots, name, props = {}, fallback, noSlotted) {
|
|
if (currentRenderingInstance.ce || currentRenderingInstance.parent && isAsyncWrapper(currentRenderingInstance.parent) && currentRenderingInstance.parent.ce) {
|
|
if (name !== "default") props.name = name;
|
|
return openBlock(), createBlock(
|
|
Fragment,
|
|
null,
|
|
[createVNode("slot", props, fallback && fallback())],
|
|
64
|
|
);
|
|
}
|
|
let slot = slots[name];
|
|
if (slot && slot._c) {
|
|
slot._d = false;
|
|
}
|
|
openBlock();
|
|
const validSlotContent = slot && ensureValidVNode$1(slot(props));
|
|
const slotKey = props.key || // slot content array of a dynamic conditional slot may have a branch
|
|
// key attached in the `createSlots` helper, respect that
|
|
validSlotContent && validSlotContent.key;
|
|
const rendered = createBlock(
|
|
Fragment,
|
|
{
|
|
key: (slotKey && !isSymbol$1(slotKey) ? slotKey : `_${name}`) + // #7256 force differentiate fallback content from actual content
|
|
(!validSlotContent && fallback ? "_fb" : "")
|
|
},
|
|
validSlotContent || (fallback ? fallback() : []),
|
|
validSlotContent && slots._ === 1 ? 64 : -2
|
|
);
|
|
if (!noSlotted && rendered.scopeId) {
|
|
rendered.slotScopeIds = [rendered.scopeId + "-s"];
|
|
}
|
|
if (slot && slot._c) {
|
|
slot._d = true;
|
|
}
|
|
return rendered;
|
|
}
|
|
function ensureValidVNode$1(vnodes) {
|
|
return vnodes.some((child) => {
|
|
if (!isVNode(child)) return true;
|
|
if (child.type === Comment) return false;
|
|
if (child.type === Fragment && !ensureValidVNode$1(child.children))
|
|
return false;
|
|
return true;
|
|
}) ? vnodes : null;
|
|
}
|
|
function toHandlers(obj, preserveCaseIfNecessary) {
|
|
const ret = {};
|
|
for (const key in obj) {
|
|
ret[preserveCaseIfNecessary && /[A-Z]/.test(key) ? `on:${key}` : toHandlerKey(key)] = obj[key];
|
|
}
|
|
return ret;
|
|
}
|
|
const getPublicInstance = (i) => {
|
|
if (!i) return null;
|
|
if (isStatefulComponent(i)) return getComponentPublicInstance(i);
|
|
return getPublicInstance(i.parent);
|
|
};
|
|
const publicPropertiesMap = (
|
|
// Move PURE marker to new line to workaround compiler discarding it
|
|
// due to type annotation
|
|
/* @__PURE__ */ extend$1(/* @__PURE__ */ Object.create(null), {
|
|
$: (i) => i,
|
|
$el: (i) => i.vnode.el,
|
|
$data: (i) => i.data,
|
|
$props: (i) => i.props,
|
|
$attrs: (i) => i.attrs,
|
|
$slots: (i) => i.slots,
|
|
$refs: (i) => i.refs,
|
|
$parent: (i) => getPublicInstance(i.parent),
|
|
$root: (i) => getPublicInstance(i.root),
|
|
$host: (i) => i.ce,
|
|
$emit: (i) => i.emit,
|
|
$options: (i) => resolveMergedOptions(i),
|
|
$forceUpdate: (i) => i.f || (i.f = () => {
|
|
queueJob(i.update);
|
|
}),
|
|
$nextTick: (i) => i.n || (i.n = nextTick.bind(i.proxy)),
|
|
$watch: (i) => instanceWatch.bind(i)
|
|
})
|
|
);
|
|
const hasSetupBinding = (state, key) => state !== EMPTY_OBJ && !state.__isScriptSetup && hasOwn(state, key);
|
|
const PublicInstanceProxyHandlers = {
|
|
get({ _: instance }, key) {
|
|
if (key === "__v_skip") {
|
|
return true;
|
|
}
|
|
const { ctx: ctx2, setupState, data, props, accessCache, type, appContext } = instance;
|
|
let normalizedProps;
|
|
if (key[0] !== "$") {
|
|
const n = accessCache[key];
|
|
if (n !== void 0) {
|
|
switch (n) {
|
|
case 1:
|
|
return setupState[key];
|
|
case 2:
|
|
return data[key];
|
|
case 4:
|
|
return ctx2[key];
|
|
case 3:
|
|
return props[key];
|
|
}
|
|
} else if (hasSetupBinding(setupState, key)) {
|
|
accessCache[key] = 1;
|
|
return setupState[key];
|
|
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
|
accessCache[key] = 2;
|
|
return data[key];
|
|
} else if (
|
|
// only cache other properties when instance has declared (thus stable)
|
|
// props
|
|
(normalizedProps = instance.propsOptions[0]) && hasOwn(normalizedProps, key)
|
|
) {
|
|
accessCache[key] = 3;
|
|
return props[key];
|
|
} else if (ctx2 !== EMPTY_OBJ && hasOwn(ctx2, key)) {
|
|
accessCache[key] = 4;
|
|
return ctx2[key];
|
|
} else if (shouldCacheAccess) {
|
|
accessCache[key] = 0;
|
|
}
|
|
}
|
|
const publicGetter = publicPropertiesMap[key];
|
|
let cssModule, globalProperties;
|
|
if (publicGetter) {
|
|
if (key === "$attrs") {
|
|
track(instance.attrs, "get", "");
|
|
}
|
|
return publicGetter(instance);
|
|
} else if (
|
|
// css module (injected by vue-loader)
|
|
(cssModule = type.__cssModules) && (cssModule = cssModule[key])
|
|
) {
|
|
return cssModule;
|
|
} else if (ctx2 !== EMPTY_OBJ && hasOwn(ctx2, key)) {
|
|
accessCache[key] = 4;
|
|
return ctx2[key];
|
|
} else if (
|
|
// global properties
|
|
globalProperties = appContext.config.globalProperties, hasOwn(globalProperties, key)
|
|
) {
|
|
{
|
|
return globalProperties[key];
|
|
}
|
|
} else ;
|
|
},
|
|
set({ _: instance }, key, value) {
|
|
const { data, setupState, ctx: ctx2 } = instance;
|
|
if (hasSetupBinding(setupState, key)) {
|
|
setupState[key] = value;
|
|
return true;
|
|
} else if (data !== EMPTY_OBJ && hasOwn(data, key)) {
|
|
data[key] = value;
|
|
return true;
|
|
} else if (hasOwn(instance.props, key)) {
|
|
return false;
|
|
}
|
|
if (key[0] === "$" && key.slice(1) in instance) {
|
|
return false;
|
|
} else {
|
|
{
|
|
ctx2[key] = value;
|
|
}
|
|
}
|
|
return true;
|
|
},
|
|
has({
|
|
_: { data, setupState, accessCache, ctx: ctx2, appContext, propsOptions }
|
|
}, key) {
|
|
let normalizedProps;
|
|
return !!accessCache[key] || data !== EMPTY_OBJ && hasOwn(data, key) || hasSetupBinding(setupState, key) || (normalizedProps = propsOptions[0]) && hasOwn(normalizedProps, key) || hasOwn(ctx2, key) || hasOwn(publicPropertiesMap, key) || hasOwn(appContext.config.globalProperties, key);
|
|
},
|
|
defineProperty(target, key, descriptor) {
|
|
if (descriptor.get != null) {
|
|
target._.accessCache[key] = 0;
|
|
} else if (hasOwn(descriptor, "value")) {
|
|
this.set(target, key, descriptor.value, null);
|
|
}
|
|
return Reflect.defineProperty(target, key, descriptor);
|
|
}
|
|
};
|
|
const RuntimeCompiledPublicInstanceProxyHandlers = /* @__PURE__ */ extend$1({}, PublicInstanceProxyHandlers, {
|
|
get(target, key) {
|
|
if (key === Symbol.unscopables) {
|
|
return;
|
|
}
|
|
return PublicInstanceProxyHandlers.get(target, key, target);
|
|
},
|
|
has(_, key) {
|
|
const has = key[0] !== "_" && !isGloballyAllowed(key);
|
|
return has;
|
|
}
|
|
});
|
|
function defineProps() {
|
|
return null;
|
|
}
|
|
function defineEmits() {
|
|
return null;
|
|
}
|
|
function defineExpose(exposed) {
|
|
}
|
|
function defineOptions(options) {
|
|
}
|
|
function defineSlots() {
|
|
return null;
|
|
}
|
|
function defineModel() {
|
|
}
|
|
function withDefaults(props, defaults2) {
|
|
return null;
|
|
}
|
|
function useSlots() {
|
|
return getContext().slots;
|
|
}
|
|
function useAttrs() {
|
|
return getContext().attrs;
|
|
}
|
|
function getContext() {
|
|
const i = getCurrentInstance();
|
|
return i.setupContext || (i.setupContext = createSetupContext(i));
|
|
}
|
|
function normalizePropsOrEmits(props) {
|
|
return isArray$3(props) ? props.reduce(
|
|
(normalized, p2) => (normalized[p2] = null, normalized),
|
|
{}
|
|
) : props;
|
|
}
|
|
function mergeDefaults(raw, defaults2) {
|
|
const props = normalizePropsOrEmits(raw);
|
|
for (const key in defaults2) {
|
|
if (key.startsWith("__skip")) continue;
|
|
let opt = props[key];
|
|
if (opt) {
|
|
if (isArray$3(opt) || isFunction$2(opt)) {
|
|
opt = props[key] = { type: opt, default: defaults2[key] };
|
|
} else {
|
|
opt.default = defaults2[key];
|
|
}
|
|
} else if (opt === null) {
|
|
opt = props[key] = { default: defaults2[key] };
|
|
} else ;
|
|
if (opt && defaults2[`__skip_${key}`]) {
|
|
opt.skipFactory = true;
|
|
}
|
|
}
|
|
return props;
|
|
}
|
|
function mergeModels(a, b) {
|
|
if (!a || !b) return a || b;
|
|
if (isArray$3(a) && isArray$3(b)) return a.concat(b);
|
|
return extend$1({}, normalizePropsOrEmits(a), normalizePropsOrEmits(b));
|
|
}
|
|
function createPropsRestProxy(props, excludedKeys) {
|
|
const ret = {};
|
|
for (const key in props) {
|
|
if (!excludedKeys.includes(key)) {
|
|
Object.defineProperty(ret, key, {
|
|
enumerable: true,
|
|
get: () => props[key]
|
|
});
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
function withAsyncContext(getAwaitable) {
|
|
const ctx2 = getCurrentInstance();
|
|
let awaitable = getAwaitable();
|
|
unsetCurrentInstance();
|
|
if (isPromise(awaitable)) {
|
|
awaitable = awaitable.catch((e) => {
|
|
setCurrentInstance(ctx2);
|
|
throw e;
|
|
});
|
|
}
|
|
return [awaitable, () => setCurrentInstance(ctx2)];
|
|
}
|
|
let shouldCacheAccess = true;
|
|
function applyOptions(instance) {
|
|
const options = resolveMergedOptions(instance);
|
|
const publicThis = instance.proxy;
|
|
const ctx2 = instance.ctx;
|
|
shouldCacheAccess = false;
|
|
if (options.beforeCreate) {
|
|
callHook$1(options.beforeCreate, instance, "bc");
|
|
}
|
|
const {
|
|
// state
|
|
data: dataOptions,
|
|
computed: computedOptions,
|
|
methods,
|
|
watch: watchOptions,
|
|
provide: provideOptions,
|
|
inject: injectOptions,
|
|
// lifecycle
|
|
created,
|
|
beforeMount,
|
|
mounted,
|
|
beforeUpdate,
|
|
updated,
|
|
activated,
|
|
deactivated,
|
|
beforeDestroy,
|
|
beforeUnmount,
|
|
destroyed,
|
|
unmounted,
|
|
render: render2,
|
|
renderTracked,
|
|
renderTriggered,
|
|
errorCaptured,
|
|
serverPrefetch,
|
|
// public API
|
|
expose,
|
|
inheritAttrs,
|
|
// assets
|
|
components,
|
|
directives,
|
|
filters
|
|
} = options;
|
|
const checkDuplicateProperties = null;
|
|
if (injectOptions) {
|
|
resolveInjections(injectOptions, ctx2, checkDuplicateProperties);
|
|
}
|
|
if (methods) {
|
|
for (const key in methods) {
|
|
const methodHandler = methods[key];
|
|
if (isFunction$2(methodHandler)) {
|
|
{
|
|
ctx2[key] = methodHandler.bind(publicThis);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (dataOptions) {
|
|
const data = dataOptions.call(publicThis, publicThis);
|
|
if (!isObject$2(data)) ;
|
|
else {
|
|
instance.data = reactive(data);
|
|
}
|
|
}
|
|
shouldCacheAccess = true;
|
|
if (computedOptions) {
|
|
for (const key in computedOptions) {
|
|
const opt = computedOptions[key];
|
|
const get = isFunction$2(opt) ? opt.bind(publicThis, publicThis) : isFunction$2(opt.get) ? opt.get.bind(publicThis, publicThis) : NOOP;
|
|
const set = !isFunction$2(opt) && isFunction$2(opt.set) ? opt.set.bind(publicThis) : NOOP;
|
|
const c2 = computed({
|
|
get,
|
|
set
|
|
});
|
|
Object.defineProperty(ctx2, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => c2.value,
|
|
set: (v) => c2.value = v
|
|
});
|
|
}
|
|
}
|
|
if (watchOptions) {
|
|
for (const key in watchOptions) {
|
|
createWatcher(watchOptions[key], ctx2, publicThis, key);
|
|
}
|
|
}
|
|
if (provideOptions) {
|
|
const provides = isFunction$2(provideOptions) ? provideOptions.call(publicThis) : provideOptions;
|
|
Reflect.ownKeys(provides).forEach((key) => {
|
|
provide(key, provides[key]);
|
|
});
|
|
}
|
|
if (created) {
|
|
callHook$1(created, instance, "c");
|
|
}
|
|
function registerLifecycleHook(register, hook) {
|
|
if (isArray$3(hook)) {
|
|
hook.forEach((_hook) => register(_hook.bind(publicThis)));
|
|
} else if (hook) {
|
|
register(hook.bind(publicThis));
|
|
}
|
|
}
|
|
registerLifecycleHook(onBeforeMount, beforeMount);
|
|
registerLifecycleHook(onMounted, mounted);
|
|
registerLifecycleHook(onBeforeUpdate, beforeUpdate);
|
|
registerLifecycleHook(onUpdated, updated);
|
|
registerLifecycleHook(onActivated, activated);
|
|
registerLifecycleHook(onDeactivated, deactivated);
|
|
registerLifecycleHook(onErrorCaptured, errorCaptured);
|
|
registerLifecycleHook(onRenderTracked, renderTracked);
|
|
registerLifecycleHook(onRenderTriggered, renderTriggered);
|
|
registerLifecycleHook(onBeforeUnmount, beforeUnmount);
|
|
registerLifecycleHook(onUnmounted, unmounted);
|
|
registerLifecycleHook(onServerPrefetch, serverPrefetch);
|
|
if (isArray$3(expose)) {
|
|
if (expose.length) {
|
|
const exposed = instance.exposed || (instance.exposed = {});
|
|
expose.forEach((key) => {
|
|
Object.defineProperty(exposed, key, {
|
|
get: () => publicThis[key],
|
|
set: (val) => publicThis[key] = val
|
|
});
|
|
});
|
|
} else if (!instance.exposed) {
|
|
instance.exposed = {};
|
|
}
|
|
}
|
|
if (render2 && instance.render === NOOP) {
|
|
instance.render = render2;
|
|
}
|
|
if (inheritAttrs != null) {
|
|
instance.inheritAttrs = inheritAttrs;
|
|
}
|
|
if (components) instance.components = components;
|
|
if (directives) instance.directives = directives;
|
|
if (serverPrefetch) {
|
|
markAsyncBoundary(instance);
|
|
}
|
|
}
|
|
function resolveInjections(injectOptions, ctx2, checkDuplicateProperties = NOOP) {
|
|
if (isArray$3(injectOptions)) {
|
|
injectOptions = normalizeInject(injectOptions);
|
|
}
|
|
for (const key in injectOptions) {
|
|
const opt = injectOptions[key];
|
|
let injected;
|
|
if (isObject$2(opt)) {
|
|
if ("default" in opt) {
|
|
injected = inject(
|
|
opt.from || key,
|
|
opt.default,
|
|
true
|
|
);
|
|
} else {
|
|
injected = inject(opt.from || key);
|
|
}
|
|
} else {
|
|
injected = inject(opt);
|
|
}
|
|
if (isRef(injected)) {
|
|
Object.defineProperty(ctx2, key, {
|
|
enumerable: true,
|
|
configurable: true,
|
|
get: () => injected.value,
|
|
set: (v) => injected.value = v
|
|
});
|
|
} else {
|
|
ctx2[key] = injected;
|
|
}
|
|
}
|
|
}
|
|
function callHook$1(hook, instance, type) {
|
|
callWithAsyncErrorHandling(
|
|
isArray$3(hook) ? hook.map((h2) => h2.bind(instance.proxy)) : hook.bind(instance.proxy),
|
|
instance,
|
|
type
|
|
);
|
|
}
|
|
function createWatcher(raw, ctx2, publicThis, key) {
|
|
let getter = key.includes(".") ? createPathGetter(publicThis, key) : () => publicThis[key];
|
|
if (isString$1(raw)) {
|
|
const handler = ctx2[raw];
|
|
if (isFunction$2(handler)) {
|
|
{
|
|
watch(getter, handler);
|
|
}
|
|
}
|
|
} else if (isFunction$2(raw)) {
|
|
{
|
|
watch(getter, raw.bind(publicThis));
|
|
}
|
|
} else if (isObject$2(raw)) {
|
|
if (isArray$3(raw)) {
|
|
raw.forEach((r) => createWatcher(r, ctx2, publicThis, key));
|
|
} else {
|
|
const handler = isFunction$2(raw.handler) ? raw.handler.bind(publicThis) : ctx2[raw.handler];
|
|
if (isFunction$2(handler)) {
|
|
watch(getter, handler, raw);
|
|
}
|
|
}
|
|
} else ;
|
|
}
|
|
function resolveMergedOptions(instance) {
|
|
const base2 = instance.type;
|
|
const { mixins, extends: extendsOptions } = base2;
|
|
const {
|
|
mixins: globalMixins,
|
|
optionsCache: cache2,
|
|
config: { optionMergeStrategies }
|
|
} = instance.appContext;
|
|
const cached = cache2.get(base2);
|
|
let resolved;
|
|
if (cached) {
|
|
resolved = cached;
|
|
} else if (!globalMixins.length && !mixins && !extendsOptions) {
|
|
{
|
|
resolved = base2;
|
|
}
|
|
} else {
|
|
resolved = {};
|
|
if (globalMixins.length) {
|
|
globalMixins.forEach(
|
|
(m) => mergeOptions$1(resolved, m, optionMergeStrategies, true)
|
|
);
|
|
}
|
|
mergeOptions$1(resolved, base2, optionMergeStrategies);
|
|
}
|
|
if (isObject$2(base2)) {
|
|
cache2.set(base2, resolved);
|
|
}
|
|
return resolved;
|
|
}
|
|
function mergeOptions$1(to, from, strats, asMixin = false) {
|
|
const { mixins, extends: extendsOptions } = from;
|
|
if (extendsOptions) {
|
|
mergeOptions$1(to, extendsOptions, strats, true);
|
|
}
|
|
if (mixins) {
|
|
mixins.forEach(
|
|
(m) => mergeOptions$1(to, m, strats, true)
|
|
);
|
|
}
|
|
for (const key in from) {
|
|
if (asMixin && key === "expose") ;
|
|
else {
|
|
const strat = internalOptionMergeStrats[key] || strats && strats[key];
|
|
to[key] = strat ? strat(to[key], from[key]) : from[key];
|
|
}
|
|
}
|
|
return to;
|
|
}
|
|
const internalOptionMergeStrats = {
|
|
data: mergeDataFn,
|
|
props: mergeEmitsOrPropsOptions,
|
|
emits: mergeEmitsOrPropsOptions,
|
|
// objects
|
|
methods: mergeObjectOptions,
|
|
computed: mergeObjectOptions,
|
|
// lifecycle
|
|
beforeCreate: mergeAsArray,
|
|
created: mergeAsArray,
|
|
beforeMount: mergeAsArray,
|
|
mounted: mergeAsArray,
|
|
beforeUpdate: mergeAsArray,
|
|
updated: mergeAsArray,
|
|
beforeDestroy: mergeAsArray,
|
|
beforeUnmount: mergeAsArray,
|
|
destroyed: mergeAsArray,
|
|
unmounted: mergeAsArray,
|
|
activated: mergeAsArray,
|
|
deactivated: mergeAsArray,
|
|
errorCaptured: mergeAsArray,
|
|
serverPrefetch: mergeAsArray,
|
|
// assets
|
|
components: mergeObjectOptions,
|
|
directives: mergeObjectOptions,
|
|
// watch
|
|
watch: mergeWatchOptions,
|
|
// provide / inject
|
|
provide: mergeDataFn,
|
|
inject: mergeInject
|
|
};
|
|
function mergeDataFn(to, from) {
|
|
if (!from) {
|
|
return to;
|
|
}
|
|
if (!to) {
|
|
return from;
|
|
}
|
|
return function mergedDataFn() {
|
|
return extend$1(
|
|
isFunction$2(to) ? to.call(this, this) : to,
|
|
isFunction$2(from) ? from.call(this, this) : from
|
|
);
|
|
};
|
|
}
|
|
function mergeInject(to, from) {
|
|
return mergeObjectOptions(normalizeInject(to), normalizeInject(from));
|
|
}
|
|
function normalizeInject(raw) {
|
|
if (isArray$3(raw)) {
|
|
const res = {};
|
|
for (let i = 0; i < raw.length; i++) {
|
|
res[raw[i]] = raw[i];
|
|
}
|
|
return res;
|
|
}
|
|
return raw;
|
|
}
|
|
function mergeAsArray(to, from) {
|
|
return to ? [...new Set([].concat(to, from))] : from;
|
|
}
|
|
function mergeObjectOptions(to, from) {
|
|
return to ? extend$1(/* @__PURE__ */ Object.create(null), to, from) : from;
|
|
}
|
|
function mergeEmitsOrPropsOptions(to, from) {
|
|
if (to) {
|
|
if (isArray$3(to) && isArray$3(from)) {
|
|
return [.../* @__PURE__ */ new Set([...to, ...from])];
|
|
}
|
|
return extend$1(
|
|
/* @__PURE__ */ Object.create(null),
|
|
normalizePropsOrEmits(to),
|
|
normalizePropsOrEmits(from != null ? from : {})
|
|
);
|
|
} else {
|
|
return from;
|
|
}
|
|
}
|
|
function mergeWatchOptions(to, from) {
|
|
if (!to) return from;
|
|
if (!from) return to;
|
|
const merged = extend$1(/* @__PURE__ */ Object.create(null), to);
|
|
for (const key in from) {
|
|
merged[key] = mergeAsArray(to[key], from[key]);
|
|
}
|
|
return merged;
|
|
}
|
|
function createAppContext() {
|
|
return {
|
|
app: null,
|
|
config: {
|
|
isNativeTag: NO,
|
|
performance: false,
|
|
globalProperties: {},
|
|
optionMergeStrategies: {},
|
|
errorHandler: void 0,
|
|
warnHandler: void 0,
|
|
compilerOptions: {}
|
|
},
|
|
mixins: [],
|
|
components: {},
|
|
directives: {},
|
|
provides: /* @__PURE__ */ Object.create(null),
|
|
optionsCache: /* @__PURE__ */ new WeakMap(),
|
|
propsCache: /* @__PURE__ */ new WeakMap(),
|
|
emitsCache: /* @__PURE__ */ new WeakMap()
|
|
};
|
|
}
|
|
let uid$1 = 0;
|
|
function createAppAPI(render2, hydrate2) {
|
|
return function createApp2(rootComponent, rootProps = null) {
|
|
if (!isFunction$2(rootComponent)) {
|
|
rootComponent = extend$1({}, rootComponent);
|
|
}
|
|
if (rootProps != null && !isObject$2(rootProps)) {
|
|
rootProps = null;
|
|
}
|
|
const context = createAppContext();
|
|
const installedPlugins = /* @__PURE__ */ new WeakSet();
|
|
const pluginCleanupFns = [];
|
|
let isMounted2 = false;
|
|
const app2 = context.app = {
|
|
_uid: uid$1++,
|
|
_component: rootComponent,
|
|
_props: rootProps,
|
|
_container: null,
|
|
_context: context,
|
|
_instance: null,
|
|
version,
|
|
get config() {
|
|
return context.config;
|
|
},
|
|
set config(v) {
|
|
},
|
|
use(plugin2, ...options) {
|
|
if (installedPlugins.has(plugin2)) ;
|
|
else if (plugin2 && isFunction$2(plugin2.install)) {
|
|
installedPlugins.add(plugin2);
|
|
plugin2.install(app2, ...options);
|
|
} else if (isFunction$2(plugin2)) {
|
|
installedPlugins.add(plugin2);
|
|
plugin2(app2, ...options);
|
|
} else ;
|
|
return app2;
|
|
},
|
|
mixin(mixin) {
|
|
{
|
|
if (!context.mixins.includes(mixin)) {
|
|
context.mixins.push(mixin);
|
|
}
|
|
}
|
|
return app2;
|
|
},
|
|
component(name, component) {
|
|
if (!component) {
|
|
return context.components[name];
|
|
}
|
|
context.components[name] = component;
|
|
return app2;
|
|
},
|
|
directive(name, directive) {
|
|
if (!directive) {
|
|
return context.directives[name];
|
|
}
|
|
context.directives[name] = directive;
|
|
return app2;
|
|
},
|
|
mount(rootContainer, isHydrate, namespace2) {
|
|
if (!isMounted2) {
|
|
const vnode = app2._ceVNode || createVNode(rootComponent, rootProps);
|
|
vnode.appContext = context;
|
|
if (namespace2 === true) {
|
|
namespace2 = "svg";
|
|
} else if (namespace2 === false) {
|
|
namespace2 = void 0;
|
|
}
|
|
if (isHydrate && hydrate2) {
|
|
hydrate2(vnode, rootContainer);
|
|
} else {
|
|
render2(vnode, rootContainer, namespace2);
|
|
}
|
|
isMounted2 = true;
|
|
app2._container = rootContainer;
|
|
rootContainer.__vue_app__ = app2;
|
|
return getComponentPublicInstance(vnode.component);
|
|
}
|
|
},
|
|
onUnmount(cleanupFn) {
|
|
pluginCleanupFns.push(cleanupFn);
|
|
},
|
|
unmount() {
|
|
if (isMounted2) {
|
|
callWithAsyncErrorHandling(
|
|
pluginCleanupFns,
|
|
app2._instance,
|
|
16
|
|
);
|
|
render2(null, app2._container);
|
|
delete app2._container.__vue_app__;
|
|
}
|
|
},
|
|
provide(key, value) {
|
|
context.provides[key] = value;
|
|
return app2;
|
|
},
|
|
runWithContext(fn) {
|
|
const lastApp = currentApp;
|
|
currentApp = app2;
|
|
try {
|
|
return fn();
|
|
} finally {
|
|
currentApp = lastApp;
|
|
}
|
|
}
|
|
};
|
|
return app2;
|
|
};
|
|
}
|
|
let currentApp = null;
|
|
function provide(key, value) {
|
|
if (!currentInstance) ;
|
|
else {
|
|
let provides = currentInstance.provides;
|
|
const parentProvides = currentInstance.parent && currentInstance.parent.provides;
|
|
if (parentProvides === provides) {
|
|
provides = currentInstance.provides = Object.create(parentProvides);
|
|
}
|
|
provides[key] = value;
|
|
}
|
|
}
|
|
function inject(key, defaultValue, treatDefaultAsFactory = false) {
|
|
const instance = currentInstance || currentRenderingInstance;
|
|
if (instance || currentApp) {
|
|
const provides = currentApp ? currentApp._context.provides : instance ? instance.parent == null ? instance.vnode.appContext && instance.vnode.appContext.provides : instance.parent.provides : void 0;
|
|
if (provides && key in provides) {
|
|
return provides[key];
|
|
} else if (arguments.length > 1) {
|
|
return treatDefaultAsFactory && isFunction$2(defaultValue) ? defaultValue.call(instance && instance.proxy) : defaultValue;
|
|
} else ;
|
|
}
|
|
}
|
|
function hasInjectionContext() {
|
|
return !!(currentInstance || currentRenderingInstance || currentApp);
|
|
}
|
|
const internalObjectProto = {};
|
|
const createInternalObject = () => Object.create(internalObjectProto);
|
|
const isInternalObject = (obj) => Object.getPrototypeOf(obj) === internalObjectProto;
|
|
function initProps(instance, rawProps, isStateful, isSSR = false) {
|
|
const props = {};
|
|
const attrs = createInternalObject();
|
|
instance.propsDefaults = /* @__PURE__ */ Object.create(null);
|
|
setFullProps(instance, rawProps, props, attrs);
|
|
for (const key in instance.propsOptions[0]) {
|
|
if (!(key in props)) {
|
|
props[key] = void 0;
|
|
}
|
|
}
|
|
if (isStateful) {
|
|
instance.props = isSSR ? props : shallowReactive(props);
|
|
} else {
|
|
if (!instance.type.props) {
|
|
instance.props = attrs;
|
|
} else {
|
|
instance.props = props;
|
|
}
|
|
}
|
|
instance.attrs = attrs;
|
|
}
|
|
function updateProps(instance, rawProps, rawPrevProps, optimized) {
|
|
const {
|
|
props,
|
|
attrs,
|
|
vnode: { patchFlag }
|
|
} = instance;
|
|
const rawCurrentProps = toRaw(props);
|
|
const [options] = instance.propsOptions;
|
|
let hasAttrsChanged = false;
|
|
if (
|
|
// always force full diff in dev
|
|
// - #1942 if hmr is enabled with sfc component
|
|
// - vite#872 non-sfc component used by sfc component
|
|
(optimized || patchFlag > 0) && !(patchFlag & 16)
|
|
) {
|
|
if (patchFlag & 8) {
|
|
const propsToUpdate = instance.vnode.dynamicProps;
|
|
for (let i = 0; i < propsToUpdate.length; i++) {
|
|
let key = propsToUpdate[i];
|
|
if (isEmitListener(instance.emitsOptions, key)) {
|
|
continue;
|
|
}
|
|
const value = rawProps[key];
|
|
if (options) {
|
|
if (hasOwn(attrs, key)) {
|
|
if (value !== attrs[key]) {
|
|
attrs[key] = value;
|
|
hasAttrsChanged = true;
|
|
}
|
|
} else {
|
|
const camelizedKey = camelize(key);
|
|
props[camelizedKey] = resolvePropValue(
|
|
options,
|
|
rawCurrentProps,
|
|
camelizedKey,
|
|
value,
|
|
instance,
|
|
false
|
|
);
|
|
}
|
|
} else {
|
|
if (value !== attrs[key]) {
|
|
attrs[key] = value;
|
|
hasAttrsChanged = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (setFullProps(instance, rawProps, props, attrs)) {
|
|
hasAttrsChanged = true;
|
|
}
|
|
let kebabKey;
|
|
for (const key in rawCurrentProps) {
|
|
if (!rawProps || // for camelCase
|
|
!hasOwn(rawProps, key) && // it's possible the original props was passed in as kebab-case
|
|
// and converted to camelCase (#955)
|
|
((kebabKey = hyphenate(key)) === key || !hasOwn(rawProps, kebabKey))) {
|
|
if (options) {
|
|
if (rawPrevProps && // for camelCase
|
|
(rawPrevProps[key] !== void 0 || // for kebab-case
|
|
rawPrevProps[kebabKey] !== void 0)) {
|
|
props[key] = resolvePropValue(
|
|
options,
|
|
rawCurrentProps,
|
|
key,
|
|
void 0,
|
|
instance,
|
|
true
|
|
);
|
|
}
|
|
} else {
|
|
delete props[key];
|
|
}
|
|
}
|
|
}
|
|
if (attrs !== rawCurrentProps) {
|
|
for (const key in attrs) {
|
|
if (!rawProps || !hasOwn(rawProps, key) && true) {
|
|
delete attrs[key];
|
|
hasAttrsChanged = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (hasAttrsChanged) {
|
|
trigger$1(instance.attrs, "set", "");
|
|
}
|
|
}
|
|
function setFullProps(instance, rawProps, props, attrs) {
|
|
const [options, needCastKeys] = instance.propsOptions;
|
|
let hasAttrsChanged = false;
|
|
let rawCastValues;
|
|
if (rawProps) {
|
|
for (let key in rawProps) {
|
|
if (isReservedProp(key)) {
|
|
continue;
|
|
}
|
|
const value = rawProps[key];
|
|
let camelKey;
|
|
if (options && hasOwn(options, camelKey = camelize(key))) {
|
|
if (!needCastKeys || !needCastKeys.includes(camelKey)) {
|
|
props[camelKey] = value;
|
|
} else {
|
|
(rawCastValues || (rawCastValues = {}))[camelKey] = value;
|
|
}
|
|
} else if (!isEmitListener(instance.emitsOptions, key)) {
|
|
if (!(key in attrs) || value !== attrs[key]) {
|
|
attrs[key] = value;
|
|
hasAttrsChanged = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (needCastKeys) {
|
|
const rawCurrentProps = toRaw(props);
|
|
const castValues = rawCastValues || EMPTY_OBJ;
|
|
for (let i = 0; i < needCastKeys.length; i++) {
|
|
const key = needCastKeys[i];
|
|
props[key] = resolvePropValue(
|
|
options,
|
|
rawCurrentProps,
|
|
key,
|
|
castValues[key],
|
|
instance,
|
|
!hasOwn(castValues, key)
|
|
);
|
|
}
|
|
}
|
|
return hasAttrsChanged;
|
|
}
|
|
function resolvePropValue(options, props, key, value, instance, isAbsent) {
|
|
const opt = options[key];
|
|
if (opt != null) {
|
|
const hasDefault = hasOwn(opt, "default");
|
|
if (hasDefault && value === void 0) {
|
|
const defaultValue = opt.default;
|
|
if (opt.type !== Function && !opt.skipFactory && isFunction$2(defaultValue)) {
|
|
const { propsDefaults } = instance;
|
|
if (key in propsDefaults) {
|
|
value = propsDefaults[key];
|
|
} else {
|
|
const reset = setCurrentInstance(instance);
|
|
value = propsDefaults[key] = defaultValue.call(
|
|
null,
|
|
props
|
|
);
|
|
reset();
|
|
}
|
|
} else {
|
|
value = defaultValue;
|
|
}
|
|
if (instance.ce) {
|
|
instance.ce._setProp(key, value);
|
|
}
|
|
}
|
|
if (opt[
|
|
0
|
|
/* shouldCast */
|
|
]) {
|
|
if (isAbsent && !hasDefault) {
|
|
value = false;
|
|
} else if (opt[
|
|
1
|
|
/* shouldCastTrue */
|
|
] && (value === "" || value === hyphenate(key))) {
|
|
value = true;
|
|
}
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
const mixinPropsCache = /* @__PURE__ */ new WeakMap();
|
|
function normalizePropsOptions(comp, appContext, asMixin = false) {
|
|
const cache2 = asMixin ? mixinPropsCache : appContext.propsCache;
|
|
const cached = cache2.get(comp);
|
|
if (cached) {
|
|
return cached;
|
|
}
|
|
const raw = comp.props;
|
|
const normalized = {};
|
|
const needCastKeys = [];
|
|
let hasExtends = false;
|
|
if (!isFunction$2(comp)) {
|
|
const extendProps = (raw2) => {
|
|
hasExtends = true;
|
|
const [props, keys] = normalizePropsOptions(raw2, appContext, true);
|
|
extend$1(normalized, props);
|
|
if (keys) needCastKeys.push(...keys);
|
|
};
|
|
if (!asMixin && appContext.mixins.length) {
|
|
appContext.mixins.forEach(extendProps);
|
|
}
|
|
if (comp.extends) {
|
|
extendProps(comp.extends);
|
|
}
|
|
if (comp.mixins) {
|
|
comp.mixins.forEach(extendProps);
|
|
}
|
|
}
|
|
if (!raw && !hasExtends) {
|
|
if (isObject$2(comp)) {
|
|
cache2.set(comp, EMPTY_ARR);
|
|
}
|
|
return EMPTY_ARR;
|
|
}
|
|
if (isArray$3(raw)) {
|
|
for (let i = 0; i < raw.length; i++) {
|
|
const normalizedKey = camelize(raw[i]);
|
|
if (validatePropName(normalizedKey)) {
|
|
normalized[normalizedKey] = EMPTY_OBJ;
|
|
}
|
|
}
|
|
} else if (raw) {
|
|
for (const key in raw) {
|
|
const normalizedKey = camelize(key);
|
|
if (validatePropName(normalizedKey)) {
|
|
const opt = raw[key];
|
|
const prop = normalized[normalizedKey] = isArray$3(opt) || isFunction$2(opt) ? { type: opt } : extend$1({}, opt);
|
|
const propType = prop.type;
|
|
let shouldCast = false;
|
|
let shouldCastTrue = true;
|
|
if (isArray$3(propType)) {
|
|
for (let index = 0; index < propType.length; ++index) {
|
|
const type = propType[index];
|
|
const typeName = isFunction$2(type) && type.name;
|
|
if (typeName === "Boolean") {
|
|
shouldCast = true;
|
|
break;
|
|
} else if (typeName === "String") {
|
|
shouldCastTrue = false;
|
|
}
|
|
}
|
|
} else {
|
|
shouldCast = isFunction$2(propType) && propType.name === "Boolean";
|
|
}
|
|
prop[
|
|
0
|
|
/* shouldCast */
|
|
] = shouldCast;
|
|
prop[
|
|
1
|
|
/* shouldCastTrue */
|
|
] = shouldCastTrue;
|
|
if (shouldCast || hasOwn(prop, "default")) {
|
|
needCastKeys.push(normalizedKey);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const res = [normalized, needCastKeys];
|
|
if (isObject$2(comp)) {
|
|
cache2.set(comp, res);
|
|
}
|
|
return res;
|
|
}
|
|
function validatePropName(key) {
|
|
if (key[0] !== "$" && !isReservedProp(key)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
const isInternalKey = (key) => key[0] === "_" || key === "$stable";
|
|
const normalizeSlotValue = (value) => isArray$3(value) ? value.map(normalizeVNode) : [normalizeVNode(value)];
|
|
const normalizeSlot$1 = (key, rawSlot, ctx2) => {
|
|
if (rawSlot._n) {
|
|
return rawSlot;
|
|
}
|
|
const normalized = withCtx((...args) => {
|
|
if (false) ;
|
|
return normalizeSlotValue(rawSlot(...args));
|
|
}, ctx2);
|
|
normalized._c = false;
|
|
return normalized;
|
|
};
|
|
const normalizeObjectSlots = (rawSlots, slots, instance) => {
|
|
const ctx2 = rawSlots._ctx;
|
|
for (const key in rawSlots) {
|
|
if (isInternalKey(key)) continue;
|
|
const value = rawSlots[key];
|
|
if (isFunction$2(value)) {
|
|
slots[key] = normalizeSlot$1(key, value, ctx2);
|
|
} else if (value != null) {
|
|
const normalized = normalizeSlotValue(value);
|
|
slots[key] = () => normalized;
|
|
}
|
|
}
|
|
};
|
|
const normalizeVNodeSlots = (instance, children) => {
|
|
const normalized = normalizeSlotValue(children);
|
|
instance.slots.default = () => normalized;
|
|
};
|
|
const assignSlots = (slots, children, optimized) => {
|
|
for (const key in children) {
|
|
if (optimized || key !== "_") {
|
|
slots[key] = children[key];
|
|
}
|
|
}
|
|
};
|
|
const initSlots = (instance, children, optimized) => {
|
|
const slots = instance.slots = createInternalObject();
|
|
if (instance.vnode.shapeFlag & 32) {
|
|
const type = children._;
|
|
if (type) {
|
|
assignSlots(slots, children, optimized);
|
|
if (optimized) {
|
|
def(slots, "_", type, true);
|
|
}
|
|
} else {
|
|
normalizeObjectSlots(children, slots);
|
|
}
|
|
} else if (children) {
|
|
normalizeVNodeSlots(instance, children);
|
|
}
|
|
};
|
|
const updateSlots = (instance, children, optimized) => {
|
|
const { vnode, slots } = instance;
|
|
let needDeletionCheck = true;
|
|
let deletionComparisonTarget = EMPTY_OBJ;
|
|
if (vnode.shapeFlag & 32) {
|
|
const type = children._;
|
|
if (type) {
|
|
if (optimized && type === 1) {
|
|
needDeletionCheck = false;
|
|
} else {
|
|
assignSlots(slots, children, optimized);
|
|
}
|
|
} else {
|
|
needDeletionCheck = !children.$stable;
|
|
normalizeObjectSlots(children, slots);
|
|
}
|
|
deletionComparisonTarget = children;
|
|
} else if (children) {
|
|
normalizeVNodeSlots(instance, children);
|
|
deletionComparisonTarget = { default: 1 };
|
|
}
|
|
if (needDeletionCheck) {
|
|
for (const key in slots) {
|
|
if (!isInternalKey(key) && deletionComparisonTarget[key] == null) {
|
|
delete slots[key];
|
|
}
|
|
}
|
|
}
|
|
};
|
|
const queuePostRenderEffect = queueEffectWithSuspense;
|
|
function createRenderer(options) {
|
|
return baseCreateRenderer(options);
|
|
}
|
|
function createHydrationRenderer(options) {
|
|
return baseCreateRenderer(options, createHydrationFunctions);
|
|
}
|
|
function baseCreateRenderer(options, createHydrationFns) {
|
|
const target = getGlobalThis();
|
|
target.__VUE__ = true;
|
|
const {
|
|
insert: hostInsert,
|
|
remove: hostRemove,
|
|
patchProp: hostPatchProp,
|
|
createElement: hostCreateElement,
|
|
createText: hostCreateText,
|
|
createComment: hostCreateComment,
|
|
setText: hostSetText,
|
|
setElementText: hostSetElementText,
|
|
parentNode: hostParentNode,
|
|
nextSibling: hostNextSibling,
|
|
setScopeId: hostSetScopeId = NOOP,
|
|
insertStaticContent: hostInsertStaticContent
|
|
} = options;
|
|
const patch = (n1, n2, container, anchor = null, parentComponent = null, parentSuspense = null, namespace2 = void 0, slotScopeIds = null, optimized = !!n2.dynamicChildren) => {
|
|
if (n1 === n2) {
|
|
return;
|
|
}
|
|
if (n1 && !isSameVNodeType(n1, n2)) {
|
|
anchor = getNextHostNode(n1);
|
|
unmount2(n1, parentComponent, parentSuspense, true);
|
|
n1 = null;
|
|
}
|
|
if (n2.patchFlag === -2) {
|
|
optimized = false;
|
|
n2.dynamicChildren = null;
|
|
}
|
|
const { type, ref: ref3, shapeFlag } = n2;
|
|
switch (type) {
|
|
case Text:
|
|
processText(n1, n2, container, anchor);
|
|
break;
|
|
case Comment:
|
|
processCommentNode(n1, n2, container, anchor);
|
|
break;
|
|
case Static:
|
|
if (n1 == null) {
|
|
mountStaticNode(n2, container, anchor, namespace2);
|
|
}
|
|
break;
|
|
case Fragment:
|
|
processFragment(
|
|
n1,
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
break;
|
|
default:
|
|
if (shapeFlag & 1) {
|
|
processElement(
|
|
n1,
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else if (shapeFlag & 6) {
|
|
processComponent(
|
|
n1,
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else if (shapeFlag & 64) {
|
|
type.process(
|
|
n1,
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized,
|
|
internals
|
|
);
|
|
} else if (shapeFlag & 128) {
|
|
type.process(
|
|
n1,
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized,
|
|
internals
|
|
);
|
|
} else ;
|
|
}
|
|
if (ref3 != null && parentComponent) {
|
|
setRef(ref3, n1 && n1.ref, parentSuspense, n2 || n1, !n2);
|
|
}
|
|
};
|
|
const processText = (n1, n2, container, anchor) => {
|
|
if (n1 == null) {
|
|
hostInsert(
|
|
n2.el = hostCreateText(n2.children),
|
|
container,
|
|
anchor
|
|
);
|
|
} else {
|
|
const el = n2.el = n1.el;
|
|
if (n2.children !== n1.children) {
|
|
hostSetText(el, n2.children);
|
|
}
|
|
}
|
|
};
|
|
const processCommentNode = (n1, n2, container, anchor) => {
|
|
if (n1 == null) {
|
|
hostInsert(
|
|
n2.el = hostCreateComment(n2.children || ""),
|
|
container,
|
|
anchor
|
|
);
|
|
} else {
|
|
n2.el = n1.el;
|
|
}
|
|
};
|
|
const mountStaticNode = (n2, container, anchor, namespace2) => {
|
|
[n2.el, n2.anchor] = hostInsertStaticContent(
|
|
n2.children,
|
|
container,
|
|
anchor,
|
|
namespace2,
|
|
n2.el,
|
|
n2.anchor
|
|
);
|
|
};
|
|
const moveStaticNode = ({ el, anchor }, container, nextSibling) => {
|
|
let next;
|
|
while (el && el !== anchor) {
|
|
next = hostNextSibling(el);
|
|
hostInsert(el, container, nextSibling);
|
|
el = next;
|
|
}
|
|
hostInsert(anchor, container, nextSibling);
|
|
};
|
|
const removeStaticNode = ({ el, anchor }) => {
|
|
let next;
|
|
while (el && el !== anchor) {
|
|
next = hostNextSibling(el);
|
|
hostRemove(el);
|
|
el = next;
|
|
}
|
|
hostRemove(anchor);
|
|
};
|
|
const processElement = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized) => {
|
|
if (n2.type === "svg") {
|
|
namespace2 = "svg";
|
|
} else if (n2.type === "math") {
|
|
namespace2 = "mathml";
|
|
}
|
|
if (n1 == null) {
|
|
mountElement(
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else {
|
|
patchElement(
|
|
n1,
|
|
n2,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
};
|
|
const mountElement = (vnode, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized) => {
|
|
let el;
|
|
let vnodeHook;
|
|
const { props, shapeFlag, transition, dirs } = vnode;
|
|
el = vnode.el = hostCreateElement(
|
|
vnode.type,
|
|
namespace2,
|
|
props && props.is,
|
|
props
|
|
);
|
|
if (shapeFlag & 8) {
|
|
hostSetElementText(el, vnode.children);
|
|
} else if (shapeFlag & 16) {
|
|
mountChildren(
|
|
vnode.children,
|
|
el,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
resolveChildrenNamespace(vnode, namespace2),
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
if (dirs) {
|
|
invokeDirectiveHook(vnode, null, parentComponent, "created");
|
|
}
|
|
setScopeId(el, vnode, vnode.scopeId, slotScopeIds, parentComponent);
|
|
if (props) {
|
|
for (const key in props) {
|
|
if (key !== "value" && !isReservedProp(key)) {
|
|
hostPatchProp(el, key, null, props[key], namespace2, parentComponent);
|
|
}
|
|
}
|
|
if ("value" in props) {
|
|
hostPatchProp(el, "value", null, props.value, namespace2);
|
|
}
|
|
if (vnodeHook = props.onVnodeBeforeMount) {
|
|
invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
|
}
|
|
}
|
|
if (dirs) {
|
|
invokeDirectiveHook(vnode, null, parentComponent, "beforeMount");
|
|
}
|
|
const needCallTransitionHooks = needTransition(parentSuspense, transition);
|
|
if (needCallTransitionHooks) {
|
|
transition.beforeEnter(el);
|
|
}
|
|
hostInsert(el, container, anchor);
|
|
if ((vnodeHook = props && props.onVnodeMounted) || needCallTransitionHooks || dirs) {
|
|
queuePostRenderEffect(() => {
|
|
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
|
needCallTransitionHooks && transition.enter(el);
|
|
dirs && invokeDirectiveHook(vnode, null, parentComponent, "mounted");
|
|
}, parentSuspense);
|
|
}
|
|
};
|
|
const setScopeId = (el, vnode, scopeId, slotScopeIds, parentComponent) => {
|
|
if (scopeId) {
|
|
hostSetScopeId(el, scopeId);
|
|
}
|
|
if (slotScopeIds) {
|
|
for (let i = 0; i < slotScopeIds.length; i++) {
|
|
hostSetScopeId(el, slotScopeIds[i]);
|
|
}
|
|
}
|
|
if (parentComponent) {
|
|
let subTree = parentComponent.subTree;
|
|
if (vnode === subTree || isSuspense(subTree.type) && (subTree.ssContent === vnode || subTree.ssFallback === vnode)) {
|
|
const parentVNode = parentComponent.vnode;
|
|
setScopeId(
|
|
el,
|
|
parentVNode,
|
|
parentVNode.scopeId,
|
|
parentVNode.slotScopeIds,
|
|
parentComponent.parent
|
|
);
|
|
}
|
|
}
|
|
};
|
|
const mountChildren = (children, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized, start = 0) => {
|
|
for (let i = start; i < children.length; i++) {
|
|
const child = children[i] = optimized ? cloneIfMounted(children[i]) : normalizeVNode(children[i]);
|
|
patch(
|
|
null,
|
|
child,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
};
|
|
const patchElement = (n1, n2, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized) => {
|
|
const el = n2.el = n1.el;
|
|
let { patchFlag, dynamicChildren, dirs } = n2;
|
|
patchFlag |= n1.patchFlag & 16;
|
|
const oldProps = n1.props || EMPTY_OBJ;
|
|
const newProps = n2.props || EMPTY_OBJ;
|
|
let vnodeHook;
|
|
parentComponent && toggleRecurse(parentComponent, false);
|
|
if (vnodeHook = newProps.onVnodeBeforeUpdate) {
|
|
invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
|
}
|
|
if (dirs) {
|
|
invokeDirectiveHook(n2, n1, parentComponent, "beforeUpdate");
|
|
}
|
|
parentComponent && toggleRecurse(parentComponent, true);
|
|
if (oldProps.innerHTML && newProps.innerHTML == null || oldProps.textContent && newProps.textContent == null) {
|
|
hostSetElementText(el, "");
|
|
}
|
|
if (dynamicChildren) {
|
|
patchBlockChildren(
|
|
n1.dynamicChildren,
|
|
dynamicChildren,
|
|
el,
|
|
parentComponent,
|
|
parentSuspense,
|
|
resolveChildrenNamespace(n2, namespace2),
|
|
slotScopeIds
|
|
);
|
|
} else if (!optimized) {
|
|
patchChildren(
|
|
n1,
|
|
n2,
|
|
el,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
resolveChildrenNamespace(n2, namespace2),
|
|
slotScopeIds,
|
|
false
|
|
);
|
|
}
|
|
if (patchFlag > 0) {
|
|
if (patchFlag & 16) {
|
|
patchProps(el, oldProps, newProps, parentComponent, namespace2);
|
|
} else {
|
|
if (patchFlag & 2) {
|
|
if (oldProps.class !== newProps.class) {
|
|
hostPatchProp(el, "class", null, newProps.class, namespace2);
|
|
}
|
|
}
|
|
if (patchFlag & 4) {
|
|
hostPatchProp(el, "style", oldProps.style, newProps.style, namespace2);
|
|
}
|
|
if (patchFlag & 8) {
|
|
const propsToUpdate = n2.dynamicProps;
|
|
for (let i = 0; i < propsToUpdate.length; i++) {
|
|
const key = propsToUpdate[i];
|
|
const prev = oldProps[key];
|
|
const next = newProps[key];
|
|
if (next !== prev || key === "value") {
|
|
hostPatchProp(el, key, prev, next, namespace2, parentComponent);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (patchFlag & 1) {
|
|
if (n1.children !== n2.children) {
|
|
hostSetElementText(el, n2.children);
|
|
}
|
|
}
|
|
} else if (!optimized && dynamicChildren == null) {
|
|
patchProps(el, oldProps, newProps, parentComponent, namespace2);
|
|
}
|
|
if ((vnodeHook = newProps.onVnodeUpdated) || dirs) {
|
|
queuePostRenderEffect(() => {
|
|
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, n2, n1);
|
|
dirs && invokeDirectiveHook(n2, n1, parentComponent, "updated");
|
|
}, parentSuspense);
|
|
}
|
|
};
|
|
const patchBlockChildren = (oldChildren, newChildren, fallbackContainer, parentComponent, parentSuspense, namespace2, slotScopeIds) => {
|
|
for (let i = 0; i < newChildren.length; i++) {
|
|
const oldVNode = oldChildren[i];
|
|
const newVNode = newChildren[i];
|
|
const container = (
|
|
// oldVNode may be an errored async setup() component inside Suspense
|
|
// which will not have a mounted element
|
|
oldVNode.el && // - In the case of a Fragment, we need to provide the actual parent
|
|
// of the Fragment itself so it can move its children.
|
|
(oldVNode.type === Fragment || // - In the case of different nodes, there is going to be a replacement
|
|
// which also requires the correct parent container
|
|
!isSameVNodeType(oldVNode, newVNode) || // - In the case of a component, it could contain anything.
|
|
oldVNode.shapeFlag & (6 | 64)) ? hostParentNode(oldVNode.el) : (
|
|
// In other cases, the parent container is not actually used so we
|
|
// just pass the block element here to avoid a DOM parentNode call.
|
|
fallbackContainer
|
|
)
|
|
);
|
|
patch(
|
|
oldVNode,
|
|
newVNode,
|
|
container,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
true
|
|
);
|
|
}
|
|
};
|
|
const patchProps = (el, oldProps, newProps, parentComponent, namespace2) => {
|
|
if (oldProps !== newProps) {
|
|
if (oldProps !== EMPTY_OBJ) {
|
|
for (const key in oldProps) {
|
|
if (!isReservedProp(key) && !(key in newProps)) {
|
|
hostPatchProp(
|
|
el,
|
|
key,
|
|
oldProps[key],
|
|
null,
|
|
namespace2,
|
|
parentComponent
|
|
);
|
|
}
|
|
}
|
|
}
|
|
for (const key in newProps) {
|
|
if (isReservedProp(key)) continue;
|
|
const next = newProps[key];
|
|
const prev = oldProps[key];
|
|
if (next !== prev && key !== "value") {
|
|
hostPatchProp(el, key, prev, next, namespace2, parentComponent);
|
|
}
|
|
}
|
|
if ("value" in newProps) {
|
|
hostPatchProp(el, "value", oldProps.value, newProps.value, namespace2);
|
|
}
|
|
}
|
|
};
|
|
const processFragment = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized) => {
|
|
const fragmentStartAnchor = n2.el = n1 ? n1.el : hostCreateText("");
|
|
const fragmentEndAnchor = n2.anchor = n1 ? n1.anchor : hostCreateText("");
|
|
let { patchFlag, dynamicChildren, slotScopeIds: fragmentSlotScopeIds } = n2;
|
|
if (fragmentSlotScopeIds) {
|
|
slotScopeIds = slotScopeIds ? slotScopeIds.concat(fragmentSlotScopeIds) : fragmentSlotScopeIds;
|
|
}
|
|
if (n1 == null) {
|
|
hostInsert(fragmentStartAnchor, container, anchor);
|
|
hostInsert(fragmentEndAnchor, container, anchor);
|
|
mountChildren(
|
|
// #10007
|
|
// such fragment like `<></>` will be compiled into
|
|
// a fragment which doesn't have a children.
|
|
// In this case fallback to an empty array
|
|
n2.children || [],
|
|
container,
|
|
fragmentEndAnchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else {
|
|
if (patchFlag > 0 && patchFlag & 64 && dynamicChildren && // #2715 the previous fragment could've been a BAILed one as a result
|
|
// of renderSlot() with no valid children
|
|
n1.dynamicChildren) {
|
|
patchBlockChildren(
|
|
n1.dynamicChildren,
|
|
dynamicChildren,
|
|
container,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds
|
|
);
|
|
if (
|
|
// #2080 if the stable fragment has a key, it's a <template v-for> that may
|
|
// get moved around. Make sure all root level vnodes inherit el.
|
|
// #2134 or if it's a component root, it may also get moved around
|
|
// as the component is being moved.
|
|
n2.key != null || parentComponent && n2 === parentComponent.subTree
|
|
) {
|
|
traverseStaticChildren(
|
|
n1,
|
|
n2,
|
|
true
|
|
/* shallow */
|
|
);
|
|
}
|
|
} else {
|
|
patchChildren(
|
|
n1,
|
|
n2,
|
|
container,
|
|
fragmentEndAnchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
}
|
|
};
|
|
const processComponent = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized) => {
|
|
n2.slotScopeIds = slotScopeIds;
|
|
if (n1 == null) {
|
|
if (n2.shapeFlag & 512) {
|
|
parentComponent.ctx.activate(
|
|
n2,
|
|
container,
|
|
anchor,
|
|
namespace2,
|
|
optimized
|
|
);
|
|
} else {
|
|
mountComponent(
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
optimized
|
|
);
|
|
}
|
|
} else {
|
|
updateComponent(n1, n2, optimized);
|
|
}
|
|
};
|
|
const mountComponent = (initialVNode, container, anchor, parentComponent, parentSuspense, namespace2, optimized) => {
|
|
const instance = initialVNode.component = createComponentInstance(
|
|
initialVNode,
|
|
parentComponent,
|
|
parentSuspense
|
|
);
|
|
if (isKeepAlive(initialVNode)) {
|
|
instance.ctx.renderer = internals;
|
|
}
|
|
{
|
|
setupComponent(instance, false, optimized);
|
|
}
|
|
if (instance.asyncDep) {
|
|
parentSuspense && parentSuspense.registerDep(instance, setupRenderEffect, optimized);
|
|
if (!initialVNode.el) {
|
|
const placeholder = instance.subTree = createVNode(Comment);
|
|
processCommentNode(null, placeholder, container, anchor);
|
|
}
|
|
} else {
|
|
setupRenderEffect(
|
|
instance,
|
|
initialVNode,
|
|
container,
|
|
anchor,
|
|
parentSuspense,
|
|
namespace2,
|
|
optimized
|
|
);
|
|
}
|
|
};
|
|
const updateComponent = (n1, n2, optimized) => {
|
|
const instance = n2.component = n1.component;
|
|
if (shouldUpdateComponent(n1, n2, optimized)) {
|
|
if (instance.asyncDep && !instance.asyncResolved) {
|
|
updateComponentPreRender(instance, n2, optimized);
|
|
return;
|
|
} else {
|
|
instance.next = n2;
|
|
instance.update();
|
|
}
|
|
} else {
|
|
n2.el = n1.el;
|
|
instance.vnode = n2;
|
|
}
|
|
};
|
|
const setupRenderEffect = (instance, initialVNode, container, anchor, parentSuspense, namespace2, optimized) => {
|
|
const componentUpdateFn = () => {
|
|
if (!instance.isMounted) {
|
|
let vnodeHook;
|
|
const { el, props } = initialVNode;
|
|
const { bm, m, parent, root: root2, type } = instance;
|
|
const isAsyncWrapperVNode = isAsyncWrapper(initialVNode);
|
|
toggleRecurse(instance, false);
|
|
if (bm) {
|
|
invokeArrayFns(bm);
|
|
}
|
|
if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeBeforeMount)) {
|
|
invokeVNodeHook(vnodeHook, parent, initialVNode);
|
|
}
|
|
toggleRecurse(instance, true);
|
|
if (el && hydrateNode) {
|
|
const hydrateSubTree = () => {
|
|
instance.subTree = renderComponentRoot(instance);
|
|
hydrateNode(
|
|
el,
|
|
instance.subTree,
|
|
instance,
|
|
parentSuspense,
|
|
null
|
|
);
|
|
};
|
|
if (isAsyncWrapperVNode && type.__asyncHydrate) {
|
|
type.__asyncHydrate(
|
|
el,
|
|
instance,
|
|
hydrateSubTree
|
|
);
|
|
} else {
|
|
hydrateSubTree();
|
|
}
|
|
} else {
|
|
if (root2.ce) {
|
|
root2.ce._injectChildStyle(type);
|
|
}
|
|
const subTree = instance.subTree = renderComponentRoot(instance);
|
|
patch(
|
|
null,
|
|
subTree,
|
|
container,
|
|
anchor,
|
|
instance,
|
|
parentSuspense,
|
|
namespace2
|
|
);
|
|
initialVNode.el = subTree.el;
|
|
}
|
|
if (m) {
|
|
queuePostRenderEffect(m, parentSuspense);
|
|
}
|
|
if (!isAsyncWrapperVNode && (vnodeHook = props && props.onVnodeMounted)) {
|
|
const scopedInitialVNode = initialVNode;
|
|
queuePostRenderEffect(
|
|
() => invokeVNodeHook(vnodeHook, parent, scopedInitialVNode),
|
|
parentSuspense
|
|
);
|
|
}
|
|
if (initialVNode.shapeFlag & 256 || parent && isAsyncWrapper(parent.vnode) && parent.vnode.shapeFlag & 256) {
|
|
instance.a && queuePostRenderEffect(instance.a, parentSuspense);
|
|
}
|
|
instance.isMounted = true;
|
|
initialVNode = container = anchor = null;
|
|
} else {
|
|
let { next, bu, u, parent, vnode } = instance;
|
|
{
|
|
const nonHydratedAsyncRoot = locateNonHydratedAsyncRoot(instance);
|
|
if (nonHydratedAsyncRoot) {
|
|
if (next) {
|
|
next.el = vnode.el;
|
|
updateComponentPreRender(instance, next, optimized);
|
|
}
|
|
nonHydratedAsyncRoot.asyncDep.then(() => {
|
|
if (!instance.isUnmounted) {
|
|
componentUpdateFn();
|
|
}
|
|
});
|
|
return;
|
|
}
|
|
}
|
|
let originNext = next;
|
|
let vnodeHook;
|
|
toggleRecurse(instance, false);
|
|
if (next) {
|
|
next.el = vnode.el;
|
|
updateComponentPreRender(instance, next, optimized);
|
|
} else {
|
|
next = vnode;
|
|
}
|
|
if (bu) {
|
|
invokeArrayFns(bu);
|
|
}
|
|
if (vnodeHook = next.props && next.props.onVnodeBeforeUpdate) {
|
|
invokeVNodeHook(vnodeHook, parent, next, vnode);
|
|
}
|
|
toggleRecurse(instance, true);
|
|
const nextTree = renderComponentRoot(instance);
|
|
const prevTree = instance.subTree;
|
|
instance.subTree = nextTree;
|
|
patch(
|
|
prevTree,
|
|
nextTree,
|
|
// parent may have changed if it's in a teleport
|
|
hostParentNode(prevTree.el),
|
|
// anchor may have changed if it's in a fragment
|
|
getNextHostNode(prevTree),
|
|
instance,
|
|
parentSuspense,
|
|
namespace2
|
|
);
|
|
next.el = nextTree.el;
|
|
if (originNext === null) {
|
|
updateHOCHostEl(instance, nextTree.el);
|
|
}
|
|
if (u) {
|
|
queuePostRenderEffect(u, parentSuspense);
|
|
}
|
|
if (vnodeHook = next.props && next.props.onVnodeUpdated) {
|
|
queuePostRenderEffect(
|
|
() => invokeVNodeHook(vnodeHook, parent, next, vnode),
|
|
parentSuspense
|
|
);
|
|
}
|
|
}
|
|
};
|
|
instance.scope.on();
|
|
const effect2 = instance.effect = new ReactiveEffect(componentUpdateFn);
|
|
instance.scope.off();
|
|
const update = instance.update = effect2.run.bind(effect2);
|
|
const job = instance.job = effect2.runIfDirty.bind(effect2);
|
|
job.i = instance;
|
|
job.id = instance.uid;
|
|
effect2.scheduler = () => queueJob(job);
|
|
toggleRecurse(instance, true);
|
|
update();
|
|
};
|
|
const updateComponentPreRender = (instance, nextVNode, optimized) => {
|
|
nextVNode.component = instance;
|
|
const prevProps = instance.vnode.props;
|
|
instance.vnode = nextVNode;
|
|
instance.next = null;
|
|
updateProps(instance, nextVNode.props, prevProps, optimized);
|
|
updateSlots(instance, nextVNode.children, optimized);
|
|
pauseTracking();
|
|
flushPreFlushCbs(instance);
|
|
resetTracking();
|
|
};
|
|
const patchChildren = (n1, n2, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized = false) => {
|
|
const c1 = n1 && n1.children;
|
|
const prevShapeFlag = n1 ? n1.shapeFlag : 0;
|
|
const c2 = n2.children;
|
|
const { patchFlag, shapeFlag } = n2;
|
|
if (patchFlag > 0) {
|
|
if (patchFlag & 128) {
|
|
patchKeyedChildren(
|
|
c1,
|
|
c2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
return;
|
|
} else if (patchFlag & 256) {
|
|
patchUnkeyedChildren(
|
|
c1,
|
|
c2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
return;
|
|
}
|
|
}
|
|
if (shapeFlag & 8) {
|
|
if (prevShapeFlag & 16) {
|
|
unmountChildren(c1, parentComponent, parentSuspense);
|
|
}
|
|
if (c2 !== c1) {
|
|
hostSetElementText(container, c2);
|
|
}
|
|
} else {
|
|
if (prevShapeFlag & 16) {
|
|
if (shapeFlag & 16) {
|
|
patchKeyedChildren(
|
|
c1,
|
|
c2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else {
|
|
unmountChildren(c1, parentComponent, parentSuspense, true);
|
|
}
|
|
} else {
|
|
if (prevShapeFlag & 8) {
|
|
hostSetElementText(container, "");
|
|
}
|
|
if (shapeFlag & 16) {
|
|
mountChildren(
|
|
c2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
const patchUnkeyedChildren = (c1, c2, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized) => {
|
|
c1 = c1 || EMPTY_ARR;
|
|
c2 = c2 || EMPTY_ARR;
|
|
const oldLength = c1.length;
|
|
const newLength = c2.length;
|
|
const commonLength = Math.min(oldLength, newLength);
|
|
let i;
|
|
for (i = 0; i < commonLength; i++) {
|
|
const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
|
patch(
|
|
c1[i],
|
|
nextChild,
|
|
container,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
}
|
|
if (oldLength > newLength) {
|
|
unmountChildren(
|
|
c1,
|
|
parentComponent,
|
|
parentSuspense,
|
|
true,
|
|
false,
|
|
commonLength
|
|
);
|
|
} else {
|
|
mountChildren(
|
|
c2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized,
|
|
commonLength
|
|
);
|
|
}
|
|
};
|
|
const patchKeyedChildren = (c1, c2, container, parentAnchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized) => {
|
|
let i = 0;
|
|
const l2 = c2.length;
|
|
let e1 = c1.length - 1;
|
|
let e2 = l2 - 1;
|
|
while (i <= e1 && i <= e2) {
|
|
const n1 = c1[i];
|
|
const n2 = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
|
if (isSameVNodeType(n1, n2)) {
|
|
patch(
|
|
n1,
|
|
n2,
|
|
container,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else {
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
while (i <= e1 && i <= e2) {
|
|
const n1 = c1[e1];
|
|
const n2 = c2[e2] = optimized ? cloneIfMounted(c2[e2]) : normalizeVNode(c2[e2]);
|
|
if (isSameVNodeType(n1, n2)) {
|
|
patch(
|
|
n1,
|
|
n2,
|
|
container,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else {
|
|
break;
|
|
}
|
|
e1--;
|
|
e2--;
|
|
}
|
|
if (i > e1) {
|
|
if (i <= e2) {
|
|
const nextPos = e2 + 1;
|
|
const anchor = nextPos < l2 ? c2[nextPos].el : parentAnchor;
|
|
while (i <= e2) {
|
|
patch(
|
|
null,
|
|
c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]),
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
i++;
|
|
}
|
|
}
|
|
} else if (i > e2) {
|
|
while (i <= e1) {
|
|
unmount2(c1[i], parentComponent, parentSuspense, true);
|
|
i++;
|
|
}
|
|
} else {
|
|
const s1 = i;
|
|
const s2 = i;
|
|
const keyToNewIndexMap = /* @__PURE__ */ new Map();
|
|
for (i = s2; i <= e2; i++) {
|
|
const nextChild = c2[i] = optimized ? cloneIfMounted(c2[i]) : normalizeVNode(c2[i]);
|
|
if (nextChild.key != null) {
|
|
keyToNewIndexMap.set(nextChild.key, i);
|
|
}
|
|
}
|
|
let j;
|
|
let patched = 0;
|
|
const toBePatched = e2 - s2 + 1;
|
|
let moved = false;
|
|
let maxNewIndexSoFar = 0;
|
|
const newIndexToOldIndexMap = new Array(toBePatched);
|
|
for (i = 0; i < toBePatched; i++) newIndexToOldIndexMap[i] = 0;
|
|
for (i = s1; i <= e1; i++) {
|
|
const prevChild = c1[i];
|
|
if (patched >= toBePatched) {
|
|
unmount2(prevChild, parentComponent, parentSuspense, true);
|
|
continue;
|
|
}
|
|
let newIndex;
|
|
if (prevChild.key != null) {
|
|
newIndex = keyToNewIndexMap.get(prevChild.key);
|
|
} else {
|
|
for (j = s2; j <= e2; j++) {
|
|
if (newIndexToOldIndexMap[j - s2] === 0 && isSameVNodeType(prevChild, c2[j])) {
|
|
newIndex = j;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (newIndex === void 0) {
|
|
unmount2(prevChild, parentComponent, parentSuspense, true);
|
|
} else {
|
|
newIndexToOldIndexMap[newIndex - s2] = i + 1;
|
|
if (newIndex >= maxNewIndexSoFar) {
|
|
maxNewIndexSoFar = newIndex;
|
|
} else {
|
|
moved = true;
|
|
}
|
|
patch(
|
|
prevChild,
|
|
c2[newIndex],
|
|
container,
|
|
null,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
patched++;
|
|
}
|
|
}
|
|
const increasingNewIndexSequence = moved ? getSequence(newIndexToOldIndexMap) : EMPTY_ARR;
|
|
j = increasingNewIndexSequence.length - 1;
|
|
for (i = toBePatched - 1; i >= 0; i--) {
|
|
const nextIndex = s2 + i;
|
|
const nextChild = c2[nextIndex];
|
|
const anchor = nextIndex + 1 < l2 ? c2[nextIndex + 1].el : parentAnchor;
|
|
if (newIndexToOldIndexMap[i] === 0) {
|
|
patch(
|
|
null,
|
|
nextChild,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
} else if (moved) {
|
|
if (j < 0 || i !== increasingNewIndexSequence[j]) {
|
|
move(nextChild, container, anchor, 2);
|
|
} else {
|
|
j--;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
const move = (vnode, container, anchor, moveType, parentSuspense = null) => {
|
|
const { el, type, transition, children, shapeFlag } = vnode;
|
|
if (shapeFlag & 6) {
|
|
move(vnode.component.subTree, container, anchor, moveType);
|
|
return;
|
|
}
|
|
if (shapeFlag & 128) {
|
|
vnode.suspense.move(container, anchor, moveType);
|
|
return;
|
|
}
|
|
if (shapeFlag & 64) {
|
|
type.move(vnode, container, anchor, internals);
|
|
return;
|
|
}
|
|
if (type === Fragment) {
|
|
hostInsert(el, container, anchor);
|
|
for (let i = 0; i < children.length; i++) {
|
|
move(children[i], container, anchor, moveType);
|
|
}
|
|
hostInsert(vnode.anchor, container, anchor);
|
|
return;
|
|
}
|
|
if (type === Static) {
|
|
moveStaticNode(vnode, container, anchor);
|
|
return;
|
|
}
|
|
const needTransition2 = moveType !== 2 && shapeFlag & 1 && transition;
|
|
if (needTransition2) {
|
|
if (moveType === 0) {
|
|
transition.beforeEnter(el);
|
|
hostInsert(el, container, anchor);
|
|
queuePostRenderEffect(() => transition.enter(el), parentSuspense);
|
|
} else {
|
|
const { leave, delayLeave, afterLeave } = transition;
|
|
const remove22 = () => hostInsert(el, container, anchor);
|
|
const performLeave = () => {
|
|
leave(el, () => {
|
|
remove22();
|
|
afterLeave && afterLeave();
|
|
});
|
|
};
|
|
if (delayLeave) {
|
|
delayLeave(el, remove22, performLeave);
|
|
} else {
|
|
performLeave();
|
|
}
|
|
}
|
|
} else {
|
|
hostInsert(el, container, anchor);
|
|
}
|
|
};
|
|
const unmount2 = (vnode, parentComponent, parentSuspense, doRemove = false, optimized = false) => {
|
|
const {
|
|
type,
|
|
props,
|
|
ref: ref3,
|
|
children,
|
|
dynamicChildren,
|
|
shapeFlag,
|
|
patchFlag,
|
|
dirs,
|
|
cacheIndex
|
|
} = vnode;
|
|
if (patchFlag === -2) {
|
|
optimized = false;
|
|
}
|
|
if (ref3 != null) {
|
|
setRef(ref3, null, parentSuspense, vnode, true);
|
|
}
|
|
if (cacheIndex != null) {
|
|
parentComponent.renderCache[cacheIndex] = void 0;
|
|
}
|
|
if (shapeFlag & 256) {
|
|
parentComponent.ctx.deactivate(vnode);
|
|
return;
|
|
}
|
|
const shouldInvokeDirs = shapeFlag & 1 && dirs;
|
|
const shouldInvokeVnodeHook = !isAsyncWrapper(vnode);
|
|
let vnodeHook;
|
|
if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeBeforeUnmount)) {
|
|
invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
|
}
|
|
if (shapeFlag & 6) {
|
|
unmountComponent(vnode.component, parentSuspense, doRemove);
|
|
} else {
|
|
if (shapeFlag & 128) {
|
|
vnode.suspense.unmount(parentSuspense, doRemove);
|
|
return;
|
|
}
|
|
if (shouldInvokeDirs) {
|
|
invokeDirectiveHook(vnode, null, parentComponent, "beforeUnmount");
|
|
}
|
|
if (shapeFlag & 64) {
|
|
vnode.type.remove(
|
|
vnode,
|
|
parentComponent,
|
|
parentSuspense,
|
|
internals,
|
|
doRemove
|
|
);
|
|
} else if (dynamicChildren && // #5154
|
|
// when v-once is used inside a block, setBlockTracking(-1) marks the
|
|
// parent block with hasOnce: true
|
|
// so that it doesn't take the fast path during unmount - otherwise
|
|
// components nested in v-once are never unmounted.
|
|
!dynamicChildren.hasOnce && // #1153: fast path should not be taken for non-stable (v-for) fragments
|
|
(type !== Fragment || patchFlag > 0 && patchFlag & 64)) {
|
|
unmountChildren(
|
|
dynamicChildren,
|
|
parentComponent,
|
|
parentSuspense,
|
|
false,
|
|
true
|
|
);
|
|
} else if (type === Fragment && patchFlag & (128 | 256) || !optimized && shapeFlag & 16) {
|
|
unmountChildren(children, parentComponent, parentSuspense);
|
|
}
|
|
if (doRemove) {
|
|
remove2(vnode);
|
|
}
|
|
}
|
|
if (shouldInvokeVnodeHook && (vnodeHook = props && props.onVnodeUnmounted) || shouldInvokeDirs) {
|
|
queuePostRenderEffect(() => {
|
|
vnodeHook && invokeVNodeHook(vnodeHook, parentComponent, vnode);
|
|
shouldInvokeDirs && invokeDirectiveHook(vnode, null, parentComponent, "unmounted");
|
|
}, parentSuspense);
|
|
}
|
|
};
|
|
const remove2 = (vnode) => {
|
|
const { type, el, anchor, transition } = vnode;
|
|
if (type === Fragment) {
|
|
{
|
|
removeFragment(el, anchor);
|
|
}
|
|
return;
|
|
}
|
|
if (type === Static) {
|
|
removeStaticNode(vnode);
|
|
return;
|
|
}
|
|
const performRemove = () => {
|
|
hostRemove(el);
|
|
if (transition && !transition.persisted && transition.afterLeave) {
|
|
transition.afterLeave();
|
|
}
|
|
};
|
|
if (vnode.shapeFlag & 1 && transition && !transition.persisted) {
|
|
const { leave, delayLeave } = transition;
|
|
const performLeave = () => leave(el, performRemove);
|
|
if (delayLeave) {
|
|
delayLeave(vnode.el, performRemove, performLeave);
|
|
} else {
|
|
performLeave();
|
|
}
|
|
} else {
|
|
performRemove();
|
|
}
|
|
};
|
|
const removeFragment = (cur, end) => {
|
|
let next;
|
|
while (cur !== end) {
|
|
next = hostNextSibling(cur);
|
|
hostRemove(cur);
|
|
cur = next;
|
|
}
|
|
hostRemove(end);
|
|
};
|
|
const unmountComponent = (instance, parentSuspense, doRemove) => {
|
|
const { bum, scope, job, subTree, um, m, a } = instance;
|
|
invalidateMount(m);
|
|
invalidateMount(a);
|
|
if (bum) {
|
|
invokeArrayFns(bum);
|
|
}
|
|
scope.stop();
|
|
if (job) {
|
|
job.flags |= 8;
|
|
unmount2(subTree, instance, parentSuspense, doRemove);
|
|
}
|
|
if (um) {
|
|
queuePostRenderEffect(um, parentSuspense);
|
|
}
|
|
queuePostRenderEffect(() => {
|
|
instance.isUnmounted = true;
|
|
}, parentSuspense);
|
|
if (parentSuspense && parentSuspense.pendingBranch && !parentSuspense.isUnmounted && instance.asyncDep && !instance.asyncResolved && instance.suspenseId === parentSuspense.pendingId) {
|
|
parentSuspense.deps--;
|
|
if (parentSuspense.deps === 0) {
|
|
parentSuspense.resolve();
|
|
}
|
|
}
|
|
};
|
|
const unmountChildren = (children, parentComponent, parentSuspense, doRemove = false, optimized = false, start = 0) => {
|
|
for (let i = start; i < children.length; i++) {
|
|
unmount2(children[i], parentComponent, parentSuspense, doRemove, optimized);
|
|
}
|
|
};
|
|
const getNextHostNode = (vnode) => {
|
|
if (vnode.shapeFlag & 6) {
|
|
return getNextHostNode(vnode.component.subTree);
|
|
}
|
|
if (vnode.shapeFlag & 128) {
|
|
return vnode.suspense.next();
|
|
}
|
|
const el = hostNextSibling(vnode.anchor || vnode.el);
|
|
const teleportEnd = el && el[TeleportEndKey];
|
|
return teleportEnd ? hostNextSibling(teleportEnd) : el;
|
|
};
|
|
let isFlushing = false;
|
|
const render2 = (vnode, container, namespace2) => {
|
|
if (vnode == null) {
|
|
if (container._vnode) {
|
|
unmount2(container._vnode, null, null, true);
|
|
}
|
|
} else {
|
|
patch(
|
|
container._vnode || null,
|
|
vnode,
|
|
container,
|
|
null,
|
|
null,
|
|
null,
|
|
namespace2
|
|
);
|
|
}
|
|
container._vnode = vnode;
|
|
if (!isFlushing) {
|
|
isFlushing = true;
|
|
flushPreFlushCbs();
|
|
flushPostFlushCbs();
|
|
isFlushing = false;
|
|
}
|
|
};
|
|
const internals = {
|
|
p: patch,
|
|
um: unmount2,
|
|
m: move,
|
|
r: remove2,
|
|
mt: mountComponent,
|
|
mc: mountChildren,
|
|
pc: patchChildren,
|
|
pbc: patchBlockChildren,
|
|
n: getNextHostNode,
|
|
o: options
|
|
};
|
|
let hydrate2;
|
|
let hydrateNode;
|
|
if (createHydrationFns) {
|
|
[hydrate2, hydrateNode] = createHydrationFns(
|
|
internals
|
|
);
|
|
}
|
|
return {
|
|
render: render2,
|
|
hydrate: hydrate2,
|
|
createApp: createAppAPI(render2, hydrate2)
|
|
};
|
|
}
|
|
function resolveChildrenNamespace({ type, props }, currentNamespace) {
|
|
return currentNamespace === "svg" && type === "foreignObject" || currentNamespace === "mathml" && type === "annotation-xml" && props && props.encoding && props.encoding.includes("html") ? void 0 : currentNamespace;
|
|
}
|
|
function toggleRecurse({ effect: effect2, job }, allowed) {
|
|
if (allowed) {
|
|
effect2.flags |= 32;
|
|
job.flags |= 4;
|
|
} else {
|
|
effect2.flags &= -33;
|
|
job.flags &= -5;
|
|
}
|
|
}
|
|
function needTransition(parentSuspense, transition) {
|
|
return (!parentSuspense || parentSuspense && !parentSuspense.pendingBranch) && transition && !transition.persisted;
|
|
}
|
|
function traverseStaticChildren(n1, n2, shallow = false) {
|
|
const ch1 = n1.children;
|
|
const ch2 = n2.children;
|
|
if (isArray$3(ch1) && isArray$3(ch2)) {
|
|
for (let i = 0; i < ch1.length; i++) {
|
|
const c1 = ch1[i];
|
|
let c2 = ch2[i];
|
|
if (c2.shapeFlag & 1 && !c2.dynamicChildren) {
|
|
if (c2.patchFlag <= 0 || c2.patchFlag === 32) {
|
|
c2 = ch2[i] = cloneIfMounted(ch2[i]);
|
|
c2.el = c1.el;
|
|
}
|
|
if (!shallow && c2.patchFlag !== -2)
|
|
traverseStaticChildren(c1, c2);
|
|
}
|
|
if (c2.type === Text) {
|
|
c2.el = c1.el;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function getSequence(arr) {
|
|
const p2 = arr.slice();
|
|
const result = [0];
|
|
let i, j, u, v, c2;
|
|
const len = arr.length;
|
|
for (i = 0; i < len; i++) {
|
|
const arrI = arr[i];
|
|
if (arrI !== 0) {
|
|
j = result[result.length - 1];
|
|
if (arr[j] < arrI) {
|
|
p2[i] = j;
|
|
result.push(i);
|
|
continue;
|
|
}
|
|
u = 0;
|
|
v = result.length - 1;
|
|
while (u < v) {
|
|
c2 = u + v >> 1;
|
|
if (arr[result[c2]] < arrI) {
|
|
u = c2 + 1;
|
|
} else {
|
|
v = c2;
|
|
}
|
|
}
|
|
if (arrI < arr[result[u]]) {
|
|
if (u > 0) {
|
|
p2[i] = result[u - 1];
|
|
}
|
|
result[u] = i;
|
|
}
|
|
}
|
|
}
|
|
u = result.length;
|
|
v = result[u - 1];
|
|
while (u-- > 0) {
|
|
result[u] = v;
|
|
v = p2[v];
|
|
}
|
|
return result;
|
|
}
|
|
function locateNonHydratedAsyncRoot(instance) {
|
|
const subComponent = instance.subTree.component;
|
|
if (subComponent) {
|
|
if (subComponent.asyncDep && !subComponent.asyncResolved) {
|
|
return subComponent;
|
|
} else {
|
|
return locateNonHydratedAsyncRoot(subComponent);
|
|
}
|
|
}
|
|
}
|
|
function invalidateMount(hooks) {
|
|
if (hooks) {
|
|
for (let i = 0; i < hooks.length; i++)
|
|
hooks[i].flags |= 8;
|
|
}
|
|
}
|
|
const ssrContextKey$1 = Symbol.for("v-scx");
|
|
const useSSRContext = () => {
|
|
{
|
|
const ctx2 = inject(ssrContextKey$1);
|
|
return ctx2;
|
|
}
|
|
};
|
|
function watchEffect(effect2, options) {
|
|
return doWatch(effect2, null, options);
|
|
}
|
|
function watchPostEffect(effect2, options) {
|
|
return doWatch(
|
|
effect2,
|
|
null,
|
|
{ flush: "post" }
|
|
);
|
|
}
|
|
function watchSyncEffect(effect2, options) {
|
|
return doWatch(
|
|
effect2,
|
|
null,
|
|
{ flush: "sync" }
|
|
);
|
|
}
|
|
function watch(source, cb, options) {
|
|
return doWatch(source, cb, options);
|
|
}
|
|
function doWatch(source, cb, options = EMPTY_OBJ) {
|
|
const { immediate, deep, flush, once } = options;
|
|
const baseWatchOptions = extend$1({}, options);
|
|
const runsImmediately = cb && immediate || !cb && flush !== "post";
|
|
let ssrCleanup;
|
|
if (isInSSRComponentSetup) {
|
|
if (flush === "sync") {
|
|
const ctx2 = useSSRContext();
|
|
ssrCleanup = ctx2.__watcherHandles || (ctx2.__watcherHandles = []);
|
|
} else if (!runsImmediately) {
|
|
const watchStopHandle = () => {
|
|
};
|
|
watchStopHandle.stop = NOOP;
|
|
watchStopHandle.resume = NOOP;
|
|
watchStopHandle.pause = NOOP;
|
|
return watchStopHandle;
|
|
}
|
|
}
|
|
const instance = currentInstance;
|
|
baseWatchOptions.call = (fn, type, args) => callWithAsyncErrorHandling(fn, instance, type, args);
|
|
let isPre = false;
|
|
if (flush === "post") {
|
|
baseWatchOptions.scheduler = (job) => {
|
|
queuePostRenderEffect(job, instance && instance.suspense);
|
|
};
|
|
} else if (flush !== "sync") {
|
|
isPre = true;
|
|
baseWatchOptions.scheduler = (job, isFirstRun) => {
|
|
if (isFirstRun) {
|
|
job();
|
|
} else {
|
|
queueJob(job);
|
|
}
|
|
};
|
|
}
|
|
baseWatchOptions.augmentJob = (job) => {
|
|
if (cb) {
|
|
job.flags |= 4;
|
|
}
|
|
if (isPre) {
|
|
job.flags |= 2;
|
|
if (instance) {
|
|
job.id = instance.uid;
|
|
job.i = instance;
|
|
}
|
|
}
|
|
};
|
|
const watchHandle = watch$1(source, cb, baseWatchOptions);
|
|
if (isInSSRComponentSetup) {
|
|
if (ssrCleanup) {
|
|
ssrCleanup.push(watchHandle);
|
|
} else if (runsImmediately) {
|
|
watchHandle();
|
|
}
|
|
}
|
|
return watchHandle;
|
|
}
|
|
function instanceWatch(source, value, options) {
|
|
const publicThis = this.proxy;
|
|
const getter = isString$1(source) ? source.includes(".") ? createPathGetter(publicThis, source) : () => publicThis[source] : source.bind(publicThis, publicThis);
|
|
let cb;
|
|
if (isFunction$2(value)) {
|
|
cb = value;
|
|
} else {
|
|
cb = value.handler;
|
|
options = value;
|
|
}
|
|
const reset = setCurrentInstance(this);
|
|
const res = doWatch(getter, cb.bind(publicThis), options);
|
|
reset();
|
|
return res;
|
|
}
|
|
function createPathGetter(ctx2, path) {
|
|
const segments = path.split(".");
|
|
return () => {
|
|
let cur = ctx2;
|
|
for (let i = 0; i < segments.length && cur; i++) {
|
|
cur = cur[segments[i]];
|
|
}
|
|
return cur;
|
|
};
|
|
}
|
|
function useModel(props, name, options = EMPTY_OBJ) {
|
|
const i = getCurrentInstance();
|
|
const camelizedName = camelize(name);
|
|
const hyphenatedName = hyphenate(name);
|
|
const modifiers = getModelModifiers(props, camelizedName);
|
|
const res = customRef((track2, trigger2) => {
|
|
let localValue;
|
|
let prevSetValue = EMPTY_OBJ;
|
|
let prevEmittedValue;
|
|
watchSyncEffect(() => {
|
|
const propValue = props[camelizedName];
|
|
if (hasChanged(localValue, propValue)) {
|
|
localValue = propValue;
|
|
trigger2();
|
|
}
|
|
});
|
|
return {
|
|
get() {
|
|
track2();
|
|
return options.get ? options.get(localValue) : localValue;
|
|
},
|
|
set(value) {
|
|
const emittedValue = options.set ? options.set(value) : value;
|
|
if (!hasChanged(emittedValue, localValue) && !(prevSetValue !== EMPTY_OBJ && hasChanged(value, prevSetValue))) {
|
|
return;
|
|
}
|
|
const rawProps = i.vnode.props;
|
|
if (!(rawProps && // check if parent has passed v-model
|
|
(name in rawProps || camelizedName in rawProps || hyphenatedName in rawProps) && (`onUpdate:${name}` in rawProps || `onUpdate:${camelizedName}` in rawProps || `onUpdate:${hyphenatedName}` in rawProps))) {
|
|
localValue = value;
|
|
trigger2();
|
|
}
|
|
i.emit(`update:${name}`, emittedValue);
|
|
if (hasChanged(value, emittedValue) && hasChanged(value, prevSetValue) && !hasChanged(emittedValue, prevEmittedValue)) {
|
|
trigger2();
|
|
}
|
|
prevSetValue = value;
|
|
prevEmittedValue = emittedValue;
|
|
}
|
|
};
|
|
});
|
|
res[Symbol.iterator] = () => {
|
|
let i2 = 0;
|
|
return {
|
|
next() {
|
|
if (i2 < 2) {
|
|
return { value: i2++ ? modifiers || EMPTY_OBJ : res, done: false };
|
|
} else {
|
|
return { done: true };
|
|
}
|
|
}
|
|
};
|
|
};
|
|
return res;
|
|
}
|
|
const getModelModifiers = (props, modelName) => {
|
|
return modelName === "modelValue" || modelName === "model-value" ? props.modelModifiers : props[`${modelName}Modifiers`] || props[`${camelize(modelName)}Modifiers`] || props[`${hyphenate(modelName)}Modifiers`];
|
|
};
|
|
function emit(instance, event, ...rawArgs) {
|
|
if (instance.isUnmounted) return;
|
|
const props = instance.vnode.props || EMPTY_OBJ;
|
|
let args = rawArgs;
|
|
const isModelListener2 = event.startsWith("update:");
|
|
const modifiers = isModelListener2 && getModelModifiers(props, event.slice(7));
|
|
if (modifiers) {
|
|
if (modifiers.trim) {
|
|
args = rawArgs.map((a) => isString$1(a) ? a.trim() : a);
|
|
}
|
|
if (modifiers.number) {
|
|
args = rawArgs.map(looseToNumber);
|
|
}
|
|
}
|
|
let handlerName;
|
|
let handler = props[handlerName = toHandlerKey(event)] || // also try camelCase event handler (#2249)
|
|
props[handlerName = toHandlerKey(camelize(event))];
|
|
if (!handler && isModelListener2) {
|
|
handler = props[handlerName = toHandlerKey(hyphenate(event))];
|
|
}
|
|
if (handler) {
|
|
callWithAsyncErrorHandling(
|
|
handler,
|
|
instance,
|
|
6,
|
|
args
|
|
);
|
|
}
|
|
const onceHandler = props[handlerName + `Once`];
|
|
if (onceHandler) {
|
|
if (!instance.emitted) {
|
|
instance.emitted = {};
|
|
} else if (instance.emitted[handlerName]) {
|
|
return;
|
|
}
|
|
instance.emitted[handlerName] = true;
|
|
callWithAsyncErrorHandling(
|
|
onceHandler,
|
|
instance,
|
|
6,
|
|
args
|
|
);
|
|
}
|
|
}
|
|
function normalizeEmitsOptions(comp, appContext, asMixin = false) {
|
|
const cache2 = appContext.emitsCache;
|
|
const cached = cache2.get(comp);
|
|
if (cached !== void 0) {
|
|
return cached;
|
|
}
|
|
const raw = comp.emits;
|
|
let normalized = {};
|
|
let hasExtends = false;
|
|
if (!isFunction$2(comp)) {
|
|
const extendEmits = (raw2) => {
|
|
const normalizedFromExtend = normalizeEmitsOptions(raw2, appContext, true);
|
|
if (normalizedFromExtend) {
|
|
hasExtends = true;
|
|
extend$1(normalized, normalizedFromExtend);
|
|
}
|
|
};
|
|
if (!asMixin && appContext.mixins.length) {
|
|
appContext.mixins.forEach(extendEmits);
|
|
}
|
|
if (comp.extends) {
|
|
extendEmits(comp.extends);
|
|
}
|
|
if (comp.mixins) {
|
|
comp.mixins.forEach(extendEmits);
|
|
}
|
|
}
|
|
if (!raw && !hasExtends) {
|
|
if (isObject$2(comp)) {
|
|
cache2.set(comp, null);
|
|
}
|
|
return null;
|
|
}
|
|
if (isArray$3(raw)) {
|
|
raw.forEach((key) => normalized[key] = null);
|
|
} else {
|
|
extend$1(normalized, raw);
|
|
}
|
|
if (isObject$2(comp)) {
|
|
cache2.set(comp, normalized);
|
|
}
|
|
return normalized;
|
|
}
|
|
function isEmitListener(options, key) {
|
|
if (!options || !isOn(key)) {
|
|
return false;
|
|
}
|
|
key = key.slice(2).replace(/Once$/, "");
|
|
return hasOwn(options, key[0].toLowerCase() + key.slice(1)) || hasOwn(options, hyphenate(key)) || hasOwn(options, key);
|
|
}
|
|
function markAttrsAccessed() {
|
|
}
|
|
function renderComponentRoot(instance) {
|
|
const {
|
|
type: Component,
|
|
vnode,
|
|
proxy,
|
|
withProxy,
|
|
propsOptions: [propsOptions],
|
|
slots,
|
|
attrs,
|
|
emit: emit2,
|
|
render: render2,
|
|
renderCache,
|
|
props,
|
|
data,
|
|
setupState,
|
|
ctx: ctx2,
|
|
inheritAttrs
|
|
} = instance;
|
|
const prev = setCurrentRenderingInstance(instance);
|
|
let result;
|
|
let fallthroughAttrs;
|
|
try {
|
|
if (vnode.shapeFlag & 4) {
|
|
const proxyToUse = withProxy || proxy;
|
|
const thisProxy = false ? new Proxy(proxyToUse, {
|
|
get(target, key, receiver) {
|
|
warn$1$1(
|
|
`Property '${String(
|
|
key
|
|
)}' was accessed via 'this'. Avoid using 'this' in templates.`
|
|
);
|
|
return Reflect.get(target, key, receiver);
|
|
}
|
|
}) : proxyToUse;
|
|
result = normalizeVNode(
|
|
render2.call(
|
|
thisProxy,
|
|
proxyToUse,
|
|
renderCache,
|
|
false ? shallowReadonly(props) : props,
|
|
setupState,
|
|
data,
|
|
ctx2
|
|
)
|
|
);
|
|
fallthroughAttrs = attrs;
|
|
} else {
|
|
const render22 = Component;
|
|
if (false) ;
|
|
result = normalizeVNode(
|
|
render22.length > 1 ? render22(
|
|
false ? shallowReadonly(props) : props,
|
|
false ? {
|
|
get attrs() {
|
|
markAttrsAccessed();
|
|
return shallowReadonly(attrs);
|
|
},
|
|
slots,
|
|
emit: emit2
|
|
} : { attrs, slots, emit: emit2 }
|
|
) : render22(
|
|
false ? shallowReadonly(props) : props,
|
|
null
|
|
)
|
|
);
|
|
fallthroughAttrs = Component.props ? attrs : getFunctionalFallthrough(attrs);
|
|
}
|
|
} catch (err) {
|
|
blockStack.length = 0;
|
|
handleError(err, instance, 1);
|
|
result = createVNode(Comment);
|
|
}
|
|
let root2 = result;
|
|
if (fallthroughAttrs && inheritAttrs !== false) {
|
|
const keys = Object.keys(fallthroughAttrs);
|
|
const { shapeFlag } = root2;
|
|
if (keys.length) {
|
|
if (shapeFlag & (1 | 6)) {
|
|
if (propsOptions && keys.some(isModelListener)) {
|
|
fallthroughAttrs = filterModelListeners(
|
|
fallthroughAttrs,
|
|
propsOptions
|
|
);
|
|
}
|
|
root2 = cloneVNode(root2, fallthroughAttrs, false, true);
|
|
}
|
|
}
|
|
}
|
|
if (vnode.dirs) {
|
|
root2 = cloneVNode(root2, null, false, true);
|
|
root2.dirs = root2.dirs ? root2.dirs.concat(vnode.dirs) : vnode.dirs;
|
|
}
|
|
if (vnode.transition) {
|
|
setTransitionHooks(root2, vnode.transition);
|
|
}
|
|
{
|
|
result = root2;
|
|
}
|
|
setCurrentRenderingInstance(prev);
|
|
return result;
|
|
}
|
|
function filterSingleRoot(children, recurse = true) {
|
|
let singleRoot;
|
|
for (let i = 0; i < children.length; i++) {
|
|
const child = children[i];
|
|
if (isVNode(child)) {
|
|
if (child.type !== Comment || child.children === "v-if") {
|
|
if (singleRoot) {
|
|
return;
|
|
} else {
|
|
singleRoot = child;
|
|
}
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
return singleRoot;
|
|
}
|
|
const getFunctionalFallthrough = (attrs) => {
|
|
let res;
|
|
for (const key in attrs) {
|
|
if (key === "class" || key === "style" || isOn(key)) {
|
|
(res || (res = {}))[key] = attrs[key];
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
const filterModelListeners = (attrs, props) => {
|
|
const res = {};
|
|
for (const key in attrs) {
|
|
if (!isModelListener(key) || !(key.slice(9) in props)) {
|
|
res[key] = attrs[key];
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
function shouldUpdateComponent(prevVNode, nextVNode, optimized) {
|
|
const { props: prevProps, children: prevChildren, component } = prevVNode;
|
|
const { props: nextProps, children: nextChildren, patchFlag } = nextVNode;
|
|
const emits = component.emitsOptions;
|
|
if (nextVNode.dirs || nextVNode.transition) {
|
|
return true;
|
|
}
|
|
if (optimized && patchFlag >= 0) {
|
|
if (patchFlag & 1024) {
|
|
return true;
|
|
}
|
|
if (patchFlag & 16) {
|
|
if (!prevProps) {
|
|
return !!nextProps;
|
|
}
|
|
return hasPropsChanged(prevProps, nextProps, emits);
|
|
} else if (patchFlag & 8) {
|
|
const dynamicProps = nextVNode.dynamicProps;
|
|
for (let i = 0; i < dynamicProps.length; i++) {
|
|
const key = dynamicProps[i];
|
|
if (nextProps[key] !== prevProps[key] && !isEmitListener(emits, key)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (prevChildren || nextChildren) {
|
|
if (!nextChildren || !nextChildren.$stable) {
|
|
return true;
|
|
}
|
|
}
|
|
if (prevProps === nextProps) {
|
|
return false;
|
|
}
|
|
if (!prevProps) {
|
|
return !!nextProps;
|
|
}
|
|
if (!nextProps) {
|
|
return true;
|
|
}
|
|
return hasPropsChanged(prevProps, nextProps, emits);
|
|
}
|
|
return false;
|
|
}
|
|
function hasPropsChanged(prevProps, nextProps, emitsOptions) {
|
|
const nextKeys = Object.keys(nextProps);
|
|
if (nextKeys.length !== Object.keys(prevProps).length) {
|
|
return true;
|
|
}
|
|
for (let i = 0; i < nextKeys.length; i++) {
|
|
const key = nextKeys[i];
|
|
if (nextProps[key] !== prevProps[key] && !isEmitListener(emitsOptions, key)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function updateHOCHostEl({ vnode, parent }, el) {
|
|
while (parent) {
|
|
const root2 = parent.subTree;
|
|
if (root2.suspense && root2.suspense.activeBranch === vnode) {
|
|
root2.el = vnode.el;
|
|
}
|
|
if (root2 === vnode) {
|
|
(vnode = parent.vnode).el = el;
|
|
parent = parent.parent;
|
|
} else {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
const isSuspense = (type) => type.__isSuspense;
|
|
let suspenseId = 0;
|
|
const SuspenseImpl = {
|
|
name: "Suspense",
|
|
// In order to make Suspense tree-shakable, we need to avoid importing it
|
|
// directly in the renderer. The renderer checks for the __isSuspense flag
|
|
// on a vnode's type and calls the `process` method, passing in renderer
|
|
// internals.
|
|
__isSuspense: true,
|
|
process(n1, n2, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized, rendererInternals) {
|
|
if (n1 == null) {
|
|
mountSuspense(
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
parentSuspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized,
|
|
rendererInternals
|
|
);
|
|
} else {
|
|
if (parentSuspense && parentSuspense.deps > 0 && !n1.suspense.isInFallback) {
|
|
n2.suspense = n1.suspense;
|
|
n2.suspense.vnode = n2;
|
|
n2.el = n1.el;
|
|
return;
|
|
}
|
|
patchSuspense(
|
|
n1,
|
|
n2,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized,
|
|
rendererInternals
|
|
);
|
|
}
|
|
},
|
|
hydrate: hydrateSuspense,
|
|
normalize: normalizeSuspenseChildren
|
|
};
|
|
const Suspense = SuspenseImpl;
|
|
function triggerEvent(vnode, name) {
|
|
const eventListener = vnode.props && vnode.props[name];
|
|
if (isFunction$2(eventListener)) {
|
|
eventListener();
|
|
}
|
|
}
|
|
function mountSuspense(vnode, container, anchor, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized, rendererInternals) {
|
|
const {
|
|
p: patch,
|
|
o: { createElement: createElement2 }
|
|
} = rendererInternals;
|
|
const hiddenContainer = createElement2("div");
|
|
const suspense = vnode.suspense = createSuspenseBoundary(
|
|
vnode,
|
|
parentSuspense,
|
|
parentComponent,
|
|
container,
|
|
hiddenContainer,
|
|
anchor,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized,
|
|
rendererInternals
|
|
);
|
|
patch(
|
|
null,
|
|
suspense.pendingBranch = vnode.ssContent,
|
|
hiddenContainer,
|
|
null,
|
|
parentComponent,
|
|
suspense,
|
|
namespace2,
|
|
slotScopeIds
|
|
);
|
|
if (suspense.deps > 0) {
|
|
triggerEvent(vnode, "onPending");
|
|
triggerEvent(vnode, "onFallback");
|
|
patch(
|
|
null,
|
|
vnode.ssFallback,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
null,
|
|
// fallback tree will not have suspense context
|
|
namespace2,
|
|
slotScopeIds
|
|
);
|
|
setActiveBranch(suspense, vnode.ssFallback);
|
|
} else {
|
|
suspense.resolve(false, true);
|
|
}
|
|
}
|
|
function patchSuspense(n1, n2, container, anchor, parentComponent, namespace2, slotScopeIds, optimized, { p: patch, um: unmount2, o: { createElement: createElement2 } }) {
|
|
const suspense = n2.suspense = n1.suspense;
|
|
suspense.vnode = n2;
|
|
n2.el = n1.el;
|
|
const newBranch = n2.ssContent;
|
|
const newFallback = n2.ssFallback;
|
|
const { activeBranch, pendingBranch, isInFallback, isHydrating } = suspense;
|
|
if (pendingBranch) {
|
|
suspense.pendingBranch = newBranch;
|
|
if (isSameVNodeType(newBranch, pendingBranch)) {
|
|
patch(
|
|
pendingBranch,
|
|
newBranch,
|
|
suspense.hiddenContainer,
|
|
null,
|
|
parentComponent,
|
|
suspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
if (suspense.deps <= 0) {
|
|
suspense.resolve();
|
|
} else if (isInFallback) {
|
|
if (!isHydrating) {
|
|
patch(
|
|
activeBranch,
|
|
newFallback,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
null,
|
|
// fallback tree will not have suspense context
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
setActiveBranch(suspense, newFallback);
|
|
}
|
|
}
|
|
} else {
|
|
suspense.pendingId = suspenseId++;
|
|
if (isHydrating) {
|
|
suspense.isHydrating = false;
|
|
suspense.activeBranch = pendingBranch;
|
|
} else {
|
|
unmount2(pendingBranch, parentComponent, suspense);
|
|
}
|
|
suspense.deps = 0;
|
|
suspense.effects.length = 0;
|
|
suspense.hiddenContainer = createElement2("div");
|
|
if (isInFallback) {
|
|
patch(
|
|
null,
|
|
newBranch,
|
|
suspense.hiddenContainer,
|
|
null,
|
|
parentComponent,
|
|
suspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
if (suspense.deps <= 0) {
|
|
suspense.resolve();
|
|
} else {
|
|
patch(
|
|
activeBranch,
|
|
newFallback,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
null,
|
|
// fallback tree will not have suspense context
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
setActiveBranch(suspense, newFallback);
|
|
}
|
|
} else if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
|
patch(
|
|
activeBranch,
|
|
newBranch,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
suspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
suspense.resolve(true);
|
|
} else {
|
|
patch(
|
|
null,
|
|
newBranch,
|
|
suspense.hiddenContainer,
|
|
null,
|
|
parentComponent,
|
|
suspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
if (suspense.deps <= 0) {
|
|
suspense.resolve();
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (activeBranch && isSameVNodeType(newBranch, activeBranch)) {
|
|
patch(
|
|
activeBranch,
|
|
newBranch,
|
|
container,
|
|
anchor,
|
|
parentComponent,
|
|
suspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
setActiveBranch(suspense, newBranch);
|
|
} else {
|
|
triggerEvent(n2, "onPending");
|
|
suspense.pendingBranch = newBranch;
|
|
if (newBranch.shapeFlag & 512) {
|
|
suspense.pendingId = newBranch.component.suspenseId;
|
|
} else {
|
|
suspense.pendingId = suspenseId++;
|
|
}
|
|
patch(
|
|
null,
|
|
newBranch,
|
|
suspense.hiddenContainer,
|
|
null,
|
|
parentComponent,
|
|
suspense,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
if (suspense.deps <= 0) {
|
|
suspense.resolve();
|
|
} else {
|
|
const { timeout: timeout2, pendingId } = suspense;
|
|
if (timeout2 > 0) {
|
|
setTimeout(() => {
|
|
if (suspense.pendingId === pendingId) {
|
|
suspense.fallback(newFallback);
|
|
}
|
|
}, timeout2);
|
|
} else if (timeout2 === 0) {
|
|
suspense.fallback(newFallback);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function createSuspenseBoundary(vnode, parentSuspense, parentComponent, container, hiddenContainer, anchor, namespace2, slotScopeIds, optimized, rendererInternals, isHydrating = false) {
|
|
const {
|
|
p: patch,
|
|
m: move,
|
|
um: unmount2,
|
|
n: next,
|
|
o: { parentNode, remove: remove2 }
|
|
} = rendererInternals;
|
|
let parentSuspenseId;
|
|
const isSuspensible = isVNodeSuspensible(vnode);
|
|
if (isSuspensible) {
|
|
if (parentSuspense && parentSuspense.pendingBranch) {
|
|
parentSuspenseId = parentSuspense.pendingId;
|
|
parentSuspense.deps++;
|
|
}
|
|
}
|
|
const timeout2 = vnode.props ? toNumber(vnode.props.timeout) : void 0;
|
|
const initialAnchor = anchor;
|
|
const suspense = {
|
|
vnode,
|
|
parent: parentSuspense,
|
|
parentComponent,
|
|
namespace: namespace2,
|
|
container,
|
|
hiddenContainer,
|
|
deps: 0,
|
|
pendingId: suspenseId++,
|
|
timeout: typeof timeout2 === "number" ? timeout2 : -1,
|
|
activeBranch: null,
|
|
pendingBranch: null,
|
|
isInFallback: !isHydrating,
|
|
isHydrating,
|
|
isUnmounted: false,
|
|
effects: [],
|
|
resolve(resume = false, sync = false) {
|
|
const {
|
|
vnode: vnode2,
|
|
activeBranch,
|
|
pendingBranch,
|
|
pendingId,
|
|
effects,
|
|
parentComponent: parentComponent2,
|
|
container: container2
|
|
} = suspense;
|
|
let delayEnter = false;
|
|
if (suspense.isHydrating) {
|
|
suspense.isHydrating = false;
|
|
} else if (!resume) {
|
|
delayEnter = activeBranch && pendingBranch.transition && pendingBranch.transition.mode === "out-in";
|
|
if (delayEnter) {
|
|
activeBranch.transition.afterLeave = () => {
|
|
if (pendingId === suspense.pendingId) {
|
|
move(
|
|
pendingBranch,
|
|
container2,
|
|
anchor === initialAnchor ? next(activeBranch) : anchor,
|
|
0
|
|
);
|
|
queuePostFlushCb(effects);
|
|
}
|
|
};
|
|
}
|
|
if (activeBranch) {
|
|
if (parentNode(activeBranch.el) === container2) {
|
|
anchor = next(activeBranch);
|
|
}
|
|
unmount2(activeBranch, parentComponent2, suspense, true);
|
|
}
|
|
if (!delayEnter) {
|
|
move(pendingBranch, container2, anchor, 0);
|
|
}
|
|
}
|
|
setActiveBranch(suspense, pendingBranch);
|
|
suspense.pendingBranch = null;
|
|
suspense.isInFallback = false;
|
|
let parent = suspense.parent;
|
|
let hasUnresolvedAncestor = false;
|
|
while (parent) {
|
|
if (parent.pendingBranch) {
|
|
parent.effects.push(...effects);
|
|
hasUnresolvedAncestor = true;
|
|
break;
|
|
}
|
|
parent = parent.parent;
|
|
}
|
|
if (!hasUnresolvedAncestor && !delayEnter) {
|
|
queuePostFlushCb(effects);
|
|
}
|
|
suspense.effects = [];
|
|
if (isSuspensible) {
|
|
if (parentSuspense && parentSuspense.pendingBranch && parentSuspenseId === parentSuspense.pendingId) {
|
|
parentSuspense.deps--;
|
|
if (parentSuspense.deps === 0 && !sync) {
|
|
parentSuspense.resolve();
|
|
}
|
|
}
|
|
}
|
|
triggerEvent(vnode2, "onResolve");
|
|
},
|
|
fallback(fallbackVNode) {
|
|
if (!suspense.pendingBranch) {
|
|
return;
|
|
}
|
|
const { vnode: vnode2, activeBranch, parentComponent: parentComponent2, container: container2, namespace: namespace22 } = suspense;
|
|
triggerEvent(vnode2, "onFallback");
|
|
const anchor2 = next(activeBranch);
|
|
const mountFallback = () => {
|
|
if (!suspense.isInFallback) {
|
|
return;
|
|
}
|
|
patch(
|
|
null,
|
|
fallbackVNode,
|
|
container2,
|
|
anchor2,
|
|
parentComponent2,
|
|
null,
|
|
// fallback tree will not have suspense context
|
|
namespace22,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
setActiveBranch(suspense, fallbackVNode);
|
|
};
|
|
const delayEnter = fallbackVNode.transition && fallbackVNode.transition.mode === "out-in";
|
|
if (delayEnter) {
|
|
activeBranch.transition.afterLeave = mountFallback;
|
|
}
|
|
suspense.isInFallback = true;
|
|
unmount2(
|
|
activeBranch,
|
|
parentComponent2,
|
|
null,
|
|
// no suspense so unmount hooks fire now
|
|
true
|
|
// shouldRemove
|
|
);
|
|
if (!delayEnter) {
|
|
mountFallback();
|
|
}
|
|
},
|
|
move(container2, anchor2, type) {
|
|
suspense.activeBranch && move(suspense.activeBranch, container2, anchor2, type);
|
|
suspense.container = container2;
|
|
},
|
|
next() {
|
|
return suspense.activeBranch && next(suspense.activeBranch);
|
|
},
|
|
registerDep(instance, setupRenderEffect, optimized2) {
|
|
const isInPendingSuspense = !!suspense.pendingBranch;
|
|
if (isInPendingSuspense) {
|
|
suspense.deps++;
|
|
}
|
|
const hydratedEl = instance.vnode.el;
|
|
instance.asyncDep.catch((err) => {
|
|
handleError(err, instance, 0);
|
|
}).then((asyncSetupResult) => {
|
|
if (instance.isUnmounted || suspense.isUnmounted || suspense.pendingId !== instance.suspenseId) {
|
|
return;
|
|
}
|
|
instance.asyncResolved = true;
|
|
const { vnode: vnode2 } = instance;
|
|
handleSetupResult(instance, asyncSetupResult, false);
|
|
if (hydratedEl) {
|
|
vnode2.el = hydratedEl;
|
|
}
|
|
const placeholder = !hydratedEl && instance.subTree.el;
|
|
setupRenderEffect(
|
|
instance,
|
|
vnode2,
|
|
// component may have been moved before resolve.
|
|
// if this is not a hydration, instance.subTree will be the comment
|
|
// placeholder.
|
|
parentNode(hydratedEl || instance.subTree.el),
|
|
// anchor will not be used if this is hydration, so only need to
|
|
// consider the comment placeholder case.
|
|
hydratedEl ? null : next(instance.subTree),
|
|
suspense,
|
|
namespace2,
|
|
optimized2
|
|
);
|
|
if (placeholder) {
|
|
remove2(placeholder);
|
|
}
|
|
updateHOCHostEl(instance, vnode2.el);
|
|
if (isInPendingSuspense && --suspense.deps === 0) {
|
|
suspense.resolve();
|
|
}
|
|
});
|
|
},
|
|
unmount(parentSuspense2, doRemove) {
|
|
suspense.isUnmounted = true;
|
|
if (suspense.activeBranch) {
|
|
unmount2(
|
|
suspense.activeBranch,
|
|
parentComponent,
|
|
parentSuspense2,
|
|
doRemove
|
|
);
|
|
}
|
|
if (suspense.pendingBranch) {
|
|
unmount2(
|
|
suspense.pendingBranch,
|
|
parentComponent,
|
|
parentSuspense2,
|
|
doRemove
|
|
);
|
|
}
|
|
}
|
|
};
|
|
return suspense;
|
|
}
|
|
function hydrateSuspense(node, vnode, parentComponent, parentSuspense, namespace2, slotScopeIds, optimized, rendererInternals, hydrateNode) {
|
|
const suspense = vnode.suspense = createSuspenseBoundary(
|
|
vnode,
|
|
parentSuspense,
|
|
parentComponent,
|
|
node.parentNode,
|
|
// eslint-disable-next-line no-restricted-globals
|
|
document.createElement("div"),
|
|
null,
|
|
namespace2,
|
|
slotScopeIds,
|
|
optimized,
|
|
rendererInternals,
|
|
true
|
|
);
|
|
const result = hydrateNode(
|
|
node,
|
|
suspense.pendingBranch = vnode.ssContent,
|
|
parentComponent,
|
|
suspense,
|
|
slotScopeIds,
|
|
optimized
|
|
);
|
|
if (suspense.deps === 0) {
|
|
suspense.resolve(false, true);
|
|
}
|
|
return result;
|
|
}
|
|
function normalizeSuspenseChildren(vnode) {
|
|
const { shapeFlag, children } = vnode;
|
|
const isSlotChildren = shapeFlag & 32;
|
|
vnode.ssContent = normalizeSuspenseSlot(
|
|
isSlotChildren ? children.default : children
|
|
);
|
|
vnode.ssFallback = isSlotChildren ? normalizeSuspenseSlot(children.fallback) : createVNode(Comment);
|
|
}
|
|
function normalizeSuspenseSlot(s) {
|
|
let block;
|
|
if (isFunction$2(s)) {
|
|
const trackBlock = isBlockTreeEnabled && s._c;
|
|
if (trackBlock) {
|
|
s._d = false;
|
|
openBlock();
|
|
}
|
|
s = s();
|
|
if (trackBlock) {
|
|
s._d = true;
|
|
block = currentBlock;
|
|
closeBlock();
|
|
}
|
|
}
|
|
if (isArray$3(s)) {
|
|
const singleChild = filterSingleRoot(s);
|
|
s = singleChild;
|
|
}
|
|
s = normalizeVNode(s);
|
|
if (block && !s.dynamicChildren) {
|
|
s.dynamicChildren = block.filter((c2) => c2 !== s);
|
|
}
|
|
return s;
|
|
}
|
|
function queueEffectWithSuspense(fn, suspense) {
|
|
if (suspense && suspense.pendingBranch) {
|
|
if (isArray$3(fn)) {
|
|
suspense.effects.push(...fn);
|
|
} else {
|
|
suspense.effects.push(fn);
|
|
}
|
|
} else {
|
|
queuePostFlushCb(fn);
|
|
}
|
|
}
|
|
function setActiveBranch(suspense, branch) {
|
|
suspense.activeBranch = branch;
|
|
const { vnode, parentComponent } = suspense;
|
|
let el = branch.el;
|
|
while (!el && branch.component) {
|
|
branch = branch.component.subTree;
|
|
el = branch.el;
|
|
}
|
|
vnode.el = el;
|
|
if (parentComponent && parentComponent.subTree === vnode) {
|
|
parentComponent.vnode.el = el;
|
|
updateHOCHostEl(parentComponent, el);
|
|
}
|
|
}
|
|
function isVNodeSuspensible(vnode) {
|
|
const suspensible = vnode.props && vnode.props.suspensible;
|
|
return suspensible != null && suspensible !== false;
|
|
}
|
|
const Fragment = Symbol.for("v-fgt");
|
|
const Text = Symbol.for("v-txt");
|
|
const Comment = Symbol.for("v-cmt");
|
|
const Static = Symbol.for("v-stc");
|
|
const blockStack = [];
|
|
let currentBlock = null;
|
|
function openBlock(disableTracking = false) {
|
|
blockStack.push(currentBlock = disableTracking ? null : []);
|
|
}
|
|
function closeBlock() {
|
|
blockStack.pop();
|
|
currentBlock = blockStack[blockStack.length - 1] || null;
|
|
}
|
|
let isBlockTreeEnabled = 1;
|
|
function setBlockTracking(value, inVOnce = false) {
|
|
isBlockTreeEnabled += value;
|
|
if (value < 0 && currentBlock && inVOnce) {
|
|
currentBlock.hasOnce = true;
|
|
}
|
|
}
|
|
function setupBlock(vnode) {
|
|
vnode.dynamicChildren = isBlockTreeEnabled > 0 ? currentBlock || EMPTY_ARR : null;
|
|
closeBlock();
|
|
if (isBlockTreeEnabled > 0 && currentBlock) {
|
|
currentBlock.push(vnode);
|
|
}
|
|
return vnode;
|
|
}
|
|
function createElementBlock(type, props, children, patchFlag, dynamicProps, shapeFlag) {
|
|
return setupBlock(
|
|
createBaseVNode(
|
|
type,
|
|
props,
|
|
children,
|
|
patchFlag,
|
|
dynamicProps,
|
|
shapeFlag,
|
|
true
|
|
)
|
|
);
|
|
}
|
|
function createBlock(type, props, children, patchFlag, dynamicProps) {
|
|
return setupBlock(
|
|
createVNode(
|
|
type,
|
|
props,
|
|
children,
|
|
patchFlag,
|
|
dynamicProps,
|
|
true
|
|
)
|
|
);
|
|
}
|
|
function isVNode(value) {
|
|
return value ? value.__v_isVNode === true : false;
|
|
}
|
|
function isSameVNodeType(n1, n2) {
|
|
return n1.type === n2.type && n1.key === n2.key;
|
|
}
|
|
function transformVNodeArgs(transformer) {
|
|
}
|
|
const normalizeKey = ({ key }) => key != null ? key : null;
|
|
const normalizeRef = ({
|
|
ref: ref3,
|
|
ref_key,
|
|
ref_for
|
|
}) => {
|
|
if (typeof ref3 === "number") {
|
|
ref3 = "" + ref3;
|
|
}
|
|
return ref3 != null ? isString$1(ref3) || isRef(ref3) || isFunction$2(ref3) ? { i: currentRenderingInstance, r: ref3, k: ref_key, f: !!ref_for } : ref3 : null;
|
|
};
|
|
function createBaseVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, shapeFlag = type === Fragment ? 0 : 1, isBlockNode = false, needFullChildrenNormalization = false) {
|
|
const vnode = {
|
|
__v_isVNode: true,
|
|
__v_skip: true,
|
|
type,
|
|
props,
|
|
key: props && normalizeKey(props),
|
|
ref: props && normalizeRef(props),
|
|
scopeId: currentScopeId,
|
|
slotScopeIds: null,
|
|
children,
|
|
component: null,
|
|
suspense: null,
|
|
ssContent: null,
|
|
ssFallback: null,
|
|
dirs: null,
|
|
transition: null,
|
|
el: null,
|
|
anchor: null,
|
|
target: null,
|
|
targetStart: null,
|
|
targetAnchor: null,
|
|
staticCount: 0,
|
|
shapeFlag,
|
|
patchFlag,
|
|
dynamicProps,
|
|
dynamicChildren: null,
|
|
appContext: null,
|
|
ctx: currentRenderingInstance
|
|
};
|
|
if (needFullChildrenNormalization) {
|
|
normalizeChildren(vnode, children);
|
|
if (shapeFlag & 128) {
|
|
type.normalize(vnode);
|
|
}
|
|
} else if (children) {
|
|
vnode.shapeFlag |= isString$1(children) ? 8 : 16;
|
|
}
|
|
if (isBlockTreeEnabled > 0 && // avoid a block node from tracking itself
|
|
!isBlockNode && // has current parent block
|
|
currentBlock && // presence of a patch flag indicates this node needs patching on updates.
|
|
// component nodes also should always be patched, because even if the
|
|
// component doesn't need to update, it needs to persist the instance on to
|
|
// the next vnode so that it can be properly unmounted later.
|
|
(vnode.patchFlag > 0 || shapeFlag & 6) && // the EVENTS flag is only for hydration and if it is the only flag, the
|
|
// vnode should not be considered dynamic due to handler caching.
|
|
vnode.patchFlag !== 32) {
|
|
currentBlock.push(vnode);
|
|
}
|
|
return vnode;
|
|
}
|
|
const createVNode = _createVNode;
|
|
function _createVNode(type, props = null, children = null, patchFlag = 0, dynamicProps = null, isBlockNode = false) {
|
|
if (!type || type === NULL_DYNAMIC_COMPONENT) {
|
|
type = Comment;
|
|
}
|
|
if (isVNode(type)) {
|
|
const cloned = cloneVNode(
|
|
type,
|
|
props,
|
|
true
|
|
/* mergeRef: true */
|
|
);
|
|
if (children) {
|
|
normalizeChildren(cloned, children);
|
|
}
|
|
if (isBlockTreeEnabled > 0 && !isBlockNode && currentBlock) {
|
|
if (cloned.shapeFlag & 6) {
|
|
currentBlock[currentBlock.indexOf(type)] = cloned;
|
|
} else {
|
|
currentBlock.push(cloned);
|
|
}
|
|
}
|
|
cloned.patchFlag = -2;
|
|
return cloned;
|
|
}
|
|
if (isClassComponent(type)) {
|
|
type = type.__vccOpts;
|
|
}
|
|
if (props) {
|
|
props = guardReactiveProps(props);
|
|
let { class: klass, style: style2 } = props;
|
|
if (klass && !isString$1(klass)) {
|
|
props.class = normalizeClass(klass);
|
|
}
|
|
if (isObject$2(style2)) {
|
|
if (isProxy(style2) && !isArray$3(style2)) {
|
|
style2 = extend$1({}, style2);
|
|
}
|
|
props.style = normalizeStyle(style2);
|
|
}
|
|
}
|
|
const shapeFlag = isString$1(type) ? 1 : isSuspense(type) ? 128 : isTeleport(type) ? 64 : isObject$2(type) ? 4 : isFunction$2(type) ? 2 : 0;
|
|
return createBaseVNode(
|
|
type,
|
|
props,
|
|
children,
|
|
patchFlag,
|
|
dynamicProps,
|
|
shapeFlag,
|
|
isBlockNode,
|
|
true
|
|
);
|
|
}
|
|
function guardReactiveProps(props) {
|
|
if (!props) return null;
|
|
return isProxy(props) || isInternalObject(props) ? extend$1({}, props) : props;
|
|
}
|
|
function cloneVNode(vnode, extraProps, mergeRef = false, cloneTransition = false) {
|
|
const { props, ref: ref3, patchFlag, children, transition } = vnode;
|
|
const mergedProps = extraProps ? mergeProps(props || {}, extraProps) : props;
|
|
const cloned = {
|
|
__v_isVNode: true,
|
|
__v_skip: true,
|
|
type: vnode.type,
|
|
props: mergedProps,
|
|
key: mergedProps && normalizeKey(mergedProps),
|
|
ref: extraProps && extraProps.ref ? (
|
|
// #2078 in the case of <component :is="vnode" ref="extra"/>
|
|
// if the vnode itself already has a ref, cloneVNode will need to merge
|
|
// the refs so the single vnode can be set on multiple refs
|
|
mergeRef && ref3 ? isArray$3(ref3) ? ref3.concat(normalizeRef(extraProps)) : [ref3, normalizeRef(extraProps)] : normalizeRef(extraProps)
|
|
) : ref3,
|
|
scopeId: vnode.scopeId,
|
|
slotScopeIds: vnode.slotScopeIds,
|
|
children,
|
|
target: vnode.target,
|
|
targetStart: vnode.targetStart,
|
|
targetAnchor: vnode.targetAnchor,
|
|
staticCount: vnode.staticCount,
|
|
shapeFlag: vnode.shapeFlag,
|
|
// if the vnode is cloned with extra props, we can no longer assume its
|
|
// existing patch flag to be reliable and need to add the FULL_PROPS flag.
|
|
// note: preserve flag for fragments since they use the flag for children
|
|
// fast paths only.
|
|
patchFlag: extraProps && vnode.type !== Fragment ? patchFlag === -1 ? 16 : patchFlag | 16 : patchFlag,
|
|
dynamicProps: vnode.dynamicProps,
|
|
dynamicChildren: vnode.dynamicChildren,
|
|
appContext: vnode.appContext,
|
|
dirs: vnode.dirs,
|
|
transition,
|
|
// These should technically only be non-null on mounted VNodes. However,
|
|
// they *should* be copied for kept-alive vnodes. So we just always copy
|
|
// them since them being non-null during a mount doesn't affect the logic as
|
|
// they will simply be overwritten.
|
|
component: vnode.component,
|
|
suspense: vnode.suspense,
|
|
ssContent: vnode.ssContent && cloneVNode(vnode.ssContent),
|
|
ssFallback: vnode.ssFallback && cloneVNode(vnode.ssFallback),
|
|
el: vnode.el,
|
|
anchor: vnode.anchor,
|
|
ctx: vnode.ctx,
|
|
ce: vnode.ce
|
|
};
|
|
if (transition && cloneTransition) {
|
|
setTransitionHooks(
|
|
cloned,
|
|
transition.clone(cloned)
|
|
);
|
|
}
|
|
return cloned;
|
|
}
|
|
function createTextVNode(text = " ", flag = 0) {
|
|
return createVNode(Text, null, text, flag);
|
|
}
|
|
function createStaticVNode(content, numberOfNodes) {
|
|
const vnode = createVNode(Static, null, content);
|
|
vnode.staticCount = numberOfNodes;
|
|
return vnode;
|
|
}
|
|
function createCommentVNode(text = "", asBlock = false) {
|
|
return asBlock ? (openBlock(), createBlock(Comment, null, text)) : createVNode(Comment, null, text);
|
|
}
|
|
function normalizeVNode(child) {
|
|
if (child == null || typeof child === "boolean") {
|
|
return createVNode(Comment);
|
|
} else if (isArray$3(child)) {
|
|
return createVNode(
|
|
Fragment,
|
|
null,
|
|
// #3666, avoid reference pollution when reusing vnode
|
|
child.slice()
|
|
);
|
|
} else if (isVNode(child)) {
|
|
return cloneIfMounted(child);
|
|
} else {
|
|
return createVNode(Text, null, String(child));
|
|
}
|
|
}
|
|
function cloneIfMounted(child) {
|
|
return child.el === null && child.patchFlag !== -1 || child.memo ? child : cloneVNode(child);
|
|
}
|
|
function normalizeChildren(vnode, children) {
|
|
let type = 0;
|
|
const { shapeFlag } = vnode;
|
|
if (children == null) {
|
|
children = null;
|
|
} else if (isArray$3(children)) {
|
|
type = 16;
|
|
} else if (typeof children === "object") {
|
|
if (shapeFlag & (1 | 64)) {
|
|
const slot = children.default;
|
|
if (slot) {
|
|
slot._c && (slot._d = false);
|
|
normalizeChildren(vnode, slot());
|
|
slot._c && (slot._d = true);
|
|
}
|
|
return;
|
|
} else {
|
|
type = 32;
|
|
const slotFlag = children._;
|
|
if (!slotFlag && !isInternalObject(children)) {
|
|
children._ctx = currentRenderingInstance;
|
|
} else if (slotFlag === 3 && currentRenderingInstance) {
|
|
if (currentRenderingInstance.slots._ === 1) {
|
|
children._ = 1;
|
|
} else {
|
|
children._ = 2;
|
|
vnode.patchFlag |= 1024;
|
|
}
|
|
}
|
|
}
|
|
} else if (isFunction$2(children)) {
|
|
children = { default: children, _ctx: currentRenderingInstance };
|
|
type = 32;
|
|
} else {
|
|
children = String(children);
|
|
if (shapeFlag & 64) {
|
|
type = 16;
|
|
children = [createTextVNode(children)];
|
|
} else {
|
|
type = 8;
|
|
}
|
|
}
|
|
vnode.children = children;
|
|
vnode.shapeFlag |= type;
|
|
}
|
|
function mergeProps(...args) {
|
|
const ret = {};
|
|
for (let i = 0; i < args.length; i++) {
|
|
const toMerge = args[i];
|
|
for (const key in toMerge) {
|
|
if (key === "class") {
|
|
if (ret.class !== toMerge.class) {
|
|
ret.class = normalizeClass([ret.class, toMerge.class]);
|
|
}
|
|
} else if (key === "style") {
|
|
ret.style = normalizeStyle([ret.style, toMerge.style]);
|
|
} else if (isOn(key)) {
|
|
const existing = ret[key];
|
|
const incoming = toMerge[key];
|
|
if (incoming && existing !== incoming && !(isArray$3(existing) && existing.includes(incoming))) {
|
|
ret[key] = existing ? [].concat(existing, incoming) : incoming;
|
|
}
|
|
} else if (key !== "") {
|
|
ret[key] = toMerge[key];
|
|
}
|
|
}
|
|
}
|
|
return ret;
|
|
}
|
|
function invokeVNodeHook(hook, instance, vnode, prevVNode = null) {
|
|
callWithAsyncErrorHandling(hook, instance, 7, [
|
|
vnode,
|
|
prevVNode
|
|
]);
|
|
}
|
|
const emptyAppContext = createAppContext();
|
|
let uid = 0;
|
|
function createComponentInstance(vnode, parent, suspense) {
|
|
const type = vnode.type;
|
|
const appContext = (parent ? parent.appContext : vnode.appContext) || emptyAppContext;
|
|
const instance = {
|
|
uid: uid++,
|
|
vnode,
|
|
type,
|
|
parent,
|
|
appContext,
|
|
root: null,
|
|
// to be immediately set
|
|
next: null,
|
|
subTree: null,
|
|
// will be set synchronously right after creation
|
|
effect: null,
|
|
update: null,
|
|
// will be set synchronously right after creation
|
|
job: null,
|
|
scope: new EffectScope(
|
|
true
|
|
/* detached */
|
|
),
|
|
render: null,
|
|
proxy: null,
|
|
exposed: null,
|
|
exposeProxy: null,
|
|
withProxy: null,
|
|
provides: parent ? parent.provides : Object.create(appContext.provides),
|
|
ids: parent ? parent.ids : ["", 0, 0],
|
|
accessCache: null,
|
|
renderCache: [],
|
|
// local resolved assets
|
|
components: null,
|
|
directives: null,
|
|
// resolved props and emits options
|
|
propsOptions: normalizePropsOptions(type, appContext),
|
|
emitsOptions: normalizeEmitsOptions(type, appContext),
|
|
// emit
|
|
emit: null,
|
|
// to be set immediately
|
|
emitted: null,
|
|
// props default value
|
|
propsDefaults: EMPTY_OBJ,
|
|
// inheritAttrs
|
|
inheritAttrs: type.inheritAttrs,
|
|
// state
|
|
ctx: EMPTY_OBJ,
|
|
data: EMPTY_OBJ,
|
|
props: EMPTY_OBJ,
|
|
attrs: EMPTY_OBJ,
|
|
slots: EMPTY_OBJ,
|
|
refs: EMPTY_OBJ,
|
|
setupState: EMPTY_OBJ,
|
|
setupContext: null,
|
|
// suspense related
|
|
suspense,
|
|
suspenseId: suspense ? suspense.pendingId : 0,
|
|
asyncDep: null,
|
|
asyncResolved: false,
|
|
// lifecycle hooks
|
|
// not using enums here because it results in computed properties
|
|
isMounted: false,
|
|
isUnmounted: false,
|
|
isDeactivated: false,
|
|
bc: null,
|
|
c: null,
|
|
bm: null,
|
|
m: null,
|
|
bu: null,
|
|
u: null,
|
|
um: null,
|
|
bum: null,
|
|
da: null,
|
|
a: null,
|
|
rtg: null,
|
|
rtc: null,
|
|
ec: null,
|
|
sp: null
|
|
};
|
|
{
|
|
instance.ctx = { _: instance };
|
|
}
|
|
instance.root = parent ? parent.root : instance;
|
|
instance.emit = emit.bind(null, instance);
|
|
if (vnode.ce) {
|
|
vnode.ce(instance);
|
|
}
|
|
return instance;
|
|
}
|
|
let currentInstance = null;
|
|
const getCurrentInstance = () => currentInstance || currentRenderingInstance;
|
|
let internalSetCurrentInstance;
|
|
let setInSSRSetupState;
|
|
{
|
|
const g = getGlobalThis();
|
|
const registerGlobalSetter = (key, setter) => {
|
|
let setters;
|
|
if (!(setters = g[key])) setters = g[key] = [];
|
|
setters.push(setter);
|
|
return (v) => {
|
|
if (setters.length > 1) setters.forEach((set) => set(v));
|
|
else setters[0](v);
|
|
};
|
|
};
|
|
internalSetCurrentInstance = registerGlobalSetter(
|
|
`__VUE_INSTANCE_SETTERS__`,
|
|
(v) => currentInstance = v
|
|
);
|
|
setInSSRSetupState = registerGlobalSetter(
|
|
`__VUE_SSR_SETTERS__`,
|
|
(v) => isInSSRComponentSetup = v
|
|
);
|
|
}
|
|
const setCurrentInstance = (instance) => {
|
|
const prev = currentInstance;
|
|
internalSetCurrentInstance(instance);
|
|
instance.scope.on();
|
|
return () => {
|
|
instance.scope.off();
|
|
internalSetCurrentInstance(prev);
|
|
};
|
|
};
|
|
const unsetCurrentInstance = () => {
|
|
currentInstance && currentInstance.scope.off();
|
|
internalSetCurrentInstance(null);
|
|
};
|
|
function isStatefulComponent(instance) {
|
|
return instance.vnode.shapeFlag & 4;
|
|
}
|
|
let isInSSRComponentSetup = false;
|
|
function setupComponent(instance, isSSR = false, optimized = false) {
|
|
isSSR && setInSSRSetupState(isSSR);
|
|
const { props, children } = instance.vnode;
|
|
const isStateful = isStatefulComponent(instance);
|
|
initProps(instance, props, isStateful, isSSR);
|
|
initSlots(instance, children, optimized);
|
|
const setupResult = isStateful ? setupStatefulComponent(instance, isSSR) : void 0;
|
|
isSSR && setInSSRSetupState(false);
|
|
return setupResult;
|
|
}
|
|
function setupStatefulComponent(instance, isSSR) {
|
|
const Component = instance.type;
|
|
instance.accessCache = /* @__PURE__ */ Object.create(null);
|
|
instance.proxy = new Proxy(instance.ctx, PublicInstanceProxyHandlers);
|
|
const { setup } = Component;
|
|
if (setup) {
|
|
pauseTracking();
|
|
const setupContext = instance.setupContext = setup.length > 1 ? createSetupContext(instance) : null;
|
|
const reset = setCurrentInstance(instance);
|
|
const setupResult = callWithErrorHandling(
|
|
setup,
|
|
instance,
|
|
0,
|
|
[
|
|
instance.props,
|
|
setupContext
|
|
]
|
|
);
|
|
const isAsyncSetup = isPromise(setupResult);
|
|
resetTracking();
|
|
reset();
|
|
if ((isAsyncSetup || instance.sp) && !isAsyncWrapper(instance)) {
|
|
markAsyncBoundary(instance);
|
|
}
|
|
if (isAsyncSetup) {
|
|
setupResult.then(unsetCurrentInstance, unsetCurrentInstance);
|
|
if (isSSR) {
|
|
return setupResult.then((resolvedResult) => {
|
|
handleSetupResult(instance, resolvedResult, isSSR);
|
|
}).catch((e) => {
|
|
handleError(e, instance, 0);
|
|
});
|
|
} else {
|
|
instance.asyncDep = setupResult;
|
|
}
|
|
} else {
|
|
handleSetupResult(instance, setupResult, isSSR);
|
|
}
|
|
} else {
|
|
finishComponentSetup(instance, isSSR);
|
|
}
|
|
}
|
|
function handleSetupResult(instance, setupResult, isSSR) {
|
|
if (isFunction$2(setupResult)) {
|
|
if (instance.type.__ssrInlineRender) {
|
|
instance.ssrRender = setupResult;
|
|
} else {
|
|
instance.render = setupResult;
|
|
}
|
|
} else if (isObject$2(setupResult)) {
|
|
instance.setupState = proxyRefs(setupResult);
|
|
} else ;
|
|
finishComponentSetup(instance, isSSR);
|
|
}
|
|
let compile;
|
|
let installWithProxy;
|
|
function registerRuntimeCompiler(_compile) {
|
|
compile = _compile;
|
|
installWithProxy = (i) => {
|
|
if (i.render._rc) {
|
|
i.withProxy = new Proxy(i.ctx, RuntimeCompiledPublicInstanceProxyHandlers);
|
|
}
|
|
};
|
|
}
|
|
const isRuntimeOnly = () => !compile;
|
|
function finishComponentSetup(instance, isSSR, skipOptions) {
|
|
const Component = instance.type;
|
|
if (!instance.render) {
|
|
if (!isSSR && compile && !Component.render) {
|
|
const template = Component.template || resolveMergedOptions(instance).template;
|
|
if (template) {
|
|
const { isCustomElement, compilerOptions } = instance.appContext.config;
|
|
const { delimiters, compilerOptions: componentCompilerOptions } = Component;
|
|
const finalCompilerOptions = extend$1(
|
|
extend$1(
|
|
{
|
|
isCustomElement,
|
|
delimiters
|
|
},
|
|
compilerOptions
|
|
),
|
|
componentCompilerOptions
|
|
);
|
|
Component.render = compile(template, finalCompilerOptions);
|
|
}
|
|
}
|
|
instance.render = Component.render || NOOP;
|
|
if (installWithProxy) {
|
|
installWithProxy(instance);
|
|
}
|
|
}
|
|
{
|
|
const reset = setCurrentInstance(instance);
|
|
pauseTracking();
|
|
try {
|
|
applyOptions(instance);
|
|
} finally {
|
|
resetTracking();
|
|
reset();
|
|
}
|
|
}
|
|
}
|
|
const attrsProxyHandlers = {
|
|
get(target, key) {
|
|
track(target, "get", "");
|
|
return target[key];
|
|
}
|
|
};
|
|
function createSetupContext(instance) {
|
|
const expose = (exposed) => {
|
|
instance.exposed = exposed || {};
|
|
};
|
|
{
|
|
return {
|
|
attrs: new Proxy(instance.attrs, attrsProxyHandlers),
|
|
slots: instance.slots,
|
|
emit: instance.emit,
|
|
expose
|
|
};
|
|
}
|
|
}
|
|
function getComponentPublicInstance(instance) {
|
|
if (instance.exposed) {
|
|
return instance.exposeProxy || (instance.exposeProxy = new Proxy(proxyRefs(markRaw(instance.exposed)), {
|
|
get(target, key) {
|
|
if (key in target) {
|
|
return target[key];
|
|
} else if (key in publicPropertiesMap) {
|
|
return publicPropertiesMap[key](instance);
|
|
}
|
|
},
|
|
has(target, key) {
|
|
return key in target || key in publicPropertiesMap;
|
|
}
|
|
}));
|
|
} else {
|
|
return instance.proxy;
|
|
}
|
|
}
|
|
const classifyRE = /(?:^|[-_])(\w)/g;
|
|
const classify = (str) => str.replace(classifyRE, (c2) => c2.toUpperCase()).replace(/[-_]/g, "");
|
|
function getComponentName(Component, includeInferred = true) {
|
|
return isFunction$2(Component) ? Component.displayName || Component.name : Component.name || includeInferred && Component.__name;
|
|
}
|
|
function formatComponentName(instance, Component, isRoot = false) {
|
|
let name = getComponentName(Component);
|
|
if (!name && Component.__file) {
|
|
const match2 = Component.__file.match(/([^/\\]+)\.\w+$/);
|
|
if (match2) {
|
|
name = match2[1];
|
|
}
|
|
}
|
|
if (!name && instance && instance.parent) {
|
|
const inferFromRegistry = (registry) => {
|
|
for (const key in registry) {
|
|
if (registry[key] === Component) {
|
|
return key;
|
|
}
|
|
}
|
|
};
|
|
name = inferFromRegistry(
|
|
instance.components || instance.parent.type.components
|
|
) || inferFromRegistry(instance.appContext.components);
|
|
}
|
|
return name ? classify(name) : isRoot ? `App` : `Anonymous`;
|
|
}
|
|
function isClassComponent(value) {
|
|
return isFunction$2(value) && "__vccOpts" in value;
|
|
}
|
|
const computed = (getterOrOptions, debugOptions) => {
|
|
const c2 = computed$1(getterOrOptions, debugOptions, isInSSRComponentSetup);
|
|
return c2;
|
|
};
|
|
function h(type, propsOrChildren, children) {
|
|
const l = arguments.length;
|
|
if (l === 2) {
|
|
if (isObject$2(propsOrChildren) && !isArray$3(propsOrChildren)) {
|
|
if (isVNode(propsOrChildren)) {
|
|
return createVNode(type, null, [propsOrChildren]);
|
|
}
|
|
return createVNode(type, propsOrChildren);
|
|
} else {
|
|
return createVNode(type, null, propsOrChildren);
|
|
}
|
|
} else {
|
|
if (l > 3) {
|
|
children = Array.prototype.slice.call(arguments, 2);
|
|
} else if (l === 3 && isVNode(children)) {
|
|
children = [children];
|
|
}
|
|
return createVNode(type, propsOrChildren, children);
|
|
}
|
|
}
|
|
function initCustomFormatter() {
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
function withMemo(memo, render2, cache2, index) {
|
|
const cached = cache2[index];
|
|
if (cached && isMemoSame(cached, memo)) {
|
|
return cached;
|
|
}
|
|
const ret = render2();
|
|
ret.memo = memo.slice();
|
|
ret.cacheIndex = index;
|
|
return cache2[index] = ret;
|
|
}
|
|
function isMemoSame(cached, memo) {
|
|
const prev = cached.memo;
|
|
if (prev.length != memo.length) {
|
|
return false;
|
|
}
|
|
for (let i = 0; i < prev.length; i++) {
|
|
if (hasChanged(prev[i], memo[i])) {
|
|
return false;
|
|
}
|
|
}
|
|
if (isBlockTreeEnabled > 0 && currentBlock) {
|
|
currentBlock.push(cached);
|
|
}
|
|
return true;
|
|
}
|
|
const version = "3.5.13";
|
|
const warn$3 = NOOP;
|
|
const ErrorTypeStrings = ErrorTypeStrings$1;
|
|
const devtools = devtools$1;
|
|
const setDevtoolsHook = setDevtoolsHook$1;
|
|
const _ssrUtils = {
|
|
createComponentInstance,
|
|
setupComponent,
|
|
renderComponentRoot,
|
|
setCurrentRenderingInstance,
|
|
isVNode,
|
|
normalizeVNode,
|
|
getComponentPublicInstance,
|
|
ensureValidVNode: ensureValidVNode$1,
|
|
pushWarningContext,
|
|
popWarningContext
|
|
};
|
|
const ssrUtils = _ssrUtils;
|
|
const resolveFilter = null;
|
|
const compatUtils = null;
|
|
const DeprecationTypes = null;
|
|
/**
|
|
* @vue/runtime-dom v3.5.13
|
|
* (c) 2018-present Yuxi (Evan) You and Vue contributors
|
|
* @license MIT
|
|
**/
|
|
let policy = void 0;
|
|
const tt = typeof window !== "undefined" && window.trustedTypes;
|
|
if (tt) {
|
|
try {
|
|
policy = /* @__PURE__ */ tt.createPolicy("vue", {
|
|
createHTML: (val) => val
|
|
});
|
|
} catch (e) {
|
|
}
|
|
}
|
|
const unsafeToTrustedHTML = policy ? (val) => policy.createHTML(val) : (val) => val;
|
|
const svgNS = "http://www.w3.org/2000/svg";
|
|
const mathmlNS = "http://www.w3.org/1998/Math/MathML";
|
|
const doc = typeof document !== "undefined" ? document : null;
|
|
const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
|
|
const nodeOps = {
|
|
insert: (child, parent, anchor) => {
|
|
parent.insertBefore(child, anchor || null);
|
|
},
|
|
remove: (child) => {
|
|
const parent = child.parentNode;
|
|
if (parent) {
|
|
parent.removeChild(child);
|
|
}
|
|
},
|
|
createElement: (tag, namespace2, is, props) => {
|
|
const el = namespace2 === "svg" ? doc.createElementNS(svgNS, tag) : namespace2 === "mathml" ? doc.createElementNS(mathmlNS, tag) : is ? doc.createElement(tag, { is }) : doc.createElement(tag);
|
|
if (tag === "select" && props && props.multiple != null) {
|
|
el.setAttribute("multiple", props.multiple);
|
|
}
|
|
return el;
|
|
},
|
|
createText: (text) => doc.createTextNode(text),
|
|
createComment: (text) => doc.createComment(text),
|
|
setText: (node, text) => {
|
|
node.nodeValue = text;
|
|
},
|
|
setElementText: (el, text) => {
|
|
el.textContent = text;
|
|
},
|
|
parentNode: (node) => node.parentNode,
|
|
nextSibling: (node) => node.nextSibling,
|
|
querySelector: (selector) => doc.querySelector(selector),
|
|
setScopeId(el, id) {
|
|
el.setAttribute(id, "");
|
|
},
|
|
// __UNSAFE__
|
|
// Reason: innerHTML.
|
|
// Static content here can only come from compiled templates.
|
|
// As long as the user only uses trusted templates, this is safe.
|
|
insertStaticContent(content, parent, anchor, namespace2, start, end) {
|
|
const before = anchor ? anchor.previousSibling : parent.lastChild;
|
|
if (start && (start === end || start.nextSibling)) {
|
|
while (true) {
|
|
parent.insertBefore(start.cloneNode(true), anchor);
|
|
if (start === end || !(start = start.nextSibling)) break;
|
|
}
|
|
} else {
|
|
templateContainer.innerHTML = unsafeToTrustedHTML(
|
|
namespace2 === "svg" ? `<svg>${content}</svg>` : namespace2 === "mathml" ? `<math>${content}</math>` : content
|
|
);
|
|
const template = templateContainer.content;
|
|
if (namespace2 === "svg" || namespace2 === "mathml") {
|
|
const wrapper = template.firstChild;
|
|
while (wrapper.firstChild) {
|
|
template.appendChild(wrapper.firstChild);
|
|
}
|
|
template.removeChild(wrapper);
|
|
}
|
|
parent.insertBefore(template, anchor);
|
|
}
|
|
return [
|
|
// first
|
|
before ? before.nextSibling : parent.firstChild,
|
|
// last
|
|
anchor ? anchor.previousSibling : parent.lastChild
|
|
];
|
|
}
|
|
};
|
|
const TRANSITION = "transition";
|
|
const ANIMATION = "animation";
|
|
const vtcKey = Symbol("_vtc");
|
|
const DOMTransitionPropsValidators = {
|
|
name: String,
|
|
type: String,
|
|
css: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
duration: [String, Number, Object],
|
|
enterFromClass: String,
|
|
enterActiveClass: String,
|
|
enterToClass: String,
|
|
appearFromClass: String,
|
|
appearActiveClass: String,
|
|
appearToClass: String,
|
|
leaveFromClass: String,
|
|
leaveActiveClass: String,
|
|
leaveToClass: String
|
|
};
|
|
const TransitionPropsValidators = /* @__PURE__ */ extend$1(
|
|
{},
|
|
BaseTransitionPropsValidators,
|
|
DOMTransitionPropsValidators
|
|
);
|
|
const decorate$1 = (t) => {
|
|
t.displayName = "Transition";
|
|
t.props = TransitionPropsValidators;
|
|
return t;
|
|
};
|
|
const Transition = /* @__PURE__ */ decorate$1(
|
|
(props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots)
|
|
);
|
|
const callHook = (hook, args = []) => {
|
|
if (isArray$3(hook)) {
|
|
hook.forEach((h2) => h2(...args));
|
|
} else if (hook) {
|
|
hook(...args);
|
|
}
|
|
};
|
|
const hasExplicitCallback = (hook) => {
|
|
return hook ? isArray$3(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
|
|
};
|
|
function resolveTransitionProps(rawProps) {
|
|
const baseProps = {};
|
|
for (const key in rawProps) {
|
|
if (!(key in DOMTransitionPropsValidators)) {
|
|
baseProps[key] = rawProps[key];
|
|
}
|
|
}
|
|
if (rawProps.css === false) {
|
|
return baseProps;
|
|
}
|
|
const {
|
|
name = "v",
|
|
type,
|
|
duration: duration2,
|
|
enterFromClass = `${name}-enter-from`,
|
|
enterActiveClass = `${name}-enter-active`,
|
|
enterToClass = `${name}-enter-to`,
|
|
appearFromClass = enterFromClass,
|
|
appearActiveClass = enterActiveClass,
|
|
appearToClass = enterToClass,
|
|
leaveFromClass = `${name}-leave-from`,
|
|
leaveActiveClass = `${name}-leave-active`,
|
|
leaveToClass = `${name}-leave-to`
|
|
} = rawProps;
|
|
const durations = normalizeDuration(duration2);
|
|
const enterDuration = durations && durations[0];
|
|
const leaveDuration = durations && durations[1];
|
|
const {
|
|
onBeforeEnter,
|
|
onEnter,
|
|
onEnterCancelled,
|
|
onLeave,
|
|
onLeaveCancelled,
|
|
onBeforeAppear = onBeforeEnter,
|
|
onAppear = onEnter,
|
|
onAppearCancelled = onEnterCancelled
|
|
} = baseProps;
|
|
const finishEnter = (el, isAppear, done, isCancelled) => {
|
|
el._enterCancelled = isCancelled;
|
|
removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
|
removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
|
|
done && done();
|
|
};
|
|
const finishLeave = (el, done) => {
|
|
el._isLeaving = false;
|
|
removeTransitionClass(el, leaveFromClass);
|
|
removeTransitionClass(el, leaveToClass);
|
|
removeTransitionClass(el, leaveActiveClass);
|
|
done && done();
|
|
};
|
|
const makeEnterHook = (isAppear) => {
|
|
return (el, done) => {
|
|
const hook = isAppear ? onAppear : onEnter;
|
|
const resolve2 = () => finishEnter(el, isAppear, done);
|
|
callHook(hook, [el, resolve2]);
|
|
nextFrame(() => {
|
|
removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
|
|
addTransitionClass(el, isAppear ? appearToClass : enterToClass);
|
|
if (!hasExplicitCallback(hook)) {
|
|
whenTransitionEnds(el, type, enterDuration, resolve2);
|
|
}
|
|
});
|
|
};
|
|
};
|
|
return extend$1(baseProps, {
|
|
onBeforeEnter(el) {
|
|
callHook(onBeforeEnter, [el]);
|
|
addTransitionClass(el, enterFromClass);
|
|
addTransitionClass(el, enterActiveClass);
|
|
},
|
|
onBeforeAppear(el) {
|
|
callHook(onBeforeAppear, [el]);
|
|
addTransitionClass(el, appearFromClass);
|
|
addTransitionClass(el, appearActiveClass);
|
|
},
|
|
onEnter: makeEnterHook(false),
|
|
onAppear: makeEnterHook(true),
|
|
onLeave(el, done) {
|
|
el._isLeaving = true;
|
|
const resolve2 = () => finishLeave(el, done);
|
|
addTransitionClass(el, leaveFromClass);
|
|
if (!el._enterCancelled) {
|
|
forceReflow();
|
|
addTransitionClass(el, leaveActiveClass);
|
|
} else {
|
|
addTransitionClass(el, leaveActiveClass);
|
|
forceReflow();
|
|
}
|
|
nextFrame(() => {
|
|
if (!el._isLeaving) {
|
|
return;
|
|
}
|
|
removeTransitionClass(el, leaveFromClass);
|
|
addTransitionClass(el, leaveToClass);
|
|
if (!hasExplicitCallback(onLeave)) {
|
|
whenTransitionEnds(el, type, leaveDuration, resolve2);
|
|
}
|
|
});
|
|
callHook(onLeave, [el, resolve2]);
|
|
},
|
|
onEnterCancelled(el) {
|
|
finishEnter(el, false, void 0, true);
|
|
callHook(onEnterCancelled, [el]);
|
|
},
|
|
onAppearCancelled(el) {
|
|
finishEnter(el, true, void 0, true);
|
|
callHook(onAppearCancelled, [el]);
|
|
},
|
|
onLeaveCancelled(el) {
|
|
finishLeave(el);
|
|
callHook(onLeaveCancelled, [el]);
|
|
}
|
|
});
|
|
}
|
|
function normalizeDuration(duration2) {
|
|
if (duration2 == null) {
|
|
return null;
|
|
} else if (isObject$2(duration2)) {
|
|
return [NumberOf(duration2.enter), NumberOf(duration2.leave)];
|
|
} else {
|
|
const n = NumberOf(duration2);
|
|
return [n, n];
|
|
}
|
|
}
|
|
function NumberOf(val) {
|
|
const res = toNumber(val);
|
|
return res;
|
|
}
|
|
function addTransitionClass(el, cls) {
|
|
cls.split(/\s+/).forEach((c2) => c2 && el.classList.add(c2));
|
|
(el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
|
|
}
|
|
function removeTransitionClass(el, cls) {
|
|
cls.split(/\s+/).forEach((c2) => c2 && el.classList.remove(c2));
|
|
const _vtc = el[vtcKey];
|
|
if (_vtc) {
|
|
_vtc.delete(cls);
|
|
if (!_vtc.size) {
|
|
el[vtcKey] = void 0;
|
|
}
|
|
}
|
|
}
|
|
function nextFrame(cb) {
|
|
requestAnimationFrame(() => {
|
|
requestAnimationFrame(cb);
|
|
});
|
|
}
|
|
let endId = 0;
|
|
function whenTransitionEnds(el, expectedType, explicitTimeout, resolve2) {
|
|
const id = el._endId = ++endId;
|
|
const resolveIfNotStale = () => {
|
|
if (id === el._endId) {
|
|
resolve2();
|
|
}
|
|
};
|
|
if (explicitTimeout != null) {
|
|
return setTimeout(resolveIfNotStale, explicitTimeout);
|
|
}
|
|
const { type, timeout: timeout2, propCount } = getTransitionInfo(el, expectedType);
|
|
if (!type) {
|
|
return resolve2();
|
|
}
|
|
const endEvent = type + "end";
|
|
let ended = 0;
|
|
const end = () => {
|
|
el.removeEventListener(endEvent, onEnd);
|
|
resolveIfNotStale();
|
|
};
|
|
const onEnd = (e) => {
|
|
if (e.target === el && ++ended >= propCount) {
|
|
end();
|
|
}
|
|
};
|
|
setTimeout(() => {
|
|
if (ended < propCount) {
|
|
end();
|
|
}
|
|
}, timeout2 + 1);
|
|
el.addEventListener(endEvent, onEnd);
|
|
}
|
|
function getTransitionInfo(el, expectedType) {
|
|
const styles = window.getComputedStyle(el);
|
|
const getStyleProperties = (key) => (styles[key] || "").split(", ");
|
|
const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
|
|
const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
|
|
const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
|
|
const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
|
|
const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
|
|
const animationTimeout = getTimeout(animationDelays, animationDurations);
|
|
let type = null;
|
|
let timeout2 = 0;
|
|
let propCount = 0;
|
|
if (expectedType === TRANSITION) {
|
|
if (transitionTimeout > 0) {
|
|
type = TRANSITION;
|
|
timeout2 = transitionTimeout;
|
|
propCount = transitionDurations.length;
|
|
}
|
|
} else if (expectedType === ANIMATION) {
|
|
if (animationTimeout > 0) {
|
|
type = ANIMATION;
|
|
timeout2 = animationTimeout;
|
|
propCount = animationDurations.length;
|
|
}
|
|
} else {
|
|
timeout2 = Math.max(transitionTimeout, animationTimeout);
|
|
type = timeout2 > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
|
|
propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
|
|
}
|
|
const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
|
|
getStyleProperties(`${TRANSITION}Property`).toString()
|
|
);
|
|
return {
|
|
type,
|
|
timeout: timeout2,
|
|
propCount,
|
|
hasTransform
|
|
};
|
|
}
|
|
function getTimeout(delays, durations) {
|
|
while (delays.length < durations.length) {
|
|
delays = delays.concat(delays);
|
|
}
|
|
return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
|
|
}
|
|
function toMs(s) {
|
|
if (s === "auto") return 0;
|
|
return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
|
|
}
|
|
function forceReflow() {
|
|
return document.body.offsetHeight;
|
|
}
|
|
function patchClass(el, value, isSVG2) {
|
|
const transitionClasses = el[vtcKey];
|
|
if (transitionClasses) {
|
|
value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
|
|
}
|
|
if (value == null) {
|
|
el.removeAttribute("class");
|
|
} else if (isSVG2) {
|
|
el.setAttribute("class", value);
|
|
} else {
|
|
el.className = value;
|
|
}
|
|
}
|
|
const vShowOriginalDisplay = Symbol("_vod");
|
|
const vShowHidden = Symbol("_vsh");
|
|
const vShow = {
|
|
beforeMount(el, { value }, { transition }) {
|
|
el[vShowOriginalDisplay] = el.style.display === "none" ? "" : el.style.display;
|
|
if (transition && value) {
|
|
transition.beforeEnter(el);
|
|
} else {
|
|
setDisplay(el, value);
|
|
}
|
|
},
|
|
mounted(el, { value }, { transition }) {
|
|
if (transition && value) {
|
|
transition.enter(el);
|
|
}
|
|
},
|
|
updated(el, { value, oldValue }, { transition }) {
|
|
if (!value === !oldValue) return;
|
|
if (transition) {
|
|
if (value) {
|
|
transition.beforeEnter(el);
|
|
setDisplay(el, true);
|
|
transition.enter(el);
|
|
} else {
|
|
transition.leave(el, () => {
|
|
setDisplay(el, false);
|
|
});
|
|
}
|
|
} else {
|
|
setDisplay(el, value);
|
|
}
|
|
},
|
|
beforeUnmount(el, { value }) {
|
|
setDisplay(el, value);
|
|
}
|
|
};
|
|
function setDisplay(el, value) {
|
|
el.style.display = value ? el[vShowOriginalDisplay] : "none";
|
|
el[vShowHidden] = !value;
|
|
}
|
|
function initVShowForSSR() {
|
|
vShow.getSSRProps = ({ value }) => {
|
|
if (!value) {
|
|
return { style: { display: "none" } };
|
|
}
|
|
};
|
|
}
|
|
const CSS_VAR_TEXT = Symbol("");
|
|
function useCssVars(getter) {
|
|
const instance = getCurrentInstance();
|
|
if (!instance) {
|
|
return;
|
|
}
|
|
const updateTeleports = instance.ut = (vars = getter(instance.proxy)) => {
|
|
Array.from(
|
|
document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)
|
|
).forEach((node) => setVarsOnNode(node, vars));
|
|
};
|
|
const setVars = () => {
|
|
const vars = getter(instance.proxy);
|
|
if (instance.ce) {
|
|
setVarsOnNode(instance.ce, vars);
|
|
} else {
|
|
setVarsOnVNode(instance.subTree, vars);
|
|
}
|
|
updateTeleports(vars);
|
|
};
|
|
onBeforeUpdate(() => {
|
|
queuePostFlushCb(setVars);
|
|
});
|
|
onMounted(() => {
|
|
watch(setVars, NOOP, { flush: "post" });
|
|
const ob = new MutationObserver(setVars);
|
|
ob.observe(instance.subTree.el.parentNode, { childList: true });
|
|
onUnmounted(() => ob.disconnect());
|
|
});
|
|
}
|
|
function setVarsOnVNode(vnode, vars) {
|
|
if (vnode.shapeFlag & 128) {
|
|
const suspense = vnode.suspense;
|
|
vnode = suspense.activeBranch;
|
|
if (suspense.pendingBranch && !suspense.isHydrating) {
|
|
suspense.effects.push(() => {
|
|
setVarsOnVNode(suspense.activeBranch, vars);
|
|
});
|
|
}
|
|
}
|
|
while (vnode.component) {
|
|
vnode = vnode.component.subTree;
|
|
}
|
|
if (vnode.shapeFlag & 1 && vnode.el) {
|
|
setVarsOnNode(vnode.el, vars);
|
|
} else if (vnode.type === Fragment) {
|
|
vnode.children.forEach((c2) => setVarsOnVNode(c2, vars));
|
|
} else if (vnode.type === Static) {
|
|
let { el, anchor } = vnode;
|
|
while (el) {
|
|
setVarsOnNode(el, vars);
|
|
if (el === anchor) break;
|
|
el = el.nextSibling;
|
|
}
|
|
}
|
|
}
|
|
function setVarsOnNode(el, vars) {
|
|
if (el.nodeType === 1) {
|
|
const style2 = el.style;
|
|
let cssText = "";
|
|
for (const key in vars) {
|
|
style2.setProperty(`--${key}`, vars[key]);
|
|
cssText += `--${key}: ${vars[key]};`;
|
|
}
|
|
style2[CSS_VAR_TEXT] = cssText;
|
|
}
|
|
}
|
|
const displayRE = /(^|;)\s*display\s*:/;
|
|
function patchStyle(el, prev, next) {
|
|
const style2 = el.style;
|
|
const isCssString = isString$1(next);
|
|
let hasControlledDisplay = false;
|
|
if (next && !isCssString) {
|
|
if (prev) {
|
|
if (!isString$1(prev)) {
|
|
for (const key in prev) {
|
|
if (next[key] == null) {
|
|
setStyle(style2, key, "");
|
|
}
|
|
}
|
|
} else {
|
|
for (const prevStyle of prev.split(";")) {
|
|
const key = prevStyle.slice(0, prevStyle.indexOf(":")).trim();
|
|
if (next[key] == null) {
|
|
setStyle(style2, key, "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
for (const key in next) {
|
|
if (key === "display") {
|
|
hasControlledDisplay = true;
|
|
}
|
|
setStyle(style2, key, next[key]);
|
|
}
|
|
} else {
|
|
if (isCssString) {
|
|
if (prev !== next) {
|
|
const cssVarText = style2[CSS_VAR_TEXT];
|
|
if (cssVarText) {
|
|
next += ";" + cssVarText;
|
|
}
|
|
style2.cssText = next;
|
|
hasControlledDisplay = displayRE.test(next);
|
|
}
|
|
} else if (prev) {
|
|
el.removeAttribute("style");
|
|
}
|
|
}
|
|
if (vShowOriginalDisplay in el) {
|
|
el[vShowOriginalDisplay] = hasControlledDisplay ? style2.display : "";
|
|
if (el[vShowHidden]) {
|
|
style2.display = "none";
|
|
}
|
|
}
|
|
}
|
|
const importantRE = /\s*!important$/;
|
|
function setStyle(style2, name, val) {
|
|
if (isArray$3(val)) {
|
|
val.forEach((v) => setStyle(style2, name, v));
|
|
} else {
|
|
if (val == null) val = "";
|
|
if (name.startsWith("--")) {
|
|
style2.setProperty(name, val);
|
|
} else {
|
|
const prefixed = autoPrefix(style2, name);
|
|
if (importantRE.test(val)) {
|
|
style2.setProperty(
|
|
hyphenate(prefixed),
|
|
val.replace(importantRE, ""),
|
|
"important"
|
|
);
|
|
} else {
|
|
style2[prefixed] = val;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
const prefixes = ["Webkit", "Moz", "ms"];
|
|
const prefixCache = {};
|
|
function autoPrefix(style2, rawName) {
|
|
const cached = prefixCache[rawName];
|
|
if (cached) {
|
|
return cached;
|
|
}
|
|
let name = camelize(rawName);
|
|
if (name !== "filter" && name in style2) {
|
|
return prefixCache[rawName] = name;
|
|
}
|
|
name = capitalize(name);
|
|
for (let i = 0; i < prefixes.length; i++) {
|
|
const prefixed = prefixes[i] + name;
|
|
if (prefixed in style2) {
|
|
return prefixCache[rawName] = prefixed;
|
|
}
|
|
}
|
|
return rawName;
|
|
}
|
|
const xlinkNS = "http://www.w3.org/1999/xlink";
|
|
function patchAttr(el, key, value, isSVG2, instance, isBoolean2 = isSpecialBooleanAttr(key)) {
|
|
if (isSVG2 && key.startsWith("xlink:")) {
|
|
if (value == null) {
|
|
el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
|
|
} else {
|
|
el.setAttributeNS(xlinkNS, key, value);
|
|
}
|
|
} else {
|
|
if (value == null || isBoolean2 && !includeBooleanAttr(value)) {
|
|
el.removeAttribute(key);
|
|
} else {
|
|
el.setAttribute(
|
|
key,
|
|
isBoolean2 ? "" : isSymbol$1(value) ? String(value) : value
|
|
);
|
|
}
|
|
}
|
|
}
|
|
function patchDOMProp(el, key, value, parentComponent, attrName) {
|
|
if (key === "innerHTML" || key === "textContent") {
|
|
if (value != null) {
|
|
el[key] = key === "innerHTML" ? unsafeToTrustedHTML(value) : value;
|
|
}
|
|
return;
|
|
}
|
|
const tag = el.tagName;
|
|
if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
|
|
!tag.includes("-")) {
|
|
const oldValue = tag === "OPTION" ? el.getAttribute("value") || "" : el.value;
|
|
const newValue = value == null ? (
|
|
// #11647: value should be set as empty string for null and undefined,
|
|
// but <input type="checkbox"> should be set as 'on'.
|
|
el.type === "checkbox" ? "on" : ""
|
|
) : String(value);
|
|
if (oldValue !== newValue || !("_value" in el)) {
|
|
el.value = newValue;
|
|
}
|
|
if (value == null) {
|
|
el.removeAttribute(key);
|
|
}
|
|
el._value = value;
|
|
return;
|
|
}
|
|
let needRemove = false;
|
|
if (value === "" || value == null) {
|
|
const type = typeof el[key];
|
|
if (type === "boolean") {
|
|
value = includeBooleanAttr(value);
|
|
} else if (value == null && type === "string") {
|
|
value = "";
|
|
needRemove = true;
|
|
} else if (type === "number") {
|
|
value = 0;
|
|
needRemove = true;
|
|
}
|
|
}
|
|
try {
|
|
el[key] = value;
|
|
} catch (e) {
|
|
}
|
|
needRemove && el.removeAttribute(attrName || key);
|
|
}
|
|
function addEventListener(el, event, handler, options) {
|
|
el.addEventListener(event, handler, options);
|
|
}
|
|
function removeEventListener(el, event, handler, options) {
|
|
el.removeEventListener(event, handler, options);
|
|
}
|
|
const veiKey = Symbol("_vei");
|
|
function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
|
|
const invokers = el[veiKey] || (el[veiKey] = {});
|
|
const existingInvoker = invokers[rawName];
|
|
if (nextValue && existingInvoker) {
|
|
existingInvoker.value = nextValue;
|
|
} else {
|
|
const [name, options] = parseName(rawName);
|
|
if (nextValue) {
|
|
const invoker = invokers[rawName] = createInvoker(
|
|
nextValue,
|
|
instance
|
|
);
|
|
addEventListener(el, name, invoker, options);
|
|
} else if (existingInvoker) {
|
|
removeEventListener(el, name, existingInvoker, options);
|
|
invokers[rawName] = void 0;
|
|
}
|
|
}
|
|
}
|
|
const optionsModifierRE = /(?:Once|Passive|Capture)$/;
|
|
function parseName(name) {
|
|
let options;
|
|
if (optionsModifierRE.test(name)) {
|
|
options = {};
|
|
let m;
|
|
while (m = name.match(optionsModifierRE)) {
|
|
name = name.slice(0, name.length - m[0].length);
|
|
options[m[0].toLowerCase()] = true;
|
|
}
|
|
}
|
|
const event = name[2] === ":" ? name.slice(3) : hyphenate(name.slice(2));
|
|
return [event, options];
|
|
}
|
|
let cachedNow = 0;
|
|
const p = /* @__PURE__ */ Promise.resolve();
|
|
const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
|
|
function createInvoker(initialValue, instance) {
|
|
const invoker = (e) => {
|
|
if (!e._vts) {
|
|
e._vts = Date.now();
|
|
} else if (e._vts <= invoker.attached) {
|
|
return;
|
|
}
|
|
callWithAsyncErrorHandling(
|
|
patchStopImmediatePropagation(e, invoker.value),
|
|
instance,
|
|
5,
|
|
[e]
|
|
);
|
|
};
|
|
invoker.value = initialValue;
|
|
invoker.attached = getNow();
|
|
return invoker;
|
|
}
|
|
function patchStopImmediatePropagation(e, value) {
|
|
if (isArray$3(value)) {
|
|
const originalStop = e.stopImmediatePropagation;
|
|
e.stopImmediatePropagation = () => {
|
|
originalStop.call(e);
|
|
e._stopped = true;
|
|
};
|
|
return value.map(
|
|
(fn) => (e2) => !e2._stopped && fn && fn(e2)
|
|
);
|
|
} else {
|
|
return value;
|
|
}
|
|
}
|
|
const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
|
|
key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
|
|
const patchProp = (el, key, prevValue, nextValue, namespace2, parentComponent) => {
|
|
const isSVG2 = namespace2 === "svg";
|
|
if (key === "class") {
|
|
patchClass(el, nextValue, isSVG2);
|
|
} else if (key === "style") {
|
|
patchStyle(el, prevValue, nextValue);
|
|
} else if (isOn(key)) {
|
|
if (!isModelListener(key)) {
|
|
patchEvent(el, key, prevValue, nextValue, parentComponent);
|
|
}
|
|
} else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG2)) {
|
|
patchDOMProp(el, key, nextValue);
|
|
if (!el.tagName.includes("-") && (key === "value" || key === "checked" || key === "selected")) {
|
|
patchAttr(el, key, nextValue, isSVG2, parentComponent, key !== "value");
|
|
}
|
|
} else if (
|
|
// #11081 force set props for possible async custom element
|
|
el._isVueCE && (/[A-Z]/.test(key) || !isString$1(nextValue))
|
|
) {
|
|
patchDOMProp(el, camelize(key), nextValue, parentComponent, key);
|
|
} else {
|
|
if (key === "true-value") {
|
|
el._trueValue = nextValue;
|
|
} else if (key === "false-value") {
|
|
el._falseValue = nextValue;
|
|
}
|
|
patchAttr(el, key, nextValue, isSVG2);
|
|
}
|
|
};
|
|
function shouldSetAsProp(el, key, value, isSVG2) {
|
|
if (isSVG2) {
|
|
if (key === "innerHTML" || key === "textContent") {
|
|
return true;
|
|
}
|
|
if (key in el && isNativeOn(key) && isFunction$2(value)) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
if (key === "spellcheck" || key === "draggable" || key === "translate") {
|
|
return false;
|
|
}
|
|
if (key === "form") {
|
|
return false;
|
|
}
|
|
if (key === "list" && el.tagName === "INPUT") {
|
|
return false;
|
|
}
|
|
if (key === "type" && el.tagName === "TEXTAREA") {
|
|
return false;
|
|
}
|
|
if (key === "width" || key === "height") {
|
|
const tag = el.tagName;
|
|
if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
|
|
return false;
|
|
}
|
|
}
|
|
if (isNativeOn(key) && isString$1(value)) {
|
|
return false;
|
|
}
|
|
return key in el;
|
|
}
|
|
const REMOVAL = {};
|
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
// @__NO_SIDE_EFFECTS__
|
|
function defineCustomElement(options, extraOptions, _createApp) {
|
|
const Comp = /* @__PURE__ */ defineComponent(options, extraOptions);
|
|
if (isPlainObject$3(Comp)) extend$1(Comp, extraOptions);
|
|
class VueCustomElement extends VueElement {
|
|
constructor(initialProps) {
|
|
super(Comp, initialProps, _createApp);
|
|
}
|
|
}
|
|
VueCustomElement.def = Comp;
|
|
return VueCustomElement;
|
|
}
|
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options, extraOptions) => {
|
|
return /* @__PURE__ */ defineCustomElement(options, extraOptions, createSSRApp);
|
|
};
|
|
const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
|
|
};
|
|
class VueElement extends BaseClass {
|
|
constructor(_def, _props = {}, _createApp = createApp) {
|
|
super();
|
|
this._def = _def;
|
|
this._props = _props;
|
|
this._createApp = _createApp;
|
|
this._isVueCE = true;
|
|
this._instance = null;
|
|
this._app = null;
|
|
this._nonce = this._def.nonce;
|
|
this._connected = false;
|
|
this._resolved = false;
|
|
this._numberProps = null;
|
|
this._styleChildren = /* @__PURE__ */ new WeakSet();
|
|
this._ob = null;
|
|
if (this.shadowRoot && _createApp !== createApp) {
|
|
this._root = this.shadowRoot;
|
|
} else {
|
|
if (_def.shadowRoot !== false) {
|
|
this.attachShadow({ mode: "open" });
|
|
this._root = this.shadowRoot;
|
|
} else {
|
|
this._root = this;
|
|
}
|
|
}
|
|
if (!this._def.__asyncLoader) {
|
|
this._resolveProps(this._def);
|
|
}
|
|
}
|
|
connectedCallback() {
|
|
if (!this.isConnected) return;
|
|
if (!this.shadowRoot) {
|
|
this._parseSlots();
|
|
}
|
|
this._connected = true;
|
|
let parent = this;
|
|
while (parent = parent && (parent.parentNode || parent.host)) {
|
|
if (parent instanceof VueElement) {
|
|
this._parent = parent;
|
|
break;
|
|
}
|
|
}
|
|
if (!this._instance) {
|
|
if (this._resolved) {
|
|
this._setParent();
|
|
this._update();
|
|
} else {
|
|
if (parent && parent._pendingResolve) {
|
|
this._pendingResolve = parent._pendingResolve.then(() => {
|
|
this._pendingResolve = void 0;
|
|
this._resolveDef();
|
|
});
|
|
} else {
|
|
this._resolveDef();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
_setParent(parent = this._parent) {
|
|
if (parent) {
|
|
this._instance.parent = parent._instance;
|
|
this._instance.provides = parent._instance.provides;
|
|
}
|
|
}
|
|
disconnectedCallback() {
|
|
this._connected = false;
|
|
nextTick(() => {
|
|
if (!this._connected) {
|
|
if (this._ob) {
|
|
this._ob.disconnect();
|
|
this._ob = null;
|
|
}
|
|
this._app && this._app.unmount();
|
|
if (this._instance) this._instance.ce = void 0;
|
|
this._app = this._instance = null;
|
|
}
|
|
});
|
|
}
|
|
/**
|
|
* resolve inner component definition (handle possible async component)
|
|
*/
|
|
_resolveDef() {
|
|
if (this._pendingResolve) {
|
|
return;
|
|
}
|
|
for (let i = 0; i < this.attributes.length; i++) {
|
|
this._setAttr(this.attributes[i].name);
|
|
}
|
|
this._ob = new MutationObserver((mutations) => {
|
|
for (const m of mutations) {
|
|
this._setAttr(m.attributeName);
|
|
}
|
|
});
|
|
this._ob.observe(this, { attributes: true });
|
|
const resolve2 = (def2, isAsync = false) => {
|
|
this._resolved = true;
|
|
this._pendingResolve = void 0;
|
|
const { props, styles } = def2;
|
|
let numberProps;
|
|
if (props && !isArray$3(props)) {
|
|
for (const key in props) {
|
|
const opt = props[key];
|
|
if (opt === Number || opt && opt.type === Number) {
|
|
if (key in this._props) {
|
|
this._props[key] = toNumber(this._props[key]);
|
|
}
|
|
(numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[camelize(key)] = true;
|
|
}
|
|
}
|
|
}
|
|
this._numberProps = numberProps;
|
|
if (isAsync) {
|
|
this._resolveProps(def2);
|
|
}
|
|
if (this.shadowRoot) {
|
|
this._applyStyles(styles);
|
|
}
|
|
this._mount(def2);
|
|
};
|
|
const asyncDef = this._def.__asyncLoader;
|
|
if (asyncDef) {
|
|
this._pendingResolve = asyncDef().then(
|
|
(def2) => resolve2(this._def = def2, true)
|
|
);
|
|
} else {
|
|
resolve2(this._def);
|
|
}
|
|
}
|
|
_mount(def2) {
|
|
this._app = this._createApp(def2);
|
|
if (def2.configureApp) {
|
|
def2.configureApp(this._app);
|
|
}
|
|
this._app._ceVNode = this._createVNode();
|
|
this._app.mount(this._root);
|
|
const exposed = this._instance && this._instance.exposed;
|
|
if (!exposed) return;
|
|
for (const key in exposed) {
|
|
if (!hasOwn(this, key)) {
|
|
Object.defineProperty(this, key, {
|
|
// unwrap ref to be consistent with public instance behavior
|
|
get: () => unref(exposed[key])
|
|
});
|
|
}
|
|
}
|
|
}
|
|
_resolveProps(def2) {
|
|
const { props } = def2;
|
|
const declaredPropKeys = isArray$3(props) ? props : Object.keys(props || {});
|
|
for (const key of Object.keys(this)) {
|
|
if (key[0] !== "_" && declaredPropKeys.includes(key)) {
|
|
this._setProp(key, this[key]);
|
|
}
|
|
}
|
|
for (const key of declaredPropKeys.map(camelize)) {
|
|
Object.defineProperty(this, key, {
|
|
get() {
|
|
return this._getProp(key);
|
|
},
|
|
set(val) {
|
|
this._setProp(key, val, true, true);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
_setAttr(key) {
|
|
if (key.startsWith("data-v-")) return;
|
|
const has = this.hasAttribute(key);
|
|
let value = has ? this.getAttribute(key) : REMOVAL;
|
|
const camelKey = camelize(key);
|
|
if (has && this._numberProps && this._numberProps[camelKey]) {
|
|
value = toNumber(value);
|
|
}
|
|
this._setProp(camelKey, value, false, true);
|
|
}
|
|
/**
|
|
* @internal
|
|
*/
|
|
_getProp(key) {
|
|
return this._props[key];
|
|
}
|
|
/**
|
|
* @internal
|
|
*/
|
|
_setProp(key, val, shouldReflect = true, shouldUpdate = false) {
|
|
if (val !== this._props[key]) {
|
|
if (val === REMOVAL) {
|
|
delete this._props[key];
|
|
} else {
|
|
this._props[key] = val;
|
|
if (key === "key" && this._app) {
|
|
this._app._ceVNode.key = val;
|
|
}
|
|
}
|
|
if (shouldUpdate && this._instance) {
|
|
this._update();
|
|
}
|
|
if (shouldReflect) {
|
|
const ob = this._ob;
|
|
ob && ob.disconnect();
|
|
if (val === true) {
|
|
this.setAttribute(hyphenate(key), "");
|
|
} else if (typeof val === "string" || typeof val === "number") {
|
|
this.setAttribute(hyphenate(key), val + "");
|
|
} else if (!val) {
|
|
this.removeAttribute(hyphenate(key));
|
|
}
|
|
ob && ob.observe(this, { attributes: true });
|
|
}
|
|
}
|
|
}
|
|
_update() {
|
|
render$2(this._createVNode(), this._root);
|
|
}
|
|
_createVNode() {
|
|
const baseProps = {};
|
|
if (!this.shadowRoot) {
|
|
baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
|
|
}
|
|
const vnode = createVNode(this._def, extend$1(baseProps, this._props));
|
|
if (!this._instance) {
|
|
vnode.ce = (instance) => {
|
|
this._instance = instance;
|
|
instance.ce = this;
|
|
instance.isCE = true;
|
|
const dispatch = (event, args) => {
|
|
this.dispatchEvent(
|
|
new CustomEvent(
|
|
event,
|
|
isPlainObject$3(args[0]) ? extend$1({ detail: args }, args[0]) : { detail: args }
|
|
)
|
|
);
|
|
};
|
|
instance.emit = (event, ...args) => {
|
|
dispatch(event, args);
|
|
if (hyphenate(event) !== event) {
|
|
dispatch(hyphenate(event), args);
|
|
}
|
|
};
|
|
this._setParent();
|
|
};
|
|
}
|
|
return vnode;
|
|
}
|
|
_applyStyles(styles, owner) {
|
|
if (!styles) return;
|
|
if (owner) {
|
|
if (owner === this._def || this._styleChildren.has(owner)) {
|
|
return;
|
|
}
|
|
this._styleChildren.add(owner);
|
|
}
|
|
const nonce = this._nonce;
|
|
for (let i = styles.length - 1; i >= 0; i--) {
|
|
const s = document.createElement("style");
|
|
if (nonce) s.setAttribute("nonce", nonce);
|
|
s.textContent = styles[i];
|
|
this.shadowRoot.prepend(s);
|
|
}
|
|
}
|
|
/**
|
|
* Only called when shadowRoot is false
|
|
*/
|
|
_parseSlots() {
|
|
const slots = this._slots = {};
|
|
let n;
|
|
while (n = this.firstChild) {
|
|
const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
|
|
(slots[slotName] || (slots[slotName] = [])).push(n);
|
|
this.removeChild(n);
|
|
}
|
|
}
|
|
/**
|
|
* Only called when shadowRoot is false
|
|
*/
|
|
_renderSlots() {
|
|
const outlets = (this._teleportTarget || this).querySelectorAll("slot");
|
|
const scopeId = this._instance.type.__scopeId;
|
|
for (let i = 0; i < outlets.length; i++) {
|
|
const o = outlets[i];
|
|
const slotName = o.getAttribute("name") || "default";
|
|
const content = this._slots[slotName];
|
|
const parent = o.parentNode;
|
|
if (content) {
|
|
for (const n of content) {
|
|
if (scopeId && n.nodeType === 1) {
|
|
const id = scopeId + "-s";
|
|
const walker = document.createTreeWalker(n, 1);
|
|
n.setAttribute(id, "");
|
|
let child;
|
|
while (child = walker.nextNode()) {
|
|
child.setAttribute(id, "");
|
|
}
|
|
}
|
|
parent.insertBefore(n, o);
|
|
}
|
|
} else {
|
|
while (o.firstChild) parent.insertBefore(o.firstChild, o);
|
|
}
|
|
parent.removeChild(o);
|
|
}
|
|
}
|
|
/**
|
|
* @internal
|
|
*/
|
|
_injectChildStyle(comp) {
|
|
this._applyStyles(comp.styles, comp);
|
|
}
|
|
/**
|
|
* @internal
|
|
*/
|
|
_removeChildStyle(comp) {
|
|
}
|
|
}
|
|
function useHost(caller) {
|
|
const instance = getCurrentInstance();
|
|
const el = instance && instance.ce;
|
|
if (el) {
|
|
return el;
|
|
}
|
|
return null;
|
|
}
|
|
function useShadowRoot() {
|
|
const el = useHost();
|
|
return el && el.shadowRoot;
|
|
}
|
|
function useCssModule(name = "$style") {
|
|
{
|
|
const instance = getCurrentInstance();
|
|
if (!instance) {
|
|
return EMPTY_OBJ;
|
|
}
|
|
const modules = instance.type.__cssModules;
|
|
if (!modules) {
|
|
return EMPTY_OBJ;
|
|
}
|
|
const mod = modules[name];
|
|
if (!mod) {
|
|
return EMPTY_OBJ;
|
|
}
|
|
return mod;
|
|
}
|
|
}
|
|
const positionMap = /* @__PURE__ */ new WeakMap();
|
|
const newPositionMap = /* @__PURE__ */ new WeakMap();
|
|
const moveCbKey = Symbol("_moveCb");
|
|
const enterCbKey = Symbol("_enterCb");
|
|
const decorate = (t) => {
|
|
delete t.props.mode;
|
|
return t;
|
|
};
|
|
const TransitionGroupImpl = /* @__PURE__ */ decorate({
|
|
name: "TransitionGroup",
|
|
props: /* @__PURE__ */ extend$1({}, TransitionPropsValidators, {
|
|
tag: String,
|
|
moveClass: String
|
|
}),
|
|
setup(props, { slots }) {
|
|
const instance = getCurrentInstance();
|
|
const state = useTransitionState();
|
|
let prevChildren;
|
|
let children;
|
|
onUpdated(() => {
|
|
if (!prevChildren.length) {
|
|
return;
|
|
}
|
|
const moveClass = props.moveClass || `${props.name || "v"}-move`;
|
|
if (!hasCSSTransform(
|
|
prevChildren[0].el,
|
|
instance.vnode.el,
|
|
moveClass
|
|
)) {
|
|
return;
|
|
}
|
|
prevChildren.forEach(callPendingCbs);
|
|
prevChildren.forEach(recordPosition);
|
|
const movedChildren = prevChildren.filter(applyTranslation);
|
|
forceReflow();
|
|
movedChildren.forEach((c2) => {
|
|
const el = c2.el;
|
|
const style2 = el.style;
|
|
addTransitionClass(el, moveClass);
|
|
style2.transform = style2.webkitTransform = style2.transitionDuration = "";
|
|
const cb = el[moveCbKey] = (e) => {
|
|
if (e && e.target !== el) {
|
|
return;
|
|
}
|
|
if (!e || /transform$/.test(e.propertyName)) {
|
|
el.removeEventListener("transitionend", cb);
|
|
el[moveCbKey] = null;
|
|
removeTransitionClass(el, moveClass);
|
|
}
|
|
};
|
|
el.addEventListener("transitionend", cb);
|
|
});
|
|
});
|
|
return () => {
|
|
const rawProps = toRaw(props);
|
|
const cssTransitionProps = resolveTransitionProps(rawProps);
|
|
let tag = rawProps.tag || Fragment;
|
|
prevChildren = [];
|
|
if (children) {
|
|
for (let i = 0; i < children.length; i++) {
|
|
const child = children[i];
|
|
if (child.el && child.el instanceof Element) {
|
|
prevChildren.push(child);
|
|
setTransitionHooks(
|
|
child,
|
|
resolveTransitionHooks(
|
|
child,
|
|
cssTransitionProps,
|
|
state,
|
|
instance
|
|
)
|
|
);
|
|
positionMap.set(
|
|
child,
|
|
child.el.getBoundingClientRect()
|
|
);
|
|
}
|
|
}
|
|
}
|
|
children = slots.default ? getTransitionRawChildren(slots.default()) : [];
|
|
for (let i = 0; i < children.length; i++) {
|
|
const child = children[i];
|
|
if (child.key != null) {
|
|
setTransitionHooks(
|
|
child,
|
|
resolveTransitionHooks(child, cssTransitionProps, state, instance)
|
|
);
|
|
}
|
|
}
|
|
return createVNode(tag, null, children);
|
|
};
|
|
}
|
|
});
|
|
const TransitionGroup = TransitionGroupImpl;
|
|
function callPendingCbs(c2) {
|
|
const el = c2.el;
|
|
if (el[moveCbKey]) {
|
|
el[moveCbKey]();
|
|
}
|
|
if (el[enterCbKey]) {
|
|
el[enterCbKey]();
|
|
}
|
|
}
|
|
function recordPosition(c2) {
|
|
newPositionMap.set(c2, c2.el.getBoundingClientRect());
|
|
}
|
|
function applyTranslation(c2) {
|
|
const oldPos = positionMap.get(c2);
|
|
const newPos = newPositionMap.get(c2);
|
|
const dx = oldPos.left - newPos.left;
|
|
const dy = oldPos.top - newPos.top;
|
|
if (dx || dy) {
|
|
const s = c2.el.style;
|
|
s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
|
|
s.transitionDuration = "0s";
|
|
return c2;
|
|
}
|
|
}
|
|
function hasCSSTransform(el, root2, moveClass) {
|
|
const clone = el.cloneNode();
|
|
const _vtc = el[vtcKey];
|
|
if (_vtc) {
|
|
_vtc.forEach((cls) => {
|
|
cls.split(/\s+/).forEach((c2) => c2 && clone.classList.remove(c2));
|
|
});
|
|
}
|
|
moveClass.split(/\s+/).forEach((c2) => c2 && clone.classList.add(c2));
|
|
clone.style.display = "none";
|
|
const container = root2.nodeType === 1 ? root2 : root2.parentNode;
|
|
container.appendChild(clone);
|
|
const { hasTransform } = getTransitionInfo(clone);
|
|
container.removeChild(clone);
|
|
return hasTransform;
|
|
}
|
|
const getModelAssigner = (vnode) => {
|
|
const fn = vnode.props["onUpdate:modelValue"] || false;
|
|
return isArray$3(fn) ? (value) => invokeArrayFns(fn, value) : fn;
|
|
};
|
|
function onCompositionStart(e) {
|
|
e.target.composing = true;
|
|
}
|
|
function onCompositionEnd(e) {
|
|
const target = e.target;
|
|
if (target.composing) {
|
|
target.composing = false;
|
|
target.dispatchEvent(new Event("input"));
|
|
}
|
|
}
|
|
const assignKey = Symbol("_assign");
|
|
const vModelText = {
|
|
created(el, { modifiers: { lazy, trim: trim2, number } }, vnode) {
|
|
el[assignKey] = getModelAssigner(vnode);
|
|
const castToNumber = number || vnode.props && vnode.props.type === "number";
|
|
addEventListener(el, lazy ? "change" : "input", (e) => {
|
|
if (e.target.composing) return;
|
|
let domValue = el.value;
|
|
if (trim2) {
|
|
domValue = domValue.trim();
|
|
}
|
|
if (castToNumber) {
|
|
domValue = looseToNumber(domValue);
|
|
}
|
|
el[assignKey](domValue);
|
|
});
|
|
if (trim2) {
|
|
addEventListener(el, "change", () => {
|
|
el.value = el.value.trim();
|
|
});
|
|
}
|
|
if (!lazy) {
|
|
addEventListener(el, "compositionstart", onCompositionStart);
|
|
addEventListener(el, "compositionend", onCompositionEnd);
|
|
addEventListener(el, "change", onCompositionEnd);
|
|
}
|
|
},
|
|
// set value on mounted so it's after min/max for type="range"
|
|
mounted(el, { value }) {
|
|
el.value = value == null ? "" : value;
|
|
},
|
|
beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim: trim2, number } }, vnode) {
|
|
el[assignKey] = getModelAssigner(vnode);
|
|
if (el.composing) return;
|
|
const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? looseToNumber(el.value) : el.value;
|
|
const newValue = value == null ? "" : value;
|
|
if (elValue === newValue) {
|
|
return;
|
|
}
|
|
if (document.activeElement === el && el.type !== "range") {
|
|
if (lazy && value === oldValue) {
|
|
return;
|
|
}
|
|
if (trim2 && el.value.trim() === newValue) {
|
|
return;
|
|
}
|
|
}
|
|
el.value = newValue;
|
|
}
|
|
};
|
|
const vModelCheckbox = {
|
|
// #4096 array checkboxes need to be deep traversed
|
|
deep: true,
|
|
created(el, _, vnode) {
|
|
el[assignKey] = getModelAssigner(vnode);
|
|
addEventListener(el, "change", () => {
|
|
const modelValue = el._modelValue;
|
|
const elementValue = getValue$1(el);
|
|
const checked = el.checked;
|
|
const assign2 = el[assignKey];
|
|
if (isArray$3(modelValue)) {
|
|
const index = looseIndexOf(modelValue, elementValue);
|
|
const found = index !== -1;
|
|
if (checked && !found) {
|
|
assign2(modelValue.concat(elementValue));
|
|
} else if (!checked && found) {
|
|
const filtered = [...modelValue];
|
|
filtered.splice(index, 1);
|
|
assign2(filtered);
|
|
}
|
|
} else if (isSet(modelValue)) {
|
|
const cloned = new Set(modelValue);
|
|
if (checked) {
|
|
cloned.add(elementValue);
|
|
} else {
|
|
cloned.delete(elementValue);
|
|
}
|
|
assign2(cloned);
|
|
} else {
|
|
assign2(getCheckboxValue(el, checked));
|
|
}
|
|
});
|
|
},
|
|
// set initial checked on mount to wait for true-value/false-value
|
|
mounted: setChecked,
|
|
beforeUpdate(el, binding, vnode) {
|
|
el[assignKey] = getModelAssigner(vnode);
|
|
setChecked(el, binding, vnode);
|
|
}
|
|
};
|
|
function setChecked(el, { value, oldValue }, vnode) {
|
|
el._modelValue = value;
|
|
let checked;
|
|
if (isArray$3(value)) {
|
|
checked = looseIndexOf(value, vnode.props.value) > -1;
|
|
} else if (isSet(value)) {
|
|
checked = value.has(vnode.props.value);
|
|
} else {
|
|
if (value === oldValue) return;
|
|
checked = looseEqual(value, getCheckboxValue(el, true));
|
|
}
|
|
if (el.checked !== checked) {
|
|
el.checked = checked;
|
|
}
|
|
}
|
|
const vModelRadio = {
|
|
created(el, { value }, vnode) {
|
|
el.checked = looseEqual(value, vnode.props.value);
|
|
el[assignKey] = getModelAssigner(vnode);
|
|
addEventListener(el, "change", () => {
|
|
el[assignKey](getValue$1(el));
|
|
});
|
|
},
|
|
beforeUpdate(el, { value, oldValue }, vnode) {
|
|
el[assignKey] = getModelAssigner(vnode);
|
|
if (value !== oldValue) {
|
|
el.checked = looseEqual(value, vnode.props.value);
|
|
}
|
|
}
|
|
};
|
|
const vModelSelect = {
|
|
// <select multiple> value need to be deep traversed
|
|
deep: true,
|
|
created(el, { value, modifiers: { number } }, vnode) {
|
|
const isSetModel = isSet(value);
|
|
addEventListener(el, "change", () => {
|
|
const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
|
|
(o) => number ? looseToNumber(getValue$1(o)) : getValue$1(o)
|
|
);
|
|
el[assignKey](
|
|
el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
|
|
);
|
|
el._assigning = true;
|
|
nextTick(() => {
|
|
el._assigning = false;
|
|
});
|
|
});
|
|
el[assignKey] = getModelAssigner(vnode);
|
|
},
|
|
// set value in mounted & updated because <select> relies on its children
|
|
// <option>s.
|
|
mounted(el, { value }) {
|
|
setSelected(el, value);
|
|
},
|
|
beforeUpdate(el, _binding, vnode) {
|
|
el[assignKey] = getModelAssigner(vnode);
|
|
},
|
|
updated(el, { value }) {
|
|
if (!el._assigning) {
|
|
setSelected(el, value);
|
|
}
|
|
}
|
|
};
|
|
function setSelected(el, value) {
|
|
const isMultiple = el.multiple;
|
|
const isArrayValue = isArray$3(value);
|
|
if (isMultiple && !isArrayValue && !isSet(value)) {
|
|
return;
|
|
}
|
|
for (let i = 0, l = el.options.length; i < l; i++) {
|
|
const option = el.options[i];
|
|
const optionValue = getValue$1(option);
|
|
if (isMultiple) {
|
|
if (isArrayValue) {
|
|
const optionType = typeof optionValue;
|
|
if (optionType === "string" || optionType === "number") {
|
|
option.selected = value.some((v) => String(v) === String(optionValue));
|
|
} else {
|
|
option.selected = looseIndexOf(value, optionValue) > -1;
|
|
}
|
|
} else {
|
|
option.selected = value.has(optionValue);
|
|
}
|
|
} else if (looseEqual(getValue$1(option), value)) {
|
|
if (el.selectedIndex !== i) el.selectedIndex = i;
|
|
return;
|
|
}
|
|
}
|
|
if (!isMultiple && el.selectedIndex !== -1) {
|
|
el.selectedIndex = -1;
|
|
}
|
|
}
|
|
function getValue$1(el) {
|
|
return "_value" in el ? el._value : el.value;
|
|
}
|
|
function getCheckboxValue(el, checked) {
|
|
const key = checked ? "_trueValue" : "_falseValue";
|
|
return key in el ? el[key] : checked;
|
|
}
|
|
const vModelDynamic = {
|
|
created(el, binding, vnode) {
|
|
callModelHook(el, binding, vnode, null, "created");
|
|
},
|
|
mounted(el, binding, vnode) {
|
|
callModelHook(el, binding, vnode, null, "mounted");
|
|
},
|
|
beforeUpdate(el, binding, vnode, prevVNode) {
|
|
callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
|
|
},
|
|
updated(el, binding, vnode, prevVNode) {
|
|
callModelHook(el, binding, vnode, prevVNode, "updated");
|
|
}
|
|
};
|
|
function resolveDynamicModel(tagName, type) {
|
|
switch (tagName) {
|
|
case "SELECT":
|
|
return vModelSelect;
|
|
case "TEXTAREA":
|
|
return vModelText;
|
|
default:
|
|
switch (type) {
|
|
case "checkbox":
|
|
return vModelCheckbox;
|
|
case "radio":
|
|
return vModelRadio;
|
|
default:
|
|
return vModelText;
|
|
}
|
|
}
|
|
}
|
|
function callModelHook(el, binding, vnode, prevVNode, hook) {
|
|
const modelToUse = resolveDynamicModel(
|
|
el.tagName,
|
|
vnode.props && vnode.props.type
|
|
);
|
|
const fn = modelToUse[hook];
|
|
fn && fn(el, binding, vnode, prevVNode);
|
|
}
|
|
function initVModelForSSR() {
|
|
vModelText.getSSRProps = ({ value }) => ({ value });
|
|
vModelRadio.getSSRProps = ({ value }, vnode) => {
|
|
if (vnode.props && looseEqual(vnode.props.value, value)) {
|
|
return { checked: true };
|
|
}
|
|
};
|
|
vModelCheckbox.getSSRProps = ({ value }, vnode) => {
|
|
if (isArray$3(value)) {
|
|
if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
|
|
return { checked: true };
|
|
}
|
|
} else if (isSet(value)) {
|
|
if (vnode.props && value.has(vnode.props.value)) {
|
|
return { checked: true };
|
|
}
|
|
} else if (value) {
|
|
return { checked: true };
|
|
}
|
|
};
|
|
vModelDynamic.getSSRProps = (binding, vnode) => {
|
|
if (typeof vnode.type !== "string") {
|
|
return;
|
|
}
|
|
const modelToUse = resolveDynamicModel(
|
|
// resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
|
|
vnode.type.toUpperCase(),
|
|
vnode.props && vnode.props.type
|
|
);
|
|
if (modelToUse.getSSRProps) {
|
|
return modelToUse.getSSRProps(binding, vnode);
|
|
}
|
|
};
|
|
}
|
|
const systemModifiers = ["ctrl", "shift", "alt", "meta"];
|
|
const modifierGuards = {
|
|
stop: (e) => e.stopPropagation(),
|
|
prevent: (e) => e.preventDefault(),
|
|
self: (e) => e.target !== e.currentTarget,
|
|
ctrl: (e) => !e.ctrlKey,
|
|
shift: (e) => !e.shiftKey,
|
|
alt: (e) => !e.altKey,
|
|
meta: (e) => !e.metaKey,
|
|
left: (e) => "button" in e && e.button !== 0,
|
|
middle: (e) => "button" in e && e.button !== 1,
|
|
right: (e) => "button" in e && e.button !== 2,
|
|
exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
|
|
};
|
|
const withModifiers = (fn, modifiers) => {
|
|
const cache2 = fn._withMods || (fn._withMods = {});
|
|
const cacheKey = modifiers.join(".");
|
|
return cache2[cacheKey] || (cache2[cacheKey] = (event, ...args) => {
|
|
for (let i = 0; i < modifiers.length; i++) {
|
|
const guard = modifierGuards[modifiers[i]];
|
|
if (guard && guard(event, modifiers)) return;
|
|
}
|
|
return fn(event, ...args);
|
|
});
|
|
};
|
|
const keyNames = {
|
|
esc: "escape",
|
|
space: " ",
|
|
up: "arrow-up",
|
|
left: "arrow-left",
|
|
right: "arrow-right",
|
|
down: "arrow-down",
|
|
delete: "backspace"
|
|
};
|
|
const withKeys = (fn, modifiers) => {
|
|
const cache2 = fn._withKeys || (fn._withKeys = {});
|
|
const cacheKey = modifiers.join(".");
|
|
return cache2[cacheKey] || (cache2[cacheKey] = (event) => {
|
|
if (!("key" in event)) {
|
|
return;
|
|
}
|
|
const eventKey = hyphenate(event.key);
|
|
if (modifiers.some(
|
|
(k) => k === eventKey || keyNames[k] === eventKey
|
|
)) {
|
|
return fn(event);
|
|
}
|
|
});
|
|
};
|
|
const rendererOptions = /* @__PURE__ */ extend$1({ patchProp }, nodeOps);
|
|
let renderer;
|
|
let enabledHydration = false;
|
|
function ensureRenderer() {
|
|
return renderer || (renderer = createRenderer(rendererOptions));
|
|
}
|
|
function ensureHydrationRenderer() {
|
|
renderer = enabledHydration ? renderer : createHydrationRenderer(rendererOptions);
|
|
enabledHydration = true;
|
|
return renderer;
|
|
}
|
|
const render$2 = (...args) => {
|
|
ensureRenderer().render(...args);
|
|
};
|
|
const hydrate = (...args) => {
|
|
ensureHydrationRenderer().hydrate(...args);
|
|
};
|
|
const createApp = (...args) => {
|
|
const app2 = ensureRenderer().createApp(...args);
|
|
const { mount: mount2 } = app2;
|
|
app2.mount = (containerOrSelector) => {
|
|
const container = normalizeContainer(containerOrSelector);
|
|
if (!container) return;
|
|
const component = app2._component;
|
|
if (!isFunction$2(component) && !component.render && !component.template) {
|
|
component.template = container.innerHTML;
|
|
}
|
|
if (container.nodeType === 1) {
|
|
container.textContent = "";
|
|
}
|
|
const proxy = mount2(container, false, resolveRootNamespace(container));
|
|
if (container instanceof Element) {
|
|
container.removeAttribute("v-cloak");
|
|
container.setAttribute("data-v-app", "");
|
|
}
|
|
return proxy;
|
|
};
|
|
return app2;
|
|
};
|
|
const createSSRApp = (...args) => {
|
|
const app2 = ensureHydrationRenderer().createApp(...args);
|
|
const { mount: mount2 } = app2;
|
|
app2.mount = (containerOrSelector) => {
|
|
const container = normalizeContainer(containerOrSelector);
|
|
if (container) {
|
|
return mount2(container, true, resolveRootNamespace(container));
|
|
}
|
|
};
|
|
return app2;
|
|
};
|
|
function resolveRootNamespace(container) {
|
|
if (container instanceof SVGElement) {
|
|
return "svg";
|
|
}
|
|
if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
|
|
return "mathml";
|
|
}
|
|
}
|
|
function normalizeContainer(container) {
|
|
if (isString$1(container)) {
|
|
const res = document.querySelector(container);
|
|
return res;
|
|
}
|
|
return container;
|
|
}
|
|
let ssrDirectiveInitialized = false;
|
|
const initDirectivesForSSR = () => {
|
|
if (!ssrDirectiveInitialized) {
|
|
ssrDirectiveInitialized = true;
|
|
initVModelForSSR();
|
|
initVShowForSSR();
|
|
}
|
|
};
|
|
const runtimeDom_esmBundler = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
BaseTransition,
|
|
BaseTransitionPropsValidators,
|
|
Comment,
|
|
DeprecationTypes,
|
|
EffectScope,
|
|
ErrorCodes,
|
|
ErrorTypeStrings,
|
|
Fragment,
|
|
KeepAlive,
|
|
ReactiveEffect,
|
|
Static,
|
|
Suspense,
|
|
Teleport,
|
|
Text,
|
|
TrackOpTypes,
|
|
Transition,
|
|
TransitionGroup,
|
|
TriggerOpTypes,
|
|
VueElement,
|
|
assertNumber,
|
|
callWithAsyncErrorHandling,
|
|
callWithErrorHandling,
|
|
camelize,
|
|
capitalize,
|
|
cloneVNode,
|
|
compatUtils,
|
|
computed,
|
|
createApp,
|
|
createBlock,
|
|
createCommentVNode,
|
|
createElementBlock,
|
|
createElementVNode: createBaseVNode,
|
|
createHydrationRenderer,
|
|
createPropsRestProxy,
|
|
createRenderer,
|
|
createSSRApp,
|
|
createSlots,
|
|
createStaticVNode,
|
|
createTextVNode,
|
|
createVNode,
|
|
customRef,
|
|
defineAsyncComponent,
|
|
defineComponent,
|
|
defineCustomElement,
|
|
defineEmits,
|
|
defineExpose,
|
|
defineModel,
|
|
defineOptions,
|
|
defineProps,
|
|
defineSSRCustomElement,
|
|
defineSlots,
|
|
devtools,
|
|
effect,
|
|
effectScope,
|
|
getCurrentInstance,
|
|
getCurrentScope,
|
|
getCurrentWatcher,
|
|
getTransitionRawChildren,
|
|
guardReactiveProps,
|
|
h,
|
|
handleError,
|
|
hasInjectionContext,
|
|
hydrate,
|
|
hydrateOnIdle,
|
|
hydrateOnInteraction,
|
|
hydrateOnMediaQuery,
|
|
hydrateOnVisible,
|
|
initCustomFormatter,
|
|
initDirectivesForSSR,
|
|
inject,
|
|
isMemoSame,
|
|
isProxy,
|
|
isReactive,
|
|
isReadonly,
|
|
isRef,
|
|
isRuntimeOnly,
|
|
isShallow,
|
|
isVNode,
|
|
markRaw,
|
|
mergeDefaults,
|
|
mergeModels,
|
|
mergeProps,
|
|
nextTick,
|
|
normalizeClass,
|
|
normalizeProps,
|
|
normalizeStyle,
|
|
onActivated,
|
|
onBeforeMount,
|
|
onBeforeUnmount,
|
|
onBeforeUpdate,
|
|
onDeactivated,
|
|
onErrorCaptured,
|
|
onMounted,
|
|
onRenderTracked,
|
|
onRenderTriggered,
|
|
onScopeDispose,
|
|
onServerPrefetch,
|
|
onUnmounted,
|
|
onUpdated,
|
|
onWatcherCleanup,
|
|
openBlock,
|
|
popScopeId,
|
|
provide,
|
|
proxyRefs,
|
|
pushScopeId,
|
|
queuePostFlushCb,
|
|
reactive,
|
|
readonly,
|
|
ref,
|
|
registerRuntimeCompiler,
|
|
render: render$2,
|
|
renderList,
|
|
renderSlot,
|
|
resolveComponent,
|
|
resolveDirective,
|
|
resolveDynamicComponent,
|
|
resolveFilter,
|
|
resolveTransitionHooks,
|
|
setBlockTracking,
|
|
setDevtoolsHook,
|
|
setTransitionHooks,
|
|
shallowReactive,
|
|
shallowReadonly,
|
|
shallowRef,
|
|
ssrContextKey: ssrContextKey$1,
|
|
ssrUtils,
|
|
stop,
|
|
toDisplayString,
|
|
toHandlerKey,
|
|
toHandlers,
|
|
toRaw,
|
|
toRef,
|
|
toRefs,
|
|
toValue,
|
|
transformVNodeArgs,
|
|
triggerRef,
|
|
unref,
|
|
useAttrs,
|
|
useCssModule,
|
|
useCssVars,
|
|
useHost,
|
|
useId,
|
|
useModel,
|
|
useSSRContext,
|
|
useShadowRoot,
|
|
useSlots,
|
|
useTemplateRef,
|
|
useTransitionState,
|
|
vModelCheckbox,
|
|
vModelDynamic,
|
|
vModelRadio,
|
|
vModelSelect,
|
|
vModelText,
|
|
vShow,
|
|
version,
|
|
warn: warn$3,
|
|
watch,
|
|
watchEffect,
|
|
watchPostEffect,
|
|
watchSyncEffect,
|
|
withAsyncContext,
|
|
withCtx,
|
|
withDefaults,
|
|
withDirectives,
|
|
withKeys,
|
|
withMemo,
|
|
withModifiers,
|
|
withScopeId
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
/*!
|
|
* pinia v2.3.1
|
|
* (c) 2025 Eduardo San Martin Morote
|
|
* @license MIT
|
|
*/
|
|
let activePinia;
|
|
const setActivePinia = (pinia) => activePinia = pinia;
|
|
const piniaSymbol = (
|
|
/* istanbul ignore next */
|
|
Symbol()
|
|
);
|
|
function isPlainObject$2(o) {
|
|
return o && typeof o === "object" && Object.prototype.toString.call(o) === "[object Object]" && typeof o.toJSON !== "function";
|
|
}
|
|
var MutationType;
|
|
(function(MutationType2) {
|
|
MutationType2["direct"] = "direct";
|
|
MutationType2["patchObject"] = "patch object";
|
|
MutationType2["patchFunction"] = "patch function";
|
|
})(MutationType || (MutationType = {}));
|
|
function createPinia() {
|
|
const scope = effectScope(true);
|
|
const state = scope.run(() => ref({}));
|
|
let _p = [];
|
|
let toBeInstalled = [];
|
|
const pinia = markRaw({
|
|
install(app2) {
|
|
setActivePinia(pinia);
|
|
{
|
|
pinia._a = app2;
|
|
app2.provide(piniaSymbol, pinia);
|
|
app2.config.globalProperties.$pinia = pinia;
|
|
toBeInstalled.forEach((plugin2) => _p.push(plugin2));
|
|
toBeInstalled = [];
|
|
}
|
|
},
|
|
use(plugin2) {
|
|
if (!this._a && true) {
|
|
toBeInstalled.push(plugin2);
|
|
} else {
|
|
_p.push(plugin2);
|
|
}
|
|
return this;
|
|
},
|
|
_p,
|
|
// it's actually undefined here
|
|
// @ts-expect-error
|
|
_a: null,
|
|
_e: scope,
|
|
_s: /* @__PURE__ */ new Map(),
|
|
state
|
|
});
|
|
return pinia;
|
|
}
|
|
const noop$2 = () => {
|
|
};
|
|
function addSubscription(subscriptions, callback, detached, onCleanup = noop$2) {
|
|
subscriptions.push(callback);
|
|
const removeSubscription = () => {
|
|
const idx = subscriptions.indexOf(callback);
|
|
if (idx > -1) {
|
|
subscriptions.splice(idx, 1);
|
|
onCleanup();
|
|
}
|
|
};
|
|
if (!detached && getCurrentScope()) {
|
|
onScopeDispose(removeSubscription);
|
|
}
|
|
return removeSubscription;
|
|
}
|
|
function triggerSubscriptions(subscriptions, ...args) {
|
|
subscriptions.slice().forEach((callback) => {
|
|
callback(...args);
|
|
});
|
|
}
|
|
const fallbackRunWithContext = (fn) => fn();
|
|
const ACTION_MARKER = Symbol();
|
|
const ACTION_NAME = Symbol();
|
|
function mergeReactiveObjects(target, patchToApply) {
|
|
if (target instanceof Map && patchToApply instanceof Map) {
|
|
patchToApply.forEach((value, key) => target.set(key, value));
|
|
} else if (target instanceof Set && patchToApply instanceof Set) {
|
|
patchToApply.forEach(target.add, target);
|
|
}
|
|
for (const key in patchToApply) {
|
|
if (!patchToApply.hasOwnProperty(key))
|
|
continue;
|
|
const subPatch = patchToApply[key];
|
|
const targetValue = target[key];
|
|
if (isPlainObject$2(targetValue) && isPlainObject$2(subPatch) && target.hasOwnProperty(key) && !isRef(subPatch) && !isReactive(subPatch)) {
|
|
target[key] = mergeReactiveObjects(targetValue, subPatch);
|
|
} else {
|
|
target[key] = subPatch;
|
|
}
|
|
}
|
|
return target;
|
|
}
|
|
const skipHydrateSymbol = (
|
|
/* istanbul ignore next */
|
|
Symbol()
|
|
);
|
|
function shouldHydrate(obj) {
|
|
return !isPlainObject$2(obj) || !obj.hasOwnProperty(skipHydrateSymbol);
|
|
}
|
|
const { assign: assign$1 } = Object;
|
|
function isComputed(o) {
|
|
return !!(isRef(o) && o.effect);
|
|
}
|
|
function createOptionsStore(id, options, pinia, hot) {
|
|
const { state, actions, getters } = options;
|
|
const initialState = pinia.state.value[id];
|
|
let store;
|
|
function setup() {
|
|
if (!initialState && true) {
|
|
{
|
|
pinia.state.value[id] = state ? state() : {};
|
|
}
|
|
}
|
|
const localState = toRefs(pinia.state.value[id]);
|
|
return assign$1(localState, actions, Object.keys(getters || {}).reduce((computedGetters, name) => {
|
|
computedGetters[name] = markRaw(computed(() => {
|
|
setActivePinia(pinia);
|
|
const store2 = pinia._s.get(id);
|
|
return getters[name].call(store2, store2);
|
|
}));
|
|
return computedGetters;
|
|
}, {}));
|
|
}
|
|
store = createSetupStore(id, setup, options, pinia, hot, true);
|
|
return store;
|
|
}
|
|
function createSetupStore($id, setup, options = {}, pinia, hot, isOptionsStore) {
|
|
let scope;
|
|
const optionsForPlugin = assign$1({ actions: {} }, options);
|
|
const $subscribeOptions = { deep: true };
|
|
let isListening;
|
|
let isSyncListening;
|
|
let subscriptions = [];
|
|
let actionSubscriptions = [];
|
|
let debuggerEvents;
|
|
const initialState = pinia.state.value[$id];
|
|
if (!isOptionsStore && !initialState && true) {
|
|
{
|
|
pinia.state.value[$id] = {};
|
|
}
|
|
}
|
|
ref({});
|
|
let activeListener;
|
|
function $patch(partialStateOrMutator) {
|
|
let subscriptionMutation;
|
|
isListening = isSyncListening = false;
|
|
if (typeof partialStateOrMutator === "function") {
|
|
partialStateOrMutator(pinia.state.value[$id]);
|
|
subscriptionMutation = {
|
|
type: MutationType.patchFunction,
|
|
storeId: $id,
|
|
events: debuggerEvents
|
|
};
|
|
} else {
|
|
mergeReactiveObjects(pinia.state.value[$id], partialStateOrMutator);
|
|
subscriptionMutation = {
|
|
type: MutationType.patchObject,
|
|
payload: partialStateOrMutator,
|
|
storeId: $id,
|
|
events: debuggerEvents
|
|
};
|
|
}
|
|
const myListenerId = activeListener = Symbol();
|
|
nextTick().then(() => {
|
|
if (activeListener === myListenerId) {
|
|
isListening = true;
|
|
}
|
|
});
|
|
isSyncListening = true;
|
|
triggerSubscriptions(subscriptions, subscriptionMutation, pinia.state.value[$id]);
|
|
}
|
|
const $reset = isOptionsStore ? function $reset2() {
|
|
const { state } = options;
|
|
const newState = state ? state() : {};
|
|
this.$patch(($state) => {
|
|
assign$1($state, newState);
|
|
});
|
|
} : (
|
|
/* istanbul ignore next */
|
|
noop$2
|
|
);
|
|
function $dispose() {
|
|
scope.stop();
|
|
subscriptions = [];
|
|
actionSubscriptions = [];
|
|
pinia._s.delete($id);
|
|
}
|
|
const action = (fn, name = "") => {
|
|
if (ACTION_MARKER in fn) {
|
|
fn[ACTION_NAME] = name;
|
|
return fn;
|
|
}
|
|
const wrappedAction = function() {
|
|
setActivePinia(pinia);
|
|
const args = Array.from(arguments);
|
|
const afterCallbackList = [];
|
|
const onErrorCallbackList = [];
|
|
function after(callback) {
|
|
afterCallbackList.push(callback);
|
|
}
|
|
function onError(callback) {
|
|
onErrorCallbackList.push(callback);
|
|
}
|
|
triggerSubscriptions(actionSubscriptions, {
|
|
args,
|
|
name: wrappedAction[ACTION_NAME],
|
|
store,
|
|
after,
|
|
onError
|
|
});
|
|
let ret;
|
|
try {
|
|
ret = fn.apply(this && this.$id === $id ? this : store, args);
|
|
} catch (error2) {
|
|
triggerSubscriptions(onErrorCallbackList, error2);
|
|
throw error2;
|
|
}
|
|
if (ret instanceof Promise) {
|
|
return ret.then((value) => {
|
|
triggerSubscriptions(afterCallbackList, value);
|
|
return value;
|
|
}).catch((error2) => {
|
|
triggerSubscriptions(onErrorCallbackList, error2);
|
|
return Promise.reject(error2);
|
|
});
|
|
}
|
|
triggerSubscriptions(afterCallbackList, ret);
|
|
return ret;
|
|
};
|
|
wrappedAction[ACTION_MARKER] = true;
|
|
wrappedAction[ACTION_NAME] = name;
|
|
return wrappedAction;
|
|
};
|
|
const partialStore = {
|
|
_p: pinia,
|
|
// _s: scope,
|
|
$id,
|
|
$onAction: addSubscription.bind(null, actionSubscriptions),
|
|
$patch,
|
|
$reset,
|
|
$subscribe(callback, options2 = {}) {
|
|
const removeSubscription = addSubscription(subscriptions, callback, options2.detached, () => stopWatcher());
|
|
const stopWatcher = scope.run(() => watch(() => pinia.state.value[$id], (state) => {
|
|
if (options2.flush === "sync" ? isSyncListening : isListening) {
|
|
callback({
|
|
storeId: $id,
|
|
type: MutationType.direct,
|
|
events: debuggerEvents
|
|
}, state);
|
|
}
|
|
}, assign$1({}, $subscribeOptions, options2)));
|
|
return removeSubscription;
|
|
},
|
|
$dispose
|
|
};
|
|
const store = reactive(partialStore);
|
|
pinia._s.set($id, store);
|
|
const runWithContext = pinia._a && pinia._a.runWithContext || fallbackRunWithContext;
|
|
const setupStore = runWithContext(() => pinia._e.run(() => (scope = effectScope()).run(() => setup({ action }))));
|
|
for (const key in setupStore) {
|
|
const prop = setupStore[key];
|
|
if (isRef(prop) && !isComputed(prop) || isReactive(prop)) {
|
|
if (!isOptionsStore) {
|
|
if (initialState && shouldHydrate(prop)) {
|
|
if (isRef(prop)) {
|
|
prop.value = initialState[key];
|
|
} else {
|
|
mergeReactiveObjects(prop, initialState[key]);
|
|
}
|
|
}
|
|
{
|
|
pinia.state.value[$id][key] = prop;
|
|
}
|
|
}
|
|
} else if (typeof prop === "function") {
|
|
const actionValue = action(prop, key);
|
|
{
|
|
setupStore[key] = actionValue;
|
|
}
|
|
optionsForPlugin.actions[key] = prop;
|
|
} else ;
|
|
}
|
|
{
|
|
assign$1(store, setupStore);
|
|
assign$1(toRaw(store), setupStore);
|
|
}
|
|
Object.defineProperty(store, "$state", {
|
|
get: () => pinia.state.value[$id],
|
|
set: (state) => {
|
|
$patch(($state) => {
|
|
assign$1($state, state);
|
|
});
|
|
}
|
|
});
|
|
pinia._p.forEach((extender) => {
|
|
{
|
|
assign$1(store, scope.run(() => extender({
|
|
store,
|
|
app: pinia._a,
|
|
pinia,
|
|
options: optionsForPlugin
|
|
})));
|
|
}
|
|
});
|
|
if (initialState && isOptionsStore && options.hydrate) {
|
|
options.hydrate(store.$state, initialState);
|
|
}
|
|
isListening = true;
|
|
isSyncListening = true;
|
|
return store;
|
|
}
|
|
/*! #__NO_SIDE_EFFECTS__ */
|
|
// @__NO_SIDE_EFFECTS__
|
|
function defineStore(idOrOptions, setup, setupOptions) {
|
|
let id;
|
|
let options;
|
|
const isSetupStore = typeof setup === "function";
|
|
if (typeof idOrOptions === "string") {
|
|
id = idOrOptions;
|
|
options = isSetupStore ? setupOptions : setup;
|
|
} else {
|
|
options = idOrOptions;
|
|
id = idOrOptions.id;
|
|
}
|
|
function useStore(pinia, hot) {
|
|
const hasContext = hasInjectionContext();
|
|
pinia = // in test mode, ignore the argument provided as we can always retrieve a
|
|
// pinia instance with getActivePinia()
|
|
pinia || (hasContext ? inject(piniaSymbol, null) : null);
|
|
if (pinia)
|
|
setActivePinia(pinia);
|
|
pinia = activePinia;
|
|
if (!pinia._s.has(id)) {
|
|
if (isSetupStore) {
|
|
createSetupStore(id, setup, options, pinia);
|
|
} else {
|
|
createOptionsStore(id, options, pinia);
|
|
}
|
|
}
|
|
const store = pinia._s.get(id);
|
|
return store;
|
|
}
|
|
useStore.$id = id;
|
|
return useStore;
|
|
}
|
|
function storeToRefs(store) {
|
|
{
|
|
const rawStore = toRaw(store);
|
|
const refs = {};
|
|
for (const key in rawStore) {
|
|
const value = rawStore[key];
|
|
if (value.effect) {
|
|
refs[key] = // ...
|
|
computed({
|
|
get: () => store[key],
|
|
set(value2) {
|
|
store[key] = value2;
|
|
}
|
|
});
|
|
} else if (isRef(value) || isReactive(value)) {
|
|
refs[key] = // ---
|
|
toRef(store, key);
|
|
}
|
|
}
|
|
return refs;
|
|
}
|
|
}
|
|
const scriptRel = "modulepreload";
|
|
const assetsURL = function(dep) {
|
|
return "/" + dep;
|
|
};
|
|
const seen = {};
|
|
const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
let promise = Promise.resolve();
|
|
if (deps && deps.length > 0) {
|
|
let allSettled2 = function(promises) {
|
|
return Promise.all(
|
|
promises.map(
|
|
(p2) => Promise.resolve(p2).then(
|
|
(value) => ({ status: "fulfilled", value }),
|
|
(reason) => ({ status: "rejected", reason })
|
|
)
|
|
)
|
|
);
|
|
};
|
|
document.getElementsByTagName("link");
|
|
const cspNonceMeta = document.querySelector(
|
|
"meta[property=csp-nonce]"
|
|
);
|
|
const cspNonce = (cspNonceMeta == null ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta == null ? void 0 : cspNonceMeta.getAttribute("nonce"));
|
|
promise = allSettled2(
|
|
deps.map((dep) => {
|
|
dep = assetsURL(dep);
|
|
if (dep in seen) return;
|
|
seen[dep] = true;
|
|
const isCss = dep.endsWith(".css");
|
|
const cssSelector = isCss ? '[rel="stylesheet"]' : "";
|
|
if (document.querySelector(`link[href="${dep}"]${cssSelector}`)) {
|
|
return;
|
|
}
|
|
const link = document.createElement("link");
|
|
link.rel = isCss ? "stylesheet" : scriptRel;
|
|
if (!isCss) {
|
|
link.as = "script";
|
|
}
|
|
link.crossOrigin = "";
|
|
link.href = dep;
|
|
if (cspNonce) {
|
|
link.setAttribute("nonce", cspNonce);
|
|
}
|
|
document.head.appendChild(link);
|
|
if (isCss) {
|
|
return new Promise((res, rej) => {
|
|
link.addEventListener("load", res);
|
|
link.addEventListener(
|
|
"error",
|
|
() => rej(new Error(`Unable to preload CSS for ${dep}`))
|
|
);
|
|
});
|
|
}
|
|
})
|
|
);
|
|
}
|
|
function handlePreloadError(err) {
|
|
const e = new Event("vite:preloadError", {
|
|
cancelable: true
|
|
});
|
|
e.payload = err;
|
|
window.dispatchEvent(e);
|
|
if (!e.defaultPrevented) {
|
|
throw err;
|
|
}
|
|
}
|
|
return promise.then((res) => {
|
|
for (const item of res || []) {
|
|
if (item.status !== "rejected") continue;
|
|
handlePreloadError(item.reason);
|
|
}
|
|
return baseModule().catch(handlePreloadError);
|
|
});
|
|
};
|
|
function plugin$3(options) {
|
|
let _bPrefix = ".";
|
|
let _ePrefix = "__";
|
|
let _mPrefix = "--";
|
|
let c2;
|
|
if (options) {
|
|
let t = options.blockPrefix;
|
|
if (t) {
|
|
_bPrefix = t;
|
|
}
|
|
t = options.elementPrefix;
|
|
if (t) {
|
|
_ePrefix = t;
|
|
}
|
|
t = options.modifierPrefix;
|
|
if (t) {
|
|
_mPrefix = t;
|
|
}
|
|
}
|
|
const _plugin = {
|
|
install(instance) {
|
|
c2 = instance.c;
|
|
const ctx2 = instance.context;
|
|
ctx2.bem = {};
|
|
ctx2.bem.b = null;
|
|
ctx2.bem.els = null;
|
|
}
|
|
};
|
|
function b(arg) {
|
|
let memorizedB;
|
|
let memorizedE;
|
|
return {
|
|
before(ctx2) {
|
|
memorizedB = ctx2.bem.b;
|
|
memorizedE = ctx2.bem.els;
|
|
ctx2.bem.els = null;
|
|
},
|
|
after(ctx2) {
|
|
ctx2.bem.b = memorizedB;
|
|
ctx2.bem.els = memorizedE;
|
|
},
|
|
$({ context, props }) {
|
|
arg = typeof arg === "string" ? arg : arg({ context, props });
|
|
context.bem.b = arg;
|
|
return `${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}`;
|
|
}
|
|
};
|
|
}
|
|
function e(arg) {
|
|
let memorizedE;
|
|
return {
|
|
before(ctx2) {
|
|
memorizedE = ctx2.bem.els;
|
|
},
|
|
after(ctx2) {
|
|
ctx2.bem.els = memorizedE;
|
|
},
|
|
$({ context, props }) {
|
|
arg = typeof arg === "string" ? arg : arg({ context, props });
|
|
context.bem.els = arg.split(",").map((v) => v.trim());
|
|
return context.bem.els.map((el) => `${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${_ePrefix}${el}`).join(", ");
|
|
}
|
|
};
|
|
}
|
|
function m(arg) {
|
|
return {
|
|
$({ context, props }) {
|
|
arg = typeof arg === "string" ? arg : arg({ context, props });
|
|
const modifiers = arg.split(",").map((v) => v.trim());
|
|
function elementToSelector(el) {
|
|
return modifiers.map((modifier) => `&${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${el !== void 0 ? `${_ePrefix}${el}` : ""}${_mPrefix}${modifier}`).join(", ");
|
|
}
|
|
const els = context.bem.els;
|
|
if (els !== null) {
|
|
return elementToSelector(els[0]);
|
|
} else {
|
|
return elementToSelector();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
function notM(arg) {
|
|
return {
|
|
$({ context, props }) {
|
|
arg = typeof arg === "string" ? arg : arg({ context, props });
|
|
const els = context.bem.els;
|
|
return `&:not(${(props === null || props === void 0 ? void 0 : props.bPrefix) || _bPrefix}${context.bem.b}${els !== null && els.length > 0 ? `${_ePrefix}${els[0]}` : ""}${_mPrefix}${arg})`;
|
|
}
|
|
};
|
|
}
|
|
const cB2 = (...args) => c2(b(args[0]), args[1], args[2]);
|
|
const cE2 = (...args) => c2(e(args[0]), args[1], args[2]);
|
|
const cM2 = (...args) => c2(m(args[0]), args[1], args[2]);
|
|
const cNotM2 = (...args) => c2(notM(args[0]), args[1], args[2]);
|
|
Object.assign(_plugin, {
|
|
cB: cB2,
|
|
cE: cE2,
|
|
cM: cM2,
|
|
cNotM: cNotM2
|
|
});
|
|
return _plugin;
|
|
}
|
|
function ampCount(selector) {
|
|
let cnt = 0;
|
|
for (let i = 0; i < selector.length; ++i) {
|
|
if (selector[i] === "&")
|
|
++cnt;
|
|
}
|
|
return cnt;
|
|
}
|
|
const separatorRegex = /\s*,(?![^(]*\))\s*/g;
|
|
const extraSpaceRegex = /\s+/g;
|
|
function resolveSelectorWithAmp(amp, selector) {
|
|
const nextAmp = [];
|
|
selector.split(separatorRegex).forEach((partialSelector) => {
|
|
let round = ampCount(partialSelector);
|
|
if (!round) {
|
|
amp.forEach((partialAmp) => {
|
|
nextAmp.push(
|
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
(partialAmp && partialAmp + " ") + partialSelector
|
|
);
|
|
});
|
|
return;
|
|
} else if (round === 1) {
|
|
amp.forEach((partialAmp) => {
|
|
nextAmp.push(partialSelector.replace("&", partialAmp));
|
|
});
|
|
return;
|
|
}
|
|
let partialNextAmp = [
|
|
partialSelector
|
|
];
|
|
while (round--) {
|
|
const nextPartialNextAmp = [];
|
|
partialNextAmp.forEach((selectorItr) => {
|
|
amp.forEach((partialAmp) => {
|
|
nextPartialNextAmp.push(selectorItr.replace("&", partialAmp));
|
|
});
|
|
});
|
|
partialNextAmp = nextPartialNextAmp;
|
|
}
|
|
partialNextAmp.forEach((part) => nextAmp.push(part));
|
|
});
|
|
return nextAmp;
|
|
}
|
|
function resolveSelector(amp, selector) {
|
|
const nextAmp = [];
|
|
selector.split(separatorRegex).forEach((partialSelector) => {
|
|
amp.forEach((partialAmp) => {
|
|
nextAmp.push((partialAmp && partialAmp + " ") + partialSelector);
|
|
});
|
|
});
|
|
return nextAmp;
|
|
}
|
|
function parseSelectorPath(selectorPaths) {
|
|
let amp = [""];
|
|
selectorPaths.forEach((selector) => {
|
|
selector = selector && selector.trim();
|
|
if (
|
|
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
!selector
|
|
) {
|
|
return;
|
|
}
|
|
if (selector.includes("&")) {
|
|
amp = resolveSelectorWithAmp(amp, selector);
|
|
} else {
|
|
amp = resolveSelector(amp, selector);
|
|
}
|
|
});
|
|
return amp.join(", ").replace(extraSpaceRegex, " ");
|
|
}
|
|
function removeElement(el) {
|
|
if (!el)
|
|
return;
|
|
const parentElement = el.parentElement;
|
|
if (parentElement)
|
|
parentElement.removeChild(el);
|
|
}
|
|
function queryElement(id, parent) {
|
|
return (parent !== null && parent !== void 0 ? parent : document.head).querySelector(`style[cssr-id="${id}"]`);
|
|
}
|
|
function createElement(id) {
|
|
const el = document.createElement("style");
|
|
el.setAttribute("cssr-id", id);
|
|
return el;
|
|
}
|
|
function isMediaOrSupports(selector) {
|
|
if (!selector)
|
|
return false;
|
|
return /^\s*@(s|m)/.test(selector);
|
|
}
|
|
const kebabRegex = /[A-Z]/g;
|
|
function kebabCase(pattern) {
|
|
return pattern.replace(kebabRegex, (match2) => "-" + match2.toLowerCase());
|
|
}
|
|
function unwrapProperty(prop, indent = " ") {
|
|
if (typeof prop === "object" && prop !== null) {
|
|
return " {\n" + Object.entries(prop).map((v) => {
|
|
return indent + ` ${kebabCase(v[0])}: ${v[1]};`;
|
|
}).join("\n") + "\n" + indent + "}";
|
|
}
|
|
return `: ${prop};`;
|
|
}
|
|
function unwrapProperties(props, instance, params) {
|
|
if (typeof props === "function") {
|
|
return props({
|
|
context: instance.context,
|
|
props: params
|
|
});
|
|
}
|
|
return props;
|
|
}
|
|
function createStyle(selector, props, instance, params) {
|
|
if (!props)
|
|
return "";
|
|
const unwrappedProps = unwrapProperties(props, instance, params);
|
|
if (!unwrappedProps)
|
|
return "";
|
|
if (typeof unwrappedProps === "string") {
|
|
return `${selector} {
|
|
${unwrappedProps}
|
|
}`;
|
|
}
|
|
const propertyNames = Object.keys(unwrappedProps);
|
|
if (propertyNames.length === 0) {
|
|
if (instance.config.keepEmptyBlock)
|
|
return selector + " {\n}";
|
|
return "";
|
|
}
|
|
const statements = selector ? [
|
|
selector + " {"
|
|
] : [];
|
|
propertyNames.forEach((propertyName) => {
|
|
const property = unwrappedProps[propertyName];
|
|
if (propertyName === "raw") {
|
|
statements.push("\n" + property + "\n");
|
|
return;
|
|
}
|
|
propertyName = kebabCase(propertyName);
|
|
if (property !== null && property !== void 0) {
|
|
statements.push(` ${propertyName}${unwrapProperty(property)}`);
|
|
}
|
|
});
|
|
if (selector) {
|
|
statements.push("}");
|
|
}
|
|
return statements.join("\n");
|
|
}
|
|
function loopCNodeListWithCallback(children, options, callback) {
|
|
if (!children)
|
|
return;
|
|
children.forEach((child) => {
|
|
if (Array.isArray(child)) {
|
|
loopCNodeListWithCallback(child, options, callback);
|
|
} else if (typeof child === "function") {
|
|
const grandChildren = child(options);
|
|
if (Array.isArray(grandChildren)) {
|
|
loopCNodeListWithCallback(grandChildren, options, callback);
|
|
} else if (grandChildren) {
|
|
callback(grandChildren);
|
|
}
|
|
} else if (child) {
|
|
callback(child);
|
|
}
|
|
});
|
|
}
|
|
function traverseCNode(node, selectorPaths, styles, instance, params) {
|
|
const $ = node.$;
|
|
let blockSelector = "";
|
|
if (!$ || typeof $ === "string") {
|
|
if (isMediaOrSupports($)) {
|
|
blockSelector = $;
|
|
} else {
|
|
selectorPaths.push($);
|
|
}
|
|
} else if (typeof $ === "function") {
|
|
const selector2 = $({
|
|
context: instance.context,
|
|
props: params
|
|
});
|
|
if (isMediaOrSupports(selector2)) {
|
|
blockSelector = selector2;
|
|
} else {
|
|
selectorPaths.push(selector2);
|
|
}
|
|
} else {
|
|
if ($.before)
|
|
$.before(instance.context);
|
|
if (!$.$ || typeof $.$ === "string") {
|
|
if (isMediaOrSupports($.$)) {
|
|
blockSelector = $.$;
|
|
} else {
|
|
selectorPaths.push($.$);
|
|
}
|
|
} else if ($.$) {
|
|
const selector2 = $.$({
|
|
context: instance.context,
|
|
props: params
|
|
});
|
|
if (isMediaOrSupports(selector2)) {
|
|
blockSelector = selector2;
|
|
} else {
|
|
selectorPaths.push(selector2);
|
|
}
|
|
}
|
|
}
|
|
const selector = parseSelectorPath(selectorPaths);
|
|
const style2 = createStyle(selector, node.props, instance, params);
|
|
if (blockSelector) {
|
|
styles.push(`${blockSelector} {`);
|
|
} else if (style2.length) {
|
|
styles.push(style2);
|
|
}
|
|
if (node.children) {
|
|
loopCNodeListWithCallback(node.children, {
|
|
context: instance.context,
|
|
props: params
|
|
}, (childNode) => {
|
|
if (typeof childNode === "string") {
|
|
const style3 = createStyle(selector, { raw: childNode }, instance, params);
|
|
styles.push(style3);
|
|
} else {
|
|
traverseCNode(childNode, selectorPaths, styles, instance, params);
|
|
}
|
|
});
|
|
}
|
|
selectorPaths.pop();
|
|
if (blockSelector) {
|
|
styles.push("}");
|
|
}
|
|
if ($ && $.after)
|
|
$.after(instance.context);
|
|
}
|
|
function render$1(node, instance, props) {
|
|
const styles = [];
|
|
traverseCNode(node, [], styles, instance, props);
|
|
return styles.join("\n\n");
|
|
}
|
|
function murmur2(str) {
|
|
var h2 = 0;
|
|
var k, i = 0, len = str.length;
|
|
for (; len >= 4; ++i, len -= 4) {
|
|
k = str.charCodeAt(i) & 255 | (str.charCodeAt(++i) & 255) << 8 | (str.charCodeAt(++i) & 255) << 16 | (str.charCodeAt(++i) & 255) << 24;
|
|
k = /* Math.imul(k, m): */
|
|
(k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16);
|
|
k ^= /* k >>> r: */
|
|
k >>> 24;
|
|
h2 = /* Math.imul(k, m): */
|
|
(k & 65535) * 1540483477 + ((k >>> 16) * 59797 << 16) ^ /* Math.imul(h, m): */
|
|
(h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
|
|
}
|
|
switch (len) {
|
|
case 3:
|
|
h2 ^= (str.charCodeAt(i + 2) & 255) << 16;
|
|
case 2:
|
|
h2 ^= (str.charCodeAt(i + 1) & 255) << 8;
|
|
case 1:
|
|
h2 ^= str.charCodeAt(i) & 255;
|
|
h2 = /* Math.imul(h, m): */
|
|
(h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
|
|
}
|
|
h2 ^= h2 >>> 13;
|
|
h2 = /* Math.imul(h, m): */
|
|
(h2 & 65535) * 1540483477 + ((h2 >>> 16) * 59797 << 16);
|
|
return ((h2 ^ h2 >>> 15) >>> 0).toString(36);
|
|
}
|
|
if (typeof window !== "undefined") {
|
|
window.__cssrContext = {};
|
|
}
|
|
function unmount(instance, node, id, parent) {
|
|
const { els } = node;
|
|
if (id === void 0) {
|
|
els.forEach(removeElement);
|
|
node.els = [];
|
|
} else {
|
|
const target = queryElement(id, parent);
|
|
if (target && els.includes(target)) {
|
|
removeElement(target);
|
|
node.els = els.filter((el) => el !== target);
|
|
}
|
|
}
|
|
}
|
|
function addElementToList(els, target) {
|
|
els.push(target);
|
|
}
|
|
function mount(instance, node, id, props, head, force, anchorMetaName, parent, ssrAdapter2) {
|
|
let style2;
|
|
if (id === void 0) {
|
|
style2 = node.render(props);
|
|
id = murmur2(style2);
|
|
}
|
|
if (ssrAdapter2) {
|
|
ssrAdapter2.adapter(id, style2 !== null && style2 !== void 0 ? style2 : node.render(props));
|
|
return;
|
|
}
|
|
if (parent === void 0) {
|
|
parent = document.head;
|
|
}
|
|
const queriedTarget = queryElement(id, parent);
|
|
if (queriedTarget !== null && !force) {
|
|
return queriedTarget;
|
|
}
|
|
const target = queriedTarget !== null && queriedTarget !== void 0 ? queriedTarget : createElement(id);
|
|
if (style2 === void 0)
|
|
style2 = node.render(props);
|
|
target.textContent = style2;
|
|
if (queriedTarget !== null)
|
|
return queriedTarget;
|
|
if (anchorMetaName) {
|
|
const anchorMetaEl = parent.querySelector(`meta[name="${anchorMetaName}"]`);
|
|
if (anchorMetaEl) {
|
|
parent.insertBefore(target, anchorMetaEl);
|
|
addElementToList(node.els, target);
|
|
return target;
|
|
}
|
|
}
|
|
if (head) {
|
|
parent.insertBefore(target, parent.querySelector("style, link"));
|
|
} else {
|
|
parent.appendChild(target);
|
|
}
|
|
addElementToList(node.els, target);
|
|
return target;
|
|
}
|
|
function wrappedRender(props) {
|
|
return render$1(this, this.instance, props);
|
|
}
|
|
function wrappedMount(options = {}) {
|
|
const { id, ssr, props, head = false, force = false, anchorMetaName, parent } = options;
|
|
const targetElement = mount(this.instance, this, id, props, head, force, anchorMetaName, parent, ssr);
|
|
return targetElement;
|
|
}
|
|
function wrappedUnmount(options = {}) {
|
|
const { id, parent } = options;
|
|
unmount(this.instance, this, id, parent);
|
|
}
|
|
const createCNode = function(instance, $, props, children) {
|
|
return {
|
|
instance,
|
|
$,
|
|
props,
|
|
children,
|
|
els: [],
|
|
render: wrappedRender,
|
|
mount: wrappedMount,
|
|
unmount: wrappedUnmount
|
|
};
|
|
};
|
|
const c$1 = function(instance, $, props, children) {
|
|
if (Array.isArray($)) {
|
|
return createCNode(instance, { $: null }, null, $);
|
|
} else if (Array.isArray(props)) {
|
|
return createCNode(instance, $, null, props);
|
|
} else if (Array.isArray(children)) {
|
|
return createCNode(instance, $, props, children);
|
|
} else {
|
|
return createCNode(instance, $, props, null);
|
|
}
|
|
};
|
|
function CssRender(config = {}) {
|
|
const cssr2 = {
|
|
c: (...args) => c$1(cssr2, ...args),
|
|
use: (plugin2, ...args) => plugin2.install(cssr2, ...args),
|
|
find: queryElement,
|
|
context: {},
|
|
config
|
|
};
|
|
return cssr2;
|
|
}
|
|
function exists(id, ssr) {
|
|
if (id === void 0)
|
|
return false;
|
|
if (ssr) {
|
|
const { context: { ids } } = ssr;
|
|
return ids.has(id);
|
|
}
|
|
return queryElement(id) !== null;
|
|
}
|
|
const namespace = "n";
|
|
const prefix$1 = `.${namespace}-`;
|
|
const elementPrefix = "__";
|
|
const modifierPrefix = "--";
|
|
const cssr = CssRender();
|
|
const plugin$2 = plugin$3({
|
|
blockPrefix: prefix$1,
|
|
elementPrefix,
|
|
modifierPrefix
|
|
});
|
|
cssr.use(plugin$2);
|
|
const {
|
|
c,
|
|
find
|
|
} = cssr;
|
|
const {
|
|
cB,
|
|
cE,
|
|
cM,
|
|
cNotM
|
|
} = plugin$2;
|
|
function insideModal(style2) {
|
|
return c(({
|
|
props: {
|
|
bPrefix
|
|
}
|
|
}) => `${bPrefix || prefix$1}modal, ${bPrefix || prefix$1}drawer`, [style2]);
|
|
}
|
|
function insidePopover(style2) {
|
|
return c(({
|
|
props: {
|
|
bPrefix
|
|
}
|
|
}) => `${bPrefix || prefix$1}popover`, [style2]);
|
|
}
|
|
function asModal(style2) {
|
|
return c(({
|
|
props: {
|
|
bPrefix
|
|
}
|
|
}) => `&${bPrefix || prefix$1}modal`, style2);
|
|
}
|
|
const cCB = (...args) => {
|
|
return c(">", [cB(...args)]);
|
|
};
|
|
function createKey(prefix2, suffix2) {
|
|
return prefix2 + (suffix2 === "default" ? "" : suffix2.replace(/^[a-z]/, (startChar) => startChar.toUpperCase()));
|
|
}
|
|
function getPreciseEventTarget(event) {
|
|
return event.composedPath()[0] || null;
|
|
}
|
|
function depx(value) {
|
|
if (typeof value === "string") {
|
|
if (value.endsWith("px")) {
|
|
return Number(value.slice(0, value.length - 2));
|
|
}
|
|
return Number(value);
|
|
}
|
|
return value;
|
|
}
|
|
function pxfy(value) {
|
|
if (value === void 0 || value === null)
|
|
return void 0;
|
|
if (typeof value === "number")
|
|
return `${value}px`;
|
|
if (value.endsWith("px"))
|
|
return value;
|
|
return `${value}px`;
|
|
}
|
|
function getMargin(value, position) {
|
|
const parts = value.trim().split(/\s+/g);
|
|
const margin = {
|
|
top: parts[0]
|
|
};
|
|
switch (parts.length) {
|
|
case 1:
|
|
margin.right = parts[0];
|
|
margin.bottom = parts[0];
|
|
margin.left = parts[0];
|
|
break;
|
|
case 2:
|
|
margin.right = parts[1];
|
|
margin.left = parts[1];
|
|
margin.bottom = parts[0];
|
|
break;
|
|
case 3:
|
|
margin.right = parts[1];
|
|
margin.bottom = parts[2];
|
|
margin.left = parts[1];
|
|
break;
|
|
case 4:
|
|
margin.right = parts[1];
|
|
margin.bottom = parts[2];
|
|
margin.left = parts[3];
|
|
break;
|
|
default:
|
|
throw new Error("[seemly/getMargin]:" + value + " is not a valid value.");
|
|
}
|
|
if (position === void 0)
|
|
return margin;
|
|
return margin[position];
|
|
}
|
|
function getGap(value, orient) {
|
|
const [rowGap, colGap] = value.split(" ");
|
|
return {
|
|
row: rowGap,
|
|
col: colGap || rowGap
|
|
};
|
|
}
|
|
const colors = {
|
|
black: "#000",
|
|
silver: "#C0C0C0",
|
|
gray: "#808080",
|
|
white: "#FFF",
|
|
maroon: "#800000",
|
|
red: "#F00",
|
|
purple: "#800080",
|
|
fuchsia: "#F0F",
|
|
green: "#008000",
|
|
lime: "#0F0",
|
|
olive: "#808000",
|
|
yellow: "#FF0",
|
|
navy: "#000080",
|
|
blue: "#00F",
|
|
teal: "#008080",
|
|
aqua: "#0FF",
|
|
transparent: "#0000"
|
|
};
|
|
const prefix = "^\\s*";
|
|
const suffix = "\\s*$";
|
|
const float = "\\s*((\\.\\d+)|(\\d+(\\.\\d*)?))\\s*";
|
|
const hex = "([0-9A-Fa-f])";
|
|
const dhex = "([0-9A-Fa-f]{2})";
|
|
const rgbRegex = new RegExp(`${prefix}rgb\\s*\\(${float},${float},${float}\\)${suffix}`);
|
|
const rgbaRegex = new RegExp(`${prefix}rgba\\s*\\(${float},${float},${float},${float}\\)${suffix}`);
|
|
const sHexRegex = new RegExp(`${prefix}#${hex}${hex}${hex}${suffix}`);
|
|
const hexRegex = new RegExp(`${prefix}#${dhex}${dhex}${dhex}${suffix}`);
|
|
const sHexaRegex = new RegExp(`${prefix}#${hex}${hex}${hex}${hex}${suffix}`);
|
|
const hexaRegex = new RegExp(`${prefix}#${dhex}${dhex}${dhex}${dhex}${suffix}`);
|
|
function parseHex(value) {
|
|
return parseInt(value, 16);
|
|
}
|
|
function rgba(color) {
|
|
try {
|
|
let i;
|
|
if (i = hexRegex.exec(color)) {
|
|
return [parseHex(i[1]), parseHex(i[2]), parseHex(i[3]), 1];
|
|
} else if (i = rgbRegex.exec(color)) {
|
|
return [roundChannel(i[1]), roundChannel(i[5]), roundChannel(i[9]), 1];
|
|
} else if (i = rgbaRegex.exec(color)) {
|
|
return [
|
|
roundChannel(i[1]),
|
|
roundChannel(i[5]),
|
|
roundChannel(i[9]),
|
|
roundAlpha(i[13])
|
|
];
|
|
} else if (i = sHexRegex.exec(color)) {
|
|
return [
|
|
parseHex(i[1] + i[1]),
|
|
parseHex(i[2] + i[2]),
|
|
parseHex(i[3] + i[3]),
|
|
1
|
|
];
|
|
} else if (i = hexaRegex.exec(color)) {
|
|
return [
|
|
parseHex(i[1]),
|
|
parseHex(i[2]),
|
|
parseHex(i[3]),
|
|
roundAlpha(parseHex(i[4]) / 255)
|
|
];
|
|
} else if (i = sHexaRegex.exec(color)) {
|
|
return [
|
|
parseHex(i[1] + i[1]),
|
|
parseHex(i[2] + i[2]),
|
|
parseHex(i[3] + i[3]),
|
|
roundAlpha(parseHex(i[4] + i[4]) / 255)
|
|
];
|
|
} else if (color in colors) {
|
|
return rgba(colors[color]);
|
|
}
|
|
throw new Error(`[seemly/rgba]: Invalid color value ${color}.`);
|
|
} catch (e) {
|
|
throw e;
|
|
}
|
|
}
|
|
function normalizeAlpha(alphaValue) {
|
|
return alphaValue > 1 ? 1 : alphaValue < 0 ? 0 : alphaValue;
|
|
}
|
|
function stringifyRgba(r, g, b, a) {
|
|
return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, ${normalizeAlpha(a)})`;
|
|
}
|
|
function compositeChannel(v1, a1, v2, a2, a) {
|
|
return roundChannel((v1 * a1 * (1 - a2) + v2 * a2) / a);
|
|
}
|
|
function composite(background, overlay2) {
|
|
if (!Array.isArray(background))
|
|
background = rgba(background);
|
|
if (!Array.isArray(overlay2))
|
|
overlay2 = rgba(overlay2);
|
|
const a1 = background[3];
|
|
const a2 = overlay2[3];
|
|
const alpha = roundAlpha(a1 + a2 - a1 * a2);
|
|
return stringifyRgba(compositeChannel(background[0], a1, overlay2[0], a2, alpha), compositeChannel(background[1], a1, overlay2[1], a2, alpha), compositeChannel(background[2], a1, overlay2[2], a2, alpha), alpha);
|
|
}
|
|
function changeColor(base2, options) {
|
|
const [r, g, b, a = 1] = Array.isArray(base2) ? base2 : rgba(base2);
|
|
if (options.alpha) {
|
|
return stringifyRgba(r, g, b, options.alpha);
|
|
}
|
|
return stringifyRgba(r, g, b, a);
|
|
}
|
|
function scaleColor(base2, options) {
|
|
const [r, g, b, a = 1] = Array.isArray(base2) ? base2 : rgba(base2);
|
|
const { lightness = 1, alpha = 1 } = options;
|
|
return toRgbaString([r * lightness, g * lightness, b * lightness, a * alpha]);
|
|
}
|
|
function roundAlpha(value) {
|
|
const v = Math.round(Number(value) * 100) / 100;
|
|
if (v > 1)
|
|
return 1;
|
|
if (v < 0)
|
|
return 0;
|
|
return v;
|
|
}
|
|
function roundChannel(value) {
|
|
const v = Math.round(Number(value));
|
|
if (v > 255)
|
|
return 255;
|
|
if (v < 0)
|
|
return 0;
|
|
return v;
|
|
}
|
|
function toRgbaString(base2) {
|
|
const [r, g, b] = base2;
|
|
if (3 in base2) {
|
|
return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, ${roundAlpha(base2[3])})`;
|
|
}
|
|
return `rgba(${roundChannel(r)}, ${roundChannel(g)}, ${roundChannel(b)}, 1)`;
|
|
}
|
|
function createId(length = 8) {
|
|
return Math.random().toString(16).slice(2, 2 + length);
|
|
}
|
|
function repeat(count, v) {
|
|
const ret = [];
|
|
for (let i = 0; i < count; ++i) {
|
|
ret.push(v);
|
|
}
|
|
return ret;
|
|
}
|
|
function getEventTarget(e) {
|
|
const path = e.composedPath();
|
|
return path[0];
|
|
}
|
|
const traps = {
|
|
mousemoveoutside: /* @__PURE__ */ new WeakMap(),
|
|
clickoutside: /* @__PURE__ */ new WeakMap()
|
|
};
|
|
function createTrapHandler(name, el, originalHandler) {
|
|
if (name === "mousemoveoutside") {
|
|
const moveHandler = (e) => {
|
|
if (el.contains(getEventTarget(e)))
|
|
return;
|
|
originalHandler(e);
|
|
};
|
|
return {
|
|
mousemove: moveHandler,
|
|
touchstart: moveHandler
|
|
};
|
|
} else if (name === "clickoutside") {
|
|
let mouseDownOutside = false;
|
|
const downHandler = (e) => {
|
|
mouseDownOutside = !el.contains(getEventTarget(e));
|
|
};
|
|
const upHanlder = (e) => {
|
|
if (!mouseDownOutside)
|
|
return;
|
|
if (el.contains(getEventTarget(e)))
|
|
return;
|
|
originalHandler(e);
|
|
};
|
|
return {
|
|
mousedown: downHandler,
|
|
mouseup: upHanlder,
|
|
touchstart: downHandler,
|
|
touchend: upHanlder
|
|
};
|
|
}
|
|
console.error(
|
|
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
|
`[evtd/create-trap-handler]: name \`${name}\` is invalid. This could be a bug of evtd.`
|
|
);
|
|
return {};
|
|
}
|
|
function ensureTrapHandlers(name, el, handler) {
|
|
const handlers = traps[name];
|
|
let elHandlers = handlers.get(el);
|
|
if (elHandlers === void 0) {
|
|
handlers.set(el, elHandlers = /* @__PURE__ */ new WeakMap());
|
|
}
|
|
let trapHandler = elHandlers.get(handler);
|
|
if (trapHandler === void 0) {
|
|
elHandlers.set(handler, trapHandler = createTrapHandler(name, el, handler));
|
|
}
|
|
return trapHandler;
|
|
}
|
|
function trapOn(name, el, handler, options) {
|
|
if (name === "mousemoveoutside" || name === "clickoutside") {
|
|
const trapHandlers = ensureTrapHandlers(name, el, handler);
|
|
Object.keys(trapHandlers).forEach((key) => {
|
|
on(key, document, trapHandlers[key], options);
|
|
});
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function trapOff(name, el, handler, options) {
|
|
if (name === "mousemoveoutside" || name === "clickoutside") {
|
|
const trapHandlers = ensureTrapHandlers(name, el, handler);
|
|
Object.keys(trapHandlers).forEach((key) => {
|
|
off(key, document, trapHandlers[key], options);
|
|
});
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function createDelegate() {
|
|
if (typeof window === "undefined") {
|
|
return {
|
|
on: () => {
|
|
},
|
|
off: () => {
|
|
}
|
|
};
|
|
}
|
|
const propagationStopped = /* @__PURE__ */ new WeakMap();
|
|
const immediatePropagationStopped = /* @__PURE__ */ new WeakMap();
|
|
function trackPropagation() {
|
|
propagationStopped.set(this, true);
|
|
}
|
|
function trackImmediate() {
|
|
propagationStopped.set(this, true);
|
|
immediatePropagationStopped.set(this, true);
|
|
}
|
|
function spy(event, propName, fn) {
|
|
const source = event[propName];
|
|
event[propName] = function() {
|
|
fn.apply(event, arguments);
|
|
return source.apply(event, arguments);
|
|
};
|
|
return event;
|
|
}
|
|
function unspy(event, propName) {
|
|
event[propName] = Event.prototype[propName];
|
|
}
|
|
const currentTargets = /* @__PURE__ */ new WeakMap();
|
|
const currentTargetDescriptor = Object.getOwnPropertyDescriptor(Event.prototype, "currentTarget");
|
|
function getCurrentTarget() {
|
|
var _a;
|
|
return (_a = currentTargets.get(this)) !== null && _a !== void 0 ? _a : null;
|
|
}
|
|
function defineCurrentTarget(event, getter) {
|
|
if (currentTargetDescriptor === void 0)
|
|
return;
|
|
Object.defineProperty(event, "currentTarget", {
|
|
configurable: true,
|
|
enumerable: true,
|
|
get: getter !== null && getter !== void 0 ? getter : currentTargetDescriptor.get
|
|
});
|
|
}
|
|
const phaseToTypeToElToHandlers = {
|
|
bubble: {},
|
|
capture: {}
|
|
};
|
|
const typeToWindowEventHandlers = {};
|
|
function createUnifiedHandler() {
|
|
const delegeteHandler = function(e) {
|
|
const { type, eventPhase, bubbles } = e;
|
|
const target = getEventTarget(e);
|
|
if (eventPhase === 2)
|
|
return;
|
|
const phase = eventPhase === 1 ? "capture" : "bubble";
|
|
let cursor = target;
|
|
const path = [];
|
|
while (true) {
|
|
if (cursor === null)
|
|
cursor = window;
|
|
path.push(cursor);
|
|
if (cursor === window) {
|
|
break;
|
|
}
|
|
cursor = cursor.parentNode || null;
|
|
}
|
|
const captureElToHandlers = phaseToTypeToElToHandlers.capture[type];
|
|
const bubbleElToHandlers = phaseToTypeToElToHandlers.bubble[type];
|
|
spy(e, "stopPropagation", trackPropagation);
|
|
spy(e, "stopImmediatePropagation", trackImmediate);
|
|
defineCurrentTarget(e, getCurrentTarget);
|
|
if (phase === "capture") {
|
|
if (captureElToHandlers === void 0)
|
|
return;
|
|
for (let i = path.length - 1; i >= 0; --i) {
|
|
if (propagationStopped.has(e))
|
|
break;
|
|
const target2 = path[i];
|
|
const handlers = captureElToHandlers.get(target2);
|
|
if (handlers !== void 0) {
|
|
currentTargets.set(e, target2);
|
|
for (const handler of handlers) {
|
|
if (immediatePropagationStopped.has(e))
|
|
break;
|
|
handler(e);
|
|
}
|
|
}
|
|
if (i === 0 && !bubbles && bubbleElToHandlers !== void 0) {
|
|
const bubbleHandlers = bubbleElToHandlers.get(target2);
|
|
if (bubbleHandlers !== void 0) {
|
|
for (const handler of bubbleHandlers) {
|
|
if (immediatePropagationStopped.has(e))
|
|
break;
|
|
handler(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (phase === "bubble") {
|
|
if (bubbleElToHandlers === void 0)
|
|
return;
|
|
for (let i = 0; i < path.length; ++i) {
|
|
if (propagationStopped.has(e))
|
|
break;
|
|
const target2 = path[i];
|
|
const handlers = bubbleElToHandlers.get(target2);
|
|
if (handlers !== void 0) {
|
|
currentTargets.set(e, target2);
|
|
for (const handler of handlers) {
|
|
if (immediatePropagationStopped.has(e))
|
|
break;
|
|
handler(e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
unspy(e, "stopPropagation");
|
|
unspy(e, "stopImmediatePropagation");
|
|
defineCurrentTarget(e);
|
|
};
|
|
delegeteHandler.displayName = "evtdUnifiedHandler";
|
|
return delegeteHandler;
|
|
}
|
|
function createUnifiedWindowEventHandler() {
|
|
const delegateHandler = function(e) {
|
|
const { type, eventPhase } = e;
|
|
if (eventPhase !== 2)
|
|
return;
|
|
const handlers = typeToWindowEventHandlers[type];
|
|
if (handlers === void 0)
|
|
return;
|
|
handlers.forEach((handler) => handler(e));
|
|
};
|
|
delegateHandler.displayName = "evtdUnifiedWindowEventHandler";
|
|
return delegateHandler;
|
|
}
|
|
const unifiedHandler = createUnifiedHandler();
|
|
const unfiendWindowEventHandler = createUnifiedWindowEventHandler();
|
|
function ensureElToHandlers(phase, type) {
|
|
const phaseHandlers = phaseToTypeToElToHandlers[phase];
|
|
if (phaseHandlers[type] === void 0) {
|
|
phaseHandlers[type] = /* @__PURE__ */ new Map();
|
|
window.addEventListener(type, unifiedHandler, phase === "capture");
|
|
}
|
|
return phaseHandlers[type];
|
|
}
|
|
function ensureWindowEventHandlers(type) {
|
|
const windowEventHandlers = typeToWindowEventHandlers[type];
|
|
if (windowEventHandlers === void 0) {
|
|
typeToWindowEventHandlers[type] = /* @__PURE__ */ new Set();
|
|
window.addEventListener(type, unfiendWindowEventHandler);
|
|
}
|
|
return typeToWindowEventHandlers[type];
|
|
}
|
|
function ensureHandlers(elToHandlers, el) {
|
|
let elHandlers = elToHandlers.get(el);
|
|
if (elHandlers === void 0) {
|
|
elToHandlers.set(el, elHandlers = /* @__PURE__ */ new Set());
|
|
}
|
|
return elHandlers;
|
|
}
|
|
function handlerExist(el, phase, type, handler) {
|
|
const elToHandlers = phaseToTypeToElToHandlers[phase][type];
|
|
if (elToHandlers !== void 0) {
|
|
const handlers = elToHandlers.get(el);
|
|
if (handlers !== void 0) {
|
|
if (handlers.has(handler))
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function windowEventHandlerExist(type, handler) {
|
|
const handlers = typeToWindowEventHandlers[type];
|
|
if (handlers !== void 0) {
|
|
if (handlers.has(handler)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function on2(type, el, handler, options) {
|
|
let mergedHandler;
|
|
if (typeof options === "object" && options.once === true) {
|
|
mergedHandler = (e) => {
|
|
off2(type, el, mergedHandler, options);
|
|
handler(e);
|
|
};
|
|
} else {
|
|
mergedHandler = handler;
|
|
}
|
|
const trapped = trapOn(type, el, mergedHandler, options);
|
|
if (trapped)
|
|
return;
|
|
const phase = options === true || typeof options === "object" && options.capture === true ? "capture" : "bubble";
|
|
const elToHandlers = ensureElToHandlers(phase, type);
|
|
const handlers = ensureHandlers(elToHandlers, el);
|
|
if (!handlers.has(mergedHandler))
|
|
handlers.add(mergedHandler);
|
|
if (el === window) {
|
|
const windowEventHandlers = ensureWindowEventHandlers(type);
|
|
if (!windowEventHandlers.has(mergedHandler)) {
|
|
windowEventHandlers.add(mergedHandler);
|
|
}
|
|
}
|
|
}
|
|
function off2(type, el, handler, options) {
|
|
const trapped = trapOff(type, el, handler, options);
|
|
if (trapped)
|
|
return;
|
|
const capture = options === true || typeof options === "object" && options.capture === true;
|
|
const phase = capture ? "capture" : "bubble";
|
|
const elToHandlers = ensureElToHandlers(phase, type);
|
|
const handlers = ensureHandlers(elToHandlers, el);
|
|
if (el === window) {
|
|
const mirrorPhase = capture ? "bubble" : "capture";
|
|
if (!handlerExist(el, mirrorPhase, type, handler) && windowEventHandlerExist(type, handler)) {
|
|
const windowEventHandlers = typeToWindowEventHandlers[type];
|
|
windowEventHandlers.delete(handler);
|
|
if (windowEventHandlers.size === 0) {
|
|
window.removeEventListener(type, unfiendWindowEventHandler);
|
|
typeToWindowEventHandlers[type] = void 0;
|
|
}
|
|
}
|
|
}
|
|
if (handlers.has(handler))
|
|
handlers.delete(handler);
|
|
if (handlers.size === 0) {
|
|
elToHandlers.delete(el);
|
|
}
|
|
if (elToHandlers.size === 0) {
|
|
window.removeEventListener(type, unifiedHandler, phase === "capture");
|
|
phaseToTypeToElToHandlers[phase][type] = void 0;
|
|
}
|
|
}
|
|
return {
|
|
on: on2,
|
|
off: off2
|
|
};
|
|
}
|
|
const { on, off } = createDelegate();
|
|
function useFalseUntilTruthy(originalRef) {
|
|
const currentRef = ref(!!originalRef.value);
|
|
if (currentRef.value)
|
|
return readonly(currentRef);
|
|
const stop2 = watch(originalRef, (value) => {
|
|
if (value) {
|
|
currentRef.value = true;
|
|
stop2();
|
|
}
|
|
});
|
|
return readonly(currentRef);
|
|
}
|
|
function useMemo(getterOrOptions) {
|
|
const computedValueRef = computed(getterOrOptions);
|
|
const valueRef = ref(computedValueRef.value);
|
|
watch(computedValueRef, (value) => {
|
|
valueRef.value = value;
|
|
});
|
|
if (typeof getterOrOptions === "function") {
|
|
return valueRef;
|
|
} else {
|
|
return {
|
|
__v_isRef: true,
|
|
get value() {
|
|
return valueRef.value;
|
|
},
|
|
set value(v) {
|
|
getterOrOptions.set(v);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
function hasInstance() {
|
|
return getCurrentInstance() !== null;
|
|
}
|
|
const isBrowser$3 = typeof window !== "undefined";
|
|
let fontsReady;
|
|
let isFontReady;
|
|
const init = () => {
|
|
var _a, _b;
|
|
fontsReady = isBrowser$3 ? (_b = (_a = document) === null || _a === void 0 ? void 0 : _a.fonts) === null || _b === void 0 ? void 0 : _b.ready : void 0;
|
|
isFontReady = false;
|
|
if (fontsReady !== void 0) {
|
|
void fontsReady.then(() => {
|
|
isFontReady = true;
|
|
});
|
|
} else {
|
|
isFontReady = true;
|
|
}
|
|
};
|
|
init();
|
|
function onFontsReady(cb) {
|
|
if (isFontReady)
|
|
return;
|
|
let deactivated = false;
|
|
onMounted(() => {
|
|
if (!isFontReady) {
|
|
fontsReady === null || fontsReady === void 0 ? void 0 : fontsReady.then(() => {
|
|
if (deactivated)
|
|
return;
|
|
cb();
|
|
});
|
|
}
|
|
});
|
|
onBeforeUnmount(() => {
|
|
deactivated = true;
|
|
});
|
|
}
|
|
const mousePositionRef = ref(null);
|
|
function clickHandler(e) {
|
|
if (e.clientX > 0 || e.clientY > 0) {
|
|
mousePositionRef.value = {
|
|
x: e.clientX,
|
|
y: e.clientY
|
|
};
|
|
} else {
|
|
const { target } = e;
|
|
if (target instanceof Element) {
|
|
const { left, top, width, height } = target.getBoundingClientRect();
|
|
if (left > 0 || top > 0) {
|
|
mousePositionRef.value = {
|
|
x: left + width / 2,
|
|
y: top + height / 2
|
|
};
|
|
} else {
|
|
mousePositionRef.value = { x: 0, y: 0 };
|
|
}
|
|
} else {
|
|
mousePositionRef.value = null;
|
|
}
|
|
}
|
|
}
|
|
let usedCount$1 = 0;
|
|
let managable$1 = true;
|
|
function useClickPosition() {
|
|
if (!isBrowser$3)
|
|
return readonly(ref(null));
|
|
if (usedCount$1 === 0)
|
|
on("click", document, clickHandler, true);
|
|
const setup = () => {
|
|
usedCount$1 += 1;
|
|
};
|
|
if (managable$1 && (managable$1 = hasInstance())) {
|
|
onBeforeMount(setup);
|
|
onBeforeUnmount(() => {
|
|
usedCount$1 -= 1;
|
|
if (usedCount$1 === 0)
|
|
off("click", document, clickHandler, true);
|
|
});
|
|
} else {
|
|
setup();
|
|
}
|
|
return readonly(mousePositionRef);
|
|
}
|
|
const clickedTimeRef = ref(void 0);
|
|
let usedCount = 0;
|
|
function handleClick() {
|
|
clickedTimeRef.value = Date.now();
|
|
}
|
|
let managable = true;
|
|
function useClicked(timeout2) {
|
|
if (!isBrowser$3)
|
|
return readonly(ref(false));
|
|
const clickedRef = ref(false);
|
|
let timerId = null;
|
|
function clearTimer() {
|
|
if (timerId !== null)
|
|
window.clearTimeout(timerId);
|
|
}
|
|
function clickedHandler() {
|
|
clearTimer();
|
|
clickedRef.value = true;
|
|
timerId = window.setTimeout(() => {
|
|
clickedRef.value = false;
|
|
}, timeout2);
|
|
}
|
|
if (usedCount === 0) {
|
|
on("click", window, handleClick, true);
|
|
}
|
|
const setup = () => {
|
|
usedCount += 1;
|
|
on("click", window, clickedHandler, true);
|
|
};
|
|
if (managable && (managable = hasInstance())) {
|
|
onBeforeMount(setup);
|
|
onBeforeUnmount(() => {
|
|
usedCount -= 1;
|
|
if (usedCount === 0) {
|
|
off("click", window, handleClick, true);
|
|
}
|
|
off("click", window, clickedHandler, true);
|
|
clearTimer();
|
|
});
|
|
} else {
|
|
setup();
|
|
}
|
|
return readonly(clickedRef);
|
|
}
|
|
function useMergedState(controlledStateRef, uncontrolledStateRef) {
|
|
watch(controlledStateRef, (value) => {
|
|
if (value !== void 0) {
|
|
uncontrolledStateRef.value = value;
|
|
}
|
|
});
|
|
return computed(() => {
|
|
if (controlledStateRef.value === void 0) {
|
|
return uncontrolledStateRef.value;
|
|
}
|
|
return controlledStateRef.value;
|
|
});
|
|
}
|
|
function isMounted() {
|
|
const isMounted2 = ref(false);
|
|
onMounted(() => {
|
|
isMounted2.value = true;
|
|
});
|
|
return readonly(isMounted2);
|
|
}
|
|
const isIos = (typeof window === "undefined" ? false : /iPad|iPhone|iPod/.test(navigator.platform) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1) && // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions
|
|
!window.MSStream;
|
|
function useIsIos() {
|
|
return isIos;
|
|
}
|
|
function createInjectionKey(key) {
|
|
return key;
|
|
}
|
|
const drawerBodyInjectionKey = createInjectionKey("n-drawer-body");
|
|
const modalBodyInjectionKey = createInjectionKey("n-modal-body");
|
|
const modalProviderInjectionKey$1 = createInjectionKey("n-modal-provider");
|
|
const modalInjectionKey = createInjectionKey("n-modal");
|
|
const popoverBodyInjectionKey = createInjectionKey("n-popover-body");
|
|
const isBrowser$2 = typeof document !== "undefined" && typeof window !== "undefined";
|
|
const isComposingRef = ref(false);
|
|
function compositionStartHandler() {
|
|
isComposingRef.value = true;
|
|
}
|
|
function compositionEndHandler() {
|
|
isComposingRef.value = false;
|
|
}
|
|
let mountedCount = 0;
|
|
function useIsComposing() {
|
|
if (isBrowser$2) {
|
|
onBeforeMount(() => {
|
|
if (!mountedCount) {
|
|
window.addEventListener("compositionstart", compositionStartHandler);
|
|
window.addEventListener("compositionend", compositionEndHandler);
|
|
}
|
|
mountedCount++;
|
|
});
|
|
onBeforeUnmount(() => {
|
|
if (mountedCount <= 1) {
|
|
window.removeEventListener("compositionstart", compositionStartHandler);
|
|
window.removeEventListener("compositionend", compositionEndHandler);
|
|
mountedCount = 0;
|
|
} else {
|
|
mountedCount--;
|
|
}
|
|
});
|
|
}
|
|
return isComposingRef;
|
|
}
|
|
let lockCount = 0;
|
|
let originalMarginRight = "";
|
|
let originalOverflow = "";
|
|
let originalOverflowX = "";
|
|
let originalOverflowY = "";
|
|
const lockHtmlScrollRightCompensationRef = ref("0px");
|
|
function useLockHtmlScroll(lockRef) {
|
|
if (typeof document === "undefined") return;
|
|
const el = document.documentElement;
|
|
let watchStopHandle;
|
|
let activated = false;
|
|
const unlock = () => {
|
|
el.style.marginRight = originalMarginRight;
|
|
el.style.overflow = originalOverflow;
|
|
el.style.overflowX = originalOverflowX;
|
|
el.style.overflowY = originalOverflowY;
|
|
lockHtmlScrollRightCompensationRef.value = "0px";
|
|
};
|
|
onMounted(() => {
|
|
watchStopHandle = watch(lockRef, (value) => {
|
|
if (value) {
|
|
if (!lockCount) {
|
|
const scrollbarWidth = window.innerWidth - el.offsetWidth;
|
|
if (scrollbarWidth > 0) {
|
|
originalMarginRight = el.style.marginRight;
|
|
el.style.marginRight = `${scrollbarWidth}px`;
|
|
lockHtmlScrollRightCompensationRef.value = `${scrollbarWidth}px`;
|
|
}
|
|
originalOverflow = el.style.overflow;
|
|
originalOverflowX = el.style.overflowX;
|
|
originalOverflowY = el.style.overflowY;
|
|
el.style.overflow = "hidden";
|
|
el.style.overflowX = "hidden";
|
|
el.style.overflowY = "hidden";
|
|
}
|
|
activated = true;
|
|
lockCount++;
|
|
} else {
|
|
lockCount--;
|
|
if (!lockCount) {
|
|
unlock();
|
|
}
|
|
activated = false;
|
|
}
|
|
}, {
|
|
immediate: true
|
|
});
|
|
});
|
|
onBeforeUnmount(() => {
|
|
watchStopHandle === null || watchStopHandle === void 0 ? void 0 : watchStopHandle();
|
|
if (activated) {
|
|
lockCount--;
|
|
if (!lockCount) {
|
|
unlock();
|
|
}
|
|
activated = false;
|
|
}
|
|
});
|
|
}
|
|
function useReactivated(callback) {
|
|
const isDeactivatedRef = {
|
|
isDeactivated: false
|
|
};
|
|
let activateStateInitialized = false;
|
|
onActivated(() => {
|
|
isDeactivatedRef.isDeactivated = false;
|
|
if (!activateStateInitialized) {
|
|
activateStateInitialized = true;
|
|
return;
|
|
}
|
|
callback();
|
|
});
|
|
onDeactivated(() => {
|
|
isDeactivatedRef.isDeactivated = true;
|
|
if (!activateStateInitialized) {
|
|
activateStateInitialized = true;
|
|
}
|
|
});
|
|
return isDeactivatedRef;
|
|
}
|
|
function getSlot(scope, slots, slotName = "default") {
|
|
const slot = slots[slotName];
|
|
if (slot === void 0) {
|
|
throw new Error(`[vueuc/${scope}]: slot[${slotName}] is empty.`);
|
|
}
|
|
return slot();
|
|
}
|
|
function flatten$1(vNodes, filterCommentNode = true, result = []) {
|
|
vNodes.forEach((vNode) => {
|
|
if (vNode === null)
|
|
return;
|
|
if (typeof vNode !== "object") {
|
|
if (typeof vNode === "string" || typeof vNode === "number") {
|
|
result.push(createTextVNode(String(vNode)));
|
|
}
|
|
return;
|
|
}
|
|
if (Array.isArray(vNode)) {
|
|
flatten$1(vNode, filterCommentNode, result);
|
|
return;
|
|
}
|
|
if (vNode.type === Fragment) {
|
|
if (vNode.children === null)
|
|
return;
|
|
if (Array.isArray(vNode.children)) {
|
|
flatten$1(vNode.children, filterCommentNode, result);
|
|
}
|
|
} else if (vNode.type !== Comment) {
|
|
result.push(vNode);
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
function getFirstVNode(scope, slots, slotName = "default") {
|
|
const slot = slots[slotName];
|
|
if (slot === void 0) {
|
|
throw new Error(`[vueuc/${scope}]: slot[${slotName}] is empty.`);
|
|
}
|
|
const content = flatten$1(slot());
|
|
if (content.length === 1) {
|
|
return content[0];
|
|
} else {
|
|
throw new Error(`[vueuc/${scope}]: slot[${slotName}] should have exactly one child.`);
|
|
}
|
|
}
|
|
const ctxKey = "@@coContext";
|
|
const clickoutside = {
|
|
mounted(el, { value, modifiers }) {
|
|
el[ctxKey] = {
|
|
handler: void 0
|
|
};
|
|
if (typeof value === "function") {
|
|
el[ctxKey].handler = value;
|
|
on("clickoutside", el, value, {
|
|
capture: modifiers.capture
|
|
});
|
|
}
|
|
},
|
|
updated(el, { value, modifiers }) {
|
|
const ctx2 = el[ctxKey];
|
|
if (typeof value === "function") {
|
|
if (ctx2.handler) {
|
|
if (ctx2.handler !== value) {
|
|
off("clickoutside", el, ctx2.handler, {
|
|
capture: modifiers.capture
|
|
});
|
|
ctx2.handler = value;
|
|
on("clickoutside", el, value, {
|
|
capture: modifiers.capture
|
|
});
|
|
}
|
|
} else {
|
|
el[ctxKey].handler = value;
|
|
on("clickoutside", el, value, {
|
|
capture: modifiers.capture
|
|
});
|
|
}
|
|
} else {
|
|
if (ctx2.handler) {
|
|
off("clickoutside", el, ctx2.handler, {
|
|
capture: modifiers.capture
|
|
});
|
|
ctx2.handler = void 0;
|
|
}
|
|
}
|
|
},
|
|
unmounted(el, { modifiers }) {
|
|
const { handler } = el[ctxKey];
|
|
if (handler) {
|
|
off("clickoutside", el, handler, {
|
|
capture: modifiers.capture
|
|
});
|
|
}
|
|
el[ctxKey].handler = void 0;
|
|
}
|
|
};
|
|
function warn$2(location2, message) {
|
|
console.error(`[vdirs/${location2}]: ${message}`);
|
|
}
|
|
class ZIndexManager {
|
|
constructor() {
|
|
this.elementZIndex = /* @__PURE__ */ new Map();
|
|
this.nextZIndex = 2e3;
|
|
}
|
|
get elementCount() {
|
|
return this.elementZIndex.size;
|
|
}
|
|
ensureZIndex(el, zIndex) {
|
|
const { elementZIndex } = this;
|
|
if (zIndex !== void 0) {
|
|
el.style.zIndex = `${zIndex}`;
|
|
elementZIndex.delete(el);
|
|
return;
|
|
}
|
|
const { nextZIndex } = this;
|
|
if (elementZIndex.has(el)) {
|
|
const currentZIndex = elementZIndex.get(el);
|
|
if (currentZIndex + 1 === this.nextZIndex)
|
|
return;
|
|
}
|
|
el.style.zIndex = `${nextZIndex}`;
|
|
elementZIndex.set(el, nextZIndex);
|
|
this.nextZIndex = nextZIndex + 1;
|
|
this.squashState();
|
|
}
|
|
unregister(el, zIndex) {
|
|
const { elementZIndex } = this;
|
|
if (elementZIndex.has(el)) {
|
|
elementZIndex.delete(el);
|
|
} else if (zIndex === void 0) {
|
|
warn$2("z-index-manager/unregister-element", "Element not found when unregistering.");
|
|
}
|
|
this.squashState();
|
|
}
|
|
squashState() {
|
|
const { elementCount } = this;
|
|
if (!elementCount) {
|
|
this.nextZIndex = 2e3;
|
|
}
|
|
if (this.nextZIndex - elementCount > 2500)
|
|
this.rearrange();
|
|
}
|
|
rearrange() {
|
|
const elementZIndexPair = Array.from(this.elementZIndex.entries());
|
|
elementZIndexPair.sort((pair1, pair2) => {
|
|
return pair1[1] - pair2[1];
|
|
});
|
|
this.nextZIndex = 2e3;
|
|
elementZIndexPair.forEach((pair) => {
|
|
const el = pair[0];
|
|
const zIndex = this.nextZIndex++;
|
|
if (`${zIndex}` !== el.style.zIndex)
|
|
el.style.zIndex = `${zIndex}`;
|
|
});
|
|
}
|
|
}
|
|
const zIndexManager = new ZIndexManager();
|
|
const ctx = "@@ziContext";
|
|
const zindexable = {
|
|
mounted(el, bindings) {
|
|
const { value = {} } = bindings;
|
|
const { zIndex, enabled } = value;
|
|
el[ctx] = {
|
|
enabled: !!enabled,
|
|
initialized: false
|
|
};
|
|
if (enabled) {
|
|
zIndexManager.ensureZIndex(el, zIndex);
|
|
el[ctx].initialized = true;
|
|
}
|
|
},
|
|
updated(el, bindings) {
|
|
const { value = {} } = bindings;
|
|
const { zIndex, enabled } = value;
|
|
const cachedEnabled = el[ctx].enabled;
|
|
if (enabled && !cachedEnabled) {
|
|
zIndexManager.ensureZIndex(el, zIndex);
|
|
el[ctx].initialized = true;
|
|
}
|
|
el[ctx].enabled = !!enabled;
|
|
},
|
|
unmounted(el, bindings) {
|
|
if (!el[ctx].initialized)
|
|
return;
|
|
const { value = {} } = bindings;
|
|
const { zIndex } = value;
|
|
zIndexManager.unregister(el, zIndex);
|
|
}
|
|
};
|
|
const ssrContextKey = "@css-render/vue3-ssr";
|
|
function createStyleString(id, style2) {
|
|
return `<style cssr-id="${id}">
|
|
${style2}
|
|
</style>`;
|
|
}
|
|
function ssrAdapter(id, style2, ssrContext) {
|
|
const { styles, ids } = ssrContext;
|
|
if (ids.has(id))
|
|
return;
|
|
if (styles !== null) {
|
|
ids.add(id);
|
|
styles.push(createStyleString(id, style2));
|
|
}
|
|
}
|
|
const isBrowser$1 = typeof document !== "undefined";
|
|
function useSsrAdapter() {
|
|
if (isBrowser$1)
|
|
return void 0;
|
|
const context = inject(ssrContextKey, null);
|
|
if (context === null)
|
|
return void 0;
|
|
return {
|
|
adapter: (id, style2) => ssrAdapter(id, style2, context),
|
|
context
|
|
};
|
|
}
|
|
function warn$1(location2, message) {
|
|
console.error(`[vueuc/${location2}]: ${message}`);
|
|
}
|
|
function resolveTo(selector) {
|
|
if (typeof selector === "string") {
|
|
return document.querySelector(selector);
|
|
}
|
|
return selector();
|
|
}
|
|
const LazyTeleport = /* @__PURE__ */ defineComponent({
|
|
name: "LazyTeleport",
|
|
props: {
|
|
to: {
|
|
type: [String, Object],
|
|
default: void 0
|
|
},
|
|
disabled: Boolean,
|
|
show: {
|
|
type: Boolean,
|
|
required: true
|
|
}
|
|
},
|
|
setup(props) {
|
|
return {
|
|
showTeleport: useFalseUntilTruthy(toRef(props, "show")),
|
|
mergedTo: computed(() => {
|
|
const { to } = props;
|
|
return to !== null && to !== void 0 ? to : "body";
|
|
})
|
|
};
|
|
},
|
|
render() {
|
|
return this.showTeleport ? this.disabled ? getSlot("lazy-teleport", this.$slots) : h(Teleport, {
|
|
disabled: this.disabled,
|
|
to: this.mergedTo
|
|
}, getSlot("lazy-teleport", this.$slots)) : null;
|
|
}
|
|
});
|
|
var resizeObservers = [];
|
|
var hasActiveObservations = function() {
|
|
return resizeObservers.some(function(ro) {
|
|
return ro.activeTargets.length > 0;
|
|
});
|
|
};
|
|
var hasSkippedObservations = function() {
|
|
return resizeObservers.some(function(ro) {
|
|
return ro.skippedTargets.length > 0;
|
|
});
|
|
};
|
|
var msg = "ResizeObserver loop completed with undelivered notifications.";
|
|
var deliverResizeLoopError = function() {
|
|
var event;
|
|
if (typeof ErrorEvent === "function") {
|
|
event = new ErrorEvent("error", {
|
|
message: msg
|
|
});
|
|
} else {
|
|
event = document.createEvent("Event");
|
|
event.initEvent("error", false, false);
|
|
event.message = msg;
|
|
}
|
|
window.dispatchEvent(event);
|
|
};
|
|
var ResizeObserverBoxOptions;
|
|
(function(ResizeObserverBoxOptions2) {
|
|
ResizeObserverBoxOptions2["BORDER_BOX"] = "border-box";
|
|
ResizeObserverBoxOptions2["CONTENT_BOX"] = "content-box";
|
|
ResizeObserverBoxOptions2["DEVICE_PIXEL_CONTENT_BOX"] = "device-pixel-content-box";
|
|
})(ResizeObserverBoxOptions || (ResizeObserverBoxOptions = {}));
|
|
var freeze = function(obj) {
|
|
return Object.freeze(obj);
|
|
};
|
|
var ResizeObserverSize = /* @__PURE__ */ function() {
|
|
function ResizeObserverSize2(inlineSize, blockSize) {
|
|
this.inlineSize = inlineSize;
|
|
this.blockSize = blockSize;
|
|
freeze(this);
|
|
}
|
|
return ResizeObserverSize2;
|
|
}();
|
|
var DOMRectReadOnly = function() {
|
|
function DOMRectReadOnly2(x, y, width, height) {
|
|
this.x = x;
|
|
this.y = y;
|
|
this.width = width;
|
|
this.height = height;
|
|
this.top = this.y;
|
|
this.left = this.x;
|
|
this.bottom = this.top + this.height;
|
|
this.right = this.left + this.width;
|
|
return freeze(this);
|
|
}
|
|
DOMRectReadOnly2.prototype.toJSON = function() {
|
|
var _a = this, x = _a.x, y = _a.y, top = _a.top, right = _a.right, bottom = _a.bottom, left = _a.left, width = _a.width, height = _a.height;
|
|
return { x, y, top, right, bottom, left, width, height };
|
|
};
|
|
DOMRectReadOnly2.fromRect = function(rectangle) {
|
|
return new DOMRectReadOnly2(rectangle.x, rectangle.y, rectangle.width, rectangle.height);
|
|
};
|
|
return DOMRectReadOnly2;
|
|
}();
|
|
var isSVG = function(target) {
|
|
return target instanceof SVGElement && "getBBox" in target;
|
|
};
|
|
var isHidden = function(target) {
|
|
if (isSVG(target)) {
|
|
var _a = target.getBBox(), width = _a.width, height = _a.height;
|
|
return !width && !height;
|
|
}
|
|
var _b = target, offsetWidth = _b.offsetWidth, offsetHeight = _b.offsetHeight;
|
|
return !(offsetWidth || offsetHeight || target.getClientRects().length);
|
|
};
|
|
var isElement = function(obj) {
|
|
var _a;
|
|
if (obj instanceof Element) {
|
|
return true;
|
|
}
|
|
var scope = (_a = obj === null || obj === void 0 ? void 0 : obj.ownerDocument) === null || _a === void 0 ? void 0 : _a.defaultView;
|
|
return !!(scope && obj instanceof scope.Element);
|
|
};
|
|
var isReplacedElement = function(target) {
|
|
switch (target.tagName) {
|
|
case "INPUT":
|
|
if (target.type !== "image") {
|
|
break;
|
|
}
|
|
case "VIDEO":
|
|
case "AUDIO":
|
|
case "EMBED":
|
|
case "OBJECT":
|
|
case "CANVAS":
|
|
case "IFRAME":
|
|
case "IMG":
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
var global$1 = typeof window !== "undefined" ? window : {};
|
|
var cache = /* @__PURE__ */ new WeakMap();
|
|
var scrollRegexp = /auto|scroll/;
|
|
var verticalRegexp = /^tb|vertical/;
|
|
var IE = /msie|trident/i.test(global$1.navigator && global$1.navigator.userAgent);
|
|
var parseDimension = function(pixel) {
|
|
return parseFloat(pixel || "0");
|
|
};
|
|
var size = function(inlineSize, blockSize, switchSizes) {
|
|
if (inlineSize === void 0) {
|
|
inlineSize = 0;
|
|
}
|
|
if (blockSize === void 0) {
|
|
blockSize = 0;
|
|
}
|
|
if (switchSizes === void 0) {
|
|
switchSizes = false;
|
|
}
|
|
return new ResizeObserverSize((switchSizes ? blockSize : inlineSize) || 0, (switchSizes ? inlineSize : blockSize) || 0);
|
|
};
|
|
var zeroBoxes = freeze({
|
|
devicePixelContentBoxSize: size(),
|
|
borderBoxSize: size(),
|
|
contentBoxSize: size(),
|
|
contentRect: new DOMRectReadOnly(0, 0, 0, 0)
|
|
});
|
|
var calculateBoxSizes = function(target, forceRecalculation) {
|
|
if (forceRecalculation === void 0) {
|
|
forceRecalculation = false;
|
|
}
|
|
if (cache.has(target) && !forceRecalculation) {
|
|
return cache.get(target);
|
|
}
|
|
if (isHidden(target)) {
|
|
cache.set(target, zeroBoxes);
|
|
return zeroBoxes;
|
|
}
|
|
var cs = getComputedStyle(target);
|
|
var svg = isSVG(target) && target.ownerSVGElement && target.getBBox();
|
|
var removePadding = !IE && cs.boxSizing === "border-box";
|
|
var switchSizes = verticalRegexp.test(cs.writingMode || "");
|
|
var canScrollVertically = !svg && scrollRegexp.test(cs.overflowY || "");
|
|
var canScrollHorizontally = !svg && scrollRegexp.test(cs.overflowX || "");
|
|
var paddingTop = svg ? 0 : parseDimension(cs.paddingTop);
|
|
var paddingRight = svg ? 0 : parseDimension(cs.paddingRight);
|
|
var paddingBottom = svg ? 0 : parseDimension(cs.paddingBottom);
|
|
var paddingLeft = svg ? 0 : parseDimension(cs.paddingLeft);
|
|
var borderTop = svg ? 0 : parseDimension(cs.borderTopWidth);
|
|
var borderRight = svg ? 0 : parseDimension(cs.borderRightWidth);
|
|
var borderBottom = svg ? 0 : parseDimension(cs.borderBottomWidth);
|
|
var borderLeft = svg ? 0 : parseDimension(cs.borderLeftWidth);
|
|
var horizontalPadding = paddingLeft + paddingRight;
|
|
var verticalPadding = paddingTop + paddingBottom;
|
|
var horizontalBorderArea = borderLeft + borderRight;
|
|
var verticalBorderArea = borderTop + borderBottom;
|
|
var horizontalScrollbarThickness = !canScrollHorizontally ? 0 : target.offsetHeight - verticalBorderArea - target.clientHeight;
|
|
var verticalScrollbarThickness = !canScrollVertically ? 0 : target.offsetWidth - horizontalBorderArea - target.clientWidth;
|
|
var widthReduction = removePadding ? horizontalPadding + horizontalBorderArea : 0;
|
|
var heightReduction = removePadding ? verticalPadding + verticalBorderArea : 0;
|
|
var contentWidth = svg ? svg.width : parseDimension(cs.width) - widthReduction - verticalScrollbarThickness;
|
|
var contentHeight = svg ? svg.height : parseDimension(cs.height) - heightReduction - horizontalScrollbarThickness;
|
|
var borderBoxWidth = contentWidth + horizontalPadding + verticalScrollbarThickness + horizontalBorderArea;
|
|
var borderBoxHeight = contentHeight + verticalPadding + horizontalScrollbarThickness + verticalBorderArea;
|
|
var boxes = freeze({
|
|
devicePixelContentBoxSize: size(Math.round(contentWidth * devicePixelRatio), Math.round(contentHeight * devicePixelRatio), switchSizes),
|
|
borderBoxSize: size(borderBoxWidth, borderBoxHeight, switchSizes),
|
|
contentBoxSize: size(contentWidth, contentHeight, switchSizes),
|
|
contentRect: new DOMRectReadOnly(paddingLeft, paddingTop, contentWidth, contentHeight)
|
|
});
|
|
cache.set(target, boxes);
|
|
return boxes;
|
|
};
|
|
var calculateBoxSize = function(target, observedBox, forceRecalculation) {
|
|
var _a = calculateBoxSizes(target, forceRecalculation), borderBoxSize = _a.borderBoxSize, contentBoxSize = _a.contentBoxSize, devicePixelContentBoxSize = _a.devicePixelContentBoxSize;
|
|
switch (observedBox) {
|
|
case ResizeObserverBoxOptions.DEVICE_PIXEL_CONTENT_BOX:
|
|
return devicePixelContentBoxSize;
|
|
case ResizeObserverBoxOptions.BORDER_BOX:
|
|
return borderBoxSize;
|
|
default:
|
|
return contentBoxSize;
|
|
}
|
|
};
|
|
var ResizeObserverEntry = /* @__PURE__ */ function() {
|
|
function ResizeObserverEntry2(target) {
|
|
var boxes = calculateBoxSizes(target);
|
|
this.target = target;
|
|
this.contentRect = boxes.contentRect;
|
|
this.borderBoxSize = freeze([boxes.borderBoxSize]);
|
|
this.contentBoxSize = freeze([boxes.contentBoxSize]);
|
|
this.devicePixelContentBoxSize = freeze([boxes.devicePixelContentBoxSize]);
|
|
}
|
|
return ResizeObserverEntry2;
|
|
}();
|
|
var calculateDepthForNode = function(node) {
|
|
if (isHidden(node)) {
|
|
return Infinity;
|
|
}
|
|
var depth = 0;
|
|
var parent = node.parentNode;
|
|
while (parent) {
|
|
depth += 1;
|
|
parent = parent.parentNode;
|
|
}
|
|
return depth;
|
|
};
|
|
var broadcastActiveObservations = function() {
|
|
var shallowestDepth = Infinity;
|
|
var callbacks2 = [];
|
|
resizeObservers.forEach(function processObserver(ro) {
|
|
if (ro.activeTargets.length === 0) {
|
|
return;
|
|
}
|
|
var entries = [];
|
|
ro.activeTargets.forEach(function processTarget(ot) {
|
|
var entry = new ResizeObserverEntry(ot.target);
|
|
var targetDepth = calculateDepthForNode(ot.target);
|
|
entries.push(entry);
|
|
ot.lastReportedSize = calculateBoxSize(ot.target, ot.observedBox);
|
|
if (targetDepth < shallowestDepth) {
|
|
shallowestDepth = targetDepth;
|
|
}
|
|
});
|
|
callbacks2.push(function resizeObserverCallback() {
|
|
ro.callback.call(ro.observer, entries, ro.observer);
|
|
});
|
|
ro.activeTargets.splice(0, ro.activeTargets.length);
|
|
});
|
|
for (var _i = 0, callbacks_1 = callbacks2; _i < callbacks_1.length; _i++) {
|
|
var callback = callbacks_1[_i];
|
|
callback();
|
|
}
|
|
return shallowestDepth;
|
|
};
|
|
var gatherActiveObservationsAtDepth = function(depth) {
|
|
resizeObservers.forEach(function processObserver(ro) {
|
|
ro.activeTargets.splice(0, ro.activeTargets.length);
|
|
ro.skippedTargets.splice(0, ro.skippedTargets.length);
|
|
ro.observationTargets.forEach(function processTarget(ot) {
|
|
if (ot.isActive()) {
|
|
if (calculateDepthForNode(ot.target) > depth) {
|
|
ro.activeTargets.push(ot);
|
|
} else {
|
|
ro.skippedTargets.push(ot);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
var process$1 = function() {
|
|
var depth = 0;
|
|
gatherActiveObservationsAtDepth(depth);
|
|
while (hasActiveObservations()) {
|
|
depth = broadcastActiveObservations();
|
|
gatherActiveObservationsAtDepth(depth);
|
|
}
|
|
if (hasSkippedObservations()) {
|
|
deliverResizeLoopError();
|
|
}
|
|
return depth > 0;
|
|
};
|
|
var trigger;
|
|
var callbacks = [];
|
|
var notify = function() {
|
|
return callbacks.splice(0).forEach(function(cb) {
|
|
return cb();
|
|
});
|
|
};
|
|
var queueMicroTask = function(callback) {
|
|
if (!trigger) {
|
|
var toggle_1 = 0;
|
|
var el_1 = document.createTextNode("");
|
|
var config = { characterData: true };
|
|
new MutationObserver(function() {
|
|
return notify();
|
|
}).observe(el_1, config);
|
|
trigger = function() {
|
|
el_1.textContent = "".concat(toggle_1 ? toggle_1-- : toggle_1++);
|
|
};
|
|
}
|
|
callbacks.push(callback);
|
|
trigger();
|
|
};
|
|
var queueResizeObserver = function(cb) {
|
|
queueMicroTask(function ResizeObserver2() {
|
|
requestAnimationFrame(cb);
|
|
});
|
|
};
|
|
var watching = 0;
|
|
var isWatching = function() {
|
|
return !!watching;
|
|
};
|
|
var CATCH_PERIOD = 250;
|
|
var observerConfig = { attributes: true, characterData: true, childList: true, subtree: true };
|
|
var events$1 = [
|
|
"resize",
|
|
"load",
|
|
"transitionend",
|
|
"animationend",
|
|
"animationstart",
|
|
"animationiteration",
|
|
"keyup",
|
|
"keydown",
|
|
"mouseup",
|
|
"mousedown",
|
|
"mouseover",
|
|
"mouseout",
|
|
"blur",
|
|
"focus"
|
|
];
|
|
var time = function(timeout2) {
|
|
if (timeout2 === void 0) {
|
|
timeout2 = 0;
|
|
}
|
|
return Date.now() + timeout2;
|
|
};
|
|
var scheduled = false;
|
|
var Scheduler = function() {
|
|
function Scheduler2() {
|
|
var _this = this;
|
|
this.stopped = true;
|
|
this.listener = function() {
|
|
return _this.schedule();
|
|
};
|
|
}
|
|
Scheduler2.prototype.run = function(timeout2) {
|
|
var _this = this;
|
|
if (timeout2 === void 0) {
|
|
timeout2 = CATCH_PERIOD;
|
|
}
|
|
if (scheduled) {
|
|
return;
|
|
}
|
|
scheduled = true;
|
|
var until = time(timeout2);
|
|
queueResizeObserver(function() {
|
|
var elementsHaveResized = false;
|
|
try {
|
|
elementsHaveResized = process$1();
|
|
} finally {
|
|
scheduled = false;
|
|
timeout2 = until - time();
|
|
if (!isWatching()) {
|
|
return;
|
|
}
|
|
if (elementsHaveResized) {
|
|
_this.run(1e3);
|
|
} else if (timeout2 > 0) {
|
|
_this.run(timeout2);
|
|
} else {
|
|
_this.start();
|
|
}
|
|
}
|
|
});
|
|
};
|
|
Scheduler2.prototype.schedule = function() {
|
|
this.stop();
|
|
this.run();
|
|
};
|
|
Scheduler2.prototype.observe = function() {
|
|
var _this = this;
|
|
var cb = function() {
|
|
return _this.observer && _this.observer.observe(document.body, observerConfig);
|
|
};
|
|
document.body ? cb() : global$1.addEventListener("DOMContentLoaded", cb);
|
|
};
|
|
Scheduler2.prototype.start = function() {
|
|
var _this = this;
|
|
if (this.stopped) {
|
|
this.stopped = false;
|
|
this.observer = new MutationObserver(this.listener);
|
|
this.observe();
|
|
events$1.forEach(function(name) {
|
|
return global$1.addEventListener(name, _this.listener, true);
|
|
});
|
|
}
|
|
};
|
|
Scheduler2.prototype.stop = function() {
|
|
var _this = this;
|
|
if (!this.stopped) {
|
|
this.observer && this.observer.disconnect();
|
|
events$1.forEach(function(name) {
|
|
return global$1.removeEventListener(name, _this.listener, true);
|
|
});
|
|
this.stopped = true;
|
|
}
|
|
};
|
|
return Scheduler2;
|
|
}();
|
|
var scheduler = new Scheduler();
|
|
var updateCount = function(n) {
|
|
!watching && n > 0 && scheduler.start();
|
|
watching += n;
|
|
!watching && scheduler.stop();
|
|
};
|
|
var skipNotifyOnElement = function(target) {
|
|
return !isSVG(target) && !isReplacedElement(target) && getComputedStyle(target).display === "inline";
|
|
};
|
|
var ResizeObservation = function() {
|
|
function ResizeObservation2(target, observedBox) {
|
|
this.target = target;
|
|
this.observedBox = observedBox || ResizeObserverBoxOptions.CONTENT_BOX;
|
|
this.lastReportedSize = {
|
|
inlineSize: 0,
|
|
blockSize: 0
|
|
};
|
|
}
|
|
ResizeObservation2.prototype.isActive = function() {
|
|
var size2 = calculateBoxSize(this.target, this.observedBox, true);
|
|
if (skipNotifyOnElement(this.target)) {
|
|
this.lastReportedSize = size2;
|
|
}
|
|
if (this.lastReportedSize.inlineSize !== size2.inlineSize || this.lastReportedSize.blockSize !== size2.blockSize) {
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
return ResizeObservation2;
|
|
}();
|
|
var ResizeObserverDetail = /* @__PURE__ */ function() {
|
|
function ResizeObserverDetail2(resizeObserver, callback) {
|
|
this.activeTargets = [];
|
|
this.skippedTargets = [];
|
|
this.observationTargets = [];
|
|
this.observer = resizeObserver;
|
|
this.callback = callback;
|
|
}
|
|
return ResizeObserverDetail2;
|
|
}();
|
|
var observerMap = /* @__PURE__ */ new WeakMap();
|
|
var getObservationIndex = function(observationTargets, target) {
|
|
for (var i = 0; i < observationTargets.length; i += 1) {
|
|
if (observationTargets[i].target === target) {
|
|
return i;
|
|
}
|
|
}
|
|
return -1;
|
|
};
|
|
var ResizeObserverController = function() {
|
|
function ResizeObserverController2() {
|
|
}
|
|
ResizeObserverController2.connect = function(resizeObserver, callback) {
|
|
var detail = new ResizeObserverDetail(resizeObserver, callback);
|
|
observerMap.set(resizeObserver, detail);
|
|
};
|
|
ResizeObserverController2.observe = function(resizeObserver, target, options) {
|
|
var detail = observerMap.get(resizeObserver);
|
|
var firstObservation = detail.observationTargets.length === 0;
|
|
if (getObservationIndex(detail.observationTargets, target) < 0) {
|
|
firstObservation && resizeObservers.push(detail);
|
|
detail.observationTargets.push(new ResizeObservation(target, options && options.box));
|
|
updateCount(1);
|
|
scheduler.schedule();
|
|
}
|
|
};
|
|
ResizeObserverController2.unobserve = function(resizeObserver, target) {
|
|
var detail = observerMap.get(resizeObserver);
|
|
var index = getObservationIndex(detail.observationTargets, target);
|
|
var lastObservation = detail.observationTargets.length === 1;
|
|
if (index >= 0) {
|
|
lastObservation && resizeObservers.splice(resizeObservers.indexOf(detail), 1);
|
|
detail.observationTargets.splice(index, 1);
|
|
updateCount(-1);
|
|
}
|
|
};
|
|
ResizeObserverController2.disconnect = function(resizeObserver) {
|
|
var _this = this;
|
|
var detail = observerMap.get(resizeObserver);
|
|
detail.observationTargets.slice().forEach(function(ot) {
|
|
return _this.unobserve(resizeObserver, ot.target);
|
|
});
|
|
detail.activeTargets.splice(0, detail.activeTargets.length);
|
|
};
|
|
return ResizeObserverController2;
|
|
}();
|
|
var ResizeObserver = function() {
|
|
function ResizeObserver2(callback) {
|
|
if (arguments.length === 0) {
|
|
throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");
|
|
}
|
|
if (typeof callback !== "function") {
|
|
throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");
|
|
}
|
|
ResizeObserverController.connect(this, callback);
|
|
}
|
|
ResizeObserver2.prototype.observe = function(target, options) {
|
|
if (arguments.length === 0) {
|
|
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");
|
|
}
|
|
if (!isElement(target)) {
|
|
throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");
|
|
}
|
|
ResizeObserverController.observe(this, target, options);
|
|
};
|
|
ResizeObserver2.prototype.unobserve = function(target) {
|
|
if (arguments.length === 0) {
|
|
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");
|
|
}
|
|
if (!isElement(target)) {
|
|
throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");
|
|
}
|
|
ResizeObserverController.unobserve(this, target);
|
|
};
|
|
ResizeObserver2.prototype.disconnect = function() {
|
|
ResizeObserverController.disconnect(this);
|
|
};
|
|
ResizeObserver2.toString = function() {
|
|
return "function ResizeObserver () { [polyfill code] }";
|
|
};
|
|
return ResizeObserver2;
|
|
}();
|
|
class ResizeObserverDelegate {
|
|
constructor() {
|
|
this.handleResize = this.handleResize.bind(this);
|
|
this.observer = new (typeof window !== "undefined" && window.ResizeObserver || ResizeObserver)(this.handleResize);
|
|
this.elHandlersMap = /* @__PURE__ */ new Map();
|
|
}
|
|
handleResize(entries) {
|
|
for (const entry of entries) {
|
|
const handler = this.elHandlersMap.get(entry.target);
|
|
if (handler !== void 0) {
|
|
handler(entry);
|
|
}
|
|
}
|
|
}
|
|
registerHandler(el, handler) {
|
|
this.elHandlersMap.set(el, handler);
|
|
this.observer.observe(el);
|
|
}
|
|
unregisterHandler(el) {
|
|
if (!this.elHandlersMap.has(el)) {
|
|
return;
|
|
}
|
|
this.elHandlersMap.delete(el);
|
|
this.observer.unobserve(el);
|
|
}
|
|
}
|
|
const resizeObserverManager = new ResizeObserverDelegate();
|
|
const VResizeObserver = /* @__PURE__ */ defineComponent({
|
|
name: "ResizeObserver",
|
|
props: {
|
|
onResize: Function
|
|
},
|
|
setup(props) {
|
|
let registered = false;
|
|
const proxy = getCurrentInstance().proxy;
|
|
function handleResize(entry) {
|
|
const { onResize } = props;
|
|
if (onResize !== void 0)
|
|
onResize(entry);
|
|
}
|
|
onMounted(() => {
|
|
const el = proxy.$el;
|
|
if (el === void 0) {
|
|
warn$1("resize-observer", "$el does not exist.");
|
|
return;
|
|
}
|
|
if (el.nextElementSibling !== el.nextSibling) {
|
|
if (el.nodeType === 3 && el.nodeValue !== "") {
|
|
warn$1("resize-observer", "$el can not be observed (it may be a text node).");
|
|
return;
|
|
}
|
|
}
|
|
if (el.nextElementSibling !== null) {
|
|
resizeObserverManager.registerHandler(el.nextElementSibling, handleResize);
|
|
registered = true;
|
|
}
|
|
});
|
|
onBeforeUnmount(() => {
|
|
if (registered) {
|
|
resizeObserverManager.unregisterHandler(proxy.$el.nextElementSibling);
|
|
}
|
|
});
|
|
},
|
|
render() {
|
|
return renderSlot(this.$slots, "default");
|
|
}
|
|
});
|
|
function isHTMLElement(node) {
|
|
return node instanceof HTMLElement;
|
|
}
|
|
function focusFirstDescendant(node) {
|
|
for (let i = 0; i < node.childNodes.length; i++) {
|
|
const child = node.childNodes[i];
|
|
if (isHTMLElement(child)) {
|
|
if (attemptFocus(child) || focusFirstDescendant(child)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function focusLastDescendant(element) {
|
|
for (let i = element.childNodes.length - 1; i >= 0; i--) {
|
|
const child = element.childNodes[i];
|
|
if (isHTMLElement(child)) {
|
|
if (attemptFocus(child) || focusLastDescendant(child)) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function attemptFocus(element) {
|
|
if (!isFocusable(element)) {
|
|
return false;
|
|
}
|
|
try {
|
|
element.focus({ preventScroll: true });
|
|
} catch (e) {
|
|
}
|
|
return document.activeElement === element;
|
|
}
|
|
function isFocusable(element) {
|
|
if (element.tabIndex > 0 || element.tabIndex === 0 && element.getAttribute("tabIndex") !== null) {
|
|
return true;
|
|
}
|
|
if (element.getAttribute("disabled")) {
|
|
return false;
|
|
}
|
|
switch (element.nodeName) {
|
|
case "A":
|
|
return !!element.href && element.rel !== "ignore";
|
|
case "INPUT":
|
|
return element.type !== "hidden" && element.type !== "file";
|
|
case "BUTTON":
|
|
case "SELECT":
|
|
case "TEXTAREA":
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
let stack = [];
|
|
const FocusTrap = /* @__PURE__ */ defineComponent({
|
|
name: "FocusTrap",
|
|
props: {
|
|
disabled: Boolean,
|
|
active: Boolean,
|
|
autoFocus: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
onEsc: Function,
|
|
initialFocusTo: String,
|
|
finalFocusTo: String,
|
|
returnFocusOnDeactivated: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
},
|
|
setup(props) {
|
|
const id = createId();
|
|
const focusableStartRef = ref(null);
|
|
const focusableEndRef = ref(null);
|
|
let activated = false;
|
|
let ignoreInternalFocusChange = false;
|
|
const lastFocusedElement = typeof document === "undefined" ? null : document.activeElement;
|
|
function isCurrentActive() {
|
|
const currentActiveId = stack[stack.length - 1];
|
|
return currentActiveId === id;
|
|
}
|
|
function handleDocumentKeydown(e) {
|
|
var _a;
|
|
if (e.code === "Escape") {
|
|
if (isCurrentActive()) {
|
|
(_a = props.onEsc) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
}
|
|
}
|
|
}
|
|
onMounted(() => {
|
|
watch(() => props.active, (value) => {
|
|
if (value) {
|
|
activate();
|
|
on("keydown", document, handleDocumentKeydown);
|
|
} else {
|
|
off("keydown", document, handleDocumentKeydown);
|
|
if (activated) {
|
|
deactivate();
|
|
}
|
|
}
|
|
}, {
|
|
immediate: true
|
|
});
|
|
});
|
|
onBeforeUnmount(() => {
|
|
off("keydown", document, handleDocumentKeydown);
|
|
if (activated)
|
|
deactivate();
|
|
});
|
|
function handleDocumentFocus(e) {
|
|
if (ignoreInternalFocusChange)
|
|
return;
|
|
if (isCurrentActive()) {
|
|
const mainEl = getMainEl();
|
|
if (mainEl === null)
|
|
return;
|
|
if (mainEl.contains(getPreciseEventTarget(e)))
|
|
return;
|
|
resetFocusTo("first");
|
|
}
|
|
}
|
|
function getMainEl() {
|
|
const focusableStartEl = focusableStartRef.value;
|
|
if (focusableStartEl === null)
|
|
return null;
|
|
let mainEl = focusableStartEl;
|
|
while (true) {
|
|
mainEl = mainEl.nextSibling;
|
|
if (mainEl === null)
|
|
break;
|
|
if (mainEl instanceof Element && mainEl.tagName === "DIV") {
|
|
break;
|
|
}
|
|
}
|
|
return mainEl;
|
|
}
|
|
function activate() {
|
|
var _a;
|
|
if (props.disabled)
|
|
return;
|
|
stack.push(id);
|
|
if (props.autoFocus) {
|
|
const { initialFocusTo } = props;
|
|
if (initialFocusTo === void 0) {
|
|
resetFocusTo("first");
|
|
} else {
|
|
(_a = resolveTo(initialFocusTo)) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
}
|
|
}
|
|
activated = true;
|
|
document.addEventListener("focus", handleDocumentFocus, true);
|
|
}
|
|
function deactivate() {
|
|
var _a;
|
|
if (props.disabled)
|
|
return;
|
|
document.removeEventListener("focus", handleDocumentFocus, true);
|
|
stack = stack.filter((idInStack) => idInStack !== id);
|
|
if (isCurrentActive())
|
|
return;
|
|
const { finalFocusTo } = props;
|
|
if (finalFocusTo !== void 0) {
|
|
(_a = resolveTo(finalFocusTo)) === null || _a === void 0 ? void 0 : _a.focus({ preventScroll: true });
|
|
} else if (props.returnFocusOnDeactivated) {
|
|
if (lastFocusedElement instanceof HTMLElement) {
|
|
ignoreInternalFocusChange = true;
|
|
lastFocusedElement.focus({ preventScroll: true });
|
|
ignoreInternalFocusChange = false;
|
|
}
|
|
}
|
|
}
|
|
function resetFocusTo(target) {
|
|
if (!isCurrentActive())
|
|
return;
|
|
if (props.active) {
|
|
const focusableStartEl = focusableStartRef.value;
|
|
const focusableEndEl = focusableEndRef.value;
|
|
if (focusableStartEl !== null && focusableEndEl !== null) {
|
|
const mainEl = getMainEl();
|
|
if (mainEl == null || mainEl === focusableEndEl) {
|
|
ignoreInternalFocusChange = true;
|
|
focusableStartEl.focus({ preventScroll: true });
|
|
ignoreInternalFocusChange = false;
|
|
return;
|
|
}
|
|
ignoreInternalFocusChange = true;
|
|
const focused = target === "first" ? focusFirstDescendant(mainEl) : focusLastDescendant(mainEl);
|
|
ignoreInternalFocusChange = false;
|
|
if (!focused) {
|
|
ignoreInternalFocusChange = true;
|
|
focusableStartEl.focus({ preventScroll: true });
|
|
ignoreInternalFocusChange = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function handleStartFocus(e) {
|
|
if (ignoreInternalFocusChange)
|
|
return;
|
|
const mainEl = getMainEl();
|
|
if (mainEl === null)
|
|
return;
|
|
if (e.relatedTarget !== null && mainEl.contains(e.relatedTarget)) {
|
|
resetFocusTo("last");
|
|
} else {
|
|
resetFocusTo("first");
|
|
}
|
|
}
|
|
function handleEndFocus(e) {
|
|
if (ignoreInternalFocusChange)
|
|
return;
|
|
if (e.relatedTarget !== null && e.relatedTarget === focusableStartRef.value) {
|
|
resetFocusTo("last");
|
|
} else {
|
|
resetFocusTo("first");
|
|
}
|
|
}
|
|
return {
|
|
focusableStartRef,
|
|
focusableEndRef,
|
|
focusableStyle: "position: absolute; height: 0; width: 0;",
|
|
handleStartFocus,
|
|
handleEndFocus
|
|
};
|
|
},
|
|
render() {
|
|
const { default: defaultSlot } = this.$slots;
|
|
if (defaultSlot === void 0)
|
|
return null;
|
|
if (this.disabled)
|
|
return defaultSlot();
|
|
const { active, focusableStyle } = this;
|
|
return h(Fragment, null, [
|
|
h("div", {
|
|
"aria-hidden": "true",
|
|
tabindex: active ? "0" : "-1",
|
|
ref: "focusableStartRef",
|
|
style: focusableStyle,
|
|
onFocus: this.handleStartFocus
|
|
}),
|
|
defaultSlot(),
|
|
h("div", {
|
|
"aria-hidden": "true",
|
|
style: focusableStyle,
|
|
ref: "focusableEndRef",
|
|
tabindex: active ? "0" : "-1",
|
|
onFocus: this.handleEndFocus
|
|
})
|
|
]);
|
|
}
|
|
});
|
|
function color2Class(color) {
|
|
return color.replace(/#|\(|\)|,|\s|\./g, "_");
|
|
}
|
|
const pureNumberRegex = /^(\d|\.)+$/;
|
|
const numberRegex = /(\d|\.)+/;
|
|
function formatLength(length, {
|
|
c: c2 = 1,
|
|
offset = 0,
|
|
attachPx = true
|
|
} = {}) {
|
|
if (typeof length === "number") {
|
|
const result = (length + offset) * c2;
|
|
if (result === 0) return "0";
|
|
return `${result}px`;
|
|
} else if (typeof length === "string") {
|
|
if (pureNumberRegex.test(length)) {
|
|
const result = (Number(length) + offset) * c2;
|
|
if (attachPx) {
|
|
if (result === 0) return "0";
|
|
return `${result}px`;
|
|
} else {
|
|
return `${result}`;
|
|
}
|
|
} else {
|
|
const result = numberRegex.exec(length);
|
|
if (!result) return length;
|
|
return length.replace(numberRegex, String((Number(result[0]) + offset) * c2));
|
|
}
|
|
}
|
|
return length;
|
|
}
|
|
function rtlInset(inset) {
|
|
const {
|
|
left,
|
|
right,
|
|
top,
|
|
bottom
|
|
} = getMargin(inset);
|
|
return `${top} ${left} ${bottom} ${right}`;
|
|
}
|
|
const eventSet = /* @__PURE__ */ new WeakSet();
|
|
function markEventEffectPerformed(event) {
|
|
eventSet.add(event);
|
|
}
|
|
function eventEffectNotPerformed(event) {
|
|
return !eventSet.has(event);
|
|
}
|
|
const warnedMessages = /* @__PURE__ */ new Set();
|
|
function warnOnce(location2, message) {
|
|
const mergedMessage = `[naive/${location2}]: ${message}`;
|
|
if (warnedMessages.has(mergedMessage)) return;
|
|
warnedMessages.add(mergedMessage);
|
|
console.error(mergedMessage);
|
|
}
|
|
function warn(location2, message) {
|
|
console.error(`[naive/${location2}]: ${message}`);
|
|
}
|
|
function error(location2, message, error2) {
|
|
console.error(`[naive/${location2}]: ${message}`, error2);
|
|
}
|
|
function throwError(location2, message) {
|
|
throw new Error(`[naive/${location2}]: ${message}`);
|
|
}
|
|
function call(funcs, ...args) {
|
|
if (Array.isArray(funcs)) {
|
|
funcs.forEach((func) => call(func, ...args));
|
|
} else {
|
|
return funcs(...args);
|
|
}
|
|
}
|
|
function flatten(vNodes, filterCommentNode = true, result = []) {
|
|
vNodes.forEach((vNode) => {
|
|
if (vNode === null) return;
|
|
if (typeof vNode !== "object") {
|
|
if (typeof vNode === "string" || typeof vNode === "number") {
|
|
result.push(createTextVNode(String(vNode)));
|
|
}
|
|
return;
|
|
}
|
|
if (Array.isArray(vNode)) {
|
|
flatten(vNode, filterCommentNode, result);
|
|
return;
|
|
}
|
|
if (vNode.type === Fragment) {
|
|
if (vNode.children === null) return;
|
|
if (Array.isArray(vNode.children)) {
|
|
flatten(vNode.children, filterCommentNode, result);
|
|
}
|
|
} else {
|
|
if (vNode.type === Comment && filterCommentNode) return;
|
|
result.push(vNode);
|
|
}
|
|
});
|
|
return result;
|
|
}
|
|
function getFirstSlotVNode(slots, slotName = "default", props = void 0) {
|
|
const slot = slots[slotName];
|
|
if (!slot) {
|
|
warn("getFirstSlotVNode", `slot[${slotName}] is empty`);
|
|
return null;
|
|
}
|
|
const slotContent = flatten(slot(props));
|
|
if (slotContent.length === 1) {
|
|
return slotContent[0];
|
|
} else {
|
|
warn("getFirstSlotVNode", `slot[${slotName}] should have exactly one child`);
|
|
return null;
|
|
}
|
|
}
|
|
function getFirstSlotVNodeWithTypedProps(slotName, slot, props) {
|
|
if (!slot) {
|
|
return null;
|
|
}
|
|
const slotContent = flatten(slot(props));
|
|
if (slotContent.length === 1) {
|
|
return slotContent[0];
|
|
} else {
|
|
warn("getFirstSlotVNode", `slot[${slotName}] should have exactly one child`);
|
|
return null;
|
|
}
|
|
}
|
|
function keep(object, keys = [], rest) {
|
|
const keepedObject = {};
|
|
keys.forEach((key) => {
|
|
keepedObject[key] = object[key];
|
|
});
|
|
return Object.assign(keepedObject, rest);
|
|
}
|
|
function keysOf(obj) {
|
|
return Object.keys(obj);
|
|
}
|
|
function omit(object, keys = [], rest) {
|
|
const omitedObject = {};
|
|
const originalKeys = Object.getOwnPropertyNames(object);
|
|
originalKeys.forEach((originalKey) => {
|
|
if (!keys.includes(originalKey)) {
|
|
omitedObject[originalKey] = object[originalKey];
|
|
}
|
|
});
|
|
return Object.assign(omitedObject, rest);
|
|
}
|
|
function render(r, ...args) {
|
|
if (typeof r === "function") {
|
|
return r(...args);
|
|
} else if (typeof r === "string") {
|
|
return createTextVNode(r);
|
|
} else if (typeof r === "number") {
|
|
return createTextVNode(String(r));
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
function ensureValidVNode(vnodes) {
|
|
return vnodes.some((child) => {
|
|
if (!isVNode(child)) {
|
|
return true;
|
|
}
|
|
if (child.type === Comment) {
|
|
return false;
|
|
}
|
|
if (child.type === Fragment && !ensureValidVNode(child.children)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}) ? vnodes : null;
|
|
}
|
|
function resolveSlot(slot, fallback) {
|
|
return slot && ensureValidVNode(slot()) || fallback();
|
|
}
|
|
function resolveSlotWithTypedProps(slot, props, fallback) {
|
|
return slot && ensureValidVNode(slot(props)) || fallback(props);
|
|
}
|
|
function resolveWrappedSlot(slot, wrapper) {
|
|
const children = slot && ensureValidVNode(slot());
|
|
return wrapper(children || null);
|
|
}
|
|
function isSlotEmpty(slot) {
|
|
return !(slot && ensureValidVNode(slot()));
|
|
}
|
|
const Wrapper = /* @__PURE__ */ defineComponent({
|
|
render() {
|
|
var _a, _b;
|
|
return (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
}
|
|
});
|
|
const configProviderInjectionKey = createInjectionKey("n-config-provider");
|
|
const defaultClsPrefix = "n";
|
|
function useConfig(props = {}, options = {
|
|
defaultBordered: true
|
|
}) {
|
|
const NConfigProvider = inject(configProviderInjectionKey, null);
|
|
return {
|
|
// NConfigProvider,
|
|
inlineThemeDisabled: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.inlineThemeDisabled,
|
|
mergedRtlRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedRtlRef,
|
|
mergedComponentPropsRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedComponentPropsRef,
|
|
mergedBreakpointsRef: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBreakpointsRef,
|
|
mergedBorderedRef: computed(() => {
|
|
var _a, _b;
|
|
const {
|
|
bordered
|
|
} = props;
|
|
if (bordered !== void 0) return bordered;
|
|
return (_b = (_a = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBorderedRef.value) !== null && _a !== void 0 ? _a : options.defaultBordered) !== null && _b !== void 0 ? _b : true;
|
|
}),
|
|
mergedClsPrefixRef: NConfigProvider ? NConfigProvider.mergedClsPrefixRef : shallowRef(defaultClsPrefix),
|
|
namespaceRef: computed(() => NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedNamespaceRef.value)
|
|
};
|
|
}
|
|
function useMergedClsPrefix() {
|
|
const NConfigProvider = inject(configProviderInjectionKey, null);
|
|
return NConfigProvider ? NConfigProvider.mergedClsPrefixRef : shallowRef(defaultClsPrefix);
|
|
}
|
|
function useThemeClass(componentName, hashRef, cssVarsRef, props) {
|
|
if (!cssVarsRef) throwError("useThemeClass", "cssVarsRef is not passed");
|
|
const NConfigProvider = inject(configProviderInjectionKey, null);
|
|
const mergedThemeHashRef = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeHashRef;
|
|
const styleMountTarget = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget;
|
|
const themeClassRef = ref("");
|
|
const ssrAdapter2 = useSsrAdapter();
|
|
let renderCallback;
|
|
const hashClassPrefix = `__${componentName}`;
|
|
const mountStyle = () => {
|
|
let finalThemeHash = hashClassPrefix;
|
|
const hashValue = hashRef ? hashRef.value : void 0;
|
|
const themeHash = mergedThemeHashRef === null || mergedThemeHashRef === void 0 ? void 0 : mergedThemeHashRef.value;
|
|
if (themeHash) finalThemeHash += `-${themeHash}`;
|
|
if (hashValue) finalThemeHash += `-${hashValue}`;
|
|
const {
|
|
themeOverrides,
|
|
builtinThemeOverrides
|
|
} = props;
|
|
if (themeOverrides) {
|
|
finalThemeHash += `-${murmur2(JSON.stringify(themeOverrides))}`;
|
|
}
|
|
if (builtinThemeOverrides) {
|
|
finalThemeHash += `-${murmur2(JSON.stringify(builtinThemeOverrides))}`;
|
|
}
|
|
themeClassRef.value = finalThemeHash;
|
|
renderCallback = () => {
|
|
const cssVars = cssVarsRef.value;
|
|
let style2 = "";
|
|
for (const key in cssVars) {
|
|
style2 += `${key}: ${cssVars[key]};`;
|
|
}
|
|
c(`.${finalThemeHash}`, style2).mount({
|
|
id: finalThemeHash,
|
|
ssr: ssrAdapter2,
|
|
parent: styleMountTarget
|
|
});
|
|
renderCallback = void 0;
|
|
};
|
|
};
|
|
watchEffect(() => {
|
|
mountStyle();
|
|
});
|
|
return {
|
|
themeClass: themeClassRef,
|
|
onRender: () => {
|
|
renderCallback === null || renderCallback === void 0 ? void 0 : renderCallback();
|
|
}
|
|
};
|
|
}
|
|
const formItemInjectionKey = createInjectionKey("n-form-item");
|
|
function useFormItem(props, {
|
|
defaultSize = "medium",
|
|
mergedSize,
|
|
mergedDisabled
|
|
} = {}) {
|
|
const NFormItem = inject(formItemInjectionKey, null);
|
|
provide(formItemInjectionKey, null);
|
|
const mergedSizeRef = computed(mergedSize ? () => mergedSize(NFormItem) : () => {
|
|
const {
|
|
size: size2
|
|
} = props;
|
|
if (size2) return size2;
|
|
if (NFormItem) {
|
|
const {
|
|
mergedSize: mergedSize2
|
|
} = NFormItem;
|
|
if (mergedSize2.value !== void 0) {
|
|
return mergedSize2.value;
|
|
}
|
|
}
|
|
return defaultSize;
|
|
});
|
|
const mergedDisabledRef = computed(mergedDisabled ? () => mergedDisabled(NFormItem) : () => {
|
|
const {
|
|
disabled
|
|
} = props;
|
|
if (disabled !== void 0) {
|
|
return disabled;
|
|
}
|
|
if (NFormItem) {
|
|
return NFormItem.disabled.value;
|
|
}
|
|
return false;
|
|
});
|
|
const mergedStatusRef = computed(() => {
|
|
const {
|
|
status
|
|
} = props;
|
|
if (status) return status;
|
|
return NFormItem === null || NFormItem === void 0 ? void 0 : NFormItem.mergedValidationStatus.value;
|
|
});
|
|
onBeforeUnmount(() => {
|
|
if (NFormItem) {
|
|
NFormItem.restoreValidation();
|
|
}
|
|
});
|
|
return {
|
|
mergedSizeRef,
|
|
mergedDisabledRef,
|
|
mergedStatusRef,
|
|
nTriggerFormBlur() {
|
|
if (NFormItem) {
|
|
NFormItem.handleContentBlur();
|
|
}
|
|
},
|
|
nTriggerFormChange() {
|
|
if (NFormItem) {
|
|
NFormItem.handleContentChange();
|
|
}
|
|
},
|
|
nTriggerFormFocus() {
|
|
if (NFormItem) {
|
|
NFormItem.handleContentFocus();
|
|
}
|
|
},
|
|
nTriggerFormInput() {
|
|
if (NFormItem) {
|
|
NFormItem.handleContentInput();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
const zhCN$1 = {
|
|
name: "zh-CN",
|
|
global: {
|
|
undo: "撤销",
|
|
redo: "重做",
|
|
confirm: "确认",
|
|
clear: "清除"
|
|
},
|
|
Popconfirm: {
|
|
positiveText: "确认",
|
|
negativeText: "取消"
|
|
},
|
|
Cascader: {
|
|
placeholder: "请选择",
|
|
loading: "加载中",
|
|
loadingRequiredMessage: (label) => `加载全部 ${label} 的子节点后才可选中`
|
|
},
|
|
Time: {
|
|
dateFormat: "yyyy-MM-dd",
|
|
dateTimeFormat: "yyyy-MM-dd HH:mm:ss"
|
|
},
|
|
DatePicker: {
|
|
yearFormat: "yyyy年",
|
|
monthFormat: "MMM",
|
|
dayFormat: "eeeeee",
|
|
yearTypeFormat: "yyyy",
|
|
monthTypeFormat: "yyyy-MM",
|
|
dateFormat: "yyyy-MM-dd",
|
|
dateTimeFormat: "yyyy-MM-dd HH:mm:ss",
|
|
quarterFormat: "yyyy-qqq",
|
|
weekFormat: "YYYY-w周",
|
|
clear: "清除",
|
|
now: "此刻",
|
|
confirm: "确认",
|
|
selectTime: "选择时间",
|
|
selectDate: "选择日期",
|
|
datePlaceholder: "选择日期",
|
|
datetimePlaceholder: "选择日期时间",
|
|
monthPlaceholder: "选择月份",
|
|
yearPlaceholder: "选择年份",
|
|
quarterPlaceholder: "选择季度",
|
|
weekPlaceholder: "选择周",
|
|
startDatePlaceholder: "开始日期",
|
|
endDatePlaceholder: "结束日期",
|
|
startDatetimePlaceholder: "开始日期时间",
|
|
endDatetimePlaceholder: "结束日期时间",
|
|
startMonthPlaceholder: "开始月份",
|
|
endMonthPlaceholder: "结束月份",
|
|
monthBeforeYear: false,
|
|
firstDayOfWeek: 0,
|
|
today: "今天"
|
|
},
|
|
DataTable: {
|
|
checkTableAll: "选择全部表格数据",
|
|
uncheckTableAll: "取消选择全部表格数据",
|
|
confirm: "确认",
|
|
clear: "重置"
|
|
},
|
|
LegacyTransfer: {
|
|
sourceTitle: "源项",
|
|
targetTitle: "目标项"
|
|
},
|
|
Transfer: {
|
|
selectAll: "全选",
|
|
clearAll: "清除",
|
|
unselectAll: "取消全选",
|
|
total: (num) => `共 ${num} 项`,
|
|
selected: (num) => `已选 ${num} 项`
|
|
},
|
|
Empty: {
|
|
description: "无数据"
|
|
},
|
|
Select: {
|
|
placeholder: "请选择"
|
|
},
|
|
TimePicker: {
|
|
placeholder: "请选择时间",
|
|
positiveText: "确认",
|
|
negativeText: "取消",
|
|
now: "此刻",
|
|
clear: "清除"
|
|
},
|
|
Pagination: {
|
|
goto: "跳至",
|
|
selectionSuffix: "页"
|
|
},
|
|
DynamicTags: {
|
|
add: "添加"
|
|
},
|
|
Log: {
|
|
loading: "加载中"
|
|
},
|
|
Input: {
|
|
placeholder: "请输入"
|
|
},
|
|
InputNumber: {
|
|
placeholder: "请输入"
|
|
},
|
|
DynamicInput: {
|
|
create: "添加"
|
|
},
|
|
ThemeEditor: {
|
|
title: "主题编辑器",
|
|
clearAllVars: "清除全部变量",
|
|
clearSearch: "清除搜索",
|
|
filterCompName: "过滤组件名",
|
|
filterVarName: "过滤变量名",
|
|
import: "导入",
|
|
export: "导出",
|
|
restore: "恢复默认"
|
|
},
|
|
Image: {
|
|
tipPrevious: "上一张(←)",
|
|
tipNext: "下一张(→)",
|
|
tipCounterclockwise: "向左旋转",
|
|
tipClockwise: "向右旋转",
|
|
tipZoomOut: "缩小",
|
|
tipZoomIn: "放大",
|
|
tipDownload: "下载",
|
|
tipClose: "关闭(Esc)",
|
|
tipOriginalSize: "缩放到原始尺寸"
|
|
}
|
|
};
|
|
function buildFormatLongFn(args) {
|
|
return (options = {}) => {
|
|
const width = options.width ? String(options.width) : args.defaultWidth;
|
|
const format = args.formats[width] || args.formats[args.defaultWidth];
|
|
return format;
|
|
};
|
|
}
|
|
function buildLocalizeFn(args) {
|
|
return (value, options) => {
|
|
const context = (options == null ? void 0 : options.context) ? String(options.context) : "standalone";
|
|
let valuesArray;
|
|
if (context === "formatting" && args.formattingValues) {
|
|
const defaultWidth = args.defaultFormattingWidth || args.defaultWidth;
|
|
const width = (options == null ? void 0 : options.width) ? String(options.width) : defaultWidth;
|
|
valuesArray = args.formattingValues[width] || args.formattingValues[defaultWidth];
|
|
} else {
|
|
const defaultWidth = args.defaultWidth;
|
|
const width = (options == null ? void 0 : options.width) ? String(options.width) : args.defaultWidth;
|
|
valuesArray = args.values[width] || args.values[defaultWidth];
|
|
}
|
|
const index = args.argumentCallback ? args.argumentCallback(value) : value;
|
|
return valuesArray[index];
|
|
};
|
|
}
|
|
function buildMatchFn(args) {
|
|
return (string, options = {}) => {
|
|
const width = options.width;
|
|
const matchPattern = width && args.matchPatterns[width] || args.matchPatterns[args.defaultMatchWidth];
|
|
const matchResult = string.match(matchPattern);
|
|
if (!matchResult) {
|
|
return null;
|
|
}
|
|
const matchedString = matchResult[0];
|
|
const parsePatterns = width && args.parsePatterns[width] || args.parsePatterns[args.defaultParseWidth];
|
|
const key = Array.isArray(parsePatterns) ? findIndex(parsePatterns, (pattern) => pattern.test(matchedString)) : (
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
|
|
findKey$1(parsePatterns, (pattern) => pattern.test(matchedString))
|
|
);
|
|
let value;
|
|
value = args.valueCallback ? args.valueCallback(key) : key;
|
|
value = options.valueCallback ? (
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
|
|
options.valueCallback(value)
|
|
) : value;
|
|
const rest = string.slice(matchedString.length);
|
|
return { value, rest };
|
|
};
|
|
}
|
|
function findKey$1(object, predicate) {
|
|
for (const key in object) {
|
|
if (Object.prototype.hasOwnProperty.call(object, key) && predicate(object[key])) {
|
|
return key;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
function findIndex(array, predicate) {
|
|
for (let key = 0; key < array.length; key++) {
|
|
if (predicate(array[key])) {
|
|
return key;
|
|
}
|
|
}
|
|
return void 0;
|
|
}
|
|
function buildMatchPatternFn(args) {
|
|
return (string, options = {}) => {
|
|
const matchResult = string.match(args.matchPattern);
|
|
if (!matchResult) return null;
|
|
const matchedString = matchResult[0];
|
|
const parseResult = string.match(args.parsePattern);
|
|
if (!parseResult) return null;
|
|
let value = args.valueCallback ? args.valueCallback(parseResult[0]) : parseResult[0];
|
|
value = options.valueCallback ? options.valueCallback(value) : value;
|
|
const rest = string.slice(matchedString.length);
|
|
return { value, rest };
|
|
};
|
|
}
|
|
function toDate(argument) {
|
|
const argStr = Object.prototype.toString.call(argument);
|
|
if (argument instanceof Date || typeof argument === "object" && argStr === "[object Date]") {
|
|
return new argument.constructor(+argument);
|
|
} else if (typeof argument === "number" || argStr === "[object Number]" || typeof argument === "string" || argStr === "[object String]") {
|
|
return new Date(argument);
|
|
} else {
|
|
return /* @__PURE__ */ new Date(NaN);
|
|
}
|
|
}
|
|
let defaultOptions = {};
|
|
function getDefaultOptions() {
|
|
return defaultOptions;
|
|
}
|
|
function startOfWeek(date, options) {
|
|
var _a, _b, _c, _d;
|
|
const defaultOptions2 = getDefaultOptions();
|
|
const weekStartsOn = (options == null ? void 0 : options.weekStartsOn) ?? ((_b = (_a = options == null ? void 0 : options.locale) == null ? void 0 : _a.options) == null ? void 0 : _b.weekStartsOn) ?? defaultOptions2.weekStartsOn ?? ((_d = (_c = defaultOptions2.locale) == null ? void 0 : _c.options) == null ? void 0 : _d.weekStartsOn) ?? 0;
|
|
const _date = toDate(date);
|
|
const day = _date.getDay();
|
|
const diff = (day < weekStartsOn ? 7 : 0) + day - weekStartsOn;
|
|
_date.setDate(_date.getDate() - diff);
|
|
_date.setHours(0, 0, 0, 0);
|
|
return _date;
|
|
}
|
|
function isSameWeek(dateLeft, dateRight, options) {
|
|
const dateLeftStartOfWeek = startOfWeek(dateLeft, options);
|
|
const dateRightStartOfWeek = startOfWeek(dateRight, options);
|
|
return +dateLeftStartOfWeek === +dateRightStartOfWeek;
|
|
}
|
|
const formatDistanceLocale = {
|
|
lessThanXSeconds: {
|
|
one: "不到 1 秒",
|
|
other: "不到 {{count}} 秒"
|
|
},
|
|
xSeconds: {
|
|
one: "1 秒",
|
|
other: "{{count}} 秒"
|
|
},
|
|
halfAMinute: "半分钟",
|
|
lessThanXMinutes: {
|
|
one: "不到 1 分钟",
|
|
other: "不到 {{count}} 分钟"
|
|
},
|
|
xMinutes: {
|
|
one: "1 分钟",
|
|
other: "{{count}} 分钟"
|
|
},
|
|
xHours: {
|
|
one: "1 小时",
|
|
other: "{{count}} 小时"
|
|
},
|
|
aboutXHours: {
|
|
one: "大约 1 小时",
|
|
other: "大约 {{count}} 小时"
|
|
},
|
|
xDays: {
|
|
one: "1 天",
|
|
other: "{{count}} 天"
|
|
},
|
|
aboutXWeeks: {
|
|
one: "大约 1 个星期",
|
|
other: "大约 {{count}} 个星期"
|
|
},
|
|
xWeeks: {
|
|
one: "1 个星期",
|
|
other: "{{count}} 个星期"
|
|
},
|
|
aboutXMonths: {
|
|
one: "大约 1 个月",
|
|
other: "大约 {{count}} 个月"
|
|
},
|
|
xMonths: {
|
|
one: "1 个月",
|
|
other: "{{count}} 个月"
|
|
},
|
|
aboutXYears: {
|
|
one: "大约 1 年",
|
|
other: "大约 {{count}} 年"
|
|
},
|
|
xYears: {
|
|
one: "1 年",
|
|
other: "{{count}} 年"
|
|
},
|
|
overXYears: {
|
|
one: "超过 1 年",
|
|
other: "超过 {{count}} 年"
|
|
},
|
|
almostXYears: {
|
|
one: "将近 1 年",
|
|
other: "将近 {{count}} 年"
|
|
}
|
|
};
|
|
const formatDistance = (token, count, options) => {
|
|
let result;
|
|
const tokenValue = formatDistanceLocale[token];
|
|
if (typeof tokenValue === "string") {
|
|
result = tokenValue;
|
|
} else if (count === 1) {
|
|
result = tokenValue.one;
|
|
} else {
|
|
result = tokenValue.other.replace("{{count}}", String(count));
|
|
}
|
|
if (options == null ? void 0 : options.addSuffix) {
|
|
if (options.comparison && options.comparison > 0) {
|
|
return result + "内";
|
|
} else {
|
|
return result + "前";
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
const dateFormats = {
|
|
full: "y'年'M'月'd'日' EEEE",
|
|
long: "y'年'M'月'd'日'",
|
|
medium: "yyyy-MM-dd",
|
|
short: "yy-MM-dd"
|
|
};
|
|
const timeFormats = {
|
|
full: "zzzz a h:mm:ss",
|
|
long: "z a h:mm:ss",
|
|
medium: "a h:mm:ss",
|
|
short: "a h:mm"
|
|
};
|
|
const dateTimeFormats = {
|
|
full: "{{date}} {{time}}",
|
|
long: "{{date}} {{time}}",
|
|
medium: "{{date}} {{time}}",
|
|
short: "{{date}} {{time}}"
|
|
};
|
|
const formatLong = {
|
|
date: buildFormatLongFn({
|
|
formats: dateFormats,
|
|
defaultWidth: "full"
|
|
}),
|
|
time: buildFormatLongFn({
|
|
formats: timeFormats,
|
|
defaultWidth: "full"
|
|
}),
|
|
dateTime: buildFormatLongFn({
|
|
formats: dateTimeFormats,
|
|
defaultWidth: "full"
|
|
})
|
|
};
|
|
function checkWeek(date, baseDate, options) {
|
|
const baseFormat = "eeee p";
|
|
if (isSameWeek(date, baseDate, options)) {
|
|
return baseFormat;
|
|
} else if (date.getTime() > baseDate.getTime()) {
|
|
return "'下个'" + baseFormat;
|
|
}
|
|
return "'上个'" + baseFormat;
|
|
}
|
|
const formatRelativeLocale = {
|
|
lastWeek: checkWeek,
|
|
// days before yesterday, maybe in this week or last week
|
|
yesterday: "'昨天' p",
|
|
today: "'今天' p",
|
|
tomorrow: "'明天' p",
|
|
nextWeek: checkWeek,
|
|
// days after tomorrow, maybe in this week or next week
|
|
other: "PP p"
|
|
};
|
|
const formatRelative = (token, date, baseDate, options) => {
|
|
const format = formatRelativeLocale[token];
|
|
if (typeof format === "function") {
|
|
return format(date, baseDate, options);
|
|
}
|
|
return format;
|
|
};
|
|
const eraValues = {
|
|
narrow: ["前", "公元"],
|
|
abbreviated: ["前", "公元"],
|
|
wide: ["公元前", "公元"]
|
|
};
|
|
const quarterValues = {
|
|
narrow: ["1", "2", "3", "4"],
|
|
abbreviated: ["第一季", "第二季", "第三季", "第四季"],
|
|
wide: ["第一季度", "第二季度", "第三季度", "第四季度"]
|
|
};
|
|
const monthValues = {
|
|
narrow: [
|
|
"一",
|
|
"二",
|
|
"三",
|
|
"四",
|
|
"五",
|
|
"六",
|
|
"七",
|
|
"八",
|
|
"九",
|
|
"十",
|
|
"十一",
|
|
"十二"
|
|
],
|
|
abbreviated: [
|
|
"1月",
|
|
"2月",
|
|
"3月",
|
|
"4月",
|
|
"5月",
|
|
"6月",
|
|
"7月",
|
|
"8月",
|
|
"9月",
|
|
"10月",
|
|
"11月",
|
|
"12月"
|
|
],
|
|
wide: [
|
|
"一月",
|
|
"二月",
|
|
"三月",
|
|
"四月",
|
|
"五月",
|
|
"六月",
|
|
"七月",
|
|
"八月",
|
|
"九月",
|
|
"十月",
|
|
"十一月",
|
|
"十二月"
|
|
]
|
|
};
|
|
const dayValues = {
|
|
narrow: ["日", "一", "二", "三", "四", "五", "六"],
|
|
short: ["日", "一", "二", "三", "四", "五", "六"],
|
|
abbreviated: ["周日", "周一", "周二", "周三", "周四", "周五", "周六"],
|
|
wide: ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]
|
|
};
|
|
const dayPeriodValues = {
|
|
narrow: {
|
|
am: "上",
|
|
pm: "下",
|
|
midnight: "凌晨",
|
|
noon: "午",
|
|
morning: "早",
|
|
afternoon: "下午",
|
|
evening: "晚",
|
|
night: "夜"
|
|
},
|
|
abbreviated: {
|
|
am: "上午",
|
|
pm: "下午",
|
|
midnight: "凌晨",
|
|
noon: "中午",
|
|
morning: "早晨",
|
|
afternoon: "中午",
|
|
evening: "晚上",
|
|
night: "夜间"
|
|
},
|
|
wide: {
|
|
am: "上午",
|
|
pm: "下午",
|
|
midnight: "凌晨",
|
|
noon: "中午",
|
|
morning: "早晨",
|
|
afternoon: "中午",
|
|
evening: "晚上",
|
|
night: "夜间"
|
|
}
|
|
};
|
|
const formattingDayPeriodValues = {
|
|
narrow: {
|
|
am: "上",
|
|
pm: "下",
|
|
midnight: "凌晨",
|
|
noon: "午",
|
|
morning: "早",
|
|
afternoon: "下午",
|
|
evening: "晚",
|
|
night: "夜"
|
|
},
|
|
abbreviated: {
|
|
am: "上午",
|
|
pm: "下午",
|
|
midnight: "凌晨",
|
|
noon: "中午",
|
|
morning: "早晨",
|
|
afternoon: "中午",
|
|
evening: "晚上",
|
|
night: "夜间"
|
|
},
|
|
wide: {
|
|
am: "上午",
|
|
pm: "下午",
|
|
midnight: "凌晨",
|
|
noon: "中午",
|
|
morning: "早晨",
|
|
afternoon: "中午",
|
|
evening: "晚上",
|
|
night: "夜间"
|
|
}
|
|
};
|
|
const ordinalNumber = (dirtyNumber, options) => {
|
|
const number = Number(dirtyNumber);
|
|
switch (options == null ? void 0 : options.unit) {
|
|
case "date":
|
|
return number.toString() + "日";
|
|
case "hour":
|
|
return number.toString() + "时";
|
|
case "minute":
|
|
return number.toString() + "分";
|
|
case "second":
|
|
return number.toString() + "秒";
|
|
default:
|
|
return "第 " + number.toString();
|
|
}
|
|
};
|
|
const localize = {
|
|
ordinalNumber,
|
|
era: buildLocalizeFn({
|
|
values: eraValues,
|
|
defaultWidth: "wide"
|
|
}),
|
|
quarter: buildLocalizeFn({
|
|
values: quarterValues,
|
|
defaultWidth: "wide",
|
|
argumentCallback: (quarter) => quarter - 1
|
|
}),
|
|
month: buildLocalizeFn({
|
|
values: monthValues,
|
|
defaultWidth: "wide"
|
|
}),
|
|
day: buildLocalizeFn({
|
|
values: dayValues,
|
|
defaultWidth: "wide"
|
|
}),
|
|
dayPeriod: buildLocalizeFn({
|
|
values: dayPeriodValues,
|
|
defaultWidth: "wide",
|
|
formattingValues: formattingDayPeriodValues,
|
|
defaultFormattingWidth: "wide"
|
|
})
|
|
};
|
|
const matchOrdinalNumberPattern = /^(第\s*)?\d+(日|时|分|秒)?/i;
|
|
const parseOrdinalNumberPattern = /\d+/i;
|
|
const matchEraPatterns = {
|
|
narrow: /^(前)/i,
|
|
abbreviated: /^(前)/i,
|
|
wide: /^(公元前|公元)/i
|
|
};
|
|
const parseEraPatterns = {
|
|
any: [/^(前)/i, /^(公元)/i]
|
|
};
|
|
const matchQuarterPatterns = {
|
|
narrow: /^[1234]/i,
|
|
abbreviated: /^第[一二三四]刻/i,
|
|
wide: /^第[一二三四]刻钟/i
|
|
};
|
|
const parseQuarterPatterns = {
|
|
any: [/(1|一)/i, /(2|二)/i, /(3|三)/i, /(4|四)/i]
|
|
};
|
|
const matchMonthPatterns = {
|
|
narrow: /^(一|二|三|四|五|六|七|八|九|十[二一])/i,
|
|
abbreviated: /^(一|二|三|四|五|六|七|八|九|十[二一]|\d|1[12])月/i,
|
|
wide: /^(一|二|三|四|五|六|七|八|九|十[二一])月/i
|
|
};
|
|
const parseMonthPatterns = {
|
|
narrow: [
|
|
/^一/i,
|
|
/^二/i,
|
|
/^三/i,
|
|
/^四/i,
|
|
/^五/i,
|
|
/^六/i,
|
|
/^七/i,
|
|
/^八/i,
|
|
/^九/i,
|
|
/^十(?!(一|二))/i,
|
|
/^十一/i,
|
|
/^十二/i
|
|
],
|
|
any: [
|
|
/^一|1/i,
|
|
/^二|2/i,
|
|
/^三|3/i,
|
|
/^四|4/i,
|
|
/^五|5/i,
|
|
/^六|6/i,
|
|
/^七|7/i,
|
|
/^八|8/i,
|
|
/^九|9/i,
|
|
/^十(?!(一|二))|10/i,
|
|
/^十一|11/i,
|
|
/^十二|12/i
|
|
]
|
|
};
|
|
const matchDayPatterns = {
|
|
narrow: /^[一二三四五六日]/i,
|
|
short: /^[一二三四五六日]/i,
|
|
abbreviated: /^周[一二三四五六日]/i,
|
|
wide: /^星期[一二三四五六日]/i
|
|
};
|
|
const parseDayPatterns = {
|
|
any: [/日/i, /一/i, /二/i, /三/i, /四/i, /五/i, /六/i]
|
|
};
|
|
const matchDayPeriodPatterns = {
|
|
any: /^(上午?|下午?|午夜|[中正]午|早上?|下午|晚上?|凌晨|)/i
|
|
};
|
|
const parseDayPeriodPatterns = {
|
|
any: {
|
|
am: /^上午?/i,
|
|
pm: /^下午?/i,
|
|
midnight: /^午夜/i,
|
|
noon: /^[中正]午/i,
|
|
morning: /^早上/i,
|
|
afternoon: /^下午/i,
|
|
evening: /^晚上?/i,
|
|
night: /^凌晨/i
|
|
}
|
|
};
|
|
const match = {
|
|
ordinalNumber: buildMatchPatternFn({
|
|
matchPattern: matchOrdinalNumberPattern,
|
|
parsePattern: parseOrdinalNumberPattern,
|
|
valueCallback: (value) => parseInt(value, 10)
|
|
}),
|
|
era: buildMatchFn({
|
|
matchPatterns: matchEraPatterns,
|
|
defaultMatchWidth: "wide",
|
|
parsePatterns: parseEraPatterns,
|
|
defaultParseWidth: "any"
|
|
}),
|
|
quarter: buildMatchFn({
|
|
matchPatterns: matchQuarterPatterns,
|
|
defaultMatchWidth: "wide",
|
|
parsePatterns: parseQuarterPatterns,
|
|
defaultParseWidth: "any",
|
|
valueCallback: (index) => index + 1
|
|
}),
|
|
month: buildMatchFn({
|
|
matchPatterns: matchMonthPatterns,
|
|
defaultMatchWidth: "wide",
|
|
parsePatterns: parseMonthPatterns,
|
|
defaultParseWidth: "any"
|
|
}),
|
|
day: buildMatchFn({
|
|
matchPatterns: matchDayPatterns,
|
|
defaultMatchWidth: "wide",
|
|
parsePatterns: parseDayPatterns,
|
|
defaultParseWidth: "any"
|
|
}),
|
|
dayPeriod: buildMatchFn({
|
|
matchPatterns: matchDayPeriodPatterns,
|
|
defaultMatchWidth: "any",
|
|
parsePatterns: parseDayPeriodPatterns,
|
|
defaultParseWidth: "any"
|
|
})
|
|
};
|
|
const zhCN = {
|
|
code: "zh-CN",
|
|
formatDistance,
|
|
formatLong,
|
|
formatRelative,
|
|
localize,
|
|
match,
|
|
options: {
|
|
weekStartsOn: 1,
|
|
firstWeekContainsDate: 4
|
|
}
|
|
};
|
|
const dateZhCN = {
|
|
name: "zh-CN",
|
|
locale: zhCN
|
|
};
|
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
var freeSelf = typeof self == "object" && self && self.Object === Object && self;
|
|
var root = freeGlobal || freeSelf || Function("return this")();
|
|
var Symbol$1 = root.Symbol;
|
|
var objectProto$a = Object.prototype;
|
|
var hasOwnProperty$a = objectProto$a.hasOwnProperty;
|
|
var nativeObjectToString$1 = objectProto$a.toString;
|
|
var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : void 0;
|
|
function getRawTag(value) {
|
|
var isOwn = hasOwnProperty$a.call(value, symToStringTag$1), tag = value[symToStringTag$1];
|
|
try {
|
|
value[symToStringTag$1] = void 0;
|
|
var unmasked = true;
|
|
} catch (e) {
|
|
}
|
|
var result = nativeObjectToString$1.call(value);
|
|
if (unmasked) {
|
|
if (isOwn) {
|
|
value[symToStringTag$1] = tag;
|
|
} else {
|
|
delete value[symToStringTag$1];
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
var objectProto$9 = Object.prototype;
|
|
var nativeObjectToString = objectProto$9.toString;
|
|
function objectToString(value) {
|
|
return nativeObjectToString.call(value);
|
|
}
|
|
var nullTag = "[object Null]", undefinedTag = "[object Undefined]";
|
|
var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : void 0;
|
|
function baseGetTag(value) {
|
|
if (value == null) {
|
|
return value === void 0 ? undefinedTag : nullTag;
|
|
}
|
|
return symToStringTag && symToStringTag in Object(value) ? getRawTag(value) : objectToString(value);
|
|
}
|
|
function isObjectLike(value) {
|
|
return value != null && typeof value == "object";
|
|
}
|
|
var symbolTag = "[object Symbol]";
|
|
function isSymbol(value) {
|
|
return typeof value == "symbol" || isObjectLike(value) && baseGetTag(value) == symbolTag;
|
|
}
|
|
function arrayMap(array, iteratee) {
|
|
var index = -1, length = array == null ? 0 : array.length, result = Array(length);
|
|
while (++index < length) {
|
|
result[index] = iteratee(array[index], index, array);
|
|
}
|
|
return result;
|
|
}
|
|
var isArray$2 = Array.isArray;
|
|
var symbolProto = Symbol$1 ? Symbol$1.prototype : void 0, symbolToString = symbolProto ? symbolProto.toString : void 0;
|
|
function baseToString(value) {
|
|
if (typeof value == "string") {
|
|
return value;
|
|
}
|
|
if (isArray$2(value)) {
|
|
return arrayMap(value, baseToString) + "";
|
|
}
|
|
if (isSymbol(value)) {
|
|
return symbolToString ? symbolToString.call(value) : "";
|
|
}
|
|
var result = value + "";
|
|
return result == "0" && 1 / value == -Infinity ? "-0" : result;
|
|
}
|
|
function isObject$1(value) {
|
|
var type = typeof value;
|
|
return value != null && (type == "object" || type == "function");
|
|
}
|
|
function identity(value) {
|
|
return value;
|
|
}
|
|
var asyncTag = "[object AsyncFunction]", funcTag$1 = "[object Function]", genTag = "[object GeneratorFunction]", proxyTag = "[object Proxy]";
|
|
function isFunction$1(value) {
|
|
if (!isObject$1(value)) {
|
|
return false;
|
|
}
|
|
var tag = baseGetTag(value);
|
|
return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
|
|
}
|
|
var coreJsData = root["__core-js_shared__"];
|
|
var maskSrcKey = function() {
|
|
var uid2 = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || "");
|
|
return uid2 ? "Symbol(src)_1." + uid2 : "";
|
|
}();
|
|
function isMasked(func) {
|
|
return !!maskSrcKey && maskSrcKey in func;
|
|
}
|
|
var funcProto$2 = Function.prototype;
|
|
var funcToString$2 = funcProto$2.toString;
|
|
function toSource(func) {
|
|
if (func != null) {
|
|
try {
|
|
return funcToString$2.call(func);
|
|
} catch (e) {
|
|
}
|
|
try {
|
|
return func + "";
|
|
} catch (e) {
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
var funcProto$1 = Function.prototype, objectProto$8 = Object.prototype;
|
|
var funcToString$1 = funcProto$1.toString;
|
|
var hasOwnProperty$9 = objectProto$8.hasOwnProperty;
|
|
var reIsNative = RegExp(
|
|
"^" + funcToString$1.call(hasOwnProperty$9).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
|
|
);
|
|
function baseIsNative(value) {
|
|
if (!isObject$1(value) || isMasked(value)) {
|
|
return false;
|
|
}
|
|
var pattern = isFunction$1(value) ? reIsNative : reIsHostCtor;
|
|
return pattern.test(toSource(value));
|
|
}
|
|
function getValue(object, key) {
|
|
return object == null ? void 0 : object[key];
|
|
}
|
|
function getNative(object, key) {
|
|
var value = getValue(object, key);
|
|
return baseIsNative(value) ? value : void 0;
|
|
}
|
|
var objectCreate = Object.create;
|
|
var baseCreate = /* @__PURE__ */ function() {
|
|
function object() {
|
|
}
|
|
return function(proto) {
|
|
if (!isObject$1(proto)) {
|
|
return {};
|
|
}
|
|
if (objectCreate) {
|
|
return objectCreate(proto);
|
|
}
|
|
object.prototype = proto;
|
|
var result = new object();
|
|
object.prototype = void 0;
|
|
return result;
|
|
};
|
|
}();
|
|
function apply(func, thisArg, args) {
|
|
switch (args.length) {
|
|
case 0:
|
|
return func.call(thisArg);
|
|
case 1:
|
|
return func.call(thisArg, args[0]);
|
|
case 2:
|
|
return func.call(thisArg, args[0], args[1]);
|
|
case 3:
|
|
return func.call(thisArg, args[0], args[1], args[2]);
|
|
}
|
|
return func.apply(thisArg, args);
|
|
}
|
|
function copyArray(source, array) {
|
|
var index = -1, length = source.length;
|
|
array || (array = Array(length));
|
|
while (++index < length) {
|
|
array[index] = source[index];
|
|
}
|
|
return array;
|
|
}
|
|
var HOT_COUNT = 800, HOT_SPAN = 16;
|
|
var nativeNow = Date.now;
|
|
function shortOut(func) {
|
|
var count = 0, lastCalled = 0;
|
|
return function() {
|
|
var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
|
|
lastCalled = stamp;
|
|
if (remaining > 0) {
|
|
if (++count >= HOT_COUNT) {
|
|
return arguments[0];
|
|
}
|
|
} else {
|
|
count = 0;
|
|
}
|
|
return func.apply(void 0, arguments);
|
|
};
|
|
}
|
|
function constant(value) {
|
|
return function() {
|
|
return value;
|
|
};
|
|
}
|
|
var defineProperty = function() {
|
|
try {
|
|
var func = getNative(Object, "defineProperty");
|
|
func({}, "", {});
|
|
return func;
|
|
} catch (e) {
|
|
}
|
|
}();
|
|
var baseSetToString = !defineProperty ? identity : function(func, string) {
|
|
return defineProperty(func, "toString", {
|
|
"configurable": true,
|
|
"enumerable": false,
|
|
"value": constant(string),
|
|
"writable": true
|
|
});
|
|
};
|
|
var setToString = shortOut(baseSetToString);
|
|
var MAX_SAFE_INTEGER$1 = 9007199254740991;
|
|
var reIsUint = /^(?:0|[1-9]\d*)$/;
|
|
function isIndex(value, length) {
|
|
var type = typeof value;
|
|
length = length == null ? MAX_SAFE_INTEGER$1 : length;
|
|
return !!length && (type == "number" || type != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length);
|
|
}
|
|
function baseAssignValue(object, key, value) {
|
|
if (key == "__proto__" && defineProperty) {
|
|
defineProperty(object, key, {
|
|
"configurable": true,
|
|
"enumerable": true,
|
|
"value": value,
|
|
"writable": true
|
|
});
|
|
} else {
|
|
object[key] = value;
|
|
}
|
|
}
|
|
function eq(value, other) {
|
|
return value === other || value !== value && other !== other;
|
|
}
|
|
var objectProto$7 = Object.prototype;
|
|
var hasOwnProperty$8 = objectProto$7.hasOwnProperty;
|
|
function assignValue(object, key, value) {
|
|
var objValue = object[key];
|
|
if (!(hasOwnProperty$8.call(object, key) && eq(objValue, value)) || value === void 0 && !(key in object)) {
|
|
baseAssignValue(object, key, value);
|
|
}
|
|
}
|
|
function copyObject(source, props, object, customizer) {
|
|
var isNew = !object;
|
|
object || (object = {});
|
|
var index = -1, length = props.length;
|
|
while (++index < length) {
|
|
var key = props[index];
|
|
var newValue = void 0;
|
|
if (newValue === void 0) {
|
|
newValue = source[key];
|
|
}
|
|
if (isNew) {
|
|
baseAssignValue(object, key, newValue);
|
|
} else {
|
|
assignValue(object, key, newValue);
|
|
}
|
|
}
|
|
return object;
|
|
}
|
|
var nativeMax = Math.max;
|
|
function overRest(func, start, transform) {
|
|
start = nativeMax(start === void 0 ? func.length - 1 : start, 0);
|
|
return function() {
|
|
var args = arguments, index = -1, length = nativeMax(args.length - start, 0), array = Array(length);
|
|
while (++index < length) {
|
|
array[index] = args[start + index];
|
|
}
|
|
index = -1;
|
|
var otherArgs = Array(start + 1);
|
|
while (++index < start) {
|
|
otherArgs[index] = args[index];
|
|
}
|
|
otherArgs[start] = transform(array);
|
|
return apply(func, this, otherArgs);
|
|
};
|
|
}
|
|
function baseRest(func, start) {
|
|
return setToString(overRest(func, start, identity), func + "");
|
|
}
|
|
var MAX_SAFE_INTEGER = 9007199254740991;
|
|
function isLength(value) {
|
|
return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
|
|
}
|
|
function isArrayLike(value) {
|
|
return value != null && isLength(value.length) && !isFunction$1(value);
|
|
}
|
|
function isIterateeCall(value, index, object) {
|
|
if (!isObject$1(object)) {
|
|
return false;
|
|
}
|
|
var type = typeof index;
|
|
if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) {
|
|
return eq(object[index], value);
|
|
}
|
|
return false;
|
|
}
|
|
function createAssigner(assigner) {
|
|
return baseRest(function(object, sources) {
|
|
var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : void 0, guard = length > 2 ? sources[2] : void 0;
|
|
customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : void 0;
|
|
if (guard && isIterateeCall(sources[0], sources[1], guard)) {
|
|
customizer = length < 3 ? void 0 : customizer;
|
|
length = 1;
|
|
}
|
|
object = Object(object);
|
|
while (++index < length) {
|
|
var source = sources[index];
|
|
if (source) {
|
|
assigner(object, source, index, customizer);
|
|
}
|
|
}
|
|
return object;
|
|
});
|
|
}
|
|
var objectProto$6 = Object.prototype;
|
|
function isPrototype(value) {
|
|
var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto$6;
|
|
return value === proto;
|
|
}
|
|
function baseTimes(n, iteratee) {
|
|
var index = -1, result = Array(n);
|
|
while (++index < n) {
|
|
result[index] = iteratee(index);
|
|
}
|
|
return result;
|
|
}
|
|
var argsTag$1 = "[object Arguments]";
|
|
function baseIsArguments(value) {
|
|
return isObjectLike(value) && baseGetTag(value) == argsTag$1;
|
|
}
|
|
var objectProto$5 = Object.prototype;
|
|
var hasOwnProperty$7 = objectProto$5.hasOwnProperty;
|
|
var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
|
|
var isArguments = baseIsArguments(/* @__PURE__ */ function() {
|
|
return arguments;
|
|
}()) ? baseIsArguments : function(value) {
|
|
return isObjectLike(value) && hasOwnProperty$7.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
|
|
};
|
|
function stubFalse() {
|
|
return false;
|
|
}
|
|
var freeExports$2 = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
var freeModule$2 = freeExports$2 && typeof module == "object" && module && !module.nodeType && module;
|
|
var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
|
|
var Buffer$2 = moduleExports$2 ? root.Buffer : void 0;
|
|
var nativeIsBuffer = Buffer$2 ? Buffer$2.isBuffer : void 0;
|
|
var isBuffer$1 = nativeIsBuffer || stubFalse;
|
|
var argsTag = "[object Arguments]", arrayTag = "[object Array]", boolTag = "[object Boolean]", dateTag = "[object Date]", errorTag = "[object Error]", funcTag = "[object Function]", mapTag = "[object Map]", numberTag = "[object Number]", objectTag$1 = "[object Object]", regexpTag = "[object RegExp]", setTag = "[object Set]", stringTag = "[object String]", weakMapTag = "[object WeakMap]";
|
|
var arrayBufferTag = "[object ArrayBuffer]", dataViewTag = "[object DataView]", float32Tag = "[object Float32Array]", float64Tag = "[object Float64Array]", int8Tag = "[object Int8Array]", int16Tag = "[object Int16Array]", int32Tag = "[object Int32Array]", uint8Tag = "[object Uint8Array]", uint8ClampedTag = "[object Uint8ClampedArray]", uint16Tag = "[object Uint16Array]", uint32Tag = "[object Uint32Array]";
|
|
var typedArrayTags = {};
|
|
typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
|
|
typedArrayTags[argsTag] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
|
|
function baseIsTypedArray(value) {
|
|
return isObjectLike(value) && isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
|
|
}
|
|
function baseUnary(func) {
|
|
return function(value) {
|
|
return func(value);
|
|
};
|
|
}
|
|
var freeExports$1 = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
var freeModule$1 = freeExports$1 && typeof module == "object" && module && !module.nodeType && module;
|
|
var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
|
|
var freeProcess = moduleExports$1 && freeGlobal.process;
|
|
var nodeUtil = function() {
|
|
try {
|
|
var types = freeModule$1 && freeModule$1.require && freeModule$1.require("util").types;
|
|
if (types) {
|
|
return types;
|
|
}
|
|
return freeProcess && freeProcess.binding && freeProcess.binding("util");
|
|
} catch (e) {
|
|
}
|
|
}();
|
|
var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
|
|
var isTypedArray$1 = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
|
|
var objectProto$4 = Object.prototype;
|
|
var hasOwnProperty$6 = objectProto$4.hasOwnProperty;
|
|
function arrayLikeKeys(value, inherited) {
|
|
var isArr = isArray$2(value), isArg = !isArr && isArguments(value), isBuff = !isArr && !isArg && isBuffer$1(value), isType = !isArr && !isArg && !isBuff && isTypedArray$1(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes(value.length, String) : [], length = result.length;
|
|
for (var key in value) {
|
|
if ((inherited || hasOwnProperty$6.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
|
|
(key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
|
|
isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
|
|
isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
|
|
isIndex(key, length)))) {
|
|
result.push(key);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function overArg(func, transform) {
|
|
return function(arg) {
|
|
return func(transform(arg));
|
|
};
|
|
}
|
|
function nativeKeysIn(object) {
|
|
var result = [];
|
|
if (object != null) {
|
|
for (var key in Object(object)) {
|
|
result.push(key);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
var objectProto$3 = Object.prototype;
|
|
var hasOwnProperty$5 = objectProto$3.hasOwnProperty;
|
|
function baseKeysIn(object) {
|
|
if (!isObject$1(object)) {
|
|
return nativeKeysIn(object);
|
|
}
|
|
var isProto = isPrototype(object), result = [];
|
|
for (var key in object) {
|
|
if (!(key == "constructor" && (isProto || !hasOwnProperty$5.call(object, key)))) {
|
|
result.push(key);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function keysIn(object) {
|
|
return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
|
|
}
|
|
var nativeCreate = getNative(Object, "create");
|
|
function hashClear() {
|
|
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
this.size = 0;
|
|
}
|
|
function hashDelete(key) {
|
|
var result = this.has(key) && delete this.__data__[key];
|
|
this.size -= result ? 1 : 0;
|
|
return result;
|
|
}
|
|
var HASH_UNDEFINED$1 = "__lodash_hash_undefined__";
|
|
var objectProto$2 = Object.prototype;
|
|
var hasOwnProperty$4 = objectProto$2.hasOwnProperty;
|
|
function hashGet(key) {
|
|
var data = this.__data__;
|
|
if (nativeCreate) {
|
|
var result = data[key];
|
|
return result === HASH_UNDEFINED$1 ? void 0 : result;
|
|
}
|
|
return hasOwnProperty$4.call(data, key) ? data[key] : void 0;
|
|
}
|
|
var objectProto$1 = Object.prototype;
|
|
var hasOwnProperty$3 = objectProto$1.hasOwnProperty;
|
|
function hashHas(key) {
|
|
var data = this.__data__;
|
|
return nativeCreate ? data[key] !== void 0 : hasOwnProperty$3.call(data, key);
|
|
}
|
|
var HASH_UNDEFINED = "__lodash_hash_undefined__";
|
|
function hashSet(key, value) {
|
|
var data = this.__data__;
|
|
this.size += this.has(key) ? 0 : 1;
|
|
data[key] = nativeCreate && value === void 0 ? HASH_UNDEFINED : value;
|
|
return this;
|
|
}
|
|
function Hash(entries) {
|
|
var index = -1, length = entries == null ? 0 : entries.length;
|
|
this.clear();
|
|
while (++index < length) {
|
|
var entry = entries[index];
|
|
this.set(entry[0], entry[1]);
|
|
}
|
|
}
|
|
Hash.prototype.clear = hashClear;
|
|
Hash.prototype["delete"] = hashDelete;
|
|
Hash.prototype.get = hashGet;
|
|
Hash.prototype.has = hashHas;
|
|
Hash.prototype.set = hashSet;
|
|
function listCacheClear() {
|
|
this.__data__ = [];
|
|
this.size = 0;
|
|
}
|
|
function assocIndexOf(array, key) {
|
|
var length = array.length;
|
|
while (length--) {
|
|
if (eq(array[length][0], key)) {
|
|
return length;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
var arrayProto = Array.prototype;
|
|
var splice = arrayProto.splice;
|
|
function listCacheDelete(key) {
|
|
var data = this.__data__, index = assocIndexOf(data, key);
|
|
if (index < 0) {
|
|
return false;
|
|
}
|
|
var lastIndex = data.length - 1;
|
|
if (index == lastIndex) {
|
|
data.pop();
|
|
} else {
|
|
splice.call(data, index, 1);
|
|
}
|
|
--this.size;
|
|
return true;
|
|
}
|
|
function listCacheGet(key) {
|
|
var data = this.__data__, index = assocIndexOf(data, key);
|
|
return index < 0 ? void 0 : data[index][1];
|
|
}
|
|
function listCacheHas(key) {
|
|
return assocIndexOf(this.__data__, key) > -1;
|
|
}
|
|
function listCacheSet(key, value) {
|
|
var data = this.__data__, index = assocIndexOf(data, key);
|
|
if (index < 0) {
|
|
++this.size;
|
|
data.push([key, value]);
|
|
} else {
|
|
data[index][1] = value;
|
|
}
|
|
return this;
|
|
}
|
|
function ListCache(entries) {
|
|
var index = -1, length = entries == null ? 0 : entries.length;
|
|
this.clear();
|
|
while (++index < length) {
|
|
var entry = entries[index];
|
|
this.set(entry[0], entry[1]);
|
|
}
|
|
}
|
|
ListCache.prototype.clear = listCacheClear;
|
|
ListCache.prototype["delete"] = listCacheDelete;
|
|
ListCache.prototype.get = listCacheGet;
|
|
ListCache.prototype.has = listCacheHas;
|
|
ListCache.prototype.set = listCacheSet;
|
|
var Map$1 = getNative(root, "Map");
|
|
function mapCacheClear() {
|
|
this.size = 0;
|
|
this.__data__ = {
|
|
"hash": new Hash(),
|
|
"map": new (Map$1 || ListCache)(),
|
|
"string": new Hash()
|
|
};
|
|
}
|
|
function isKeyable(value) {
|
|
var type = typeof value;
|
|
return type == "string" || type == "number" || type == "symbol" || type == "boolean" ? value !== "__proto__" : value === null;
|
|
}
|
|
function getMapData(map, key) {
|
|
var data = map.__data__;
|
|
return isKeyable(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
|
|
}
|
|
function mapCacheDelete(key) {
|
|
var result = getMapData(this, key)["delete"](key);
|
|
this.size -= result ? 1 : 0;
|
|
return result;
|
|
}
|
|
function mapCacheGet(key) {
|
|
return getMapData(this, key).get(key);
|
|
}
|
|
function mapCacheHas(key) {
|
|
return getMapData(this, key).has(key);
|
|
}
|
|
function mapCacheSet(key, value) {
|
|
var data = getMapData(this, key), size2 = data.size;
|
|
data.set(key, value);
|
|
this.size += data.size == size2 ? 0 : 1;
|
|
return this;
|
|
}
|
|
function MapCache(entries) {
|
|
var index = -1, length = entries == null ? 0 : entries.length;
|
|
this.clear();
|
|
while (++index < length) {
|
|
var entry = entries[index];
|
|
this.set(entry[0], entry[1]);
|
|
}
|
|
}
|
|
MapCache.prototype.clear = mapCacheClear;
|
|
MapCache.prototype["delete"] = mapCacheDelete;
|
|
MapCache.prototype.get = mapCacheGet;
|
|
MapCache.prototype.has = mapCacheHas;
|
|
MapCache.prototype.set = mapCacheSet;
|
|
function toString$1(value) {
|
|
return value == null ? "" : baseToString(value);
|
|
}
|
|
var getPrototype = overArg(Object.getPrototypeOf, Object);
|
|
var objectTag = "[object Object]";
|
|
var funcProto = Function.prototype, objectProto = Object.prototype;
|
|
var funcToString = funcProto.toString;
|
|
var hasOwnProperty$2 = objectProto.hasOwnProperty;
|
|
var objectCtorString = funcToString.call(Object);
|
|
function isPlainObject$1(value) {
|
|
if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
|
|
return false;
|
|
}
|
|
var proto = getPrototype(value);
|
|
if (proto === null) {
|
|
return true;
|
|
}
|
|
var Ctor = hasOwnProperty$2.call(proto, "constructor") && proto.constructor;
|
|
return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString.call(Ctor) == objectCtorString;
|
|
}
|
|
function baseSlice(array, start, end) {
|
|
var index = -1, length = array.length;
|
|
if (start < 0) {
|
|
start = -start > length ? 0 : length + start;
|
|
}
|
|
end = end > length ? length : end;
|
|
if (end < 0) {
|
|
end += length;
|
|
}
|
|
length = start > end ? 0 : end - start >>> 0;
|
|
start >>>= 0;
|
|
var result = Array(length);
|
|
while (++index < length) {
|
|
result[index] = array[index + start];
|
|
}
|
|
return result;
|
|
}
|
|
function castSlice(array, start, end) {
|
|
var length = array.length;
|
|
end = end === void 0 ? length : end;
|
|
return false ? array : baseSlice(array, start, end);
|
|
}
|
|
var rsAstralRange$1 = "\\ud800-\\udfff", rsComboMarksRange$1 = "\\u0300-\\u036f", reComboHalfMarksRange$1 = "\\ufe20-\\ufe2f", rsComboSymbolsRange$1 = "\\u20d0-\\u20ff", rsComboRange$1 = rsComboMarksRange$1 + reComboHalfMarksRange$1 + rsComboSymbolsRange$1, rsVarRange$1 = "\\ufe0e\\ufe0f";
|
|
var rsZWJ$1 = "\\u200d";
|
|
var reHasUnicode = RegExp("[" + rsZWJ$1 + rsAstralRange$1 + rsComboRange$1 + rsVarRange$1 + "]");
|
|
function hasUnicode(string) {
|
|
return reHasUnicode.test(string);
|
|
}
|
|
function asciiToArray(string) {
|
|
return string.split("");
|
|
}
|
|
var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = "\\ufe0e\\ufe0f";
|
|
var rsAstral = "[" + rsAstralRange + "]", rsCombo = "[" + rsComboRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsZWJ = "\\u200d";
|
|
var reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
|
|
var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
|
|
function unicodeToArray(string) {
|
|
return string.match(reUnicode) || [];
|
|
}
|
|
function stringToArray(string) {
|
|
return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
|
|
}
|
|
function createCaseFirst(methodName) {
|
|
return function(string) {
|
|
string = toString$1(string);
|
|
var strSymbols = hasUnicode(string) ? stringToArray(string) : void 0;
|
|
var chr = strSymbols ? strSymbols[0] : string.charAt(0);
|
|
var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
|
|
return chr[methodName]() + trailing;
|
|
};
|
|
}
|
|
var upperFirst = createCaseFirst("toUpperCase");
|
|
function stackClear() {
|
|
this.__data__ = new ListCache();
|
|
this.size = 0;
|
|
}
|
|
function stackDelete(key) {
|
|
var data = this.__data__, result = data["delete"](key);
|
|
this.size = data.size;
|
|
return result;
|
|
}
|
|
function stackGet(key) {
|
|
return this.__data__.get(key);
|
|
}
|
|
function stackHas(key) {
|
|
return this.__data__.has(key);
|
|
}
|
|
var LARGE_ARRAY_SIZE = 200;
|
|
function stackSet(key, value) {
|
|
var data = this.__data__;
|
|
if (data instanceof ListCache) {
|
|
var pairs = data.__data__;
|
|
if (!Map$1 || pairs.length < LARGE_ARRAY_SIZE - 1) {
|
|
pairs.push([key, value]);
|
|
this.size = ++data.size;
|
|
return this;
|
|
}
|
|
data = this.__data__ = new MapCache(pairs);
|
|
}
|
|
data.set(key, value);
|
|
this.size = data.size;
|
|
return this;
|
|
}
|
|
function Stack(entries) {
|
|
var data = this.__data__ = new ListCache(entries);
|
|
this.size = data.size;
|
|
}
|
|
Stack.prototype.clear = stackClear;
|
|
Stack.prototype["delete"] = stackDelete;
|
|
Stack.prototype.get = stackGet;
|
|
Stack.prototype.has = stackHas;
|
|
Stack.prototype.set = stackSet;
|
|
var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
|
|
var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
|
|
var moduleExports = freeModule && freeModule.exports === freeExports;
|
|
var Buffer$1 = moduleExports ? root.Buffer : void 0;
|
|
Buffer$1 ? Buffer$1.allocUnsafe : void 0;
|
|
function cloneBuffer(buffer2, isDeep) {
|
|
{
|
|
return buffer2.slice();
|
|
}
|
|
}
|
|
var Uint8Array$1 = root.Uint8Array;
|
|
function cloneArrayBuffer(arrayBuffer) {
|
|
var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
|
|
new Uint8Array$1(result).set(new Uint8Array$1(arrayBuffer));
|
|
return result;
|
|
}
|
|
function cloneTypedArray(typedArray, isDeep) {
|
|
var buffer2 = cloneArrayBuffer(typedArray.buffer);
|
|
return new typedArray.constructor(buffer2, typedArray.byteOffset, typedArray.length);
|
|
}
|
|
function initCloneObject(object) {
|
|
return typeof object.constructor == "function" && !isPrototype(object) ? baseCreate(getPrototype(object)) : {};
|
|
}
|
|
function createBaseFor(fromRight) {
|
|
return function(object, iteratee, keysFunc) {
|
|
var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length;
|
|
while (length--) {
|
|
var key = props[++index];
|
|
if (iteratee(iterable[key], key, iterable) === false) {
|
|
break;
|
|
}
|
|
}
|
|
return object;
|
|
};
|
|
}
|
|
var baseFor = createBaseFor();
|
|
function assignMergeValue(object, key, value) {
|
|
if (value !== void 0 && !eq(object[key], value) || value === void 0 && !(key in object)) {
|
|
baseAssignValue(object, key, value);
|
|
}
|
|
}
|
|
function isArrayLikeObject(value) {
|
|
return isObjectLike(value) && isArrayLike(value);
|
|
}
|
|
function safeGet(object, key) {
|
|
if (key === "constructor" && typeof object[key] === "function") {
|
|
return;
|
|
}
|
|
if (key == "__proto__") {
|
|
return;
|
|
}
|
|
return object[key];
|
|
}
|
|
function toPlainObject(value) {
|
|
return copyObject(value, keysIn(value));
|
|
}
|
|
function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack2) {
|
|
var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack2.get(srcValue);
|
|
if (stacked) {
|
|
assignMergeValue(object, key, stacked);
|
|
return;
|
|
}
|
|
var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack2) : void 0;
|
|
var isCommon = newValue === void 0;
|
|
if (isCommon) {
|
|
var isArr = isArray$2(srcValue), isBuff = !isArr && isBuffer$1(srcValue), isTyped = !isArr && !isBuff && isTypedArray$1(srcValue);
|
|
newValue = srcValue;
|
|
if (isArr || isBuff || isTyped) {
|
|
if (isArray$2(objValue)) {
|
|
newValue = objValue;
|
|
} else if (isArrayLikeObject(objValue)) {
|
|
newValue = copyArray(objValue);
|
|
} else if (isBuff) {
|
|
isCommon = false;
|
|
newValue = cloneBuffer(srcValue);
|
|
} else if (isTyped) {
|
|
isCommon = false;
|
|
newValue = cloneTypedArray(srcValue);
|
|
} else {
|
|
newValue = [];
|
|
}
|
|
} else if (isPlainObject$1(srcValue) || isArguments(srcValue)) {
|
|
newValue = objValue;
|
|
if (isArguments(objValue)) {
|
|
newValue = toPlainObject(objValue);
|
|
} else if (!isObject$1(objValue) || isFunction$1(objValue)) {
|
|
newValue = initCloneObject(srcValue);
|
|
}
|
|
} else {
|
|
isCommon = false;
|
|
}
|
|
}
|
|
if (isCommon) {
|
|
stack2.set(srcValue, newValue);
|
|
mergeFunc(newValue, srcValue, srcIndex, customizer, stack2);
|
|
stack2["delete"](srcValue);
|
|
}
|
|
assignMergeValue(object, key, newValue);
|
|
}
|
|
function baseMerge(object, source, srcIndex, customizer, stack2) {
|
|
if (object === source) {
|
|
return;
|
|
}
|
|
baseFor(source, function(srcValue, key) {
|
|
stack2 || (stack2 = new Stack());
|
|
if (isObject$1(srcValue)) {
|
|
baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack2);
|
|
} else {
|
|
var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack2) : void 0;
|
|
if (newValue === void 0) {
|
|
newValue = srcValue;
|
|
}
|
|
assignMergeValue(object, key, newValue);
|
|
}
|
|
}, keysIn);
|
|
}
|
|
var merge$1 = createAssigner(function(object, source, srcIndex) {
|
|
baseMerge(object, source, srcIndex);
|
|
});
|
|
const cssrAnchorMetaName = "naive-ui-style";
|
|
function useRtl(mountId, rtlStateRef, clsPrefixRef) {
|
|
if (!rtlStateRef) return void 0;
|
|
const ssrAdapter2 = useSsrAdapter();
|
|
const componentRtlStateRef = computed(() => {
|
|
const {
|
|
value: rtlState
|
|
} = rtlStateRef;
|
|
if (!rtlState) {
|
|
return void 0;
|
|
}
|
|
const componentRtlState = rtlState[mountId];
|
|
if (!componentRtlState) {
|
|
return void 0;
|
|
}
|
|
return componentRtlState;
|
|
});
|
|
const NConfigProvider = inject(configProviderInjectionKey, null);
|
|
const mountStyle = () => {
|
|
watchEffect(() => {
|
|
const {
|
|
value: clsPrefix
|
|
} = clsPrefixRef;
|
|
const id = `${clsPrefix}${mountId}Rtl`;
|
|
if (exists(id, ssrAdapter2)) return;
|
|
const {
|
|
value: componentRtlState
|
|
} = componentRtlStateRef;
|
|
if (!componentRtlState) return;
|
|
componentRtlState.style.mount({
|
|
id,
|
|
head: true,
|
|
anchorMetaName: cssrAnchorMetaName,
|
|
props: {
|
|
bPrefix: clsPrefix ? `.${clsPrefix}-` : void 0
|
|
},
|
|
ssr: ssrAdapter2,
|
|
parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
|
|
});
|
|
});
|
|
};
|
|
if (ssrAdapter2) {
|
|
mountStyle();
|
|
} else {
|
|
onBeforeMount(mountStyle);
|
|
}
|
|
return componentRtlStateRef;
|
|
}
|
|
const commonVariables$3 = {
|
|
fontFamily: 'v-sans, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"',
|
|
fontFamilyMono: "v-mono, SFMono-Regular, Menlo, Consolas, Courier, monospace",
|
|
fontWeight: "400",
|
|
fontWeightStrong: "500",
|
|
cubicBezierEaseInOut: "cubic-bezier(.4, 0, .2, 1)",
|
|
cubicBezierEaseOut: "cubic-bezier(0, 0, .2, 1)",
|
|
cubicBezierEaseIn: "cubic-bezier(.4, 0, 1, 1)",
|
|
borderRadius: "3px",
|
|
borderRadiusSmall: "2px",
|
|
fontSize: "14px",
|
|
fontSizeMini: "12px",
|
|
fontSizeTiny: "12px",
|
|
fontSizeSmall: "14px",
|
|
fontSizeMedium: "14px",
|
|
fontSizeLarge: "15px",
|
|
fontSizeHuge: "16px",
|
|
lineHeight: "1.6",
|
|
heightMini: "16px",
|
|
// private now, it's too small
|
|
heightTiny: "22px",
|
|
heightSmall: "28px",
|
|
heightMedium: "34px",
|
|
heightLarge: "40px",
|
|
heightHuge: "46px"
|
|
};
|
|
const {
|
|
fontSize,
|
|
fontFamily,
|
|
lineHeight
|
|
} = commonVariables$3;
|
|
const globalStyle = c("body", `
|
|
margin: 0;
|
|
font-size: ${fontSize};
|
|
font-family: ${fontFamily};
|
|
line-height: ${lineHeight};
|
|
-webkit-text-size-adjust: 100%;
|
|
-webkit-tap-highlight-color: transparent;
|
|
`, [c("input", `
|
|
font-family: inherit;
|
|
font-size: inherit;
|
|
`)]);
|
|
function useStyle(mountId, style2, clsPrefixRef) {
|
|
if (!style2) {
|
|
return;
|
|
}
|
|
const ssrAdapter2 = useSsrAdapter();
|
|
const NConfigProvider = inject(configProviderInjectionKey, null);
|
|
const mountStyle = () => {
|
|
const clsPrefix = clsPrefixRef.value;
|
|
style2.mount({
|
|
id: clsPrefix === void 0 ? mountId : clsPrefix + mountId,
|
|
head: true,
|
|
anchorMetaName: cssrAnchorMetaName,
|
|
props: {
|
|
bPrefix: clsPrefix ? `.${clsPrefix}-` : void 0
|
|
},
|
|
ssr: ssrAdapter2,
|
|
parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
|
|
});
|
|
if (!(NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.preflightStyleDisabled)) {
|
|
globalStyle.mount({
|
|
id: "n-global",
|
|
head: true,
|
|
anchorMetaName: cssrAnchorMetaName,
|
|
ssr: ssrAdapter2,
|
|
parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
|
|
});
|
|
}
|
|
};
|
|
if (ssrAdapter2) {
|
|
mountStyle();
|
|
} else {
|
|
onBeforeMount(mountStyle);
|
|
}
|
|
}
|
|
function createTheme(theme) {
|
|
return theme;
|
|
}
|
|
function useTheme(resolveId, mountId, style2, defaultTheme, props, clsPrefixRef) {
|
|
const ssrAdapter2 = useSsrAdapter();
|
|
const NConfigProvider = inject(configProviderInjectionKey, null);
|
|
if (style2) {
|
|
const mountStyle = () => {
|
|
const clsPrefix = clsPrefixRef === null || clsPrefixRef === void 0 ? void 0 : clsPrefixRef.value;
|
|
style2.mount({
|
|
id: clsPrefix === void 0 ? mountId : clsPrefix + mountId,
|
|
head: true,
|
|
props: {
|
|
bPrefix: clsPrefix ? `.${clsPrefix}-` : void 0
|
|
},
|
|
anchorMetaName: cssrAnchorMetaName,
|
|
ssr: ssrAdapter2,
|
|
parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
|
|
});
|
|
if (!(NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.preflightStyleDisabled)) {
|
|
globalStyle.mount({
|
|
id: "n-global",
|
|
head: true,
|
|
anchorMetaName: cssrAnchorMetaName,
|
|
ssr: ssrAdapter2,
|
|
parent: NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget
|
|
});
|
|
}
|
|
};
|
|
if (ssrAdapter2) {
|
|
mountStyle();
|
|
} else {
|
|
onBeforeMount(mountStyle);
|
|
}
|
|
}
|
|
const mergedThemeRef = computed(() => {
|
|
var _a;
|
|
const {
|
|
theme: {
|
|
common: selfCommon,
|
|
self: self2,
|
|
peers = {}
|
|
} = {},
|
|
themeOverrides: selfOverrides = {},
|
|
builtinThemeOverrides: builtinOverrides = {}
|
|
} = props;
|
|
const {
|
|
common: selfCommonOverrides,
|
|
peers: peersOverrides
|
|
} = selfOverrides;
|
|
const {
|
|
common: globalCommon = void 0,
|
|
[resolveId]: {
|
|
common: globalSelfCommon = void 0,
|
|
self: globalSelf = void 0,
|
|
peers: globalPeers = {}
|
|
} = {}
|
|
} = (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeRef.value) || {};
|
|
const {
|
|
common: globalCommonOverrides = void 0,
|
|
[resolveId]: globalSelfOverrides = {}
|
|
} = (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeOverridesRef.value) || {};
|
|
const {
|
|
common: globalSelfCommonOverrides,
|
|
peers: globalPeersOverrides = {}
|
|
} = globalSelfOverrides;
|
|
const mergedCommon = merge$1({}, selfCommon || globalSelfCommon || globalCommon || defaultTheme.common, globalCommonOverrides, globalSelfCommonOverrides, selfCommonOverrides);
|
|
const mergedSelf = merge$1(
|
|
// {}, executed every time, no need for empty obj
|
|
(_a = self2 || globalSelf || defaultTheme.self) === null || _a === void 0 ? void 0 : _a(mergedCommon),
|
|
builtinOverrides,
|
|
globalSelfOverrides,
|
|
selfOverrides
|
|
);
|
|
return {
|
|
common: mergedCommon,
|
|
self: mergedSelf,
|
|
peers: merge$1({}, defaultTheme.peers, globalPeers, peers),
|
|
peerOverrides: merge$1({}, builtinOverrides.peers, globalPeersOverrides, peersOverrides)
|
|
};
|
|
});
|
|
return mergedThemeRef;
|
|
}
|
|
useTheme.props = {
|
|
theme: Object,
|
|
themeOverrides: Object,
|
|
builtinThemeOverrides: Object
|
|
};
|
|
const style$f = cB("base-icon", `
|
|
height: 1em;
|
|
width: 1em;
|
|
line-height: 1em;
|
|
text-align: center;
|
|
display: inline-block;
|
|
position: relative;
|
|
fill: currentColor;
|
|
transform: translateZ(0);
|
|
`, [c("svg", `
|
|
height: 1em;
|
|
width: 1em;
|
|
`)]);
|
|
const NBaseIcon = /* @__PURE__ */ defineComponent({
|
|
name: "BaseIcon",
|
|
props: {
|
|
role: String,
|
|
ariaLabel: String,
|
|
ariaDisabled: {
|
|
type: Boolean,
|
|
default: void 0
|
|
},
|
|
ariaHidden: {
|
|
type: Boolean,
|
|
default: void 0
|
|
},
|
|
clsPrefix: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
onClick: Function,
|
|
onMousedown: Function,
|
|
onMouseup: Function
|
|
},
|
|
setup(props) {
|
|
useStyle("-base-icon", style$f, toRef(props, "clsPrefix"));
|
|
},
|
|
render() {
|
|
return h("i", {
|
|
class: `${this.clsPrefix}-base-icon`,
|
|
onClick: this.onClick,
|
|
onMousedown: this.onMousedown,
|
|
onMouseup: this.onMouseup,
|
|
role: this.role,
|
|
"aria-label": this.ariaLabel,
|
|
"aria-hidden": this.ariaHidden,
|
|
"aria-disabled": this.ariaDisabled
|
|
}, this.$slots);
|
|
}
|
|
});
|
|
const NIconSwitchTransition = /* @__PURE__ */ defineComponent({
|
|
name: "BaseIconSwitchTransition",
|
|
setup(_, {
|
|
slots
|
|
}) {
|
|
const isMountedRef = isMounted();
|
|
return () => h(Transition, {
|
|
name: "icon-switch-transition",
|
|
appear: isMountedRef.value
|
|
}, slots);
|
|
}
|
|
});
|
|
function replaceable(name, icon) {
|
|
const IconComponent = /* @__PURE__ */ defineComponent({
|
|
render() {
|
|
return icon();
|
|
}
|
|
});
|
|
return /* @__PURE__ */ defineComponent({
|
|
name: upperFirst(name),
|
|
setup() {
|
|
var _a;
|
|
const mergedIconsRef = (_a = inject(configProviderInjectionKey, null)) === null || _a === void 0 ? void 0 : _a.mergedIconsRef;
|
|
return () => {
|
|
var _a2;
|
|
const iconOverride = (_a2 = mergedIconsRef === null || mergedIconsRef === void 0 ? void 0 : mergedIconsRef.value) === null || _a2 === void 0 ? void 0 : _a2[name];
|
|
return iconOverride ? iconOverride() : h(IconComponent, null);
|
|
};
|
|
}
|
|
});
|
|
}
|
|
const ChevronRightIcon = /* @__PURE__ */ defineComponent({
|
|
name: "ChevronRight",
|
|
render() {
|
|
return h("svg", {
|
|
viewBox: "0 0 16 16",
|
|
fill: "none",
|
|
xmlns: "http://www.w3.org/2000/svg"
|
|
}, h("path", {
|
|
d: "M5.64645 3.14645C5.45118 3.34171 5.45118 3.65829 5.64645 3.85355L9.79289 8L5.64645 12.1464C5.45118 12.3417 5.45118 12.6583 5.64645 12.8536C5.84171 13.0488 6.15829 13.0488 6.35355 12.8536L10.8536 8.35355C11.0488 8.15829 11.0488 7.84171 10.8536 7.64645L6.35355 3.14645C6.15829 2.95118 5.84171 2.95118 5.64645 3.14645Z",
|
|
fill: "currentColor"
|
|
}));
|
|
}
|
|
});
|
|
const ErrorIcon$1 = replaceable("close", () => h("svg", {
|
|
viewBox: "0 0 12 12",
|
|
version: "1.1",
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
"aria-hidden": true
|
|
}, h("g", {
|
|
stroke: "none",
|
|
"stroke-width": "1",
|
|
fill: "none",
|
|
"fill-rule": "evenodd"
|
|
}, h("g", {
|
|
fill: "currentColor",
|
|
"fill-rule": "nonzero"
|
|
}, h("path", {
|
|
d: "M2.08859116,2.2156945 L2.14644661,2.14644661 C2.32001296,1.97288026 2.58943736,1.95359511 2.7843055,2.08859116 L2.85355339,2.14644661 L6,5.293 L9.14644661,2.14644661 C9.34170876,1.95118446 9.65829124,1.95118446 9.85355339,2.14644661 C10.0488155,2.34170876 10.0488155,2.65829124 9.85355339,2.85355339 L6.707,6 L9.85355339,9.14644661 C10.0271197,9.32001296 10.0464049,9.58943736 9.91140884,9.7843055 L9.85355339,9.85355339 C9.67998704,10.0271197 9.41056264,10.0464049 9.2156945,9.91140884 L9.14644661,9.85355339 L6,6.707 L2.85355339,9.85355339 C2.65829124,10.0488155 2.34170876,10.0488155 2.14644661,9.85355339 C1.95118446,9.65829124 1.95118446,9.34170876 2.14644661,9.14644661 L5.293,6 L2.14644661,2.85355339 C1.97288026,2.67998704 1.95359511,2.41056264 2.08859116,2.2156945 L2.14644661,2.14644661 L2.08859116,2.2156945 Z"
|
|
})))));
|
|
const ErrorIcon = replaceable("error", () => h("svg", {
|
|
viewBox: "0 0 48 48",
|
|
version: "1.1",
|
|
xmlns: "http://www.w3.org/2000/svg"
|
|
}, h("g", {
|
|
stroke: "none",
|
|
"stroke-width": "1",
|
|
"fill-rule": "evenodd"
|
|
}, h("g", {
|
|
"fill-rule": "nonzero"
|
|
}, h("path", {
|
|
d: "M24,4 C35.045695,4 44,12.954305 44,24 C44,35.045695 35.045695,44 24,44 C12.954305,44 4,35.045695 4,24 C4,12.954305 12.954305,4 24,4 Z M17.8838835,16.1161165 L17.7823881,16.0249942 C17.3266086,15.6583353 16.6733914,15.6583353 16.2176119,16.0249942 L16.1161165,16.1161165 L16.0249942,16.2176119 C15.6583353,16.6733914 15.6583353,17.3266086 16.0249942,17.7823881 L16.1161165,17.8838835 L22.233,24 L16.1161165,30.1161165 L16.0249942,30.2176119 C15.6583353,30.6733914 15.6583353,31.3266086 16.0249942,31.7823881 L16.1161165,31.8838835 L16.2176119,31.9750058 C16.6733914,32.3416647 17.3266086,32.3416647 17.7823881,31.9750058 L17.8838835,31.8838835 L24,25.767 L30.1161165,31.8838835 L30.2176119,31.9750058 C30.6733914,32.3416647 31.3266086,32.3416647 31.7823881,31.9750058 L31.8838835,31.8838835 L31.9750058,31.7823881 C32.3416647,31.3266086 32.3416647,30.6733914 31.9750058,30.2176119 L31.8838835,30.1161165 L25.767,24 L31.8838835,17.8838835 L31.9750058,17.7823881 C32.3416647,17.3266086 32.3416647,16.6733914 31.9750058,16.2176119 L31.8838835,16.1161165 L31.7823881,16.0249942 C31.3266086,15.6583353 30.6733914,15.6583353 30.2176119,16.0249942 L30.1161165,16.1161165 L24,22.233 L17.8838835,16.1161165 L17.7823881,16.0249942 L17.8838835,16.1161165 Z"
|
|
})))));
|
|
const InfoIcon = replaceable("info", () => h("svg", {
|
|
viewBox: "0 0 28 28",
|
|
version: "1.1",
|
|
xmlns: "http://www.w3.org/2000/svg"
|
|
}, h("g", {
|
|
stroke: "none",
|
|
"stroke-width": "1",
|
|
"fill-rule": "evenodd"
|
|
}, h("g", {
|
|
"fill-rule": "nonzero"
|
|
}, h("path", {
|
|
d: "M14,2 C20.6274,2 26,7.37258 26,14 C26,20.6274 20.6274,26 14,26 C7.37258,26 2,20.6274 2,14 C2,7.37258 7.37258,2 14,2 Z M14,11 C13.4477,11 13,11.4477 13,12 L13,12 L13,20 C13,20.5523 13.4477,21 14,21 C14.5523,21 15,20.5523 15,20 L15,20 L15,12 C15,11.4477 14.5523,11 14,11 Z M14,6.75 C13.3096,6.75 12.75,7.30964 12.75,8 C12.75,8.69036 13.3096,9.25 14,9.25 C14.6904,9.25 15.25,8.69036 15.25,8 C15.25,7.30964 14.6904,6.75 14,6.75 Z"
|
|
})))));
|
|
const SuccessIcon = replaceable("success", () => h("svg", {
|
|
viewBox: "0 0 48 48",
|
|
version: "1.1",
|
|
xmlns: "http://www.w3.org/2000/svg"
|
|
}, h("g", {
|
|
stroke: "none",
|
|
"stroke-width": "1",
|
|
"fill-rule": "evenodd"
|
|
}, h("g", {
|
|
"fill-rule": "nonzero"
|
|
}, h("path", {
|
|
d: "M24,4 C35.045695,4 44,12.954305 44,24 C44,35.045695 35.045695,44 24,44 C12.954305,44 4,35.045695 4,24 C4,12.954305 12.954305,4 24,4 Z M32.6338835,17.6161165 C32.1782718,17.1605048 31.4584514,17.1301307 30.9676119,17.5249942 L30.8661165,17.6161165 L20.75,27.732233 L17.1338835,24.1161165 C16.6457281,23.6279612 15.8542719,23.6279612 15.3661165,24.1161165 C14.9105048,24.5717282 14.8801307,25.2915486 15.2749942,25.7823881 L15.3661165,25.8838835 L19.8661165,30.3838835 C20.3217282,30.8394952 21.0415486,30.8698693 21.5323881,30.4750058 L21.6338835,30.3838835 L32.6338835,19.3838835 C33.1220388,18.8957281 33.1220388,18.1042719 32.6338835,17.6161165 Z"
|
|
})))));
|
|
const WarningIcon = replaceable("warning", () => h("svg", {
|
|
viewBox: "0 0 24 24",
|
|
version: "1.1",
|
|
xmlns: "http://www.w3.org/2000/svg"
|
|
}, h("g", {
|
|
stroke: "none",
|
|
"stroke-width": "1",
|
|
"fill-rule": "evenodd"
|
|
}, h("g", {
|
|
"fill-rule": "nonzero"
|
|
}, h("path", {
|
|
d: "M12,2 C17.523,2 22,6.478 22,12 C22,17.522 17.523,22 12,22 C6.477,22 2,17.522 2,12 C2,6.478 6.477,2 12,2 Z M12.0018002,15.0037242 C11.450254,15.0037242 11.0031376,15.4508407 11.0031376,16.0023869 C11.0031376,16.553933 11.450254,17.0010495 12.0018002,17.0010495 C12.5533463,17.0010495 13.0004628,16.553933 13.0004628,16.0023869 C13.0004628,15.4508407 12.5533463,15.0037242 12.0018002,15.0037242 Z M11.99964,7 C11.4868042,7.00018474 11.0642719,7.38637706 11.0066858,7.8837365 L11,8.00036004 L11.0018003,13.0012393 L11.00857,13.117858 C11.0665141,13.6151758 11.4893244,14.0010638 12.0021602,14.0008793 C12.514996,14.0006946 12.9375283,13.6145023 12.9951144,13.1171428 L13.0018002,13.0005193 L13,7.99964009 L12.9932303,7.8830214 C12.9352861,7.38570354 12.5124758,6.99981552 11.99964,7 Z"
|
|
})))));
|
|
const {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut$3
|
|
} = commonVariables$3;
|
|
function iconSwitchTransition({
|
|
originalTransform = "",
|
|
left = 0,
|
|
top = 0,
|
|
transition = `all .3s ${cubicBezierEaseInOut$3} !important`
|
|
} = {}) {
|
|
return [c("&.icon-switch-transition-enter-from, &.icon-switch-transition-leave-to", {
|
|
transform: `${originalTransform} scale(0.75)`,
|
|
left,
|
|
top,
|
|
opacity: 0
|
|
}), c("&.icon-switch-transition-enter-to, &.icon-switch-transition-leave-from", {
|
|
transform: `scale(1) ${originalTransform}`,
|
|
left,
|
|
top,
|
|
opacity: 1
|
|
}), c("&.icon-switch-transition-enter-active, &.icon-switch-transition-leave-active", {
|
|
transformOrigin: "center",
|
|
position: "absolute",
|
|
left,
|
|
top,
|
|
transition
|
|
})];
|
|
}
|
|
const style$e = cB("base-close", `
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
cursor: pointer;
|
|
background-color: transparent;
|
|
color: var(--n-close-icon-color);
|
|
border-radius: var(--n-close-border-radius);
|
|
height: var(--n-close-size);
|
|
width: var(--n-close-size);
|
|
font-size: var(--n-close-icon-size);
|
|
outline: none;
|
|
border: none;
|
|
position: relative;
|
|
padding: 0;
|
|
`, [cM("absolute", `
|
|
height: var(--n-close-icon-size);
|
|
width: var(--n-close-icon-size);
|
|
`), c("&::before", `
|
|
content: "";
|
|
position: absolute;
|
|
width: var(--n-close-size);
|
|
height: var(--n-close-size);
|
|
left: 50%;
|
|
top: 50%;
|
|
transform: translateY(-50%) translateX(-50%);
|
|
transition: inherit;
|
|
border-radius: inherit;
|
|
`), cNotM("disabled", [c("&:hover", `
|
|
color: var(--n-close-icon-color-hover);
|
|
`), c("&:hover::before", `
|
|
background-color: var(--n-close-color-hover);
|
|
`), c("&:focus::before", `
|
|
background-color: var(--n-close-color-hover);
|
|
`), c("&:active", `
|
|
color: var(--n-close-icon-color-pressed);
|
|
`), c("&:active::before", `
|
|
background-color: var(--n-close-color-pressed);
|
|
`)]), cM("disabled", `
|
|
cursor: not-allowed;
|
|
color: var(--n-close-icon-color-disabled);
|
|
background-color: transparent;
|
|
`), cM("round", [c("&::before", `
|
|
border-radius: 50%;
|
|
`)])]);
|
|
const NBaseClose = /* @__PURE__ */ defineComponent({
|
|
name: "BaseClose",
|
|
props: {
|
|
isButtonTag: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
clsPrefix: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: void 0
|
|
},
|
|
focusable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
round: Boolean,
|
|
onClick: Function,
|
|
absolute: Boolean
|
|
},
|
|
setup(props) {
|
|
useStyle("-base-close", style$e, toRef(props, "clsPrefix"));
|
|
return () => {
|
|
const {
|
|
clsPrefix,
|
|
disabled,
|
|
absolute,
|
|
round,
|
|
isButtonTag
|
|
} = props;
|
|
const Tag = isButtonTag ? "button" : "div";
|
|
return h(Tag, {
|
|
type: isButtonTag ? "button" : void 0,
|
|
tabindex: disabled || !props.focusable ? -1 : 0,
|
|
"aria-disabled": disabled,
|
|
"aria-label": "close",
|
|
role: isButtonTag ? void 0 : "button",
|
|
disabled,
|
|
class: [`${clsPrefix}-base-close`, absolute && `${clsPrefix}-base-close--absolute`, disabled && `${clsPrefix}-base-close--disabled`, round && `${clsPrefix}-base-close--round`],
|
|
onMousedown: (e) => {
|
|
if (!props.focusable) {
|
|
e.preventDefault();
|
|
}
|
|
},
|
|
onClick: props.onClick
|
|
}, h(NBaseIcon, {
|
|
clsPrefix
|
|
}, {
|
|
default: () => h(ErrorIcon$1, null)
|
|
}));
|
|
};
|
|
}
|
|
});
|
|
const NFadeInExpandTransition = /* @__PURE__ */ defineComponent({
|
|
name: "FadeInExpandTransition",
|
|
props: {
|
|
appear: Boolean,
|
|
group: Boolean,
|
|
mode: String,
|
|
onLeave: Function,
|
|
onAfterLeave: Function,
|
|
onAfterEnter: Function,
|
|
width: Boolean,
|
|
// reverse mode is only used in tree
|
|
// it make it from expanded to collapsed after mounted
|
|
reverse: Boolean
|
|
},
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
function handleBeforeLeave(el) {
|
|
if (props.width) {
|
|
el.style.maxWidth = `${el.offsetWidth}px`;
|
|
} else {
|
|
el.style.maxHeight = `${el.offsetHeight}px`;
|
|
}
|
|
void el.offsetWidth;
|
|
}
|
|
function handleLeave(el) {
|
|
if (props.width) {
|
|
el.style.maxWidth = "0";
|
|
} else {
|
|
el.style.maxHeight = "0";
|
|
}
|
|
void el.offsetWidth;
|
|
const {
|
|
onLeave
|
|
} = props;
|
|
if (onLeave) onLeave();
|
|
}
|
|
function handleAfterLeave(el) {
|
|
if (props.width) {
|
|
el.style.maxWidth = "";
|
|
} else {
|
|
el.style.maxHeight = "";
|
|
}
|
|
const {
|
|
onAfterLeave
|
|
} = props;
|
|
if (onAfterLeave) onAfterLeave();
|
|
}
|
|
function handleEnter(el) {
|
|
el.style.transition = "none";
|
|
if (props.width) {
|
|
const memorizedWidth = el.offsetWidth;
|
|
el.style.maxWidth = "0";
|
|
void el.offsetWidth;
|
|
el.style.transition = "";
|
|
el.style.maxWidth = `${memorizedWidth}px`;
|
|
} else {
|
|
if (props.reverse) {
|
|
el.style.maxHeight = `${el.offsetHeight}px`;
|
|
void el.offsetHeight;
|
|
el.style.transition = "";
|
|
el.style.maxHeight = "0";
|
|
} else {
|
|
const memorizedHeight = el.offsetHeight;
|
|
el.style.maxHeight = "0";
|
|
void el.offsetWidth;
|
|
el.style.transition = "";
|
|
el.style.maxHeight = `${memorizedHeight}px`;
|
|
}
|
|
}
|
|
void el.offsetWidth;
|
|
}
|
|
function handleAfterEnter(el) {
|
|
var _a;
|
|
if (props.width) {
|
|
el.style.maxWidth = "";
|
|
} else {
|
|
if (!props.reverse) {
|
|
el.style.maxHeight = "";
|
|
}
|
|
}
|
|
(_a = props.onAfterEnter) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
}
|
|
return () => {
|
|
const {
|
|
group,
|
|
width,
|
|
appear,
|
|
mode
|
|
} = props;
|
|
const type = group ? TransitionGroup : Transition;
|
|
const resolvedProps = {
|
|
name: width ? "fade-in-width-expand-transition" : "fade-in-height-expand-transition",
|
|
appear,
|
|
onEnter: handleEnter,
|
|
onAfterEnter: handleAfterEnter,
|
|
onBeforeLeave: handleBeforeLeave,
|
|
onLeave: handleLeave,
|
|
onAfterLeave: handleAfterLeave
|
|
};
|
|
if (!group) {
|
|
resolvedProps.mode = mode;
|
|
}
|
|
return h(type, resolvedProps, slots);
|
|
};
|
|
}
|
|
});
|
|
const style$d = c([c("@keyframes rotator", `
|
|
0% {
|
|
-webkit-transform: rotate(0deg);
|
|
transform: rotate(0deg);
|
|
}
|
|
100% {
|
|
-webkit-transform: rotate(360deg);
|
|
transform: rotate(360deg);
|
|
}`), cB("base-loading", `
|
|
position: relative;
|
|
line-height: 0;
|
|
width: 1em;
|
|
height: 1em;
|
|
`, [cE("transition-wrapper", `
|
|
position: absolute;
|
|
width: 100%;
|
|
height: 100%;
|
|
`, [iconSwitchTransition()]), cE("placeholder", `
|
|
position: absolute;
|
|
left: 50%;
|
|
top: 50%;
|
|
transform: translateX(-50%) translateY(-50%);
|
|
`, [iconSwitchTransition({
|
|
left: "50%",
|
|
top: "50%",
|
|
originalTransform: "translateX(-50%) translateY(-50%)"
|
|
})]), cE("container", `
|
|
animation: rotator 3s linear infinite both;
|
|
`, [cE("icon", `
|
|
height: 1em;
|
|
width: 1em;
|
|
`)])])]);
|
|
const duration = "1.6s";
|
|
const exposedLoadingProps = {
|
|
strokeWidth: {
|
|
type: Number,
|
|
default: 28
|
|
},
|
|
stroke: {
|
|
type: String,
|
|
default: void 0
|
|
}
|
|
};
|
|
const NBaseLoading = /* @__PURE__ */ defineComponent({
|
|
name: "BaseLoading",
|
|
props: Object.assign({
|
|
clsPrefix: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
show: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
scale: {
|
|
type: Number,
|
|
default: 1
|
|
},
|
|
radius: {
|
|
type: Number,
|
|
default: 100
|
|
}
|
|
}, exposedLoadingProps),
|
|
setup(props) {
|
|
useStyle("-base-loading", style$d, toRef(props, "clsPrefix"));
|
|
},
|
|
render() {
|
|
const {
|
|
clsPrefix,
|
|
radius,
|
|
strokeWidth,
|
|
stroke,
|
|
scale
|
|
} = this;
|
|
const scaledRadius = radius / scale;
|
|
return h("div", {
|
|
class: `${clsPrefix}-base-loading`,
|
|
role: "img",
|
|
"aria-label": "loading"
|
|
}, h(NIconSwitchTransition, null, {
|
|
default: () => this.show ? h("div", {
|
|
key: "icon",
|
|
class: `${clsPrefix}-base-loading__transition-wrapper`
|
|
}, h("div", {
|
|
class: `${clsPrefix}-base-loading__container`
|
|
}, h("svg", {
|
|
class: `${clsPrefix}-base-loading__icon`,
|
|
viewBox: `0 0 ${2 * scaledRadius} ${2 * scaledRadius}`,
|
|
xmlns: "http://www.w3.org/2000/svg",
|
|
style: {
|
|
color: stroke
|
|
}
|
|
}, h("g", null, h("animateTransform", {
|
|
attributeName: "transform",
|
|
type: "rotate",
|
|
values: `0 ${scaledRadius} ${scaledRadius};270 ${scaledRadius} ${scaledRadius}`,
|
|
begin: "0s",
|
|
dur: duration,
|
|
fill: "freeze",
|
|
repeatCount: "indefinite"
|
|
}), h("circle", {
|
|
class: `${clsPrefix}-base-loading__icon`,
|
|
fill: "none",
|
|
stroke: "currentColor",
|
|
"stroke-width": strokeWidth,
|
|
"stroke-linecap": "round",
|
|
cx: scaledRadius,
|
|
cy: scaledRadius,
|
|
r: radius - strokeWidth / 2,
|
|
"stroke-dasharray": 5.67 * radius,
|
|
"stroke-dashoffset": 18.48 * radius
|
|
}, h("animateTransform", {
|
|
attributeName: "transform",
|
|
type: "rotate",
|
|
values: `0 ${scaledRadius} ${scaledRadius};135 ${scaledRadius} ${scaledRadius};450 ${scaledRadius} ${scaledRadius}`,
|
|
begin: "0s",
|
|
dur: duration,
|
|
fill: "freeze",
|
|
repeatCount: "indefinite"
|
|
}), h("animate", {
|
|
attributeName: "stroke-dashoffset",
|
|
values: `${5.67 * radius};${1.42 * radius};${5.67 * radius}`,
|
|
begin: "0s",
|
|
dur: duration,
|
|
fill: "freeze",
|
|
repeatCount: "indefinite"
|
|
})))))) : h("div", {
|
|
key: "placeholder",
|
|
class: `${clsPrefix}-base-loading__placeholder`
|
|
}, this.$slots)
|
|
}));
|
|
}
|
|
});
|
|
const {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut$2
|
|
} = commonVariables$3;
|
|
function fadeInTransition({
|
|
name = "fade-in",
|
|
enterDuration = "0.2s",
|
|
leaveDuration = "0.2s",
|
|
enterCubicBezier = cubicBezierEaseInOut$2,
|
|
leaveCubicBezier = cubicBezierEaseInOut$2
|
|
} = {}) {
|
|
return [c(`&.${name}-transition-enter-active`, {
|
|
transition: `all ${enterDuration} ${enterCubicBezier}!important`
|
|
}), c(`&.${name}-transition-leave-active`, {
|
|
transition: `all ${leaveDuration} ${leaveCubicBezier}!important`
|
|
}), c(`&.${name}-transition-enter-from, &.${name}-transition-leave-to`, {
|
|
opacity: 0
|
|
}), c(`&.${name}-transition-leave-from, &.${name}-transition-enter-to`, {
|
|
opacity: 1
|
|
})];
|
|
}
|
|
const base = {
|
|
neutralBase: "#FFF",
|
|
neutralInvertBase: "#000",
|
|
neutralTextBase: "#000",
|
|
neutralPopover: "#fff",
|
|
neutralCard: "#fff",
|
|
neutralModal: "#fff",
|
|
neutralBody: "#fff",
|
|
alpha1: "0.82",
|
|
alpha2: "0.72",
|
|
alpha3: "0.38",
|
|
alpha4: "0.24",
|
|
// disabled text, placeholder, icon
|
|
alpha5: "0.18",
|
|
// disabled placeholder
|
|
alphaClose: "0.6",
|
|
alphaDisabled: "0.5",
|
|
alphaAvatar: "0.2",
|
|
alphaProgressRail: ".08",
|
|
alphaInput: "0",
|
|
alphaScrollbar: "0.25",
|
|
alphaScrollbarHover: "0.4",
|
|
// primary
|
|
primaryHover: "#36ad6a",
|
|
primaryDefault: "#18a058",
|
|
primaryActive: "#0c7a43",
|
|
primarySuppl: "#36ad6a",
|
|
// info
|
|
infoHover: "#4098fc",
|
|
infoDefault: "#2080f0",
|
|
infoActive: "#1060c9",
|
|
infoSuppl: "#4098fc",
|
|
// error
|
|
errorHover: "#de576d",
|
|
errorDefault: "#d03050",
|
|
errorActive: "#ab1f3f",
|
|
errorSuppl: "#de576d",
|
|
// warning
|
|
warningHover: "#fcb040",
|
|
warningDefault: "#f0a020",
|
|
warningActive: "#c97c10",
|
|
warningSuppl: "#fcb040",
|
|
// success
|
|
successHover: "#36ad6a",
|
|
successDefault: "#18a058",
|
|
successActive: "#0c7a43",
|
|
successSuppl: "#36ad6a"
|
|
};
|
|
const baseBackgroundRgb = rgba(base.neutralBase);
|
|
const baseInvertBackgroundRgb = rgba(base.neutralInvertBase);
|
|
const overlayPrefix = `rgba(${baseInvertBackgroundRgb.slice(0, 3).join(", ")}, `;
|
|
function overlay(alpha) {
|
|
return `${overlayPrefix + String(alpha)})`;
|
|
}
|
|
function neutral(alpha) {
|
|
const overlayRgba = Array.from(baseInvertBackgroundRgb);
|
|
overlayRgba[3] = Number(alpha);
|
|
return composite(baseBackgroundRgb, overlayRgba);
|
|
}
|
|
const derived = Object.assign(Object.assign({
|
|
name: "common"
|
|
}, commonVariables$3), {
|
|
baseColor: base.neutralBase,
|
|
// primary color
|
|
primaryColor: base.primaryDefault,
|
|
primaryColorHover: base.primaryHover,
|
|
primaryColorPressed: base.primaryActive,
|
|
primaryColorSuppl: base.primarySuppl,
|
|
// info color
|
|
infoColor: base.infoDefault,
|
|
infoColorHover: base.infoHover,
|
|
infoColorPressed: base.infoActive,
|
|
infoColorSuppl: base.infoSuppl,
|
|
// success color
|
|
successColor: base.successDefault,
|
|
successColorHover: base.successHover,
|
|
successColorPressed: base.successActive,
|
|
successColorSuppl: base.successSuppl,
|
|
// warning color
|
|
warningColor: base.warningDefault,
|
|
warningColorHover: base.warningHover,
|
|
warningColorPressed: base.warningActive,
|
|
warningColorSuppl: base.warningSuppl,
|
|
// error color
|
|
errorColor: base.errorDefault,
|
|
errorColorHover: base.errorHover,
|
|
errorColorPressed: base.errorActive,
|
|
errorColorSuppl: base.errorSuppl,
|
|
// text color
|
|
textColorBase: base.neutralTextBase,
|
|
textColor1: "rgb(31, 34, 37)",
|
|
textColor2: "rgb(51, 54, 57)",
|
|
textColor3: "rgb(118, 124, 130)",
|
|
// textColor4: neutral(base.alpha4), // disabled, placeholder, icon
|
|
// textColor5: neutral(base.alpha5),
|
|
textColorDisabled: neutral(base.alpha4),
|
|
placeholderColor: neutral(base.alpha4),
|
|
placeholderColorDisabled: neutral(base.alpha5),
|
|
iconColor: neutral(base.alpha4),
|
|
iconColorHover: scaleColor(neutral(base.alpha4), {
|
|
lightness: 0.75
|
|
}),
|
|
iconColorPressed: scaleColor(neutral(base.alpha4), {
|
|
lightness: 0.9
|
|
}),
|
|
iconColorDisabled: neutral(base.alpha5),
|
|
opacity1: base.alpha1,
|
|
opacity2: base.alpha2,
|
|
opacity3: base.alpha3,
|
|
opacity4: base.alpha4,
|
|
opacity5: base.alpha5,
|
|
dividerColor: "rgb(239, 239, 245)",
|
|
borderColor: "rgb(224, 224, 230)",
|
|
// close
|
|
closeIconColor: neutral(Number(base.alphaClose)),
|
|
closeIconColorHover: neutral(Number(base.alphaClose)),
|
|
closeIconColorPressed: neutral(Number(base.alphaClose)),
|
|
closeColorHover: "rgba(0, 0, 0, .09)",
|
|
closeColorPressed: "rgba(0, 0, 0, .13)",
|
|
// clear
|
|
clearColor: neutral(base.alpha4),
|
|
clearColorHover: scaleColor(neutral(base.alpha4), {
|
|
lightness: 0.75
|
|
}),
|
|
clearColorPressed: scaleColor(neutral(base.alpha4), {
|
|
lightness: 0.9
|
|
}),
|
|
scrollbarColor: overlay(base.alphaScrollbar),
|
|
scrollbarColorHover: overlay(base.alphaScrollbarHover),
|
|
scrollbarWidth: "5px",
|
|
scrollbarHeight: "5px",
|
|
scrollbarBorderRadius: "5px",
|
|
progressRailColor: neutral(base.alphaProgressRail),
|
|
railColor: "rgb(219, 219, 223)",
|
|
popoverColor: base.neutralPopover,
|
|
tableColor: base.neutralCard,
|
|
cardColor: base.neutralCard,
|
|
modalColor: base.neutralModal,
|
|
bodyColor: base.neutralBody,
|
|
tagColor: "#eee",
|
|
avatarColor: neutral(base.alphaAvatar),
|
|
invertedColor: "rgb(0, 20, 40)",
|
|
inputColor: neutral(base.alphaInput),
|
|
codeColor: "rgb(244, 244, 248)",
|
|
tabColor: "rgb(247, 247, 250)",
|
|
actionColor: "rgb(250, 250, 252)",
|
|
tableHeaderColor: "rgb(250, 250, 252)",
|
|
hoverColor: "rgb(243, 243, 245)",
|
|
// use color with alpha since it can be nested with header filter & sorter effect
|
|
tableColorHover: "rgba(0, 0, 100, 0.03)",
|
|
tableColorStriped: "rgba(0, 0, 100, 0.02)",
|
|
pressedColor: "rgb(237, 237, 239)",
|
|
opacityDisabled: base.alphaDisabled,
|
|
inputColorDisabled: "rgb(250, 250, 252)",
|
|
// secondary button color
|
|
// can also be used in tertiary button & quaternary button
|
|
buttonColor2: "rgba(46, 51, 56, .05)",
|
|
buttonColor2Hover: "rgba(46, 51, 56, .09)",
|
|
buttonColor2Pressed: "rgba(46, 51, 56, .13)",
|
|
boxShadow1: "0 1px 2px -2px rgba(0, 0, 0, .08), 0 3px 6px 0 rgba(0, 0, 0, .06), 0 5px 12px 4px rgba(0, 0, 0, .04)",
|
|
boxShadow2: "0 3px 6px -4px rgba(0, 0, 0, .12), 0 6px 16px 0 rgba(0, 0, 0, .08), 0 9px 28px 8px rgba(0, 0, 0, .05)",
|
|
boxShadow3: "0 6px 16px -9px rgba(0, 0, 0, .08), 0 9px 28px 0 rgba(0, 0, 0, .05), 0 12px 48px 16px rgba(0, 0, 0, .03)"
|
|
});
|
|
const commonVars$2 = {
|
|
railInsetHorizontalBottom: "auto 2px 4px 2px",
|
|
railInsetHorizontalTop: "4px 2px auto 2px",
|
|
railInsetVerticalRight: "2px 4px 2px auto",
|
|
railInsetVerticalLeft: "2px auto 2px 4px",
|
|
railColor: "transparent"
|
|
};
|
|
function self$9(vars) {
|
|
const {
|
|
scrollbarColor,
|
|
scrollbarColorHover,
|
|
scrollbarHeight,
|
|
scrollbarWidth,
|
|
scrollbarBorderRadius
|
|
} = vars;
|
|
return Object.assign(Object.assign({}, commonVars$2), {
|
|
height: scrollbarHeight,
|
|
width: scrollbarWidth,
|
|
borderRadius: scrollbarBorderRadius,
|
|
color: scrollbarColor,
|
|
colorHover: scrollbarColorHover
|
|
});
|
|
}
|
|
const scrollbarLight = {
|
|
name: "Scrollbar",
|
|
common: derived,
|
|
self: self$9
|
|
};
|
|
const style$c = cB("scrollbar", `
|
|
overflow: hidden;
|
|
position: relative;
|
|
z-index: auto;
|
|
height: 100%;
|
|
width: 100%;
|
|
`, [c(">", [cB("scrollbar-container", `
|
|
width: 100%;
|
|
overflow: scroll;
|
|
height: 100%;
|
|
min-height: inherit;
|
|
max-height: inherit;
|
|
scrollbar-width: none;
|
|
`, [c("&::-webkit-scrollbar, &::-webkit-scrollbar-track-piece, &::-webkit-scrollbar-thumb", `
|
|
width: 0;
|
|
height: 0;
|
|
display: none;
|
|
`), c(">", [
|
|
// We can't set overflow hidden since it affects positioning.
|
|
cB("scrollbar-content", `
|
|
box-sizing: border-box;
|
|
min-width: 100%;
|
|
`)
|
|
])])]), c(">, +", [cB("scrollbar-rail", `
|
|
position: absolute;
|
|
pointer-events: none;
|
|
user-select: none;
|
|
background: var(--n-scrollbar-rail-color);
|
|
-webkit-user-select: none;
|
|
`, [cM("horizontal", `
|
|
height: var(--n-scrollbar-height);
|
|
`, [c(">", [cE("scrollbar", `
|
|
height: var(--n-scrollbar-height);
|
|
border-radius: var(--n-scrollbar-border-radius);
|
|
right: 0;
|
|
`)])]), cM("horizontal--top", `
|
|
top: var(--n-scrollbar-rail-top-horizontal-top);
|
|
right: var(--n-scrollbar-rail-right-horizontal-top);
|
|
bottom: var(--n-scrollbar-rail-bottom-horizontal-top);
|
|
left: var(--n-scrollbar-rail-left-horizontal-top);
|
|
`), cM("horizontal--bottom", `
|
|
top: var(--n-scrollbar-rail-top-horizontal-bottom);
|
|
right: var(--n-scrollbar-rail-right-horizontal-bottom);
|
|
bottom: var(--n-scrollbar-rail-bottom-horizontal-bottom);
|
|
left: var(--n-scrollbar-rail-left-horizontal-bottom);
|
|
`), cM("vertical", `
|
|
width: var(--n-scrollbar-width);
|
|
`, [c(">", [cE("scrollbar", `
|
|
width: var(--n-scrollbar-width);
|
|
border-radius: var(--n-scrollbar-border-radius);
|
|
bottom: 0;
|
|
`)])]), cM("vertical--left", `
|
|
top: var(--n-scrollbar-rail-top-vertical-left);
|
|
right: var(--n-scrollbar-rail-right-vertical-left);
|
|
bottom: var(--n-scrollbar-rail-bottom-vertical-left);
|
|
left: var(--n-scrollbar-rail-left-vertical-left);
|
|
`), cM("vertical--right", `
|
|
top: var(--n-scrollbar-rail-top-vertical-right);
|
|
right: var(--n-scrollbar-rail-right-vertical-right);
|
|
bottom: var(--n-scrollbar-rail-bottom-vertical-right);
|
|
left: var(--n-scrollbar-rail-left-vertical-right);
|
|
`), cM("disabled", [c(">", [cE("scrollbar", "pointer-events: none;")])]), c(">", [cE("scrollbar", `
|
|
z-index: 1;
|
|
position: absolute;
|
|
cursor: pointer;
|
|
pointer-events: all;
|
|
background-color: var(--n-scrollbar-color);
|
|
transition: background-color .2s var(--n-scrollbar-bezier);
|
|
`, [fadeInTransition(), c("&:hover", "background-color: var(--n-scrollbar-color-hover);")])])])])]);
|
|
const scrollbarProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
duration: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
scrollable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
xScrollable: Boolean,
|
|
trigger: {
|
|
type: String,
|
|
default: "hover"
|
|
},
|
|
useUnifiedContainer: Boolean,
|
|
triggerDisplayManually: Boolean,
|
|
// If container is set, resize observer won't not attached
|
|
container: Function,
|
|
content: Function,
|
|
containerClass: String,
|
|
containerStyle: [String, Object],
|
|
contentClass: [String, Array],
|
|
contentStyle: [String, Object],
|
|
horizontalRailStyle: [String, Object],
|
|
verticalRailStyle: [String, Object],
|
|
onScroll: Function,
|
|
onWheel: Function,
|
|
onResize: Function,
|
|
internalOnUpdateScrollLeft: Function,
|
|
internalHoistYRail: Boolean,
|
|
yPlacement: {
|
|
type: String,
|
|
default: "right"
|
|
},
|
|
xPlacement: {
|
|
type: String,
|
|
default: "bottom"
|
|
}
|
|
});
|
|
const Scrollbar = /* @__PURE__ */ defineComponent({
|
|
name: "Scrollbar",
|
|
props: scrollbarProps,
|
|
inheritAttrs: false,
|
|
setup(props) {
|
|
const {
|
|
mergedClsPrefixRef,
|
|
inlineThemeDisabled,
|
|
mergedRtlRef
|
|
} = useConfig(props);
|
|
const rtlEnabledRef = useRtl("Scrollbar", mergedRtlRef, mergedClsPrefixRef);
|
|
const wrapperRef = ref(null);
|
|
const containerRef = ref(null);
|
|
const contentRef = ref(null);
|
|
const yRailRef = ref(null);
|
|
const xRailRef = ref(null);
|
|
const contentHeightRef = ref(null);
|
|
const contentWidthRef = ref(null);
|
|
const containerHeightRef = ref(null);
|
|
const containerWidthRef = ref(null);
|
|
const yRailSizeRef = ref(null);
|
|
const xRailSizeRef = ref(null);
|
|
const containerScrollTopRef = ref(0);
|
|
const containerScrollLeftRef = ref(0);
|
|
const isShowXBarRef = ref(false);
|
|
const isShowYBarRef = ref(false);
|
|
let yBarPressed = false;
|
|
let xBarPressed = false;
|
|
let xBarVanishTimerId;
|
|
let yBarVanishTimerId;
|
|
let memoYTop = 0;
|
|
let memoXLeft = 0;
|
|
let memoMouseX = 0;
|
|
let memoMouseY = 0;
|
|
const isIos2 = useIsIos();
|
|
const themeRef = useTheme("Scrollbar", "-scrollbar", style$c, scrollbarLight, props, mergedClsPrefixRef);
|
|
const yBarSizeRef = computed(() => {
|
|
const {
|
|
value: containerHeight
|
|
} = containerHeightRef;
|
|
const {
|
|
value: contentHeight
|
|
} = contentHeightRef;
|
|
const {
|
|
value: yRailSize
|
|
} = yRailSizeRef;
|
|
if (containerHeight === null || contentHeight === null || yRailSize === null) {
|
|
return 0;
|
|
} else {
|
|
return Math.min(containerHeight, yRailSize * containerHeight / contentHeight + depx(themeRef.value.self.width) * 1.5);
|
|
}
|
|
});
|
|
const yBarSizePxRef = computed(() => {
|
|
return `${yBarSizeRef.value}px`;
|
|
});
|
|
const xBarSizeRef = computed(() => {
|
|
const {
|
|
value: containerWidth
|
|
} = containerWidthRef;
|
|
const {
|
|
value: contentWidth
|
|
} = contentWidthRef;
|
|
const {
|
|
value: xRailSize
|
|
} = xRailSizeRef;
|
|
if (containerWidth === null || contentWidth === null || xRailSize === null) {
|
|
return 0;
|
|
} else {
|
|
return xRailSize * containerWidth / contentWidth + depx(themeRef.value.self.height) * 1.5;
|
|
}
|
|
});
|
|
const xBarSizePxRef = computed(() => {
|
|
return `${xBarSizeRef.value}px`;
|
|
});
|
|
const yBarTopRef = computed(() => {
|
|
const {
|
|
value: containerHeight
|
|
} = containerHeightRef;
|
|
const {
|
|
value: containerScrollTop
|
|
} = containerScrollTopRef;
|
|
const {
|
|
value: contentHeight
|
|
} = contentHeightRef;
|
|
const {
|
|
value: yRailSize
|
|
} = yRailSizeRef;
|
|
if (containerHeight === null || contentHeight === null || yRailSize === null) {
|
|
return 0;
|
|
} else {
|
|
const heightDiff = contentHeight - containerHeight;
|
|
if (!heightDiff) return 0;
|
|
return containerScrollTop / heightDiff * (yRailSize - yBarSizeRef.value);
|
|
}
|
|
});
|
|
const yBarTopPxRef = computed(() => {
|
|
return `${yBarTopRef.value}px`;
|
|
});
|
|
const xBarLeftRef = computed(() => {
|
|
const {
|
|
value: containerWidth
|
|
} = containerWidthRef;
|
|
const {
|
|
value: containerScrollLeft
|
|
} = containerScrollLeftRef;
|
|
const {
|
|
value: contentWidth
|
|
} = contentWidthRef;
|
|
const {
|
|
value: xRailSize
|
|
} = xRailSizeRef;
|
|
if (containerWidth === null || contentWidth === null || xRailSize === null) {
|
|
return 0;
|
|
} else {
|
|
const widthDiff = contentWidth - containerWidth;
|
|
if (!widthDiff) return 0;
|
|
return containerScrollLeft / widthDiff * (xRailSize - xBarSizeRef.value);
|
|
}
|
|
});
|
|
const xBarLeftPxRef = computed(() => {
|
|
return `${xBarLeftRef.value}px`;
|
|
});
|
|
const needYBarRef = computed(() => {
|
|
const {
|
|
value: containerHeight
|
|
} = containerHeightRef;
|
|
const {
|
|
value: contentHeight
|
|
} = contentHeightRef;
|
|
return containerHeight !== null && contentHeight !== null && contentHeight > containerHeight;
|
|
});
|
|
const needXBarRef = computed(() => {
|
|
const {
|
|
value: containerWidth
|
|
} = containerWidthRef;
|
|
const {
|
|
value: contentWidth
|
|
} = contentWidthRef;
|
|
return containerWidth !== null && contentWidth !== null && contentWidth > containerWidth;
|
|
});
|
|
const mergedShowXBarRef = computed(() => {
|
|
const {
|
|
trigger: trigger2
|
|
} = props;
|
|
return trigger2 === "none" || isShowXBarRef.value;
|
|
});
|
|
const mergedShowYBarRef = computed(() => {
|
|
const {
|
|
trigger: trigger2
|
|
} = props;
|
|
return trigger2 === "none" || isShowYBarRef.value;
|
|
});
|
|
const mergedContainerRef = computed(() => {
|
|
const {
|
|
container
|
|
} = props;
|
|
if (container) return container();
|
|
return containerRef.value;
|
|
});
|
|
const mergedContentRef = computed(() => {
|
|
const {
|
|
content
|
|
} = props;
|
|
if (content) return content();
|
|
return contentRef.value;
|
|
});
|
|
const scrollTo = (options, y) => {
|
|
if (!props.scrollable) return;
|
|
if (typeof options === "number") {
|
|
scrollToPosition2(options, y !== null && y !== void 0 ? y : 0, 0, false, "auto");
|
|
return;
|
|
}
|
|
const {
|
|
left,
|
|
top,
|
|
index,
|
|
elSize,
|
|
position,
|
|
behavior,
|
|
el,
|
|
debounce = true
|
|
} = options;
|
|
if (left !== void 0 || top !== void 0) {
|
|
scrollToPosition2(left !== null && left !== void 0 ? left : 0, top !== null && top !== void 0 ? top : 0, 0, false, behavior);
|
|
}
|
|
if (el !== void 0) {
|
|
scrollToPosition2(0, el.offsetTop, el.offsetHeight, debounce, behavior);
|
|
} else if (index !== void 0 && elSize !== void 0) {
|
|
scrollToPosition2(0, index * elSize, elSize, debounce, behavior);
|
|
} else if (position === "bottom") {
|
|
scrollToPosition2(0, Number.MAX_SAFE_INTEGER, 0, false, behavior);
|
|
} else if (position === "top") {
|
|
scrollToPosition2(0, 0, 0, false, behavior);
|
|
}
|
|
};
|
|
const activateState = useReactivated(() => {
|
|
if (!props.container) {
|
|
scrollTo({
|
|
top: containerScrollTopRef.value,
|
|
left: containerScrollLeftRef.value
|
|
});
|
|
}
|
|
});
|
|
const handleContentResize = () => {
|
|
if (activateState.isDeactivated) return;
|
|
sync();
|
|
};
|
|
const handleContainerResize = (e) => {
|
|
if (activateState.isDeactivated) return;
|
|
const {
|
|
onResize
|
|
} = props;
|
|
if (onResize) onResize(e);
|
|
sync();
|
|
};
|
|
const scrollBy = (options, y) => {
|
|
if (!props.scrollable) return;
|
|
const {
|
|
value: container
|
|
} = mergedContainerRef;
|
|
if (!container) return;
|
|
if (typeof options === "object") {
|
|
container.scrollBy(options);
|
|
} else {
|
|
container.scrollBy(options, y || 0);
|
|
}
|
|
};
|
|
function scrollToPosition2(left, top, elSize, debounce, behavior) {
|
|
const {
|
|
value: container
|
|
} = mergedContainerRef;
|
|
if (!container) return;
|
|
if (debounce) {
|
|
const {
|
|
scrollTop,
|
|
offsetHeight
|
|
} = container;
|
|
if (top > scrollTop) {
|
|
if (top + elSize <= scrollTop + offsetHeight) ;
|
|
else {
|
|
container.scrollTo({
|
|
left,
|
|
top: top + elSize - offsetHeight,
|
|
behavior
|
|
});
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
container.scrollTo({
|
|
left,
|
|
top,
|
|
behavior
|
|
});
|
|
}
|
|
function handleMouseEnterWrapper() {
|
|
showXBar();
|
|
showYBar();
|
|
sync();
|
|
}
|
|
function handleMouseLeaveWrapper() {
|
|
hideBar();
|
|
}
|
|
function hideBar() {
|
|
hideYBar();
|
|
hideXBar();
|
|
}
|
|
function hideYBar() {
|
|
if (yBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(yBarVanishTimerId);
|
|
}
|
|
yBarVanishTimerId = window.setTimeout(() => {
|
|
isShowYBarRef.value = false;
|
|
}, props.duration);
|
|
}
|
|
function hideXBar() {
|
|
if (xBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(xBarVanishTimerId);
|
|
}
|
|
xBarVanishTimerId = window.setTimeout(() => {
|
|
isShowXBarRef.value = false;
|
|
}, props.duration);
|
|
}
|
|
function showXBar() {
|
|
if (xBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(xBarVanishTimerId);
|
|
}
|
|
isShowXBarRef.value = true;
|
|
}
|
|
function showYBar() {
|
|
if (yBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(yBarVanishTimerId);
|
|
}
|
|
isShowYBarRef.value = true;
|
|
}
|
|
function handleScroll(e) {
|
|
const {
|
|
onScroll
|
|
} = props;
|
|
if (onScroll) onScroll(e);
|
|
syncScrollState();
|
|
}
|
|
function syncScrollState() {
|
|
const {
|
|
value: container
|
|
} = mergedContainerRef;
|
|
if (container) {
|
|
containerScrollTopRef.value = container.scrollTop;
|
|
containerScrollLeftRef.value = container.scrollLeft * ((rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? -1 : 1);
|
|
}
|
|
}
|
|
function syncPositionState() {
|
|
const {
|
|
value: content
|
|
} = mergedContentRef;
|
|
if (content) {
|
|
contentHeightRef.value = content.offsetHeight;
|
|
contentWidthRef.value = content.offsetWidth;
|
|
}
|
|
const {
|
|
value: container
|
|
} = mergedContainerRef;
|
|
if (container) {
|
|
containerHeightRef.value = container.offsetHeight;
|
|
containerWidthRef.value = container.offsetWidth;
|
|
}
|
|
const {
|
|
value: xRailEl
|
|
} = xRailRef;
|
|
const {
|
|
value: yRailEl
|
|
} = yRailRef;
|
|
if (xRailEl) {
|
|
xRailSizeRef.value = xRailEl.offsetWidth;
|
|
}
|
|
if (yRailEl) {
|
|
yRailSizeRef.value = yRailEl.offsetHeight;
|
|
}
|
|
}
|
|
function syncUnifiedContainer() {
|
|
const {
|
|
value: container
|
|
} = mergedContainerRef;
|
|
if (container) {
|
|
containerScrollTopRef.value = container.scrollTop;
|
|
containerScrollLeftRef.value = container.scrollLeft * ((rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? -1 : 1);
|
|
containerHeightRef.value = container.offsetHeight;
|
|
containerWidthRef.value = container.offsetWidth;
|
|
contentHeightRef.value = container.scrollHeight;
|
|
contentWidthRef.value = container.scrollWidth;
|
|
}
|
|
const {
|
|
value: xRailEl
|
|
} = xRailRef;
|
|
const {
|
|
value: yRailEl
|
|
} = yRailRef;
|
|
if (xRailEl) {
|
|
xRailSizeRef.value = xRailEl.offsetWidth;
|
|
}
|
|
if (yRailEl) {
|
|
yRailSizeRef.value = yRailEl.offsetHeight;
|
|
}
|
|
}
|
|
function sync() {
|
|
if (!props.scrollable) return;
|
|
if (props.useUnifiedContainer) {
|
|
syncUnifiedContainer();
|
|
} else {
|
|
syncPositionState();
|
|
syncScrollState();
|
|
}
|
|
}
|
|
function isMouseUpAway(e) {
|
|
var _a;
|
|
return !((_a = wrapperRef.value) === null || _a === void 0 ? void 0 : _a.contains(getPreciseEventTarget(e)));
|
|
}
|
|
function handleXScrollMouseDown(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
xBarPressed = true;
|
|
on("mousemove", window, handleXScrollMouseMove, true);
|
|
on("mouseup", window, handleXScrollMouseUp, true);
|
|
memoXLeft = containerScrollLeftRef.value;
|
|
memoMouseX = (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? window.innerWidth - e.clientX : e.clientX;
|
|
}
|
|
function handleXScrollMouseMove(e) {
|
|
if (!xBarPressed) return;
|
|
if (xBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(xBarVanishTimerId);
|
|
}
|
|
if (yBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(yBarVanishTimerId);
|
|
}
|
|
const {
|
|
value: containerWidth
|
|
} = containerWidthRef;
|
|
const {
|
|
value: contentWidth
|
|
} = contentWidthRef;
|
|
const {
|
|
value: xBarSize
|
|
} = xBarSizeRef;
|
|
if (containerWidth === null || contentWidth === null) return;
|
|
const dX = (rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? window.innerWidth - e.clientX - memoMouseX : e.clientX - memoMouseX;
|
|
const dScrollLeft = dX * (contentWidth - containerWidth) / (containerWidth - xBarSize);
|
|
const toScrollLeftUpperBound = contentWidth - containerWidth;
|
|
let toScrollLeft = memoXLeft + dScrollLeft;
|
|
toScrollLeft = Math.min(toScrollLeftUpperBound, toScrollLeft);
|
|
toScrollLeft = Math.max(toScrollLeft, 0);
|
|
const {
|
|
value: container
|
|
} = mergedContainerRef;
|
|
if (container) {
|
|
container.scrollLeft = toScrollLeft * ((rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? -1 : 1);
|
|
const {
|
|
internalOnUpdateScrollLeft
|
|
} = props;
|
|
if (internalOnUpdateScrollLeft) internalOnUpdateScrollLeft(toScrollLeft);
|
|
}
|
|
}
|
|
function handleXScrollMouseUp(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
off("mousemove", window, handleXScrollMouseMove, true);
|
|
off("mouseup", window, handleXScrollMouseUp, true);
|
|
xBarPressed = false;
|
|
sync();
|
|
if (isMouseUpAway(e)) {
|
|
hideBar();
|
|
}
|
|
}
|
|
function handleYScrollMouseDown(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
yBarPressed = true;
|
|
on("mousemove", window, handleYScrollMouseMove, true);
|
|
on("mouseup", window, handleYScrollMouseUp, true);
|
|
memoYTop = containerScrollTopRef.value;
|
|
memoMouseY = e.clientY;
|
|
}
|
|
function handleYScrollMouseMove(e) {
|
|
if (!yBarPressed) return;
|
|
if (xBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(xBarVanishTimerId);
|
|
}
|
|
if (yBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(yBarVanishTimerId);
|
|
}
|
|
const {
|
|
value: containerHeight
|
|
} = containerHeightRef;
|
|
const {
|
|
value: contentHeight
|
|
} = contentHeightRef;
|
|
const {
|
|
value: yBarSize
|
|
} = yBarSizeRef;
|
|
if (containerHeight === null || contentHeight === null) return;
|
|
const dY = e.clientY - memoMouseY;
|
|
const dScrollTop = dY * (contentHeight - containerHeight) / (containerHeight - yBarSize);
|
|
const toScrollTopUpperBound = contentHeight - containerHeight;
|
|
let toScrollTop = memoYTop + dScrollTop;
|
|
toScrollTop = Math.min(toScrollTopUpperBound, toScrollTop);
|
|
toScrollTop = Math.max(toScrollTop, 0);
|
|
const {
|
|
value: container
|
|
} = mergedContainerRef;
|
|
if (container) {
|
|
container.scrollTop = toScrollTop;
|
|
}
|
|
}
|
|
function handleYScrollMouseUp(e) {
|
|
e.preventDefault();
|
|
e.stopPropagation();
|
|
off("mousemove", window, handleYScrollMouseMove, true);
|
|
off("mouseup", window, handleYScrollMouseUp, true);
|
|
yBarPressed = false;
|
|
sync();
|
|
if (isMouseUpAway(e)) {
|
|
hideBar();
|
|
}
|
|
}
|
|
watchEffect(() => {
|
|
const {
|
|
value: needXBar
|
|
} = needXBarRef;
|
|
const {
|
|
value: needYBar
|
|
} = needYBarRef;
|
|
const {
|
|
value: mergedClsPrefix
|
|
} = mergedClsPrefixRef;
|
|
const {
|
|
value: xRailEl
|
|
} = xRailRef;
|
|
const {
|
|
value: yRailEl
|
|
} = yRailRef;
|
|
if (xRailEl) {
|
|
if (!needXBar) {
|
|
xRailEl.classList.add(`${mergedClsPrefix}-scrollbar-rail--disabled`);
|
|
} else {
|
|
xRailEl.classList.remove(`${mergedClsPrefix}-scrollbar-rail--disabled`);
|
|
}
|
|
}
|
|
if (yRailEl) {
|
|
if (!needYBar) {
|
|
yRailEl.classList.add(`${mergedClsPrefix}-scrollbar-rail--disabled`);
|
|
} else {
|
|
yRailEl.classList.remove(`${mergedClsPrefix}-scrollbar-rail--disabled`);
|
|
}
|
|
}
|
|
});
|
|
onMounted(() => {
|
|
if (props.container) return;
|
|
sync();
|
|
});
|
|
onBeforeUnmount(() => {
|
|
if (xBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(xBarVanishTimerId);
|
|
}
|
|
if (yBarVanishTimerId !== void 0) {
|
|
window.clearTimeout(yBarVanishTimerId);
|
|
}
|
|
off("mousemove", window, handleYScrollMouseMove, true);
|
|
off("mouseup", window, handleYScrollMouseUp, true);
|
|
});
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
common: {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2
|
|
},
|
|
self: {
|
|
color,
|
|
colorHover,
|
|
height,
|
|
width,
|
|
borderRadius,
|
|
railInsetHorizontalTop,
|
|
railInsetHorizontalBottom,
|
|
railInsetVerticalRight,
|
|
railInsetVerticalLeft,
|
|
railColor
|
|
}
|
|
} = themeRef.value;
|
|
const {
|
|
top: railTopHorizontalTop,
|
|
right: railRightHorizontalTop,
|
|
bottom: railBottomHorizontalTop,
|
|
left: railLeftHorizontalTop
|
|
} = getMargin(railInsetHorizontalTop);
|
|
const {
|
|
top: railTopHorizontalBottom,
|
|
right: railRightHorizontalBottom,
|
|
bottom: railBottomHorizontalBottom,
|
|
left: railLeftHorizontalBottom
|
|
} = getMargin(railInsetHorizontalBottom);
|
|
const {
|
|
top: railTopVerticalRight,
|
|
right: railRightVerticalRight,
|
|
bottom: railBottomVerticalRight,
|
|
left: railLeftVerticalRight
|
|
} = getMargin((rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? rtlInset(railInsetVerticalRight) : railInsetVerticalRight);
|
|
const {
|
|
top: railTopVerticalLeft,
|
|
right: railRightVerticalLeft,
|
|
bottom: railBottomVerticalLeft,
|
|
left: railLeftVerticalLeft
|
|
} = getMargin((rtlEnabledRef === null || rtlEnabledRef === void 0 ? void 0 : rtlEnabledRef.value) ? rtlInset(railInsetVerticalLeft) : railInsetVerticalLeft);
|
|
return {
|
|
"--n-scrollbar-bezier": cubicBezierEaseInOut2,
|
|
"--n-scrollbar-color": color,
|
|
"--n-scrollbar-color-hover": colorHover,
|
|
"--n-scrollbar-border-radius": borderRadius,
|
|
"--n-scrollbar-width": width,
|
|
"--n-scrollbar-height": height,
|
|
"--n-scrollbar-rail-top-horizontal-top": railTopHorizontalTop,
|
|
"--n-scrollbar-rail-right-horizontal-top": railRightHorizontalTop,
|
|
"--n-scrollbar-rail-bottom-horizontal-top": railBottomHorizontalTop,
|
|
"--n-scrollbar-rail-left-horizontal-top": railLeftHorizontalTop,
|
|
"--n-scrollbar-rail-top-horizontal-bottom": railTopHorizontalBottom,
|
|
"--n-scrollbar-rail-right-horizontal-bottom": railRightHorizontalBottom,
|
|
"--n-scrollbar-rail-bottom-horizontal-bottom": railBottomHorizontalBottom,
|
|
"--n-scrollbar-rail-left-horizontal-bottom": railLeftHorizontalBottom,
|
|
"--n-scrollbar-rail-top-vertical-right": railTopVerticalRight,
|
|
"--n-scrollbar-rail-right-vertical-right": railRightVerticalRight,
|
|
"--n-scrollbar-rail-bottom-vertical-right": railBottomVerticalRight,
|
|
"--n-scrollbar-rail-left-vertical-right": railLeftVerticalRight,
|
|
"--n-scrollbar-rail-top-vertical-left": railTopVerticalLeft,
|
|
"--n-scrollbar-rail-right-vertical-left": railRightVerticalLeft,
|
|
"--n-scrollbar-rail-bottom-vertical-left": railBottomVerticalLeft,
|
|
"--n-scrollbar-rail-left-vertical-left": railLeftVerticalLeft,
|
|
"--n-scrollbar-rail-color": railColor
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("scrollbar", void 0, cssVarsRef, props) : void 0;
|
|
const exposedMethods = {
|
|
scrollTo,
|
|
scrollBy,
|
|
sync,
|
|
syncUnifiedContainer,
|
|
handleMouseEnterWrapper,
|
|
handleMouseLeaveWrapper
|
|
};
|
|
return Object.assign(Object.assign({}, exposedMethods), {
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
rtlEnabled: rtlEnabledRef,
|
|
containerScrollTop: containerScrollTopRef,
|
|
wrapperRef,
|
|
containerRef,
|
|
contentRef,
|
|
yRailRef,
|
|
xRailRef,
|
|
needYBar: needYBarRef,
|
|
needXBar: needXBarRef,
|
|
yBarSizePx: yBarSizePxRef,
|
|
xBarSizePx: xBarSizePxRef,
|
|
yBarTopPx: yBarTopPxRef,
|
|
xBarLeftPx: xBarLeftPxRef,
|
|
isShowXBar: mergedShowXBarRef,
|
|
isShowYBar: mergedShowYBarRef,
|
|
isIos: isIos2,
|
|
handleScroll,
|
|
handleContentResize,
|
|
handleContainerResize,
|
|
handleYScrollMouseDown,
|
|
handleXScrollMouseDown,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
});
|
|
},
|
|
render() {
|
|
var _a;
|
|
const {
|
|
$slots,
|
|
mergedClsPrefix,
|
|
triggerDisplayManually,
|
|
rtlEnabled,
|
|
internalHoistYRail,
|
|
yPlacement,
|
|
xPlacement,
|
|
xScrollable
|
|
} = this;
|
|
if (!this.scrollable) return (_a = $slots.default) === null || _a === void 0 ? void 0 : _a.call($slots);
|
|
const triggerIsNone = this.trigger === "none";
|
|
const createYRail = (className, style2) => {
|
|
return h("div", {
|
|
ref: "yRailRef",
|
|
class: [`${mergedClsPrefix}-scrollbar-rail`, `${mergedClsPrefix}-scrollbar-rail--vertical`, `${mergedClsPrefix}-scrollbar-rail--vertical--${yPlacement}`, className],
|
|
"data-scrollbar-rail": true,
|
|
style: [style2 || "", this.verticalRailStyle],
|
|
"aria-hidden": true
|
|
}, h(triggerIsNone ? Wrapper : Transition, triggerIsNone ? null : {
|
|
name: "fade-in-transition"
|
|
}, {
|
|
default: () => this.needYBar && this.isShowYBar && !this.isIos ? h("div", {
|
|
class: `${mergedClsPrefix}-scrollbar-rail__scrollbar`,
|
|
style: {
|
|
height: this.yBarSizePx,
|
|
top: this.yBarTopPx
|
|
},
|
|
onMousedown: this.handleYScrollMouseDown
|
|
}) : null
|
|
}));
|
|
};
|
|
const createChildren = () => {
|
|
var _a2, _b;
|
|
(_a2 = this.onRender) === null || _a2 === void 0 ? void 0 : _a2.call(this);
|
|
return h("div", mergeProps(this.$attrs, {
|
|
role: "none",
|
|
ref: "wrapperRef",
|
|
class: [`${mergedClsPrefix}-scrollbar`, this.themeClass, rtlEnabled && `${mergedClsPrefix}-scrollbar--rtl`],
|
|
style: this.cssVars,
|
|
onMouseenter: triggerDisplayManually ? void 0 : this.handleMouseEnterWrapper,
|
|
onMouseleave: triggerDisplayManually ? void 0 : this.handleMouseLeaveWrapper
|
|
}), [this.container ? (_b = $slots.default) === null || _b === void 0 ? void 0 : _b.call($slots) : h("div", {
|
|
role: "none",
|
|
ref: "containerRef",
|
|
class: [`${mergedClsPrefix}-scrollbar-container`, this.containerClass],
|
|
style: this.containerStyle,
|
|
onScroll: this.handleScroll,
|
|
onWheel: this.onWheel
|
|
}, h(VResizeObserver, {
|
|
onResize: this.handleContentResize
|
|
}, {
|
|
default: () => h("div", {
|
|
ref: "contentRef",
|
|
role: "none",
|
|
style: [{
|
|
width: this.xScrollable ? "fit-content" : null
|
|
}, this.contentStyle],
|
|
class: [`${mergedClsPrefix}-scrollbar-content`, this.contentClass]
|
|
}, $slots)
|
|
})), internalHoistYRail ? null : createYRail(void 0, void 0), xScrollable && h("div", {
|
|
ref: "xRailRef",
|
|
class: [`${mergedClsPrefix}-scrollbar-rail`, `${mergedClsPrefix}-scrollbar-rail--horizontal`, `${mergedClsPrefix}-scrollbar-rail--horizontal--${xPlacement}`],
|
|
style: this.horizontalRailStyle,
|
|
"data-scrollbar-rail": true,
|
|
"aria-hidden": true
|
|
}, h(triggerIsNone ? Wrapper : Transition, triggerIsNone ? null : {
|
|
name: "fade-in-transition"
|
|
}, {
|
|
default: () => this.needXBar && this.isShowXBar && !this.isIos ? h("div", {
|
|
class: `${mergedClsPrefix}-scrollbar-rail__scrollbar`,
|
|
style: {
|
|
width: this.xBarSizePx,
|
|
right: rtlEnabled ? this.xBarLeftPx : void 0,
|
|
left: rtlEnabled ? void 0 : this.xBarLeftPx
|
|
},
|
|
onMousedown: this.handleXScrollMouseDown
|
|
}) : null
|
|
}))]);
|
|
};
|
|
const scrollbarNode = this.container ? createChildren() : h(VResizeObserver, {
|
|
onResize: this.handleContainerResize
|
|
}, {
|
|
default: createChildren
|
|
});
|
|
if (internalHoistYRail) {
|
|
return h(Fragment, null, scrollbarNode, createYRail(this.themeClass, this.cssVars));
|
|
} else {
|
|
return scrollbarNode;
|
|
}
|
|
}
|
|
});
|
|
const XScrollbar = Scrollbar;
|
|
const {
|
|
cubicBezierEaseIn: cubicBezierEaseIn$1,
|
|
cubicBezierEaseOut: cubicBezierEaseOut$1
|
|
} = commonVariables$3;
|
|
function fadeInScaleUpTransition({
|
|
transformOrigin = "inherit",
|
|
duration: duration2 = ".2s",
|
|
enterScale = ".9",
|
|
originalTransform = "",
|
|
originalTransition = ""
|
|
} = {}) {
|
|
return [c("&.fade-in-scale-up-transition-leave-active", {
|
|
transformOrigin,
|
|
transition: `opacity ${duration2} ${cubicBezierEaseIn$1}, transform ${duration2} ${cubicBezierEaseIn$1} ${originalTransition && `,${originalTransition}`}`
|
|
}), c("&.fade-in-scale-up-transition-enter-active", {
|
|
transformOrigin,
|
|
transition: `opacity ${duration2} ${cubicBezierEaseOut$1}, transform ${duration2} ${cubicBezierEaseOut$1} ${originalTransition && `,${originalTransition}`}`
|
|
}), c("&.fade-in-scale-up-transition-enter-from, &.fade-in-scale-up-transition-leave-to", {
|
|
opacity: 0,
|
|
transform: `${originalTransform} scale(${enterScale})`
|
|
}), c("&.fade-in-scale-up-transition-leave-from, &.fade-in-scale-up-transition-enter-to", {
|
|
opacity: 1,
|
|
transform: `${originalTransform} scale(1)`
|
|
})];
|
|
}
|
|
const {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut$1
|
|
} = commonVariables$3;
|
|
function fadeInWidthExpandTransition({
|
|
duration: duration2 = ".2s",
|
|
delay = ".1s"
|
|
} = {}) {
|
|
return [c("&.fade-in-width-expand-transition-leave-from, &.fade-in-width-expand-transition-enter-to", {
|
|
opacity: 1
|
|
}), c("&.fade-in-width-expand-transition-leave-to, &.fade-in-width-expand-transition-enter-from", `
|
|
opacity: 0!important;
|
|
margin-left: 0!important;
|
|
margin-right: 0!important;
|
|
`), c("&.fade-in-width-expand-transition-leave-active", `
|
|
overflow: hidden;
|
|
transition:
|
|
opacity ${duration2} ${cubicBezierEaseInOut$1},
|
|
max-width ${duration2} ${cubicBezierEaseInOut$1} ${delay},
|
|
margin-left ${duration2} ${cubicBezierEaseInOut$1} ${delay},
|
|
margin-right ${duration2} ${cubicBezierEaseInOut$1} ${delay};
|
|
`), c("&.fade-in-width-expand-transition-enter-active", `
|
|
overflow: hidden;
|
|
transition:
|
|
opacity ${duration2} ${cubicBezierEaseInOut$1} ${delay},
|
|
max-width ${duration2} ${cubicBezierEaseInOut$1},
|
|
margin-left ${duration2} ${cubicBezierEaseInOut$1},
|
|
margin-right ${duration2} ${cubicBezierEaseInOut$1};
|
|
`)];
|
|
}
|
|
const style$b = cB("base-wave", `
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
border-radius: inherit;
|
|
`);
|
|
const NBaseWave = /* @__PURE__ */ defineComponent({
|
|
name: "BaseWave",
|
|
props: {
|
|
clsPrefix: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
},
|
|
setup(props) {
|
|
useStyle("-base-wave", style$b, toRef(props, "clsPrefix"));
|
|
const selfRef = ref(null);
|
|
const activeRef = ref(false);
|
|
let animationTimerId = null;
|
|
onBeforeUnmount(() => {
|
|
if (animationTimerId !== null) {
|
|
window.clearTimeout(animationTimerId);
|
|
}
|
|
});
|
|
return {
|
|
active: activeRef,
|
|
selfRef,
|
|
play() {
|
|
if (animationTimerId !== null) {
|
|
window.clearTimeout(animationTimerId);
|
|
activeRef.value = false;
|
|
animationTimerId = null;
|
|
}
|
|
void nextTick(() => {
|
|
var _a;
|
|
void ((_a = selfRef.value) === null || _a === void 0 ? void 0 : _a.offsetHeight);
|
|
activeRef.value = true;
|
|
animationTimerId = window.setTimeout(() => {
|
|
activeRef.value = false;
|
|
animationTimerId = null;
|
|
}, 1e3);
|
|
});
|
|
}
|
|
};
|
|
},
|
|
render() {
|
|
const {
|
|
clsPrefix
|
|
} = this;
|
|
return h("div", {
|
|
ref: "selfRef",
|
|
"aria-hidden": true,
|
|
class: [`${clsPrefix}-base-wave`, this.active && `${clsPrefix}-base-wave--active`]
|
|
});
|
|
}
|
|
});
|
|
const {
|
|
cubicBezierEaseInOut,
|
|
cubicBezierEaseOut,
|
|
cubicBezierEaseIn
|
|
} = commonVariables$3;
|
|
function fadeInHeightExpandTransition({
|
|
overflow = "hidden",
|
|
duration: duration2 = ".3s",
|
|
originalTransition = "",
|
|
leavingDelay = "0s",
|
|
foldPadding = false,
|
|
enterToProps = void 0,
|
|
leaveToProps = void 0,
|
|
reverse = false
|
|
} = {}) {
|
|
const enterClass = reverse ? "leave" : "enter";
|
|
const leaveClass = reverse ? "enter" : "leave";
|
|
return [c(`&.fade-in-height-expand-transition-${leaveClass}-from,
|
|
&.fade-in-height-expand-transition-${enterClass}-to`, Object.assign(Object.assign({}, enterToProps), {
|
|
opacity: 1
|
|
})), c(`&.fade-in-height-expand-transition-${leaveClass}-to,
|
|
&.fade-in-height-expand-transition-${enterClass}-from`, Object.assign(Object.assign({}, leaveToProps), {
|
|
opacity: 0,
|
|
marginTop: "0 !important",
|
|
marginBottom: "0 !important",
|
|
paddingTop: foldPadding ? "0 !important" : void 0,
|
|
paddingBottom: foldPadding ? "0 !important" : void 0
|
|
})), c(`&.fade-in-height-expand-transition-${leaveClass}-active`, `
|
|
overflow: ${overflow};
|
|
transition:
|
|
max-height ${duration2} ${cubicBezierEaseInOut} ${leavingDelay},
|
|
opacity ${duration2} ${cubicBezierEaseOut} ${leavingDelay},
|
|
margin-top ${duration2} ${cubicBezierEaseInOut} ${leavingDelay},
|
|
margin-bottom ${duration2} ${cubicBezierEaseInOut} ${leavingDelay},
|
|
padding-top ${duration2} ${cubicBezierEaseInOut} ${leavingDelay},
|
|
padding-bottom ${duration2} ${cubicBezierEaseInOut} ${leavingDelay}
|
|
${originalTransition ? `,${originalTransition}` : ""}
|
|
`), c(`&.fade-in-height-expand-transition-${enterClass}-active`, `
|
|
overflow: ${overflow};
|
|
transition:
|
|
max-height ${duration2} ${cubicBezierEaseInOut},
|
|
opacity ${duration2} ${cubicBezierEaseIn},
|
|
margin-top ${duration2} ${cubicBezierEaseInOut},
|
|
margin-bottom ${duration2} ${cubicBezierEaseInOut},
|
|
padding-top ${duration2} ${cubicBezierEaseInOut},
|
|
padding-bottom ${duration2} ${cubicBezierEaseInOut}
|
|
${originalTransition ? `,${originalTransition}` : ""}
|
|
`)];
|
|
}
|
|
const isChrome = isBrowser$2 && "chrome" in window;
|
|
isBrowser$2 && navigator.userAgent.includes("Firefox");
|
|
const isSafari = isBrowser$2 && navigator.userAgent.includes("Safari") && !isChrome;
|
|
function createHoverColor(rgb) {
|
|
return composite(rgb, [255, 255, 255, 0.16]);
|
|
}
|
|
function createPressedColor(rgb) {
|
|
return composite(rgb, [0, 0, 0, 0.12]);
|
|
}
|
|
const buttonGroupInjectionKey = createInjectionKey("n-button-group");
|
|
const commonVariables$2 = {
|
|
paddingTiny: "0 6px",
|
|
paddingSmall: "0 10px",
|
|
paddingMedium: "0 14px",
|
|
paddingLarge: "0 18px",
|
|
paddingRoundTiny: "0 10px",
|
|
paddingRoundSmall: "0 14px",
|
|
paddingRoundMedium: "0 18px",
|
|
paddingRoundLarge: "0 22px",
|
|
iconMarginTiny: "6px",
|
|
iconMarginSmall: "6px",
|
|
iconMarginMedium: "6px",
|
|
iconMarginLarge: "6px",
|
|
iconSizeTiny: "14px",
|
|
iconSizeSmall: "18px",
|
|
iconSizeMedium: "18px",
|
|
iconSizeLarge: "20px",
|
|
rippleDuration: ".6s"
|
|
};
|
|
function self$8(vars) {
|
|
const {
|
|
heightTiny,
|
|
heightSmall,
|
|
heightMedium,
|
|
heightLarge,
|
|
borderRadius,
|
|
fontSizeTiny,
|
|
fontSizeSmall,
|
|
fontSizeMedium,
|
|
fontSizeLarge,
|
|
opacityDisabled,
|
|
textColor2,
|
|
textColor3,
|
|
primaryColorHover,
|
|
primaryColorPressed,
|
|
borderColor,
|
|
primaryColor,
|
|
baseColor,
|
|
infoColor,
|
|
infoColorHover,
|
|
infoColorPressed,
|
|
successColor,
|
|
successColorHover,
|
|
successColorPressed,
|
|
warningColor,
|
|
warningColorHover,
|
|
warningColorPressed,
|
|
errorColor,
|
|
errorColorHover,
|
|
errorColorPressed,
|
|
fontWeight,
|
|
buttonColor2,
|
|
buttonColor2Hover,
|
|
buttonColor2Pressed,
|
|
fontWeightStrong
|
|
} = vars;
|
|
return Object.assign(Object.assign({}, commonVariables$2), {
|
|
heightTiny,
|
|
heightSmall,
|
|
heightMedium,
|
|
heightLarge,
|
|
borderRadiusTiny: borderRadius,
|
|
borderRadiusSmall: borderRadius,
|
|
borderRadiusMedium: borderRadius,
|
|
borderRadiusLarge: borderRadius,
|
|
fontSizeTiny,
|
|
fontSizeSmall,
|
|
fontSizeMedium,
|
|
fontSizeLarge,
|
|
opacityDisabled,
|
|
// secondary
|
|
colorOpacitySecondary: "0.16",
|
|
colorOpacitySecondaryHover: "0.22",
|
|
colorOpacitySecondaryPressed: "0.28",
|
|
colorSecondary: buttonColor2,
|
|
colorSecondaryHover: buttonColor2Hover,
|
|
colorSecondaryPressed: buttonColor2Pressed,
|
|
// tertiary
|
|
colorTertiary: buttonColor2,
|
|
colorTertiaryHover: buttonColor2Hover,
|
|
colorTertiaryPressed: buttonColor2Pressed,
|
|
// quaternary
|
|
colorQuaternary: "#0000",
|
|
colorQuaternaryHover: buttonColor2Hover,
|
|
colorQuaternaryPressed: buttonColor2Pressed,
|
|
// default type
|
|
color: "#0000",
|
|
colorHover: "#0000",
|
|
colorPressed: "#0000",
|
|
colorFocus: "#0000",
|
|
colorDisabled: "#0000",
|
|
textColor: textColor2,
|
|
textColorTertiary: textColor3,
|
|
textColorHover: primaryColorHover,
|
|
textColorPressed: primaryColorPressed,
|
|
textColorFocus: primaryColorHover,
|
|
textColorDisabled: textColor2,
|
|
textColorText: textColor2,
|
|
textColorTextHover: primaryColorHover,
|
|
textColorTextPressed: primaryColorPressed,
|
|
textColorTextFocus: primaryColorHover,
|
|
textColorTextDisabled: textColor2,
|
|
textColorGhost: textColor2,
|
|
textColorGhostHover: primaryColorHover,
|
|
textColorGhostPressed: primaryColorPressed,
|
|
textColorGhostFocus: primaryColorHover,
|
|
textColorGhostDisabled: textColor2,
|
|
border: `1px solid ${borderColor}`,
|
|
borderHover: `1px solid ${primaryColorHover}`,
|
|
borderPressed: `1px solid ${primaryColorPressed}`,
|
|
borderFocus: `1px solid ${primaryColorHover}`,
|
|
borderDisabled: `1px solid ${borderColor}`,
|
|
rippleColor: primaryColor,
|
|
// primary
|
|
colorPrimary: primaryColor,
|
|
colorHoverPrimary: primaryColorHover,
|
|
colorPressedPrimary: primaryColorPressed,
|
|
colorFocusPrimary: primaryColorHover,
|
|
colorDisabledPrimary: primaryColor,
|
|
textColorPrimary: baseColor,
|
|
textColorHoverPrimary: baseColor,
|
|
textColorPressedPrimary: baseColor,
|
|
textColorFocusPrimary: baseColor,
|
|
textColorDisabledPrimary: baseColor,
|
|
textColorTextPrimary: primaryColor,
|
|
textColorTextHoverPrimary: primaryColorHover,
|
|
textColorTextPressedPrimary: primaryColorPressed,
|
|
textColorTextFocusPrimary: primaryColorHover,
|
|
textColorTextDisabledPrimary: textColor2,
|
|
textColorGhostPrimary: primaryColor,
|
|
textColorGhostHoverPrimary: primaryColorHover,
|
|
textColorGhostPressedPrimary: primaryColorPressed,
|
|
textColorGhostFocusPrimary: primaryColorHover,
|
|
textColorGhostDisabledPrimary: primaryColor,
|
|
borderPrimary: `1px solid ${primaryColor}`,
|
|
borderHoverPrimary: `1px solid ${primaryColorHover}`,
|
|
borderPressedPrimary: `1px solid ${primaryColorPressed}`,
|
|
borderFocusPrimary: `1px solid ${primaryColorHover}`,
|
|
borderDisabledPrimary: `1px solid ${primaryColor}`,
|
|
rippleColorPrimary: primaryColor,
|
|
// info
|
|
colorInfo: infoColor,
|
|
colorHoverInfo: infoColorHover,
|
|
colorPressedInfo: infoColorPressed,
|
|
colorFocusInfo: infoColorHover,
|
|
colorDisabledInfo: infoColor,
|
|
textColorInfo: baseColor,
|
|
textColorHoverInfo: baseColor,
|
|
textColorPressedInfo: baseColor,
|
|
textColorFocusInfo: baseColor,
|
|
textColorDisabledInfo: baseColor,
|
|
textColorTextInfo: infoColor,
|
|
textColorTextHoverInfo: infoColorHover,
|
|
textColorTextPressedInfo: infoColorPressed,
|
|
textColorTextFocusInfo: infoColorHover,
|
|
textColorTextDisabledInfo: textColor2,
|
|
textColorGhostInfo: infoColor,
|
|
textColorGhostHoverInfo: infoColorHover,
|
|
textColorGhostPressedInfo: infoColorPressed,
|
|
textColorGhostFocusInfo: infoColorHover,
|
|
textColorGhostDisabledInfo: infoColor,
|
|
borderInfo: `1px solid ${infoColor}`,
|
|
borderHoverInfo: `1px solid ${infoColorHover}`,
|
|
borderPressedInfo: `1px solid ${infoColorPressed}`,
|
|
borderFocusInfo: `1px solid ${infoColorHover}`,
|
|
borderDisabledInfo: `1px solid ${infoColor}`,
|
|
rippleColorInfo: infoColor,
|
|
// success
|
|
colorSuccess: successColor,
|
|
colorHoverSuccess: successColorHover,
|
|
colorPressedSuccess: successColorPressed,
|
|
colorFocusSuccess: successColorHover,
|
|
colorDisabledSuccess: successColor,
|
|
textColorSuccess: baseColor,
|
|
textColorHoverSuccess: baseColor,
|
|
textColorPressedSuccess: baseColor,
|
|
textColorFocusSuccess: baseColor,
|
|
textColorDisabledSuccess: baseColor,
|
|
textColorTextSuccess: successColor,
|
|
textColorTextHoverSuccess: successColorHover,
|
|
textColorTextPressedSuccess: successColorPressed,
|
|
textColorTextFocusSuccess: successColorHover,
|
|
textColorTextDisabledSuccess: textColor2,
|
|
textColorGhostSuccess: successColor,
|
|
textColorGhostHoverSuccess: successColorHover,
|
|
textColorGhostPressedSuccess: successColorPressed,
|
|
textColorGhostFocusSuccess: successColorHover,
|
|
textColorGhostDisabledSuccess: successColor,
|
|
borderSuccess: `1px solid ${successColor}`,
|
|
borderHoverSuccess: `1px solid ${successColorHover}`,
|
|
borderPressedSuccess: `1px solid ${successColorPressed}`,
|
|
borderFocusSuccess: `1px solid ${successColorHover}`,
|
|
borderDisabledSuccess: `1px solid ${successColor}`,
|
|
rippleColorSuccess: successColor,
|
|
// warning
|
|
colorWarning: warningColor,
|
|
colorHoverWarning: warningColorHover,
|
|
colorPressedWarning: warningColorPressed,
|
|
colorFocusWarning: warningColorHover,
|
|
colorDisabledWarning: warningColor,
|
|
textColorWarning: baseColor,
|
|
textColorHoverWarning: baseColor,
|
|
textColorPressedWarning: baseColor,
|
|
textColorFocusWarning: baseColor,
|
|
textColorDisabledWarning: baseColor,
|
|
textColorTextWarning: warningColor,
|
|
textColorTextHoverWarning: warningColorHover,
|
|
textColorTextPressedWarning: warningColorPressed,
|
|
textColorTextFocusWarning: warningColorHover,
|
|
textColorTextDisabledWarning: textColor2,
|
|
textColorGhostWarning: warningColor,
|
|
textColorGhostHoverWarning: warningColorHover,
|
|
textColorGhostPressedWarning: warningColorPressed,
|
|
textColorGhostFocusWarning: warningColorHover,
|
|
textColorGhostDisabledWarning: warningColor,
|
|
borderWarning: `1px solid ${warningColor}`,
|
|
borderHoverWarning: `1px solid ${warningColorHover}`,
|
|
borderPressedWarning: `1px solid ${warningColorPressed}`,
|
|
borderFocusWarning: `1px solid ${warningColorHover}`,
|
|
borderDisabledWarning: `1px solid ${warningColor}`,
|
|
rippleColorWarning: warningColor,
|
|
// error
|
|
colorError: errorColor,
|
|
colorHoverError: errorColorHover,
|
|
colorPressedError: errorColorPressed,
|
|
colorFocusError: errorColorHover,
|
|
colorDisabledError: errorColor,
|
|
textColorError: baseColor,
|
|
textColorHoverError: baseColor,
|
|
textColorPressedError: baseColor,
|
|
textColorFocusError: baseColor,
|
|
textColorDisabledError: baseColor,
|
|
textColorTextError: errorColor,
|
|
textColorTextHoverError: errorColorHover,
|
|
textColorTextPressedError: errorColorPressed,
|
|
textColorTextFocusError: errorColorHover,
|
|
textColorTextDisabledError: textColor2,
|
|
textColorGhostError: errorColor,
|
|
textColorGhostHoverError: errorColorHover,
|
|
textColorGhostPressedError: errorColorPressed,
|
|
textColorGhostFocusError: errorColorHover,
|
|
textColorGhostDisabledError: errorColor,
|
|
borderError: `1px solid ${errorColor}`,
|
|
borderHoverError: `1px solid ${errorColorHover}`,
|
|
borderPressedError: `1px solid ${errorColorPressed}`,
|
|
borderFocusError: `1px solid ${errorColorHover}`,
|
|
borderDisabledError: `1px solid ${errorColor}`,
|
|
rippleColorError: errorColor,
|
|
waveOpacity: "0.6",
|
|
fontWeight,
|
|
fontWeightStrong
|
|
});
|
|
}
|
|
const buttonLight = {
|
|
name: "Button",
|
|
common: derived,
|
|
self: self$8
|
|
};
|
|
const style$a = c([cB("button", `
|
|
margin: 0;
|
|
font-weight: var(--n-font-weight);
|
|
line-height: 1;
|
|
font-family: inherit;
|
|
padding: var(--n-padding);
|
|
height: var(--n-height);
|
|
font-size: var(--n-font-size);
|
|
border-radius: var(--n-border-radius);
|
|
color: var(--n-text-color);
|
|
background-color: var(--n-color);
|
|
width: var(--n-width);
|
|
white-space: nowrap;
|
|
outline: none;
|
|
position: relative;
|
|
z-index: auto;
|
|
border: none;
|
|
display: inline-flex;
|
|
flex-wrap: nowrap;
|
|
flex-shrink: 0;
|
|
align-items: center;
|
|
justify-content: center;
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
text-align: center;
|
|
cursor: pointer;
|
|
text-decoration: none;
|
|
transition:
|
|
color .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier),
|
|
opacity .3s var(--n-bezier),
|
|
border-color .3s var(--n-bezier);
|
|
`, [cM("color", [cE("border", {
|
|
borderColor: "var(--n-border-color)"
|
|
}), cM("disabled", [cE("border", {
|
|
borderColor: "var(--n-border-color-disabled)"
|
|
})]), cNotM("disabled", [c("&:focus", [cE("state-border", {
|
|
borderColor: "var(--n-border-color-focus)"
|
|
})]), c("&:hover", [cE("state-border", {
|
|
borderColor: "var(--n-border-color-hover)"
|
|
})]), c("&:active", [cE("state-border", {
|
|
borderColor: "var(--n-border-color-pressed)"
|
|
})]), cM("pressed", [cE("state-border", {
|
|
borderColor: "var(--n-border-color-pressed)"
|
|
})])])]), cM("disabled", {
|
|
backgroundColor: "var(--n-color-disabled)",
|
|
color: "var(--n-text-color-disabled)"
|
|
}, [cE("border", {
|
|
border: "var(--n-border-disabled)"
|
|
})]), cNotM("disabled", [c("&:focus", {
|
|
backgroundColor: "var(--n-color-focus)",
|
|
color: "var(--n-text-color-focus)"
|
|
}, [cE("state-border", {
|
|
border: "var(--n-border-focus)"
|
|
})]), c("&:hover", {
|
|
backgroundColor: "var(--n-color-hover)",
|
|
color: "var(--n-text-color-hover)"
|
|
}, [cE("state-border", {
|
|
border: "var(--n-border-hover)"
|
|
})]), c("&:active", {
|
|
backgroundColor: "var(--n-color-pressed)",
|
|
color: "var(--n-text-color-pressed)"
|
|
}, [cE("state-border", {
|
|
border: "var(--n-border-pressed)"
|
|
})]), cM("pressed", {
|
|
backgroundColor: "var(--n-color-pressed)",
|
|
color: "var(--n-text-color-pressed)"
|
|
}, [cE("state-border", {
|
|
border: "var(--n-border-pressed)"
|
|
})])]), cM("loading", "cursor: wait;"), cB("base-wave", `
|
|
pointer-events: none;
|
|
top: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
left: 0;
|
|
animation-iteration-count: 1;
|
|
animation-duration: var(--n-ripple-duration);
|
|
animation-timing-function: var(--n-bezier-ease-out), var(--n-bezier-ease-out);
|
|
`, [cM("active", {
|
|
zIndex: 1,
|
|
animationName: "button-wave-spread, button-wave-opacity"
|
|
})]), isBrowser$2 && "MozBoxSizing" in document.createElement("div").style ? c("&::moz-focus-inner", {
|
|
border: 0
|
|
}) : null, cE("border, state-border", `
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
border-radius: inherit;
|
|
transition: border-color .3s var(--n-bezier);
|
|
pointer-events: none;
|
|
`), cE("border", {
|
|
border: "var(--n-border)"
|
|
}), cE("state-border", {
|
|
border: "var(--n-border)",
|
|
borderColor: "#0000",
|
|
zIndex: 1
|
|
}), cE("icon", `
|
|
margin: var(--n-icon-margin);
|
|
margin-left: 0;
|
|
height: var(--n-icon-size);
|
|
width: var(--n-icon-size);
|
|
max-width: var(--n-icon-size);
|
|
font-size: var(--n-icon-size);
|
|
position: relative;
|
|
flex-shrink: 0;
|
|
`, [cB("icon-slot", `
|
|
height: var(--n-icon-size);
|
|
width: var(--n-icon-size);
|
|
position: absolute;
|
|
left: 0;
|
|
top: 50%;
|
|
transform: translateY(-50%);
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
`, [iconSwitchTransition({
|
|
top: "50%",
|
|
originalTransform: "translateY(-50%)"
|
|
})]), fadeInWidthExpandTransition()]), cE("content", `
|
|
display: flex;
|
|
align-items: center;
|
|
flex-wrap: nowrap;
|
|
min-width: 0;
|
|
`, [c("~", [cE("icon", {
|
|
margin: "var(--n-icon-margin)",
|
|
marginRight: 0
|
|
})])]), cM("block", `
|
|
display: flex;
|
|
width: 100%;
|
|
`), cM("dashed", [cE("border, state-border", {
|
|
borderStyle: "dashed !important"
|
|
})]), cM("disabled", {
|
|
cursor: "not-allowed",
|
|
opacity: "var(--n-opacity-disabled)"
|
|
})]), c("@keyframes button-wave-spread", {
|
|
from: {
|
|
boxShadow: "0 0 0.5px 0 var(--n-ripple-color)"
|
|
},
|
|
to: {
|
|
// don't use exact 5px since chrome will display the animation with glitches
|
|
boxShadow: "0 0 0.5px 4.5px var(--n-ripple-color)"
|
|
}
|
|
}), c("@keyframes button-wave-opacity", {
|
|
from: {
|
|
opacity: "var(--n-wave-opacity)"
|
|
},
|
|
to: {
|
|
opacity: 0
|
|
}
|
|
})]);
|
|
const buttonProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
color: String,
|
|
textColor: String,
|
|
text: Boolean,
|
|
block: Boolean,
|
|
loading: Boolean,
|
|
disabled: Boolean,
|
|
circle: Boolean,
|
|
size: String,
|
|
ghost: Boolean,
|
|
round: Boolean,
|
|
secondary: Boolean,
|
|
tertiary: Boolean,
|
|
quaternary: Boolean,
|
|
strong: Boolean,
|
|
focusable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
keyboard: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
tag: {
|
|
type: String,
|
|
default: "button"
|
|
},
|
|
type: {
|
|
type: String,
|
|
default: "default"
|
|
},
|
|
dashed: Boolean,
|
|
renderIcon: Function,
|
|
iconPlacement: {
|
|
type: String,
|
|
default: "left"
|
|
},
|
|
attrType: {
|
|
type: String,
|
|
default: "button"
|
|
},
|
|
bordered: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
onClick: [Function, Array],
|
|
nativeFocusBehavior: {
|
|
type: Boolean,
|
|
default: !isSafari
|
|
}
|
|
});
|
|
const Button$1 = /* @__PURE__ */ defineComponent({
|
|
name: "Button",
|
|
props: buttonProps,
|
|
slots: Object,
|
|
setup(props) {
|
|
const selfElRef = ref(null);
|
|
const waveElRef = ref(null);
|
|
const enterPressedRef = ref(false);
|
|
const showBorderRef = useMemo(() => {
|
|
return !props.quaternary && !props.tertiary && !props.secondary && !props.text && (!props.color || props.ghost || props.dashed) && props.bordered;
|
|
});
|
|
const NButtonGroup = inject(buttonGroupInjectionKey, {});
|
|
const {
|
|
mergedSizeRef
|
|
} = useFormItem({}, {
|
|
defaultSize: "medium",
|
|
mergedSize: (NFormItem) => {
|
|
const {
|
|
size: size2
|
|
} = props;
|
|
if (size2) return size2;
|
|
const {
|
|
size: buttonGroupSize
|
|
} = NButtonGroup;
|
|
if (buttonGroupSize) return buttonGroupSize;
|
|
const {
|
|
mergedSize: formItemSize
|
|
} = NFormItem || {};
|
|
if (formItemSize) {
|
|
return formItemSize.value;
|
|
}
|
|
return "medium";
|
|
}
|
|
});
|
|
const mergedFocusableRef = computed(() => {
|
|
return props.focusable && !props.disabled;
|
|
});
|
|
const handleMousedown = (e) => {
|
|
var _a;
|
|
if (!mergedFocusableRef.value) {
|
|
e.preventDefault();
|
|
}
|
|
if (props.nativeFocusBehavior) {
|
|
return;
|
|
}
|
|
e.preventDefault();
|
|
if (props.disabled) {
|
|
return;
|
|
}
|
|
if (mergedFocusableRef.value) {
|
|
(_a = selfElRef.value) === null || _a === void 0 ? void 0 : _a.focus({
|
|
preventScroll: true
|
|
});
|
|
}
|
|
};
|
|
const handleClick2 = (e) => {
|
|
var _a;
|
|
if (!props.disabled && !props.loading) {
|
|
const {
|
|
onClick
|
|
} = props;
|
|
if (onClick) call(onClick, e);
|
|
if (!props.text) {
|
|
(_a = waveElRef.value) === null || _a === void 0 ? void 0 : _a.play();
|
|
}
|
|
}
|
|
};
|
|
const handleKeyup = (e) => {
|
|
switch (e.key) {
|
|
case "Enter":
|
|
if (!props.keyboard) {
|
|
return;
|
|
}
|
|
enterPressedRef.value = false;
|
|
}
|
|
};
|
|
const handleKeydown = (e) => {
|
|
switch (e.key) {
|
|
case "Enter":
|
|
if (!props.keyboard || props.loading) {
|
|
e.preventDefault();
|
|
return;
|
|
}
|
|
enterPressedRef.value = true;
|
|
}
|
|
};
|
|
const handleBlur = () => {
|
|
enterPressedRef.value = false;
|
|
};
|
|
const {
|
|
inlineThemeDisabled,
|
|
mergedClsPrefixRef,
|
|
mergedRtlRef
|
|
} = useConfig(props);
|
|
const themeRef = useTheme("Button", "-button", style$a, buttonLight, props, mergedClsPrefixRef);
|
|
const rtlEnabledRef = useRtl("Button", mergedRtlRef, mergedClsPrefixRef);
|
|
const cssVarsRef = computed(() => {
|
|
const theme = themeRef.value;
|
|
const {
|
|
common: {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2,
|
|
cubicBezierEaseOut: cubicBezierEaseOut2
|
|
},
|
|
self: self2
|
|
} = theme;
|
|
const {
|
|
rippleDuration,
|
|
opacityDisabled,
|
|
fontWeight,
|
|
fontWeightStrong
|
|
} = self2;
|
|
const size2 = mergedSizeRef.value;
|
|
const {
|
|
dashed,
|
|
type,
|
|
ghost,
|
|
text,
|
|
color,
|
|
round,
|
|
circle,
|
|
textColor,
|
|
secondary,
|
|
tertiary,
|
|
quaternary,
|
|
strong
|
|
} = props;
|
|
const fontProps = {
|
|
"--n-font-weight": strong ? fontWeightStrong : fontWeight
|
|
};
|
|
let colorProps = {
|
|
"--n-color": "initial",
|
|
"--n-color-hover": "initial",
|
|
"--n-color-pressed": "initial",
|
|
"--n-color-focus": "initial",
|
|
"--n-color-disabled": "initial",
|
|
"--n-ripple-color": "initial",
|
|
"--n-text-color": "initial",
|
|
"--n-text-color-hover": "initial",
|
|
"--n-text-color-pressed": "initial",
|
|
"--n-text-color-focus": "initial",
|
|
"--n-text-color-disabled": "initial"
|
|
};
|
|
const typeIsTertiary = type === "tertiary";
|
|
const typeIsDefault = type === "default";
|
|
const mergedType = typeIsTertiary ? "default" : type;
|
|
if (text) {
|
|
const propTextColor = textColor || color;
|
|
const mergedTextColor = propTextColor || self2[createKey("textColorText", mergedType)];
|
|
colorProps = {
|
|
"--n-color": "#0000",
|
|
"--n-color-hover": "#0000",
|
|
"--n-color-pressed": "#0000",
|
|
"--n-color-focus": "#0000",
|
|
"--n-color-disabled": "#0000",
|
|
"--n-ripple-color": "#0000",
|
|
"--n-text-color": mergedTextColor,
|
|
"--n-text-color-hover": propTextColor ? createHoverColor(propTextColor) : self2[createKey("textColorTextHover", mergedType)],
|
|
"--n-text-color-pressed": propTextColor ? createPressedColor(propTextColor) : self2[createKey("textColorTextPressed", mergedType)],
|
|
"--n-text-color-focus": propTextColor ? createHoverColor(propTextColor) : self2[createKey("textColorTextHover", mergedType)],
|
|
"--n-text-color-disabled": propTextColor || self2[createKey("textColorTextDisabled", mergedType)]
|
|
};
|
|
} else if (ghost || dashed) {
|
|
const mergedTextColor = textColor || color;
|
|
colorProps = {
|
|
"--n-color": "#0000",
|
|
"--n-color-hover": "#0000",
|
|
"--n-color-pressed": "#0000",
|
|
"--n-color-focus": "#0000",
|
|
"--n-color-disabled": "#0000",
|
|
"--n-ripple-color": color || self2[createKey("rippleColor", mergedType)],
|
|
"--n-text-color": mergedTextColor || self2[createKey("textColorGhost", mergedType)],
|
|
"--n-text-color-hover": mergedTextColor ? createHoverColor(mergedTextColor) : self2[createKey("textColorGhostHover", mergedType)],
|
|
"--n-text-color-pressed": mergedTextColor ? createPressedColor(mergedTextColor) : self2[createKey("textColorGhostPressed", mergedType)],
|
|
"--n-text-color-focus": mergedTextColor ? createHoverColor(mergedTextColor) : self2[createKey("textColorGhostHover", mergedType)],
|
|
"--n-text-color-disabled": mergedTextColor || self2[createKey("textColorGhostDisabled", mergedType)]
|
|
};
|
|
} else if (secondary) {
|
|
const typeTextColor = typeIsDefault ? self2.textColor : typeIsTertiary ? self2.textColorTertiary : self2[createKey("color", mergedType)];
|
|
const mergedTextColor = color || typeTextColor;
|
|
const isColoredType = type !== "default" && type !== "tertiary";
|
|
colorProps = {
|
|
"--n-color": isColoredType ? changeColor(mergedTextColor, {
|
|
alpha: Number(self2.colorOpacitySecondary)
|
|
}) : self2.colorSecondary,
|
|
"--n-color-hover": isColoredType ? changeColor(mergedTextColor, {
|
|
alpha: Number(self2.colorOpacitySecondaryHover)
|
|
}) : self2.colorSecondaryHover,
|
|
"--n-color-pressed": isColoredType ? changeColor(mergedTextColor, {
|
|
alpha: Number(self2.colorOpacitySecondaryPressed)
|
|
}) : self2.colorSecondaryPressed,
|
|
"--n-color-focus": isColoredType ? changeColor(mergedTextColor, {
|
|
alpha: Number(self2.colorOpacitySecondaryHover)
|
|
}) : self2.colorSecondaryHover,
|
|
"--n-color-disabled": self2.colorSecondary,
|
|
"--n-ripple-color": "#0000",
|
|
"--n-text-color": mergedTextColor,
|
|
"--n-text-color-hover": mergedTextColor,
|
|
"--n-text-color-pressed": mergedTextColor,
|
|
"--n-text-color-focus": mergedTextColor,
|
|
"--n-text-color-disabled": mergedTextColor
|
|
};
|
|
} else if (tertiary || quaternary) {
|
|
const typeColor = typeIsDefault ? self2.textColor : typeIsTertiary ? self2.textColorTertiary : self2[createKey("color", mergedType)];
|
|
const mergedColor = color || typeColor;
|
|
if (tertiary) {
|
|
colorProps["--n-color"] = self2.colorTertiary;
|
|
colorProps["--n-color-hover"] = self2.colorTertiaryHover;
|
|
colorProps["--n-color-pressed"] = self2.colorTertiaryPressed;
|
|
colorProps["--n-color-focus"] = self2.colorSecondaryHover;
|
|
colorProps["--n-color-disabled"] = self2.colorTertiary;
|
|
} else {
|
|
colorProps["--n-color"] = self2.colorQuaternary;
|
|
colorProps["--n-color-hover"] = self2.colorQuaternaryHover;
|
|
colorProps["--n-color-pressed"] = self2.colorQuaternaryPressed;
|
|
colorProps["--n-color-focus"] = self2.colorQuaternaryHover;
|
|
colorProps["--n-color-disabled"] = self2.colorQuaternary;
|
|
}
|
|
colorProps["--n-ripple-color"] = "#0000";
|
|
colorProps["--n-text-color"] = mergedColor;
|
|
colorProps["--n-text-color-hover"] = mergedColor;
|
|
colorProps["--n-text-color-pressed"] = mergedColor;
|
|
colorProps["--n-text-color-focus"] = mergedColor;
|
|
colorProps["--n-text-color-disabled"] = mergedColor;
|
|
} else {
|
|
colorProps = {
|
|
"--n-color": color || self2[createKey("color", mergedType)],
|
|
"--n-color-hover": color ? createHoverColor(color) : self2[createKey("colorHover", mergedType)],
|
|
"--n-color-pressed": color ? createPressedColor(color) : self2[createKey("colorPressed", mergedType)],
|
|
"--n-color-focus": color ? createHoverColor(color) : self2[createKey("colorFocus", mergedType)],
|
|
"--n-color-disabled": color || self2[createKey("colorDisabled", mergedType)],
|
|
"--n-ripple-color": color || self2[createKey("rippleColor", mergedType)],
|
|
"--n-text-color": textColor || (color ? self2.textColorPrimary : typeIsTertiary ? self2.textColorTertiary : self2[createKey("textColor", mergedType)]),
|
|
"--n-text-color-hover": textColor || (color ? self2.textColorHoverPrimary : self2[createKey("textColorHover", mergedType)]),
|
|
"--n-text-color-pressed": textColor || (color ? self2.textColorPressedPrimary : self2[createKey("textColorPressed", mergedType)]),
|
|
"--n-text-color-focus": textColor || (color ? self2.textColorFocusPrimary : self2[createKey("textColorFocus", mergedType)]),
|
|
"--n-text-color-disabled": textColor || (color ? self2.textColorDisabledPrimary : self2[createKey("textColorDisabled", mergedType)])
|
|
};
|
|
}
|
|
let borderProps = {
|
|
"--n-border": "initial",
|
|
"--n-border-hover": "initial",
|
|
"--n-border-pressed": "initial",
|
|
"--n-border-focus": "initial",
|
|
"--n-border-disabled": "initial"
|
|
};
|
|
if (text) {
|
|
borderProps = {
|
|
"--n-border": "none",
|
|
"--n-border-hover": "none",
|
|
"--n-border-pressed": "none",
|
|
"--n-border-focus": "none",
|
|
"--n-border-disabled": "none"
|
|
};
|
|
} else {
|
|
borderProps = {
|
|
"--n-border": self2[createKey("border", mergedType)],
|
|
"--n-border-hover": self2[createKey("borderHover", mergedType)],
|
|
"--n-border-pressed": self2[createKey("borderPressed", mergedType)],
|
|
"--n-border-focus": self2[createKey("borderFocus", mergedType)],
|
|
"--n-border-disabled": self2[createKey("borderDisabled", mergedType)]
|
|
};
|
|
}
|
|
const {
|
|
[createKey("height", size2)]: height,
|
|
[createKey("fontSize", size2)]: fontSize2,
|
|
[createKey("padding", size2)]: padding,
|
|
[createKey("paddingRound", size2)]: paddingRound,
|
|
[createKey("iconSize", size2)]: iconSize,
|
|
[createKey("borderRadius", size2)]: borderRadius,
|
|
[createKey("iconMargin", size2)]: iconMargin,
|
|
waveOpacity
|
|
} = self2;
|
|
const sizeProps = {
|
|
"--n-width": circle && !text ? height : "initial",
|
|
"--n-height": text ? "initial" : height,
|
|
"--n-font-size": fontSize2,
|
|
"--n-padding": circle ? "initial" : text ? "initial" : round ? paddingRound : padding,
|
|
"--n-icon-size": iconSize,
|
|
"--n-icon-margin": iconMargin,
|
|
"--n-border-radius": text ? "initial" : circle || round ? height : borderRadius
|
|
};
|
|
return Object.assign(Object.assign(Object.assign(Object.assign({
|
|
"--n-bezier": cubicBezierEaseInOut2,
|
|
"--n-bezier-ease-out": cubicBezierEaseOut2,
|
|
"--n-ripple-duration": rippleDuration,
|
|
"--n-opacity-disabled": opacityDisabled,
|
|
"--n-wave-opacity": waveOpacity
|
|
}, fontProps), colorProps), borderProps), sizeProps);
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("button", computed(() => {
|
|
let hash = "";
|
|
const {
|
|
dashed,
|
|
type,
|
|
ghost,
|
|
text,
|
|
color,
|
|
round,
|
|
circle,
|
|
textColor,
|
|
secondary,
|
|
tertiary,
|
|
quaternary,
|
|
strong
|
|
} = props;
|
|
if (dashed) hash += "a";
|
|
if (ghost) hash += "b";
|
|
if (text) hash += "c";
|
|
if (round) hash += "d";
|
|
if (circle) hash += "e";
|
|
if (secondary) hash += "f";
|
|
if (tertiary) hash += "g";
|
|
if (quaternary) hash += "h";
|
|
if (strong) hash += "i";
|
|
if (color) hash += `j${color2Class(color)}`;
|
|
if (textColor) hash += `k${color2Class(textColor)}`;
|
|
const {
|
|
value: size2
|
|
} = mergedSizeRef;
|
|
hash += `l${size2[0]}`;
|
|
hash += `m${type[0]}`;
|
|
return hash;
|
|
}), cssVarsRef, props) : void 0;
|
|
return {
|
|
selfElRef,
|
|
waveElRef,
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
mergedFocusable: mergedFocusableRef,
|
|
mergedSize: mergedSizeRef,
|
|
showBorder: showBorderRef,
|
|
enterPressed: enterPressedRef,
|
|
rtlEnabled: rtlEnabledRef,
|
|
handleMousedown,
|
|
handleKeydown,
|
|
handleBlur,
|
|
handleKeyup,
|
|
handleClick: handleClick2,
|
|
customColorCssVars: computed(() => {
|
|
const {
|
|
color
|
|
} = props;
|
|
if (!color) return null;
|
|
const hoverColor = createHoverColor(color);
|
|
return {
|
|
"--n-border-color": color,
|
|
"--n-border-color-hover": hoverColor,
|
|
"--n-border-color-pressed": createPressedColor(color),
|
|
"--n-border-color-focus": hoverColor,
|
|
"--n-border-color-disabled": color
|
|
};
|
|
}),
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
};
|
|
},
|
|
render() {
|
|
const {
|
|
mergedClsPrefix,
|
|
tag: Component,
|
|
onRender
|
|
} = this;
|
|
onRender === null || onRender === void 0 ? void 0 : onRender();
|
|
const children = resolveWrappedSlot(this.$slots.default, (children2) => children2 && h("span", {
|
|
class: `${mergedClsPrefix}-button__content`
|
|
}, children2));
|
|
return h(Component, {
|
|
ref: "selfElRef",
|
|
class: [
|
|
this.themeClass,
|
|
`${mergedClsPrefix}-button`,
|
|
`${mergedClsPrefix}-button--${this.type}-type`,
|
|
`${mergedClsPrefix}-button--${this.mergedSize}-type`,
|
|
this.rtlEnabled && `${mergedClsPrefix}-button--rtl`,
|
|
this.disabled && `${mergedClsPrefix}-button--disabled`,
|
|
this.block && `${mergedClsPrefix}-button--block`,
|
|
this.enterPressed && `${mergedClsPrefix}-button--pressed`,
|
|
!this.text && this.dashed && `${mergedClsPrefix}-button--dashed`,
|
|
this.color && `${mergedClsPrefix}-button--color`,
|
|
this.secondary && `${mergedClsPrefix}-button--secondary`,
|
|
this.loading && `${mergedClsPrefix}-button--loading`,
|
|
this.ghost && `${mergedClsPrefix}-button--ghost`
|
|
// required for button group border collapse
|
|
],
|
|
tabindex: this.mergedFocusable ? 0 : -1,
|
|
type: this.attrType,
|
|
style: this.cssVars,
|
|
disabled: this.disabled,
|
|
onClick: this.handleClick,
|
|
onBlur: this.handleBlur,
|
|
onMousedown: this.handleMousedown,
|
|
onKeyup: this.handleKeyup,
|
|
onKeydown: this.handleKeydown
|
|
}, this.iconPlacement === "right" && children, h(NFadeInExpandTransition, {
|
|
width: true
|
|
}, {
|
|
default: () => resolveWrappedSlot(this.$slots.icon, (children2) => (this.loading || this.renderIcon || children2) && h("span", {
|
|
class: `${mergedClsPrefix}-button__icon`,
|
|
style: {
|
|
margin: isSlotEmpty(this.$slots.default) ? "0" : ""
|
|
}
|
|
}, h(NIconSwitchTransition, null, {
|
|
default: () => this.loading ? h(NBaseLoading, {
|
|
clsPrefix: mergedClsPrefix,
|
|
key: "loading",
|
|
class: `${mergedClsPrefix}-icon-slot`,
|
|
strokeWidth: 20
|
|
}) : h("div", {
|
|
key: "icon",
|
|
class: `${mergedClsPrefix}-icon-slot`,
|
|
role: "none"
|
|
}, this.renderIcon ? this.renderIcon() : children2)
|
|
})))
|
|
}), this.iconPlacement === "left" && children, !this.text ? h(NBaseWave, {
|
|
ref: "waveElRef",
|
|
clsPrefix: mergedClsPrefix
|
|
}) : null, this.showBorder ? h("div", {
|
|
"aria-hidden": true,
|
|
class: `${mergedClsPrefix}-button__border`,
|
|
style: this.customColorCssVars
|
|
}) : null, this.showBorder ? h("div", {
|
|
"aria-hidden": true,
|
|
class: `${mergedClsPrefix}-button__state-border`,
|
|
style: this.customColorCssVars
|
|
}) : null);
|
|
}
|
|
});
|
|
const XButton = Button$1;
|
|
const commonVariables$1 = {
|
|
paddingSmall: "12px 16px 12px",
|
|
paddingMedium: "19px 24px 20px",
|
|
paddingLarge: "23px 32px 24px",
|
|
paddingHuge: "27px 40px 28px",
|
|
titleFontSizeSmall: "16px",
|
|
titleFontSizeMedium: "18px",
|
|
titleFontSizeLarge: "18px",
|
|
titleFontSizeHuge: "18px",
|
|
closeIconSize: "18px",
|
|
closeSize: "22px"
|
|
};
|
|
function self$7(vars) {
|
|
const {
|
|
primaryColor,
|
|
borderRadius,
|
|
lineHeight: lineHeight2,
|
|
fontSize: fontSize2,
|
|
cardColor,
|
|
textColor2,
|
|
textColor1,
|
|
dividerColor,
|
|
fontWeightStrong,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
modalColor,
|
|
boxShadow1,
|
|
popoverColor,
|
|
actionColor
|
|
} = vars;
|
|
return Object.assign(Object.assign({}, commonVariables$1), {
|
|
lineHeight: lineHeight2,
|
|
color: cardColor,
|
|
colorModal: modalColor,
|
|
colorPopover: popoverColor,
|
|
colorTarget: primaryColor,
|
|
colorEmbedded: actionColor,
|
|
colorEmbeddedModal: actionColor,
|
|
colorEmbeddedPopover: actionColor,
|
|
textColor: textColor2,
|
|
titleTextColor: textColor1,
|
|
borderColor: dividerColor,
|
|
actionColor,
|
|
titleFontWeight: fontWeightStrong,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
closeBorderRadius: borderRadius,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
fontSizeSmall: fontSize2,
|
|
fontSizeMedium: fontSize2,
|
|
fontSizeLarge: fontSize2,
|
|
fontSizeHuge: fontSize2,
|
|
boxShadow: boxShadow1,
|
|
borderRadius
|
|
});
|
|
}
|
|
const cardLight = {
|
|
name: "Card",
|
|
common: derived,
|
|
self: self$7
|
|
};
|
|
const style$9 = c([cB("card", `
|
|
font-size: var(--n-font-size);
|
|
line-height: var(--n-line-height);
|
|
display: flex;
|
|
flex-direction: column;
|
|
width: 100%;
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
border-radius: var(--n-border-radius);
|
|
background-color: var(--n-color);
|
|
color: var(--n-text-color);
|
|
word-break: break-word;
|
|
transition:
|
|
color .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier),
|
|
box-shadow .3s var(--n-bezier),
|
|
border-color .3s var(--n-bezier);
|
|
`, [asModal({
|
|
background: "var(--n-color-modal)"
|
|
}), cM("hoverable", [c("&:hover", "box-shadow: var(--n-box-shadow);")]), cM("content-segmented", [c(">", [cE("content", {
|
|
paddingTop: "var(--n-padding-bottom)"
|
|
})])]), cM("content-soft-segmented", [c(">", [cE("content", `
|
|
margin: 0 var(--n-padding-left);
|
|
padding: var(--n-padding-bottom) 0;
|
|
`)])]), cM("footer-segmented", [c(">", [cE("footer", {
|
|
paddingTop: "var(--n-padding-bottom)"
|
|
})])]), cM("footer-soft-segmented", [c(">", [cE("footer", `
|
|
padding: var(--n-padding-bottom) 0;
|
|
margin: 0 var(--n-padding-left);
|
|
`)])]), c(">", [cB("card-header", `
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: var(--n-title-font-size);
|
|
padding:
|
|
var(--n-padding-top)
|
|
var(--n-padding-left)
|
|
var(--n-padding-bottom)
|
|
var(--n-padding-left);
|
|
`, [cE("main", `
|
|
font-weight: var(--n-title-font-weight);
|
|
transition: color .3s var(--n-bezier);
|
|
flex: 1;
|
|
min-width: 0;
|
|
color: var(--n-title-text-color);
|
|
`), cE("extra", `
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: var(--n-font-size);
|
|
font-weight: 400;
|
|
transition: color .3s var(--n-bezier);
|
|
color: var(--n-text-color);
|
|
`), cE("close", `
|
|
margin: 0 0 0 8px;
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier);
|
|
`)]), cE("action", `
|
|
box-sizing: border-box;
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
border-color .3s var(--n-bezier);
|
|
background-clip: padding-box;
|
|
background-color: var(--n-action-color);
|
|
`), cE("content", "flex: 1; min-width: 0;"), cE("content, footer", `
|
|
box-sizing: border-box;
|
|
padding: 0 var(--n-padding-left) var(--n-padding-bottom) var(--n-padding-left);
|
|
font-size: var(--n-font-size);
|
|
`, [c("&:first-child", {
|
|
paddingTop: "var(--n-padding-bottom)"
|
|
})]), cE("action", `
|
|
background-color: var(--n-action-color);
|
|
padding: var(--n-padding-bottom) var(--n-padding-left);
|
|
border-bottom-left-radius: var(--n-border-radius);
|
|
border-bottom-right-radius: var(--n-border-radius);
|
|
`)]), cB("card-cover", `
|
|
overflow: hidden;
|
|
width: 100%;
|
|
border-radius: var(--n-border-radius) var(--n-border-radius) 0 0;
|
|
`, [c("img", `
|
|
display: block;
|
|
width: 100%;
|
|
`)]), cM("bordered", `
|
|
border: 1px solid var(--n-border-color);
|
|
`, [c("&:target", "border-color: var(--n-color-target);")]), cM("action-segmented", [c(">", [cE("action", [c("&:not(:first-child)", {
|
|
borderTop: "1px solid var(--n-border-color)"
|
|
})])])]), cM("content-segmented, content-soft-segmented", [c(">", [cE("content", {
|
|
transition: "border-color 0.3s var(--n-bezier)"
|
|
}, [c("&:not(:first-child)", {
|
|
borderTop: "1px solid var(--n-border-color)"
|
|
})])])]), cM("footer-segmented, footer-soft-segmented", [c(">", [cE("footer", {
|
|
transition: "border-color 0.3s var(--n-bezier)"
|
|
}, [c("&:not(:first-child)", {
|
|
borderTop: "1px solid var(--n-border-color)"
|
|
})])])]), cM("embedded", `
|
|
background-color: var(--n-color-embedded);
|
|
`)]), insideModal(cB("card", `
|
|
background: var(--n-color-modal);
|
|
`, [cM("embedded", `
|
|
background-color: var(--n-color-embedded-modal);
|
|
`)])), insidePopover(cB("card", `
|
|
background: var(--n-color-popover);
|
|
`, [cM("embedded", `
|
|
background-color: var(--n-color-embedded-popover);
|
|
`)]))]);
|
|
const cardBaseProps = {
|
|
title: [String, Function],
|
|
contentClass: String,
|
|
contentStyle: [Object, String],
|
|
headerClass: String,
|
|
headerStyle: [Object, String],
|
|
headerExtraClass: String,
|
|
headerExtraStyle: [Object, String],
|
|
footerClass: String,
|
|
footerStyle: [Object, String],
|
|
embedded: Boolean,
|
|
segmented: {
|
|
type: [Boolean, Object],
|
|
default: false
|
|
},
|
|
size: {
|
|
type: String,
|
|
default: "medium"
|
|
},
|
|
bordered: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
closable: Boolean,
|
|
hoverable: Boolean,
|
|
role: String,
|
|
onClose: [Function, Array],
|
|
tag: {
|
|
type: String,
|
|
default: "div"
|
|
},
|
|
cover: Function,
|
|
content: [String, Function],
|
|
footer: Function,
|
|
action: Function,
|
|
headerExtra: Function
|
|
};
|
|
const cardBasePropKeys = keysOf(cardBaseProps);
|
|
const cardProps = Object.assign(Object.assign({}, useTheme.props), cardBaseProps);
|
|
const __unplugin_components_0$1 = /* @__PURE__ */ defineComponent({
|
|
name: "Card",
|
|
props: cardProps,
|
|
slots: Object,
|
|
setup(props) {
|
|
const handleCloseClick = () => {
|
|
const {
|
|
onClose
|
|
} = props;
|
|
if (onClose) call(onClose);
|
|
};
|
|
const {
|
|
inlineThemeDisabled,
|
|
mergedClsPrefixRef,
|
|
mergedRtlRef
|
|
} = useConfig(props);
|
|
const themeRef = useTheme("Card", "-card", style$9, cardLight, props, mergedClsPrefixRef);
|
|
const rtlEnabledRef = useRtl("Card", mergedRtlRef, mergedClsPrefixRef);
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
size: size2
|
|
} = props;
|
|
const {
|
|
self: {
|
|
color,
|
|
colorModal,
|
|
colorTarget,
|
|
textColor,
|
|
titleTextColor,
|
|
titleFontWeight,
|
|
borderColor,
|
|
actionColor,
|
|
borderRadius,
|
|
lineHeight: lineHeight2,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
closeBorderRadius,
|
|
closeIconSize,
|
|
closeSize,
|
|
boxShadow,
|
|
colorPopover,
|
|
colorEmbedded,
|
|
colorEmbeddedModal,
|
|
colorEmbeddedPopover,
|
|
[createKey("padding", size2)]: padding,
|
|
[createKey("fontSize", size2)]: fontSize2,
|
|
[createKey("titleFontSize", size2)]: titleFontSize
|
|
},
|
|
common: {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2
|
|
}
|
|
} = themeRef.value;
|
|
const {
|
|
top: paddingTop,
|
|
left: paddingLeft,
|
|
bottom: paddingBottom
|
|
} = getMargin(padding);
|
|
return {
|
|
"--n-bezier": cubicBezierEaseInOut2,
|
|
"--n-border-radius": borderRadius,
|
|
"--n-color": color,
|
|
"--n-color-modal": colorModal,
|
|
"--n-color-popover": colorPopover,
|
|
"--n-color-embedded": colorEmbedded,
|
|
"--n-color-embedded-modal": colorEmbeddedModal,
|
|
"--n-color-embedded-popover": colorEmbeddedPopover,
|
|
"--n-color-target": colorTarget,
|
|
"--n-text-color": textColor,
|
|
"--n-line-height": lineHeight2,
|
|
"--n-action-color": actionColor,
|
|
"--n-title-text-color": titleTextColor,
|
|
"--n-title-font-weight": titleFontWeight,
|
|
"--n-close-icon-color": closeIconColor,
|
|
"--n-close-icon-color-hover": closeIconColorHover,
|
|
"--n-close-icon-color-pressed": closeIconColorPressed,
|
|
"--n-close-color-hover": closeColorHover,
|
|
"--n-close-color-pressed": closeColorPressed,
|
|
"--n-border-color": borderColor,
|
|
"--n-box-shadow": boxShadow,
|
|
// size
|
|
"--n-padding-top": paddingTop,
|
|
"--n-padding-bottom": paddingBottom,
|
|
"--n-padding-left": paddingLeft,
|
|
"--n-font-size": fontSize2,
|
|
"--n-title-font-size": titleFontSize,
|
|
"--n-close-size": closeSize,
|
|
"--n-close-icon-size": closeIconSize,
|
|
"--n-close-border-radius": closeBorderRadius
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("card", computed(() => {
|
|
return props.size[0];
|
|
}), cssVarsRef, props) : void 0;
|
|
return {
|
|
rtlEnabled: rtlEnabledRef,
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
mergedTheme: themeRef,
|
|
handleCloseClick,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
};
|
|
},
|
|
render() {
|
|
const {
|
|
segmented,
|
|
bordered,
|
|
hoverable,
|
|
mergedClsPrefix,
|
|
rtlEnabled,
|
|
onRender,
|
|
embedded,
|
|
tag: Component,
|
|
$slots
|
|
} = this;
|
|
onRender === null || onRender === void 0 ? void 0 : onRender();
|
|
return h(Component, {
|
|
class: [`${mergedClsPrefix}-card`, this.themeClass, embedded && `${mergedClsPrefix}-card--embedded`, {
|
|
[`${mergedClsPrefix}-card--rtl`]: rtlEnabled,
|
|
[`${mergedClsPrefix}-card--content${typeof segmented !== "boolean" && segmented.content === "soft" ? "-soft" : ""}-segmented`]: segmented === true || segmented !== false && segmented.content,
|
|
[`${mergedClsPrefix}-card--footer${typeof segmented !== "boolean" && segmented.footer === "soft" ? "-soft" : ""}-segmented`]: segmented === true || segmented !== false && segmented.footer,
|
|
[`${mergedClsPrefix}-card--action-segmented`]: segmented === true || segmented !== false && segmented.action,
|
|
[`${mergedClsPrefix}-card--bordered`]: bordered,
|
|
[`${mergedClsPrefix}-card--hoverable`]: hoverable
|
|
}],
|
|
style: this.cssVars,
|
|
role: this.role
|
|
}, resolveWrappedSlot($slots.cover, (children) => {
|
|
const mergedChildren = this.cover ? ensureValidVNode([this.cover()]) : children;
|
|
return mergedChildren && h("div", {
|
|
class: `${mergedClsPrefix}-card-cover`,
|
|
role: "none"
|
|
}, mergedChildren);
|
|
}), resolveWrappedSlot($slots.header, (children) => {
|
|
const {
|
|
title
|
|
} = this;
|
|
const mergedChildren = title ? ensureValidVNode(typeof title === "function" ? [title()] : [title]) : children;
|
|
return mergedChildren || this.closable ? h("div", {
|
|
class: [`${mergedClsPrefix}-card-header`, this.headerClass],
|
|
style: this.headerStyle,
|
|
role: "heading"
|
|
}, h("div", {
|
|
class: `${mergedClsPrefix}-card-header__main`,
|
|
role: "heading"
|
|
}, mergedChildren), resolveWrappedSlot($slots["header-extra"], (children2) => {
|
|
const mergedChildren2 = this.headerExtra ? ensureValidVNode([this.headerExtra()]) : children2;
|
|
return mergedChildren2 && h("div", {
|
|
class: [`${mergedClsPrefix}-card-header__extra`, this.headerExtraClass],
|
|
style: this.headerExtraStyle
|
|
}, mergedChildren2);
|
|
}), this.closable && h(NBaseClose, {
|
|
clsPrefix: mergedClsPrefix,
|
|
class: `${mergedClsPrefix}-card-header__close`,
|
|
onClick: this.handleCloseClick,
|
|
absolute: true
|
|
})) : null;
|
|
}), resolveWrappedSlot($slots.default, (children) => {
|
|
const {
|
|
content
|
|
} = this;
|
|
const mergedChildren = content ? ensureValidVNode(typeof content === "function" ? [content()] : [content]) : children;
|
|
return mergedChildren && h("div", {
|
|
class: [`${mergedClsPrefix}-card__content`, this.contentClass],
|
|
style: this.contentStyle,
|
|
role: "none"
|
|
}, mergedChildren);
|
|
}), resolveWrappedSlot($slots.footer, (children) => {
|
|
const mergedChildren = this.footer ? ensureValidVNode([this.footer()]) : children;
|
|
return mergedChildren && h("div", {
|
|
class: [`${mergedClsPrefix}-card__footer`, this.footerClass],
|
|
style: this.footerStyle,
|
|
role: "none"
|
|
}, mergedChildren);
|
|
}), resolveWrappedSlot($slots.action, (children) => {
|
|
const mergedChildren = this.action ? ensureValidVNode([this.action()]) : children;
|
|
return mergedChildren && h("div", {
|
|
class: `${mergedClsPrefix}-card__action`,
|
|
role: "none"
|
|
}, mergedChildren);
|
|
}));
|
|
}
|
|
});
|
|
const configProviderProps = {
|
|
abstract: Boolean,
|
|
bordered: {
|
|
type: Boolean,
|
|
default: void 0
|
|
},
|
|
clsPrefix: String,
|
|
locale: Object,
|
|
dateLocale: Object,
|
|
namespace: String,
|
|
rtl: Array,
|
|
tag: {
|
|
type: String,
|
|
default: "div"
|
|
},
|
|
hljs: Object,
|
|
katex: Object,
|
|
theme: Object,
|
|
themeOverrides: Object,
|
|
componentOptions: Object,
|
|
icons: Object,
|
|
breakpoints: Object,
|
|
preflightStyleDisabled: Boolean,
|
|
styleMountTarget: Object,
|
|
inlineThemeDisabled: {
|
|
type: Boolean,
|
|
default: void 0
|
|
},
|
|
// deprecated
|
|
as: {
|
|
type: String,
|
|
validator: () => {
|
|
warn("config-provider", "`as` is deprecated, please use `tag` instead.");
|
|
return true;
|
|
},
|
|
default: void 0
|
|
}
|
|
};
|
|
const __unplugin_components_11 = /* @__PURE__ */ defineComponent({
|
|
name: "ConfigProvider",
|
|
alias: ["App"],
|
|
props: configProviderProps,
|
|
setup(props) {
|
|
const NConfigProvider = inject(configProviderInjectionKey, null);
|
|
const mergedThemeRef = computed(() => {
|
|
const {
|
|
theme
|
|
} = props;
|
|
if (theme === null) return void 0;
|
|
const inheritedTheme = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeRef.value;
|
|
return theme === void 0 ? inheritedTheme : inheritedTheme === void 0 ? theme : Object.assign({}, inheritedTheme, theme);
|
|
});
|
|
const mergedThemeOverridesRef = computed(() => {
|
|
const {
|
|
themeOverrides
|
|
} = props;
|
|
if (themeOverrides === null) return void 0;
|
|
if (themeOverrides === void 0) {
|
|
return NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeOverridesRef.value;
|
|
} else {
|
|
const inheritedThemeOverrides = NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedThemeOverridesRef.value;
|
|
if (inheritedThemeOverrides === void 0) {
|
|
return themeOverrides;
|
|
} else {
|
|
return merge$1({}, inheritedThemeOverrides, themeOverrides);
|
|
}
|
|
}
|
|
});
|
|
const mergedNamespaceRef = useMemo(() => {
|
|
const {
|
|
namespace: namespace2
|
|
} = props;
|
|
return namespace2 === void 0 ? NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedNamespaceRef.value : namespace2;
|
|
});
|
|
const mergedBorderedRef = useMemo(() => {
|
|
const {
|
|
bordered
|
|
} = props;
|
|
return bordered === void 0 ? NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBorderedRef.value : bordered;
|
|
});
|
|
const mergedIconsRef = computed(() => {
|
|
const {
|
|
icons
|
|
} = props;
|
|
return icons === void 0 ? NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedIconsRef.value : icons;
|
|
});
|
|
const mergedComponentPropsRef = computed(() => {
|
|
const {
|
|
componentOptions
|
|
} = props;
|
|
if (componentOptions !== void 0) return componentOptions;
|
|
return NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedComponentPropsRef.value;
|
|
});
|
|
const mergedClsPrefixRef = computed(() => {
|
|
const {
|
|
clsPrefix
|
|
} = props;
|
|
if (clsPrefix !== void 0) return clsPrefix;
|
|
if (NConfigProvider) return NConfigProvider.mergedClsPrefixRef.value;
|
|
return defaultClsPrefix;
|
|
});
|
|
const mergedRtlRef = computed(() => {
|
|
var _a;
|
|
const {
|
|
rtl
|
|
} = props;
|
|
if (rtl === void 0) {
|
|
return NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedRtlRef.value;
|
|
}
|
|
const rtlEnabledState = {};
|
|
for (const rtlInfo of rtl) {
|
|
rtlEnabledState[rtlInfo.name] = markRaw(rtlInfo);
|
|
(_a = rtlInfo.peers) === null || _a === void 0 ? void 0 : _a.forEach((peerRtlInfo) => {
|
|
if (!(peerRtlInfo.name in rtlEnabledState)) {
|
|
rtlEnabledState[peerRtlInfo.name] = markRaw(peerRtlInfo);
|
|
}
|
|
});
|
|
}
|
|
return rtlEnabledState;
|
|
});
|
|
const mergedBreakpointsRef = computed(() => {
|
|
return props.breakpoints || (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedBreakpointsRef.value);
|
|
});
|
|
const inlineThemeDisabled = props.inlineThemeDisabled || (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.inlineThemeDisabled);
|
|
const preflightStyleDisabled = props.preflightStyleDisabled || (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.preflightStyleDisabled);
|
|
const styleMountTarget = props.styleMountTarget || (NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.styleMountTarget);
|
|
const mergedThemeHashRef = computed(() => {
|
|
const {
|
|
value: theme
|
|
} = mergedThemeRef;
|
|
const {
|
|
value: mergedThemeOverrides
|
|
} = mergedThemeOverridesRef;
|
|
const hasThemeOverrides = mergedThemeOverrides && Object.keys(mergedThemeOverrides).length !== 0;
|
|
const themeName = theme === null || theme === void 0 ? void 0 : theme.name;
|
|
if (themeName) {
|
|
if (hasThemeOverrides) {
|
|
return `${themeName}-${murmur2(JSON.stringify(mergedThemeOverridesRef.value))}`;
|
|
}
|
|
return themeName;
|
|
} else {
|
|
if (hasThemeOverrides) {
|
|
return murmur2(JSON.stringify(mergedThemeOverridesRef.value));
|
|
}
|
|
return "";
|
|
}
|
|
});
|
|
provide(configProviderInjectionKey, {
|
|
mergedThemeHashRef,
|
|
mergedBreakpointsRef,
|
|
mergedRtlRef,
|
|
mergedIconsRef,
|
|
mergedComponentPropsRef,
|
|
mergedBorderedRef,
|
|
mergedNamespaceRef,
|
|
mergedClsPrefixRef,
|
|
mergedLocaleRef: computed(() => {
|
|
const {
|
|
locale
|
|
} = props;
|
|
if (locale === null) return void 0;
|
|
return locale === void 0 ? NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedLocaleRef.value : locale;
|
|
}),
|
|
mergedDateLocaleRef: computed(() => {
|
|
const {
|
|
dateLocale
|
|
} = props;
|
|
if (dateLocale === null) return void 0;
|
|
return dateLocale === void 0 ? NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedDateLocaleRef.value : dateLocale;
|
|
}),
|
|
mergedHljsRef: computed(() => {
|
|
const {
|
|
hljs
|
|
} = props;
|
|
return hljs === void 0 ? NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedHljsRef.value : hljs;
|
|
}),
|
|
mergedKatexRef: computed(() => {
|
|
const {
|
|
katex
|
|
} = props;
|
|
return katex === void 0 ? NConfigProvider === null || NConfigProvider === void 0 ? void 0 : NConfigProvider.mergedKatexRef.value : katex;
|
|
}),
|
|
mergedThemeRef,
|
|
mergedThemeOverridesRef,
|
|
inlineThemeDisabled: inlineThemeDisabled || false,
|
|
preflightStyleDisabled: preflightStyleDisabled || false,
|
|
styleMountTarget
|
|
});
|
|
return {
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
mergedBordered: mergedBorderedRef,
|
|
mergedNamespace: mergedNamespaceRef,
|
|
mergedTheme: mergedThemeRef,
|
|
mergedThemeOverrides: mergedThemeOverridesRef
|
|
};
|
|
},
|
|
render() {
|
|
var _a, _b, _c, _d;
|
|
return !this.abstract ? h(this.as || this.tag, {
|
|
class: `${this.mergedClsPrefix || defaultClsPrefix}-config-provider`
|
|
}, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a)) : (_d = (_c = this.$slots).default) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
}
|
|
});
|
|
const dialogProviderInjectionKey = createInjectionKey("n-dialog-provider");
|
|
const commonVars$1 = {
|
|
titleFontSize: "18px",
|
|
padding: "16px 28px 20px 28px",
|
|
iconSize: "28px",
|
|
actionSpace: "12px",
|
|
contentMargin: "8px 0 16px 0",
|
|
iconMargin: "0 4px 0 0",
|
|
iconMarginIconTop: "4px 0 8px 0",
|
|
closeSize: "22px",
|
|
closeIconSize: "18px",
|
|
closeMargin: "20px 26px 0 0",
|
|
closeMarginIconTop: "10px 16px 0 0"
|
|
};
|
|
function self$6(vars) {
|
|
const {
|
|
textColor1,
|
|
textColor2,
|
|
modalColor,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
infoColor,
|
|
successColor,
|
|
warningColor,
|
|
errorColor,
|
|
primaryColor,
|
|
dividerColor,
|
|
borderRadius,
|
|
fontWeightStrong,
|
|
lineHeight: lineHeight2,
|
|
fontSize: fontSize2
|
|
} = vars;
|
|
return Object.assign(Object.assign({}, commonVars$1), {
|
|
fontSize: fontSize2,
|
|
lineHeight: lineHeight2,
|
|
border: `1px solid ${dividerColor}`,
|
|
titleTextColor: textColor1,
|
|
textColor: textColor2,
|
|
color: modalColor,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
closeBorderRadius: borderRadius,
|
|
iconColor: primaryColor,
|
|
iconColorInfo: infoColor,
|
|
iconColorSuccess: successColor,
|
|
iconColorWarning: warningColor,
|
|
iconColorError: errorColor,
|
|
borderRadius,
|
|
titleFontWeight: fontWeightStrong
|
|
});
|
|
}
|
|
const dialogLight = createTheme({
|
|
name: "Dialog",
|
|
common: derived,
|
|
peers: {
|
|
Button: buttonLight
|
|
},
|
|
self: self$6
|
|
});
|
|
const dialogProps = {
|
|
icon: Function,
|
|
type: {
|
|
type: String,
|
|
default: "default"
|
|
},
|
|
title: [String, Function],
|
|
closable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
negativeText: String,
|
|
positiveText: String,
|
|
positiveButtonProps: Object,
|
|
negativeButtonProps: Object,
|
|
content: [String, Function],
|
|
action: Function,
|
|
showIcon: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
loading: Boolean,
|
|
bordered: Boolean,
|
|
iconPlacement: String,
|
|
titleClass: [String, Array],
|
|
titleStyle: [String, Object],
|
|
contentClass: [String, Array],
|
|
contentStyle: [String, Object],
|
|
actionClass: [String, Array],
|
|
actionStyle: [String, Object],
|
|
onPositiveClick: Function,
|
|
onNegativeClick: Function,
|
|
onClose: Function
|
|
};
|
|
const dialogPropKeys = keysOf(dialogProps);
|
|
const style$8 = c([cB("dialog", `
|
|
--n-icon-margin: var(--n-icon-margin-top) var(--n-icon-margin-right) var(--n-icon-margin-bottom) var(--n-icon-margin-left);
|
|
word-break: break-word;
|
|
line-height: var(--n-line-height);
|
|
position: relative;
|
|
background: var(--n-color);
|
|
color: var(--n-text-color);
|
|
box-sizing: border-box;
|
|
margin: auto;
|
|
border-radius: var(--n-border-radius);
|
|
padding: var(--n-padding);
|
|
transition:
|
|
border-color .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier);
|
|
`, [cE("icon", {
|
|
color: "var(--n-icon-color)"
|
|
}), cM("bordered", {
|
|
border: "var(--n-border)"
|
|
}), cM("icon-top", [cE("close", {
|
|
margin: "var(--n-close-margin)"
|
|
}), cE("icon", {
|
|
margin: "var(--n-icon-margin)"
|
|
}), cE("content", {
|
|
textAlign: "center"
|
|
}), cE("title", {
|
|
justifyContent: "center"
|
|
}), cE("action", {
|
|
justifyContent: "center"
|
|
})]), cM("icon-left", [cE("icon", {
|
|
margin: "var(--n-icon-margin)"
|
|
}), cM("closable", [cE("title", `
|
|
padding-right: calc(var(--n-close-size) + 6px);
|
|
`)])]), cE("close", `
|
|
position: absolute;
|
|
right: 0;
|
|
top: 0;
|
|
margin: var(--n-close-margin);
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier);
|
|
z-index: 1;
|
|
`), cE("content", `
|
|
font-size: var(--n-font-size);
|
|
margin: var(--n-content-margin);
|
|
position: relative;
|
|
word-break: break-word;
|
|
`, [cM("last", "margin-bottom: 0;")]), cE("action", `
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
`, [c("> *:not(:last-child)", `
|
|
margin-right: var(--n-action-space);
|
|
`)]), cE("icon", `
|
|
font-size: var(--n-icon-size);
|
|
transition: color .3s var(--n-bezier);
|
|
`), cE("title", `
|
|
transition: color .3s var(--n-bezier);
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: var(--n-title-font-size);
|
|
font-weight: var(--n-title-font-weight);
|
|
color: var(--n-title-text-color);
|
|
`), cB("dialog-icon-container", `
|
|
display: flex;
|
|
justify-content: center;
|
|
`)]), insideModal(cB("dialog", `
|
|
width: 446px;
|
|
max-width: calc(100vw - 32px);
|
|
`)), cB("dialog", [asModal(`
|
|
width: 446px;
|
|
max-width: calc(100vw - 32px);
|
|
`)])]);
|
|
const iconRenderMap$2 = {
|
|
default: () => h(InfoIcon, null),
|
|
info: () => h(InfoIcon, null),
|
|
success: () => h(SuccessIcon, null),
|
|
warning: () => h(WarningIcon, null),
|
|
error: () => h(ErrorIcon, null)
|
|
};
|
|
const NDialog = /* @__PURE__ */ defineComponent({
|
|
name: "Dialog",
|
|
alias: [
|
|
"NimbusConfirmCard",
|
|
// deprecated
|
|
"Confirm"
|
|
// deprecated
|
|
],
|
|
props: Object.assign(Object.assign({}, useTheme.props), dialogProps),
|
|
slots: Object,
|
|
setup(props) {
|
|
const {
|
|
mergedComponentPropsRef,
|
|
mergedClsPrefixRef,
|
|
inlineThemeDisabled,
|
|
mergedRtlRef
|
|
} = useConfig(props);
|
|
const rtlEnabledRef = useRtl("Dialog", mergedRtlRef, mergedClsPrefixRef);
|
|
const mergedIconPlacementRef = computed(() => {
|
|
var _a, _b;
|
|
const {
|
|
iconPlacement
|
|
} = props;
|
|
return iconPlacement || ((_b = (_a = mergedComponentPropsRef === null || mergedComponentPropsRef === void 0 ? void 0 : mergedComponentPropsRef.value) === null || _a === void 0 ? void 0 : _a.Dialog) === null || _b === void 0 ? void 0 : _b.iconPlacement) || "left";
|
|
});
|
|
function handlePositiveClick(e) {
|
|
const {
|
|
onPositiveClick
|
|
} = props;
|
|
if (onPositiveClick) onPositiveClick(e);
|
|
}
|
|
function handleNegativeClick(e) {
|
|
const {
|
|
onNegativeClick
|
|
} = props;
|
|
if (onNegativeClick) onNegativeClick(e);
|
|
}
|
|
function handleCloseClick() {
|
|
const {
|
|
onClose
|
|
} = props;
|
|
if (onClose) onClose();
|
|
}
|
|
const themeRef = useTheme("Dialog", "-dialog", style$8, dialogLight, props, mergedClsPrefixRef);
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
type
|
|
} = props;
|
|
const iconPlacement = mergedIconPlacementRef.value;
|
|
const {
|
|
common: {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2
|
|
},
|
|
self: {
|
|
fontSize: fontSize2,
|
|
lineHeight: lineHeight2,
|
|
border,
|
|
titleTextColor,
|
|
textColor,
|
|
color,
|
|
closeBorderRadius,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
closeIconSize,
|
|
borderRadius,
|
|
titleFontWeight,
|
|
titleFontSize,
|
|
padding,
|
|
iconSize,
|
|
actionSpace,
|
|
contentMargin,
|
|
closeSize,
|
|
[iconPlacement === "top" ? "iconMarginIconTop" : "iconMargin"]: iconMargin,
|
|
[iconPlacement === "top" ? "closeMarginIconTop" : "closeMargin"]: closeMargin,
|
|
[createKey("iconColor", type)]: iconColor
|
|
}
|
|
} = themeRef.value;
|
|
const iconMarginDiscrete = getMargin(iconMargin);
|
|
return {
|
|
"--n-font-size": fontSize2,
|
|
"--n-icon-color": iconColor,
|
|
"--n-bezier": cubicBezierEaseInOut2,
|
|
"--n-close-margin": closeMargin,
|
|
"--n-icon-margin-top": iconMarginDiscrete.top,
|
|
"--n-icon-margin-right": iconMarginDiscrete.right,
|
|
"--n-icon-margin-bottom": iconMarginDiscrete.bottom,
|
|
"--n-icon-margin-left": iconMarginDiscrete.left,
|
|
"--n-icon-size": iconSize,
|
|
"--n-close-size": closeSize,
|
|
"--n-close-icon-size": closeIconSize,
|
|
"--n-close-border-radius": closeBorderRadius,
|
|
"--n-close-color-hover": closeColorHover,
|
|
"--n-close-color-pressed": closeColorPressed,
|
|
"--n-close-icon-color": closeIconColor,
|
|
"--n-close-icon-color-hover": closeIconColorHover,
|
|
"--n-close-icon-color-pressed": closeIconColorPressed,
|
|
"--n-color": color,
|
|
"--n-text-color": textColor,
|
|
"--n-border-radius": borderRadius,
|
|
"--n-padding": padding,
|
|
"--n-line-height": lineHeight2,
|
|
"--n-border": border,
|
|
"--n-content-margin": contentMargin,
|
|
"--n-title-font-size": titleFontSize,
|
|
"--n-title-font-weight": titleFontWeight,
|
|
"--n-title-text-color": titleTextColor,
|
|
"--n-action-space": actionSpace
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("dialog", computed(() => `${props.type[0]}${mergedIconPlacementRef.value[0]}`), cssVarsRef, props) : void 0;
|
|
return {
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
rtlEnabled: rtlEnabledRef,
|
|
mergedIconPlacement: mergedIconPlacementRef,
|
|
mergedTheme: themeRef,
|
|
handlePositiveClick,
|
|
handleNegativeClick,
|
|
handleCloseClick,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
};
|
|
},
|
|
render() {
|
|
var _a;
|
|
const {
|
|
bordered,
|
|
mergedIconPlacement,
|
|
cssVars,
|
|
closable,
|
|
showIcon,
|
|
title,
|
|
content,
|
|
action,
|
|
negativeText,
|
|
positiveText,
|
|
positiveButtonProps,
|
|
negativeButtonProps,
|
|
handlePositiveClick,
|
|
handleNegativeClick,
|
|
mergedTheme,
|
|
loading,
|
|
type,
|
|
mergedClsPrefix
|
|
} = this;
|
|
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
const icon = showIcon ? h(NBaseIcon, {
|
|
clsPrefix: mergedClsPrefix,
|
|
class: `${mergedClsPrefix}-dialog__icon`
|
|
}, {
|
|
default: () => resolveWrappedSlot(this.$slots.icon, (children) => children || (this.icon ? render(this.icon) : iconRenderMap$2[this.type]()))
|
|
}) : null;
|
|
const actionNode = resolveWrappedSlot(this.$slots.action, (children) => children || positiveText || negativeText || action ? h("div", {
|
|
class: [`${mergedClsPrefix}-dialog__action`, this.actionClass],
|
|
style: this.actionStyle
|
|
}, children || (action ? [render(action)] : [this.negativeText && h(Button$1, Object.assign({
|
|
theme: mergedTheme.peers.Button,
|
|
themeOverrides: mergedTheme.peerOverrides.Button,
|
|
ghost: true,
|
|
size: "small",
|
|
onClick: handleNegativeClick
|
|
}, negativeButtonProps), {
|
|
default: () => render(this.negativeText)
|
|
}), this.positiveText && h(Button$1, Object.assign({
|
|
theme: mergedTheme.peers.Button,
|
|
themeOverrides: mergedTheme.peerOverrides.Button,
|
|
size: "small",
|
|
type: type === "default" ? "primary" : type,
|
|
disabled: loading,
|
|
loading,
|
|
onClick: handlePositiveClick
|
|
}, positiveButtonProps), {
|
|
default: () => render(this.positiveText)
|
|
})])) : null);
|
|
return h("div", {
|
|
class: [`${mergedClsPrefix}-dialog`, this.themeClass, this.closable && `${mergedClsPrefix}-dialog--closable`, `${mergedClsPrefix}-dialog--icon-${mergedIconPlacement}`, bordered && `${mergedClsPrefix}-dialog--bordered`, this.rtlEnabled && `${mergedClsPrefix}-dialog--rtl`],
|
|
style: cssVars,
|
|
role: "dialog"
|
|
}, closable ? resolveWrappedSlot(this.$slots.close, (node) => {
|
|
const classNames = [`${mergedClsPrefix}-dialog__close`, this.rtlEnabled && `${mergedClsPrefix}-dialog--rtl`];
|
|
return node ? h("div", {
|
|
class: classNames
|
|
}, node) : h(NBaseClose, {
|
|
clsPrefix: mergedClsPrefix,
|
|
class: classNames,
|
|
onClick: this.handleCloseClick
|
|
});
|
|
}) : null, showIcon && mergedIconPlacement === "top" ? h("div", {
|
|
class: `${mergedClsPrefix}-dialog-icon-container`
|
|
}, icon) : null, h("div", {
|
|
class: [`${mergedClsPrefix}-dialog__title`, this.titleClass],
|
|
style: this.titleStyle
|
|
}, showIcon && mergedIconPlacement === "left" ? icon : null, resolveSlot(this.$slots.header, () => [render(title)])), h("div", {
|
|
class: [`${mergedClsPrefix}-dialog__content`, actionNode ? "" : `${mergedClsPrefix}-dialog__content--last`, this.contentClass],
|
|
style: this.contentStyle
|
|
}, resolveSlot(this.$slots.default, () => [render(content)])), actionNode);
|
|
}
|
|
});
|
|
function self$5(vars) {
|
|
const {
|
|
modalColor,
|
|
textColor2,
|
|
boxShadow3
|
|
} = vars;
|
|
return {
|
|
color: modalColor,
|
|
textColor: textColor2,
|
|
boxShadow: boxShadow3
|
|
};
|
|
}
|
|
const modalLight = createTheme({
|
|
name: "Modal",
|
|
common: derived,
|
|
peers: {
|
|
Scrollbar: scrollbarLight,
|
|
Dialog: dialogLight,
|
|
Card: cardLight
|
|
},
|
|
self: self$5
|
|
});
|
|
const modalProviderInjectionKey = createInjectionKey("n-modal-provider");
|
|
const modalApiInjectionKey = createInjectionKey("n-modal-api");
|
|
const modalReactiveListInjectionKey = createInjectionKey("n-modal-reactive-list");
|
|
const DRAGGABLE_CLASS = "n-draggable";
|
|
function useDragModal(draggablePropsRef, options) {
|
|
let cleanup;
|
|
const draggableRef = computed(() => {
|
|
return draggablePropsRef.value !== false;
|
|
});
|
|
const draggableClassRef = computed(() => {
|
|
return draggableRef.value ? DRAGGABLE_CLASS : "";
|
|
});
|
|
const boundsToWindowRef = computed(() => {
|
|
const draggableProps = draggablePropsRef.value;
|
|
if (draggableProps === true || draggableProps === false) {
|
|
return true;
|
|
} else if (draggableProps) {
|
|
return draggableProps.bounds !== "none";
|
|
} else {
|
|
return true;
|
|
}
|
|
});
|
|
function startDrag(modal) {
|
|
const header = modal.querySelector(`.${DRAGGABLE_CLASS}`);
|
|
if (!header || !draggableClassRef.value) {
|
|
return;
|
|
}
|
|
let maxMoveX = 0;
|
|
let minMoveX = 0;
|
|
let maxMoveY = 0;
|
|
let minMoveY = 0;
|
|
let prevMoveY = 0;
|
|
let prevMoveX = 0;
|
|
let mousedownEvent;
|
|
function handleMouseDown(event) {
|
|
event.preventDefault();
|
|
mousedownEvent = event;
|
|
const {
|
|
x,
|
|
y,
|
|
right,
|
|
bottom
|
|
} = modal.getBoundingClientRect();
|
|
minMoveX = x;
|
|
minMoveY = y;
|
|
maxMoveX = window.innerWidth - right;
|
|
maxMoveY = window.innerHeight - bottom;
|
|
const {
|
|
left,
|
|
top
|
|
} = modal.style;
|
|
prevMoveY = +top.slice(0, -2);
|
|
prevMoveX = +left.slice(0, -2);
|
|
}
|
|
function handleMouseMove(event) {
|
|
if (!mousedownEvent) return;
|
|
const {
|
|
clientX: downX,
|
|
clientY: downY
|
|
} = mousedownEvent;
|
|
let moveX = event.clientX - downX;
|
|
let moveY = event.clientY - downY;
|
|
if (boundsToWindowRef.value) {
|
|
if (moveX > maxMoveX) {
|
|
moveX = maxMoveX;
|
|
} else if (-moveX > minMoveX) {
|
|
moveX = -minMoveX;
|
|
}
|
|
if (moveY > maxMoveY) {
|
|
moveY = maxMoveY;
|
|
} else if (-moveY > minMoveY) {
|
|
moveY = -minMoveY;
|
|
}
|
|
}
|
|
const x = moveX + prevMoveX;
|
|
const y = moveY + prevMoveY;
|
|
modal.style.top = `${y}px`;
|
|
modal.style.left = `${x}px`;
|
|
}
|
|
function handleMouseUp() {
|
|
mousedownEvent = void 0;
|
|
options.onEnd(modal);
|
|
}
|
|
on("mousedown", header, handleMouseDown);
|
|
on("mousemove", window, handleMouseMove);
|
|
on("mouseup", window, handleMouseUp);
|
|
cleanup = () => {
|
|
off("mousedown", header, handleMouseDown);
|
|
on("mousemove", window, handleMouseMove);
|
|
on("mouseup", window, handleMouseUp);
|
|
};
|
|
}
|
|
function stopDrag() {
|
|
if (cleanup) {
|
|
cleanup();
|
|
cleanup = void 0;
|
|
}
|
|
}
|
|
onUnmounted(stopDrag);
|
|
return {
|
|
stopDrag,
|
|
startDrag,
|
|
draggableRef,
|
|
draggableClassRef
|
|
};
|
|
}
|
|
const presetProps = Object.assign(Object.assign({}, cardBaseProps), dialogProps);
|
|
const presetPropsKeys = keysOf(presetProps);
|
|
const NModalBodyWrapper = /* @__PURE__ */ defineComponent({
|
|
name: "ModalBody",
|
|
inheritAttrs: false,
|
|
slots: Object,
|
|
props: Object.assign(Object.assign({
|
|
show: {
|
|
type: Boolean,
|
|
required: true
|
|
},
|
|
preset: String,
|
|
displayDirective: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
trapFocus: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
autoFocus: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
blockScroll: Boolean,
|
|
draggable: {
|
|
type: [Boolean, Object],
|
|
default: false
|
|
}
|
|
}, presetProps), {
|
|
renderMask: Function,
|
|
// events
|
|
onClickoutside: Function,
|
|
onBeforeLeave: {
|
|
type: Function,
|
|
required: true
|
|
},
|
|
onAfterLeave: {
|
|
type: Function,
|
|
required: true
|
|
},
|
|
onPositiveClick: {
|
|
type: Function,
|
|
required: true
|
|
},
|
|
onNegativeClick: {
|
|
type: Function,
|
|
required: true
|
|
},
|
|
onClose: {
|
|
type: Function,
|
|
required: true
|
|
},
|
|
onAfterEnter: Function,
|
|
onEsc: Function
|
|
}),
|
|
setup(props) {
|
|
const bodyRef = ref(null);
|
|
const scrollbarRef = ref(null);
|
|
const displayedRef = ref(props.show);
|
|
const transformOriginXRef = ref(null);
|
|
const transformOriginYRef = ref(null);
|
|
const NModal = inject(modalInjectionKey);
|
|
let mousePosition = null;
|
|
watch(toRef(props, "show"), (value) => {
|
|
if (value) {
|
|
mousePosition = NModal.getMousePosition();
|
|
}
|
|
}, {
|
|
immediate: true
|
|
});
|
|
const {
|
|
stopDrag,
|
|
startDrag,
|
|
draggableRef,
|
|
draggableClassRef
|
|
} = useDragModal(toRef(props, "draggable"), {
|
|
onEnd: (el) => {
|
|
syncTransformOrigin(el);
|
|
}
|
|
});
|
|
const dialogTitleClassRef = computed(() => {
|
|
return normalizeClass([props.titleClass, draggableClassRef.value]);
|
|
});
|
|
const cardHeaderClassRef = computed(() => {
|
|
return normalizeClass([props.headerClass, draggableClassRef.value]);
|
|
});
|
|
watch(toRef(props, "show"), (value) => {
|
|
if (value) displayedRef.value = true;
|
|
});
|
|
useLockHtmlScroll(computed(() => props.blockScroll && displayedRef.value));
|
|
function styleTransformOrigin() {
|
|
if (NModal.transformOriginRef.value === "center") {
|
|
return "";
|
|
}
|
|
const {
|
|
value: transformOriginX
|
|
} = transformOriginXRef;
|
|
const {
|
|
value: transformOriginY
|
|
} = transformOriginYRef;
|
|
if (transformOriginX === null || transformOriginY === null) {
|
|
return "";
|
|
} else if (scrollbarRef.value) {
|
|
const scrollTop = scrollbarRef.value.containerScrollTop;
|
|
return `${transformOriginX}px ${transformOriginY + scrollTop}px`;
|
|
}
|
|
return "";
|
|
}
|
|
function syncTransformOrigin(el) {
|
|
if (NModal.transformOriginRef.value === "center") {
|
|
return;
|
|
}
|
|
if (!mousePosition) {
|
|
return;
|
|
}
|
|
if (!scrollbarRef.value) return;
|
|
const scrollTop = scrollbarRef.value.containerScrollTop;
|
|
const {
|
|
offsetLeft,
|
|
offsetTop
|
|
} = el;
|
|
const top = mousePosition.y;
|
|
const left = mousePosition.x;
|
|
transformOriginXRef.value = -(offsetLeft - left);
|
|
transformOriginYRef.value = -(offsetTop - top - scrollTop);
|
|
el.style.transformOrigin = styleTransformOrigin();
|
|
}
|
|
function handleEnter(el) {
|
|
void nextTick(() => {
|
|
syncTransformOrigin(el);
|
|
});
|
|
}
|
|
function handleBeforeLeave(el) {
|
|
el.style.transformOrigin = styleTransformOrigin();
|
|
props.onBeforeLeave();
|
|
}
|
|
function handleAfterEnter(el) {
|
|
const element = el;
|
|
draggableRef.value && startDrag(element);
|
|
props.onAfterEnter && props.onAfterEnter(element);
|
|
}
|
|
function handleAfterLeave() {
|
|
displayedRef.value = false;
|
|
transformOriginXRef.value = null;
|
|
transformOriginYRef.value = null;
|
|
stopDrag();
|
|
props.onAfterLeave();
|
|
}
|
|
function handleCloseClick() {
|
|
const {
|
|
onClose
|
|
} = props;
|
|
if (onClose) {
|
|
onClose();
|
|
}
|
|
}
|
|
function handleNegativeClick() {
|
|
props.onNegativeClick();
|
|
}
|
|
function handlePositiveClick() {
|
|
props.onPositiveClick();
|
|
}
|
|
const childNodeRef = ref(null);
|
|
watch(childNodeRef, (node) => {
|
|
if (node) {
|
|
void nextTick(() => {
|
|
const el = node.el;
|
|
if (el && bodyRef.value !== el) {
|
|
bodyRef.value = el;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
provide(modalBodyInjectionKey, bodyRef);
|
|
provide(drawerBodyInjectionKey, null);
|
|
provide(popoverBodyInjectionKey, null);
|
|
return {
|
|
mergedTheme: NModal.mergedThemeRef,
|
|
appear: NModal.appearRef,
|
|
isMounted: NModal.isMountedRef,
|
|
mergedClsPrefix: NModal.mergedClsPrefixRef,
|
|
bodyRef,
|
|
scrollbarRef,
|
|
draggableClass: draggableClassRef,
|
|
displayed: displayedRef,
|
|
childNodeRef,
|
|
cardHeaderClass: cardHeaderClassRef,
|
|
dialogTitleClass: dialogTitleClassRef,
|
|
handlePositiveClick,
|
|
handleNegativeClick,
|
|
handleCloseClick,
|
|
handleAfterEnter,
|
|
handleAfterLeave,
|
|
handleBeforeLeave,
|
|
handleEnter
|
|
};
|
|
},
|
|
render() {
|
|
const {
|
|
$slots,
|
|
$attrs,
|
|
handleEnter,
|
|
handleAfterEnter,
|
|
handleAfterLeave,
|
|
handleBeforeLeave,
|
|
preset,
|
|
mergedClsPrefix
|
|
} = this;
|
|
let childNode = null;
|
|
if (!preset) {
|
|
childNode = getFirstSlotVNodeWithTypedProps("default", $slots.default, {
|
|
draggableClass: this.draggableClass
|
|
});
|
|
if (!childNode) {
|
|
warn("modal", "default slot is empty");
|
|
return;
|
|
}
|
|
childNode = cloneVNode(childNode);
|
|
childNode.props = mergeProps({
|
|
class: `${mergedClsPrefix}-modal`
|
|
}, $attrs, childNode.props || {});
|
|
}
|
|
return this.displayDirective === "show" || this.displayed || this.show ? withDirectives(h("div", {
|
|
role: "none",
|
|
class: `${mergedClsPrefix}-modal-body-wrapper`
|
|
}, h(Scrollbar, {
|
|
ref: "scrollbarRef",
|
|
theme: this.mergedTheme.peers.Scrollbar,
|
|
themeOverrides: this.mergedTheme.peerOverrides.Scrollbar,
|
|
contentClass: `${mergedClsPrefix}-modal-scroll-content`
|
|
}, {
|
|
default: () => {
|
|
var _a;
|
|
return [(_a = this.renderMask) === null || _a === void 0 ? void 0 : _a.call(this), h(FocusTrap, {
|
|
disabled: !this.trapFocus,
|
|
active: this.show,
|
|
onEsc: this.onEsc,
|
|
autoFocus: this.autoFocus
|
|
}, {
|
|
default: () => {
|
|
var _a2;
|
|
return h(Transition, {
|
|
name: "fade-in-scale-up-transition",
|
|
appear: (_a2 = this.appear) !== null && _a2 !== void 0 ? _a2 : this.isMounted,
|
|
onEnter: handleEnter,
|
|
onAfterEnter: handleAfterEnter,
|
|
onAfterLeave: handleAfterLeave,
|
|
onBeforeLeave: handleBeforeLeave
|
|
}, {
|
|
default: () => {
|
|
const dirs = [[vShow, this.show]];
|
|
const {
|
|
onClickoutside
|
|
} = this;
|
|
if (onClickoutside) {
|
|
dirs.push([clickoutside, this.onClickoutside, void 0, {
|
|
capture: true
|
|
}]);
|
|
}
|
|
return withDirectives(this.preset === "confirm" || this.preset === "dialog" ? h(NDialog, Object.assign({}, this.$attrs, {
|
|
class: [`${mergedClsPrefix}-modal`, this.$attrs.class],
|
|
ref: "bodyRef",
|
|
theme: this.mergedTheme.peers.Dialog,
|
|
themeOverrides: this.mergedTheme.peerOverrides.Dialog
|
|
}, keep(this.$props, dialogPropKeys), {
|
|
titleClass: this.dialogTitleClass,
|
|
"aria-modal": "true"
|
|
}), $slots) : this.preset === "card" ? h(__unplugin_components_0$1, Object.assign({}, this.$attrs, {
|
|
ref: "bodyRef",
|
|
class: [`${mergedClsPrefix}-modal`, this.$attrs.class],
|
|
theme: this.mergedTheme.peers.Card,
|
|
themeOverrides: this.mergedTheme.peerOverrides.Card
|
|
}, keep(this.$props, cardBasePropKeys), {
|
|
headerClass: this.cardHeaderClass,
|
|
"aria-modal": "true",
|
|
role: "dialog"
|
|
}), $slots) : this.childNodeRef = childNode, dirs);
|
|
}
|
|
});
|
|
}
|
|
})];
|
|
}
|
|
})), [[vShow, this.displayDirective === "if" || this.displayed || this.show]]) : null;
|
|
}
|
|
});
|
|
const style$7 = c([cB("modal-container", `
|
|
position: fixed;
|
|
left: 0;
|
|
top: 0;
|
|
height: 0;
|
|
width: 0;
|
|
display: flex;
|
|
`), cB("modal-mask", `
|
|
position: fixed;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
background-color: rgba(0, 0, 0, .4);
|
|
`, [fadeInTransition({
|
|
enterDuration: ".25s",
|
|
leaveDuration: ".25s",
|
|
enterCubicBezier: "var(--n-bezier-ease-out)",
|
|
leaveCubicBezier: "var(--n-bezier-ease-out)"
|
|
})]), cB("modal-body-wrapper", `
|
|
position: fixed;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
overflow: visible;
|
|
`, [cB("modal-scroll-content", `
|
|
min-height: 100%;
|
|
display: flex;
|
|
position: relative;
|
|
`)]), cB("modal", `
|
|
position: relative;
|
|
align-self: center;
|
|
color: var(--n-text-color);
|
|
margin: auto;
|
|
box-shadow: var(--n-box-shadow);
|
|
`, [fadeInScaleUpTransition({
|
|
duration: ".25s",
|
|
enterScale: ".5"
|
|
}), c(`.${DRAGGABLE_CLASS}`, `
|
|
cursor: move;
|
|
user-select: none;
|
|
`)])]);
|
|
const modalProps = Object.assign(Object.assign(Object.assign(Object.assign({}, useTheme.props), {
|
|
show: Boolean,
|
|
unstableShowMask: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
maskClosable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
preset: String,
|
|
to: [String, Object],
|
|
displayDirective: {
|
|
type: String,
|
|
default: "if"
|
|
},
|
|
transformOrigin: {
|
|
type: String,
|
|
default: "mouse"
|
|
},
|
|
zIndex: Number,
|
|
autoFocus: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
trapFocus: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
closeOnEsc: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
blockScroll: {
|
|
type: Boolean,
|
|
default: true
|
|
}
|
|
}), presetProps), {
|
|
draggable: [Boolean, Object],
|
|
// events
|
|
onEsc: Function,
|
|
"onUpdate:show": [Function, Array],
|
|
onUpdateShow: [Function, Array],
|
|
onAfterEnter: Function,
|
|
onBeforeLeave: Function,
|
|
onAfterLeave: Function,
|
|
onClose: Function,
|
|
onPositiveClick: Function,
|
|
onNegativeClick: Function,
|
|
onMaskClick: Function,
|
|
// private
|
|
internalDialog: Boolean,
|
|
internalModal: Boolean,
|
|
internalAppear: {
|
|
type: Boolean,
|
|
default: void 0
|
|
},
|
|
// deprecated
|
|
overlayStyle: [String, Object],
|
|
onBeforeHide: Function,
|
|
onAfterHide: Function,
|
|
onHide: Function
|
|
});
|
|
const __unplugin_components_4 = /* @__PURE__ */ defineComponent({
|
|
name: "Modal",
|
|
inheritAttrs: false,
|
|
props: modalProps,
|
|
slots: Object,
|
|
setup(props) {
|
|
const containerRef = ref(null);
|
|
const {
|
|
mergedClsPrefixRef,
|
|
namespaceRef,
|
|
inlineThemeDisabled
|
|
} = useConfig(props);
|
|
const themeRef = useTheme("Modal", "-modal", style$7, modalLight, props, mergedClsPrefixRef);
|
|
const clickedRef = useClicked(64);
|
|
const clickedPositionRef = useClickPosition();
|
|
const isMountedRef = isMounted();
|
|
const NDialogProvider = props.internalDialog ? inject(dialogProviderInjectionKey, null) : null;
|
|
const NModalProvider2 = props.internalModal ? inject(modalProviderInjectionKey$1, null) : null;
|
|
const isComposingRef2 = useIsComposing();
|
|
function doUpdateShow(show) {
|
|
const {
|
|
onUpdateShow,
|
|
"onUpdate:show": _onUpdateShow,
|
|
onHide
|
|
} = props;
|
|
if (onUpdateShow) call(onUpdateShow, show);
|
|
if (_onUpdateShow) call(_onUpdateShow, show);
|
|
if (onHide && !show) onHide(show);
|
|
}
|
|
function handleCloseClick() {
|
|
const {
|
|
onClose
|
|
} = props;
|
|
if (onClose) {
|
|
void Promise.resolve(onClose()).then((value) => {
|
|
if (value === false) return;
|
|
doUpdateShow(false);
|
|
});
|
|
} else {
|
|
doUpdateShow(false);
|
|
}
|
|
}
|
|
function handlePositiveClick() {
|
|
const {
|
|
onPositiveClick
|
|
} = props;
|
|
if (onPositiveClick) {
|
|
void Promise.resolve(onPositiveClick()).then((value) => {
|
|
if (value === false) return;
|
|
doUpdateShow(false);
|
|
});
|
|
} else {
|
|
doUpdateShow(false);
|
|
}
|
|
}
|
|
function handleNegativeClick() {
|
|
const {
|
|
onNegativeClick
|
|
} = props;
|
|
if (onNegativeClick) {
|
|
void Promise.resolve(onNegativeClick()).then((value) => {
|
|
if (value === false) return;
|
|
doUpdateShow(false);
|
|
});
|
|
} else {
|
|
doUpdateShow(false);
|
|
}
|
|
}
|
|
function handleBeforeLeave() {
|
|
const {
|
|
onBeforeLeave,
|
|
onBeforeHide
|
|
} = props;
|
|
if (onBeforeLeave) call(onBeforeLeave);
|
|
if (onBeforeHide) onBeforeHide();
|
|
}
|
|
function handleAfterLeave() {
|
|
const {
|
|
onAfterLeave,
|
|
onAfterHide
|
|
} = props;
|
|
if (onAfterLeave) call(onAfterLeave);
|
|
if (onAfterHide) onAfterHide();
|
|
}
|
|
function handleClickoutside(e) {
|
|
var _a;
|
|
const {
|
|
onMaskClick
|
|
} = props;
|
|
if (onMaskClick) {
|
|
onMaskClick(e);
|
|
}
|
|
if (props.maskClosable) {
|
|
if ((_a = containerRef.value) === null || _a === void 0 ? void 0 : _a.contains(getPreciseEventTarget(e))) {
|
|
doUpdateShow(false);
|
|
}
|
|
}
|
|
}
|
|
function handleEsc(e) {
|
|
var _a;
|
|
(_a = props.onEsc) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
if (props.show && props.closeOnEsc && eventEffectNotPerformed(e)) {
|
|
if (!isComposingRef2.value) {
|
|
doUpdateShow(false);
|
|
}
|
|
}
|
|
}
|
|
provide(modalInjectionKey, {
|
|
getMousePosition: () => {
|
|
const mergedProvider = NDialogProvider || NModalProvider2;
|
|
if (mergedProvider) {
|
|
const {
|
|
clickedRef: clickedRef2,
|
|
clickedPositionRef: clickedPositionRef2
|
|
} = mergedProvider;
|
|
if (clickedRef2.value && clickedPositionRef2.value) {
|
|
return clickedPositionRef2.value;
|
|
}
|
|
}
|
|
if (clickedRef.value) {
|
|
return clickedPositionRef.value;
|
|
}
|
|
return null;
|
|
},
|
|
mergedClsPrefixRef,
|
|
mergedThemeRef: themeRef,
|
|
isMountedRef,
|
|
appearRef: toRef(props, "internalAppear"),
|
|
transformOriginRef: toRef(props, "transformOrigin")
|
|
});
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
common: {
|
|
cubicBezierEaseOut: cubicBezierEaseOut2
|
|
},
|
|
self: {
|
|
boxShadow,
|
|
color,
|
|
textColor
|
|
}
|
|
} = themeRef.value;
|
|
return {
|
|
"--n-bezier-ease-out": cubicBezierEaseOut2,
|
|
"--n-box-shadow": boxShadow,
|
|
"--n-color": color,
|
|
"--n-text-color": textColor
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("theme-class", void 0, cssVarsRef, props) : void 0;
|
|
return {
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
namespace: namespaceRef,
|
|
isMounted: isMountedRef,
|
|
containerRef,
|
|
presetProps: computed(() => {
|
|
const pickedProps = keep(props, presetPropsKeys);
|
|
return pickedProps;
|
|
}),
|
|
handleEsc,
|
|
handleAfterLeave,
|
|
handleClickoutside,
|
|
handleBeforeLeave,
|
|
doUpdateShow,
|
|
handleNegativeClick,
|
|
handlePositiveClick,
|
|
handleCloseClick,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
};
|
|
},
|
|
render() {
|
|
const {
|
|
mergedClsPrefix
|
|
} = this;
|
|
return h(LazyTeleport, {
|
|
to: this.to,
|
|
show: this.show
|
|
}, {
|
|
default: () => {
|
|
var _a;
|
|
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
const {
|
|
unstableShowMask
|
|
} = this;
|
|
return withDirectives(h("div", {
|
|
role: "none",
|
|
ref: "containerRef",
|
|
class: [`${mergedClsPrefix}-modal-container`, this.themeClass, this.namespace],
|
|
style: this.cssVars
|
|
}, h(NModalBodyWrapper, Object.assign({
|
|
style: this.overlayStyle
|
|
}, this.$attrs, {
|
|
ref: "bodyWrapper",
|
|
displayDirective: this.displayDirective,
|
|
show: this.show,
|
|
preset: this.preset,
|
|
autoFocus: this.autoFocus,
|
|
trapFocus: this.trapFocus,
|
|
draggable: this.draggable,
|
|
blockScroll: this.blockScroll
|
|
}, this.presetProps, {
|
|
onEsc: this.handleEsc,
|
|
onClose: this.handleCloseClick,
|
|
onNegativeClick: this.handleNegativeClick,
|
|
onPositiveClick: this.handlePositiveClick,
|
|
onBeforeLeave: this.handleBeforeLeave,
|
|
onAfterEnter: this.onAfterEnter,
|
|
onAfterLeave: this.handleAfterLeave,
|
|
onClickoutside: unstableShowMask ? void 0 : this.handleClickoutside,
|
|
renderMask: unstableShowMask ? () => {
|
|
var _a2;
|
|
return h(Transition, {
|
|
name: "fade-in-transition",
|
|
key: "mask",
|
|
appear: (_a2 = this.internalAppear) !== null && _a2 !== void 0 ? _a2 : this.isMounted
|
|
}, {
|
|
default: () => {
|
|
return this.show ? h("div", {
|
|
"aria-hidden": true,
|
|
ref: "containerRef",
|
|
class: `${mergedClsPrefix}-modal-mask`,
|
|
onClick: this.handleClickoutside
|
|
}) : null;
|
|
}
|
|
});
|
|
} : void 0
|
|
}), this.$slots)), [[zindexable, {
|
|
zIndex: this.zIndex,
|
|
enabled: this.show
|
|
}]]);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
const loadingBarProviderInjectionKey = createInjectionKey("n-loading-bar");
|
|
const loadingBarApiInjectionKey = createInjectionKey("n-loading-bar-api");
|
|
function self$4(vars) {
|
|
const {
|
|
primaryColor,
|
|
errorColor
|
|
} = vars;
|
|
return {
|
|
colorError: errorColor,
|
|
colorLoading: primaryColor,
|
|
height: "2px"
|
|
};
|
|
}
|
|
const loadingBarLight = {
|
|
common: derived,
|
|
self: self$4
|
|
};
|
|
const style$6 = cB("loading-bar-container", `
|
|
z-index: 5999;
|
|
position: fixed;
|
|
top: 0;
|
|
left: 0;
|
|
right: 0;
|
|
height: 2px;
|
|
`, [fadeInTransition({
|
|
enterDuration: "0.3s",
|
|
leaveDuration: "0.8s"
|
|
}), cB("loading-bar", `
|
|
width: 100%;
|
|
transition:
|
|
max-width 4s linear,
|
|
background .2s linear;
|
|
height: var(--n-height);
|
|
`, [cM("starting", `
|
|
background: var(--n-color-loading);
|
|
`), cM("finishing", `
|
|
background: var(--n-color-loading);
|
|
transition:
|
|
max-width .2s linear,
|
|
background .2s linear;
|
|
`), cM("error", `
|
|
background: var(--n-color-error);
|
|
transition:
|
|
max-width .2s linear,
|
|
background .2s linear;
|
|
`)])]);
|
|
var __awaiter = function(thisArg, _arguments, P, generator) {
|
|
function adopt(value) {
|
|
return value instanceof P ? value : new P(function(resolve2) {
|
|
resolve2(value);
|
|
});
|
|
}
|
|
return new (P || (P = Promise))(function(resolve2, reject) {
|
|
function fulfilled(value) {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
}
|
|
function rejected(value) {
|
|
try {
|
|
step(generator["throw"](value));
|
|
} catch (e) {
|
|
reject(e);
|
|
}
|
|
}
|
|
function step(result) {
|
|
result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
}
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
function createClassName(status, clsPrefix) {
|
|
return `${clsPrefix}-loading-bar ${clsPrefix}-loading-bar--${status}`;
|
|
}
|
|
const NLoadingBar = /* @__PURE__ */ defineComponent({
|
|
name: "LoadingBar",
|
|
props: {
|
|
containerClass: String,
|
|
containerStyle: [String, Object]
|
|
},
|
|
setup() {
|
|
const {
|
|
inlineThemeDisabled
|
|
} = useConfig();
|
|
const {
|
|
props: providerProps,
|
|
mergedClsPrefixRef
|
|
} = inject(loadingBarProviderInjectionKey);
|
|
const loadingBarRef = ref(null);
|
|
const enteringRef = ref(false);
|
|
const startedRef = ref(false);
|
|
const loadingRef = ref(false);
|
|
const transitionDisabledRef = ref(false);
|
|
let finishing = false;
|
|
const erroringRef = ref(false);
|
|
const mergedLoadingBarStyle = computed(() => {
|
|
const {
|
|
loadingBarStyle
|
|
} = providerProps;
|
|
if (!loadingBarStyle) return "";
|
|
return loadingBarStyle[erroringRef.value ? "error" : "loading"];
|
|
});
|
|
function init2() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
enteringRef.value = false;
|
|
loadingRef.value = false;
|
|
finishing = false;
|
|
erroringRef.value = false;
|
|
transitionDisabledRef.value = true;
|
|
yield nextTick();
|
|
transitionDisabledRef.value = false;
|
|
});
|
|
}
|
|
function start() {
|
|
return __awaiter(this, arguments, void 0, function* (fromProgress = 0, toProgress = 80, status = "starting") {
|
|
startedRef.value = true;
|
|
yield init2();
|
|
if (finishing) return;
|
|
loadingRef.value = true;
|
|
yield nextTick();
|
|
const el = loadingBarRef.value;
|
|
if (!el) return;
|
|
el.style.maxWidth = `${fromProgress}%`;
|
|
el.style.transition = "none";
|
|
void el.offsetWidth;
|
|
el.className = createClassName(status, mergedClsPrefixRef.value);
|
|
el.style.transition = "";
|
|
el.style.maxWidth = `${toProgress}%`;
|
|
});
|
|
}
|
|
function finish() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
if (finishing || erroringRef.value) return;
|
|
if (startedRef.value) {
|
|
yield nextTick();
|
|
}
|
|
finishing = true;
|
|
const el = loadingBarRef.value;
|
|
if (!el) return;
|
|
el.className = createClassName("finishing", mergedClsPrefixRef.value);
|
|
el.style.maxWidth = "100%";
|
|
void el.offsetWidth;
|
|
loadingRef.value = false;
|
|
});
|
|
}
|
|
function error2() {
|
|
if (finishing || erroringRef.value) return;
|
|
if (!loadingRef.value) {
|
|
void start(100, 100, "error").then(() => {
|
|
erroringRef.value = true;
|
|
const el = loadingBarRef.value;
|
|
if (!el) return;
|
|
el.className = createClassName("error", mergedClsPrefixRef.value);
|
|
void el.offsetWidth;
|
|
loadingRef.value = false;
|
|
});
|
|
} else {
|
|
erroringRef.value = true;
|
|
const el = loadingBarRef.value;
|
|
if (!el) return;
|
|
el.className = createClassName("error", mergedClsPrefixRef.value);
|
|
el.style.maxWidth = "100%";
|
|
void el.offsetWidth;
|
|
loadingRef.value = false;
|
|
}
|
|
}
|
|
function handleEnter() {
|
|
enteringRef.value = true;
|
|
}
|
|
function handleAfterEnter() {
|
|
enteringRef.value = false;
|
|
}
|
|
function handleAfterLeave() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
yield init2();
|
|
});
|
|
}
|
|
const themeRef = useTheme("LoadingBar", "-loading-bar", style$6, loadingBarLight, providerProps, mergedClsPrefixRef);
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
self: {
|
|
height,
|
|
colorError,
|
|
colorLoading
|
|
}
|
|
} = themeRef.value;
|
|
return {
|
|
"--n-height": height,
|
|
"--n-color-loading": colorLoading,
|
|
"--n-color-error": colorError
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("loading-bar", void 0, cssVarsRef, providerProps) : void 0;
|
|
return {
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
loadingBarRef,
|
|
started: startedRef,
|
|
loading: loadingRef,
|
|
entering: enteringRef,
|
|
transitionDisabled: transitionDisabledRef,
|
|
start,
|
|
error: error2,
|
|
finish,
|
|
handleEnter,
|
|
handleAfterEnter,
|
|
handleAfterLeave,
|
|
mergedLoadingBarStyle,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
};
|
|
},
|
|
render() {
|
|
if (!this.started) return null;
|
|
const {
|
|
mergedClsPrefix
|
|
} = this;
|
|
return h(Transition, {
|
|
name: "fade-in-transition",
|
|
appear: true,
|
|
onEnter: this.handleEnter,
|
|
onAfterEnter: this.handleAfterEnter,
|
|
onAfterLeave: this.handleAfterLeave,
|
|
css: !this.transitionDisabled
|
|
}, {
|
|
default: () => {
|
|
var _a;
|
|
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
return withDirectives(h("div", {
|
|
class: [`${mergedClsPrefix}-loading-bar-container`, this.themeClass, this.containerClass],
|
|
style: this.containerStyle
|
|
}, h("div", {
|
|
ref: "loadingBarRef",
|
|
class: [`${mergedClsPrefix}-loading-bar`],
|
|
style: [this.cssVars, this.mergedLoadingBarStyle]
|
|
})), [[vShow, this.loading || !this.loading && this.entering]]);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
const loadingBarProviderProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
to: {
|
|
type: [String, Object, Boolean],
|
|
default: void 0
|
|
},
|
|
containerClass: String,
|
|
containerStyle: [String, Object],
|
|
loadingBarStyle: {
|
|
type: Object
|
|
}
|
|
});
|
|
const __unplugin_components_8 = /* @__PURE__ */ defineComponent({
|
|
name: "LoadingBarProvider",
|
|
props: loadingBarProviderProps,
|
|
setup(props) {
|
|
const isMountedRef = isMounted();
|
|
const loadingBarRef = ref(null);
|
|
const methods = {
|
|
start() {
|
|
var _a;
|
|
if (isMountedRef.value) {
|
|
(_a = loadingBarRef.value) === null || _a === void 0 ? void 0 : _a.start();
|
|
} else {
|
|
void nextTick(() => {
|
|
var _a2;
|
|
(_a2 = loadingBarRef.value) === null || _a2 === void 0 ? void 0 : _a2.start();
|
|
});
|
|
}
|
|
},
|
|
error() {
|
|
var _a;
|
|
if (isMountedRef.value) {
|
|
(_a = loadingBarRef.value) === null || _a === void 0 ? void 0 : _a.error();
|
|
} else {
|
|
void nextTick(() => {
|
|
var _a2;
|
|
(_a2 = loadingBarRef.value) === null || _a2 === void 0 ? void 0 : _a2.error();
|
|
});
|
|
}
|
|
},
|
|
finish() {
|
|
var _a;
|
|
if (isMountedRef.value) {
|
|
(_a = loadingBarRef.value) === null || _a === void 0 ? void 0 : _a.finish();
|
|
} else {
|
|
void nextTick(() => {
|
|
var _a2;
|
|
(_a2 = loadingBarRef.value) === null || _a2 === void 0 ? void 0 : _a2.finish();
|
|
});
|
|
}
|
|
}
|
|
};
|
|
const {
|
|
mergedClsPrefixRef
|
|
} = useConfig(props);
|
|
provide(loadingBarApiInjectionKey, methods);
|
|
provide(loadingBarProviderInjectionKey, {
|
|
props,
|
|
mergedClsPrefixRef
|
|
});
|
|
return Object.assign(methods, {
|
|
loadingBarRef
|
|
});
|
|
},
|
|
render() {
|
|
var _a, _b;
|
|
return h(Fragment, null, h(Teleport, {
|
|
disabled: this.to === false,
|
|
to: this.to || "body"
|
|
}, h(NLoadingBar, {
|
|
ref: "loadingBarRef",
|
|
containerStyle: this.containerStyle,
|
|
containerClass: this.containerClass
|
|
})), (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
}
|
|
});
|
|
const messageApiInjectionKey = createInjectionKey("n-message-api");
|
|
const messageProviderInjectionKey = createInjectionKey("n-message-provider");
|
|
const commonVariables = {
|
|
margin: "0 0 8px 0",
|
|
padding: "10px 20px",
|
|
maxWidth: "720px",
|
|
minWidth: "420px",
|
|
iconMargin: "0 10px 0 0",
|
|
closeMargin: "0 0 0 10px",
|
|
closeSize: "20px",
|
|
closeIconSize: "16px",
|
|
iconSize: "20px",
|
|
fontSize: "14px"
|
|
};
|
|
function self$3(vars) {
|
|
const {
|
|
textColor2,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
infoColor,
|
|
successColor,
|
|
errorColor,
|
|
warningColor,
|
|
popoverColor,
|
|
boxShadow2,
|
|
primaryColor,
|
|
lineHeight: lineHeight2,
|
|
borderRadius,
|
|
closeColorHover,
|
|
closeColorPressed
|
|
} = vars;
|
|
return Object.assign(Object.assign({}, commonVariables), {
|
|
closeBorderRadius: borderRadius,
|
|
textColor: textColor2,
|
|
textColorInfo: textColor2,
|
|
textColorSuccess: textColor2,
|
|
textColorError: textColor2,
|
|
textColorWarning: textColor2,
|
|
textColorLoading: textColor2,
|
|
color: popoverColor,
|
|
colorInfo: popoverColor,
|
|
colorSuccess: popoverColor,
|
|
colorError: popoverColor,
|
|
colorWarning: popoverColor,
|
|
colorLoading: popoverColor,
|
|
boxShadow: boxShadow2,
|
|
boxShadowInfo: boxShadow2,
|
|
boxShadowSuccess: boxShadow2,
|
|
boxShadowError: boxShadow2,
|
|
boxShadowWarning: boxShadow2,
|
|
boxShadowLoading: boxShadow2,
|
|
iconColor: textColor2,
|
|
iconColorInfo: infoColor,
|
|
iconColorSuccess: successColor,
|
|
iconColorWarning: warningColor,
|
|
iconColorError: errorColor,
|
|
iconColorLoading: primaryColor,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
closeColorHoverInfo: closeColorHover,
|
|
closeColorPressedInfo: closeColorPressed,
|
|
closeIconColorInfo: closeIconColor,
|
|
closeIconColorHoverInfo: closeIconColorHover,
|
|
closeIconColorPressedInfo: closeIconColorPressed,
|
|
closeColorHoverSuccess: closeColorHover,
|
|
closeColorPressedSuccess: closeColorPressed,
|
|
closeIconColorSuccess: closeIconColor,
|
|
closeIconColorHoverSuccess: closeIconColorHover,
|
|
closeIconColorPressedSuccess: closeIconColorPressed,
|
|
closeColorHoverError: closeColorHover,
|
|
closeColorPressedError: closeColorPressed,
|
|
closeIconColorError: closeIconColor,
|
|
closeIconColorHoverError: closeIconColorHover,
|
|
closeIconColorPressedError: closeIconColorPressed,
|
|
closeColorHoverWarning: closeColorHover,
|
|
closeColorPressedWarning: closeColorPressed,
|
|
closeIconColorWarning: closeIconColor,
|
|
closeIconColorHoverWarning: closeIconColorHover,
|
|
closeIconColorPressedWarning: closeIconColorPressed,
|
|
closeColorHoverLoading: closeColorHover,
|
|
closeColorPressedLoading: closeColorPressed,
|
|
closeIconColorLoading: closeIconColor,
|
|
closeIconColorHoverLoading: closeIconColorHover,
|
|
closeIconColorPressedLoading: closeIconColorPressed,
|
|
loadingColor: primaryColor,
|
|
lineHeight: lineHeight2,
|
|
borderRadius
|
|
});
|
|
}
|
|
const messageLight = {
|
|
common: derived,
|
|
self: self$3
|
|
};
|
|
const messageProps = {
|
|
icon: Function,
|
|
type: {
|
|
type: String,
|
|
default: "info"
|
|
},
|
|
content: [String, Number, Function],
|
|
showIcon: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
closable: Boolean,
|
|
keepAliveOnHover: Boolean,
|
|
onClose: Function,
|
|
onMouseenter: Function,
|
|
onMouseleave: Function
|
|
};
|
|
const style$5 = c([cB("message-wrapper", `
|
|
margin: var(--n-margin);
|
|
z-index: 0;
|
|
transform-origin: top center;
|
|
display: flex;
|
|
`, [fadeInHeightExpandTransition({
|
|
overflow: "visible",
|
|
originalTransition: "transform .3s var(--n-bezier)",
|
|
enterToProps: {
|
|
transform: "scale(1)"
|
|
},
|
|
leaveToProps: {
|
|
transform: "scale(0.85)"
|
|
}
|
|
})]), cB("message", `
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
align-items: center;
|
|
transition:
|
|
color .3s var(--n-bezier),
|
|
box-shadow .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier),
|
|
opacity .3s var(--n-bezier),
|
|
transform .3s var(--n-bezier),
|
|
margin-bottom .3s var(--n-bezier);
|
|
padding: var(--n-padding);
|
|
border-radius: var(--n-border-radius);
|
|
flex-wrap: nowrap;
|
|
overflow: hidden;
|
|
max-width: var(--n-max-width);
|
|
color: var(--n-text-color);
|
|
background-color: var(--n-color);
|
|
box-shadow: var(--n-box-shadow);
|
|
`, [cE("content", `
|
|
display: inline-block;
|
|
line-height: var(--n-line-height);
|
|
font-size: var(--n-font-size);
|
|
`), cE("icon", `
|
|
position: relative;
|
|
margin: var(--n-icon-margin);
|
|
height: var(--n-icon-size);
|
|
width: var(--n-icon-size);
|
|
font-size: var(--n-icon-size);
|
|
flex-shrink: 0;
|
|
`, [["default", "info", "success", "warning", "error", "loading"].map((type) => cM(`${type}-type`, [c("> *", `
|
|
color: var(--n-icon-color-${type});
|
|
transition: color .3s var(--n-bezier);
|
|
`)])), c("> *", `
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
`, [iconSwitchTransition()])]), cE("close", `
|
|
margin: var(--n-close-margin);
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier);
|
|
flex-shrink: 0;
|
|
`, [c("&:hover", `
|
|
color: var(--n-close-icon-color-hover);
|
|
`), c("&:active", `
|
|
color: var(--n-close-icon-color-pressed);
|
|
`)])]), cB("message-container", `
|
|
z-index: 6000;
|
|
position: fixed;
|
|
height: 0;
|
|
overflow: visible;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
`, [cM("top", `
|
|
top: 12px;
|
|
left: 0;
|
|
right: 0;
|
|
`), cM("top-left", `
|
|
top: 12px;
|
|
left: 12px;
|
|
right: 0;
|
|
align-items: flex-start;
|
|
`), cM("top-right", `
|
|
top: 12px;
|
|
left: 0;
|
|
right: 12px;
|
|
align-items: flex-end;
|
|
`), cM("bottom", `
|
|
bottom: 4px;
|
|
left: 0;
|
|
right: 0;
|
|
justify-content: flex-end;
|
|
`), cM("bottom-left", `
|
|
bottom: 4px;
|
|
left: 12px;
|
|
right: 0;
|
|
justify-content: flex-end;
|
|
align-items: flex-start;
|
|
`), cM("bottom-right", `
|
|
bottom: 4px;
|
|
left: 0;
|
|
right: 12px;
|
|
justify-content: flex-end;
|
|
align-items: flex-end;
|
|
`)])]);
|
|
const iconRenderMap$1 = {
|
|
info: () => h(InfoIcon, null),
|
|
success: () => h(SuccessIcon, null),
|
|
warning: () => h(WarningIcon, null),
|
|
error: () => h(ErrorIcon, null),
|
|
default: () => null
|
|
};
|
|
const NMessage = /* @__PURE__ */ defineComponent({
|
|
name: "Message",
|
|
props: Object.assign(Object.assign({}, messageProps), {
|
|
render: Function
|
|
}),
|
|
setup(props) {
|
|
const {
|
|
inlineThemeDisabled,
|
|
mergedRtlRef
|
|
} = useConfig(props);
|
|
const {
|
|
props: messageProviderProps2,
|
|
mergedClsPrefixRef
|
|
} = inject(messageProviderInjectionKey);
|
|
const rtlEnabledRef = useRtl("Message", mergedRtlRef, mergedClsPrefixRef);
|
|
const themeRef = useTheme("Message", "-message", style$5, messageLight, messageProviderProps2, mergedClsPrefixRef);
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
type
|
|
} = props;
|
|
const {
|
|
common: {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2
|
|
},
|
|
self: {
|
|
padding,
|
|
margin,
|
|
maxWidth,
|
|
iconMargin,
|
|
closeMargin,
|
|
closeSize,
|
|
iconSize,
|
|
fontSize: fontSize2,
|
|
lineHeight: lineHeight2,
|
|
borderRadius,
|
|
iconColorInfo,
|
|
iconColorSuccess,
|
|
iconColorWarning,
|
|
iconColorError,
|
|
iconColorLoading,
|
|
closeIconSize,
|
|
closeBorderRadius,
|
|
[createKey("textColor", type)]: textColor,
|
|
[createKey("boxShadow", type)]: boxShadow,
|
|
[createKey("color", type)]: color,
|
|
[createKey("closeColorHover", type)]: closeColorHover,
|
|
[createKey("closeColorPressed", type)]: closeColorPressed,
|
|
[createKey("closeIconColor", type)]: closeIconColor,
|
|
[createKey("closeIconColorPressed", type)]: closeIconColorPressed,
|
|
[createKey("closeIconColorHover", type)]: closeIconColorHover
|
|
}
|
|
} = themeRef.value;
|
|
return {
|
|
"--n-bezier": cubicBezierEaseInOut2,
|
|
"--n-margin": margin,
|
|
"--n-padding": padding,
|
|
"--n-max-width": maxWidth,
|
|
"--n-font-size": fontSize2,
|
|
"--n-icon-margin": iconMargin,
|
|
"--n-icon-size": iconSize,
|
|
"--n-close-icon-size": closeIconSize,
|
|
"--n-close-border-radius": closeBorderRadius,
|
|
"--n-close-size": closeSize,
|
|
"--n-close-margin": closeMargin,
|
|
"--n-text-color": textColor,
|
|
"--n-color": color,
|
|
"--n-box-shadow": boxShadow,
|
|
"--n-icon-color-info": iconColorInfo,
|
|
"--n-icon-color-success": iconColorSuccess,
|
|
"--n-icon-color-warning": iconColorWarning,
|
|
"--n-icon-color-error": iconColorError,
|
|
"--n-icon-color-loading": iconColorLoading,
|
|
"--n-close-color-hover": closeColorHover,
|
|
"--n-close-color-pressed": closeColorPressed,
|
|
"--n-close-icon-color": closeIconColor,
|
|
"--n-close-icon-color-pressed": closeIconColorPressed,
|
|
"--n-close-icon-color-hover": closeIconColorHover,
|
|
"--n-line-height": lineHeight2,
|
|
"--n-border-radius": borderRadius
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("message", computed(() => props.type[0]), cssVarsRef, {}) : void 0;
|
|
return {
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
rtlEnabled: rtlEnabledRef,
|
|
messageProviderProps: messageProviderProps2,
|
|
handleClose() {
|
|
var _a;
|
|
(_a = props.onClose) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
},
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender,
|
|
placement: messageProviderProps2.placement
|
|
};
|
|
},
|
|
render() {
|
|
const {
|
|
render: renderMessage,
|
|
type,
|
|
closable,
|
|
content,
|
|
mergedClsPrefix,
|
|
cssVars,
|
|
themeClass,
|
|
onRender,
|
|
icon,
|
|
handleClose,
|
|
showIcon
|
|
} = this;
|
|
onRender === null || onRender === void 0 ? void 0 : onRender();
|
|
let iconNode;
|
|
return h("div", {
|
|
class: [`${mergedClsPrefix}-message-wrapper`, themeClass],
|
|
onMouseenter: this.onMouseenter,
|
|
onMouseleave: this.onMouseleave,
|
|
style: [{
|
|
alignItems: this.placement.startsWith("top") ? "flex-start" : "flex-end"
|
|
}, cssVars]
|
|
}, renderMessage ? renderMessage(this.$props) : h("div", {
|
|
class: [`${mergedClsPrefix}-message ${mergedClsPrefix}-message--${type}-type`, this.rtlEnabled && `${mergedClsPrefix}-message--rtl`]
|
|
}, (iconNode = createIconVNode(icon, type, mergedClsPrefix)) && showIcon ? h("div", {
|
|
class: `${mergedClsPrefix}-message__icon ${mergedClsPrefix}-message__icon--${type}-type`
|
|
}, h(NIconSwitchTransition, null, {
|
|
default: () => iconNode
|
|
})) : null, h("div", {
|
|
class: `${mergedClsPrefix}-message__content`
|
|
}, render(content)), closable ? h(NBaseClose, {
|
|
clsPrefix: mergedClsPrefix,
|
|
class: `${mergedClsPrefix}-message__close`,
|
|
onClick: handleClose,
|
|
absolute: true
|
|
}) : null));
|
|
}
|
|
});
|
|
function createIconVNode(icon, type, clsPrefix) {
|
|
if (typeof icon === "function") {
|
|
return icon();
|
|
} else {
|
|
const innerIcon = type === "loading" ? h(NBaseLoading, {
|
|
clsPrefix,
|
|
strokeWidth: 24,
|
|
scale: 0.85
|
|
}) : iconRenderMap$1[type]();
|
|
if (!innerIcon) return null;
|
|
return h(NBaseIcon, {
|
|
clsPrefix,
|
|
key: type
|
|
}, {
|
|
default: () => innerIcon
|
|
});
|
|
}
|
|
}
|
|
const MessageEnvironment = /* @__PURE__ */ defineComponent({
|
|
name: "MessageEnvironment",
|
|
props: Object.assign(Object.assign({}, messageProps), {
|
|
duration: {
|
|
type: Number,
|
|
default: 3e3
|
|
},
|
|
onAfterLeave: Function,
|
|
onLeave: Function,
|
|
internalKey: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
// private
|
|
onInternalAfterLeave: Function,
|
|
// deprecated
|
|
onHide: Function,
|
|
onAfterHide: Function
|
|
}),
|
|
setup(props) {
|
|
let timerId = null;
|
|
const showRef = ref(true);
|
|
onMounted(() => {
|
|
setHideTimeout();
|
|
});
|
|
function setHideTimeout() {
|
|
const {
|
|
duration: duration2
|
|
} = props;
|
|
if (duration2) {
|
|
timerId = window.setTimeout(hide, duration2);
|
|
}
|
|
}
|
|
function handleMouseenter(e) {
|
|
if (e.currentTarget !== e.target) return;
|
|
if (timerId !== null) {
|
|
window.clearTimeout(timerId);
|
|
timerId = null;
|
|
}
|
|
}
|
|
function handleMouseleave(e) {
|
|
if (e.currentTarget !== e.target) return;
|
|
setHideTimeout();
|
|
}
|
|
function hide() {
|
|
const {
|
|
onHide
|
|
} = props;
|
|
showRef.value = false;
|
|
if (timerId) {
|
|
window.clearTimeout(timerId);
|
|
timerId = null;
|
|
}
|
|
if (onHide) onHide();
|
|
}
|
|
function handleClose() {
|
|
const {
|
|
onClose
|
|
} = props;
|
|
if (onClose) onClose();
|
|
hide();
|
|
}
|
|
function handleAfterLeave() {
|
|
const {
|
|
onAfterLeave,
|
|
onInternalAfterLeave,
|
|
onAfterHide,
|
|
internalKey
|
|
} = props;
|
|
if (onAfterLeave) onAfterLeave();
|
|
if (onInternalAfterLeave) onInternalAfterLeave(internalKey);
|
|
if (onAfterHide) onAfterHide();
|
|
}
|
|
function deactivate() {
|
|
hide();
|
|
}
|
|
return {
|
|
show: showRef,
|
|
hide,
|
|
handleClose,
|
|
handleAfterLeave,
|
|
handleMouseleave,
|
|
handleMouseenter,
|
|
deactivate
|
|
};
|
|
},
|
|
render() {
|
|
return h(NFadeInExpandTransition, {
|
|
appear: true,
|
|
onAfterLeave: this.handleAfterLeave,
|
|
onLeave: this.onLeave
|
|
}, {
|
|
default: () => [this.show ? h(NMessage, {
|
|
content: this.content,
|
|
type: this.type,
|
|
icon: this.icon,
|
|
showIcon: this.showIcon,
|
|
closable: this.closable,
|
|
onClose: this.handleClose,
|
|
onMouseenter: this.keepAliveOnHover ? this.handleMouseenter : void 0,
|
|
onMouseleave: this.keepAliveOnHover ? this.handleMouseleave : void 0
|
|
}) : null]
|
|
});
|
|
}
|
|
});
|
|
const messageProviderProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
to: [String, Object],
|
|
duration: {
|
|
type: Number,
|
|
default: 3e3
|
|
},
|
|
keepAliveOnHover: Boolean,
|
|
max: Number,
|
|
placement: {
|
|
type: String,
|
|
default: "top"
|
|
},
|
|
closable: Boolean,
|
|
containerClass: String,
|
|
containerStyle: [String, Object]
|
|
});
|
|
const __unplugin_components_9 = /* @__PURE__ */ defineComponent({
|
|
name: "MessageProvider",
|
|
props: messageProviderProps,
|
|
setup(props) {
|
|
const {
|
|
mergedClsPrefixRef
|
|
} = useConfig(props);
|
|
const messageListRef = ref([]);
|
|
const messageRefs = ref({});
|
|
const api = {
|
|
create(content, options) {
|
|
return create(content, Object.assign({
|
|
type: "default"
|
|
}, options));
|
|
},
|
|
info(content, options) {
|
|
return create(content, Object.assign(Object.assign({}, options), {
|
|
type: "info"
|
|
}));
|
|
},
|
|
success(content, options) {
|
|
return create(content, Object.assign(Object.assign({}, options), {
|
|
type: "success"
|
|
}));
|
|
},
|
|
warning(content, options) {
|
|
return create(content, Object.assign(Object.assign({}, options), {
|
|
type: "warning"
|
|
}));
|
|
},
|
|
error(content, options) {
|
|
return create(content, Object.assign(Object.assign({}, options), {
|
|
type: "error"
|
|
}));
|
|
},
|
|
loading(content, options) {
|
|
return create(content, Object.assign(Object.assign({}, options), {
|
|
type: "loading"
|
|
}));
|
|
},
|
|
destroyAll
|
|
};
|
|
provide(messageProviderInjectionKey, {
|
|
props,
|
|
mergedClsPrefixRef
|
|
});
|
|
provide(messageApiInjectionKey, api);
|
|
function create(content, options) {
|
|
const key = createId();
|
|
const messageReactive = reactive(Object.assign(Object.assign({}, options), {
|
|
content,
|
|
key,
|
|
destroy: () => {
|
|
var _a;
|
|
(_a = messageRefs.value[key]) === null || _a === void 0 ? void 0 : _a.hide();
|
|
}
|
|
}));
|
|
const {
|
|
max
|
|
} = props;
|
|
if (max && messageListRef.value.length >= max) {
|
|
messageListRef.value.shift();
|
|
}
|
|
messageListRef.value.push(messageReactive);
|
|
return messageReactive;
|
|
}
|
|
function handleAfterLeave(key) {
|
|
messageListRef.value.splice(messageListRef.value.findIndex((message) => message.key === key), 1);
|
|
delete messageRefs.value[key];
|
|
}
|
|
function destroyAll() {
|
|
Object.values(messageRefs.value).forEach((messageInstRef) => {
|
|
messageInstRef.hide();
|
|
});
|
|
}
|
|
return Object.assign({
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
messageRefs,
|
|
messageList: messageListRef,
|
|
handleAfterLeave
|
|
}, api);
|
|
},
|
|
render() {
|
|
var _a, _b, _c;
|
|
return h(Fragment, null, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a), this.messageList.length ? h(Teleport, {
|
|
to: (_c = this.to) !== null && _c !== void 0 ? _c : "body"
|
|
}, h("div", {
|
|
class: [`${this.mergedClsPrefix}-message-container`, `${this.mergedClsPrefix}-message-container--${this.placement}`, this.containerClass],
|
|
key: "message-container",
|
|
style: this.containerStyle
|
|
}, this.messageList.map((message) => {
|
|
return h(MessageEnvironment, Object.assign({
|
|
ref: (inst) => {
|
|
if (inst) {
|
|
this.messageRefs[message.key] = inst;
|
|
}
|
|
},
|
|
internalKey: message.key,
|
|
onInternalAfterLeave: this.handleAfterLeave
|
|
}, omit(message, ["destroy"], void 0), {
|
|
duration: message.duration === void 0 ? this.duration : message.duration,
|
|
keepAliveOnHover: message.keepAliveOnHover === void 0 ? this.keepAliveOnHover : message.keepAliveOnHover,
|
|
closable: message.closable === void 0 ? this.closable : message.closable
|
|
}));
|
|
}))) : null);
|
|
}
|
|
});
|
|
const NModalEnvironment = /* @__PURE__ */ defineComponent({
|
|
name: "ModalEnvironment",
|
|
props: Object.assign(Object.assign({}, modalProps), {
|
|
internalKey: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
// private
|
|
onInternalAfterLeave: {
|
|
type: Function,
|
|
required: true
|
|
}
|
|
}),
|
|
setup(props) {
|
|
const showRef = ref(true);
|
|
function handleAfterLeave() {
|
|
const {
|
|
onInternalAfterLeave,
|
|
internalKey,
|
|
onAfterLeave
|
|
} = props;
|
|
if (onInternalAfterLeave) onInternalAfterLeave(internalKey);
|
|
if (onAfterLeave) onAfterLeave();
|
|
}
|
|
function handlePositiveClick() {
|
|
const {
|
|
onPositiveClick
|
|
} = props;
|
|
if (onPositiveClick) {
|
|
void Promise.resolve(onPositiveClick()).then((result) => {
|
|
if (result === false) return;
|
|
hide();
|
|
});
|
|
} else {
|
|
hide();
|
|
}
|
|
}
|
|
function handleNegativeClick() {
|
|
const {
|
|
onNegativeClick
|
|
} = props;
|
|
if (onNegativeClick) {
|
|
void Promise.resolve(onNegativeClick()).then((result) => {
|
|
if (result === false) return;
|
|
hide();
|
|
});
|
|
} else {
|
|
hide();
|
|
}
|
|
}
|
|
function handleCloseClick() {
|
|
const {
|
|
onClose
|
|
} = props;
|
|
if (onClose) {
|
|
void Promise.resolve(onClose()).then((result) => {
|
|
if (result === false) return;
|
|
hide();
|
|
});
|
|
} else {
|
|
hide();
|
|
}
|
|
}
|
|
function handleMaskClick(e) {
|
|
const {
|
|
onMaskClick,
|
|
maskClosable
|
|
} = props;
|
|
if (onMaskClick) {
|
|
onMaskClick(e);
|
|
if (maskClosable) {
|
|
hide();
|
|
}
|
|
}
|
|
}
|
|
function handleEsc() {
|
|
const {
|
|
onEsc
|
|
} = props;
|
|
if (onEsc) {
|
|
onEsc();
|
|
}
|
|
}
|
|
function hide() {
|
|
showRef.value = false;
|
|
}
|
|
function handleUpdateShow(value) {
|
|
showRef.value = value;
|
|
}
|
|
return {
|
|
show: showRef,
|
|
hide,
|
|
handleUpdateShow,
|
|
handleAfterLeave,
|
|
handleCloseClick,
|
|
handleNegativeClick,
|
|
handlePositiveClick,
|
|
handleMaskClick,
|
|
handleEsc
|
|
};
|
|
},
|
|
render() {
|
|
const {
|
|
handleUpdateShow,
|
|
handleAfterLeave,
|
|
handleMaskClick,
|
|
handleEsc,
|
|
show
|
|
} = this;
|
|
return h(__unplugin_components_4, Object.assign({}, this.$props, {
|
|
show,
|
|
onUpdateShow: handleUpdateShow,
|
|
onMaskClick: handleMaskClick,
|
|
onEsc: handleEsc,
|
|
onAfterLeave: handleAfterLeave,
|
|
internalAppear: true,
|
|
internalModal: true
|
|
}));
|
|
}
|
|
});
|
|
const modalProviderProps = {
|
|
to: [String, Object]
|
|
};
|
|
const NModalProvider = /* @__PURE__ */ defineComponent({
|
|
name: "ModalProvider",
|
|
props: modalProviderProps,
|
|
setup() {
|
|
const modalListRef = ref([]);
|
|
const modalInstRefs = {};
|
|
function create(options = {}) {
|
|
const key = createId();
|
|
const modalReactive = reactive(Object.assign(Object.assign({}, options), {
|
|
key,
|
|
destroy: () => {
|
|
var _a;
|
|
(_a = modalInstRefs[`n-modal-${key}`]) === null || _a === void 0 ? void 0 : _a.hide();
|
|
}
|
|
}));
|
|
modalListRef.value.push(modalReactive);
|
|
return modalReactive;
|
|
}
|
|
function handleAfterLeave(key) {
|
|
const {
|
|
value: modalList
|
|
} = modalListRef;
|
|
modalList.splice(modalList.findIndex((modal) => modal.key === key), 1);
|
|
}
|
|
function destroyAll() {
|
|
Object.values(modalInstRefs).forEach((modalInstRef) => {
|
|
modalInstRef === null || modalInstRef === void 0 ? void 0 : modalInstRef.hide();
|
|
});
|
|
}
|
|
const api = {
|
|
create,
|
|
destroyAll
|
|
};
|
|
provide(modalApiInjectionKey, api);
|
|
provide(modalProviderInjectionKey, {
|
|
clickedRef: useClicked(64),
|
|
clickedPositionRef: useClickPosition()
|
|
});
|
|
provide(modalReactiveListInjectionKey, modalListRef);
|
|
return Object.assign(Object.assign({}, api), {
|
|
modalList: modalListRef,
|
|
modalInstRefs,
|
|
handleAfterLeave
|
|
});
|
|
},
|
|
render() {
|
|
var _a, _b;
|
|
return h(Fragment, null, [this.modalList.map((modal) => {
|
|
var _a2;
|
|
return h(NModalEnvironment, omit(modal, ["destroy"], {
|
|
to: (_a2 = modal.to) !== null && _a2 !== void 0 ? _a2 : this.to,
|
|
ref: (inst) => {
|
|
if (inst === null) {
|
|
delete this.modalInstRefs[`n-modal-${modal.key}`];
|
|
} else {
|
|
this.modalInstRefs[`n-modal-${modal.key}`] = inst;
|
|
}
|
|
},
|
|
internalKey: modal.key,
|
|
onInternalAfterLeave: this.handleAfterLeave
|
|
}));
|
|
}), (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a)]);
|
|
}
|
|
});
|
|
const commonVars = {
|
|
closeMargin: "16px 12px",
|
|
closeSize: "20px",
|
|
closeIconSize: "16px",
|
|
width: "365px",
|
|
padding: "16px",
|
|
titleFontSize: "16px",
|
|
metaFontSize: "12px",
|
|
descriptionFontSize: "12px"
|
|
};
|
|
function self$2(vars) {
|
|
const {
|
|
textColor2,
|
|
successColor,
|
|
infoColor,
|
|
warningColor,
|
|
errorColor,
|
|
popoverColor,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
textColor1,
|
|
textColor3,
|
|
borderRadius,
|
|
fontWeightStrong,
|
|
boxShadow2,
|
|
lineHeight: lineHeight2,
|
|
fontSize: fontSize2
|
|
} = vars;
|
|
return Object.assign(Object.assign({}, commonVars), {
|
|
borderRadius,
|
|
lineHeight: lineHeight2,
|
|
fontSize: fontSize2,
|
|
headerFontWeight: fontWeightStrong,
|
|
iconColor: textColor2,
|
|
iconColorSuccess: successColor,
|
|
iconColorInfo: infoColor,
|
|
iconColorWarning: warningColor,
|
|
iconColorError: errorColor,
|
|
color: popoverColor,
|
|
textColor: textColor2,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
closeBorderRadius: borderRadius,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
headerTextColor: textColor1,
|
|
descriptionTextColor: textColor3,
|
|
actionTextColor: textColor2,
|
|
boxShadow: boxShadow2
|
|
});
|
|
}
|
|
const notificationLight = createTheme({
|
|
name: "Notification",
|
|
common: derived,
|
|
peers: {
|
|
Scrollbar: scrollbarLight
|
|
},
|
|
self: self$2
|
|
});
|
|
const notificationProviderInjectionKey = createInjectionKey("n-notification-provider");
|
|
const NotificationContainer = /* @__PURE__ */ defineComponent({
|
|
name: "NotificationContainer",
|
|
props: {
|
|
scrollable: {
|
|
type: Boolean,
|
|
required: true
|
|
},
|
|
placement: {
|
|
type: String,
|
|
required: true
|
|
}
|
|
},
|
|
setup() {
|
|
const {
|
|
mergedThemeRef,
|
|
mergedClsPrefixRef,
|
|
wipTransitionCountRef
|
|
} = inject(notificationProviderInjectionKey);
|
|
const selfRef = ref(null);
|
|
watchEffect(() => {
|
|
var _a, _b;
|
|
if (wipTransitionCountRef.value > 0) {
|
|
(_a = selfRef === null || selfRef === void 0 ? void 0 : selfRef.value) === null || _a === void 0 ? void 0 : _a.classList.add("transitioning");
|
|
} else {
|
|
(_b = selfRef === null || selfRef === void 0 ? void 0 : selfRef.value) === null || _b === void 0 ? void 0 : _b.classList.remove("transitioning");
|
|
}
|
|
});
|
|
return {
|
|
selfRef,
|
|
mergedTheme: mergedThemeRef,
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
transitioning: wipTransitionCountRef
|
|
};
|
|
},
|
|
render() {
|
|
const {
|
|
$slots,
|
|
scrollable,
|
|
mergedClsPrefix,
|
|
mergedTheme,
|
|
placement
|
|
} = this;
|
|
return h("div", {
|
|
ref: "selfRef",
|
|
class: [`${mergedClsPrefix}-notification-container`, scrollable && `${mergedClsPrefix}-notification-container--scrollable`, `${mergedClsPrefix}-notification-container--${placement}`]
|
|
}, scrollable ? h(Scrollbar, {
|
|
theme: mergedTheme.peers.Scrollbar,
|
|
themeOverrides: mergedTheme.peerOverrides.Scrollbar,
|
|
contentStyle: {
|
|
overflow: "hidden"
|
|
}
|
|
}, $slots) : $slots);
|
|
}
|
|
});
|
|
const iconRenderMap = {
|
|
info: () => h(InfoIcon, null),
|
|
success: () => h(SuccessIcon, null),
|
|
warning: () => h(WarningIcon, null),
|
|
error: () => h(ErrorIcon, null),
|
|
default: () => null
|
|
};
|
|
const notificationProps = {
|
|
closable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
type: {
|
|
type: String,
|
|
default: "default"
|
|
},
|
|
avatar: Function,
|
|
title: [String, Function],
|
|
description: [String, Function],
|
|
content: [String, Function],
|
|
meta: [String, Function],
|
|
action: [String, Function],
|
|
onClose: {
|
|
type: Function,
|
|
required: true
|
|
},
|
|
keepAliveOnHover: Boolean,
|
|
onMouseenter: Function,
|
|
onMouseleave: Function
|
|
};
|
|
const notificationPropKeys = keysOf(notificationProps);
|
|
const Notification = /* @__PURE__ */ defineComponent({
|
|
name: "Notification",
|
|
props: notificationProps,
|
|
setup(props) {
|
|
const {
|
|
mergedClsPrefixRef,
|
|
mergedThemeRef,
|
|
props: providerProps
|
|
} = inject(notificationProviderInjectionKey);
|
|
const {
|
|
inlineThemeDisabled,
|
|
mergedRtlRef
|
|
} = useConfig();
|
|
const rtlEnabledRef = useRtl("Notification", mergedRtlRef, mergedClsPrefixRef);
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
type
|
|
} = props;
|
|
const {
|
|
self: {
|
|
color,
|
|
textColor,
|
|
closeIconColor,
|
|
closeIconColorHover,
|
|
closeIconColorPressed,
|
|
headerTextColor,
|
|
descriptionTextColor,
|
|
actionTextColor,
|
|
borderRadius,
|
|
headerFontWeight,
|
|
boxShadow,
|
|
lineHeight: lineHeight2,
|
|
fontSize: fontSize2,
|
|
closeMargin,
|
|
closeSize,
|
|
width,
|
|
padding,
|
|
closeIconSize,
|
|
closeBorderRadius,
|
|
closeColorHover,
|
|
closeColorPressed,
|
|
titleFontSize,
|
|
metaFontSize,
|
|
descriptionFontSize,
|
|
[createKey("iconColor", type)]: iconColor
|
|
},
|
|
common: {
|
|
cubicBezierEaseOut: cubicBezierEaseOut2,
|
|
cubicBezierEaseIn: cubicBezierEaseIn2,
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2
|
|
}
|
|
} = mergedThemeRef.value;
|
|
const {
|
|
left,
|
|
right,
|
|
top,
|
|
bottom
|
|
} = getMargin(padding);
|
|
return {
|
|
"--n-color": color,
|
|
"--n-font-size": fontSize2,
|
|
"--n-text-color": textColor,
|
|
"--n-description-text-color": descriptionTextColor,
|
|
"--n-action-text-color": actionTextColor,
|
|
"--n-title-text-color": headerTextColor,
|
|
"--n-title-font-weight": headerFontWeight,
|
|
"--n-bezier": cubicBezierEaseInOut2,
|
|
"--n-bezier-ease-out": cubicBezierEaseOut2,
|
|
"--n-bezier-ease-in": cubicBezierEaseIn2,
|
|
"--n-border-radius": borderRadius,
|
|
"--n-box-shadow": boxShadow,
|
|
"--n-close-border-radius": closeBorderRadius,
|
|
"--n-close-color-hover": closeColorHover,
|
|
"--n-close-color-pressed": closeColorPressed,
|
|
"--n-close-icon-color": closeIconColor,
|
|
"--n-close-icon-color-hover": closeIconColorHover,
|
|
"--n-close-icon-color-pressed": closeIconColorPressed,
|
|
"--n-line-height": lineHeight2,
|
|
"--n-icon-color": iconColor,
|
|
"--n-close-margin": closeMargin,
|
|
"--n-close-size": closeSize,
|
|
"--n-close-icon-size": closeIconSize,
|
|
"--n-width": width,
|
|
"--n-padding-left": left,
|
|
"--n-padding-right": right,
|
|
"--n-padding-top": top,
|
|
"--n-padding-bottom": bottom,
|
|
"--n-title-font-size": titleFontSize,
|
|
"--n-meta-font-size": metaFontSize,
|
|
"--n-description-font-size": descriptionFontSize
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("notification", computed(() => props.type[0]), cssVarsRef, providerProps) : void 0;
|
|
return {
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
showAvatar: computed(() => {
|
|
return props.avatar || props.type !== "default";
|
|
}),
|
|
handleCloseClick() {
|
|
props.onClose();
|
|
},
|
|
rtlEnabled: rtlEnabledRef,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
};
|
|
},
|
|
render() {
|
|
var _a;
|
|
const {
|
|
mergedClsPrefix
|
|
} = this;
|
|
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
return h("div", {
|
|
class: [`${mergedClsPrefix}-notification-wrapper`, this.themeClass],
|
|
onMouseenter: this.onMouseenter,
|
|
onMouseleave: this.onMouseleave,
|
|
style: this.cssVars
|
|
}, h("div", {
|
|
class: [`${mergedClsPrefix}-notification`, this.rtlEnabled && `${mergedClsPrefix}-notification--rtl`, this.themeClass, {
|
|
[`${mergedClsPrefix}-notification--closable`]: this.closable,
|
|
[`${mergedClsPrefix}-notification--show-avatar`]: this.showAvatar
|
|
}],
|
|
style: this.cssVars
|
|
}, this.showAvatar ? h("div", {
|
|
class: `${mergedClsPrefix}-notification__avatar`
|
|
}, this.avatar ? render(this.avatar) : this.type !== "default" ? h(NBaseIcon, {
|
|
clsPrefix: mergedClsPrefix
|
|
}, {
|
|
default: () => iconRenderMap[this.type]()
|
|
}) : null) : null, this.closable ? h(NBaseClose, {
|
|
clsPrefix: mergedClsPrefix,
|
|
class: `${mergedClsPrefix}-notification__close`,
|
|
onClick: this.handleCloseClick
|
|
}) : null, h("div", {
|
|
ref: "bodyRef",
|
|
class: `${mergedClsPrefix}-notification-main`
|
|
}, this.title ? h("div", {
|
|
class: `${mergedClsPrefix}-notification-main__header`
|
|
}, render(this.title)) : null, this.description ? h("div", {
|
|
class: `${mergedClsPrefix}-notification-main__description`
|
|
}, render(this.description)) : null, this.content ? h("pre", {
|
|
class: `${mergedClsPrefix}-notification-main__content`
|
|
}, render(this.content)) : null, this.meta || this.action ? h("div", {
|
|
class: `${mergedClsPrefix}-notification-main-footer`
|
|
}, this.meta ? h("div", {
|
|
class: `${mergedClsPrefix}-notification-main-footer__meta`
|
|
}, render(this.meta)) : null, this.action ? h("div", {
|
|
class: `${mergedClsPrefix}-notification-main-footer__action`
|
|
}, render(this.action)) : null) : null)));
|
|
}
|
|
});
|
|
const notificationEnvOptions = Object.assign(Object.assign({}, notificationProps), {
|
|
duration: Number,
|
|
onClose: Function,
|
|
onLeave: Function,
|
|
onAfterEnter: Function,
|
|
onAfterLeave: Function,
|
|
/** @deprecated */
|
|
onHide: Function,
|
|
/** @deprecated */
|
|
onAfterShow: Function,
|
|
/** @deprecated */
|
|
onAfterHide: Function
|
|
});
|
|
const NotificationEnvironment = /* @__PURE__ */ defineComponent({
|
|
name: "NotificationEnvironment",
|
|
props: Object.assign(Object.assign({}, notificationEnvOptions), {
|
|
// private
|
|
internalKey: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
onInternalAfterLeave: {
|
|
type: Function,
|
|
required: true
|
|
}
|
|
}),
|
|
setup(props) {
|
|
const {
|
|
wipTransitionCountRef
|
|
} = inject(notificationProviderInjectionKey);
|
|
const showRef = ref(true);
|
|
let timerId = null;
|
|
function hide() {
|
|
showRef.value = false;
|
|
if (timerId) {
|
|
window.clearTimeout(timerId);
|
|
}
|
|
}
|
|
function handleBeforeEnter(el) {
|
|
wipTransitionCountRef.value++;
|
|
void nextTick(() => {
|
|
el.style.height = `${el.offsetHeight}px`;
|
|
el.style.maxHeight = "0";
|
|
el.style.transition = "none";
|
|
void el.offsetHeight;
|
|
el.style.transition = "";
|
|
el.style.maxHeight = el.style.height;
|
|
});
|
|
}
|
|
function handleAfterEnter(el) {
|
|
wipTransitionCountRef.value--;
|
|
el.style.height = "";
|
|
el.style.maxHeight = "";
|
|
const {
|
|
onAfterEnter,
|
|
onAfterShow
|
|
} = props;
|
|
if (onAfterEnter) onAfterEnter();
|
|
if (onAfterShow) onAfterShow();
|
|
}
|
|
function handleBeforeLeave(el) {
|
|
wipTransitionCountRef.value++;
|
|
el.style.maxHeight = `${el.offsetHeight}px`;
|
|
el.style.height = `${el.offsetHeight}px`;
|
|
void el.offsetHeight;
|
|
}
|
|
function handleLeave(el) {
|
|
const {
|
|
onHide
|
|
} = props;
|
|
if (onHide) onHide();
|
|
el.style.maxHeight = "0";
|
|
void el.offsetHeight;
|
|
}
|
|
function handleAfterLeave() {
|
|
wipTransitionCountRef.value--;
|
|
const {
|
|
onAfterLeave,
|
|
onInternalAfterLeave,
|
|
onAfterHide,
|
|
internalKey
|
|
} = props;
|
|
if (onAfterLeave) onAfterLeave();
|
|
onInternalAfterLeave(internalKey);
|
|
if (onAfterHide) onAfterHide();
|
|
}
|
|
function setHideTimeout() {
|
|
const {
|
|
duration: duration2
|
|
} = props;
|
|
if (duration2) {
|
|
timerId = window.setTimeout(hide, duration2);
|
|
}
|
|
}
|
|
function handleMouseenter(e) {
|
|
if (e.currentTarget !== e.target) return;
|
|
if (timerId !== null) {
|
|
window.clearTimeout(timerId);
|
|
timerId = null;
|
|
}
|
|
}
|
|
function handleMouseleave(e) {
|
|
if (e.currentTarget !== e.target) return;
|
|
setHideTimeout();
|
|
}
|
|
function handleClose() {
|
|
const {
|
|
onClose
|
|
} = props;
|
|
if (onClose) {
|
|
void Promise.resolve(onClose()).then((feedback) => {
|
|
if (feedback === false) return;
|
|
hide();
|
|
});
|
|
} else {
|
|
hide();
|
|
}
|
|
}
|
|
onMounted(() => {
|
|
if (props.duration) {
|
|
timerId = window.setTimeout(hide, props.duration);
|
|
}
|
|
});
|
|
return {
|
|
show: showRef,
|
|
hide,
|
|
handleClose,
|
|
handleAfterLeave,
|
|
handleLeave,
|
|
handleBeforeLeave,
|
|
handleAfterEnter,
|
|
handleBeforeEnter,
|
|
handleMouseenter,
|
|
handleMouseleave
|
|
};
|
|
},
|
|
render() {
|
|
return h(Transition, {
|
|
name: "notification-transition",
|
|
appear: true,
|
|
// convert to any since Element is not compatible with HTMLElement
|
|
onBeforeEnter: this.handleBeforeEnter,
|
|
onAfterEnter: this.handleAfterEnter,
|
|
onBeforeLeave: this.handleBeforeLeave,
|
|
onLeave: this.handleLeave,
|
|
onAfterLeave: this.handleAfterLeave
|
|
}, {
|
|
default: () => {
|
|
return this.show ? h(Notification, Object.assign({}, keep(this.$props, notificationPropKeys), {
|
|
onClose: this.handleClose,
|
|
onMouseenter: this.duration && this.keepAliveOnHover ? this.handleMouseenter : void 0,
|
|
onMouseleave: this.duration && this.keepAliveOnHover ? this.handleMouseleave : void 0
|
|
})) : null;
|
|
}
|
|
});
|
|
}
|
|
});
|
|
const style$4 = c([cB("notification-container", `
|
|
z-index: 4000;
|
|
position: fixed;
|
|
overflow: visible;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: flex-end;
|
|
`, [c(">", [cB("scrollbar", `
|
|
width: initial;
|
|
overflow: visible;
|
|
height: -moz-fit-content !important;
|
|
height: fit-content !important;
|
|
max-height: 100vh !important;
|
|
`, [c(">", [cB("scrollbar-container", `
|
|
height: -moz-fit-content !important;
|
|
height: fit-content !important;
|
|
max-height: 100vh !important;
|
|
`, [cB("scrollbar-content", `
|
|
padding-top: 12px;
|
|
padding-bottom: 33px;
|
|
`)])])])]), cM("top, top-right, top-left", `
|
|
top: 12px;
|
|
`, [c("&.transitioning >", [cB("scrollbar", [c(">", [cB("scrollbar-container", `
|
|
min-height: 100vh !important;
|
|
`)])])])]), cM("bottom, bottom-right, bottom-left", `
|
|
bottom: 12px;
|
|
`, [c(">", [cB("scrollbar", [c(">", [cB("scrollbar-container", [cB("scrollbar-content", `
|
|
padding-bottom: 12px;
|
|
`)])])])]), cB("notification-wrapper", `
|
|
display: flex;
|
|
align-items: flex-end;
|
|
margin-bottom: 0;
|
|
margin-top: 12px;
|
|
`)]), cM("top, bottom", `
|
|
left: 50%;
|
|
transform: translateX(-50%);
|
|
`, [cB("notification-wrapper", [c("&.notification-transition-enter-from, &.notification-transition-leave-to", `
|
|
transform: scale(0.85);
|
|
`), c("&.notification-transition-leave-from, &.notification-transition-enter-to", `
|
|
transform: scale(1);
|
|
`)])]), cM("top", [cB("notification-wrapper", `
|
|
transform-origin: top center;
|
|
`)]), cM("bottom", [cB("notification-wrapper", `
|
|
transform-origin: bottom center;
|
|
`)]), cM("top-right, bottom-right", [cB("notification", `
|
|
margin-left: 28px;
|
|
margin-right: 16px;
|
|
`)]), cM("top-left, bottom-left", [cB("notification", `
|
|
margin-left: 16px;
|
|
margin-right: 28px;
|
|
`)]), cM("top-right", `
|
|
right: 0;
|
|
`, [placementTransformStyle("top-right")]), cM("top-left", `
|
|
left: 0;
|
|
`, [placementTransformStyle("top-left")]), cM("bottom-right", `
|
|
right: 0;
|
|
`, [placementTransformStyle("bottom-right")]), cM("bottom-left", `
|
|
left: 0;
|
|
`, [placementTransformStyle("bottom-left")]), cM("scrollable", [cM("top-right", `
|
|
top: 0;
|
|
`), cM("top-left", `
|
|
top: 0;
|
|
`), cM("bottom-right", `
|
|
bottom: 0;
|
|
`), cM("bottom-left", `
|
|
bottom: 0;
|
|
`)]), cB("notification-wrapper", `
|
|
margin-bottom: 12px;
|
|
`, [c("&.notification-transition-enter-from, &.notification-transition-leave-to", `
|
|
opacity: 0;
|
|
margin-top: 0 !important;
|
|
margin-bottom: 0 !important;
|
|
`), c("&.notification-transition-leave-from, &.notification-transition-enter-to", `
|
|
opacity: 1;
|
|
`), c("&.notification-transition-leave-active", `
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier),
|
|
opacity .3s var(--n-bezier),
|
|
transform .3s var(--n-bezier-ease-in),
|
|
max-height .3s var(--n-bezier),
|
|
margin-top .3s linear,
|
|
margin-bottom .3s linear,
|
|
box-shadow .3s var(--n-bezier);
|
|
`), c("&.notification-transition-enter-active", `
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier),
|
|
opacity .3s var(--n-bezier),
|
|
transform .3s var(--n-bezier-ease-out),
|
|
max-height .3s var(--n-bezier),
|
|
margin-top .3s linear,
|
|
margin-bottom .3s linear,
|
|
box-shadow .3s var(--n-bezier);
|
|
`)]), cB("notification", `
|
|
background-color: var(--n-color);
|
|
color: var(--n-text-color);
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier),
|
|
opacity .3s var(--n-bezier),
|
|
box-shadow .3s var(--n-bezier);
|
|
font-family: inherit;
|
|
font-size: var(--n-font-size);
|
|
font-weight: 400;
|
|
position: relative;
|
|
display: flex;
|
|
overflow: hidden;
|
|
flex-shrink: 0;
|
|
padding-left: var(--n-padding-left);
|
|
padding-right: var(--n-padding-right);
|
|
width: var(--n-width);
|
|
max-width: calc(100vw - 16px - 16px);
|
|
border-radius: var(--n-border-radius);
|
|
box-shadow: var(--n-box-shadow);
|
|
box-sizing: border-box;
|
|
opacity: 1;
|
|
`, [cE("avatar", [cB("icon", `
|
|
color: var(--n-icon-color);
|
|
`), cB("base-icon", `
|
|
color: var(--n-icon-color);
|
|
`)]), cM("show-avatar", [cB("notification-main", `
|
|
margin-left: 40px;
|
|
width: calc(100% - 40px);
|
|
`)]), cM("closable", [cB("notification-main", [c("> *:first-child", `
|
|
padding-right: 20px;
|
|
`)]), cE("close", `
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
margin: var(--n-close-margin);
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier);
|
|
`)]), cE("avatar", `
|
|
position: absolute;
|
|
top: var(--n-padding-top);
|
|
left: var(--n-padding-left);
|
|
width: 28px;
|
|
height: 28px;
|
|
font-size: 28px;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
`, [cB("icon", "transition: color .3s var(--n-bezier);")]), cB("notification-main", `
|
|
padding-top: var(--n-padding-top);
|
|
padding-bottom: var(--n-padding-bottom);
|
|
box-sizing: border-box;
|
|
display: flex;
|
|
flex-direction: column;
|
|
margin-left: 8px;
|
|
width: calc(100% - 8px);
|
|
`, [cB("notification-main-footer", `
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
margin-top: 12px;
|
|
`, [cE("meta", `
|
|
font-size: var(--n-meta-font-size);
|
|
transition: color .3s var(--n-bezier-ease-out);
|
|
color: var(--n-description-text-color);
|
|
`), cE("action", `
|
|
cursor: pointer;
|
|
transition: color .3s var(--n-bezier-ease-out);
|
|
color: var(--n-action-text-color);
|
|
`)]), cE("header", `
|
|
font-weight: var(--n-title-font-weight);
|
|
font-size: var(--n-title-font-size);
|
|
transition: color .3s var(--n-bezier-ease-out);
|
|
color: var(--n-title-text-color);
|
|
`), cE("description", `
|
|
margin-top: 8px;
|
|
font-size: var(--n-description-font-size);
|
|
white-space: pre-wrap;
|
|
word-wrap: break-word;
|
|
transition: color .3s var(--n-bezier-ease-out);
|
|
color: var(--n-description-text-color);
|
|
`), cE("content", `
|
|
line-height: var(--n-line-height);
|
|
margin: 12px 0 0 0;
|
|
font-family: inherit;
|
|
white-space: pre-wrap;
|
|
word-wrap: break-word;
|
|
transition: color .3s var(--n-bezier-ease-out);
|
|
color: var(--n-text-color);
|
|
`, [c("&:first-child", "margin: 0;")])])])])]);
|
|
function placementTransformStyle(placement) {
|
|
const direction = placement.split("-")[1];
|
|
const transformXEnter = direction === "left" ? "calc(-100%)" : "calc(100%)";
|
|
const transformXLeave = "0";
|
|
return cB("notification-wrapper", [c("&.notification-transition-enter-from, &.notification-transition-leave-to", `
|
|
transform: translate(${transformXEnter}, 0);
|
|
`), c("&.notification-transition-leave-from, &.notification-transition-enter-to", `
|
|
transform: translate(${transformXLeave}, 0);
|
|
`)]);
|
|
}
|
|
const notificationApiInjectionKey = createInjectionKey("n-notification-api");
|
|
const notificationProviderProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
containerClass: String,
|
|
containerStyle: [String, Object],
|
|
to: [String, Object],
|
|
scrollable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
max: Number,
|
|
placement: {
|
|
type: String,
|
|
default: "top-right"
|
|
},
|
|
keepAliveOnHover: Boolean
|
|
});
|
|
const __unplugin_components_7 = /* @__PURE__ */ defineComponent({
|
|
name: "NotificationProvider",
|
|
props: notificationProviderProps,
|
|
setup(props) {
|
|
const {
|
|
mergedClsPrefixRef
|
|
} = useConfig(props);
|
|
const notificationListRef = ref([]);
|
|
const notificationRefs = {};
|
|
const leavingKeySet = /* @__PURE__ */ new Set();
|
|
function create(options) {
|
|
const key = createId();
|
|
const destroy = () => {
|
|
leavingKeySet.add(key);
|
|
if (notificationRefs[key]) {
|
|
notificationRefs[key].hide();
|
|
}
|
|
};
|
|
const notificationReactive = reactive(Object.assign(Object.assign({}, options), {
|
|
key,
|
|
destroy,
|
|
hide: destroy,
|
|
deactivate: destroy
|
|
}));
|
|
const {
|
|
max
|
|
} = props;
|
|
if (max && notificationListRef.value.length - leavingKeySet.size >= max) {
|
|
let someoneMountedRemoved = false;
|
|
let index = 0;
|
|
for (const notification of notificationListRef.value) {
|
|
if (!leavingKeySet.has(notification.key)) {
|
|
if (notificationRefs[notification.key]) {
|
|
notification.destroy();
|
|
someoneMountedRemoved = true;
|
|
}
|
|
break;
|
|
}
|
|
index++;
|
|
}
|
|
if (!someoneMountedRemoved) {
|
|
notificationListRef.value.splice(index, 1);
|
|
}
|
|
}
|
|
notificationListRef.value.push(notificationReactive);
|
|
return notificationReactive;
|
|
}
|
|
const apis = ["info", "success", "warning", "error"].map((type) => {
|
|
return (options) => create(Object.assign(Object.assign({}, options), {
|
|
type
|
|
}));
|
|
});
|
|
function handleAfterLeave(key) {
|
|
leavingKeySet.delete(key);
|
|
notificationListRef.value.splice(notificationListRef.value.findIndex((notification) => notification.key === key), 1);
|
|
}
|
|
const themeRef = useTheme("Notification", "-notification", style$4, notificationLight, props, mergedClsPrefixRef);
|
|
const api = {
|
|
create,
|
|
info: apis[0],
|
|
success: apis[1],
|
|
warning: apis[2],
|
|
error: apis[3],
|
|
open,
|
|
destroyAll
|
|
};
|
|
const wipTransitionCountRef = ref(0);
|
|
provide(notificationApiInjectionKey, api);
|
|
provide(notificationProviderInjectionKey, {
|
|
props,
|
|
mergedClsPrefixRef,
|
|
mergedThemeRef: themeRef,
|
|
wipTransitionCountRef
|
|
});
|
|
function open(options) {
|
|
return create(options);
|
|
}
|
|
function destroyAll() {
|
|
Object.values(notificationListRef.value).forEach((notification) => {
|
|
notification.hide();
|
|
});
|
|
}
|
|
return Object.assign({
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
notificationList: notificationListRef,
|
|
notificationRefs,
|
|
handleAfterLeave
|
|
}, api);
|
|
},
|
|
render() {
|
|
var _a, _b, _c;
|
|
const {
|
|
placement
|
|
} = this;
|
|
return h(Fragment, null, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a), this.notificationList.length ? h(Teleport, {
|
|
to: (_c = this.to) !== null && _c !== void 0 ? _c : "body"
|
|
}, h(NotificationContainer, {
|
|
class: this.containerClass,
|
|
style: this.containerStyle,
|
|
scrollable: this.scrollable && placement !== "top" && placement !== "bottom",
|
|
placement
|
|
}, {
|
|
default: () => {
|
|
return this.notificationList.map((notification) => {
|
|
return h(NotificationEnvironment, Object.assign({
|
|
ref: (inst) => {
|
|
const refKey = notification.key;
|
|
if (inst === null) {
|
|
delete this.notificationRefs[refKey];
|
|
} else {
|
|
this.notificationRefs[refKey] = inst;
|
|
}
|
|
}
|
|
}, omit(notification, ["destroy", "hide", "deactivate"]), {
|
|
internalKey: notification.key,
|
|
onInternalAfterLeave: this.handleAfterLeave,
|
|
keepAliveOnHover: notification.keepAliveOnHover === void 0 ? this.keepAliveOnHover : notification.keepAliveOnHover
|
|
}));
|
|
});
|
|
}
|
|
})) : null);
|
|
}
|
|
});
|
|
function self$1(vars) {
|
|
const {
|
|
baseColor,
|
|
textColor2,
|
|
bodyColor,
|
|
cardColor,
|
|
dividerColor,
|
|
actionColor,
|
|
scrollbarColor,
|
|
scrollbarColorHover,
|
|
invertedColor
|
|
} = vars;
|
|
return {
|
|
textColor: textColor2,
|
|
textColorInverted: "#FFF",
|
|
color: bodyColor,
|
|
colorEmbedded: actionColor,
|
|
headerColor: cardColor,
|
|
headerColorInverted: invertedColor,
|
|
footerColor: actionColor,
|
|
footerColorInverted: invertedColor,
|
|
headerBorderColor: dividerColor,
|
|
headerBorderColorInverted: invertedColor,
|
|
footerBorderColor: dividerColor,
|
|
footerBorderColorInverted: invertedColor,
|
|
siderBorderColor: dividerColor,
|
|
siderBorderColorInverted: invertedColor,
|
|
siderColor: cardColor,
|
|
siderColorInverted: invertedColor,
|
|
siderToggleButtonBorder: `1px solid ${dividerColor}`,
|
|
siderToggleButtonColor: baseColor,
|
|
siderToggleButtonIconColor: textColor2,
|
|
siderToggleButtonIconColorInverted: textColor2,
|
|
siderToggleBarColor: composite(bodyColor, scrollbarColor),
|
|
siderToggleBarColorHover: composite(bodyColor, scrollbarColorHover),
|
|
// hack for inverted background
|
|
__invertScrollbar: "true"
|
|
};
|
|
}
|
|
const layoutLight = createTheme({
|
|
name: "Layout",
|
|
common: derived,
|
|
peers: {
|
|
Scrollbar: scrollbarLight
|
|
},
|
|
self: self$1
|
|
});
|
|
const watermarkLight = createTheme({
|
|
name: "Watermark",
|
|
common: derived,
|
|
self(vars) {
|
|
const {
|
|
fontFamily: fontFamily2
|
|
} = vars;
|
|
return {
|
|
fontFamily: fontFamily2
|
|
};
|
|
}
|
|
});
|
|
const __unplugin_components_0 = /* @__PURE__ */ defineComponent({
|
|
name: "GlobalStyle",
|
|
setup() {
|
|
if (typeof document === "undefined") return;
|
|
const NConfigProvider = inject(configProviderInjectionKey, null);
|
|
const {
|
|
body
|
|
} = document;
|
|
const {
|
|
style: style2
|
|
} = body;
|
|
let styleApplied = false;
|
|
let firstApply = true;
|
|
onBeforeMount(() => {
|
|
watchEffect(() => {
|
|
var _a, _b;
|
|
const {
|
|
textColor2,
|
|
fontSize: fontSize2,
|
|
fontFamily: fontFamily2,
|
|
bodyColor,
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2,
|
|
lineHeight: lineHeight2
|
|
} = NConfigProvider ? merge$1({}, ((_a = NConfigProvider.mergedThemeRef.value) === null || _a === void 0 ? void 0 : _a.common) || derived, (_b = NConfigProvider.mergedThemeOverridesRef.value) === null || _b === void 0 ? void 0 : _b.common) : derived;
|
|
if (styleApplied || !body.hasAttribute("n-styled")) {
|
|
style2.setProperty("-webkit-text-size-adjust", "100%");
|
|
style2.setProperty("-webkit-tap-highlight-color", "transparent");
|
|
style2.padding = "0";
|
|
style2.margin = "0";
|
|
style2.backgroundColor = bodyColor;
|
|
style2.color = textColor2;
|
|
style2.fontSize = fontSize2;
|
|
style2.fontFamily = fontFamily2;
|
|
style2.lineHeight = lineHeight2;
|
|
const transition = `color .3s ${cubicBezierEaseInOut2}, background-color .3s ${cubicBezierEaseInOut2}`;
|
|
if (firstApply) {
|
|
setTimeout(() => {
|
|
style2.transition = transition;
|
|
}, 0);
|
|
} else {
|
|
style2.transition = transition;
|
|
}
|
|
body.setAttribute("n-styled", "");
|
|
styleApplied = true;
|
|
firstApply = false;
|
|
}
|
|
});
|
|
});
|
|
onUnmounted(() => {
|
|
if (styleApplied) {
|
|
body.removeAttribute("n-styled");
|
|
}
|
|
});
|
|
},
|
|
render() {
|
|
return null;
|
|
}
|
|
});
|
|
const layoutSiderInjectionKey = createInjectionKey("n-layout-sider");
|
|
const positionProp = {
|
|
type: String,
|
|
default: "static"
|
|
};
|
|
const style$3 = cB("layout", `
|
|
color: var(--n-text-color);
|
|
background-color: var(--n-color);
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
z-index: auto;
|
|
flex: auto;
|
|
overflow: hidden;
|
|
transition:
|
|
box-shadow .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier),
|
|
color .3s var(--n-bezier);
|
|
`, [cB("layout-scroll-container", `
|
|
overflow-x: hidden;
|
|
box-sizing: border-box;
|
|
height: 100%;
|
|
`), cM("absolute-positioned", `
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
`)]);
|
|
const layoutProps = {
|
|
embedded: Boolean,
|
|
position: positionProp,
|
|
nativeScrollbar: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
scrollbarProps: Object,
|
|
onScroll: Function,
|
|
contentClass: String,
|
|
contentStyle: {
|
|
type: [String, Object],
|
|
default: ""
|
|
},
|
|
hasSider: Boolean,
|
|
siderPlacement: {
|
|
type: String,
|
|
default: "left"
|
|
}
|
|
};
|
|
const layoutInjectionKey = createInjectionKey("n-layout");
|
|
function createLayoutComponent(isContent) {
|
|
return /* @__PURE__ */ defineComponent({
|
|
name: isContent ? "LayoutContent" : "Layout",
|
|
props: Object.assign(Object.assign({}, useTheme.props), layoutProps),
|
|
setup(props) {
|
|
const scrollableElRef = ref(null);
|
|
const scrollbarInstRef = ref(null);
|
|
const {
|
|
mergedClsPrefixRef,
|
|
inlineThemeDisabled
|
|
} = useConfig(props);
|
|
const themeRef = useTheme("Layout", "-layout", style$3, layoutLight, props, mergedClsPrefixRef);
|
|
function scrollTo(options, y) {
|
|
if (props.nativeScrollbar) {
|
|
const {
|
|
value: scrollableEl
|
|
} = scrollableElRef;
|
|
if (scrollableEl) {
|
|
if (y === void 0) {
|
|
scrollableEl.scrollTo(options);
|
|
} else {
|
|
scrollableEl.scrollTo(options, y);
|
|
}
|
|
}
|
|
} else {
|
|
const {
|
|
value: scrollbarInst
|
|
} = scrollbarInstRef;
|
|
if (scrollbarInst) {
|
|
scrollbarInst.scrollTo(options, y);
|
|
}
|
|
}
|
|
}
|
|
provide(layoutInjectionKey, props);
|
|
let scrollX = 0;
|
|
let scrollY = 0;
|
|
const handleNativeElScroll = (e) => {
|
|
var _a;
|
|
const target = e.target;
|
|
scrollX = target.scrollLeft;
|
|
scrollY = target.scrollTop;
|
|
(_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
};
|
|
useReactivated(() => {
|
|
if (props.nativeScrollbar) {
|
|
const el = scrollableElRef.value;
|
|
if (el) {
|
|
el.scrollTop = scrollY;
|
|
el.scrollLeft = scrollX;
|
|
}
|
|
}
|
|
});
|
|
const hasSiderStyle = {
|
|
display: "flex",
|
|
flexWrap: "nowrap",
|
|
width: "100%",
|
|
flexDirection: "row"
|
|
};
|
|
const exposedMethods = {
|
|
scrollTo
|
|
};
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
common: {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2
|
|
},
|
|
self: self2
|
|
} = themeRef.value;
|
|
return {
|
|
"--n-bezier": cubicBezierEaseInOut2,
|
|
"--n-color": props.embedded ? self2.colorEmbedded : self2.color,
|
|
"--n-text-color": self2.textColor
|
|
};
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("layout", computed(() => {
|
|
return props.embedded ? "e" : "";
|
|
}), cssVarsRef, props) : void 0;
|
|
return Object.assign({
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
scrollableElRef,
|
|
scrollbarInstRef,
|
|
hasSiderStyle,
|
|
mergedTheme: themeRef,
|
|
handleNativeElScroll,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
}, exposedMethods);
|
|
},
|
|
render() {
|
|
var _a;
|
|
const {
|
|
mergedClsPrefix,
|
|
hasSider
|
|
} = this;
|
|
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
const hasSiderStyle = hasSider ? this.hasSiderStyle : void 0;
|
|
const layoutClass = [this.themeClass, isContent && `${mergedClsPrefix}-layout-content`, `${mergedClsPrefix}-layout`, `${mergedClsPrefix}-layout--${this.position}-positioned`];
|
|
return h("div", {
|
|
class: layoutClass,
|
|
style: this.cssVars
|
|
}, this.nativeScrollbar ? h("div", {
|
|
ref: "scrollableElRef",
|
|
class: [`${mergedClsPrefix}-layout-scroll-container`, this.contentClass],
|
|
style: [this.contentStyle, hasSiderStyle],
|
|
onScroll: this.handleNativeElScroll
|
|
}, this.$slots) : h(Scrollbar, Object.assign({}, this.scrollbarProps, {
|
|
onScroll: this.onScroll,
|
|
ref: "scrollbarInstRef",
|
|
theme: this.mergedTheme.peers.Scrollbar,
|
|
themeOverrides: this.mergedTheme.peerOverrides.Scrollbar,
|
|
contentClass: this.contentClass,
|
|
contentStyle: [this.contentStyle, hasSiderStyle]
|
|
}), this.$slots));
|
|
}
|
|
});
|
|
}
|
|
const NLayout = createLayoutComponent(false);
|
|
const NLayoutContent = createLayoutComponent(true);
|
|
const style$2 = cB("layout-footer", `
|
|
transition:
|
|
box-shadow .3s var(--n-bezier),
|
|
color .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier),
|
|
border-color .3s var(--n-bezier);
|
|
color: var(--n-text-color);
|
|
background-color: var(--n-color);
|
|
box-sizing: border-box;
|
|
`, [cM("absolute-positioned", `
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
`), cM("bordered", `
|
|
border-top: solid 1px var(--n-border-color);
|
|
`)]);
|
|
const layoutFooterProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
inverted: Boolean,
|
|
position: positionProp,
|
|
bordered: Boolean
|
|
});
|
|
const __unplugin_components_5 = /* @__PURE__ */ defineComponent({
|
|
name: "LayoutFooter",
|
|
props: layoutFooterProps,
|
|
setup(props) {
|
|
const {
|
|
mergedClsPrefixRef,
|
|
inlineThemeDisabled
|
|
} = useConfig(props);
|
|
const themeRef = useTheme("Layout", "-layout-footer", style$2, layoutLight, props, mergedClsPrefixRef);
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
common: {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2
|
|
},
|
|
self: self2
|
|
} = themeRef.value;
|
|
const vars = {
|
|
"--n-bezier": cubicBezierEaseInOut2
|
|
};
|
|
if (props.inverted) {
|
|
vars["--n-color"] = self2.footerColorInverted;
|
|
vars["--n-text-color"] = self2.textColorInverted;
|
|
vars["--n-border-color"] = self2.footerBorderColorInverted;
|
|
} else {
|
|
vars["--n-color"] = self2.footerColor;
|
|
vars["--n-text-color"] = self2.textColor;
|
|
vars["--n-border-color"] = self2.footerBorderColor;
|
|
}
|
|
return vars;
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("layout-footer", computed(() => props.inverted ? "a" : "b"), cssVarsRef, props) : void 0;
|
|
return {
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
cssVars: inlineThemeDisabled ? void 0 : cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
};
|
|
},
|
|
render() {
|
|
var _a;
|
|
const {
|
|
mergedClsPrefix
|
|
} = this;
|
|
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
return h("div", {
|
|
class: [`${mergedClsPrefix}-layout-footer`, this.themeClass, this.position && `${mergedClsPrefix}-layout-footer--${this.position}-positioned`, this.bordered && `${mergedClsPrefix}-layout-footer--bordered`],
|
|
style: this.cssVars
|
|
}, this.$slots);
|
|
}
|
|
});
|
|
const style$1 = cB("layout-sider", `
|
|
flex-shrink: 0;
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
z-index: 1;
|
|
color: var(--n-text-color);
|
|
transition:
|
|
color .3s var(--n-bezier),
|
|
border-color .3s var(--n-bezier),
|
|
min-width .3s var(--n-bezier),
|
|
max-width .3s var(--n-bezier),
|
|
transform .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier);
|
|
background-color: var(--n-color);
|
|
display: flex;
|
|
justify-content: flex-end;
|
|
`, [cM("bordered", [cE("border", `
|
|
content: "";
|
|
position: absolute;
|
|
top: 0;
|
|
bottom: 0;
|
|
width: 1px;
|
|
background-color: var(--n-border-color);
|
|
transition: background-color .3s var(--n-bezier);
|
|
`)]), cE("left-placement", [cM("bordered", [cE("border", `
|
|
right: 0;
|
|
`)])]), cM("right-placement", `
|
|
justify-content: flex-start;
|
|
`, [cM("bordered", [cE("border", `
|
|
left: 0;
|
|
`)]), cM("collapsed", [cB("layout-toggle-button", [cB("base-icon", `
|
|
transform: rotate(180deg);
|
|
`)]), cB("layout-toggle-bar", [c("&:hover", [cE("top", {
|
|
transform: "rotate(-12deg) scale(1.15) translateY(-2px)"
|
|
}), cE("bottom", {
|
|
transform: "rotate(12deg) scale(1.15) translateY(2px)"
|
|
})])])]), cB("layout-toggle-button", `
|
|
left: 0;
|
|
transform: translateX(-50%) translateY(-50%);
|
|
`, [cB("base-icon", `
|
|
transform: rotate(0);
|
|
`)]), cB("layout-toggle-bar", `
|
|
left: -28px;
|
|
transform: rotate(180deg);
|
|
`, [c("&:hover", [cE("top", {
|
|
transform: "rotate(12deg) scale(1.15) translateY(-2px)"
|
|
}), cE("bottom", {
|
|
transform: "rotate(-12deg) scale(1.15) translateY(2px)"
|
|
})])])]), cM("collapsed", [cB("layout-toggle-bar", [c("&:hover", [cE("top", {
|
|
transform: "rotate(-12deg) scale(1.15) translateY(-2px)"
|
|
}), cE("bottom", {
|
|
transform: "rotate(12deg) scale(1.15) translateY(2px)"
|
|
})])]), cB("layout-toggle-button", [cB("base-icon", `
|
|
transform: rotate(0);
|
|
`)])]), cB("layout-toggle-button", `
|
|
transition:
|
|
color .3s var(--n-bezier),
|
|
right .3s var(--n-bezier),
|
|
left .3s var(--n-bezier),
|
|
border-color .3s var(--n-bezier),
|
|
background-color .3s var(--n-bezier);
|
|
cursor: pointer;
|
|
width: 24px;
|
|
height: 24px;
|
|
position: absolute;
|
|
top: 50%;
|
|
right: 0;
|
|
border-radius: 50%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
font-size: 18px;
|
|
color: var(--n-toggle-button-icon-color);
|
|
border: var(--n-toggle-button-border);
|
|
background-color: var(--n-toggle-button-color);
|
|
box-shadow: 0 2px 4px 0px rgba(0, 0, 0, .06);
|
|
transform: translateX(50%) translateY(-50%);
|
|
z-index: 1;
|
|
`, [cB("base-icon", `
|
|
transition: transform .3s var(--n-bezier);
|
|
transform: rotate(180deg);
|
|
`)]), cB("layout-toggle-bar", `
|
|
cursor: pointer;
|
|
height: 72px;
|
|
width: 32px;
|
|
position: absolute;
|
|
top: calc(50% - 36px);
|
|
right: -28px;
|
|
`, [cE("top, bottom", `
|
|
position: absolute;
|
|
width: 4px;
|
|
border-radius: 2px;
|
|
height: 38px;
|
|
left: 14px;
|
|
transition:
|
|
background-color .3s var(--n-bezier),
|
|
transform .3s var(--n-bezier);
|
|
`), cE("bottom", `
|
|
position: absolute;
|
|
top: 34px;
|
|
`), c("&:hover", [cE("top", {
|
|
transform: "rotate(12deg) scale(1.15) translateY(-2px)"
|
|
}), cE("bottom", {
|
|
transform: "rotate(-12deg) scale(1.15) translateY(2px)"
|
|
})]), cE("top, bottom", {
|
|
backgroundColor: "var(--n-toggle-bar-color)"
|
|
}), c("&:hover", [cE("top, bottom", {
|
|
backgroundColor: "var(--n-toggle-bar-color-hover)"
|
|
})])]), cE("border", `
|
|
position: absolute;
|
|
top: 0;
|
|
right: 0;
|
|
bottom: 0;
|
|
width: 1px;
|
|
transition: background-color .3s var(--n-bezier);
|
|
`), cB("layout-sider-scroll-container", `
|
|
flex-grow: 1;
|
|
flex-shrink: 0;
|
|
box-sizing: border-box;
|
|
height: 100%;
|
|
opacity: 0;
|
|
transition: opacity .3s var(--n-bezier);
|
|
max-width: 100%;
|
|
`), cM("show-content", [cB("layout-sider-scroll-container", {
|
|
opacity: 1
|
|
})]), cM("absolute-positioned", `
|
|
position: absolute;
|
|
left: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
`)]);
|
|
const ToggleBar = /* @__PURE__ */ defineComponent({
|
|
props: {
|
|
clsPrefix: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
onClick: Function
|
|
},
|
|
render() {
|
|
const {
|
|
clsPrefix
|
|
} = this;
|
|
return h("div", {
|
|
onClick: this.onClick,
|
|
class: `${clsPrefix}-layout-toggle-bar`
|
|
}, h("div", {
|
|
class: `${clsPrefix}-layout-toggle-bar__top`
|
|
}), h("div", {
|
|
class: `${clsPrefix}-layout-toggle-bar__bottom`
|
|
}));
|
|
}
|
|
});
|
|
const ToggleButton = /* @__PURE__ */ defineComponent({
|
|
name: "LayoutToggleButton",
|
|
props: {
|
|
clsPrefix: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
onClick: Function
|
|
},
|
|
render() {
|
|
const {
|
|
clsPrefix
|
|
} = this;
|
|
return h("div", {
|
|
class: `${clsPrefix}-layout-toggle-button`,
|
|
onClick: this.onClick
|
|
}, h(NBaseIcon, {
|
|
clsPrefix
|
|
}, {
|
|
default: () => h(ChevronRightIcon, null)
|
|
}));
|
|
}
|
|
});
|
|
const layoutSiderProps = {
|
|
position: positionProp,
|
|
bordered: Boolean,
|
|
collapsedWidth: {
|
|
type: Number,
|
|
default: 48
|
|
},
|
|
width: {
|
|
type: [Number, String],
|
|
default: 272
|
|
},
|
|
contentClass: String,
|
|
contentStyle: {
|
|
type: [String, Object],
|
|
default: ""
|
|
},
|
|
collapseMode: {
|
|
type: String,
|
|
default: "transform"
|
|
},
|
|
collapsed: {
|
|
type: Boolean,
|
|
default: void 0
|
|
},
|
|
defaultCollapsed: Boolean,
|
|
showCollapsedContent: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
showTrigger: {
|
|
type: [Boolean, String],
|
|
default: false
|
|
},
|
|
nativeScrollbar: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
inverted: Boolean,
|
|
scrollbarProps: Object,
|
|
triggerClass: String,
|
|
triggerStyle: [String, Object],
|
|
collapsedTriggerClass: String,
|
|
collapsedTriggerStyle: [String, Object],
|
|
"onUpdate:collapsed": [Function, Array],
|
|
onUpdateCollapsed: [Function, Array],
|
|
onAfterEnter: Function,
|
|
onAfterLeave: Function,
|
|
// deprecated
|
|
onExpand: [Function, Array],
|
|
onCollapse: [Function, Array],
|
|
onScroll: Function
|
|
};
|
|
const NLayoutSider = /* @__PURE__ */ defineComponent({
|
|
name: "LayoutSider",
|
|
props: Object.assign(Object.assign({}, useTheme.props), layoutSiderProps),
|
|
setup(props) {
|
|
const layoutProps2 = inject(layoutInjectionKey);
|
|
const scrollableElRef = ref(null);
|
|
const scrollbarInstRef = ref(null);
|
|
const uncontrolledCollapsedRef = ref(props.defaultCollapsed);
|
|
const mergedCollapsedRef = useMergedState(toRef(props, "collapsed"), uncontrolledCollapsedRef);
|
|
const styleMaxWidthRef = computed(() => {
|
|
return formatLength(mergedCollapsedRef.value ? props.collapsedWidth : props.width);
|
|
});
|
|
const scrollContainerStyleRef = computed(() => {
|
|
if (props.collapseMode !== "transform") return {};
|
|
return {
|
|
minWidth: formatLength(props.width)
|
|
};
|
|
});
|
|
const siderPlacementRef = computed(() => {
|
|
return layoutProps2 ? layoutProps2.siderPlacement : "left";
|
|
});
|
|
function scrollTo(options, y) {
|
|
if (props.nativeScrollbar) {
|
|
const {
|
|
value: scrollableEl
|
|
} = scrollableElRef;
|
|
if (scrollableEl) {
|
|
if (y === void 0) {
|
|
scrollableEl.scrollTo(options);
|
|
} else {
|
|
scrollableEl.scrollTo(options, y);
|
|
}
|
|
}
|
|
} else {
|
|
const {
|
|
value: scrollbarInst
|
|
} = scrollbarInstRef;
|
|
if (scrollbarInst) {
|
|
scrollbarInst.scrollTo(options, y);
|
|
}
|
|
}
|
|
}
|
|
function handleTriggerClick() {
|
|
const {
|
|
"onUpdate:collapsed": _onUpdateCollapsed,
|
|
onUpdateCollapsed,
|
|
// deprecated
|
|
onExpand,
|
|
onCollapse
|
|
} = props;
|
|
const {
|
|
value: collapsed
|
|
} = mergedCollapsedRef;
|
|
if (onUpdateCollapsed) {
|
|
call(onUpdateCollapsed, !collapsed);
|
|
}
|
|
if (_onUpdateCollapsed) {
|
|
call(_onUpdateCollapsed, !collapsed);
|
|
}
|
|
uncontrolledCollapsedRef.value = !collapsed;
|
|
if (collapsed) {
|
|
if (onExpand) call(onExpand);
|
|
} else {
|
|
if (onCollapse) call(onCollapse);
|
|
}
|
|
}
|
|
let scrollX = 0;
|
|
let scrollY = 0;
|
|
const handleNativeElScroll = (e) => {
|
|
var _a;
|
|
const target = e.target;
|
|
scrollX = target.scrollLeft;
|
|
scrollY = target.scrollTop;
|
|
(_a = props.onScroll) === null || _a === void 0 ? void 0 : _a.call(props, e);
|
|
};
|
|
useReactivated(() => {
|
|
if (props.nativeScrollbar) {
|
|
const el = scrollableElRef.value;
|
|
if (el) {
|
|
el.scrollTop = scrollY;
|
|
el.scrollLeft = scrollX;
|
|
}
|
|
}
|
|
});
|
|
provide(layoutSiderInjectionKey, {
|
|
collapsedRef: mergedCollapsedRef,
|
|
collapseModeRef: toRef(props, "collapseMode")
|
|
});
|
|
const {
|
|
mergedClsPrefixRef,
|
|
inlineThemeDisabled
|
|
} = useConfig(props);
|
|
const themeRef = useTheme("Layout", "-layout-sider", style$1, layoutLight, props, mergedClsPrefixRef);
|
|
function handleTransitionend(e) {
|
|
var _a, _b;
|
|
if (e.propertyName === "max-width") {
|
|
if (mergedCollapsedRef.value) {
|
|
(_a = props.onAfterLeave) === null || _a === void 0 ? void 0 : _a.call(props);
|
|
} else {
|
|
(_b = props.onAfterEnter) === null || _b === void 0 ? void 0 : _b.call(props);
|
|
}
|
|
}
|
|
}
|
|
const exposedMethods = {
|
|
scrollTo
|
|
};
|
|
const cssVarsRef = computed(() => {
|
|
const {
|
|
common: {
|
|
cubicBezierEaseInOut: cubicBezierEaseInOut2
|
|
},
|
|
self: self2
|
|
} = themeRef.value;
|
|
const {
|
|
siderToggleButtonColor,
|
|
siderToggleButtonBorder,
|
|
siderToggleBarColor,
|
|
siderToggleBarColorHover
|
|
} = self2;
|
|
const vars = {
|
|
"--n-bezier": cubicBezierEaseInOut2,
|
|
"--n-toggle-button-color": siderToggleButtonColor,
|
|
"--n-toggle-button-border": siderToggleButtonBorder,
|
|
"--n-toggle-bar-color": siderToggleBarColor,
|
|
"--n-toggle-bar-color-hover": siderToggleBarColorHover
|
|
};
|
|
if (props.inverted) {
|
|
vars["--n-color"] = self2.siderColorInverted;
|
|
vars["--n-text-color"] = self2.textColorInverted;
|
|
vars["--n-border-color"] = self2.siderBorderColorInverted;
|
|
vars["--n-toggle-button-icon-color"] = self2.siderToggleButtonIconColorInverted;
|
|
vars.__invertScrollbar = self2.__invertScrollbar;
|
|
} else {
|
|
vars["--n-color"] = self2.siderColor;
|
|
vars["--n-text-color"] = self2.textColor;
|
|
vars["--n-border-color"] = self2.siderBorderColor;
|
|
vars["--n-toggle-button-icon-color"] = self2.siderToggleButtonIconColor;
|
|
}
|
|
return vars;
|
|
});
|
|
const themeClassHandle = inlineThemeDisabled ? useThemeClass("layout-sider", computed(() => props.inverted ? "a" : "b"), cssVarsRef, props) : void 0;
|
|
return Object.assign({
|
|
scrollableElRef,
|
|
scrollbarInstRef,
|
|
mergedClsPrefix: mergedClsPrefixRef,
|
|
mergedTheme: themeRef,
|
|
styleMaxWidth: styleMaxWidthRef,
|
|
mergedCollapsed: mergedCollapsedRef,
|
|
scrollContainerStyle: scrollContainerStyleRef,
|
|
siderPlacement: siderPlacementRef,
|
|
handleNativeElScroll,
|
|
handleTransitionend,
|
|
handleTriggerClick,
|
|
inlineThemeDisabled,
|
|
cssVars: cssVarsRef,
|
|
themeClass: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.themeClass,
|
|
onRender: themeClassHandle === null || themeClassHandle === void 0 ? void 0 : themeClassHandle.onRender
|
|
}, exposedMethods);
|
|
},
|
|
render() {
|
|
var _a;
|
|
const {
|
|
mergedClsPrefix,
|
|
mergedCollapsed,
|
|
showTrigger
|
|
} = this;
|
|
(_a = this.onRender) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
return h("aside", {
|
|
class: [`${mergedClsPrefix}-layout-sider`, this.themeClass, `${mergedClsPrefix}-layout-sider--${this.position}-positioned`, `${mergedClsPrefix}-layout-sider--${this.siderPlacement}-placement`, this.bordered && `${mergedClsPrefix}-layout-sider--bordered`, mergedCollapsed && `${mergedClsPrefix}-layout-sider--collapsed`, (!mergedCollapsed || this.showCollapsedContent) && `${mergedClsPrefix}-layout-sider--show-content`],
|
|
onTransitionend: this.handleTransitionend,
|
|
style: [this.inlineThemeDisabled ? void 0 : this.cssVars, {
|
|
maxWidth: this.styleMaxWidth,
|
|
width: formatLength(this.width)
|
|
}]
|
|
}, !this.nativeScrollbar ? h(Scrollbar, Object.assign({}, this.scrollbarProps, {
|
|
onScroll: this.onScroll,
|
|
ref: "scrollbarInstRef",
|
|
style: this.scrollContainerStyle,
|
|
contentStyle: this.contentStyle,
|
|
contentClass: this.contentClass,
|
|
theme: this.mergedTheme.peers.Scrollbar,
|
|
themeOverrides: this.mergedTheme.peerOverrides.Scrollbar,
|
|
// here is a hack, since in light theme the scrollbar color is dark,
|
|
// we need to invert it in light color...
|
|
builtinThemeOverrides: this.inverted && this.cssVars.__invertScrollbar === "true" ? {
|
|
colorHover: "rgba(255, 255, 255, .4)",
|
|
color: "rgba(255, 255, 255, .3)"
|
|
} : void 0
|
|
}), this.$slots) : h("div", {
|
|
class: [`${mergedClsPrefix}-layout-sider-scroll-container`, this.contentClass],
|
|
onScroll: this.handleNativeElScroll,
|
|
style: [this.scrollContainerStyle, {
|
|
overflow: "auto"
|
|
}, this.contentStyle],
|
|
ref: "scrollableElRef"
|
|
}, this.$slots), showTrigger ? showTrigger === "bar" ? h(ToggleBar, {
|
|
clsPrefix: mergedClsPrefix,
|
|
class: mergedCollapsed ? this.collapsedTriggerClass : this.triggerClass,
|
|
style: mergedCollapsed ? this.collapsedTriggerStyle : this.triggerStyle,
|
|
onClick: this.handleTriggerClick
|
|
}) : h(ToggleButton, {
|
|
clsPrefix: mergedClsPrefix,
|
|
class: mergedCollapsed ? this.collapsedTriggerClass : this.triggerClass,
|
|
style: mergedCollapsed ? this.collapsedTriggerStyle : this.triggerStyle,
|
|
onClick: this.handleTriggerClick
|
|
}) : null, this.bordered ? h("div", {
|
|
class: `${mergedClsPrefix}-layout-sider__border`
|
|
}) : null);
|
|
}
|
|
});
|
|
const style = c([cB("watermark-container", `
|
|
position: relative;
|
|
`, [cNotM("selectable", `
|
|
user-select: none;
|
|
-webkit-user-select: none;
|
|
`), cM("global-rotate", `
|
|
overflow: hidden;
|
|
`), cM("fullscreen", `
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
pointer-events: none;
|
|
position: fixed;
|
|
`)]), cB("watermark", `
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
pointer-events: none;
|
|
background-repeat: repeat;
|
|
`, [cM("fullscreen", `
|
|
position: fixed;
|
|
`), cM("global-rotate", `
|
|
position: absolute;
|
|
height: max(284vh, 284vw);
|
|
width: max(284vh, 284vw);
|
|
`)])]);
|
|
function getRatio(context) {
|
|
if (!context) {
|
|
return 1;
|
|
}
|
|
const backingStore = context.backingStorePixelRatio || context.webkitBackingStorePixelRatio || context.mozBackingStorePixelRatio || context.msBackingStorePixelRatio || context.oBackingStorePixelRatio || context.backingStorePixelRatio || 1;
|
|
return (window.devicePixelRatio || 1) / backingStore;
|
|
}
|
|
const watermarkProps = Object.assign(Object.assign({}, useTheme.props), {
|
|
debug: Boolean,
|
|
cross: Boolean,
|
|
fullscreen: Boolean,
|
|
width: {
|
|
type: Number,
|
|
default: 32
|
|
},
|
|
height: {
|
|
type: Number,
|
|
default: 32
|
|
},
|
|
zIndex: {
|
|
type: Number,
|
|
default: 10
|
|
},
|
|
xGap: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
yGap: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
yOffset: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
xOffset: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
rotate: {
|
|
type: Number,
|
|
default: 0
|
|
},
|
|
textAlign: {
|
|
type: String,
|
|
default: "left"
|
|
},
|
|
image: String,
|
|
imageOpacity: {
|
|
type: Number,
|
|
default: 1
|
|
},
|
|
imageHeight: Number,
|
|
imageWidth: Number,
|
|
content: String,
|
|
selectable: {
|
|
type: Boolean,
|
|
default: true
|
|
},
|
|
fontSize: {
|
|
type: Number,
|
|
default: 14
|
|
},
|
|
fontFamily: String,
|
|
fontStyle: {
|
|
type: String,
|
|
default: "normal"
|
|
},
|
|
fontVariant: {
|
|
type: String,
|
|
default: ""
|
|
},
|
|
fontWeight: {
|
|
type: Number,
|
|
default: 400
|
|
},
|
|
fontColor: {
|
|
type: String,
|
|
default: "rgba(128, 128, 128, .3)"
|
|
},
|
|
fontStretch: {
|
|
type: String,
|
|
default: ""
|
|
},
|
|
lineHeight: {
|
|
type: Number,
|
|
default: 14
|
|
},
|
|
globalRotate: {
|
|
type: Number,
|
|
default: 0
|
|
}
|
|
});
|
|
const __unplugin_components_2 = /* @__PURE__ */ defineComponent({
|
|
name: "Watermark",
|
|
props: watermarkProps,
|
|
setup(props, {
|
|
slots
|
|
}) {
|
|
const {
|
|
mergedClsPrefixRef
|
|
} = useConfig(props);
|
|
const themeRef = useTheme("Watermark", "-watermark", style, watermarkLight, props, mergedClsPrefixRef);
|
|
const base64UrlRef = ref("");
|
|
const canvas = isBrowser$2 ? document.createElement("canvas") : null;
|
|
const ctx2 = canvas ? canvas.getContext("2d") : null;
|
|
const fontsReadyRef = ref(false);
|
|
onFontsReady(() => fontsReadyRef.value = true);
|
|
watchEffect(() => {
|
|
if (!canvas) return;
|
|
void fontsReadyRef.value;
|
|
const ratio = getRatio(ctx2);
|
|
const {
|
|
xGap,
|
|
yGap,
|
|
width,
|
|
height,
|
|
yOffset,
|
|
xOffset,
|
|
rotate,
|
|
image,
|
|
content,
|
|
fontColor,
|
|
fontStyle,
|
|
fontVariant,
|
|
fontStretch,
|
|
fontWeight,
|
|
fontFamily: fontFamily2,
|
|
fontSize: fontSize2,
|
|
lineHeight: lineHeight2,
|
|
debug
|
|
} = props;
|
|
const canvasWidth = (xGap + width) * ratio;
|
|
const canvasHeight = (yGap + height) * ratio;
|
|
const canvasOffsetLeft = xOffset * ratio;
|
|
const canvasOffsetTop = yOffset * ratio;
|
|
canvas.width = canvasWidth;
|
|
canvas.height = canvasHeight;
|
|
if (ctx2) {
|
|
ctx2.translate(0, 0);
|
|
const markWidth = width * ratio;
|
|
const markHeight = height * ratio;
|
|
if (debug) {
|
|
ctx2.strokeStyle = "grey";
|
|
ctx2.strokeRect(0, 0, markWidth, markHeight);
|
|
}
|
|
ctx2.rotate(rotate * (Math.PI / 180));
|
|
if (image) {
|
|
const img = new Image();
|
|
img.crossOrigin = "anonymous";
|
|
img.referrerPolicy = "no-referrer";
|
|
img.src = image;
|
|
img.onload = () => {
|
|
ctx2.globalAlpha = props.imageOpacity;
|
|
const {
|
|
imageWidth,
|
|
imageHeight
|
|
} = props;
|
|
ctx2.drawImage(img, canvasOffsetLeft, canvasOffsetTop, (props.imageWidth || (imageHeight ? img.width * imageHeight / img.height : img.width)) * ratio, (props.imageHeight || (imageWidth ? img.height * imageWidth / img.width : img.height)) * ratio);
|
|
base64UrlRef.value = canvas.toDataURL();
|
|
};
|
|
} else if (content) {
|
|
if (debug) {
|
|
ctx2.strokeStyle = "green";
|
|
ctx2.strokeRect(0, 0, markWidth, markHeight);
|
|
}
|
|
ctx2.font = `${fontStyle} ${fontVariant} ${fontWeight} ${fontStretch} ${fontSize2 * ratio}px/${lineHeight2 * ratio}px ${fontFamily2 || themeRef.value.self.fontFamily}`;
|
|
ctx2.fillStyle = fontColor;
|
|
let maxWidth = 0;
|
|
const {
|
|
textAlign
|
|
} = props;
|
|
content.split("\n").map((line) => {
|
|
const width2 = ctx2.measureText(line).width;
|
|
maxWidth = Math.max(maxWidth, width2);
|
|
return {
|
|
width: width2,
|
|
line
|
|
};
|
|
}).forEach(({
|
|
line,
|
|
width: width2
|
|
}, index) => {
|
|
const alignOffset = textAlign === "left" ? 0 : textAlign === "center" ? (maxWidth - width2) / 2 : maxWidth - width2;
|
|
ctx2.fillText(line, canvasOffsetLeft + alignOffset, canvasOffsetTop + lineHeight2 * ratio * (index + 1));
|
|
});
|
|
base64UrlRef.value = canvas.toDataURL();
|
|
} else if (!content) {
|
|
ctx2.clearRect(0, 0, canvas.width, canvas.height);
|
|
base64UrlRef.value = canvas.toDataURL();
|
|
}
|
|
} else {
|
|
warnOnce("watermark", "Canvas is not supported in the browser.");
|
|
}
|
|
});
|
|
return () => {
|
|
var _a;
|
|
const {
|
|
globalRotate,
|
|
fullscreen,
|
|
zIndex
|
|
} = props;
|
|
const mergedClsPrefix = mergedClsPrefixRef.value;
|
|
const isFullScreenGlobalRotate = globalRotate !== 0 && fullscreen;
|
|
const rotatedImageOffset = "max(142vh, 142vw)";
|
|
const watermarkNode = h("div", {
|
|
class: [`${mergedClsPrefix}-watermark`, globalRotate !== 0 && `${mergedClsPrefix}-watermark--global-rotate`, fullscreen && `${mergedClsPrefix}-watermark--fullscreen`],
|
|
style: {
|
|
transform: globalRotate ? `translateX(-50%) translateY(-50%) rotate(${globalRotate}deg)` : void 0,
|
|
zIndex: isFullScreenGlobalRotate ? void 0 : zIndex,
|
|
backgroundSize: `${props.xGap + props.width}px`,
|
|
backgroundPosition: globalRotate === 0 ? props.cross ? `${props.width / 2}px ${props.height / 2}px, 0 0` : "" : props.cross ? `calc(${rotatedImageOffset} + ${props.width / 2}px) calc(${rotatedImageOffset} + ${props.height / 2}px), ${rotatedImageOffset} ${rotatedImageOffset}` : rotatedImageOffset,
|
|
backgroundImage: props.cross ? `url(${base64UrlRef.value}), url(${base64UrlRef.value})` : `url(${base64UrlRef.value})`
|
|
}
|
|
});
|
|
if (props.fullscreen && !globalRotate) return watermarkNode;
|
|
return h("div", {
|
|
class: [`${mergedClsPrefix}-watermark-container`, globalRotate !== 0 && `${mergedClsPrefix}-watermark-container--global-rotate`, fullscreen && `${mergedClsPrefix}-watermark-container--fullscreen`, props.selectable && `${mergedClsPrefix}-watermark-container--selectable`],
|
|
style: {
|
|
zIndex: isFullScreenGlobalRotate ? zIndex : void 0
|
|
}
|
|
}, (_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots), watermarkNode);
|
|
};
|
|
}
|
|
});
|
|
/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
this file except in compliance with the License. You may obtain a copy of the
|
|
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
|
|
See the Apache Version 2.0 License for specific language governing permissions
|
|
and limitations under the License.
|
|
***************************************************************************** */
|
|
var extendStatics = function(d, b) {
|
|
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
d2.__proto__ = b2;
|
|
} || function(d2, b2) {
|
|
for (var p2 in b2) if (b2.hasOwnProperty(p2)) d2[p2] = b2[p2];
|
|
};
|
|
return extendStatics(d, b);
|
|
};
|
|
function __extends(d, b) {
|
|
extendStatics(d, b);
|
|
function __() {
|
|
this.constructor = d;
|
|
}
|
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
}
|
|
function __values(o) {
|
|
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
|
|
if (m) return m.call(o);
|
|
return {
|
|
next: function() {
|
|
if (o && i >= o.length) o = void 0;
|
|
return { value: o && o[i++], done: !o };
|
|
}
|
|
};
|
|
}
|
|
function __read(o, n) {
|
|
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
if (!m) return o;
|
|
var i = m.call(o), r, ar = [], e;
|
|
try {
|
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
} catch (error2) {
|
|
e = { error: error2 };
|
|
} finally {
|
|
try {
|
|
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
} finally {
|
|
if (e) throw e.error;
|
|
}
|
|
}
|
|
return ar;
|
|
}
|
|
function __spread() {
|
|
for (var ar = [], i = 0; i < arguments.length; i++)
|
|
ar = ar.concat(__read(arguments[i]));
|
|
return ar;
|
|
}
|
|
var Event$1 = (
|
|
/** @class */
|
|
/* @__PURE__ */ function() {
|
|
function Event2(type, target) {
|
|
this.target = target;
|
|
this.type = type;
|
|
}
|
|
return Event2;
|
|
}()
|
|
);
|
|
var ErrorEvent$1 = (
|
|
/** @class */
|
|
function(_super) {
|
|
__extends(ErrorEvent2, _super);
|
|
function ErrorEvent2(error2, target) {
|
|
var _this = _super.call(this, "error", target) || this;
|
|
_this.message = error2.message;
|
|
_this.error = error2;
|
|
return _this;
|
|
}
|
|
return ErrorEvent2;
|
|
}(Event$1)
|
|
);
|
|
var CloseEvent = (
|
|
/** @class */
|
|
function(_super) {
|
|
__extends(CloseEvent2, _super);
|
|
function CloseEvent2(code, reason, target) {
|
|
if (code === void 0) {
|
|
code = 1e3;
|
|
}
|
|
if (reason === void 0) {
|
|
reason = "";
|
|
}
|
|
var _this = _super.call(this, "close", target) || this;
|
|
_this.wasClean = true;
|
|
_this.code = code;
|
|
_this.reason = reason;
|
|
return _this;
|
|
}
|
|
return CloseEvent2;
|
|
}(Event$1)
|
|
);
|
|
/*!
|
|
* Reconnecting WebSocket
|
|
* by Pedro Ladaria <pedro.ladaria@gmail.com>
|
|
* https://github.com/pladaria/reconnecting-websocket
|
|
* License MIT
|
|
*/
|
|
var getGlobalWebSocket = function() {
|
|
if (typeof WebSocket !== "undefined") {
|
|
return WebSocket;
|
|
}
|
|
};
|
|
var isWebSocket = function(w) {
|
|
return typeof w !== "undefined" && !!w && w.CLOSING === 2;
|
|
};
|
|
var DEFAULT = {
|
|
maxReconnectionDelay: 1e4,
|
|
minReconnectionDelay: 1e3 + Math.random() * 4e3,
|
|
minUptime: 5e3,
|
|
reconnectionDelayGrowFactor: 1.3,
|
|
connectionTimeout: 4e3,
|
|
maxRetries: Infinity,
|
|
maxEnqueuedMessages: Infinity
|
|
};
|
|
var ReconnectingWebSocket = (
|
|
/** @class */
|
|
function() {
|
|
function ReconnectingWebSocket2(url, protocols, options) {
|
|
var _this = this;
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
this._listeners = {
|
|
error: [],
|
|
message: [],
|
|
open: [],
|
|
close: []
|
|
};
|
|
this._retryCount = -1;
|
|
this._shouldReconnect = true;
|
|
this._connectLock = false;
|
|
this._binaryType = "blob";
|
|
this._closeCalled = false;
|
|
this._messageQueue = [];
|
|
this.onclose = null;
|
|
this.onerror = null;
|
|
this.onmessage = null;
|
|
this.onopen = null;
|
|
this._handleOpen = function(event) {
|
|
_this._debug("open event");
|
|
var _a = _this._options.minUptime, minUptime = _a === void 0 ? DEFAULT.minUptime : _a;
|
|
clearTimeout(_this._connectTimeout);
|
|
_this._uptimeTimeout = setTimeout(function() {
|
|
return _this._acceptOpen();
|
|
}, minUptime);
|
|
_this._ws.binaryType = _this._binaryType;
|
|
_this._messageQueue.forEach(function(message) {
|
|
return _this._ws.send(message);
|
|
});
|
|
_this._messageQueue = [];
|
|
if (_this.onopen) {
|
|
_this.onopen(event);
|
|
}
|
|
_this._listeners.open.forEach(function(listener) {
|
|
return _this._callEventListener(event, listener);
|
|
});
|
|
};
|
|
this._handleMessage = function(event) {
|
|
_this._debug("message event");
|
|
if (_this.onmessage) {
|
|
_this.onmessage(event);
|
|
}
|
|
_this._listeners.message.forEach(function(listener) {
|
|
return _this._callEventListener(event, listener);
|
|
});
|
|
};
|
|
this._handleError = function(event) {
|
|
_this._debug("error event", event.message);
|
|
_this._disconnect(void 0, event.message === "TIMEOUT" ? "timeout" : void 0);
|
|
if (_this.onerror) {
|
|
_this.onerror(event);
|
|
}
|
|
_this._debug("exec error listeners");
|
|
_this._listeners.error.forEach(function(listener) {
|
|
return _this._callEventListener(event, listener);
|
|
});
|
|
_this._connect();
|
|
};
|
|
this._handleClose = function(event) {
|
|
_this._debug("close event");
|
|
_this._clearTimeouts();
|
|
if (_this._shouldReconnect) {
|
|
_this._connect();
|
|
}
|
|
if (_this.onclose) {
|
|
_this.onclose(event);
|
|
}
|
|
_this._listeners.close.forEach(function(listener) {
|
|
return _this._callEventListener(event, listener);
|
|
});
|
|
};
|
|
this._url = url;
|
|
this._protocols = protocols;
|
|
this._options = options;
|
|
if (this._options.startClosed) {
|
|
this._shouldReconnect = false;
|
|
}
|
|
this._connect();
|
|
}
|
|
Object.defineProperty(ReconnectingWebSocket2, "CONNECTING", {
|
|
get: function() {
|
|
return 0;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2, "OPEN", {
|
|
get: function() {
|
|
return 1;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2, "CLOSING", {
|
|
get: function() {
|
|
return 2;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2, "CLOSED", {
|
|
get: function() {
|
|
return 3;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "CONNECTING", {
|
|
get: function() {
|
|
return ReconnectingWebSocket2.CONNECTING;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "OPEN", {
|
|
get: function() {
|
|
return ReconnectingWebSocket2.OPEN;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "CLOSING", {
|
|
get: function() {
|
|
return ReconnectingWebSocket2.CLOSING;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "CLOSED", {
|
|
get: function() {
|
|
return ReconnectingWebSocket2.CLOSED;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "binaryType", {
|
|
get: function() {
|
|
return this._ws ? this._ws.binaryType : this._binaryType;
|
|
},
|
|
set: function(value) {
|
|
this._binaryType = value;
|
|
if (this._ws) {
|
|
this._ws.binaryType = value;
|
|
}
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "retryCount", {
|
|
/**
|
|
* Returns the number or connection retries
|
|
*/
|
|
get: function() {
|
|
return Math.max(this._retryCount, 0);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "bufferedAmount", {
|
|
/**
|
|
* The number of bytes of data that have been queued using calls to send() but not yet
|
|
* transmitted to the network. This value resets to zero once all queued data has been sent.
|
|
* This value does not reset to zero when the connection is closed; if you keep calling send(),
|
|
* this will continue to climb. Read only
|
|
*/
|
|
get: function() {
|
|
var bytes = this._messageQueue.reduce(function(acc, message) {
|
|
if (typeof message === "string") {
|
|
acc += message.length;
|
|
} else if (message instanceof Blob) {
|
|
acc += message.size;
|
|
} else {
|
|
acc += message.byteLength;
|
|
}
|
|
return acc;
|
|
}, 0);
|
|
return bytes + (this._ws ? this._ws.bufferedAmount : 0);
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "extensions", {
|
|
/**
|
|
* The extensions selected by the server. This is currently only the empty string or a list of
|
|
* extensions as negotiated by the connection
|
|
*/
|
|
get: function() {
|
|
return this._ws ? this._ws.extensions : "";
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "protocol", {
|
|
/**
|
|
* A string indicating the name of the sub-protocol the server selected;
|
|
* this will be one of the strings specified in the protocols parameter when creating the
|
|
* WebSocket object
|
|
*/
|
|
get: function() {
|
|
return this._ws ? this._ws.protocol : "";
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "readyState", {
|
|
/**
|
|
* The current state of the connection; this is one of the Ready state constants
|
|
*/
|
|
get: function() {
|
|
if (this._ws) {
|
|
return this._ws.readyState;
|
|
}
|
|
return this._options.startClosed ? ReconnectingWebSocket2.CLOSED : ReconnectingWebSocket2.CONNECTING;
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ReconnectingWebSocket2.prototype, "url", {
|
|
/**
|
|
* The URL as resolved by the constructor
|
|
*/
|
|
get: function() {
|
|
return this._ws ? this._ws.url : "";
|
|
},
|
|
enumerable: true,
|
|
configurable: true
|
|
});
|
|
ReconnectingWebSocket2.prototype.close = function(code, reason) {
|
|
if (code === void 0) {
|
|
code = 1e3;
|
|
}
|
|
this._closeCalled = true;
|
|
this._shouldReconnect = false;
|
|
this._clearTimeouts();
|
|
if (!this._ws) {
|
|
this._debug("close enqueued: no ws instance");
|
|
return;
|
|
}
|
|
if (this._ws.readyState === this.CLOSED) {
|
|
this._debug("close: already closed");
|
|
return;
|
|
}
|
|
this._ws.close(code, reason);
|
|
};
|
|
ReconnectingWebSocket2.prototype.reconnect = function(code, reason) {
|
|
this._shouldReconnect = true;
|
|
this._closeCalled = false;
|
|
this._retryCount = -1;
|
|
if (!this._ws || this._ws.readyState === this.CLOSED) {
|
|
this._connect();
|
|
} else {
|
|
this._disconnect(code, reason);
|
|
this._connect();
|
|
}
|
|
};
|
|
ReconnectingWebSocket2.prototype.send = function(data) {
|
|
if (this._ws && this._ws.readyState === this.OPEN) {
|
|
this._debug("send", data);
|
|
this._ws.send(data);
|
|
} else {
|
|
var _a = this._options.maxEnqueuedMessages, maxEnqueuedMessages = _a === void 0 ? DEFAULT.maxEnqueuedMessages : _a;
|
|
if (this._messageQueue.length < maxEnqueuedMessages) {
|
|
this._debug("enqueue", data);
|
|
this._messageQueue.push(data);
|
|
}
|
|
}
|
|
};
|
|
ReconnectingWebSocket2.prototype.addEventListener = function(type, listener) {
|
|
if (this._listeners[type]) {
|
|
this._listeners[type].push(listener);
|
|
}
|
|
};
|
|
ReconnectingWebSocket2.prototype.dispatchEvent = function(event) {
|
|
var e_1, _a;
|
|
var listeners = this._listeners[event.type];
|
|
if (listeners) {
|
|
try {
|
|
for (var listeners_1 = __values(listeners), listeners_1_1 = listeners_1.next(); !listeners_1_1.done; listeners_1_1 = listeners_1.next()) {
|
|
var listener = listeners_1_1.value;
|
|
this._callEventListener(event, listener);
|
|
}
|
|
} catch (e_1_1) {
|
|
e_1 = { error: e_1_1 };
|
|
} finally {
|
|
try {
|
|
if (listeners_1_1 && !listeners_1_1.done && (_a = listeners_1.return)) _a.call(listeners_1);
|
|
} finally {
|
|
if (e_1) throw e_1.error;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
ReconnectingWebSocket2.prototype.removeEventListener = function(type, listener) {
|
|
if (this._listeners[type]) {
|
|
this._listeners[type] = this._listeners[type].filter(function(l) {
|
|
return l !== listener;
|
|
});
|
|
}
|
|
};
|
|
ReconnectingWebSocket2.prototype._debug = function() {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
if (this._options.debug) {
|
|
console.log.apply(console, __spread(["RWS>"], args));
|
|
}
|
|
};
|
|
ReconnectingWebSocket2.prototype._getNextDelay = function() {
|
|
var _a = this._options, _b = _a.reconnectionDelayGrowFactor, reconnectionDelayGrowFactor = _b === void 0 ? DEFAULT.reconnectionDelayGrowFactor : _b, _c = _a.minReconnectionDelay, minReconnectionDelay = _c === void 0 ? DEFAULT.minReconnectionDelay : _c, _d = _a.maxReconnectionDelay, maxReconnectionDelay = _d === void 0 ? DEFAULT.maxReconnectionDelay : _d;
|
|
var delay = 0;
|
|
if (this._retryCount > 0) {
|
|
delay = minReconnectionDelay * Math.pow(reconnectionDelayGrowFactor, this._retryCount - 1);
|
|
if (delay > maxReconnectionDelay) {
|
|
delay = maxReconnectionDelay;
|
|
}
|
|
}
|
|
this._debug("next delay", delay);
|
|
return delay;
|
|
};
|
|
ReconnectingWebSocket2.prototype._wait = function() {
|
|
var _this = this;
|
|
return new Promise(function(resolve2) {
|
|
setTimeout(resolve2, _this._getNextDelay());
|
|
});
|
|
};
|
|
ReconnectingWebSocket2.prototype._getNextUrl = function(urlProvider) {
|
|
if (typeof urlProvider === "string") {
|
|
return Promise.resolve(urlProvider);
|
|
}
|
|
if (typeof urlProvider === "function") {
|
|
var url = urlProvider();
|
|
if (typeof url === "string") {
|
|
return Promise.resolve(url);
|
|
}
|
|
if (!!url.then) {
|
|
return url;
|
|
}
|
|
}
|
|
throw Error("Invalid URL");
|
|
};
|
|
ReconnectingWebSocket2.prototype._connect = function() {
|
|
var _this = this;
|
|
if (this._connectLock || !this._shouldReconnect) {
|
|
return;
|
|
}
|
|
this._connectLock = true;
|
|
var _a = this._options, _b = _a.maxRetries, maxRetries = _b === void 0 ? DEFAULT.maxRetries : _b, _c = _a.connectionTimeout, connectionTimeout = _c === void 0 ? DEFAULT.connectionTimeout : _c, _d = _a.WebSocket, WebSocket2 = _d === void 0 ? getGlobalWebSocket() : _d;
|
|
if (this._retryCount >= maxRetries) {
|
|
this._debug("max retries reached", this._retryCount, ">=", maxRetries);
|
|
return;
|
|
}
|
|
this._retryCount++;
|
|
this._debug("connect", this._retryCount);
|
|
this._removeListeners();
|
|
if (!isWebSocket(WebSocket2)) {
|
|
throw Error("No valid WebSocket class provided");
|
|
}
|
|
this._wait().then(function() {
|
|
return _this._getNextUrl(_this._url);
|
|
}).then(function(url) {
|
|
if (_this._closeCalled) {
|
|
return;
|
|
}
|
|
_this._debug("connect", { url, protocols: _this._protocols });
|
|
_this._ws = _this._protocols ? new WebSocket2(url, _this._protocols) : new WebSocket2(url);
|
|
_this._ws.binaryType = _this._binaryType;
|
|
_this._connectLock = false;
|
|
_this._addListeners();
|
|
_this._connectTimeout = setTimeout(function() {
|
|
return _this._handleTimeout();
|
|
}, connectionTimeout);
|
|
});
|
|
};
|
|
ReconnectingWebSocket2.prototype._handleTimeout = function() {
|
|
this._debug("timeout event");
|
|
this._handleError(new ErrorEvent$1(Error("TIMEOUT"), this));
|
|
};
|
|
ReconnectingWebSocket2.prototype._disconnect = function(code, reason) {
|
|
if (code === void 0) {
|
|
code = 1e3;
|
|
}
|
|
this._clearTimeouts();
|
|
if (!this._ws) {
|
|
return;
|
|
}
|
|
this._removeListeners();
|
|
try {
|
|
this._ws.close(code, reason);
|
|
this._handleClose(new CloseEvent(code, reason, this));
|
|
} catch (error2) {
|
|
}
|
|
};
|
|
ReconnectingWebSocket2.prototype._acceptOpen = function() {
|
|
this._debug("accept open");
|
|
this._retryCount = 0;
|
|
};
|
|
ReconnectingWebSocket2.prototype._callEventListener = function(event, listener) {
|
|
if ("handleEvent" in listener) {
|
|
listener.handleEvent(event);
|
|
} else {
|
|
listener(event);
|
|
}
|
|
};
|
|
ReconnectingWebSocket2.prototype._removeListeners = function() {
|
|
if (!this._ws) {
|
|
return;
|
|
}
|
|
this._debug("removeListeners");
|
|
this._ws.removeEventListener("open", this._handleOpen);
|
|
this._ws.removeEventListener("close", this._handleClose);
|
|
this._ws.removeEventListener("message", this._handleMessage);
|
|
this._ws.removeEventListener("error", this._handleError);
|
|
};
|
|
ReconnectingWebSocket2.prototype._addListeners = function() {
|
|
if (!this._ws) {
|
|
return;
|
|
}
|
|
this._debug("addListeners");
|
|
this._ws.addEventListener("open", this._handleOpen);
|
|
this._ws.addEventListener("close", this._handleClose);
|
|
this._ws.addEventListener("message", this._handleMessage);
|
|
this._ws.addEventListener("error", this._handleError);
|
|
};
|
|
ReconnectingWebSocket2.prototype._clearTimeouts = function() {
|
|
clearTimeout(this._connectTimeout);
|
|
clearTimeout(this._uptimeTimeout);
|
|
};
|
|
return ReconnectingWebSocket2;
|
|
}()
|
|
);
|
|
function bind(fn, thisArg) {
|
|
return function wrap() {
|
|
return fn.apply(thisArg, arguments);
|
|
};
|
|
}
|
|
const { toString } = Object.prototype;
|
|
const { getPrototypeOf } = Object;
|
|
const kindOf = /* @__PURE__ */ ((cache2) => (thing) => {
|
|
const str = toString.call(thing);
|
|
return cache2[str] || (cache2[str] = str.slice(8, -1).toLowerCase());
|
|
})(/* @__PURE__ */ Object.create(null));
|
|
const kindOfTest = (type) => {
|
|
type = type.toLowerCase();
|
|
return (thing) => kindOf(thing) === type;
|
|
};
|
|
const typeOfTest = (type) => (thing) => typeof thing === type;
|
|
const { isArray: isArray$1 } = Array;
|
|
const isUndefined = typeOfTest("undefined");
|
|
function isBuffer(val) {
|
|
return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor) && isFunction(val.constructor.isBuffer) && val.constructor.isBuffer(val);
|
|
}
|
|
const isArrayBuffer = kindOfTest("ArrayBuffer");
|
|
function isArrayBufferView(val) {
|
|
let result;
|
|
if (typeof ArrayBuffer !== "undefined" && ArrayBuffer.isView) {
|
|
result = ArrayBuffer.isView(val);
|
|
} else {
|
|
result = val && val.buffer && isArrayBuffer(val.buffer);
|
|
}
|
|
return result;
|
|
}
|
|
const isString = typeOfTest("string");
|
|
const isFunction = typeOfTest("function");
|
|
const isNumber = typeOfTest("number");
|
|
const isObject = (thing) => thing !== null && typeof thing === "object";
|
|
const isBoolean = (thing) => thing === true || thing === false;
|
|
const isPlainObject = (val) => {
|
|
if (kindOf(val) !== "object") {
|
|
return false;
|
|
}
|
|
const prototype2 = getPrototypeOf(val);
|
|
return (prototype2 === null || prototype2 === Object.prototype || Object.getPrototypeOf(prototype2) === null) && !(Symbol.toStringTag in val) && !(Symbol.iterator in val);
|
|
};
|
|
const isDate = kindOfTest("Date");
|
|
const isFile = kindOfTest("File");
|
|
const isBlob = kindOfTest("Blob");
|
|
const isFileList = kindOfTest("FileList");
|
|
const isStream = (val) => isObject(val) && isFunction(val.pipe);
|
|
const isFormData = (thing) => {
|
|
let kind;
|
|
return thing && (typeof FormData === "function" && thing instanceof FormData || isFunction(thing.append) && ((kind = kindOf(thing)) === "formdata" || // detect form-data instance
|
|
kind === "object" && isFunction(thing.toString) && thing.toString() === "[object FormData]"));
|
|
};
|
|
const isURLSearchParams = kindOfTest("URLSearchParams");
|
|
const [isReadableStream, isRequest, isResponse, isHeaders] = ["ReadableStream", "Request", "Response", "Headers"].map(kindOfTest);
|
|
const trim = (str) => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
function forEach(obj, fn, { allOwnKeys = false } = {}) {
|
|
if (obj === null || typeof obj === "undefined") {
|
|
return;
|
|
}
|
|
let i;
|
|
let l;
|
|
if (typeof obj !== "object") {
|
|
obj = [obj];
|
|
}
|
|
if (isArray$1(obj)) {
|
|
for (i = 0, l = obj.length; i < l; i++) {
|
|
fn.call(null, obj[i], i, obj);
|
|
}
|
|
} else {
|
|
const keys = allOwnKeys ? Object.getOwnPropertyNames(obj) : Object.keys(obj);
|
|
const len = keys.length;
|
|
let key;
|
|
for (i = 0; i < len; i++) {
|
|
key = keys[i];
|
|
fn.call(null, obj[key], key, obj);
|
|
}
|
|
}
|
|
}
|
|
function findKey(obj, key) {
|
|
key = key.toLowerCase();
|
|
const keys = Object.keys(obj);
|
|
let i = keys.length;
|
|
let _key;
|
|
while (i-- > 0) {
|
|
_key = keys[i];
|
|
if (key === _key.toLowerCase()) {
|
|
return _key;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
const _global = (() => {
|
|
if (typeof globalThis !== "undefined") return globalThis;
|
|
return typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : global;
|
|
})();
|
|
const isContextDefined = (context) => !isUndefined(context) && context !== _global;
|
|
function merge() {
|
|
const { caseless } = isContextDefined(this) && this || {};
|
|
const result = {};
|
|
const assignValue2 = (val, key) => {
|
|
const targetKey = caseless && findKey(result, key) || key;
|
|
if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
|
|
result[targetKey] = merge(result[targetKey], val);
|
|
} else if (isPlainObject(val)) {
|
|
result[targetKey] = merge({}, val);
|
|
} else if (isArray$1(val)) {
|
|
result[targetKey] = val.slice();
|
|
} else {
|
|
result[targetKey] = val;
|
|
}
|
|
};
|
|
for (let i = 0, l = arguments.length; i < l; i++) {
|
|
arguments[i] && forEach(arguments[i], assignValue2);
|
|
}
|
|
return result;
|
|
}
|
|
const extend = (a, b, thisArg, { allOwnKeys } = {}) => {
|
|
forEach(b, (val, key) => {
|
|
if (thisArg && isFunction(val)) {
|
|
a[key] = bind(val, thisArg);
|
|
} else {
|
|
a[key] = val;
|
|
}
|
|
}, { allOwnKeys });
|
|
return a;
|
|
};
|
|
const stripBOM = (content) => {
|
|
if (content.charCodeAt(0) === 65279) {
|
|
content = content.slice(1);
|
|
}
|
|
return content;
|
|
};
|
|
const inherits = (constructor, superConstructor, props, descriptors2) => {
|
|
constructor.prototype = Object.create(superConstructor.prototype, descriptors2);
|
|
constructor.prototype.constructor = constructor;
|
|
Object.defineProperty(constructor, "super", {
|
|
value: superConstructor.prototype
|
|
});
|
|
props && Object.assign(constructor.prototype, props);
|
|
};
|
|
const toFlatObject = (sourceObj, destObj, filter2, propFilter) => {
|
|
let props;
|
|
let i;
|
|
let prop;
|
|
const merged = {};
|
|
destObj = destObj || {};
|
|
if (sourceObj == null) return destObj;
|
|
do {
|
|
props = Object.getOwnPropertyNames(sourceObj);
|
|
i = props.length;
|
|
while (i-- > 0) {
|
|
prop = props[i];
|
|
if ((!propFilter || propFilter(prop, sourceObj, destObj)) && !merged[prop]) {
|
|
destObj[prop] = sourceObj[prop];
|
|
merged[prop] = true;
|
|
}
|
|
}
|
|
sourceObj = filter2 !== false && getPrototypeOf(sourceObj);
|
|
} while (sourceObj && (!filter2 || filter2(sourceObj, destObj)) && sourceObj !== Object.prototype);
|
|
return destObj;
|
|
};
|
|
const endsWith = (str, searchString, position) => {
|
|
str = String(str);
|
|
if (position === void 0 || position > str.length) {
|
|
position = str.length;
|
|
}
|
|
position -= searchString.length;
|
|
const lastIndex = str.indexOf(searchString, position);
|
|
return lastIndex !== -1 && lastIndex === position;
|
|
};
|
|
const toArray = (thing) => {
|
|
if (!thing) return null;
|
|
if (isArray$1(thing)) return thing;
|
|
let i = thing.length;
|
|
if (!isNumber(i)) return null;
|
|
const arr = new Array(i);
|
|
while (i-- > 0) {
|
|
arr[i] = thing[i];
|
|
}
|
|
return arr;
|
|
};
|
|
const isTypedArray = /* @__PURE__ */ ((TypedArray) => {
|
|
return (thing) => {
|
|
return TypedArray && thing instanceof TypedArray;
|
|
};
|
|
})(typeof Uint8Array !== "undefined" && getPrototypeOf(Uint8Array));
|
|
const forEachEntry = (obj, fn) => {
|
|
const generator = obj && obj[Symbol.iterator];
|
|
const iterator2 = generator.call(obj);
|
|
let result;
|
|
while ((result = iterator2.next()) && !result.done) {
|
|
const pair = result.value;
|
|
fn.call(obj, pair[0], pair[1]);
|
|
}
|
|
};
|
|
const matchAll = (regExp, str) => {
|
|
let matches2;
|
|
const arr = [];
|
|
while ((matches2 = regExp.exec(str)) !== null) {
|
|
arr.push(matches2);
|
|
}
|
|
return arr;
|
|
};
|
|
const isHTMLForm = kindOfTest("HTMLFormElement");
|
|
const toCamelCase = (str) => {
|
|
return str.toLowerCase().replace(
|
|
/[-_\s]([a-z\d])(\w*)/g,
|
|
function replacer2(m, p1, p2) {
|
|
return p1.toUpperCase() + p2;
|
|
}
|
|
);
|
|
};
|
|
const hasOwnProperty$1 = (({ hasOwnProperty: hasOwnProperty2 }) => (obj, prop) => hasOwnProperty2.call(obj, prop))(Object.prototype);
|
|
const isRegExp = kindOfTest("RegExp");
|
|
const reduceDescriptors = (obj, reducer) => {
|
|
const descriptors2 = Object.getOwnPropertyDescriptors(obj);
|
|
const reducedDescriptors = {};
|
|
forEach(descriptors2, (descriptor, name) => {
|
|
let ret;
|
|
if ((ret = reducer(descriptor, name, obj)) !== false) {
|
|
reducedDescriptors[name] = ret || descriptor;
|
|
}
|
|
});
|
|
Object.defineProperties(obj, reducedDescriptors);
|
|
};
|
|
const freezeMethods = (obj) => {
|
|
reduceDescriptors(obj, (descriptor, name) => {
|
|
if (isFunction(obj) && ["arguments", "caller", "callee"].indexOf(name) !== -1) {
|
|
return false;
|
|
}
|
|
const value = obj[name];
|
|
if (!isFunction(value)) return;
|
|
descriptor.enumerable = false;
|
|
if ("writable" in descriptor) {
|
|
descriptor.writable = false;
|
|
return;
|
|
}
|
|
if (!descriptor.set) {
|
|
descriptor.set = () => {
|
|
throw Error("Can not rewrite read-only method '" + name + "'");
|
|
};
|
|
}
|
|
});
|
|
};
|
|
const toObjectSet = (arrayOrString, delimiter) => {
|
|
const obj = {};
|
|
const define2 = (arr) => {
|
|
arr.forEach((value) => {
|
|
obj[value] = true;
|
|
});
|
|
};
|
|
isArray$1(arrayOrString) ? define2(arrayOrString) : define2(String(arrayOrString).split(delimiter));
|
|
return obj;
|
|
};
|
|
const noop$1 = () => {
|
|
};
|
|
const toFiniteNumber = (value, defaultValue) => {
|
|
return value != null && Number.isFinite(value = +value) ? value : defaultValue;
|
|
};
|
|
function isSpecCompliantForm(thing) {
|
|
return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator]);
|
|
}
|
|
const toJSONObject = (obj) => {
|
|
const stack2 = new Array(10);
|
|
const visit = (source, i) => {
|
|
if (isObject(source)) {
|
|
if (stack2.indexOf(source) >= 0) {
|
|
return;
|
|
}
|
|
if (!("toJSON" in source)) {
|
|
stack2[i] = source;
|
|
const target = isArray$1(source) ? [] : {};
|
|
forEach(source, (value, key) => {
|
|
const reducedValue = visit(value, i + 1);
|
|
!isUndefined(reducedValue) && (target[key] = reducedValue);
|
|
});
|
|
stack2[i] = void 0;
|
|
return target;
|
|
}
|
|
}
|
|
return source;
|
|
};
|
|
return visit(obj, 0);
|
|
};
|
|
const isAsyncFn = kindOfTest("AsyncFunction");
|
|
const isThenable = (thing) => thing && (isObject(thing) || isFunction(thing)) && isFunction(thing.then) && isFunction(thing.catch);
|
|
const _setImmediate = ((setImmediateSupported, postMessageSupported) => {
|
|
if (setImmediateSupported) {
|
|
return setImmediate;
|
|
}
|
|
return postMessageSupported ? ((token, callbacks2) => {
|
|
_global.addEventListener("message", ({ source, data }) => {
|
|
if (source === _global && data === token) {
|
|
callbacks2.length && callbacks2.shift()();
|
|
}
|
|
}, false);
|
|
return (cb) => {
|
|
callbacks2.push(cb);
|
|
_global.postMessage(token, "*");
|
|
};
|
|
})(`axios@${Math.random()}`, []) : (cb) => setTimeout(cb);
|
|
})(
|
|
typeof setImmediate === "function",
|
|
isFunction(_global.postMessage)
|
|
);
|
|
const asap = typeof queueMicrotask !== "undefined" ? queueMicrotask.bind(_global) : typeof process !== "undefined" && process.nextTick || _setImmediate;
|
|
const utils$1 = {
|
|
isArray: isArray$1,
|
|
isArrayBuffer,
|
|
isBuffer,
|
|
isFormData,
|
|
isArrayBufferView,
|
|
isString,
|
|
isNumber,
|
|
isBoolean,
|
|
isObject,
|
|
isPlainObject,
|
|
isReadableStream,
|
|
isRequest,
|
|
isResponse,
|
|
isHeaders,
|
|
isUndefined,
|
|
isDate,
|
|
isFile,
|
|
isBlob,
|
|
isRegExp,
|
|
isFunction,
|
|
isStream,
|
|
isURLSearchParams,
|
|
isTypedArray,
|
|
isFileList,
|
|
forEach,
|
|
merge,
|
|
extend,
|
|
trim,
|
|
stripBOM,
|
|
inherits,
|
|
toFlatObject,
|
|
kindOf,
|
|
kindOfTest,
|
|
endsWith,
|
|
toArray,
|
|
forEachEntry,
|
|
matchAll,
|
|
isHTMLForm,
|
|
hasOwnProperty: hasOwnProperty$1,
|
|
hasOwnProp: hasOwnProperty$1,
|
|
// an alias to avoid ESLint no-prototype-builtins detection
|
|
reduceDescriptors,
|
|
freezeMethods,
|
|
toObjectSet,
|
|
toCamelCase,
|
|
noop: noop$1,
|
|
toFiniteNumber,
|
|
findKey,
|
|
global: _global,
|
|
isContextDefined,
|
|
isSpecCompliantForm,
|
|
toJSONObject,
|
|
isAsyncFn,
|
|
isThenable,
|
|
setImmediate: _setImmediate,
|
|
asap
|
|
};
|
|
function AxiosError$1(message, code, config, request, response) {
|
|
Error.call(this);
|
|
if (Error.captureStackTrace) {
|
|
Error.captureStackTrace(this, this.constructor);
|
|
} else {
|
|
this.stack = new Error().stack;
|
|
}
|
|
this.message = message;
|
|
this.name = "AxiosError";
|
|
code && (this.code = code);
|
|
config && (this.config = config);
|
|
request && (this.request = request);
|
|
if (response) {
|
|
this.response = response;
|
|
this.status = response.status ? response.status : null;
|
|
}
|
|
}
|
|
utils$1.inherits(AxiosError$1, Error, {
|
|
toJSON: function toJSON() {
|
|
return {
|
|
// Standard
|
|
message: this.message,
|
|
name: this.name,
|
|
// Microsoft
|
|
description: this.description,
|
|
number: this.number,
|
|
// Mozilla
|
|
fileName: this.fileName,
|
|
lineNumber: this.lineNumber,
|
|
columnNumber: this.columnNumber,
|
|
stack: this.stack,
|
|
// Axios
|
|
config: utils$1.toJSONObject(this.config),
|
|
code: this.code,
|
|
status: this.status
|
|
};
|
|
}
|
|
});
|
|
const prototype$1 = AxiosError$1.prototype;
|
|
const descriptors = {};
|
|
[
|
|
"ERR_BAD_OPTION_VALUE",
|
|
"ERR_BAD_OPTION",
|
|
"ECONNABORTED",
|
|
"ETIMEDOUT",
|
|
"ERR_NETWORK",
|
|
"ERR_FR_TOO_MANY_REDIRECTS",
|
|
"ERR_DEPRECATED",
|
|
"ERR_BAD_RESPONSE",
|
|
"ERR_BAD_REQUEST",
|
|
"ERR_CANCELED",
|
|
"ERR_NOT_SUPPORT",
|
|
"ERR_INVALID_URL"
|
|
// eslint-disable-next-line func-names
|
|
].forEach((code) => {
|
|
descriptors[code] = { value: code };
|
|
});
|
|
Object.defineProperties(AxiosError$1, descriptors);
|
|
Object.defineProperty(prototype$1, "isAxiosError", { value: true });
|
|
AxiosError$1.from = (error2, code, config, request, response, customProps) => {
|
|
const axiosError = Object.create(prototype$1);
|
|
utils$1.toFlatObject(error2, axiosError, function filter2(obj) {
|
|
return obj !== Error.prototype;
|
|
}, (prop) => {
|
|
return prop !== "isAxiosError";
|
|
});
|
|
AxiosError$1.call(axiosError, error2.message, code, config, request, response);
|
|
axiosError.cause = error2;
|
|
axiosError.name = error2.name;
|
|
customProps && Object.assign(axiosError, customProps);
|
|
return axiosError;
|
|
};
|
|
const httpAdapter = null;
|
|
function isVisitable(thing) {
|
|
return utils$1.isPlainObject(thing) || utils$1.isArray(thing);
|
|
}
|
|
function removeBrackets(key) {
|
|
return utils$1.endsWith(key, "[]") ? key.slice(0, -2) : key;
|
|
}
|
|
function renderKey(path, key, dots) {
|
|
if (!path) return key;
|
|
return path.concat(key).map(function each(token, i) {
|
|
token = removeBrackets(token);
|
|
return !dots && i ? "[" + token + "]" : token;
|
|
}).join(dots ? "." : "");
|
|
}
|
|
function isFlatArray(arr) {
|
|
return utils$1.isArray(arr) && !arr.some(isVisitable);
|
|
}
|
|
const predicates = utils$1.toFlatObject(utils$1, {}, null, function filter(prop) {
|
|
return /^is[A-Z]/.test(prop);
|
|
});
|
|
function toFormData$1(obj, formData, options) {
|
|
if (!utils$1.isObject(obj)) {
|
|
throw new TypeError("target must be an object");
|
|
}
|
|
formData = formData || new FormData();
|
|
options = utils$1.toFlatObject(options, {
|
|
metaTokens: true,
|
|
dots: false,
|
|
indexes: false
|
|
}, false, function defined(option, source) {
|
|
return !utils$1.isUndefined(source[option]);
|
|
});
|
|
const metaTokens = options.metaTokens;
|
|
const visitor = options.visitor || defaultVisitor;
|
|
const dots = options.dots;
|
|
const indexes = options.indexes;
|
|
const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
|
|
const useBlob = _Blob && utils$1.isSpecCompliantForm(formData);
|
|
if (!utils$1.isFunction(visitor)) {
|
|
throw new TypeError("visitor must be a function");
|
|
}
|
|
function convertValue(value) {
|
|
if (value === null) return "";
|
|
if (utils$1.isDate(value)) {
|
|
return value.toISOString();
|
|
}
|
|
if (!useBlob && utils$1.isBlob(value)) {
|
|
throw new AxiosError$1("Blob is not supported. Use a Buffer instead.");
|
|
}
|
|
if (utils$1.isArrayBuffer(value) || utils$1.isTypedArray(value)) {
|
|
return useBlob && typeof Blob === "function" ? new Blob([value]) : Buffer.from(value);
|
|
}
|
|
return value;
|
|
}
|
|
function defaultVisitor(value, key, path) {
|
|
let arr = value;
|
|
if (value && !path && typeof value === "object") {
|
|
if (utils$1.endsWith(key, "{}")) {
|
|
key = metaTokens ? key : key.slice(0, -2);
|
|
value = JSON.stringify(value);
|
|
} else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
|
|
key = removeBrackets(key);
|
|
arr.forEach(function each(el, index) {
|
|
!(utils$1.isUndefined(el) || el === null) && formData.append(
|
|
// eslint-disable-next-line no-nested-ternary
|
|
indexes === true ? renderKey([key], index, dots) : indexes === null ? key : key + "[]",
|
|
convertValue(el)
|
|
);
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
if (isVisitable(value)) {
|
|
return true;
|
|
}
|
|
formData.append(renderKey(path, key, dots), convertValue(value));
|
|
return false;
|
|
}
|
|
const stack2 = [];
|
|
const exposedHelpers = Object.assign(predicates, {
|
|
defaultVisitor,
|
|
convertValue,
|
|
isVisitable
|
|
});
|
|
function build(value, path) {
|
|
if (utils$1.isUndefined(value)) return;
|
|
if (stack2.indexOf(value) !== -1) {
|
|
throw Error("Circular reference detected in " + path.join("."));
|
|
}
|
|
stack2.push(value);
|
|
utils$1.forEach(value, function each(el, key) {
|
|
const result = !(utils$1.isUndefined(el) || el === null) && visitor.call(
|
|
formData,
|
|
el,
|
|
utils$1.isString(key) ? key.trim() : key,
|
|
path,
|
|
exposedHelpers
|
|
);
|
|
if (result === true) {
|
|
build(el, path ? path.concat(key) : [key]);
|
|
}
|
|
});
|
|
stack2.pop();
|
|
}
|
|
if (!utils$1.isObject(obj)) {
|
|
throw new TypeError("data must be an object");
|
|
}
|
|
build(obj);
|
|
return formData;
|
|
}
|
|
function encode$1(str) {
|
|
const charMap = {
|
|
"!": "%21",
|
|
"'": "%27",
|
|
"(": "%28",
|
|
")": "%29",
|
|
"~": "%7E",
|
|
"%20": "+",
|
|
"%00": "\0"
|
|
};
|
|
return encodeURIComponent(str).replace(/[!'()~]|%20|%00/g, function replacer2(match2) {
|
|
return charMap[match2];
|
|
});
|
|
}
|
|
function AxiosURLSearchParams(params, options) {
|
|
this._pairs = [];
|
|
params && toFormData$1(params, this, options);
|
|
}
|
|
const prototype = AxiosURLSearchParams.prototype;
|
|
prototype.append = function append(name, value) {
|
|
this._pairs.push([name, value]);
|
|
};
|
|
prototype.toString = function toString2(encoder) {
|
|
const _encode = encoder ? function(value) {
|
|
return encoder.call(this, value, encode$1);
|
|
} : encode$1;
|
|
return this._pairs.map(function each(pair) {
|
|
return _encode(pair[0]) + "=" + _encode(pair[1]);
|
|
}, "").join("&");
|
|
};
|
|
function encode(val) {
|
|
return encodeURIComponent(val).replace(/%3A/gi, ":").replace(/%24/g, "$").replace(/%2C/gi, ",").replace(/%20/g, "+").replace(/%5B/gi, "[").replace(/%5D/gi, "]");
|
|
}
|
|
function buildURL(url, params, options) {
|
|
if (!params) {
|
|
return url;
|
|
}
|
|
const _encode = options && options.encode || encode;
|
|
if (utils$1.isFunction(options)) {
|
|
options = {
|
|
serialize: options
|
|
};
|
|
}
|
|
const serializeFn = options && options.serialize;
|
|
let serializedParams;
|
|
if (serializeFn) {
|
|
serializedParams = serializeFn(params, options);
|
|
} else {
|
|
serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, options).toString(_encode);
|
|
}
|
|
if (serializedParams) {
|
|
const hashmarkIndex = url.indexOf("#");
|
|
if (hashmarkIndex !== -1) {
|
|
url = url.slice(0, hashmarkIndex);
|
|
}
|
|
url += (url.indexOf("?") === -1 ? "?" : "&") + serializedParams;
|
|
}
|
|
return url;
|
|
}
|
|
class InterceptorManager {
|
|
constructor() {
|
|
this.handlers = [];
|
|
}
|
|
/**
|
|
* Add a new interceptor to the stack
|
|
*
|
|
* @param {Function} fulfilled The function to handle `then` for a `Promise`
|
|
* @param {Function} rejected The function to handle `reject` for a `Promise`
|
|
*
|
|
* @return {Number} An ID used to remove interceptor later
|
|
*/
|
|
use(fulfilled, rejected, options) {
|
|
this.handlers.push({
|
|
fulfilled,
|
|
rejected,
|
|
synchronous: options ? options.synchronous : false,
|
|
runWhen: options ? options.runWhen : null
|
|
});
|
|
return this.handlers.length - 1;
|
|
}
|
|
/**
|
|
* Remove an interceptor from the stack
|
|
*
|
|
* @param {Number} id The ID that was returned by `use`
|
|
*
|
|
* @returns {Boolean} `true` if the interceptor was removed, `false` otherwise
|
|
*/
|
|
eject(id) {
|
|
if (this.handlers[id]) {
|
|
this.handlers[id] = null;
|
|
}
|
|
}
|
|
/**
|
|
* Clear all interceptors from the stack
|
|
*
|
|
* @returns {void}
|
|
*/
|
|
clear() {
|
|
if (this.handlers) {
|
|
this.handlers = [];
|
|
}
|
|
}
|
|
/**
|
|
* Iterate over all the registered interceptors
|
|
*
|
|
* This method is particularly useful for skipping over any
|
|
* interceptors that may have become `null` calling `eject`.
|
|
*
|
|
* @param {Function} fn The function to call for each interceptor
|
|
*
|
|
* @returns {void}
|
|
*/
|
|
forEach(fn) {
|
|
utils$1.forEach(this.handlers, function forEachHandler(h2) {
|
|
if (h2 !== null) {
|
|
fn(h2);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
const transitionalDefaults = {
|
|
silentJSONParsing: true,
|
|
forcedJSONParsing: true,
|
|
clarifyTimeoutError: false
|
|
};
|
|
const URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
|
|
const FormData$1 = typeof FormData !== "undefined" ? FormData : null;
|
|
const Blob$1 = typeof Blob !== "undefined" ? Blob : null;
|
|
const platform$1 = {
|
|
isBrowser: true,
|
|
classes: {
|
|
URLSearchParams: URLSearchParams$1,
|
|
FormData: FormData$1,
|
|
Blob: Blob$1
|
|
},
|
|
protocols: ["http", "https", "file", "blob", "url", "data"]
|
|
};
|
|
const hasBrowserEnv = typeof window !== "undefined" && typeof document !== "undefined";
|
|
const _navigator = typeof navigator === "object" && navigator || void 0;
|
|
const hasStandardBrowserEnv = hasBrowserEnv && (!_navigator || ["ReactNative", "NativeScript", "NS"].indexOf(_navigator.product) < 0);
|
|
const hasStandardBrowserWebWorkerEnv = (() => {
|
|
return typeof WorkerGlobalScope !== "undefined" && // eslint-disable-next-line no-undef
|
|
self instanceof WorkerGlobalScope && typeof self.importScripts === "function";
|
|
})();
|
|
const origin = hasBrowserEnv && window.location.href || "http://localhost";
|
|
const utils = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
__proto__: null,
|
|
hasBrowserEnv,
|
|
hasStandardBrowserEnv,
|
|
hasStandardBrowserWebWorkerEnv,
|
|
navigator: _navigator,
|
|
origin
|
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
const platform = {
|
|
...utils,
|
|
...platform$1
|
|
};
|
|
function toURLEncodedForm(data, options) {
|
|
return toFormData$1(data, new platform.classes.URLSearchParams(), Object.assign({
|
|
visitor: function(value, key, path, helpers) {
|
|
if (platform.isNode && utils$1.isBuffer(value)) {
|
|
this.append(key, value.toString("base64"));
|
|
return false;
|
|
}
|
|
return helpers.defaultVisitor.apply(this, arguments);
|
|
}
|
|
}, options));
|
|
}
|
|
function parsePropPath(name) {
|
|
return utils$1.matchAll(/\w+|\[(\w*)]/g, name).map((match2) => {
|
|
return match2[0] === "[]" ? "" : match2[1] || match2[0];
|
|
});
|
|
}
|
|
function arrayToObject(arr) {
|
|
const obj = {};
|
|
const keys = Object.keys(arr);
|
|
let i;
|
|
const len = keys.length;
|
|
let key;
|
|
for (i = 0; i < len; i++) {
|
|
key = keys[i];
|
|
obj[key] = arr[key];
|
|
}
|
|
return obj;
|
|
}
|
|
function formDataToJSON(formData) {
|
|
function buildPath(path, value, target, index) {
|
|
let name = path[index++];
|
|
if (name === "__proto__") return true;
|
|
const isNumericKey = Number.isFinite(+name);
|
|
const isLast = index >= path.length;
|
|
name = !name && utils$1.isArray(target) ? target.length : name;
|
|
if (isLast) {
|
|
if (utils$1.hasOwnProp(target, name)) {
|
|
target[name] = [target[name], value];
|
|
} else {
|
|
target[name] = value;
|
|
}
|
|
return !isNumericKey;
|
|
}
|
|
if (!target[name] || !utils$1.isObject(target[name])) {
|
|
target[name] = [];
|
|
}
|
|
const result = buildPath(path, value, target[name], index);
|
|
if (result && utils$1.isArray(target[name])) {
|
|
target[name] = arrayToObject(target[name]);
|
|
}
|
|
return !isNumericKey;
|
|
}
|
|
if (utils$1.isFormData(formData) && utils$1.isFunction(formData.entries)) {
|
|
const obj = {};
|
|
utils$1.forEachEntry(formData, (name, value) => {
|
|
buildPath(parsePropPath(name), value, obj, 0);
|
|
});
|
|
return obj;
|
|
}
|
|
return null;
|
|
}
|
|
function stringifySafely(rawValue, parser, encoder) {
|
|
if (utils$1.isString(rawValue)) {
|
|
try {
|
|
(parser || JSON.parse)(rawValue);
|
|
return utils$1.trim(rawValue);
|
|
} catch (e) {
|
|
if (e.name !== "SyntaxError") {
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
return (encoder || JSON.stringify)(rawValue);
|
|
}
|
|
const defaults = {
|
|
transitional: transitionalDefaults,
|
|
adapter: ["xhr", "http", "fetch"],
|
|
transformRequest: [function transformRequest(data, headers) {
|
|
const contentType = headers.getContentType() || "";
|
|
const hasJSONContentType = contentType.indexOf("application/json") > -1;
|
|
const isObjectPayload = utils$1.isObject(data);
|
|
if (isObjectPayload && utils$1.isHTMLForm(data)) {
|
|
data = new FormData(data);
|
|
}
|
|
const isFormData2 = utils$1.isFormData(data);
|
|
if (isFormData2) {
|
|
return hasJSONContentType ? JSON.stringify(formDataToJSON(data)) : data;
|
|
}
|
|
if (utils$1.isArrayBuffer(data) || utils$1.isBuffer(data) || utils$1.isStream(data) || utils$1.isFile(data) || utils$1.isBlob(data) || utils$1.isReadableStream(data)) {
|
|
return data;
|
|
}
|
|
if (utils$1.isArrayBufferView(data)) {
|
|
return data.buffer;
|
|
}
|
|
if (utils$1.isURLSearchParams(data)) {
|
|
headers.setContentType("application/x-www-form-urlencoded;charset=utf-8", false);
|
|
return data.toString();
|
|
}
|
|
let isFileList2;
|
|
if (isObjectPayload) {
|
|
if (contentType.indexOf("application/x-www-form-urlencoded") > -1) {
|
|
return toURLEncodedForm(data, this.formSerializer).toString();
|
|
}
|
|
if ((isFileList2 = utils$1.isFileList(data)) || contentType.indexOf("multipart/form-data") > -1) {
|
|
const _FormData = this.env && this.env.FormData;
|
|
return toFormData$1(
|
|
isFileList2 ? { "files[]": data } : data,
|
|
_FormData && new _FormData(),
|
|
this.formSerializer
|
|
);
|
|
}
|
|
}
|
|
if (isObjectPayload || hasJSONContentType) {
|
|
headers.setContentType("application/json", false);
|
|
return stringifySafely(data);
|
|
}
|
|
return data;
|
|
}],
|
|
transformResponse: [function transformResponse(data) {
|
|
const transitional2 = this.transitional || defaults.transitional;
|
|
const forcedJSONParsing = transitional2 && transitional2.forcedJSONParsing;
|
|
const JSONRequested = this.responseType === "json";
|
|
if (utils$1.isResponse(data) || utils$1.isReadableStream(data)) {
|
|
return data;
|
|
}
|
|
if (data && utils$1.isString(data) && (forcedJSONParsing && !this.responseType || JSONRequested)) {
|
|
const silentJSONParsing = transitional2 && transitional2.silentJSONParsing;
|
|
const strictJSONParsing = !silentJSONParsing && JSONRequested;
|
|
try {
|
|
return JSON.parse(data);
|
|
} catch (e) {
|
|
if (strictJSONParsing) {
|
|
if (e.name === "SyntaxError") {
|
|
throw AxiosError$1.from(e, AxiosError$1.ERR_BAD_RESPONSE, this, null, this.response);
|
|
}
|
|
throw e;
|
|
}
|
|
}
|
|
}
|
|
return data;
|
|
}],
|
|
/**
|
|
* A timeout in milliseconds to abort a request. If set to 0 (default) a
|
|
* timeout is not created.
|
|
*/
|
|
timeout: 0,
|
|
xsrfCookieName: "XSRF-TOKEN",
|
|
xsrfHeaderName: "X-XSRF-TOKEN",
|
|
maxContentLength: -1,
|
|
maxBodyLength: -1,
|
|
env: {
|
|
FormData: platform.classes.FormData,
|
|
Blob: platform.classes.Blob
|
|
},
|
|
validateStatus: function validateStatus(status) {
|
|
return status >= 200 && status < 300;
|
|
},
|
|
headers: {
|
|
common: {
|
|
"Accept": "application/json, text/plain, */*",
|
|
"Content-Type": void 0
|
|
}
|
|
}
|
|
};
|
|
utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
|
|
defaults.headers[method] = {};
|
|
});
|
|
const ignoreDuplicateOf = utils$1.toObjectSet([
|
|
"age",
|
|
"authorization",
|
|
"content-length",
|
|
"content-type",
|
|
"etag",
|
|
"expires",
|
|
"from",
|
|
"host",
|
|
"if-modified-since",
|
|
"if-unmodified-since",
|
|
"last-modified",
|
|
"location",
|
|
"max-forwards",
|
|
"proxy-authorization",
|
|
"referer",
|
|
"retry-after",
|
|
"user-agent"
|
|
]);
|
|
const parseHeaders = (rawHeaders) => {
|
|
const parsed = {};
|
|
let key;
|
|
let val;
|
|
let i;
|
|
rawHeaders && rawHeaders.split("\n").forEach(function parser(line) {
|
|
i = line.indexOf(":");
|
|
key = line.substring(0, i).trim().toLowerCase();
|
|
val = line.substring(i + 1).trim();
|
|
if (!key || parsed[key] && ignoreDuplicateOf[key]) {
|
|
return;
|
|
}
|
|
if (key === "set-cookie") {
|
|
if (parsed[key]) {
|
|
parsed[key].push(val);
|
|
} else {
|
|
parsed[key] = [val];
|
|
}
|
|
} else {
|
|
parsed[key] = parsed[key] ? parsed[key] + ", " + val : val;
|
|
}
|
|
});
|
|
return parsed;
|
|
};
|
|
const $internals = Symbol("internals");
|
|
function normalizeHeader(header) {
|
|
return header && String(header).trim().toLowerCase();
|
|
}
|
|
function normalizeValue(value) {
|
|
if (value === false || value == null) {
|
|
return value;
|
|
}
|
|
return utils$1.isArray(value) ? value.map(normalizeValue) : String(value);
|
|
}
|
|
function parseTokens(str) {
|
|
const tokens = /* @__PURE__ */ Object.create(null);
|
|
const tokensRE = /([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;
|
|
let match2;
|
|
while (match2 = tokensRE.exec(str)) {
|
|
tokens[match2[1]] = match2[2];
|
|
}
|
|
return tokens;
|
|
}
|
|
const isValidHeaderName = (str) => /^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(str.trim());
|
|
function matchHeaderValue(context, value, header, filter2, isHeaderNameFilter) {
|
|
if (utils$1.isFunction(filter2)) {
|
|
return filter2.call(this, value, header);
|
|
}
|
|
if (isHeaderNameFilter) {
|
|
value = header;
|
|
}
|
|
if (!utils$1.isString(value)) return;
|
|
if (utils$1.isString(filter2)) {
|
|
return value.indexOf(filter2) !== -1;
|
|
}
|
|
if (utils$1.isRegExp(filter2)) {
|
|
return filter2.test(value);
|
|
}
|
|
}
|
|
function formatHeader(header) {
|
|
return header.trim().toLowerCase().replace(/([a-z\d])(\w*)/g, (w, char, str) => {
|
|
return char.toUpperCase() + str;
|
|
});
|
|
}
|
|
function buildAccessors(obj, header) {
|
|
const accessorName = utils$1.toCamelCase(" " + header);
|
|
["get", "set", "has"].forEach((methodName) => {
|
|
Object.defineProperty(obj, methodName + accessorName, {
|
|
value: function(arg1, arg2, arg3) {
|
|
return this[methodName].call(this, header, arg1, arg2, arg3);
|
|
},
|
|
configurable: true
|
|
});
|
|
});
|
|
}
|
|
let AxiosHeaders$1 = class AxiosHeaders {
|
|
constructor(headers) {
|
|
headers && this.set(headers);
|
|
}
|
|
set(header, valueOrRewrite, rewrite) {
|
|
const self2 = this;
|
|
function setHeader(_value, _header, _rewrite) {
|
|
const lHeader = normalizeHeader(_header);
|
|
if (!lHeader) {
|
|
throw new Error("header name must be a non-empty string");
|
|
}
|
|
const key = utils$1.findKey(self2, lHeader);
|
|
if (!key || self2[key] === void 0 || _rewrite === true || _rewrite === void 0 && self2[key] !== false) {
|
|
self2[key || _header] = normalizeValue(_value);
|
|
}
|
|
}
|
|
const setHeaders = (headers, _rewrite) => utils$1.forEach(headers, (_value, _header) => setHeader(_value, _header, _rewrite));
|
|
if (utils$1.isPlainObject(header) || header instanceof this.constructor) {
|
|
setHeaders(header, valueOrRewrite);
|
|
} else if (utils$1.isString(header) && (header = header.trim()) && !isValidHeaderName(header)) {
|
|
setHeaders(parseHeaders(header), valueOrRewrite);
|
|
} else if (utils$1.isHeaders(header)) {
|
|
for (const [key, value] of header.entries()) {
|
|
setHeader(value, key, rewrite);
|
|
}
|
|
} else {
|
|
header != null && setHeader(valueOrRewrite, header, rewrite);
|
|
}
|
|
return this;
|
|
}
|
|
get(header, parser) {
|
|
header = normalizeHeader(header);
|
|
if (header) {
|
|
const key = utils$1.findKey(this, header);
|
|
if (key) {
|
|
const value = this[key];
|
|
if (!parser) {
|
|
return value;
|
|
}
|
|
if (parser === true) {
|
|
return parseTokens(value);
|
|
}
|
|
if (utils$1.isFunction(parser)) {
|
|
return parser.call(this, value, key);
|
|
}
|
|
if (utils$1.isRegExp(parser)) {
|
|
return parser.exec(value);
|
|
}
|
|
throw new TypeError("parser must be boolean|regexp|function");
|
|
}
|
|
}
|
|
}
|
|
has(header, matcher) {
|
|
header = normalizeHeader(header);
|
|
if (header) {
|
|
const key = utils$1.findKey(this, header);
|
|
return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
|
|
}
|
|
return false;
|
|
}
|
|
delete(header, matcher) {
|
|
const self2 = this;
|
|
let deleted = false;
|
|
function deleteHeader(_header) {
|
|
_header = normalizeHeader(_header);
|
|
if (_header) {
|
|
const key = utils$1.findKey(self2, _header);
|
|
if (key && (!matcher || matchHeaderValue(self2, self2[key], key, matcher))) {
|
|
delete self2[key];
|
|
deleted = true;
|
|
}
|
|
}
|
|
}
|
|
if (utils$1.isArray(header)) {
|
|
header.forEach(deleteHeader);
|
|
} else {
|
|
deleteHeader(header);
|
|
}
|
|
return deleted;
|
|
}
|
|
clear(matcher) {
|
|
const keys = Object.keys(this);
|
|
let i = keys.length;
|
|
let deleted = false;
|
|
while (i--) {
|
|
const key = keys[i];
|
|
if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
|
|
delete this[key];
|
|
deleted = true;
|
|
}
|
|
}
|
|
return deleted;
|
|
}
|
|
normalize(format) {
|
|
const self2 = this;
|
|
const headers = {};
|
|
utils$1.forEach(this, (value, header) => {
|
|
const key = utils$1.findKey(headers, header);
|
|
if (key) {
|
|
self2[key] = normalizeValue(value);
|
|
delete self2[header];
|
|
return;
|
|
}
|
|
const normalized = format ? formatHeader(header) : String(header).trim();
|
|
if (normalized !== header) {
|
|
delete self2[header];
|
|
}
|
|
self2[normalized] = normalizeValue(value);
|
|
headers[normalized] = true;
|
|
});
|
|
return this;
|
|
}
|
|
concat(...targets) {
|
|
return this.constructor.concat(this, ...targets);
|
|
}
|
|
toJSON(asStrings) {
|
|
const obj = /* @__PURE__ */ Object.create(null);
|
|
utils$1.forEach(this, (value, header) => {
|
|
value != null && value !== false && (obj[header] = asStrings && utils$1.isArray(value) ? value.join(", ") : value);
|
|
});
|
|
return obj;
|
|
}
|
|
[Symbol.iterator]() {
|
|
return Object.entries(this.toJSON())[Symbol.iterator]();
|
|
}
|
|
toString() {
|
|
return Object.entries(this.toJSON()).map(([header, value]) => header + ": " + value).join("\n");
|
|
}
|
|
get [Symbol.toStringTag]() {
|
|
return "AxiosHeaders";
|
|
}
|
|
static from(thing) {
|
|
return thing instanceof this ? thing : new this(thing);
|
|
}
|
|
static concat(first, ...targets) {
|
|
const computed2 = new this(first);
|
|
targets.forEach((target) => computed2.set(target));
|
|
return computed2;
|
|
}
|
|
static accessor(header) {
|
|
const internals = this[$internals] = this[$internals] = {
|
|
accessors: {}
|
|
};
|
|
const accessors = internals.accessors;
|
|
const prototype2 = this.prototype;
|
|
function defineAccessor(_header) {
|
|
const lHeader = normalizeHeader(_header);
|
|
if (!accessors[lHeader]) {
|
|
buildAccessors(prototype2, _header);
|
|
accessors[lHeader] = true;
|
|
}
|
|
}
|
|
utils$1.isArray(header) ? header.forEach(defineAccessor) : defineAccessor(header);
|
|
return this;
|
|
}
|
|
};
|
|
AxiosHeaders$1.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
|
|
utils$1.reduceDescriptors(AxiosHeaders$1.prototype, ({ value }, key) => {
|
|
let mapped = key[0].toUpperCase() + key.slice(1);
|
|
return {
|
|
get: () => value,
|
|
set(headerValue) {
|
|
this[mapped] = headerValue;
|
|
}
|
|
};
|
|
});
|
|
utils$1.freezeMethods(AxiosHeaders$1);
|
|
function transformData(fns, response) {
|
|
const config = this || defaults;
|
|
const context = response || config;
|
|
const headers = AxiosHeaders$1.from(context.headers);
|
|
let data = context.data;
|
|
utils$1.forEach(fns, function transform(fn) {
|
|
data = fn.call(config, data, headers.normalize(), response ? response.status : void 0);
|
|
});
|
|
headers.normalize();
|
|
return data;
|
|
}
|
|
function isCancel$1(value) {
|
|
return !!(value && value.__CANCEL__);
|
|
}
|
|
function CanceledError$1(message, config, request) {
|
|
AxiosError$1.call(this, message == null ? "canceled" : message, AxiosError$1.ERR_CANCELED, config, request);
|
|
this.name = "CanceledError";
|
|
}
|
|
utils$1.inherits(CanceledError$1, AxiosError$1, {
|
|
__CANCEL__: true
|
|
});
|
|
function settle(resolve2, reject, response) {
|
|
const validateStatus2 = response.config.validateStatus;
|
|
if (!response.status || !validateStatus2 || validateStatus2(response.status)) {
|
|
resolve2(response);
|
|
} else {
|
|
reject(new AxiosError$1(
|
|
"Request failed with status code " + response.status,
|
|
[AxiosError$1.ERR_BAD_REQUEST, AxiosError$1.ERR_BAD_RESPONSE][Math.floor(response.status / 100) - 4],
|
|
response.config,
|
|
response.request,
|
|
response
|
|
));
|
|
}
|
|
}
|
|
function parseProtocol(url) {
|
|
const match2 = /^([-+\w]{1,25})(:?\/\/|:)/.exec(url);
|
|
return match2 && match2[1] || "";
|
|
}
|
|
function speedometer(samplesCount, min) {
|
|
samplesCount = samplesCount || 10;
|
|
const bytes = new Array(samplesCount);
|
|
const timestamps = new Array(samplesCount);
|
|
let head = 0;
|
|
let tail = 0;
|
|
let firstSampleTS;
|
|
min = min !== void 0 ? min : 1e3;
|
|
return function push(chunkLength) {
|
|
const now = Date.now();
|
|
const startedAt = timestamps[tail];
|
|
if (!firstSampleTS) {
|
|
firstSampleTS = now;
|
|
}
|
|
bytes[head] = chunkLength;
|
|
timestamps[head] = now;
|
|
let i = tail;
|
|
let bytesCount = 0;
|
|
while (i !== head) {
|
|
bytesCount += bytes[i++];
|
|
i = i % samplesCount;
|
|
}
|
|
head = (head + 1) % samplesCount;
|
|
if (head === tail) {
|
|
tail = (tail + 1) % samplesCount;
|
|
}
|
|
if (now - firstSampleTS < min) {
|
|
return;
|
|
}
|
|
const passed = startedAt && now - startedAt;
|
|
return passed ? Math.round(bytesCount * 1e3 / passed) : void 0;
|
|
};
|
|
}
|
|
function throttle(fn, freq) {
|
|
let timestamp = 0;
|
|
let threshold = 1e3 / freq;
|
|
let lastArgs;
|
|
let timer;
|
|
const invoke = (args, now = Date.now()) => {
|
|
timestamp = now;
|
|
lastArgs = null;
|
|
if (timer) {
|
|
clearTimeout(timer);
|
|
timer = null;
|
|
}
|
|
fn.apply(null, args);
|
|
};
|
|
const throttled = (...args) => {
|
|
const now = Date.now();
|
|
const passed = now - timestamp;
|
|
if (passed >= threshold) {
|
|
invoke(args, now);
|
|
} else {
|
|
lastArgs = args;
|
|
if (!timer) {
|
|
timer = setTimeout(() => {
|
|
timer = null;
|
|
invoke(lastArgs);
|
|
}, threshold - passed);
|
|
}
|
|
}
|
|
};
|
|
const flush = () => lastArgs && invoke(lastArgs);
|
|
return [throttled, flush];
|
|
}
|
|
const progressEventReducer = (listener, isDownloadStream, freq = 3) => {
|
|
let bytesNotified = 0;
|
|
const _speedometer = speedometer(50, 250);
|
|
return throttle((e) => {
|
|
const loaded = e.loaded;
|
|
const total = e.lengthComputable ? e.total : void 0;
|
|
const progressBytes = loaded - bytesNotified;
|
|
const rate = _speedometer(progressBytes);
|
|
const inRange = loaded <= total;
|
|
bytesNotified = loaded;
|
|
const data = {
|
|
loaded,
|
|
total,
|
|
progress: total ? loaded / total : void 0,
|
|
bytes: progressBytes,
|
|
rate: rate ? rate : void 0,
|
|
estimated: rate && total && inRange ? (total - loaded) / rate : void 0,
|
|
event: e,
|
|
lengthComputable: total != null,
|
|
[isDownloadStream ? "download" : "upload"]: true
|
|
};
|
|
listener(data);
|
|
}, freq);
|
|
};
|
|
const progressEventDecorator = (total, throttled) => {
|
|
const lengthComputable = total != null;
|
|
return [(loaded) => throttled[0]({
|
|
lengthComputable,
|
|
total,
|
|
loaded
|
|
}), throttled[1]];
|
|
};
|
|
const asyncDecorator = (fn) => (...args) => utils$1.asap(() => fn(...args));
|
|
const isURLSameOrigin = platform.hasStandardBrowserEnv ? /* @__PURE__ */ ((origin2, isMSIE) => (url) => {
|
|
url = new URL(url, platform.origin);
|
|
return origin2.protocol === url.protocol && origin2.host === url.host && (isMSIE || origin2.port === url.port);
|
|
})(
|
|
new URL(platform.origin),
|
|
platform.navigator && /(msie|trident)/i.test(platform.navigator.userAgent)
|
|
) : () => true;
|
|
const cookies = platform.hasStandardBrowserEnv ? (
|
|
// Standard browser envs support document.cookie
|
|
{
|
|
write(name, value, expires, path, domain, secure) {
|
|
const cookie = [name + "=" + encodeURIComponent(value)];
|
|
utils$1.isNumber(expires) && cookie.push("expires=" + new Date(expires).toGMTString());
|
|
utils$1.isString(path) && cookie.push("path=" + path);
|
|
utils$1.isString(domain) && cookie.push("domain=" + domain);
|
|
secure === true && cookie.push("secure");
|
|
document.cookie = cookie.join("; ");
|
|
},
|
|
read(name) {
|
|
const match2 = document.cookie.match(new RegExp("(^|;\\s*)(" + name + ")=([^;]*)"));
|
|
return match2 ? decodeURIComponent(match2[3]) : null;
|
|
},
|
|
remove(name) {
|
|
this.write(name, "", Date.now() - 864e5);
|
|
}
|
|
}
|
|
) : (
|
|
// Non-standard browser env (web workers, react-native) lack needed support.
|
|
{
|
|
write() {
|
|
},
|
|
read() {
|
|
return null;
|
|
},
|
|
remove() {
|
|
}
|
|
}
|
|
);
|
|
function isAbsoluteURL(url) {
|
|
return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
|
|
}
|
|
function combineURLs(baseURL, relativeURL) {
|
|
return relativeURL ? baseURL.replace(/\/?\/$/, "") + "/" + relativeURL.replace(/^\/+/, "") : baseURL;
|
|
}
|
|
function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
let isRelativeUrl = !isAbsoluteURL(requestedURL);
|
|
if (baseURL && (isRelativeUrl || allowAbsoluteUrls == false)) {
|
|
return combineURLs(baseURL, requestedURL);
|
|
}
|
|
return requestedURL;
|
|
}
|
|
const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
|
|
function mergeConfig$1(config1, config2) {
|
|
config2 = config2 || {};
|
|
const config = {};
|
|
function getMergedValue(target, source, prop, caseless) {
|
|
if (utils$1.isPlainObject(target) && utils$1.isPlainObject(source)) {
|
|
return utils$1.merge.call({ caseless }, target, source);
|
|
} else if (utils$1.isPlainObject(source)) {
|
|
return utils$1.merge({}, source);
|
|
} else if (utils$1.isArray(source)) {
|
|
return source.slice();
|
|
}
|
|
return source;
|
|
}
|
|
function mergeDeepProperties(a, b, prop, caseless) {
|
|
if (!utils$1.isUndefined(b)) {
|
|
return getMergedValue(a, b, prop, caseless);
|
|
} else if (!utils$1.isUndefined(a)) {
|
|
return getMergedValue(void 0, a, prop, caseless);
|
|
}
|
|
}
|
|
function valueFromConfig2(a, b) {
|
|
if (!utils$1.isUndefined(b)) {
|
|
return getMergedValue(void 0, b);
|
|
}
|
|
}
|
|
function defaultToConfig2(a, b) {
|
|
if (!utils$1.isUndefined(b)) {
|
|
return getMergedValue(void 0, b);
|
|
} else if (!utils$1.isUndefined(a)) {
|
|
return getMergedValue(void 0, a);
|
|
}
|
|
}
|
|
function mergeDirectKeys(a, b, prop) {
|
|
if (prop in config2) {
|
|
return getMergedValue(a, b);
|
|
} else if (prop in config1) {
|
|
return getMergedValue(void 0, a);
|
|
}
|
|
}
|
|
const mergeMap = {
|
|
url: valueFromConfig2,
|
|
method: valueFromConfig2,
|
|
data: valueFromConfig2,
|
|
baseURL: defaultToConfig2,
|
|
transformRequest: defaultToConfig2,
|
|
transformResponse: defaultToConfig2,
|
|
paramsSerializer: defaultToConfig2,
|
|
timeout: defaultToConfig2,
|
|
timeoutMessage: defaultToConfig2,
|
|
withCredentials: defaultToConfig2,
|
|
withXSRFToken: defaultToConfig2,
|
|
adapter: defaultToConfig2,
|
|
responseType: defaultToConfig2,
|
|
xsrfCookieName: defaultToConfig2,
|
|
xsrfHeaderName: defaultToConfig2,
|
|
onUploadProgress: defaultToConfig2,
|
|
onDownloadProgress: defaultToConfig2,
|
|
decompress: defaultToConfig2,
|
|
maxContentLength: defaultToConfig2,
|
|
maxBodyLength: defaultToConfig2,
|
|
beforeRedirect: defaultToConfig2,
|
|
transport: defaultToConfig2,
|
|
httpAgent: defaultToConfig2,
|
|
httpsAgent: defaultToConfig2,
|
|
cancelToken: defaultToConfig2,
|
|
socketPath: defaultToConfig2,
|
|
responseEncoding: defaultToConfig2,
|
|
validateStatus: mergeDirectKeys,
|
|
headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
|
|
};
|
|
utils$1.forEach(Object.keys(Object.assign({}, config1, config2)), function computeConfigValue(prop) {
|
|
const merge2 = mergeMap[prop] || mergeDeepProperties;
|
|
const configValue = merge2(config1[prop], config2[prop], prop);
|
|
utils$1.isUndefined(configValue) && merge2 !== mergeDirectKeys || (config[prop] = configValue);
|
|
});
|
|
return config;
|
|
}
|
|
const resolveConfig = (config) => {
|
|
const newConfig = mergeConfig$1({}, config);
|
|
let { data, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
|
|
newConfig.headers = headers = AxiosHeaders$1.from(headers);
|
|
newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url, newConfig.allowAbsoluteUrls), config.params, config.paramsSerializer);
|
|
if (auth) {
|
|
headers.set(
|
|
"Authorization",
|
|
"Basic " + btoa((auth.username || "") + ":" + (auth.password ? unescape(encodeURIComponent(auth.password)) : ""))
|
|
);
|
|
}
|
|
let contentType;
|
|
if (utils$1.isFormData(data)) {
|
|
if (platform.hasStandardBrowserEnv || platform.hasStandardBrowserWebWorkerEnv) {
|
|
headers.setContentType(void 0);
|
|
} else if ((contentType = headers.getContentType()) !== false) {
|
|
const [type, ...tokens] = contentType ? contentType.split(";").map((token) => token.trim()).filter(Boolean) : [];
|
|
headers.setContentType([type || "multipart/form-data", ...tokens].join("; "));
|
|
}
|
|
}
|
|
if (platform.hasStandardBrowserEnv) {
|
|
withXSRFToken && utils$1.isFunction(withXSRFToken) && (withXSRFToken = withXSRFToken(newConfig));
|
|
if (withXSRFToken || withXSRFToken !== false && isURLSameOrigin(newConfig.url)) {
|
|
const xsrfValue = xsrfHeaderName && xsrfCookieName && cookies.read(xsrfCookieName);
|
|
if (xsrfValue) {
|
|
headers.set(xsrfHeaderName, xsrfValue);
|
|
}
|
|
}
|
|
}
|
|
return newConfig;
|
|
};
|
|
const isXHRAdapterSupported = typeof XMLHttpRequest !== "undefined";
|
|
const xhrAdapter = isXHRAdapterSupported && function(config) {
|
|
return new Promise(function dispatchXhrRequest(resolve2, reject) {
|
|
const _config = resolveConfig(config);
|
|
let requestData = _config.data;
|
|
const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
|
|
let { responseType, onUploadProgress, onDownloadProgress } = _config;
|
|
let onCanceled;
|
|
let uploadThrottled, downloadThrottled;
|
|
let flushUpload, flushDownload;
|
|
function done() {
|
|
flushUpload && flushUpload();
|
|
flushDownload && flushDownload();
|
|
_config.cancelToken && _config.cancelToken.unsubscribe(onCanceled);
|
|
_config.signal && _config.signal.removeEventListener("abort", onCanceled);
|
|
}
|
|
let request = new XMLHttpRequest();
|
|
request.open(_config.method.toUpperCase(), _config.url, true);
|
|
request.timeout = _config.timeout;
|
|
function onloadend() {
|
|
if (!request) {
|
|
return;
|
|
}
|
|
const responseHeaders = AxiosHeaders$1.from(
|
|
"getAllResponseHeaders" in request && request.getAllResponseHeaders()
|
|
);
|
|
const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
|
|
const response = {
|
|
data: responseData,
|
|
status: request.status,
|
|
statusText: request.statusText,
|
|
headers: responseHeaders,
|
|
config,
|
|
request
|
|
};
|
|
settle(function _resolve(value) {
|
|
resolve2(value);
|
|
done();
|
|
}, function _reject(err) {
|
|
reject(err);
|
|
done();
|
|
}, response);
|
|
request = null;
|
|
}
|
|
if ("onloadend" in request) {
|
|
request.onloadend = onloadend;
|
|
} else {
|
|
request.onreadystatechange = function handleLoad() {
|
|
if (!request || request.readyState !== 4) {
|
|
return;
|
|
}
|
|
if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf("file:") === 0)) {
|
|
return;
|
|
}
|
|
setTimeout(onloadend);
|
|
};
|
|
}
|
|
request.onabort = function handleAbort() {
|
|
if (!request) {
|
|
return;
|
|
}
|
|
reject(new AxiosError$1("Request aborted", AxiosError$1.ECONNABORTED, config, request));
|
|
request = null;
|
|
};
|
|
request.onerror = function handleError2() {
|
|
reject(new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request));
|
|
request = null;
|
|
};
|
|
request.ontimeout = function handleTimeout() {
|
|
let timeoutErrorMessage = _config.timeout ? "timeout of " + _config.timeout + "ms exceeded" : "timeout exceeded";
|
|
const transitional2 = _config.transitional || transitionalDefaults;
|
|
if (_config.timeoutErrorMessage) {
|
|
timeoutErrorMessage = _config.timeoutErrorMessage;
|
|
}
|
|
reject(new AxiosError$1(
|
|
timeoutErrorMessage,
|
|
transitional2.clarifyTimeoutError ? AxiosError$1.ETIMEDOUT : AxiosError$1.ECONNABORTED,
|
|
config,
|
|
request
|
|
));
|
|
request = null;
|
|
};
|
|
requestData === void 0 && requestHeaders.setContentType(null);
|
|
if ("setRequestHeader" in request) {
|
|
utils$1.forEach(requestHeaders.toJSON(), function setRequestHeader(val, key) {
|
|
request.setRequestHeader(key, val);
|
|
});
|
|
}
|
|
if (!utils$1.isUndefined(_config.withCredentials)) {
|
|
request.withCredentials = !!_config.withCredentials;
|
|
}
|
|
if (responseType && responseType !== "json") {
|
|
request.responseType = _config.responseType;
|
|
}
|
|
if (onDownloadProgress) {
|
|
[downloadThrottled, flushDownload] = progressEventReducer(onDownloadProgress, true);
|
|
request.addEventListener("progress", downloadThrottled);
|
|
}
|
|
if (onUploadProgress && request.upload) {
|
|
[uploadThrottled, flushUpload] = progressEventReducer(onUploadProgress);
|
|
request.upload.addEventListener("progress", uploadThrottled);
|
|
request.upload.addEventListener("loadend", flushUpload);
|
|
}
|
|
if (_config.cancelToken || _config.signal) {
|
|
onCanceled = (cancel) => {
|
|
if (!request) {
|
|
return;
|
|
}
|
|
reject(!cancel || cancel.type ? new CanceledError$1(null, config, request) : cancel);
|
|
request.abort();
|
|
request = null;
|
|
};
|
|
_config.cancelToken && _config.cancelToken.subscribe(onCanceled);
|
|
if (_config.signal) {
|
|
_config.signal.aborted ? onCanceled() : _config.signal.addEventListener("abort", onCanceled);
|
|
}
|
|
}
|
|
const protocol = parseProtocol(_config.url);
|
|
if (protocol && platform.protocols.indexOf(protocol) === -1) {
|
|
reject(new AxiosError$1("Unsupported protocol " + protocol + ":", AxiosError$1.ERR_BAD_REQUEST, config));
|
|
return;
|
|
}
|
|
request.send(requestData || null);
|
|
});
|
|
};
|
|
const composeSignals = (signals, timeout2) => {
|
|
const { length } = signals = signals ? signals.filter(Boolean) : [];
|
|
if (timeout2 || length) {
|
|
let controller = new AbortController();
|
|
let aborted;
|
|
const onabort = function(reason) {
|
|
if (!aborted) {
|
|
aborted = true;
|
|
unsubscribe();
|
|
const err = reason instanceof Error ? reason : this.reason;
|
|
controller.abort(err instanceof AxiosError$1 ? err : new CanceledError$1(err instanceof Error ? err.message : err));
|
|
}
|
|
};
|
|
let timer = timeout2 && setTimeout(() => {
|
|
timer = null;
|
|
onabort(new AxiosError$1(`timeout ${timeout2} of ms exceeded`, AxiosError$1.ETIMEDOUT));
|
|
}, timeout2);
|
|
const unsubscribe = () => {
|
|
if (signals) {
|
|
timer && clearTimeout(timer);
|
|
timer = null;
|
|
signals.forEach((signal2) => {
|
|
signal2.unsubscribe ? signal2.unsubscribe(onabort) : signal2.removeEventListener("abort", onabort);
|
|
});
|
|
signals = null;
|
|
}
|
|
};
|
|
signals.forEach((signal2) => signal2.addEventListener("abort", onabort));
|
|
const { signal } = controller;
|
|
signal.unsubscribe = () => utils$1.asap(unsubscribe);
|
|
return signal;
|
|
}
|
|
};
|
|
const streamChunk = function* (chunk, chunkSize) {
|
|
let len = chunk.byteLength;
|
|
if (len < chunkSize) {
|
|
yield chunk;
|
|
return;
|
|
}
|
|
let pos = 0;
|
|
let end;
|
|
while (pos < len) {
|
|
end = pos + chunkSize;
|
|
yield chunk.slice(pos, end);
|
|
pos = end;
|
|
}
|
|
};
|
|
const readBytes = async function* (iterable, chunkSize) {
|
|
for await (const chunk of readStream(iterable)) {
|
|
yield* streamChunk(chunk, chunkSize);
|
|
}
|
|
};
|
|
const readStream = async function* (stream) {
|
|
if (stream[Symbol.asyncIterator]) {
|
|
yield* stream;
|
|
return;
|
|
}
|
|
const reader = stream.getReader();
|
|
try {
|
|
for (; ; ) {
|
|
const { done, value } = await reader.read();
|
|
if (done) {
|
|
break;
|
|
}
|
|
yield value;
|
|
}
|
|
} finally {
|
|
await reader.cancel();
|
|
}
|
|
};
|
|
const trackStream = (stream, chunkSize, onProgress, onFinish) => {
|
|
const iterator2 = readBytes(stream, chunkSize);
|
|
let bytes = 0;
|
|
let done;
|
|
let _onFinish = (e) => {
|
|
if (!done) {
|
|
done = true;
|
|
onFinish && onFinish(e);
|
|
}
|
|
};
|
|
return new ReadableStream({
|
|
async pull(controller) {
|
|
try {
|
|
const { done: done2, value } = await iterator2.next();
|
|
if (done2) {
|
|
_onFinish();
|
|
controller.close();
|
|
return;
|
|
}
|
|
let len = value.byteLength;
|
|
if (onProgress) {
|
|
let loadedBytes = bytes += len;
|
|
onProgress(loadedBytes);
|
|
}
|
|
controller.enqueue(new Uint8Array(value));
|
|
} catch (err) {
|
|
_onFinish(err);
|
|
throw err;
|
|
}
|
|
},
|
|
cancel(reason) {
|
|
_onFinish(reason);
|
|
return iterator2.return();
|
|
}
|
|
}, {
|
|
highWaterMark: 2
|
|
});
|
|
};
|
|
const isFetchSupported = typeof fetch === "function" && typeof Request === "function" && typeof Response === "function";
|
|
const isReadableStreamSupported = isFetchSupported && typeof ReadableStream === "function";
|
|
const encodeText = isFetchSupported && (typeof TextEncoder === "function" ? /* @__PURE__ */ ((encoder) => (str) => encoder.encode(str))(new TextEncoder()) : async (str) => new Uint8Array(await new Response(str).arrayBuffer()));
|
|
const test = (fn, ...args) => {
|
|
try {
|
|
return !!fn(...args);
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
};
|
|
const supportsRequestStream = isReadableStreamSupported && test(() => {
|
|
let duplexAccessed = false;
|
|
const hasContentType = new Request(platform.origin, {
|
|
body: new ReadableStream(),
|
|
method: "POST",
|
|
get duplex() {
|
|
duplexAccessed = true;
|
|
return "half";
|
|
}
|
|
}).headers.has("Content-Type");
|
|
return duplexAccessed && !hasContentType;
|
|
});
|
|
const DEFAULT_CHUNK_SIZE = 64 * 1024;
|
|
const supportsResponseStream = isReadableStreamSupported && test(() => utils$1.isReadableStream(new Response("").body));
|
|
const resolvers = {
|
|
stream: supportsResponseStream && ((res) => res.body)
|
|
};
|
|
isFetchSupported && ((res) => {
|
|
["text", "arrayBuffer", "blob", "formData", "stream"].forEach((type) => {
|
|
!resolvers[type] && (resolvers[type] = utils$1.isFunction(res[type]) ? (res2) => res2[type]() : (_, config) => {
|
|
throw new AxiosError$1(`Response type '${type}' is not supported`, AxiosError$1.ERR_NOT_SUPPORT, config);
|
|
});
|
|
});
|
|
})(new Response());
|
|
const getBodyLength = async (body) => {
|
|
if (body == null) {
|
|
return 0;
|
|
}
|
|
if (utils$1.isBlob(body)) {
|
|
return body.size;
|
|
}
|
|
if (utils$1.isSpecCompliantForm(body)) {
|
|
const _request = new Request(platform.origin, {
|
|
method: "POST",
|
|
body
|
|
});
|
|
return (await _request.arrayBuffer()).byteLength;
|
|
}
|
|
if (utils$1.isArrayBufferView(body) || utils$1.isArrayBuffer(body)) {
|
|
return body.byteLength;
|
|
}
|
|
if (utils$1.isURLSearchParams(body)) {
|
|
body = body + "";
|
|
}
|
|
if (utils$1.isString(body)) {
|
|
return (await encodeText(body)).byteLength;
|
|
}
|
|
};
|
|
const resolveBodyLength = async (headers, body) => {
|
|
const length = utils$1.toFiniteNumber(headers.getContentLength());
|
|
return length == null ? getBodyLength(body) : length;
|
|
};
|
|
const fetchAdapter = isFetchSupported && (async (config) => {
|
|
let {
|
|
url,
|
|
method,
|
|
data,
|
|
signal,
|
|
cancelToken,
|
|
timeout: timeout2,
|
|
onDownloadProgress,
|
|
onUploadProgress,
|
|
responseType,
|
|
headers,
|
|
withCredentials = "same-origin",
|
|
fetchOptions
|
|
} = resolveConfig(config);
|
|
responseType = responseType ? (responseType + "").toLowerCase() : "text";
|
|
let composedSignal = composeSignals([signal, cancelToken && cancelToken.toAbortSignal()], timeout2);
|
|
let request;
|
|
const unsubscribe = composedSignal && composedSignal.unsubscribe && (() => {
|
|
composedSignal.unsubscribe();
|
|
});
|
|
let requestContentLength;
|
|
try {
|
|
if (onUploadProgress && supportsRequestStream && method !== "get" && method !== "head" && (requestContentLength = await resolveBodyLength(headers, data)) !== 0) {
|
|
let _request = new Request(url, {
|
|
method: "POST",
|
|
body: data,
|
|
duplex: "half"
|
|
});
|
|
let contentTypeHeader;
|
|
if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get("content-type"))) {
|
|
headers.setContentType(contentTypeHeader);
|
|
}
|
|
if (_request.body) {
|
|
const [onProgress, flush] = progressEventDecorator(
|
|
requestContentLength,
|
|
progressEventReducer(asyncDecorator(onUploadProgress))
|
|
);
|
|
data = trackStream(_request.body, DEFAULT_CHUNK_SIZE, onProgress, flush);
|
|
}
|
|
}
|
|
if (!utils$1.isString(withCredentials)) {
|
|
withCredentials = withCredentials ? "include" : "omit";
|
|
}
|
|
const isCredentialsSupported = "credentials" in Request.prototype;
|
|
request = new Request(url, {
|
|
...fetchOptions,
|
|
signal: composedSignal,
|
|
method: method.toUpperCase(),
|
|
headers: headers.normalize().toJSON(),
|
|
body: data,
|
|
duplex: "half",
|
|
credentials: isCredentialsSupported ? withCredentials : void 0
|
|
});
|
|
let response = await fetch(request);
|
|
const isStreamResponse = supportsResponseStream && (responseType === "stream" || responseType === "response");
|
|
if (supportsResponseStream && (onDownloadProgress || isStreamResponse && unsubscribe)) {
|
|
const options = {};
|
|
["status", "statusText", "headers"].forEach((prop) => {
|
|
options[prop] = response[prop];
|
|
});
|
|
const responseContentLength = utils$1.toFiniteNumber(response.headers.get("content-length"));
|
|
const [onProgress, flush] = onDownloadProgress && progressEventDecorator(
|
|
responseContentLength,
|
|
progressEventReducer(asyncDecorator(onDownloadProgress), true)
|
|
) || [];
|
|
response = new Response(
|
|
trackStream(response.body, DEFAULT_CHUNK_SIZE, onProgress, () => {
|
|
flush && flush();
|
|
unsubscribe && unsubscribe();
|
|
}),
|
|
options
|
|
);
|
|
}
|
|
responseType = responseType || "text";
|
|
let responseData = await resolvers[utils$1.findKey(resolvers, responseType) || "text"](response, config);
|
|
!isStreamResponse && unsubscribe && unsubscribe();
|
|
return await new Promise((resolve2, reject) => {
|
|
settle(resolve2, reject, {
|
|
data: responseData,
|
|
headers: AxiosHeaders$1.from(response.headers),
|
|
status: response.status,
|
|
statusText: response.statusText,
|
|
config,
|
|
request
|
|
});
|
|
});
|
|
} catch (err) {
|
|
unsubscribe && unsubscribe();
|
|
if (err && err.name === "TypeError" && /fetch/i.test(err.message)) {
|
|
throw Object.assign(
|
|
new AxiosError$1("Network Error", AxiosError$1.ERR_NETWORK, config, request),
|
|
{
|
|
cause: err.cause || err
|
|
}
|
|
);
|
|
}
|
|
throw AxiosError$1.from(err, err && err.code, config, request);
|
|
}
|
|
});
|
|
const knownAdapters = {
|
|
http: httpAdapter,
|
|
xhr: xhrAdapter,
|
|
fetch: fetchAdapter
|
|
};
|
|
utils$1.forEach(knownAdapters, (fn, value) => {
|
|
if (fn) {
|
|
try {
|
|
Object.defineProperty(fn, "name", { value });
|
|
} catch (e) {
|
|
}
|
|
Object.defineProperty(fn, "adapterName", { value });
|
|
}
|
|
});
|
|
const renderReason = (reason) => `- ${reason}`;
|
|
const isResolvedHandle = (adapter) => utils$1.isFunction(adapter) || adapter === null || adapter === false;
|
|
const adapters = {
|
|
getAdapter: (adapters2) => {
|
|
adapters2 = utils$1.isArray(adapters2) ? adapters2 : [adapters2];
|
|
const { length } = adapters2;
|
|
let nameOrAdapter;
|
|
let adapter;
|
|
const rejectedReasons = {};
|
|
for (let i = 0; i < length; i++) {
|
|
nameOrAdapter = adapters2[i];
|
|
let id;
|
|
adapter = nameOrAdapter;
|
|
if (!isResolvedHandle(nameOrAdapter)) {
|
|
adapter = knownAdapters[(id = String(nameOrAdapter)).toLowerCase()];
|
|
if (adapter === void 0) {
|
|
throw new AxiosError$1(`Unknown adapter '${id}'`);
|
|
}
|
|
}
|
|
if (adapter) {
|
|
break;
|
|
}
|
|
rejectedReasons[id || "#" + i] = adapter;
|
|
}
|
|
if (!adapter) {
|
|
const reasons = Object.entries(rejectedReasons).map(
|
|
([id, state]) => `adapter ${id} ` + (state === false ? "is not supported by the environment" : "is not available in the build")
|
|
);
|
|
let s = length ? reasons.length > 1 ? "since :\n" + reasons.map(renderReason).join("\n") : " " + renderReason(reasons[0]) : "as no adapter specified";
|
|
throw new AxiosError$1(
|
|
`There is no suitable adapter to dispatch the request ` + s,
|
|
"ERR_NOT_SUPPORT"
|
|
);
|
|
}
|
|
return adapter;
|
|
},
|
|
adapters: knownAdapters
|
|
};
|
|
function throwIfCancellationRequested(config) {
|
|
if (config.cancelToken) {
|
|
config.cancelToken.throwIfRequested();
|
|
}
|
|
if (config.signal && config.signal.aborted) {
|
|
throw new CanceledError$1(null, config);
|
|
}
|
|
}
|
|
function dispatchRequest(config) {
|
|
throwIfCancellationRequested(config);
|
|
config.headers = AxiosHeaders$1.from(config.headers);
|
|
config.data = transformData.call(
|
|
config,
|
|
config.transformRequest
|
|
);
|
|
if (["post", "put", "patch"].indexOf(config.method) !== -1) {
|
|
config.headers.setContentType("application/x-www-form-urlencoded", false);
|
|
}
|
|
const adapter = adapters.getAdapter(config.adapter || defaults.adapter);
|
|
return adapter(config).then(function onAdapterResolution(response) {
|
|
throwIfCancellationRequested(config);
|
|
response.data = transformData.call(
|
|
config,
|
|
config.transformResponse,
|
|
response
|
|
);
|
|
response.headers = AxiosHeaders$1.from(response.headers);
|
|
return response;
|
|
}, function onAdapterRejection(reason) {
|
|
if (!isCancel$1(reason)) {
|
|
throwIfCancellationRequested(config);
|
|
if (reason && reason.response) {
|
|
reason.response.data = transformData.call(
|
|
config,
|
|
config.transformResponse,
|
|
reason.response
|
|
);
|
|
reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
|
|
}
|
|
}
|
|
return Promise.reject(reason);
|
|
});
|
|
}
|
|
const VERSION$1 = "1.8.4";
|
|
const validators$1 = {};
|
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
|
|
validators$1[type] = function validator2(thing) {
|
|
return typeof thing === type || "a" + (i < 1 ? "n " : " ") + type;
|
|
};
|
|
});
|
|
const deprecatedWarnings = {};
|
|
validators$1.transitional = function transitional(validator2, version2, message) {
|
|
function formatMessage(opt, desc) {
|
|
return "[Axios v" + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? ". " + message : "");
|
|
}
|
|
return (value, opt, opts) => {
|
|
if (validator2 === false) {
|
|
throw new AxiosError$1(
|
|
formatMessage(opt, " has been removed" + (version2 ? " in " + version2 : "")),
|
|
AxiosError$1.ERR_DEPRECATED
|
|
);
|
|
}
|
|
if (version2 && !deprecatedWarnings[opt]) {
|
|
deprecatedWarnings[opt] = true;
|
|
console.warn(
|
|
formatMessage(
|
|
opt,
|
|
" has been deprecated since v" + version2 + " and will be removed in the near future"
|
|
)
|
|
);
|
|
}
|
|
return validator2 ? validator2(value, opt, opts) : true;
|
|
};
|
|
};
|
|
validators$1.spelling = function spelling(correctSpelling) {
|
|
return (value, opt) => {
|
|
console.warn(`${opt} is likely a misspelling of ${correctSpelling}`);
|
|
return true;
|
|
};
|
|
};
|
|
function assertOptions(options, schema, allowUnknown) {
|
|
if (typeof options !== "object") {
|
|
throw new AxiosError$1("options must be an object", AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
}
|
|
const keys = Object.keys(options);
|
|
let i = keys.length;
|
|
while (i-- > 0) {
|
|
const opt = keys[i];
|
|
const validator2 = schema[opt];
|
|
if (validator2) {
|
|
const value = options[opt];
|
|
const result = value === void 0 || validator2(value, opt, options);
|
|
if (result !== true) {
|
|
throw new AxiosError$1("option " + opt + " must be " + result, AxiosError$1.ERR_BAD_OPTION_VALUE);
|
|
}
|
|
continue;
|
|
}
|
|
if (allowUnknown !== true) {
|
|
throw new AxiosError$1("Unknown option " + opt, AxiosError$1.ERR_BAD_OPTION);
|
|
}
|
|
}
|
|
}
|
|
const validator = {
|
|
assertOptions,
|
|
validators: validators$1
|
|
};
|
|
const validators = validator.validators;
|
|
let Axios$1 = class Axios {
|
|
constructor(instanceConfig) {
|
|
this.defaults = instanceConfig;
|
|
this.interceptors = {
|
|
request: new InterceptorManager(),
|
|
response: new InterceptorManager()
|
|
};
|
|
}
|
|
/**
|
|
* Dispatch a request
|
|
*
|
|
* @param {String|Object} configOrUrl The config specific for this request (merged with this.defaults)
|
|
* @param {?Object} config
|
|
*
|
|
* @returns {Promise} The Promise to be fulfilled
|
|
*/
|
|
async request(configOrUrl, config) {
|
|
try {
|
|
return await this._request(configOrUrl, config);
|
|
} catch (err) {
|
|
if (err instanceof Error) {
|
|
let dummy = {};
|
|
Error.captureStackTrace ? Error.captureStackTrace(dummy) : dummy = new Error();
|
|
const stack2 = dummy.stack ? dummy.stack.replace(/^.+\n/, "") : "";
|
|
try {
|
|
if (!err.stack) {
|
|
err.stack = stack2;
|
|
} else if (stack2 && !String(err.stack).endsWith(stack2.replace(/^.+\n.+\n/, ""))) {
|
|
err.stack += "\n" + stack2;
|
|
}
|
|
} catch (e) {
|
|
}
|
|
}
|
|
throw err;
|
|
}
|
|
}
|
|
_request(configOrUrl, config) {
|
|
if (typeof configOrUrl === "string") {
|
|
config = config || {};
|
|
config.url = configOrUrl;
|
|
} else {
|
|
config = configOrUrl || {};
|
|
}
|
|
config = mergeConfig$1(this.defaults, config);
|
|
const { transitional: transitional2, paramsSerializer, headers } = config;
|
|
if (transitional2 !== void 0) {
|
|
validator.assertOptions(transitional2, {
|
|
silentJSONParsing: validators.transitional(validators.boolean),
|
|
forcedJSONParsing: validators.transitional(validators.boolean),
|
|
clarifyTimeoutError: validators.transitional(validators.boolean)
|
|
}, false);
|
|
}
|
|
if (paramsSerializer != null) {
|
|
if (utils$1.isFunction(paramsSerializer)) {
|
|
config.paramsSerializer = {
|
|
serialize: paramsSerializer
|
|
};
|
|
} else {
|
|
validator.assertOptions(paramsSerializer, {
|
|
encode: validators.function,
|
|
serialize: validators.function
|
|
}, true);
|
|
}
|
|
}
|
|
if (config.allowAbsoluteUrls !== void 0) ;
|
|
else if (this.defaults.allowAbsoluteUrls !== void 0) {
|
|
config.allowAbsoluteUrls = this.defaults.allowAbsoluteUrls;
|
|
} else {
|
|
config.allowAbsoluteUrls = true;
|
|
}
|
|
validator.assertOptions(config, {
|
|
baseUrl: validators.spelling("baseURL"),
|
|
withXsrfToken: validators.spelling("withXSRFToken")
|
|
}, true);
|
|
config.method = (config.method || this.defaults.method || "get").toLowerCase();
|
|
let contextHeaders = headers && utils$1.merge(
|
|
headers.common,
|
|
headers[config.method]
|
|
);
|
|
headers && utils$1.forEach(
|
|
["delete", "get", "head", "post", "put", "patch", "common"],
|
|
(method) => {
|
|
delete headers[method];
|
|
}
|
|
);
|
|
config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
|
|
const requestInterceptorChain = [];
|
|
let synchronousRequestInterceptors = true;
|
|
this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
|
|
if (typeof interceptor.runWhen === "function" && interceptor.runWhen(config) === false) {
|
|
return;
|
|
}
|
|
synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
|
|
requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
|
|
});
|
|
const responseInterceptorChain = [];
|
|
this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
|
|
responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
|
|
});
|
|
let promise;
|
|
let i = 0;
|
|
let len;
|
|
if (!synchronousRequestInterceptors) {
|
|
const chain = [dispatchRequest.bind(this), void 0];
|
|
chain.unshift.apply(chain, requestInterceptorChain);
|
|
chain.push.apply(chain, responseInterceptorChain);
|
|
len = chain.length;
|
|
promise = Promise.resolve(config);
|
|
while (i < len) {
|
|
promise = promise.then(chain[i++], chain[i++]);
|
|
}
|
|
return promise;
|
|
}
|
|
len = requestInterceptorChain.length;
|
|
let newConfig = config;
|
|
i = 0;
|
|
while (i < len) {
|
|
const onFulfilled = requestInterceptorChain[i++];
|
|
const onRejected = requestInterceptorChain[i++];
|
|
try {
|
|
newConfig = onFulfilled(newConfig);
|
|
} catch (error2) {
|
|
onRejected.call(this, error2);
|
|
break;
|
|
}
|
|
}
|
|
try {
|
|
promise = dispatchRequest.call(this, newConfig);
|
|
} catch (error2) {
|
|
return Promise.reject(error2);
|
|
}
|
|
i = 0;
|
|
len = responseInterceptorChain.length;
|
|
while (i < len) {
|
|
promise = promise.then(responseInterceptorChain[i++], responseInterceptorChain[i++]);
|
|
}
|
|
return promise;
|
|
}
|
|
getUri(config) {
|
|
config = mergeConfig$1(this.defaults, config);
|
|
const fullPath = buildFullPath(config.baseURL, config.url, config.allowAbsoluteUrls);
|
|
return buildURL(fullPath, config.params, config.paramsSerializer);
|
|
}
|
|
};
|
|
utils$1.forEach(["delete", "get", "head", "options"], function forEachMethodNoData(method) {
|
|
Axios$1.prototype[method] = function(url, config) {
|
|
return this.request(mergeConfig$1(config || {}, {
|
|
method,
|
|
url,
|
|
data: (config || {}).data
|
|
}));
|
|
};
|
|
});
|
|
utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method) {
|
|
function generateHTTPMethod(isForm) {
|
|
return function httpMethod(url, data, config) {
|
|
return this.request(mergeConfig$1(config || {}, {
|
|
method,
|
|
headers: isForm ? {
|
|
"Content-Type": "multipart/form-data"
|
|
} : {},
|
|
url,
|
|
data
|
|
}));
|
|
};
|
|
}
|
|
Axios$1.prototype[method] = generateHTTPMethod();
|
|
Axios$1.prototype[method + "Form"] = generateHTTPMethod(true);
|
|
});
|
|
let CancelToken$1 = class CancelToken {
|
|
constructor(executor) {
|
|
if (typeof executor !== "function") {
|
|
throw new TypeError("executor must be a function.");
|
|
}
|
|
let resolvePromise;
|
|
this.promise = new Promise(function promiseExecutor(resolve2) {
|
|
resolvePromise = resolve2;
|
|
});
|
|
const token = this;
|
|
this.promise.then((cancel) => {
|
|
if (!token._listeners) return;
|
|
let i = token._listeners.length;
|
|
while (i-- > 0) {
|
|
token._listeners[i](cancel);
|
|
}
|
|
token._listeners = null;
|
|
});
|
|
this.promise.then = (onfulfilled) => {
|
|
let _resolve;
|
|
const promise = new Promise((resolve2) => {
|
|
token.subscribe(resolve2);
|
|
_resolve = resolve2;
|
|
}).then(onfulfilled);
|
|
promise.cancel = function reject() {
|
|
token.unsubscribe(_resolve);
|
|
};
|
|
return promise;
|
|
};
|
|
executor(function cancel(message, config, request) {
|
|
if (token.reason) {
|
|
return;
|
|
}
|
|
token.reason = new CanceledError$1(message, config, request);
|
|
resolvePromise(token.reason);
|
|
});
|
|
}
|
|
/**
|
|
* Throws a `CanceledError` if cancellation has been requested.
|
|
*/
|
|
throwIfRequested() {
|
|
if (this.reason) {
|
|
throw this.reason;
|
|
}
|
|
}
|
|
/**
|
|
* Subscribe to the cancel signal
|
|
*/
|
|
subscribe(listener) {
|
|
if (this.reason) {
|
|
listener(this.reason);
|
|
return;
|
|
}
|
|
if (this._listeners) {
|
|
this._listeners.push(listener);
|
|
} else {
|
|
this._listeners = [listener];
|
|
}
|
|
}
|
|
/**
|
|
* Unsubscribe from the cancel signal
|
|
*/
|
|
unsubscribe(listener) {
|
|
if (!this._listeners) {
|
|
return;
|
|
}
|
|
const index = this._listeners.indexOf(listener);
|
|
if (index !== -1) {
|
|
this._listeners.splice(index, 1);
|
|
}
|
|
}
|
|
toAbortSignal() {
|
|
const controller = new AbortController();
|
|
const abort = (err) => {
|
|
controller.abort(err);
|
|
};
|
|
this.subscribe(abort);
|
|
controller.signal.unsubscribe = () => this.unsubscribe(abort);
|
|
return controller.signal;
|
|
}
|
|
/**
|
|
* Returns an object that contains a new `CancelToken` and a function that, when called,
|
|
* cancels the `CancelToken`.
|
|
*/
|
|
static source() {
|
|
let cancel;
|
|
const token = new CancelToken(function executor(c2) {
|
|
cancel = c2;
|
|
});
|
|
return {
|
|
token,
|
|
cancel
|
|
};
|
|
}
|
|
};
|
|
function spread$1(callback) {
|
|
return function wrap(arr) {
|
|
return callback.apply(null, arr);
|
|
};
|
|
}
|
|
function isAxiosError$1(payload) {
|
|
return utils$1.isObject(payload) && payload.isAxiosError === true;
|
|
}
|
|
const HttpStatusCode$1 = {
|
|
Continue: 100,
|
|
SwitchingProtocols: 101,
|
|
Processing: 102,
|
|
EarlyHints: 103,
|
|
Ok: 200,
|
|
Created: 201,
|
|
Accepted: 202,
|
|
NonAuthoritativeInformation: 203,
|
|
NoContent: 204,
|
|
ResetContent: 205,
|
|
PartialContent: 206,
|
|
MultiStatus: 207,
|
|
AlreadyReported: 208,
|
|
ImUsed: 226,
|
|
MultipleChoices: 300,
|
|
MovedPermanently: 301,
|
|
Found: 302,
|
|
SeeOther: 303,
|
|
NotModified: 304,
|
|
UseProxy: 305,
|
|
Unused: 306,
|
|
TemporaryRedirect: 307,
|
|
PermanentRedirect: 308,
|
|
BadRequest: 400,
|
|
Unauthorized: 401,
|
|
PaymentRequired: 402,
|
|
Forbidden: 403,
|
|
NotFound: 404,
|
|
MethodNotAllowed: 405,
|
|
NotAcceptable: 406,
|
|
ProxyAuthenticationRequired: 407,
|
|
RequestTimeout: 408,
|
|
Conflict: 409,
|
|
Gone: 410,
|
|
LengthRequired: 411,
|
|
PreconditionFailed: 412,
|
|
PayloadTooLarge: 413,
|
|
UriTooLong: 414,
|
|
UnsupportedMediaType: 415,
|
|
RangeNotSatisfiable: 416,
|
|
ExpectationFailed: 417,
|
|
ImATeapot: 418,
|
|
MisdirectedRequest: 421,
|
|
UnprocessableEntity: 422,
|
|
Locked: 423,
|
|
FailedDependency: 424,
|
|
TooEarly: 425,
|
|
UpgradeRequired: 426,
|
|
PreconditionRequired: 428,
|
|
TooManyRequests: 429,
|
|
RequestHeaderFieldsTooLarge: 431,
|
|
UnavailableForLegalReasons: 451,
|
|
InternalServerError: 500,
|
|
NotImplemented: 501,
|
|
BadGateway: 502,
|
|
ServiceUnavailable: 503,
|
|
GatewayTimeout: 504,
|
|
HttpVersionNotSupported: 505,
|
|
VariantAlsoNegotiates: 506,
|
|
InsufficientStorage: 507,
|
|
LoopDetected: 508,
|
|
NotExtended: 510,
|
|
NetworkAuthenticationRequired: 511
|
|
};
|
|
Object.entries(HttpStatusCode$1).forEach(([key, value]) => {
|
|
HttpStatusCode$1[value] = key;
|
|
});
|
|
function createInstance(defaultConfig) {
|
|
const context = new Axios$1(defaultConfig);
|
|
const instance = bind(Axios$1.prototype.request, context);
|
|
utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
|
|
utils$1.extend(instance, context, null, { allOwnKeys: true });
|
|
instance.create = function create(instanceConfig) {
|
|
return createInstance(mergeConfig$1(defaultConfig, instanceConfig));
|
|
};
|
|
return instance;
|
|
}
|
|
const axios = createInstance(defaults);
|
|
axios.Axios = Axios$1;
|
|
axios.CanceledError = CanceledError$1;
|
|
axios.CancelToken = CancelToken$1;
|
|
axios.isCancel = isCancel$1;
|
|
axios.VERSION = VERSION$1;
|
|
axios.toFormData = toFormData$1;
|
|
axios.AxiosError = AxiosError$1;
|
|
axios.Cancel = axios.CanceledError;
|
|
axios.all = function all(promises) {
|
|
return Promise.all(promises);
|
|
};
|
|
axios.spread = spread$1;
|
|
axios.isAxiosError = isAxiosError$1;
|
|
axios.mergeConfig = mergeConfig$1;
|
|
axios.AxiosHeaders = AxiosHeaders$1;
|
|
axios.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
|
|
axios.getAdapter = adapters.getAdapter;
|
|
axios.HttpStatusCode = HttpStatusCode$1;
|
|
axios.default = axios;
|
|
const {
|
|
Axios: Axios2,
|
|
AxiosError,
|
|
CanceledError,
|
|
isCancel,
|
|
CancelToken: CancelToken2,
|
|
VERSION,
|
|
all: all2,
|
|
Cancel,
|
|
isAxiosError,
|
|
spread,
|
|
toFormData,
|
|
AxiosHeaders: AxiosHeaders2,
|
|
HttpStatusCode,
|
|
formToJSON,
|
|
getAdapter,
|
|
mergeConfig
|
|
} = axios;
|
|
const useMowerStore = /* @__PURE__ */ defineStore("mower", () => {
|
|
const log_lines = ref([]);
|
|
const log = computed(() => {
|
|
return log_lines.value.join("\n");
|
|
});
|
|
const num_reg = /^[0-9].*/;
|
|
const log_mobile = computed(() => {
|
|
const result = [];
|
|
for (const i of log_lines.value) {
|
|
if (i.match(num_reg)) {
|
|
result.push(i.substring(6));
|
|
} else {
|
|
result.push(i);
|
|
}
|
|
}
|
|
return result.join("\n");
|
|
});
|
|
const ws = ref(null);
|
|
const running = ref(false);
|
|
const waiting = ref(false);
|
|
const get_task_id = ref(0);
|
|
const task_list = ref([]);
|
|
const sc_uri = ref("");
|
|
const basement_task_list = ref([]);
|
|
const speed_msg = ref([]);
|
|
async function get_running() {
|
|
const { data } = await axios.get(`${""}/scheduler`);
|
|
running.value = !data.idle || data.next_time;
|
|
}
|
|
async function get_tasks() {
|
|
if (running.value) {
|
|
const response = await axios.get(`${""}/task`);
|
|
task_list.value = response.data;
|
|
get_task_id.value = setTimeout(get_tasks, 3e3);
|
|
} else {
|
|
task_list.value = [];
|
|
}
|
|
}
|
|
return {
|
|
log,
|
|
log_mobile,
|
|
log_lines,
|
|
ws,
|
|
sc_uri,
|
|
basement_task_list,
|
|
running,
|
|
waiting,
|
|
speed_msg,
|
|
get_running,
|
|
task_list,
|
|
get_task_id,
|
|
get_tasks
|
|
};
|
|
});
|
|
function deepcopy(data) {
|
|
return JSON.parse(JSON.stringify(data));
|
|
}
|
|
const useConfigStore = /* @__PURE__ */ defineStore("config", () => {
|
|
const shop_list = ref([]);
|
|
async function load_shop() {
|
|
const { data } = await axios.get(`${""}/shop`);
|
|
const mall_list = [];
|
|
for (const i of data) {
|
|
mall_list.push({
|
|
value: i,
|
|
label: i
|
|
});
|
|
}
|
|
shop_list.value = mall_list;
|
|
}
|
|
const scene_comment = ref({});
|
|
async function load_scene() {
|
|
const { data } = await axios.get(`${""}/scene`);
|
|
scene_comment.value = data;
|
|
}
|
|
const conf = ref({});
|
|
const int2bool = ["leifeng_mode", "mail_enable"];
|
|
const str2list = ["free_blacklist", "reload_room", "maa_mall_buy", "maa_mall_blacklist"];
|
|
function parse_config(data) {
|
|
for (const i of int2bool) {
|
|
data[i] = data[i] != 0;
|
|
}
|
|
for (const i of str2list) {
|
|
data[i] = data[i] == "" ? [] : data[i].split(",");
|
|
}
|
|
data.package_type = data.package_type == 1 ? "official" : "bilibili";
|
|
data.resting_threshold = data.resting_threshold * 100;
|
|
data.tap_to_launch_game.enable = data.tap_to_launch_game.enable ? "tap" : "command";
|
|
return data;
|
|
}
|
|
async function load_config() {
|
|
const { data } = await axios.get(`${""}/conf`);
|
|
conf.value = parse_config(data);
|
|
}
|
|
function build_config() {
|
|
const data = deepcopy(conf.value);
|
|
for (const i of int2bool) {
|
|
data[i] = data[i] ? 1 : 0;
|
|
}
|
|
for (const i of str2list) {
|
|
data[i] = data[i].join(",");
|
|
}
|
|
data.package_type = data.package_type == "official" ? 1 : 0;
|
|
data.resting_threshold = data.resting_threshold / 100;
|
|
data.tap_to_launch_game.enable = data.tap_to_launch_game.enable == "tap";
|
|
return data;
|
|
}
|
|
const timestamp = ref(0);
|
|
const post_conf = ref(false);
|
|
watch(
|
|
conf,
|
|
() => {
|
|
if (!post_conf.value) {
|
|
post_conf.value = true;
|
|
return;
|
|
}
|
|
timestamp.value = Date.now();
|
|
axios.post(`${""}/conf`, {
|
|
time: timestamp.value,
|
|
data: build_config()
|
|
});
|
|
},
|
|
{ deep: true }
|
|
);
|
|
return {
|
|
load_config,
|
|
load_shop,
|
|
load_scene,
|
|
parse_config,
|
|
shop_list,
|
|
scene_comment,
|
|
timestamp,
|
|
post_conf,
|
|
conf
|
|
};
|
|
});
|
|
const _sfc_main$1 = {
|
|
__name: "WebSocket",
|
|
setup(__props) {
|
|
const mower_store = useMowerStore();
|
|
const { ws, log_lines, sc_uri, speed_msg, basement_task_list } = storeToRefs(mower_store);
|
|
const config_store = useConfigStore();
|
|
const { timestamp, post_conf } = storeToRefs(config_store);
|
|
const { load_config } = config_store;
|
|
function listen_ws() {
|
|
let backend_url;
|
|
{
|
|
backend_url = location.origin;
|
|
}
|
|
const ws_url = backend_url.replace(/^http/, "ws") + "/ws";
|
|
ws.value = new ReconnectingWebSocket(ws_url);
|
|
ws.value.onopen = () => {
|
|
ws.value.send(JSON.stringify({ log: true, sc: true, conf: true, screenshot: true }));
|
|
};
|
|
ws.value.onmessage = async ({ data }) => {
|
|
data = JSON.parse(data);
|
|
if (data.type == "log") {
|
|
log_lines.value = log_lines.value.concat(data.data.split("\n")).slice(-100);
|
|
} else if (data.type == "conf") {
|
|
if (timestamp.value < data.time) {
|
|
post_conf.value = false;
|
|
timestamp.value = data.time;
|
|
await load_config();
|
|
}
|
|
} else if (data.type == "sc") {
|
|
sc_uri.value = data.data;
|
|
} else if (data.type == "screenshot") {
|
|
speed_msg.value = [data.msg, data.color];
|
|
} else if (data.type == "task_list") {
|
|
basement_task_list.value = data.data;
|
|
}
|
|
};
|
|
}
|
|
onMounted(() => {
|
|
if (!ws.value) {
|
|
listen_ws();
|
|
}
|
|
});
|
|
return (_ctx, _cache) => {
|
|
return null;
|
|
};
|
|
}
|
|
};
|
|
function getDefaultExportFromCjs(x) {
|
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
}
|
|
function getAugmentedNamespace(n) {
|
|
if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
|
|
var f = n.default;
|
|
if (typeof f == "function") {
|
|
var a = function a2() {
|
|
if (this instanceof a2) {
|
|
return Reflect.construct(f, arguments, this.constructor);
|
|
}
|
|
return f.apply(this, arguments);
|
|
};
|
|
a.prototype = f.prototype;
|
|
} else a = {};
|
|
Object.defineProperty(a, "__esModule", { value: true });
|
|
Object.keys(n).forEach(function(k) {
|
|
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
Object.defineProperty(a, k, d.get ? d : {
|
|
enumerable: true,
|
|
get: function() {
|
|
return n[k];
|
|
}
|
|
});
|
|
});
|
|
return a;
|
|
}
|
|
var core;
|
|
var hasRequiredCore;
|
|
function requireCore() {
|
|
if (hasRequiredCore) return core;
|
|
hasRequiredCore = 1;
|
|
function deepFreeze(obj) {
|
|
if (obj instanceof Map) {
|
|
obj.clear = obj.delete = obj.set = function() {
|
|
throw new Error("map is read-only");
|
|
};
|
|
} else if (obj instanceof Set) {
|
|
obj.add = obj.clear = obj.delete = function() {
|
|
throw new Error("set is read-only");
|
|
};
|
|
}
|
|
Object.freeze(obj);
|
|
Object.getOwnPropertyNames(obj).forEach((name) => {
|
|
const prop = obj[name];
|
|
const type = typeof prop;
|
|
if ((type === "object" || type === "function") && !Object.isFrozen(prop)) {
|
|
deepFreeze(prop);
|
|
}
|
|
});
|
|
return obj;
|
|
}
|
|
class Response2 {
|
|
/**
|
|
* @param {CompiledMode} mode
|
|
*/
|
|
constructor(mode) {
|
|
if (mode.data === void 0) mode.data = {};
|
|
this.data = mode.data;
|
|
this.isMatchIgnored = false;
|
|
}
|
|
ignoreMatch() {
|
|
this.isMatchIgnored = true;
|
|
}
|
|
}
|
|
function escapeHTML(value) {
|
|
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
}
|
|
function inherit$1(original, ...objects) {
|
|
const result = /* @__PURE__ */ Object.create(null);
|
|
for (const key in original) {
|
|
result[key] = original[key];
|
|
}
|
|
objects.forEach(function(obj) {
|
|
for (const key in obj) {
|
|
result[key] = obj[key];
|
|
}
|
|
});
|
|
return (
|
|
/** @type {T} */
|
|
result
|
|
);
|
|
}
|
|
const SPAN_CLOSE = "</span>";
|
|
const emitsWrappingTags = (node) => {
|
|
return !!node.scope;
|
|
};
|
|
const scopeToCSSClass = (name, { prefix: prefix2 }) => {
|
|
if (name.startsWith("language:")) {
|
|
return name.replace("language:", "language-");
|
|
}
|
|
if (name.includes(".")) {
|
|
const pieces = name.split(".");
|
|
return [
|
|
`${prefix2}${pieces.shift()}`,
|
|
...pieces.map((x, i) => `${x}${"_".repeat(i + 1)}`)
|
|
].join(" ");
|
|
}
|
|
return `${prefix2}${name}`;
|
|
};
|
|
class HTMLRenderer {
|
|
/**
|
|
* Creates a new HTMLRenderer
|
|
*
|
|
* @param {Tree} parseTree - the parse tree (must support `walk` API)
|
|
* @param {{classPrefix: string}} options
|
|
*/
|
|
constructor(parseTree, options) {
|
|
this.buffer = "";
|
|
this.classPrefix = options.classPrefix;
|
|
parseTree.walk(this);
|
|
}
|
|
/**
|
|
* Adds texts to the output stream
|
|
*
|
|
* @param {string} text */
|
|
addText(text) {
|
|
this.buffer += escapeHTML(text);
|
|
}
|
|
/**
|
|
* Adds a node open to the output stream (if needed)
|
|
*
|
|
* @param {Node} node */
|
|
openNode(node) {
|
|
if (!emitsWrappingTags(node)) return;
|
|
const className = scopeToCSSClass(
|
|
node.scope,
|
|
{ prefix: this.classPrefix }
|
|
);
|
|
this.span(className);
|
|
}
|
|
/**
|
|
* Adds a node close to the output stream (if needed)
|
|
*
|
|
* @param {Node} node */
|
|
closeNode(node) {
|
|
if (!emitsWrappingTags(node)) return;
|
|
this.buffer += SPAN_CLOSE;
|
|
}
|
|
/**
|
|
* returns the accumulated buffer
|
|
*/
|
|
value() {
|
|
return this.buffer;
|
|
}
|
|
// helpers
|
|
/**
|
|
* Builds a span element
|
|
*
|
|
* @param {string} className */
|
|
span(className) {
|
|
this.buffer += `<span class="${className}">`;
|
|
}
|
|
}
|
|
const newNode = (opts = {}) => {
|
|
const result = { children: [] };
|
|
Object.assign(result, opts);
|
|
return result;
|
|
};
|
|
class TokenTree {
|
|
constructor() {
|
|
this.rootNode = newNode();
|
|
this.stack = [this.rootNode];
|
|
}
|
|
get top() {
|
|
return this.stack[this.stack.length - 1];
|
|
}
|
|
get root() {
|
|
return this.rootNode;
|
|
}
|
|
/** @param {Node} node */
|
|
add(node) {
|
|
this.top.children.push(node);
|
|
}
|
|
/** @param {string} scope */
|
|
openNode(scope) {
|
|
const node = newNode({ scope });
|
|
this.add(node);
|
|
this.stack.push(node);
|
|
}
|
|
closeNode() {
|
|
if (this.stack.length > 1) {
|
|
return this.stack.pop();
|
|
}
|
|
return void 0;
|
|
}
|
|
closeAllNodes() {
|
|
while (this.closeNode()) ;
|
|
}
|
|
toJSON() {
|
|
return JSON.stringify(this.rootNode, null, 4);
|
|
}
|
|
/**
|
|
* @typedef { import("./html_renderer").Renderer } Renderer
|
|
* @param {Renderer} builder
|
|
*/
|
|
walk(builder) {
|
|
return this.constructor._walk(builder, this.rootNode);
|
|
}
|
|
/**
|
|
* @param {Renderer} builder
|
|
* @param {Node} node
|
|
*/
|
|
static _walk(builder, node) {
|
|
if (typeof node === "string") {
|
|
builder.addText(node);
|
|
} else if (node.children) {
|
|
builder.openNode(node);
|
|
node.children.forEach((child) => this._walk(builder, child));
|
|
builder.closeNode(node);
|
|
}
|
|
return builder;
|
|
}
|
|
/**
|
|
* @param {Node} node
|
|
*/
|
|
static _collapse(node) {
|
|
if (typeof node === "string") return;
|
|
if (!node.children) return;
|
|
if (node.children.every((el) => typeof el === "string")) {
|
|
node.children = [node.children.join("")];
|
|
} else {
|
|
node.children.forEach((child) => {
|
|
TokenTree._collapse(child);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
class TokenTreeEmitter extends TokenTree {
|
|
/**
|
|
* @param {*} options
|
|
*/
|
|
constructor(options) {
|
|
super();
|
|
this.options = options;
|
|
}
|
|
/**
|
|
* @param {string} text
|
|
*/
|
|
addText(text) {
|
|
if (text === "") {
|
|
return;
|
|
}
|
|
this.add(text);
|
|
}
|
|
/** @param {string} scope */
|
|
startScope(scope) {
|
|
this.openNode(scope);
|
|
}
|
|
endScope() {
|
|
this.closeNode();
|
|
}
|
|
/**
|
|
* @param {Emitter & {root: DataNode}} emitter
|
|
* @param {string} name
|
|
*/
|
|
__addSublanguage(emitter, name) {
|
|
const node = emitter.root;
|
|
if (name) node.scope = `language:${name}`;
|
|
this.add(node);
|
|
}
|
|
toHTML() {
|
|
const renderer2 = new HTMLRenderer(this, this.options);
|
|
return renderer2.value();
|
|
}
|
|
finalize() {
|
|
this.closeAllNodes();
|
|
return true;
|
|
}
|
|
}
|
|
function source(re) {
|
|
if (!re) return null;
|
|
if (typeof re === "string") return re;
|
|
return re.source;
|
|
}
|
|
function lookahead(re) {
|
|
return concat("(?=", re, ")");
|
|
}
|
|
function anyNumberOfTimes(re) {
|
|
return concat("(?:", re, ")*");
|
|
}
|
|
function optional(re) {
|
|
return concat("(?:", re, ")?");
|
|
}
|
|
function concat(...args) {
|
|
const joined = args.map((x) => source(x)).join("");
|
|
return joined;
|
|
}
|
|
function stripOptionsFromArgs(args) {
|
|
const opts = args[args.length - 1];
|
|
if (typeof opts === "object" && opts.constructor === Object) {
|
|
args.splice(args.length - 1, 1);
|
|
return opts;
|
|
} else {
|
|
return {};
|
|
}
|
|
}
|
|
function either(...args) {
|
|
const opts = stripOptionsFromArgs(args);
|
|
const joined = "(" + (opts.capture ? "" : "?:") + args.map((x) => source(x)).join("|") + ")";
|
|
return joined;
|
|
}
|
|
function countMatchGroups(re) {
|
|
return new RegExp(re.toString() + "|").exec("").length - 1;
|
|
}
|
|
function startsWith(re, lexeme) {
|
|
const match2 = re && re.exec(lexeme);
|
|
return match2 && match2.index === 0;
|
|
}
|
|
const BACKREF_RE = /\[(?:[^\\\]]|\\.)*\]|\(\??|\\([1-9][0-9]*)|\\./;
|
|
function _rewriteBackreferences(regexps, { joinWith }) {
|
|
let numCaptures = 0;
|
|
return regexps.map((regex) => {
|
|
numCaptures += 1;
|
|
const offset = numCaptures;
|
|
let re = source(regex);
|
|
let out = "";
|
|
while (re.length > 0) {
|
|
const match2 = BACKREF_RE.exec(re);
|
|
if (!match2) {
|
|
out += re;
|
|
break;
|
|
}
|
|
out += re.substring(0, match2.index);
|
|
re = re.substring(match2.index + match2[0].length);
|
|
if (match2[0][0] === "\\" && match2[1]) {
|
|
out += "\\" + String(Number(match2[1]) + offset);
|
|
} else {
|
|
out += match2[0];
|
|
if (match2[0] === "(") {
|
|
numCaptures++;
|
|
}
|
|
}
|
|
}
|
|
return out;
|
|
}).map((re) => `(${re})`).join(joinWith);
|
|
}
|
|
const MATCH_NOTHING_RE = /\b\B/;
|
|
const IDENT_RE = "[a-zA-Z]\\w*";
|
|
const UNDERSCORE_IDENT_RE = "[a-zA-Z_]\\w*";
|
|
const NUMBER_RE = "\\b\\d+(\\.\\d+)?";
|
|
const C_NUMBER_RE = "(-?)(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";
|
|
const BINARY_NUMBER_RE = "\\b(0b[01]+)";
|
|
const RE_STARTERS_RE = "!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";
|
|
const SHEBANG = (opts = {}) => {
|
|
const beginShebang = /^#![ ]*\//;
|
|
if (opts.binary) {
|
|
opts.begin = concat(
|
|
beginShebang,
|
|
/.*\b/,
|
|
opts.binary,
|
|
/\b.*/
|
|
);
|
|
}
|
|
return inherit$1({
|
|
scope: "meta",
|
|
begin: beginShebang,
|
|
end: /$/,
|
|
relevance: 0,
|
|
/** @type {ModeCallback} */
|
|
"on:begin": (m, resp) => {
|
|
if (m.index !== 0) resp.ignoreMatch();
|
|
}
|
|
}, opts);
|
|
};
|
|
const BACKSLASH_ESCAPE = {
|
|
begin: "\\\\[\\s\\S]",
|
|
relevance: 0
|
|
};
|
|
const APOS_STRING_MODE = {
|
|
scope: "string",
|
|
begin: "'",
|
|
end: "'",
|
|
illegal: "\\n",
|
|
contains: [BACKSLASH_ESCAPE]
|
|
};
|
|
const QUOTE_STRING_MODE = {
|
|
scope: "string",
|
|
begin: '"',
|
|
end: '"',
|
|
illegal: "\\n",
|
|
contains: [BACKSLASH_ESCAPE]
|
|
};
|
|
const PHRASAL_WORDS_MODE = {
|
|
begin: /\b(a|an|the|are|I'm|isn't|don't|doesn't|won't|but|just|should|pretty|simply|enough|gonna|going|wtf|so|such|will|you|your|they|like|more)\b/
|
|
};
|
|
const COMMENT = function(begin, end, modeOptions = {}) {
|
|
const mode = inherit$1(
|
|
{
|
|
scope: "comment",
|
|
begin,
|
|
end,
|
|
contains: []
|
|
},
|
|
modeOptions
|
|
);
|
|
mode.contains.push({
|
|
scope: "doctag",
|
|
// hack to avoid the space from being included. the space is necessary to
|
|
// match here to prevent the plain text rule below from gobbling up doctags
|
|
begin: "[ ]*(?=(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):)",
|
|
end: /(TODO|FIXME|NOTE|BUG|OPTIMIZE|HACK|XXX):/,
|
|
excludeBegin: true,
|
|
relevance: 0
|
|
});
|
|
const ENGLISH_WORD = either(
|
|
// list of common 1 and 2 letter words in English
|
|
"I",
|
|
"a",
|
|
"is",
|
|
"so",
|
|
"us",
|
|
"to",
|
|
"at",
|
|
"if",
|
|
"in",
|
|
"it",
|
|
"on",
|
|
// note: this is not an exhaustive list of contractions, just popular ones
|
|
/[A-Za-z]+['](d|ve|re|ll|t|s|n)/,
|
|
// contractions - can't we'd they're let's, etc
|
|
/[A-Za-z]+[-][a-z]+/,
|
|
// `no-way`, etc.
|
|
/[A-Za-z][a-z]{2,}/
|
|
// allow capitalized words at beginning of sentences
|
|
);
|
|
mode.contains.push(
|
|
{
|
|
// TODO: how to include ", (, ) without breaking grammars that use these for
|
|
// comment delimiters?
|
|
// begin: /[ ]+([()"]?([A-Za-z'-]{3,}|is|a|I|so|us|[tT][oO]|at|if|in|it|on)[.]?[()":]?([.][ ]|[ ]|\))){3}/
|
|
// ---
|
|
// this tries to find sequences of 3 english words in a row (without any
|
|
// "programming" type syntax) this gives us a strong signal that we've
|
|
// TRULY found a comment - vs perhaps scanning with the wrong language.
|
|
// It's possible to find something that LOOKS like the start of the
|
|
// comment - but then if there is no readable text - good chance it is a
|
|
// false match and not a comment.
|
|
//
|
|
// for a visual example please see:
|
|
// https://github.com/highlightjs/highlight.js/issues/2827
|
|
begin: concat(
|
|
/[ ]+/,
|
|
// necessary to prevent us gobbling up doctags like /* @author Bob Mcgill */
|
|
"(",
|
|
ENGLISH_WORD,
|
|
/[.]?[:]?([.][ ]|[ ])/,
|
|
"){3}"
|
|
)
|
|
// look for 3 words in a row
|
|
}
|
|
);
|
|
return mode;
|
|
};
|
|
const C_LINE_COMMENT_MODE = COMMENT("//", "$");
|
|
const C_BLOCK_COMMENT_MODE = COMMENT("/\\*", "\\*/");
|
|
const HASH_COMMENT_MODE = COMMENT("#", "$");
|
|
const NUMBER_MODE = {
|
|
scope: "number",
|
|
begin: NUMBER_RE,
|
|
relevance: 0
|
|
};
|
|
const C_NUMBER_MODE = {
|
|
scope: "number",
|
|
begin: C_NUMBER_RE,
|
|
relevance: 0
|
|
};
|
|
const BINARY_NUMBER_MODE = {
|
|
scope: "number",
|
|
begin: BINARY_NUMBER_RE,
|
|
relevance: 0
|
|
};
|
|
const REGEXP_MODE = {
|
|
scope: "regexp",
|
|
begin: /\/(?=[^/\n]*\/)/,
|
|
end: /\/[gimuy]*/,
|
|
contains: [
|
|
BACKSLASH_ESCAPE,
|
|
{
|
|
begin: /\[/,
|
|
end: /\]/,
|
|
relevance: 0,
|
|
contains: [BACKSLASH_ESCAPE]
|
|
}
|
|
]
|
|
};
|
|
const TITLE_MODE = {
|
|
scope: "title",
|
|
begin: IDENT_RE,
|
|
relevance: 0
|
|
};
|
|
const UNDERSCORE_TITLE_MODE = {
|
|
scope: "title",
|
|
begin: UNDERSCORE_IDENT_RE,
|
|
relevance: 0
|
|
};
|
|
const METHOD_GUARD = {
|
|
// excludes method names from keyword processing
|
|
begin: "\\.\\s*" + UNDERSCORE_IDENT_RE,
|
|
relevance: 0
|
|
};
|
|
const END_SAME_AS_BEGIN = function(mode) {
|
|
return Object.assign(
|
|
mode,
|
|
{
|
|
/** @type {ModeCallback} */
|
|
"on:begin": (m, resp) => {
|
|
resp.data._beginMatch = m[1];
|
|
},
|
|
/** @type {ModeCallback} */
|
|
"on:end": (m, resp) => {
|
|
if (resp.data._beginMatch !== m[1]) resp.ignoreMatch();
|
|
}
|
|
}
|
|
);
|
|
};
|
|
var MODES = /* @__PURE__ */ Object.freeze({
|
|
__proto__: null,
|
|
APOS_STRING_MODE,
|
|
BACKSLASH_ESCAPE,
|
|
BINARY_NUMBER_MODE,
|
|
BINARY_NUMBER_RE,
|
|
COMMENT,
|
|
C_BLOCK_COMMENT_MODE,
|
|
C_LINE_COMMENT_MODE,
|
|
C_NUMBER_MODE,
|
|
C_NUMBER_RE,
|
|
END_SAME_AS_BEGIN,
|
|
HASH_COMMENT_MODE,
|
|
IDENT_RE,
|
|
MATCH_NOTHING_RE,
|
|
METHOD_GUARD,
|
|
NUMBER_MODE,
|
|
NUMBER_RE,
|
|
PHRASAL_WORDS_MODE,
|
|
QUOTE_STRING_MODE,
|
|
REGEXP_MODE,
|
|
RE_STARTERS_RE,
|
|
SHEBANG,
|
|
TITLE_MODE,
|
|
UNDERSCORE_IDENT_RE,
|
|
UNDERSCORE_TITLE_MODE
|
|
});
|
|
function skipIfHasPrecedingDot(match2, response) {
|
|
const before = match2.input[match2.index - 1];
|
|
if (before === ".") {
|
|
response.ignoreMatch();
|
|
}
|
|
}
|
|
function scopeClassName(mode, _parent) {
|
|
if (mode.className !== void 0) {
|
|
mode.scope = mode.className;
|
|
delete mode.className;
|
|
}
|
|
}
|
|
function beginKeywords(mode, parent) {
|
|
if (!parent) return;
|
|
if (!mode.beginKeywords) return;
|
|
mode.begin = "\\b(" + mode.beginKeywords.split(" ").join("|") + ")(?!\\.)(?=\\b|\\s)";
|
|
mode.__beforeBegin = skipIfHasPrecedingDot;
|
|
mode.keywords = mode.keywords || mode.beginKeywords;
|
|
delete mode.beginKeywords;
|
|
if (mode.relevance === void 0) mode.relevance = 0;
|
|
}
|
|
function compileIllegal(mode, _parent) {
|
|
if (!Array.isArray(mode.illegal)) return;
|
|
mode.illegal = either(...mode.illegal);
|
|
}
|
|
function compileMatch(mode, _parent) {
|
|
if (!mode.match) return;
|
|
if (mode.begin || mode.end) throw new Error("begin & end are not supported with match");
|
|
mode.begin = mode.match;
|
|
delete mode.match;
|
|
}
|
|
function compileRelevance(mode, _parent) {
|
|
if (mode.relevance === void 0) mode.relevance = 1;
|
|
}
|
|
const beforeMatchExt = (mode, parent) => {
|
|
if (!mode.beforeMatch) return;
|
|
if (mode.starts) throw new Error("beforeMatch cannot be used with starts");
|
|
const originalMode = Object.assign({}, mode);
|
|
Object.keys(mode).forEach((key) => {
|
|
delete mode[key];
|
|
});
|
|
mode.keywords = originalMode.keywords;
|
|
mode.begin = concat(originalMode.beforeMatch, lookahead(originalMode.begin));
|
|
mode.starts = {
|
|
relevance: 0,
|
|
contains: [
|
|
Object.assign(originalMode, { endsParent: true })
|
|
]
|
|
};
|
|
mode.relevance = 0;
|
|
delete originalMode.beforeMatch;
|
|
};
|
|
const COMMON_KEYWORDS = [
|
|
"of",
|
|
"and",
|
|
"for",
|
|
"in",
|
|
"not",
|
|
"or",
|
|
"if",
|
|
"then",
|
|
"parent",
|
|
// common variable name
|
|
"list",
|
|
// common variable name
|
|
"value"
|
|
// common variable name
|
|
];
|
|
const DEFAULT_KEYWORD_SCOPE = "keyword";
|
|
function compileKeywords(rawKeywords, caseInsensitive, scopeName = DEFAULT_KEYWORD_SCOPE) {
|
|
const compiledKeywords = /* @__PURE__ */ Object.create(null);
|
|
if (typeof rawKeywords === "string") {
|
|
compileList(scopeName, rawKeywords.split(" "));
|
|
} else if (Array.isArray(rawKeywords)) {
|
|
compileList(scopeName, rawKeywords);
|
|
} else {
|
|
Object.keys(rawKeywords).forEach(function(scopeName2) {
|
|
Object.assign(
|
|
compiledKeywords,
|
|
compileKeywords(rawKeywords[scopeName2], caseInsensitive, scopeName2)
|
|
);
|
|
});
|
|
}
|
|
return compiledKeywords;
|
|
function compileList(scopeName2, keywordList) {
|
|
if (caseInsensitive) {
|
|
keywordList = keywordList.map((x) => x.toLowerCase());
|
|
}
|
|
keywordList.forEach(function(keyword) {
|
|
const pair = keyword.split("|");
|
|
compiledKeywords[pair[0]] = [scopeName2, scoreForKeyword(pair[0], pair[1])];
|
|
});
|
|
}
|
|
}
|
|
function scoreForKeyword(keyword, providedScore) {
|
|
if (providedScore) {
|
|
return Number(providedScore);
|
|
}
|
|
return commonKeyword(keyword) ? 0 : 1;
|
|
}
|
|
function commonKeyword(keyword) {
|
|
return COMMON_KEYWORDS.includes(keyword.toLowerCase());
|
|
}
|
|
const seenDeprecations = {};
|
|
const error2 = (message) => {
|
|
console.error(message);
|
|
};
|
|
const warn2 = (message, ...args) => {
|
|
console.log(`WARN: ${message}`, ...args);
|
|
};
|
|
const deprecated = (version3, message) => {
|
|
if (seenDeprecations[`${version3}/${message}`]) return;
|
|
console.log(`Deprecated as of ${version3}. ${message}`);
|
|
seenDeprecations[`${version3}/${message}`] = true;
|
|
};
|
|
const MultiClassError = new Error();
|
|
function remapScopeNames(mode, regexes, { key }) {
|
|
let offset = 0;
|
|
const scopeNames = mode[key];
|
|
const emit2 = {};
|
|
const positions = {};
|
|
for (let i = 1; i <= regexes.length; i++) {
|
|
positions[i + offset] = scopeNames[i];
|
|
emit2[i + offset] = true;
|
|
offset += countMatchGroups(regexes[i - 1]);
|
|
}
|
|
mode[key] = positions;
|
|
mode[key]._emit = emit2;
|
|
mode[key]._multi = true;
|
|
}
|
|
function beginMultiClass(mode) {
|
|
if (!Array.isArray(mode.begin)) return;
|
|
if (mode.skip || mode.excludeBegin || mode.returnBegin) {
|
|
error2("skip, excludeBegin, returnBegin not compatible with beginScope: {}");
|
|
throw MultiClassError;
|
|
}
|
|
if (typeof mode.beginScope !== "object" || mode.beginScope === null) {
|
|
error2("beginScope must be object");
|
|
throw MultiClassError;
|
|
}
|
|
remapScopeNames(mode, mode.begin, { key: "beginScope" });
|
|
mode.begin = _rewriteBackreferences(mode.begin, { joinWith: "" });
|
|
}
|
|
function endMultiClass(mode) {
|
|
if (!Array.isArray(mode.end)) return;
|
|
if (mode.skip || mode.excludeEnd || mode.returnEnd) {
|
|
error2("skip, excludeEnd, returnEnd not compatible with endScope: {}");
|
|
throw MultiClassError;
|
|
}
|
|
if (typeof mode.endScope !== "object" || mode.endScope === null) {
|
|
error2("endScope must be object");
|
|
throw MultiClassError;
|
|
}
|
|
remapScopeNames(mode, mode.end, { key: "endScope" });
|
|
mode.end = _rewriteBackreferences(mode.end, { joinWith: "" });
|
|
}
|
|
function scopeSugar(mode) {
|
|
if (mode.scope && typeof mode.scope === "object" && mode.scope !== null) {
|
|
mode.beginScope = mode.scope;
|
|
delete mode.scope;
|
|
}
|
|
}
|
|
function MultiClass(mode) {
|
|
scopeSugar(mode);
|
|
if (typeof mode.beginScope === "string") {
|
|
mode.beginScope = { _wrap: mode.beginScope };
|
|
}
|
|
if (typeof mode.endScope === "string") {
|
|
mode.endScope = { _wrap: mode.endScope };
|
|
}
|
|
beginMultiClass(mode);
|
|
endMultiClass(mode);
|
|
}
|
|
function compileLanguage(language) {
|
|
function langRe(value, global2) {
|
|
return new RegExp(
|
|
source(value),
|
|
"m" + (language.case_insensitive ? "i" : "") + (language.unicodeRegex ? "u" : "") + (global2 ? "g" : "")
|
|
);
|
|
}
|
|
class MultiRegex {
|
|
constructor() {
|
|
this.matchIndexes = {};
|
|
this.regexes = [];
|
|
this.matchAt = 1;
|
|
this.position = 0;
|
|
}
|
|
// @ts-ignore
|
|
addRule(re, opts) {
|
|
opts.position = this.position++;
|
|
this.matchIndexes[this.matchAt] = opts;
|
|
this.regexes.push([opts, re]);
|
|
this.matchAt += countMatchGroups(re) + 1;
|
|
}
|
|
compile() {
|
|
if (this.regexes.length === 0) {
|
|
this.exec = () => null;
|
|
}
|
|
const terminators = this.regexes.map((el) => el[1]);
|
|
this.matcherRe = langRe(_rewriteBackreferences(terminators, { joinWith: "|" }), true);
|
|
this.lastIndex = 0;
|
|
}
|
|
/** @param {string} s */
|
|
exec(s) {
|
|
this.matcherRe.lastIndex = this.lastIndex;
|
|
const match2 = this.matcherRe.exec(s);
|
|
if (!match2) {
|
|
return null;
|
|
}
|
|
const i = match2.findIndex((el, i2) => i2 > 0 && el !== void 0);
|
|
const matchData = this.matchIndexes[i];
|
|
match2.splice(0, i);
|
|
return Object.assign(match2, matchData);
|
|
}
|
|
}
|
|
class ResumableMultiRegex {
|
|
constructor() {
|
|
this.rules = [];
|
|
this.multiRegexes = [];
|
|
this.count = 0;
|
|
this.lastIndex = 0;
|
|
this.regexIndex = 0;
|
|
}
|
|
// @ts-ignore
|
|
getMatcher(index) {
|
|
if (this.multiRegexes[index]) return this.multiRegexes[index];
|
|
const matcher = new MultiRegex();
|
|
this.rules.slice(index).forEach(([re, opts]) => matcher.addRule(re, opts));
|
|
matcher.compile();
|
|
this.multiRegexes[index] = matcher;
|
|
return matcher;
|
|
}
|
|
resumingScanAtSamePosition() {
|
|
return this.regexIndex !== 0;
|
|
}
|
|
considerAll() {
|
|
this.regexIndex = 0;
|
|
}
|
|
// @ts-ignore
|
|
addRule(re, opts) {
|
|
this.rules.push([re, opts]);
|
|
if (opts.type === "begin") this.count++;
|
|
}
|
|
/** @param {string} s */
|
|
exec(s) {
|
|
const m = this.getMatcher(this.regexIndex);
|
|
m.lastIndex = this.lastIndex;
|
|
let result = m.exec(s);
|
|
if (this.resumingScanAtSamePosition()) {
|
|
if (result && result.index === this.lastIndex) ;
|
|
else {
|
|
const m2 = this.getMatcher(0);
|
|
m2.lastIndex = this.lastIndex + 1;
|
|
result = m2.exec(s);
|
|
}
|
|
}
|
|
if (result) {
|
|
this.regexIndex += result.position + 1;
|
|
if (this.regexIndex === this.count) {
|
|
this.considerAll();
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
function buildModeRegex(mode) {
|
|
const mm = new ResumableMultiRegex();
|
|
mode.contains.forEach((term) => mm.addRule(term.begin, { rule: term, type: "begin" }));
|
|
if (mode.terminatorEnd) {
|
|
mm.addRule(mode.terminatorEnd, { type: "end" });
|
|
}
|
|
if (mode.illegal) {
|
|
mm.addRule(mode.illegal, { type: "illegal" });
|
|
}
|
|
return mm;
|
|
}
|
|
function compileMode(mode, parent) {
|
|
const cmode = (
|
|
/** @type CompiledMode */
|
|
mode
|
|
);
|
|
if (mode.isCompiled) return cmode;
|
|
[
|
|
scopeClassName,
|
|
// do this early so compiler extensions generally don't have to worry about
|
|
// the distinction between match/begin
|
|
compileMatch,
|
|
MultiClass,
|
|
beforeMatchExt
|
|
].forEach((ext) => ext(mode, parent));
|
|
language.compilerExtensions.forEach((ext) => ext(mode, parent));
|
|
mode.__beforeBegin = null;
|
|
[
|
|
beginKeywords,
|
|
// do this later so compiler extensions that come earlier have access to the
|
|
// raw array if they wanted to perhaps manipulate it, etc.
|
|
compileIllegal,
|
|
// default to 1 relevance if not specified
|
|
compileRelevance
|
|
].forEach((ext) => ext(mode, parent));
|
|
mode.isCompiled = true;
|
|
let keywordPattern = null;
|
|
if (typeof mode.keywords === "object" && mode.keywords.$pattern) {
|
|
mode.keywords = Object.assign({}, mode.keywords);
|
|
keywordPattern = mode.keywords.$pattern;
|
|
delete mode.keywords.$pattern;
|
|
}
|
|
keywordPattern = keywordPattern || /\w+/;
|
|
if (mode.keywords) {
|
|
mode.keywords = compileKeywords(mode.keywords, language.case_insensitive);
|
|
}
|
|
cmode.keywordPatternRe = langRe(keywordPattern, true);
|
|
if (parent) {
|
|
if (!mode.begin) mode.begin = /\B|\b/;
|
|
cmode.beginRe = langRe(cmode.begin);
|
|
if (!mode.end && !mode.endsWithParent) mode.end = /\B|\b/;
|
|
if (mode.end) cmode.endRe = langRe(cmode.end);
|
|
cmode.terminatorEnd = source(cmode.end) || "";
|
|
if (mode.endsWithParent && parent.terminatorEnd) {
|
|
cmode.terminatorEnd += (mode.end ? "|" : "") + parent.terminatorEnd;
|
|
}
|
|
}
|
|
if (mode.illegal) cmode.illegalRe = langRe(
|
|
/** @type {RegExp | string} */
|
|
mode.illegal
|
|
);
|
|
if (!mode.contains) mode.contains = [];
|
|
mode.contains = [].concat(...mode.contains.map(function(c2) {
|
|
return expandOrCloneMode(c2 === "self" ? mode : c2);
|
|
}));
|
|
mode.contains.forEach(function(c2) {
|
|
compileMode(
|
|
/** @type Mode */
|
|
c2,
|
|
cmode
|
|
);
|
|
});
|
|
if (mode.starts) {
|
|
compileMode(mode.starts, parent);
|
|
}
|
|
cmode.matcher = buildModeRegex(cmode);
|
|
return cmode;
|
|
}
|
|
if (!language.compilerExtensions) language.compilerExtensions = [];
|
|
if (language.contains && language.contains.includes("self")) {
|
|
throw new Error("ERR: contains `self` is not supported at the top-level of a language. See documentation.");
|
|
}
|
|
language.classNameAliases = inherit$1(language.classNameAliases || {});
|
|
return compileMode(
|
|
/** @type Mode */
|
|
language
|
|
);
|
|
}
|
|
function dependencyOnParent(mode) {
|
|
if (!mode) return false;
|
|
return mode.endsWithParent || dependencyOnParent(mode.starts);
|
|
}
|
|
function expandOrCloneMode(mode) {
|
|
if (mode.variants && !mode.cachedVariants) {
|
|
mode.cachedVariants = mode.variants.map(function(variant) {
|
|
return inherit$1(mode, { variants: null }, variant);
|
|
});
|
|
}
|
|
if (mode.cachedVariants) {
|
|
return mode.cachedVariants;
|
|
}
|
|
if (dependencyOnParent(mode)) {
|
|
return inherit$1(mode, { starts: mode.starts ? inherit$1(mode.starts) : null });
|
|
}
|
|
if (Object.isFrozen(mode)) {
|
|
return inherit$1(mode);
|
|
}
|
|
return mode;
|
|
}
|
|
var version2 = "11.11.1";
|
|
class HTMLInjectionError extends Error {
|
|
constructor(reason, html) {
|
|
super(reason);
|
|
this.name = "HTMLInjectionError";
|
|
this.html = html;
|
|
}
|
|
}
|
|
const escape = escapeHTML;
|
|
const inherit = inherit$1;
|
|
const NO_MATCH = Symbol("nomatch");
|
|
const MAX_KEYWORD_HITS = 7;
|
|
const HLJS = function(hljs) {
|
|
const languages = /* @__PURE__ */ Object.create(null);
|
|
const aliases = /* @__PURE__ */ Object.create(null);
|
|
const plugins = [];
|
|
let SAFE_MODE = true;
|
|
const LANGUAGE_NOT_FOUND = "Could not find the language '{}', did you forget to load/include a language module?";
|
|
const PLAINTEXT_LANGUAGE = { disableAutodetect: true, name: "Plain text", contains: [] };
|
|
let options = {
|
|
ignoreUnescapedHTML: false,
|
|
throwUnescapedHTML: false,
|
|
noHighlightRe: /^(no-?highlight)$/i,
|
|
languageDetectRe: /\blang(?:uage)?-([\w-]+)\b/i,
|
|
classPrefix: "hljs-",
|
|
cssSelector: "pre code",
|
|
languages: null,
|
|
// beta configuration options, subject to change, welcome to discuss
|
|
// https://github.com/highlightjs/highlight.js/issues/1086
|
|
__emitter: TokenTreeEmitter
|
|
};
|
|
function shouldNotHighlight(languageName) {
|
|
return options.noHighlightRe.test(languageName);
|
|
}
|
|
function blockLanguage(block) {
|
|
let classes = block.className + " ";
|
|
classes += block.parentNode ? block.parentNode.className : "";
|
|
const match2 = options.languageDetectRe.exec(classes);
|
|
if (match2) {
|
|
const language = getLanguage(match2[1]);
|
|
if (!language) {
|
|
warn2(LANGUAGE_NOT_FOUND.replace("{}", match2[1]));
|
|
warn2("Falling back to no-highlight mode for this block.", block);
|
|
}
|
|
return language ? match2[1] : "no-highlight";
|
|
}
|
|
return classes.split(/\s+/).find((_class) => shouldNotHighlight(_class) || getLanguage(_class));
|
|
}
|
|
function highlight2(codeOrLanguageName, optionsOrCode, ignoreIllegals) {
|
|
let code = "";
|
|
let languageName = "";
|
|
if (typeof optionsOrCode === "object") {
|
|
code = codeOrLanguageName;
|
|
ignoreIllegals = optionsOrCode.ignoreIllegals;
|
|
languageName = optionsOrCode.language;
|
|
} else {
|
|
deprecated("10.7.0", "highlight(lang, code, ...args) has been deprecated.");
|
|
deprecated("10.7.0", "Please use highlight(code, options) instead.\nhttps://github.com/highlightjs/highlight.js/issues/2277");
|
|
languageName = codeOrLanguageName;
|
|
code = optionsOrCode;
|
|
}
|
|
if (ignoreIllegals === void 0) {
|
|
ignoreIllegals = true;
|
|
}
|
|
const context = {
|
|
code,
|
|
language: languageName
|
|
};
|
|
fire("before:highlight", context);
|
|
const result = context.result ? context.result : _highlight(context.language, context.code, ignoreIllegals);
|
|
result.code = context.code;
|
|
fire("after:highlight", result);
|
|
return result;
|
|
}
|
|
function _highlight(languageName, codeToHighlight, ignoreIllegals, continuation) {
|
|
const keywordHits = /* @__PURE__ */ Object.create(null);
|
|
function keywordData(mode, matchText) {
|
|
return mode.keywords[matchText];
|
|
}
|
|
function processKeywords() {
|
|
if (!top.keywords) {
|
|
emitter.addText(modeBuffer);
|
|
return;
|
|
}
|
|
let lastIndex = 0;
|
|
top.keywordPatternRe.lastIndex = 0;
|
|
let match2 = top.keywordPatternRe.exec(modeBuffer);
|
|
let buf = "";
|
|
while (match2) {
|
|
buf += modeBuffer.substring(lastIndex, match2.index);
|
|
const word = language.case_insensitive ? match2[0].toLowerCase() : match2[0];
|
|
const data = keywordData(top, word);
|
|
if (data) {
|
|
const [kind, keywordRelevance] = data;
|
|
emitter.addText(buf);
|
|
buf = "";
|
|
keywordHits[word] = (keywordHits[word] || 0) + 1;
|
|
if (keywordHits[word] <= MAX_KEYWORD_HITS) relevance += keywordRelevance;
|
|
if (kind.startsWith("_")) {
|
|
buf += match2[0];
|
|
} else {
|
|
const cssClass = language.classNameAliases[kind] || kind;
|
|
emitKeyword(match2[0], cssClass);
|
|
}
|
|
} else {
|
|
buf += match2[0];
|
|
}
|
|
lastIndex = top.keywordPatternRe.lastIndex;
|
|
match2 = top.keywordPatternRe.exec(modeBuffer);
|
|
}
|
|
buf += modeBuffer.substring(lastIndex);
|
|
emitter.addText(buf);
|
|
}
|
|
function processSubLanguage() {
|
|
if (modeBuffer === "") return;
|
|
let result2 = null;
|
|
if (typeof top.subLanguage === "string") {
|
|
if (!languages[top.subLanguage]) {
|
|
emitter.addText(modeBuffer);
|
|
return;
|
|
}
|
|
result2 = _highlight(top.subLanguage, modeBuffer, true, continuations[top.subLanguage]);
|
|
continuations[top.subLanguage] = /** @type {CompiledMode} */
|
|
result2._top;
|
|
} else {
|
|
result2 = highlightAuto(modeBuffer, top.subLanguage.length ? top.subLanguage : null);
|
|
}
|
|
if (top.relevance > 0) {
|
|
relevance += result2.relevance;
|
|
}
|
|
emitter.__addSublanguage(result2._emitter, result2.language);
|
|
}
|
|
function processBuffer() {
|
|
if (top.subLanguage != null) {
|
|
processSubLanguage();
|
|
} else {
|
|
processKeywords();
|
|
}
|
|
modeBuffer = "";
|
|
}
|
|
function emitKeyword(keyword, scope) {
|
|
if (keyword === "") return;
|
|
emitter.startScope(scope);
|
|
emitter.addText(keyword);
|
|
emitter.endScope();
|
|
}
|
|
function emitMultiClass(scope, match2) {
|
|
let i = 1;
|
|
const max = match2.length - 1;
|
|
while (i <= max) {
|
|
if (!scope._emit[i]) {
|
|
i++;
|
|
continue;
|
|
}
|
|
const klass = language.classNameAliases[scope[i]] || scope[i];
|
|
const text = match2[i];
|
|
if (klass) {
|
|
emitKeyword(text, klass);
|
|
} else {
|
|
modeBuffer = text;
|
|
processKeywords();
|
|
modeBuffer = "";
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
function startNewMode(mode, match2) {
|
|
if (mode.scope && typeof mode.scope === "string") {
|
|
emitter.openNode(language.classNameAliases[mode.scope] || mode.scope);
|
|
}
|
|
if (mode.beginScope) {
|
|
if (mode.beginScope._wrap) {
|
|
emitKeyword(modeBuffer, language.classNameAliases[mode.beginScope._wrap] || mode.beginScope._wrap);
|
|
modeBuffer = "";
|
|
} else if (mode.beginScope._multi) {
|
|
emitMultiClass(mode.beginScope, match2);
|
|
modeBuffer = "";
|
|
}
|
|
}
|
|
top = Object.create(mode, { parent: { value: top } });
|
|
return top;
|
|
}
|
|
function endOfMode(mode, match2, matchPlusRemainder) {
|
|
let matched = startsWith(mode.endRe, matchPlusRemainder);
|
|
if (matched) {
|
|
if (mode["on:end"]) {
|
|
const resp = new Response2(mode);
|
|
mode["on:end"](match2, resp);
|
|
if (resp.isMatchIgnored) matched = false;
|
|
}
|
|
if (matched) {
|
|
while (mode.endsParent && mode.parent) {
|
|
mode = mode.parent;
|
|
}
|
|
return mode;
|
|
}
|
|
}
|
|
if (mode.endsWithParent) {
|
|
return endOfMode(mode.parent, match2, matchPlusRemainder);
|
|
}
|
|
}
|
|
function doIgnore(lexeme) {
|
|
if (top.matcher.regexIndex === 0) {
|
|
modeBuffer += lexeme[0];
|
|
return 1;
|
|
} else {
|
|
resumeScanAtSamePosition = true;
|
|
return 0;
|
|
}
|
|
}
|
|
function doBeginMatch(match2) {
|
|
const lexeme = match2[0];
|
|
const newMode = match2.rule;
|
|
const resp = new Response2(newMode);
|
|
const beforeCallbacks = [newMode.__beforeBegin, newMode["on:begin"]];
|
|
for (const cb of beforeCallbacks) {
|
|
if (!cb) continue;
|
|
cb(match2, resp);
|
|
if (resp.isMatchIgnored) return doIgnore(lexeme);
|
|
}
|
|
if (newMode.skip) {
|
|
modeBuffer += lexeme;
|
|
} else {
|
|
if (newMode.excludeBegin) {
|
|
modeBuffer += lexeme;
|
|
}
|
|
processBuffer();
|
|
if (!newMode.returnBegin && !newMode.excludeBegin) {
|
|
modeBuffer = lexeme;
|
|
}
|
|
}
|
|
startNewMode(newMode, match2);
|
|
return newMode.returnBegin ? 0 : lexeme.length;
|
|
}
|
|
function doEndMatch(match2) {
|
|
const lexeme = match2[0];
|
|
const matchPlusRemainder = codeToHighlight.substring(match2.index);
|
|
const endMode = endOfMode(top, match2, matchPlusRemainder);
|
|
if (!endMode) {
|
|
return NO_MATCH;
|
|
}
|
|
const origin2 = top;
|
|
if (top.endScope && top.endScope._wrap) {
|
|
processBuffer();
|
|
emitKeyword(lexeme, top.endScope._wrap);
|
|
} else if (top.endScope && top.endScope._multi) {
|
|
processBuffer();
|
|
emitMultiClass(top.endScope, match2);
|
|
} else if (origin2.skip) {
|
|
modeBuffer += lexeme;
|
|
} else {
|
|
if (!(origin2.returnEnd || origin2.excludeEnd)) {
|
|
modeBuffer += lexeme;
|
|
}
|
|
processBuffer();
|
|
if (origin2.excludeEnd) {
|
|
modeBuffer = lexeme;
|
|
}
|
|
}
|
|
do {
|
|
if (top.scope) {
|
|
emitter.closeNode();
|
|
}
|
|
if (!top.skip && !top.subLanguage) {
|
|
relevance += top.relevance;
|
|
}
|
|
top = top.parent;
|
|
} while (top !== endMode.parent);
|
|
if (endMode.starts) {
|
|
startNewMode(endMode.starts, match2);
|
|
}
|
|
return origin2.returnEnd ? 0 : lexeme.length;
|
|
}
|
|
function processContinuations() {
|
|
const list = [];
|
|
for (let current = top; current !== language; current = current.parent) {
|
|
if (current.scope) {
|
|
list.unshift(current.scope);
|
|
}
|
|
}
|
|
list.forEach((item) => emitter.openNode(item));
|
|
}
|
|
let lastMatch = {};
|
|
function processLexeme(textBeforeMatch, match2) {
|
|
const lexeme = match2 && match2[0];
|
|
modeBuffer += textBeforeMatch;
|
|
if (lexeme == null) {
|
|
processBuffer();
|
|
return 0;
|
|
}
|
|
if (lastMatch.type === "begin" && match2.type === "end" && lastMatch.index === match2.index && lexeme === "") {
|
|
modeBuffer += codeToHighlight.slice(match2.index, match2.index + 1);
|
|
if (!SAFE_MODE) {
|
|
const err = new Error(`0 width match regex (${languageName})`);
|
|
err.languageName = languageName;
|
|
err.badRule = lastMatch.rule;
|
|
throw err;
|
|
}
|
|
return 1;
|
|
}
|
|
lastMatch = match2;
|
|
if (match2.type === "begin") {
|
|
return doBeginMatch(match2);
|
|
} else if (match2.type === "illegal" && !ignoreIllegals) {
|
|
const err = new Error('Illegal lexeme "' + lexeme + '" for mode "' + (top.scope || "<unnamed>") + '"');
|
|
err.mode = top;
|
|
throw err;
|
|
} else if (match2.type === "end") {
|
|
const processed = doEndMatch(match2);
|
|
if (processed !== NO_MATCH) {
|
|
return processed;
|
|
}
|
|
}
|
|
if (match2.type === "illegal" && lexeme === "") {
|
|
modeBuffer += "\n";
|
|
return 1;
|
|
}
|
|
if (iterations > 1e5 && iterations > match2.index * 3) {
|
|
const err = new Error("potential infinite loop, way more iterations than matches");
|
|
throw err;
|
|
}
|
|
modeBuffer += lexeme;
|
|
return lexeme.length;
|
|
}
|
|
const language = getLanguage(languageName);
|
|
if (!language) {
|
|
error2(LANGUAGE_NOT_FOUND.replace("{}", languageName));
|
|
throw new Error('Unknown language: "' + languageName + '"');
|
|
}
|
|
const md = compileLanguage(language);
|
|
let result = "";
|
|
let top = continuation || md;
|
|
const continuations = {};
|
|
const emitter = new options.__emitter(options);
|
|
processContinuations();
|
|
let modeBuffer = "";
|
|
let relevance = 0;
|
|
let index = 0;
|
|
let iterations = 0;
|
|
let resumeScanAtSamePosition = false;
|
|
try {
|
|
if (!language.__emitTokens) {
|
|
top.matcher.considerAll();
|
|
for (; ; ) {
|
|
iterations++;
|
|
if (resumeScanAtSamePosition) {
|
|
resumeScanAtSamePosition = false;
|
|
} else {
|
|
top.matcher.considerAll();
|
|
}
|
|
top.matcher.lastIndex = index;
|
|
const match2 = top.matcher.exec(codeToHighlight);
|
|
if (!match2) break;
|
|
const beforeMatch = codeToHighlight.substring(index, match2.index);
|
|
const processedCount = processLexeme(beforeMatch, match2);
|
|
index = match2.index + processedCount;
|
|
}
|
|
processLexeme(codeToHighlight.substring(index));
|
|
} else {
|
|
language.__emitTokens(codeToHighlight, emitter);
|
|
}
|
|
emitter.finalize();
|
|
result = emitter.toHTML();
|
|
return {
|
|
language: languageName,
|
|
value: result,
|
|
relevance,
|
|
illegal: false,
|
|
_emitter: emitter,
|
|
_top: top
|
|
};
|
|
} catch (err) {
|
|
if (err.message && err.message.includes("Illegal")) {
|
|
return {
|
|
language: languageName,
|
|
value: escape(codeToHighlight),
|
|
illegal: true,
|
|
relevance: 0,
|
|
_illegalBy: {
|
|
message: err.message,
|
|
index,
|
|
context: codeToHighlight.slice(index - 100, index + 100),
|
|
mode: err.mode,
|
|
resultSoFar: result
|
|
},
|
|
_emitter: emitter
|
|
};
|
|
} else if (SAFE_MODE) {
|
|
return {
|
|
language: languageName,
|
|
value: escape(codeToHighlight),
|
|
illegal: false,
|
|
relevance: 0,
|
|
errorRaised: err,
|
|
_emitter: emitter,
|
|
_top: top
|
|
};
|
|
} else {
|
|
throw err;
|
|
}
|
|
}
|
|
}
|
|
function justTextHighlightResult(code) {
|
|
const result = {
|
|
value: escape(code),
|
|
illegal: false,
|
|
relevance: 0,
|
|
_top: PLAINTEXT_LANGUAGE,
|
|
_emitter: new options.__emitter(options)
|
|
};
|
|
result._emitter.addText(code);
|
|
return result;
|
|
}
|
|
function highlightAuto(code, languageSubset) {
|
|
languageSubset = languageSubset || options.languages || Object.keys(languages);
|
|
const plaintext = justTextHighlightResult(code);
|
|
const results = languageSubset.filter(getLanguage).filter(autoDetection).map(
|
|
(name) => _highlight(name, code, false)
|
|
);
|
|
results.unshift(plaintext);
|
|
const sorted = results.sort((a, b) => {
|
|
if (a.relevance !== b.relevance) return b.relevance - a.relevance;
|
|
if (a.language && b.language) {
|
|
if (getLanguage(a.language).supersetOf === b.language) {
|
|
return 1;
|
|
} else if (getLanguage(b.language).supersetOf === a.language) {
|
|
return -1;
|
|
}
|
|
}
|
|
return 0;
|
|
});
|
|
const [best, secondBest] = sorted;
|
|
const result = best;
|
|
result.secondBest = secondBest;
|
|
return result;
|
|
}
|
|
function updateClassName(element, currentLang, resultLang) {
|
|
const language = currentLang && aliases[currentLang] || resultLang;
|
|
element.classList.add("hljs");
|
|
element.classList.add(`language-${language}`);
|
|
}
|
|
function highlightElement(element) {
|
|
let node = null;
|
|
const language = blockLanguage(element);
|
|
if (shouldNotHighlight(language)) return;
|
|
fire(
|
|
"before:highlightElement",
|
|
{ el: element, language }
|
|
);
|
|
if (element.dataset.highlighted) {
|
|
console.log("Element previously highlighted. To highlight again, first unset `dataset.highlighted`.", element);
|
|
return;
|
|
}
|
|
if (element.children.length > 0) {
|
|
if (!options.ignoreUnescapedHTML) {
|
|
console.warn("One of your code blocks includes unescaped HTML. This is a potentially serious security risk.");
|
|
console.warn("https://github.com/highlightjs/highlight.js/wiki/security");
|
|
console.warn("The element with unescaped HTML:");
|
|
console.warn(element);
|
|
}
|
|
if (options.throwUnescapedHTML) {
|
|
const err = new HTMLInjectionError(
|
|
"One of your code blocks includes unescaped HTML.",
|
|
element.innerHTML
|
|
);
|
|
throw err;
|
|
}
|
|
}
|
|
node = element;
|
|
const text = node.textContent;
|
|
const result = language ? highlight2(text, { language, ignoreIllegals: true }) : highlightAuto(text);
|
|
element.innerHTML = result.value;
|
|
element.dataset.highlighted = "yes";
|
|
updateClassName(element, language, result.language);
|
|
element.result = {
|
|
language: result.language,
|
|
// TODO: remove with version 11.0
|
|
re: result.relevance,
|
|
relevance: result.relevance
|
|
};
|
|
if (result.secondBest) {
|
|
element.secondBest = {
|
|
language: result.secondBest.language,
|
|
relevance: result.secondBest.relevance
|
|
};
|
|
}
|
|
fire("after:highlightElement", { el: element, result, text });
|
|
}
|
|
function configure(userOptions) {
|
|
options = inherit(options, userOptions);
|
|
}
|
|
const initHighlighting = () => {
|
|
highlightAll();
|
|
deprecated("10.6.0", "initHighlighting() deprecated. Use highlightAll() now.");
|
|
};
|
|
function initHighlightingOnLoad() {
|
|
highlightAll();
|
|
deprecated("10.6.0", "initHighlightingOnLoad() deprecated. Use highlightAll() now.");
|
|
}
|
|
let wantsHighlight = false;
|
|
function highlightAll() {
|
|
function boot() {
|
|
highlightAll();
|
|
}
|
|
if (document.readyState === "loading") {
|
|
if (!wantsHighlight) {
|
|
window.addEventListener("DOMContentLoaded", boot, false);
|
|
}
|
|
wantsHighlight = true;
|
|
return;
|
|
}
|
|
const blocks = document.querySelectorAll(options.cssSelector);
|
|
blocks.forEach(highlightElement);
|
|
}
|
|
function registerLanguage(languageName, languageDefinition) {
|
|
let lang = null;
|
|
try {
|
|
lang = languageDefinition(hljs);
|
|
} catch (error$1) {
|
|
error2("Language definition for '{}' could not be registered.".replace("{}", languageName));
|
|
if (!SAFE_MODE) {
|
|
throw error$1;
|
|
} else {
|
|
error2(error$1);
|
|
}
|
|
lang = PLAINTEXT_LANGUAGE;
|
|
}
|
|
if (!lang.name) lang.name = languageName;
|
|
languages[languageName] = lang;
|
|
lang.rawDefinition = languageDefinition.bind(null, hljs);
|
|
if (lang.aliases) {
|
|
registerAliases(lang.aliases, { languageName });
|
|
}
|
|
}
|
|
function unregisterLanguage(languageName) {
|
|
delete languages[languageName];
|
|
for (const alias of Object.keys(aliases)) {
|
|
if (aliases[alias] === languageName) {
|
|
delete aliases[alias];
|
|
}
|
|
}
|
|
}
|
|
function listLanguages() {
|
|
return Object.keys(languages);
|
|
}
|
|
function getLanguage(name) {
|
|
name = (name || "").toLowerCase();
|
|
return languages[name] || languages[aliases[name]];
|
|
}
|
|
function registerAliases(aliasList, { languageName }) {
|
|
if (typeof aliasList === "string") {
|
|
aliasList = [aliasList];
|
|
}
|
|
aliasList.forEach((alias) => {
|
|
aliases[alias.toLowerCase()] = languageName;
|
|
});
|
|
}
|
|
function autoDetection(name) {
|
|
const lang = getLanguage(name);
|
|
return lang && !lang.disableAutodetect;
|
|
}
|
|
function upgradePluginAPI(plugin2) {
|
|
if (plugin2["before:highlightBlock"] && !plugin2["before:highlightElement"]) {
|
|
plugin2["before:highlightElement"] = (data) => {
|
|
plugin2["before:highlightBlock"](
|
|
Object.assign({ block: data.el }, data)
|
|
);
|
|
};
|
|
}
|
|
if (plugin2["after:highlightBlock"] && !plugin2["after:highlightElement"]) {
|
|
plugin2["after:highlightElement"] = (data) => {
|
|
plugin2["after:highlightBlock"](
|
|
Object.assign({ block: data.el }, data)
|
|
);
|
|
};
|
|
}
|
|
}
|
|
function addPlugin(plugin2) {
|
|
upgradePluginAPI(plugin2);
|
|
plugins.push(plugin2);
|
|
}
|
|
function removePlugin(plugin2) {
|
|
const index = plugins.indexOf(plugin2);
|
|
if (index !== -1) {
|
|
plugins.splice(index, 1);
|
|
}
|
|
}
|
|
function fire(event, args) {
|
|
const cb = event;
|
|
plugins.forEach(function(plugin2) {
|
|
if (plugin2[cb]) {
|
|
plugin2[cb](args);
|
|
}
|
|
});
|
|
}
|
|
function deprecateHighlightBlock(el) {
|
|
deprecated("10.7.0", "highlightBlock will be removed entirely in v12.0");
|
|
deprecated("10.7.0", "Please use highlightElement now.");
|
|
return highlightElement(el);
|
|
}
|
|
Object.assign(hljs, {
|
|
highlight: highlight2,
|
|
highlightAuto,
|
|
highlightAll,
|
|
highlightElement,
|
|
// TODO: Remove with v12 API
|
|
highlightBlock: deprecateHighlightBlock,
|
|
configure,
|
|
initHighlighting,
|
|
initHighlightingOnLoad,
|
|
registerLanguage,
|
|
unregisterLanguage,
|
|
listLanguages,
|
|
getLanguage,
|
|
registerAliases,
|
|
autoDetection,
|
|
inherit,
|
|
addPlugin,
|
|
removePlugin
|
|
});
|
|
hljs.debugMode = function() {
|
|
SAFE_MODE = false;
|
|
};
|
|
hljs.safeMode = function() {
|
|
SAFE_MODE = true;
|
|
};
|
|
hljs.versionString = version2;
|
|
hljs.regex = {
|
|
concat,
|
|
lookahead,
|
|
either,
|
|
optional,
|
|
anyNumberOfTimes
|
|
};
|
|
for (const key in MODES) {
|
|
if (typeof MODES[key] === "object") {
|
|
deepFreeze(MODES[key]);
|
|
}
|
|
}
|
|
Object.assign(hljs, MODES);
|
|
return hljs;
|
|
};
|
|
const highlight = HLJS({});
|
|
highlight.newInstance = () => HLJS({});
|
|
core = highlight;
|
|
highlight.HighlightJS = highlight;
|
|
highlight.default = highlight;
|
|
return core;
|
|
}
|
|
var coreExports = /* @__PURE__ */ requireCore();
|
|
const HighlightJS = /* @__PURE__ */ getDefaultExportFromCjs(coreExports);
|
|
function json(hljs) {
|
|
const ATTRIBUTE = {
|
|
className: "attr",
|
|
begin: /"(\\.|[^\\"\r\n])*"(?=\s*:)/,
|
|
relevance: 1.01
|
|
};
|
|
const PUNCTUATION = {
|
|
match: /[{}[\],:]/,
|
|
className: "punctuation",
|
|
relevance: 0
|
|
};
|
|
const LITERALS = [
|
|
"true",
|
|
"false",
|
|
"null"
|
|
];
|
|
const LITERALS_MODE = {
|
|
scope: "literal",
|
|
beginKeywords: LITERALS.join(" ")
|
|
};
|
|
return {
|
|
name: "JSON",
|
|
aliases: ["jsonc"],
|
|
keywords: {
|
|
literal: LITERALS
|
|
},
|
|
contains: [
|
|
ATTRIBUTE,
|
|
PUNCTUATION,
|
|
hljs.QUOTE_STRING_MODE,
|
|
LITERALS_MODE,
|
|
hljs.C_NUMBER_MODE,
|
|
hljs.C_LINE_COMMENT_MODE,
|
|
hljs.C_BLOCK_COMMENT_MODE
|
|
],
|
|
illegal: "\\S"
|
|
};
|
|
}
|
|
HighlightJS.registerLanguage("json", json);
|
|
function registerMowerLanguage(operators) {
|
|
const r = RegExp(operators.map((x) => "'" + x.value).join("|"));
|
|
HighlightJS.registerLanguage("mower", () => ({
|
|
contains: [
|
|
{
|
|
begin: r,
|
|
end: /'/,
|
|
className: "operator",
|
|
relevance: 0
|
|
},
|
|
{
|
|
begin: /宿舍黑名单|重设上次房间为空/,
|
|
relevance: 10
|
|
},
|
|
{
|
|
begin: /[0-9]+(-[0-9]+)+/,
|
|
className: "date"
|
|
},
|
|
{
|
|
begin: /[0-9]+:[0-9]+:[0-9]+((\.|,)[0-9]+)?/,
|
|
className: "time"
|
|
},
|
|
{
|
|
begin: /room_[0-9]_[0-9]|dormitory_[0-9]|central|contact|factory|meeting/,
|
|
className: "room"
|
|
},
|
|
{
|
|
begin: /INFO/,
|
|
className: "info"
|
|
},
|
|
{
|
|
begin: /WARNING/,
|
|
className: "warning"
|
|
},
|
|
{
|
|
begin: /ERROR/,
|
|
className: "error"
|
|
},
|
|
{
|
|
begin: /Scene [0-9]+:.*/,
|
|
className: "scene"
|
|
}
|
|
]
|
|
}));
|
|
}
|
|
const usePlanStore = /* @__PURE__ */ defineStore("plan", () => {
|
|
const ling_xi = ref(1);
|
|
const max_resting_count = ref([]);
|
|
const exhaust_require = ref([]);
|
|
const rest_in_full = ref([]);
|
|
const resting_priority = ref([]);
|
|
const workaholic = ref([]);
|
|
const refresh_trading = ref([]);
|
|
const plan = ref({});
|
|
const backup_plans = ref([]);
|
|
const operators = ref([]);
|
|
const left_side_facility = [];
|
|
const facility_operator_limit = {
|
|
central: 5,
|
|
meeting: 2,
|
|
factory: 1,
|
|
contact: 1,
|
|
train: 2
|
|
};
|
|
for (let i = 1; i <= 3; ++i) {
|
|
for (let j = 1; j <= 3; ++j) {
|
|
const facility_name = `room_${i}_${j}`;
|
|
const display_name = `B${i}0${j}`;
|
|
facility_operator_limit[facility_name] = 3;
|
|
left_side_facility.push({ label: display_name, value: facility_name });
|
|
}
|
|
}
|
|
for (let i = 1; i <= 4; ++i) {
|
|
facility_operator_limit[`dormitory_${i}`] = 5;
|
|
}
|
|
function list2str(data) {
|
|
return data.join(",");
|
|
}
|
|
function str2list(data) {
|
|
return data && data != "" ? data.split(",") : [];
|
|
}
|
|
const backup_conf_convert_list = [
|
|
"exhaust_require",
|
|
"rest_in_full",
|
|
"resting_priority",
|
|
"workaholic",
|
|
"free_blacklist",
|
|
"refresh_trading"
|
|
];
|
|
function fill_empty(full_plan) {
|
|
for (const i in facility_operator_limit) {
|
|
let count = 0;
|
|
if (!full_plan[i]) {
|
|
count = facility_operator_limit[i];
|
|
full_plan[i] = { name: "", plans: [] };
|
|
} else {
|
|
let limit2 = facility_operator_limit[i];
|
|
if (full_plan[i].name == "发电站") {
|
|
limit2 = 1;
|
|
} else if (full_plan[i].name == "贸易站") {
|
|
if (!["lmd", "orundum"].includes(full_plan[i].product)) {
|
|
full_plan[i].product = "lmd";
|
|
}
|
|
} else if (full_plan[i].name == "制造站") {
|
|
if (!["gold", "exp3", "orirock"].includes(full_plan[i].product)) {
|
|
full_plan[i].product = "gold";
|
|
}
|
|
}
|
|
if (full_plan[i].plans.length < limit2) {
|
|
count = limit2 - full_plan[i].plans.length;
|
|
}
|
|
}
|
|
for (let j = 0; j < count; ++j) {
|
|
full_plan[i].plans.push({ agent: "", group: "", replacement: [] });
|
|
}
|
|
}
|
|
return full_plan;
|
|
}
|
|
function remove_empty_agent(input) {
|
|
const result = {
|
|
name: input.name,
|
|
plans: []
|
|
};
|
|
if (["贸易站", "制造站"].includes(input.name)) {
|
|
result.product = input.product;
|
|
}
|
|
for (const i of input.plans) {
|
|
if (i.agent) {
|
|
result.plans.push(i);
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
function strip_plan(plan2) {
|
|
const plan1 = {};
|
|
for (const i in facility_operator_limit) {
|
|
if (i.startsWith("room") && plan2[i].name) {
|
|
plan1[i] = remove_empty_agent(plan2[i]);
|
|
} else {
|
|
let empty = true;
|
|
for (const j of plan2[i].plans) {
|
|
if (j.agent) {
|
|
empty = false;
|
|
break;
|
|
}
|
|
}
|
|
if (!empty) {
|
|
plan1[i] = remove_empty_agent(plan2[i]);
|
|
}
|
|
}
|
|
}
|
|
return plan1;
|
|
}
|
|
async function load_plan() {
|
|
const response = await axios.get(`${""}/plan`);
|
|
ling_xi.value = response.data.conf.ling_xi;
|
|
max_resting_count.value = response.data.conf.max_resting_count;
|
|
exhaust_require.value = str2list(response.data.conf.exhaust_require);
|
|
rest_in_full.value = str2list(response.data.conf.rest_in_full);
|
|
resting_priority.value = str2list(response.data.conf.resting_priority);
|
|
workaholic.value = str2list(response.data.conf.workaholic);
|
|
refresh_trading.value = str2list(response.data.conf.refresh_trading);
|
|
plan.value = fill_empty(response.data.plan1);
|
|
backup_plans.value = response.data.backup_plans ?? [];
|
|
for (let b of backup_plans.value) {
|
|
for (const i of backup_conf_convert_list) {
|
|
b.conf[i] = str2list(b.conf[i]);
|
|
}
|
|
b.plan = fill_empty(b.plan);
|
|
}
|
|
}
|
|
async function load_operators() {
|
|
const response = await axios.get(`${""}/operator`);
|
|
const option_list = [];
|
|
for (const i of response.data) {
|
|
option_list.push({
|
|
value: i,
|
|
label: i
|
|
});
|
|
}
|
|
operators.value = option_list;
|
|
}
|
|
function build_plan() {
|
|
const result = {
|
|
default: "plan1",
|
|
plan1: strip_plan(plan.value),
|
|
conf: {
|
|
ling_xi: ling_xi.value,
|
|
max_resting_count: max_resting_count.value,
|
|
exhaust_require: list2str(exhaust_require.value),
|
|
rest_in_full: list2str(rest_in_full.value),
|
|
resting_priority: list2str(resting_priority.value),
|
|
workaholic: list2str(workaholic.value),
|
|
refresh_trading: list2str(refresh_trading.value)
|
|
},
|
|
backup_plans: deepcopy(backup_plans.value)
|
|
};
|
|
for (const b of result.backup_plans) {
|
|
for (const i of backup_conf_convert_list) {
|
|
b.conf[i] = list2str(b.conf[i]);
|
|
}
|
|
b.plan = strip_plan(b.plan);
|
|
}
|
|
const plan1 = result.plan1;
|
|
for (const i in facility_operator_limit) {
|
|
if (i.startsWith("room") && plan.value[i].name) {
|
|
plan1[i] = remove_empty_agent(plan.value[i]);
|
|
} else {
|
|
let empty = true;
|
|
for (const j of plan.value[i].plans) {
|
|
if (j.agent) {
|
|
empty = false;
|
|
break;
|
|
}
|
|
}
|
|
if (!empty) {
|
|
plan1[i] = remove_empty_agent(plan.value[i]);
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
const loaded = inject("loaded");
|
|
watchEffect(() => {
|
|
if (loaded.value) {
|
|
axios.post(`${""}/plan`, build_plan());
|
|
}
|
|
});
|
|
const groups = computed(() => {
|
|
const result = [];
|
|
for (const facility in plan.value) {
|
|
for (const p2 of plan.value[facility].plans) {
|
|
if (p2.group) {
|
|
result.push(p2.group);
|
|
}
|
|
}
|
|
}
|
|
return [...new Set(result)];
|
|
});
|
|
const sub_plan = ref("main");
|
|
const current_plan = computed(() => {
|
|
if (sub_plan.value == "main") {
|
|
return plan.value;
|
|
} else {
|
|
return backup_plans.value[sub_plan.value].plan;
|
|
}
|
|
});
|
|
return {
|
|
load_plan,
|
|
load_operators,
|
|
ling_xi,
|
|
max_resting_count,
|
|
exhaust_require,
|
|
rest_in_full,
|
|
resting_priority,
|
|
workaholic,
|
|
refresh_trading,
|
|
plan,
|
|
operators,
|
|
facility_operator_limit,
|
|
left_side_facility,
|
|
build_plan,
|
|
groups,
|
|
backup_plans,
|
|
sub_plan,
|
|
current_plan,
|
|
fill_empty
|
|
};
|
|
});
|
|
const usewatermarkStore = /* @__PURE__ */ defineStore("watermark", () => {
|
|
async function getwatermarkinfo() {
|
|
const response = await axios.get(`${""}/getwatermark`);
|
|
return response.data.toString();
|
|
}
|
|
return {
|
|
getwatermarkinfo
|
|
};
|
|
});
|
|
const common = { "borderColor": "#dcdfe6", "dividerColor": "#ebeef5", "primaryColor": "#409eff", "primaryColorHover": "#66b1ff", "primaryColorPressed": "#3a8ee6", "placeholderColor": "#c0c4cb", "heightSmall": "24px", "heightTiny": "24px", "borderRadius": "4px", "borderRadiusSmall": "4px", "infoColor": "#909399", "infoColorHover": "#a6a9ad", "infoColorPressed": "#82848a", "successColor": "#67c23a", "successColorHover": "#85ce61", "successColorPressed": "#5daf34", "warningColor": "#e6a23c", "warningColorHover": "#ebb563", "warningColorPressed": "#cf9236", "errorColor": "#f56c6c", "errorColorHover": "#f78989", "errorColorPressed": "#dd6161", "textColor2": "rgba(96, 98, 102, 1)", "textColor1": "rgba(48, 49, 51, 1)", "tableHeaderColor": "transparent", "fontWeightStrong": "500", "heightMedium": "32px" };
|
|
const Input = { "paddingLeftMedium": "16px", "paddingRightMedium": "16px" };
|
|
const Button = { "paddingMedium": "0 16px", "paddingLarge": "0 20px", "paddingSmall": "0 12px" };
|
|
const Progress = { "railHeight": "6px" };
|
|
const Checkbox = { "textColor": "#606266" };
|
|
const Alert = { "border": "none", "borderInfo": "none", "borderSuccess": "none", "borderWarning": "none", "borderError": "none" };
|
|
const Anchor = { "linkFontSize": "12px", "linkColor": "transparent", "railColorActive": "#409effFF", "linkPadding": "0 0 0 10px", "railWidth": "4px", "railColor": "rgba(219, 219, 223, 0)" };
|
|
const DataTable = { "thTextColor": "rgba(144, 147, 153, 1)" };
|
|
const theme_data = {
|
|
common,
|
|
Input,
|
|
Button,
|
|
Progress,
|
|
Checkbox,
|
|
Alert,
|
|
Anchor,
|
|
DataTable
|
|
};
|
|
const _export_sfc = (sfc, props) => {
|
|
const target = sfc.__vccOpts || sfc;
|
|
for (const [key, val] of props) {
|
|
target[key] = val;
|
|
}
|
|
return target;
|
|
};
|
|
const _sfc_main = {
|
|
__name: "App",
|
|
setup(__props) {
|
|
const paomadeng = /* @__PURE__ */ defineAsyncComponent(() => __vitePreload(() => import("./paomadeng.js"), true ? __vite__mapDeps([0,1,2,3]) : void 0));
|
|
const desktop_menu = /* @__PURE__ */ defineAsyncComponent(() => __vitePreload(() => import("./menu.js"), true ? __vite__mapDeps([4,5,6,7,8,9,10,11,12]) : void 0));
|
|
const mobile_menu = /* @__PURE__ */ defineAsyncComponent(() => __vitePreload(() => import("./tabs.js"), true ? __vite__mapDeps([13,14,15,16,8,10,17]) : void 0));
|
|
const DesktopSettings = /* @__PURE__ */ defineAsyncComponent(() => __vitePreload(() => import("./DesktopSettings.js"), true ? __vite__mapDeps([18,6,7,8,9,10,11,12,5,19,20,21,22,23,24,25,26,27,28,14,29,30,31,16,32,33,34,35,36,2,15,37,38,39,40]) : void 0));
|
|
const watermarkStore = usewatermarkStore();
|
|
const { getwatermarkinfo } = watermarkStore;
|
|
const watermarkData = ref("mower");
|
|
const config_store = useConfigStore();
|
|
const { load_config, load_shop, load_scene } = config_store;
|
|
const { conf } = storeToRefs(config_store);
|
|
const plan_store = usePlanStore();
|
|
const { operators } = storeToRefs(plan_store);
|
|
const { load_plan, load_operators } = plan_store;
|
|
const mower_store = useMowerStore();
|
|
const { get_running } = mower_store;
|
|
const axios2 = inject("axios");
|
|
function actions_on_resize() {
|
|
mobile.value = window.innerWidth < 800;
|
|
}
|
|
const mobile = ref(true);
|
|
provide("mobile", mobile);
|
|
const loaded = inject("loaded");
|
|
const operators_with_free_current = computed(() => {
|
|
return [
|
|
{ value: "Current", label: "Current" },
|
|
{ value: "Free", label: "Free" }
|
|
].concat(operators.value);
|
|
});
|
|
async function get_profile_name() {
|
|
const { data } = await axios2.get(`${""}/profile-name`);
|
|
document.title = data.profile_name;
|
|
}
|
|
onMounted(async () => {
|
|
actions_on_resize();
|
|
window.addEventListener("resize", () => {
|
|
actions_on_resize();
|
|
});
|
|
const params = new URLSearchParams(document.location.search);
|
|
const token = params.get("token");
|
|
provide("token", token);
|
|
axios2.defaults.headers.common["token"] = token;
|
|
await Promise.all([
|
|
load_config(),
|
|
load_shop(),
|
|
load_scene(),
|
|
load_operators(),
|
|
get_running(),
|
|
get_profile_name()
|
|
]);
|
|
await load_plan();
|
|
loaded.value = true;
|
|
RegExp(operators_with_free_current.value.map((x) => "'" + x.value).join("|"));
|
|
registerMowerLanguage(operators_with_free_current.value);
|
|
watermarkData.value = await getwatermarkinfo();
|
|
});
|
|
const show_paomadeng = ref(true);
|
|
provide("show_paomadeng", show_paomadeng);
|
|
return (_ctx, _cache) => {
|
|
const _component_n_global_style = __unplugin_components_0;
|
|
const _component_WebSocket = _sfc_main$1;
|
|
const _component_n_watermark = __unplugin_components_2;
|
|
const _component_n_layout_sider = NLayoutSider;
|
|
const _component_router_view = resolveComponent("router-view");
|
|
const _component_n_layout_content = NLayoutContent;
|
|
const _component_n_layout_footer = __unplugin_components_5;
|
|
const _component_n_layout = NLayout;
|
|
const _component_n_notification_provider = __unplugin_components_7;
|
|
const _component_n_loading_bar_provider = __unplugin_components_8;
|
|
const _component_n_message_provider = __unplugin_components_9;
|
|
const _component_n_modal_provider = NModalProvider;
|
|
const _component_n_config_provider = __unplugin_components_11;
|
|
return openBlock(), createBlock(_component_n_config_provider, {
|
|
locale: unref(zhCN$1),
|
|
"date-locale": unref(dateZhCN),
|
|
"theme-overrides": unref(theme_data),
|
|
hljs: unref(HighlightJS),
|
|
style: { "user-select": "none", "height": "100%" }
|
|
}, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_n_global_style),
|
|
createVNode(_component_n_modal_provider, null, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_n_message_provider, null, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_n_loading_bar_provider, null, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_n_notification_provider, { max: 3 }, {
|
|
default: withCtx(() => [
|
|
createVNode(_component_WebSocket),
|
|
createVNode(_component_n_watermark, {
|
|
content: watermarkData.value,
|
|
cross: "",
|
|
fullscreen: "",
|
|
"font-size": 16,
|
|
"line-height": 32,
|
|
width: 400,
|
|
height: 384,
|
|
"x-offset": 12,
|
|
"y-offset": 60,
|
|
rotate: -15
|
|
}, null, 8, ["content"]),
|
|
createVNode(unref(paomadeng)),
|
|
createVNode(_component_n_layout, {
|
|
"has-sider": !mobile.value,
|
|
class: "outer-layout"
|
|
}, {
|
|
default: withCtx(() => [
|
|
!mobile.value ? (openBlock(), createBlock(_component_n_layout_sider, {
|
|
key: 0,
|
|
bordered: "",
|
|
"collapse-mode": "width",
|
|
"collapsed-width": 64,
|
|
width: 210,
|
|
"show-trigger": ""
|
|
}, {
|
|
default: withCtx(() => [
|
|
createVNode(unref(desktop_menu))
|
|
]),
|
|
_: 1
|
|
})) : createCommentVNode("", true),
|
|
createVNode(_component_n_layout_content, { class: "layout-content-container" }, {
|
|
default: withCtx(() => [
|
|
unref(loaded) ? (openBlock(), createBlock(_component_router_view, { key: 0 })) : createCommentVNode("", true),
|
|
!mobile.value ? (openBlock(), createBlock(unref(DesktopSettings), { key: 1 })) : createCommentVNode("", true)
|
|
]),
|
|
_: 1
|
|
}),
|
|
mobile.value ? (openBlock(), createBlock(_component_n_layout_footer, { key: 1 }, {
|
|
default: withCtx(() => [
|
|
createVNode(unref(mobile_menu))
|
|
]),
|
|
_: 1
|
|
})) : createCommentVNode("", true)
|
|
]),
|
|
_: 1
|
|
}, 8, ["has-sider"])
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
})
|
|
]),
|
|
_: 1
|
|
}, 8, ["locale", "date-locale", "theme-overrides", "hljs"]);
|
|
};
|
|
}
|
|
};
|
|
const App = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-7f2c8f94"]]);
|
|
/*!
|
|
* vue-router v4.5.0
|
|
* (c) 2024 Eduardo San Martin Morote
|
|
* @license MIT
|
|
*/
|
|
const isBrowser = typeof document !== "undefined";
|
|
function isRouteComponent(component) {
|
|
return typeof component === "object" || "displayName" in component || "props" in component || "__vccOpts" in component;
|
|
}
|
|
function isESModule(obj) {
|
|
return obj.__esModule || obj[Symbol.toStringTag] === "Module" || // support CF with dynamic imports that do not
|
|
// add the Module string tag
|
|
obj.default && isRouteComponent(obj.default);
|
|
}
|
|
const assign = Object.assign;
|
|
function applyToParams(fn, params) {
|
|
const newParams = {};
|
|
for (const key in params) {
|
|
const value = params[key];
|
|
newParams[key] = isArray(value) ? value.map(fn) : fn(value);
|
|
}
|
|
return newParams;
|
|
}
|
|
const noop = () => {
|
|
};
|
|
const isArray = Array.isArray;
|
|
const HASH_RE = /#/g;
|
|
const AMPERSAND_RE = /&/g;
|
|
const SLASH_RE = /\//g;
|
|
const EQUAL_RE = /=/g;
|
|
const IM_RE = /\?/g;
|
|
const PLUS_RE = /\+/g;
|
|
const ENC_BRACKET_OPEN_RE = /%5B/g;
|
|
const ENC_BRACKET_CLOSE_RE = /%5D/g;
|
|
const ENC_CARET_RE = /%5E/g;
|
|
const ENC_BACKTICK_RE = /%60/g;
|
|
const ENC_CURLY_OPEN_RE = /%7B/g;
|
|
const ENC_PIPE_RE = /%7C/g;
|
|
const ENC_CURLY_CLOSE_RE = /%7D/g;
|
|
const ENC_SPACE_RE = /%20/g;
|
|
function commonEncode(text) {
|
|
return encodeURI("" + text).replace(ENC_PIPE_RE, "|").replace(ENC_BRACKET_OPEN_RE, "[").replace(ENC_BRACKET_CLOSE_RE, "]");
|
|
}
|
|
function encodeHash(text) {
|
|
return commonEncode(text).replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
|
|
}
|
|
function encodeQueryValue(text) {
|
|
return commonEncode(text).replace(PLUS_RE, "%2B").replace(ENC_SPACE_RE, "+").replace(HASH_RE, "%23").replace(AMPERSAND_RE, "%26").replace(ENC_BACKTICK_RE, "`").replace(ENC_CURLY_OPEN_RE, "{").replace(ENC_CURLY_CLOSE_RE, "}").replace(ENC_CARET_RE, "^");
|
|
}
|
|
function encodeQueryKey(text) {
|
|
return encodeQueryValue(text).replace(EQUAL_RE, "%3D");
|
|
}
|
|
function encodePath(text) {
|
|
return commonEncode(text).replace(HASH_RE, "%23").replace(IM_RE, "%3F");
|
|
}
|
|
function encodeParam(text) {
|
|
return text == null ? "" : encodePath(text).replace(SLASH_RE, "%2F");
|
|
}
|
|
function decode(text) {
|
|
try {
|
|
return decodeURIComponent("" + text);
|
|
} catch (err) {
|
|
}
|
|
return "" + text;
|
|
}
|
|
const TRAILING_SLASH_RE = /\/$/;
|
|
const removeTrailingSlash = (path) => path.replace(TRAILING_SLASH_RE, "");
|
|
function parseURL(parseQuery2, location2, currentLocation = "/") {
|
|
let path, query = {}, searchString = "", hash = "";
|
|
const hashPos = location2.indexOf("#");
|
|
let searchPos = location2.indexOf("?");
|
|
if (hashPos < searchPos && hashPos >= 0) {
|
|
searchPos = -1;
|
|
}
|
|
if (searchPos > -1) {
|
|
path = location2.slice(0, searchPos);
|
|
searchString = location2.slice(searchPos + 1, hashPos > -1 ? hashPos : location2.length);
|
|
query = parseQuery2(searchString);
|
|
}
|
|
if (hashPos > -1) {
|
|
path = path || location2.slice(0, hashPos);
|
|
hash = location2.slice(hashPos, location2.length);
|
|
}
|
|
path = resolveRelativePath(path != null ? path : location2, currentLocation);
|
|
return {
|
|
fullPath: path + (searchString && "?") + searchString + hash,
|
|
path,
|
|
query,
|
|
hash: decode(hash)
|
|
};
|
|
}
|
|
function stringifyURL(stringifyQuery2, location2) {
|
|
const query = location2.query ? stringifyQuery2(location2.query) : "";
|
|
return location2.path + (query && "?") + query + (location2.hash || "");
|
|
}
|
|
function stripBase(pathname, base2) {
|
|
if (!base2 || !pathname.toLowerCase().startsWith(base2.toLowerCase()))
|
|
return pathname;
|
|
return pathname.slice(base2.length) || "/";
|
|
}
|
|
function isSameRouteLocation(stringifyQuery2, a, b) {
|
|
const aLastIndex = a.matched.length - 1;
|
|
const bLastIndex = b.matched.length - 1;
|
|
return aLastIndex > -1 && aLastIndex === bLastIndex && isSameRouteRecord(a.matched[aLastIndex], b.matched[bLastIndex]) && isSameRouteLocationParams(a.params, b.params) && stringifyQuery2(a.query) === stringifyQuery2(b.query) && a.hash === b.hash;
|
|
}
|
|
function isSameRouteRecord(a, b) {
|
|
return (a.aliasOf || a) === (b.aliasOf || b);
|
|
}
|
|
function isSameRouteLocationParams(a, b) {
|
|
if (Object.keys(a).length !== Object.keys(b).length)
|
|
return false;
|
|
for (const key in a) {
|
|
if (!isSameRouteLocationParamsValue(a[key], b[key]))
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function isSameRouteLocationParamsValue(a, b) {
|
|
return isArray(a) ? isEquivalentArray(a, b) : isArray(b) ? isEquivalentArray(b, a) : a === b;
|
|
}
|
|
function isEquivalentArray(a, b) {
|
|
return isArray(b) ? a.length === b.length && a.every((value, i) => value === b[i]) : a.length === 1 && a[0] === b;
|
|
}
|
|
function resolveRelativePath(to, from) {
|
|
if (to.startsWith("/"))
|
|
return to;
|
|
if (!to)
|
|
return from;
|
|
const fromSegments = from.split("/");
|
|
const toSegments = to.split("/");
|
|
const lastToSegment = toSegments[toSegments.length - 1];
|
|
if (lastToSegment === ".." || lastToSegment === ".") {
|
|
toSegments.push("");
|
|
}
|
|
let position = fromSegments.length - 1;
|
|
let toPosition;
|
|
let segment;
|
|
for (toPosition = 0; toPosition < toSegments.length; toPosition++) {
|
|
segment = toSegments[toPosition];
|
|
if (segment === ".")
|
|
continue;
|
|
if (segment === "..") {
|
|
if (position > 1)
|
|
position--;
|
|
} else
|
|
break;
|
|
}
|
|
return fromSegments.slice(0, position).join("/") + "/" + toSegments.slice(toPosition).join("/");
|
|
}
|
|
const START_LOCATION_NORMALIZED = {
|
|
path: "/",
|
|
// TODO: could we use a symbol in the future?
|
|
name: void 0,
|
|
params: {},
|
|
query: {},
|
|
hash: "",
|
|
fullPath: "/",
|
|
matched: [],
|
|
meta: {},
|
|
redirectedFrom: void 0
|
|
};
|
|
var NavigationType;
|
|
(function(NavigationType2) {
|
|
NavigationType2["pop"] = "pop";
|
|
NavigationType2["push"] = "push";
|
|
})(NavigationType || (NavigationType = {}));
|
|
var NavigationDirection;
|
|
(function(NavigationDirection2) {
|
|
NavigationDirection2["back"] = "back";
|
|
NavigationDirection2["forward"] = "forward";
|
|
NavigationDirection2["unknown"] = "";
|
|
})(NavigationDirection || (NavigationDirection = {}));
|
|
function normalizeBase(base2) {
|
|
if (!base2) {
|
|
if (isBrowser) {
|
|
const baseEl = document.querySelector("base");
|
|
base2 = baseEl && baseEl.getAttribute("href") || "/";
|
|
base2 = base2.replace(/^\w+:\/\/[^\/]+/, "");
|
|
} else {
|
|
base2 = "/";
|
|
}
|
|
}
|
|
if (base2[0] !== "/" && base2[0] !== "#")
|
|
base2 = "/" + base2;
|
|
return removeTrailingSlash(base2);
|
|
}
|
|
const BEFORE_HASH_RE = /^[^#]+#/;
|
|
function createHref(base2, location2) {
|
|
return base2.replace(BEFORE_HASH_RE, "#") + location2;
|
|
}
|
|
function getElementPosition(el, offset) {
|
|
const docRect = document.documentElement.getBoundingClientRect();
|
|
const elRect = el.getBoundingClientRect();
|
|
return {
|
|
behavior: offset.behavior,
|
|
left: elRect.left - docRect.left - (offset.left || 0),
|
|
top: elRect.top - docRect.top - (offset.top || 0)
|
|
};
|
|
}
|
|
const computeScrollPosition = () => ({
|
|
left: window.scrollX,
|
|
top: window.scrollY
|
|
});
|
|
function scrollToPosition(position) {
|
|
let scrollToOptions;
|
|
if ("el" in position) {
|
|
const positionEl = position.el;
|
|
const isIdSelector = typeof positionEl === "string" && positionEl.startsWith("#");
|
|
const el = typeof positionEl === "string" ? isIdSelector ? document.getElementById(positionEl.slice(1)) : document.querySelector(positionEl) : positionEl;
|
|
if (!el) {
|
|
return;
|
|
}
|
|
scrollToOptions = getElementPosition(el, position);
|
|
} else {
|
|
scrollToOptions = position;
|
|
}
|
|
if ("scrollBehavior" in document.documentElement.style)
|
|
window.scrollTo(scrollToOptions);
|
|
else {
|
|
window.scrollTo(scrollToOptions.left != null ? scrollToOptions.left : window.scrollX, scrollToOptions.top != null ? scrollToOptions.top : window.scrollY);
|
|
}
|
|
}
|
|
function getScrollKey(path, delta) {
|
|
const position = history.state ? history.state.position - delta : -1;
|
|
return position + path;
|
|
}
|
|
const scrollPositions = /* @__PURE__ */ new Map();
|
|
function saveScrollPosition(key, scrollPosition) {
|
|
scrollPositions.set(key, scrollPosition);
|
|
}
|
|
function getSavedScrollPosition(key) {
|
|
const scroll = scrollPositions.get(key);
|
|
scrollPositions.delete(key);
|
|
return scroll;
|
|
}
|
|
let createBaseLocation = () => location.protocol + "//" + location.host;
|
|
function createCurrentLocation(base2, location2) {
|
|
const { pathname, search, hash } = location2;
|
|
const hashPos = base2.indexOf("#");
|
|
if (hashPos > -1) {
|
|
let slicePos = hash.includes(base2.slice(hashPos)) ? base2.slice(hashPos).length : 1;
|
|
let pathFromHash = hash.slice(slicePos);
|
|
if (pathFromHash[0] !== "/")
|
|
pathFromHash = "/" + pathFromHash;
|
|
return stripBase(pathFromHash, "");
|
|
}
|
|
const path = stripBase(pathname, base2);
|
|
return path + search + hash;
|
|
}
|
|
function useHistoryListeners(base2, historyState, currentLocation, replace) {
|
|
let listeners = [];
|
|
let teardowns = [];
|
|
let pauseState = null;
|
|
const popStateHandler = ({ state }) => {
|
|
const to = createCurrentLocation(base2, location);
|
|
const from = currentLocation.value;
|
|
const fromState = historyState.value;
|
|
let delta = 0;
|
|
if (state) {
|
|
currentLocation.value = to;
|
|
historyState.value = state;
|
|
if (pauseState && pauseState === from) {
|
|
pauseState = null;
|
|
return;
|
|
}
|
|
delta = fromState ? state.position - fromState.position : 0;
|
|
} else {
|
|
replace(to);
|
|
}
|
|
listeners.forEach((listener) => {
|
|
listener(currentLocation.value, from, {
|
|
delta,
|
|
type: NavigationType.pop,
|
|
direction: delta ? delta > 0 ? NavigationDirection.forward : NavigationDirection.back : NavigationDirection.unknown
|
|
});
|
|
});
|
|
};
|
|
function pauseListeners() {
|
|
pauseState = currentLocation.value;
|
|
}
|
|
function listen(callback) {
|
|
listeners.push(callback);
|
|
const teardown = () => {
|
|
const index = listeners.indexOf(callback);
|
|
if (index > -1)
|
|
listeners.splice(index, 1);
|
|
};
|
|
teardowns.push(teardown);
|
|
return teardown;
|
|
}
|
|
function beforeUnloadListener() {
|
|
const { history: history2 } = window;
|
|
if (!history2.state)
|
|
return;
|
|
history2.replaceState(assign({}, history2.state, { scroll: computeScrollPosition() }), "");
|
|
}
|
|
function destroy() {
|
|
for (const teardown of teardowns)
|
|
teardown();
|
|
teardowns = [];
|
|
window.removeEventListener("popstate", popStateHandler);
|
|
window.removeEventListener("beforeunload", beforeUnloadListener);
|
|
}
|
|
window.addEventListener("popstate", popStateHandler);
|
|
window.addEventListener("beforeunload", beforeUnloadListener, {
|
|
passive: true
|
|
});
|
|
return {
|
|
pauseListeners,
|
|
listen,
|
|
destroy
|
|
};
|
|
}
|
|
function buildState(back, current, forward, replaced = false, computeScroll = false) {
|
|
return {
|
|
back,
|
|
current,
|
|
forward,
|
|
replaced,
|
|
position: window.history.length,
|
|
scroll: computeScroll ? computeScrollPosition() : null
|
|
};
|
|
}
|
|
function useHistoryStateNavigation(base2) {
|
|
const { history: history2, location: location2 } = window;
|
|
const currentLocation = {
|
|
value: createCurrentLocation(base2, location2)
|
|
};
|
|
const historyState = { value: history2.state };
|
|
if (!historyState.value) {
|
|
changeLocation(currentLocation.value, {
|
|
back: null,
|
|
current: currentLocation.value,
|
|
forward: null,
|
|
// the length is off by one, we need to decrease it
|
|
position: history2.length - 1,
|
|
replaced: true,
|
|
// don't add a scroll as the user may have an anchor, and we want
|
|
// scrollBehavior to be triggered without a saved position
|
|
scroll: null
|
|
}, true);
|
|
}
|
|
function changeLocation(to, state, replace2) {
|
|
const hashIndex = base2.indexOf("#");
|
|
const url = hashIndex > -1 ? (location2.host && document.querySelector("base") ? base2 : base2.slice(hashIndex)) + to : createBaseLocation() + base2 + to;
|
|
try {
|
|
history2[replace2 ? "replaceState" : "pushState"](state, "", url);
|
|
historyState.value = state;
|
|
} catch (err) {
|
|
{
|
|
console.error(err);
|
|
}
|
|
location2[replace2 ? "replace" : "assign"](url);
|
|
}
|
|
}
|
|
function replace(to, data) {
|
|
const state = assign({}, history2.state, buildState(
|
|
historyState.value.back,
|
|
// keep back and forward entries but override current position
|
|
to,
|
|
historyState.value.forward,
|
|
true
|
|
), data, { position: historyState.value.position });
|
|
changeLocation(to, state, true);
|
|
currentLocation.value = to;
|
|
}
|
|
function push(to, data) {
|
|
const currentState = assign(
|
|
{},
|
|
// use current history state to gracefully handle a wrong call to
|
|
// history.replaceState
|
|
// https://github.com/vuejs/router/issues/366
|
|
historyState.value,
|
|
history2.state,
|
|
{
|
|
forward: to,
|
|
scroll: computeScrollPosition()
|
|
}
|
|
);
|
|
changeLocation(currentState.current, currentState, true);
|
|
const state = assign({}, buildState(currentLocation.value, to, null), { position: currentState.position + 1 }, data);
|
|
changeLocation(to, state, false);
|
|
currentLocation.value = to;
|
|
}
|
|
return {
|
|
location: currentLocation,
|
|
state: historyState,
|
|
push,
|
|
replace
|
|
};
|
|
}
|
|
function createWebHistory(base2) {
|
|
base2 = normalizeBase(base2);
|
|
const historyNavigation = useHistoryStateNavigation(base2);
|
|
const historyListeners = useHistoryListeners(base2, historyNavigation.state, historyNavigation.location, historyNavigation.replace);
|
|
function go(delta, triggerListeners = true) {
|
|
if (!triggerListeners)
|
|
historyListeners.pauseListeners();
|
|
history.go(delta);
|
|
}
|
|
const routerHistory = assign({
|
|
// it's overridden right after
|
|
location: "",
|
|
base: base2,
|
|
go,
|
|
createHref: createHref.bind(null, base2)
|
|
}, historyNavigation, historyListeners);
|
|
Object.defineProperty(routerHistory, "location", {
|
|
enumerable: true,
|
|
get: () => historyNavigation.location.value
|
|
});
|
|
Object.defineProperty(routerHistory, "state", {
|
|
enumerable: true,
|
|
get: () => historyNavigation.state.value
|
|
});
|
|
return routerHistory;
|
|
}
|
|
function isRouteLocation(route) {
|
|
return typeof route === "string" || route && typeof route === "object";
|
|
}
|
|
function isRouteName(name) {
|
|
return typeof name === "string" || typeof name === "symbol";
|
|
}
|
|
const NavigationFailureSymbol = Symbol("");
|
|
var NavigationFailureType;
|
|
(function(NavigationFailureType2) {
|
|
NavigationFailureType2[NavigationFailureType2["aborted"] = 4] = "aborted";
|
|
NavigationFailureType2[NavigationFailureType2["cancelled"] = 8] = "cancelled";
|
|
NavigationFailureType2[NavigationFailureType2["duplicated"] = 16] = "duplicated";
|
|
})(NavigationFailureType || (NavigationFailureType = {}));
|
|
function createRouterError(type, params) {
|
|
{
|
|
return assign(new Error(), {
|
|
type,
|
|
[NavigationFailureSymbol]: true
|
|
}, params);
|
|
}
|
|
}
|
|
function isNavigationFailure(error2, type) {
|
|
return error2 instanceof Error && NavigationFailureSymbol in error2 && (type == null || !!(error2.type & type));
|
|
}
|
|
const BASE_PARAM_PATTERN = "[^/]+?";
|
|
const BASE_PATH_PARSER_OPTIONS = {
|
|
sensitive: false,
|
|
strict: false,
|
|
start: true,
|
|
end: true
|
|
};
|
|
const REGEX_CHARS_RE = /[.+*?^${}()[\]/\\]/g;
|
|
function tokensToParser(segments, extraOptions) {
|
|
const options = assign({}, BASE_PATH_PARSER_OPTIONS, extraOptions);
|
|
const score = [];
|
|
let pattern = options.start ? "^" : "";
|
|
const keys = [];
|
|
for (const segment of segments) {
|
|
const segmentScores = segment.length ? [] : [
|
|
90
|
|
/* PathScore.Root */
|
|
];
|
|
if (options.strict && !segment.length)
|
|
pattern += "/";
|
|
for (let tokenIndex = 0; tokenIndex < segment.length; tokenIndex++) {
|
|
const token = segment[tokenIndex];
|
|
let subSegmentScore = 40 + (options.sensitive ? 0.25 : 0);
|
|
if (token.type === 0) {
|
|
if (!tokenIndex)
|
|
pattern += "/";
|
|
pattern += token.value.replace(REGEX_CHARS_RE, "\\$&");
|
|
subSegmentScore += 40;
|
|
} else if (token.type === 1) {
|
|
const { value, repeatable, optional, regexp } = token;
|
|
keys.push({
|
|
name: value,
|
|
repeatable,
|
|
optional
|
|
});
|
|
const re2 = regexp ? regexp : BASE_PARAM_PATTERN;
|
|
if (re2 !== BASE_PARAM_PATTERN) {
|
|
subSegmentScore += 10;
|
|
try {
|
|
new RegExp(`(${re2})`);
|
|
} catch (err) {
|
|
throw new Error(`Invalid custom RegExp for param "${value}" (${re2}): ` + err.message);
|
|
}
|
|
}
|
|
let subPattern = repeatable ? `((?:${re2})(?:/(?:${re2}))*)` : `(${re2})`;
|
|
if (!tokenIndex)
|
|
subPattern = // avoid an optional / if there are more segments e.g. /:p?-static
|
|
// or /:p?-:p2
|
|
optional && segment.length < 2 ? `(?:/${subPattern})` : "/" + subPattern;
|
|
if (optional)
|
|
subPattern += "?";
|
|
pattern += subPattern;
|
|
subSegmentScore += 20;
|
|
if (optional)
|
|
subSegmentScore += -8;
|
|
if (repeatable)
|
|
subSegmentScore += -20;
|
|
if (re2 === ".*")
|
|
subSegmentScore += -50;
|
|
}
|
|
segmentScores.push(subSegmentScore);
|
|
}
|
|
score.push(segmentScores);
|
|
}
|
|
if (options.strict && options.end) {
|
|
const i = score.length - 1;
|
|
score[i][score[i].length - 1] += 0.7000000000000001;
|
|
}
|
|
if (!options.strict)
|
|
pattern += "/?";
|
|
if (options.end)
|
|
pattern += "$";
|
|
else if (options.strict && !pattern.endsWith("/"))
|
|
pattern += "(?:/|$)";
|
|
const re = new RegExp(pattern, options.sensitive ? "" : "i");
|
|
function parse(path) {
|
|
const match2 = path.match(re);
|
|
const params = {};
|
|
if (!match2)
|
|
return null;
|
|
for (let i = 1; i < match2.length; i++) {
|
|
const value = match2[i] || "";
|
|
const key = keys[i - 1];
|
|
params[key.name] = value && key.repeatable ? value.split("/") : value;
|
|
}
|
|
return params;
|
|
}
|
|
function stringify(params) {
|
|
let path = "";
|
|
let avoidDuplicatedSlash = false;
|
|
for (const segment of segments) {
|
|
if (!avoidDuplicatedSlash || !path.endsWith("/"))
|
|
path += "/";
|
|
avoidDuplicatedSlash = false;
|
|
for (const token of segment) {
|
|
if (token.type === 0) {
|
|
path += token.value;
|
|
} else if (token.type === 1) {
|
|
const { value, repeatable, optional } = token;
|
|
const param = value in params ? params[value] : "";
|
|
if (isArray(param) && !repeatable) {
|
|
throw new Error(`Provided param "${value}" is an array but it is not repeatable (* or + modifiers)`);
|
|
}
|
|
const text = isArray(param) ? param.join("/") : param;
|
|
if (!text) {
|
|
if (optional) {
|
|
if (segment.length < 2) {
|
|
if (path.endsWith("/"))
|
|
path = path.slice(0, -1);
|
|
else
|
|
avoidDuplicatedSlash = true;
|
|
}
|
|
} else
|
|
throw new Error(`Missing required param "${value}"`);
|
|
}
|
|
path += text;
|
|
}
|
|
}
|
|
}
|
|
return path || "/";
|
|
}
|
|
return {
|
|
re,
|
|
score,
|
|
keys,
|
|
parse,
|
|
stringify
|
|
};
|
|
}
|
|
function compareScoreArray(a, b) {
|
|
let i = 0;
|
|
while (i < a.length && i < b.length) {
|
|
const diff = b[i] - a[i];
|
|
if (diff)
|
|
return diff;
|
|
i++;
|
|
}
|
|
if (a.length < b.length) {
|
|
return a.length === 1 && a[0] === 40 + 40 ? -1 : 1;
|
|
} else if (a.length > b.length) {
|
|
return b.length === 1 && b[0] === 40 + 40 ? 1 : -1;
|
|
}
|
|
return 0;
|
|
}
|
|
function comparePathParserScore(a, b) {
|
|
let i = 0;
|
|
const aScore = a.score;
|
|
const bScore = b.score;
|
|
while (i < aScore.length && i < bScore.length) {
|
|
const comp = compareScoreArray(aScore[i], bScore[i]);
|
|
if (comp)
|
|
return comp;
|
|
i++;
|
|
}
|
|
if (Math.abs(bScore.length - aScore.length) === 1) {
|
|
if (isLastScoreNegative(aScore))
|
|
return 1;
|
|
if (isLastScoreNegative(bScore))
|
|
return -1;
|
|
}
|
|
return bScore.length - aScore.length;
|
|
}
|
|
function isLastScoreNegative(score) {
|
|
const last = score[score.length - 1];
|
|
return score.length > 0 && last[last.length - 1] < 0;
|
|
}
|
|
const ROOT_TOKEN = {
|
|
type: 0,
|
|
value: ""
|
|
};
|
|
const VALID_PARAM_RE = /[a-zA-Z0-9_]/;
|
|
function tokenizePath(path) {
|
|
if (!path)
|
|
return [[]];
|
|
if (path === "/")
|
|
return [[ROOT_TOKEN]];
|
|
if (!path.startsWith("/")) {
|
|
throw new Error(`Invalid path "${path}"`);
|
|
}
|
|
function crash(message) {
|
|
throw new Error(`ERR (${state})/"${buffer2}": ${message}`);
|
|
}
|
|
let state = 0;
|
|
let previousState = state;
|
|
const tokens = [];
|
|
let segment;
|
|
function finalizeSegment() {
|
|
if (segment)
|
|
tokens.push(segment);
|
|
segment = [];
|
|
}
|
|
let i = 0;
|
|
let char;
|
|
let buffer2 = "";
|
|
let customRe = "";
|
|
function consumeBuffer() {
|
|
if (!buffer2)
|
|
return;
|
|
if (state === 0) {
|
|
segment.push({
|
|
type: 0,
|
|
value: buffer2
|
|
});
|
|
} else if (state === 1 || state === 2 || state === 3) {
|
|
if (segment.length > 1 && (char === "*" || char === "+"))
|
|
crash(`A repeatable param (${buffer2}) must be alone in its segment. eg: '/:ids+.`);
|
|
segment.push({
|
|
type: 1,
|
|
value: buffer2,
|
|
regexp: customRe,
|
|
repeatable: char === "*" || char === "+",
|
|
optional: char === "*" || char === "?"
|
|
});
|
|
} else {
|
|
crash("Invalid state to consume buffer");
|
|
}
|
|
buffer2 = "";
|
|
}
|
|
function addCharToBuffer() {
|
|
buffer2 += char;
|
|
}
|
|
while (i < path.length) {
|
|
char = path[i++];
|
|
if (char === "\\" && state !== 2) {
|
|
previousState = state;
|
|
state = 4;
|
|
continue;
|
|
}
|
|
switch (state) {
|
|
case 0:
|
|
if (char === "/") {
|
|
if (buffer2) {
|
|
consumeBuffer();
|
|
}
|
|
finalizeSegment();
|
|
} else if (char === ":") {
|
|
consumeBuffer();
|
|
state = 1;
|
|
} else {
|
|
addCharToBuffer();
|
|
}
|
|
break;
|
|
case 4:
|
|
addCharToBuffer();
|
|
state = previousState;
|
|
break;
|
|
case 1:
|
|
if (char === "(") {
|
|
state = 2;
|
|
} else if (VALID_PARAM_RE.test(char)) {
|
|
addCharToBuffer();
|
|
} else {
|
|
consumeBuffer();
|
|
state = 0;
|
|
if (char !== "*" && char !== "?" && char !== "+")
|
|
i--;
|
|
}
|
|
break;
|
|
case 2:
|
|
if (char === ")") {
|
|
if (customRe[customRe.length - 1] == "\\")
|
|
customRe = customRe.slice(0, -1) + char;
|
|
else
|
|
state = 3;
|
|
} else {
|
|
customRe += char;
|
|
}
|
|
break;
|
|
case 3:
|
|
consumeBuffer();
|
|
state = 0;
|
|
if (char !== "*" && char !== "?" && char !== "+")
|
|
i--;
|
|
customRe = "";
|
|
break;
|
|
default:
|
|
crash("Unknown state");
|
|
break;
|
|
}
|
|
}
|
|
if (state === 2)
|
|
crash(`Unfinished custom RegExp for param "${buffer2}"`);
|
|
consumeBuffer();
|
|
finalizeSegment();
|
|
return tokens;
|
|
}
|
|
function createRouteRecordMatcher(record, parent, options) {
|
|
const parser = tokensToParser(tokenizePath(record.path), options);
|
|
const matcher = assign(parser, {
|
|
record,
|
|
parent,
|
|
// these needs to be populated by the parent
|
|
children: [],
|
|
alias: []
|
|
});
|
|
if (parent) {
|
|
if (!matcher.record.aliasOf === !parent.record.aliasOf)
|
|
parent.children.push(matcher);
|
|
}
|
|
return matcher;
|
|
}
|
|
function createRouterMatcher(routes2, globalOptions) {
|
|
const matchers = [];
|
|
const matcherMap = /* @__PURE__ */ new Map();
|
|
globalOptions = mergeOptions({ strict: false, end: true, sensitive: false }, globalOptions);
|
|
function getRecordMatcher(name) {
|
|
return matcherMap.get(name);
|
|
}
|
|
function addRoute(record, parent, originalRecord) {
|
|
const isRootAdd = !originalRecord;
|
|
const mainNormalizedRecord = normalizeRouteRecord(record);
|
|
mainNormalizedRecord.aliasOf = originalRecord && originalRecord.record;
|
|
const options = mergeOptions(globalOptions, record);
|
|
const normalizedRecords = [mainNormalizedRecord];
|
|
if ("alias" in record) {
|
|
const aliases = typeof record.alias === "string" ? [record.alias] : record.alias;
|
|
for (const alias of aliases) {
|
|
normalizedRecords.push(
|
|
// we need to normalize again to ensure the `mods` property
|
|
// being non enumerable
|
|
normalizeRouteRecord(assign({}, mainNormalizedRecord, {
|
|
// this allows us to hold a copy of the `components` option
|
|
// so that async components cache is hold on the original record
|
|
components: originalRecord ? originalRecord.record.components : mainNormalizedRecord.components,
|
|
path: alias,
|
|
// we might be the child of an alias
|
|
aliasOf: originalRecord ? originalRecord.record : mainNormalizedRecord
|
|
// the aliases are always of the same kind as the original since they
|
|
// are defined on the same record
|
|
}))
|
|
);
|
|
}
|
|
}
|
|
let matcher;
|
|
let originalMatcher;
|
|
for (const normalizedRecord of normalizedRecords) {
|
|
const { path } = normalizedRecord;
|
|
if (parent && path[0] !== "/") {
|
|
const parentPath = parent.record.path;
|
|
const connectingSlash = parentPath[parentPath.length - 1] === "/" ? "" : "/";
|
|
normalizedRecord.path = parent.record.path + (path && connectingSlash + path);
|
|
}
|
|
matcher = createRouteRecordMatcher(normalizedRecord, parent, options);
|
|
if (originalRecord) {
|
|
originalRecord.alias.push(matcher);
|
|
} else {
|
|
originalMatcher = originalMatcher || matcher;
|
|
if (originalMatcher !== matcher)
|
|
originalMatcher.alias.push(matcher);
|
|
if (isRootAdd && record.name && !isAliasRecord(matcher)) {
|
|
removeRoute(record.name);
|
|
}
|
|
}
|
|
if (isMatchable(matcher)) {
|
|
insertMatcher(matcher);
|
|
}
|
|
if (mainNormalizedRecord.children) {
|
|
const children = mainNormalizedRecord.children;
|
|
for (let i = 0; i < children.length; i++) {
|
|
addRoute(children[i], matcher, originalRecord && originalRecord.children[i]);
|
|
}
|
|
}
|
|
originalRecord = originalRecord || matcher;
|
|
}
|
|
return originalMatcher ? () => {
|
|
removeRoute(originalMatcher);
|
|
} : noop;
|
|
}
|
|
function removeRoute(matcherRef) {
|
|
if (isRouteName(matcherRef)) {
|
|
const matcher = matcherMap.get(matcherRef);
|
|
if (matcher) {
|
|
matcherMap.delete(matcherRef);
|
|
matchers.splice(matchers.indexOf(matcher), 1);
|
|
matcher.children.forEach(removeRoute);
|
|
matcher.alias.forEach(removeRoute);
|
|
}
|
|
} else {
|
|
const index = matchers.indexOf(matcherRef);
|
|
if (index > -1) {
|
|
matchers.splice(index, 1);
|
|
if (matcherRef.record.name)
|
|
matcherMap.delete(matcherRef.record.name);
|
|
matcherRef.children.forEach(removeRoute);
|
|
matcherRef.alias.forEach(removeRoute);
|
|
}
|
|
}
|
|
}
|
|
function getRoutes() {
|
|
return matchers;
|
|
}
|
|
function insertMatcher(matcher) {
|
|
const index = findInsertionIndex(matcher, matchers);
|
|
matchers.splice(index, 0, matcher);
|
|
if (matcher.record.name && !isAliasRecord(matcher))
|
|
matcherMap.set(matcher.record.name, matcher);
|
|
}
|
|
function resolve2(location2, currentLocation) {
|
|
let matcher;
|
|
let params = {};
|
|
let path;
|
|
let name;
|
|
if ("name" in location2 && location2.name) {
|
|
matcher = matcherMap.get(location2.name);
|
|
if (!matcher)
|
|
throw createRouterError(1, {
|
|
location: location2
|
|
});
|
|
name = matcher.record.name;
|
|
params = assign(
|
|
// paramsFromLocation is a new object
|
|
paramsFromLocation(
|
|
currentLocation.params,
|
|
// only keep params that exist in the resolved location
|
|
// only keep optional params coming from a parent record
|
|
matcher.keys.filter((k) => !k.optional).concat(matcher.parent ? matcher.parent.keys.filter((k) => k.optional) : []).map((k) => k.name)
|
|
),
|
|
// discard any existing params in the current location that do not exist here
|
|
// #1497 this ensures better active/exact matching
|
|
location2.params && paramsFromLocation(location2.params, matcher.keys.map((k) => k.name))
|
|
);
|
|
path = matcher.stringify(params);
|
|
} else if (location2.path != null) {
|
|
path = location2.path;
|
|
matcher = matchers.find((m) => m.re.test(path));
|
|
if (matcher) {
|
|
params = matcher.parse(path);
|
|
name = matcher.record.name;
|
|
}
|
|
} else {
|
|
matcher = currentLocation.name ? matcherMap.get(currentLocation.name) : matchers.find((m) => m.re.test(currentLocation.path));
|
|
if (!matcher)
|
|
throw createRouterError(1, {
|
|
location: location2,
|
|
currentLocation
|
|
});
|
|
name = matcher.record.name;
|
|
params = assign({}, currentLocation.params, location2.params);
|
|
path = matcher.stringify(params);
|
|
}
|
|
const matched = [];
|
|
let parentMatcher = matcher;
|
|
while (parentMatcher) {
|
|
matched.unshift(parentMatcher.record);
|
|
parentMatcher = parentMatcher.parent;
|
|
}
|
|
return {
|
|
name,
|
|
path,
|
|
params,
|
|
matched,
|
|
meta: mergeMetaFields(matched)
|
|
};
|
|
}
|
|
routes2.forEach((route) => addRoute(route));
|
|
function clearRoutes() {
|
|
matchers.length = 0;
|
|
matcherMap.clear();
|
|
}
|
|
return {
|
|
addRoute,
|
|
resolve: resolve2,
|
|
removeRoute,
|
|
clearRoutes,
|
|
getRoutes,
|
|
getRecordMatcher
|
|
};
|
|
}
|
|
function paramsFromLocation(params, keys) {
|
|
const newParams = {};
|
|
for (const key of keys) {
|
|
if (key in params)
|
|
newParams[key] = params[key];
|
|
}
|
|
return newParams;
|
|
}
|
|
function normalizeRouteRecord(record) {
|
|
const normalized = {
|
|
path: record.path,
|
|
redirect: record.redirect,
|
|
name: record.name,
|
|
meta: record.meta || {},
|
|
aliasOf: record.aliasOf,
|
|
beforeEnter: record.beforeEnter,
|
|
props: normalizeRecordProps(record),
|
|
children: record.children || [],
|
|
instances: {},
|
|
leaveGuards: /* @__PURE__ */ new Set(),
|
|
updateGuards: /* @__PURE__ */ new Set(),
|
|
enterCallbacks: {},
|
|
// must be declared afterwards
|
|
// mods: {},
|
|
components: "components" in record ? record.components || null : record.component && { default: record.component }
|
|
};
|
|
Object.defineProperty(normalized, "mods", {
|
|
value: {}
|
|
});
|
|
return normalized;
|
|
}
|
|
function normalizeRecordProps(record) {
|
|
const propsObject = {};
|
|
const props = record.props || false;
|
|
if ("component" in record) {
|
|
propsObject.default = props;
|
|
} else {
|
|
for (const name in record.components)
|
|
propsObject[name] = typeof props === "object" ? props[name] : props;
|
|
}
|
|
return propsObject;
|
|
}
|
|
function isAliasRecord(record) {
|
|
while (record) {
|
|
if (record.record.aliasOf)
|
|
return true;
|
|
record = record.parent;
|
|
}
|
|
return false;
|
|
}
|
|
function mergeMetaFields(matched) {
|
|
return matched.reduce((meta, record) => assign(meta, record.meta), {});
|
|
}
|
|
function mergeOptions(defaults2, partialOptions) {
|
|
const options = {};
|
|
for (const key in defaults2) {
|
|
options[key] = key in partialOptions ? partialOptions[key] : defaults2[key];
|
|
}
|
|
return options;
|
|
}
|
|
function findInsertionIndex(matcher, matchers) {
|
|
let lower = 0;
|
|
let upper = matchers.length;
|
|
while (lower !== upper) {
|
|
const mid = lower + upper >> 1;
|
|
const sortOrder = comparePathParserScore(matcher, matchers[mid]);
|
|
if (sortOrder < 0) {
|
|
upper = mid;
|
|
} else {
|
|
lower = mid + 1;
|
|
}
|
|
}
|
|
const insertionAncestor = getInsertionAncestor(matcher);
|
|
if (insertionAncestor) {
|
|
upper = matchers.lastIndexOf(insertionAncestor, upper - 1);
|
|
}
|
|
return upper;
|
|
}
|
|
function getInsertionAncestor(matcher) {
|
|
let ancestor = matcher;
|
|
while (ancestor = ancestor.parent) {
|
|
if (isMatchable(ancestor) && comparePathParserScore(matcher, ancestor) === 0) {
|
|
return ancestor;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
function isMatchable({ record }) {
|
|
return !!(record.name || record.components && Object.keys(record.components).length || record.redirect);
|
|
}
|
|
function parseQuery(search) {
|
|
const query = {};
|
|
if (search === "" || search === "?")
|
|
return query;
|
|
const hasLeadingIM = search[0] === "?";
|
|
const searchParams = (hasLeadingIM ? search.slice(1) : search).split("&");
|
|
for (let i = 0; i < searchParams.length; ++i) {
|
|
const searchParam = searchParams[i].replace(PLUS_RE, " ");
|
|
const eqPos = searchParam.indexOf("=");
|
|
const key = decode(eqPos < 0 ? searchParam : searchParam.slice(0, eqPos));
|
|
const value = eqPos < 0 ? null : decode(searchParam.slice(eqPos + 1));
|
|
if (key in query) {
|
|
let currentValue = query[key];
|
|
if (!isArray(currentValue)) {
|
|
currentValue = query[key] = [currentValue];
|
|
}
|
|
currentValue.push(value);
|
|
} else {
|
|
query[key] = value;
|
|
}
|
|
}
|
|
return query;
|
|
}
|
|
function stringifyQuery(query) {
|
|
let search = "";
|
|
for (let key in query) {
|
|
const value = query[key];
|
|
key = encodeQueryKey(key);
|
|
if (value == null) {
|
|
if (value !== void 0) {
|
|
search += (search.length ? "&" : "") + key;
|
|
}
|
|
continue;
|
|
}
|
|
const values = isArray(value) ? value.map((v) => v && encodeQueryValue(v)) : [value && encodeQueryValue(value)];
|
|
values.forEach((value2) => {
|
|
if (value2 !== void 0) {
|
|
search += (search.length ? "&" : "") + key;
|
|
if (value2 != null)
|
|
search += "=" + value2;
|
|
}
|
|
});
|
|
}
|
|
return search;
|
|
}
|
|
function normalizeQuery(query) {
|
|
const normalizedQuery = {};
|
|
for (const key in query) {
|
|
const value = query[key];
|
|
if (value !== void 0) {
|
|
normalizedQuery[key] = isArray(value) ? value.map((v) => v == null ? null : "" + v) : value == null ? value : "" + value;
|
|
}
|
|
}
|
|
return normalizedQuery;
|
|
}
|
|
const matchedRouteKey = Symbol("");
|
|
const viewDepthKey = Symbol("");
|
|
const routerKey = Symbol("");
|
|
const routeLocationKey = Symbol("");
|
|
const routerViewLocationKey = Symbol("");
|
|
function useCallbacks() {
|
|
let handlers = [];
|
|
function add(handler) {
|
|
handlers.push(handler);
|
|
return () => {
|
|
const i = handlers.indexOf(handler);
|
|
if (i > -1)
|
|
handlers.splice(i, 1);
|
|
};
|
|
}
|
|
function reset() {
|
|
handlers = [];
|
|
}
|
|
return {
|
|
add,
|
|
list: () => handlers.slice(),
|
|
reset
|
|
};
|
|
}
|
|
function guardToPromiseFn(guard, to, from, record, name, runWithContext = (fn) => fn()) {
|
|
const enterCallbackArray = record && // name is defined if record is because of the function overload
|
|
(record.enterCallbacks[name] = record.enterCallbacks[name] || []);
|
|
return () => new Promise((resolve2, reject) => {
|
|
const next = (valid) => {
|
|
if (valid === false) {
|
|
reject(createRouterError(4, {
|
|
from,
|
|
to
|
|
}));
|
|
} else if (valid instanceof Error) {
|
|
reject(valid);
|
|
} else if (isRouteLocation(valid)) {
|
|
reject(createRouterError(2, {
|
|
from: to,
|
|
to: valid
|
|
}));
|
|
} else {
|
|
if (enterCallbackArray && // since enterCallbackArray is truthy, both record and name also are
|
|
record.enterCallbacks[name] === enterCallbackArray && typeof valid === "function") {
|
|
enterCallbackArray.push(valid);
|
|
}
|
|
resolve2();
|
|
}
|
|
};
|
|
const guardReturn = runWithContext(() => guard.call(record && record.instances[name], to, from, next));
|
|
let guardCall = Promise.resolve(guardReturn);
|
|
if (guard.length < 3)
|
|
guardCall = guardCall.then(next);
|
|
guardCall.catch((err) => reject(err));
|
|
});
|
|
}
|
|
function extractComponentsGuards(matched, guardType, to, from, runWithContext = (fn) => fn()) {
|
|
const guards = [];
|
|
for (const record of matched) {
|
|
for (const name in record.components) {
|
|
let rawComponent = record.components[name];
|
|
if (guardType !== "beforeRouteEnter" && !record.instances[name])
|
|
continue;
|
|
if (isRouteComponent(rawComponent)) {
|
|
const options = rawComponent.__vccOpts || rawComponent;
|
|
const guard = options[guardType];
|
|
guard && guards.push(guardToPromiseFn(guard, to, from, record, name, runWithContext));
|
|
} else {
|
|
let componentPromise = rawComponent();
|
|
guards.push(() => componentPromise.then((resolved) => {
|
|
if (!resolved)
|
|
throw new Error(`Couldn't resolve component "${name}" at "${record.path}"`);
|
|
const resolvedComponent = isESModule(resolved) ? resolved.default : resolved;
|
|
record.mods[name] = resolved;
|
|
record.components[name] = resolvedComponent;
|
|
const options = resolvedComponent.__vccOpts || resolvedComponent;
|
|
const guard = options[guardType];
|
|
return guard && guardToPromiseFn(guard, to, from, record, name, runWithContext)();
|
|
}));
|
|
}
|
|
}
|
|
}
|
|
return guards;
|
|
}
|
|
function useLink(props) {
|
|
const router2 = inject(routerKey);
|
|
const currentRoute = inject(routeLocationKey);
|
|
const route = computed(() => {
|
|
const to = unref(props.to);
|
|
return router2.resolve(to);
|
|
});
|
|
const activeRecordIndex = computed(() => {
|
|
const { matched } = route.value;
|
|
const { length } = matched;
|
|
const routeMatched = matched[length - 1];
|
|
const currentMatched = currentRoute.matched;
|
|
if (!routeMatched || !currentMatched.length)
|
|
return -1;
|
|
const index = currentMatched.findIndex(isSameRouteRecord.bind(null, routeMatched));
|
|
if (index > -1)
|
|
return index;
|
|
const parentRecordPath = getOriginalPath(matched[length - 2]);
|
|
return (
|
|
// we are dealing with nested routes
|
|
length > 1 && // if the parent and matched route have the same path, this link is
|
|
// referring to the empty child. Or we currently are on a different
|
|
// child of the same parent
|
|
getOriginalPath(routeMatched) === parentRecordPath && // avoid comparing the child with its parent
|
|
currentMatched[currentMatched.length - 1].path !== parentRecordPath ? currentMatched.findIndex(isSameRouteRecord.bind(null, matched[length - 2])) : index
|
|
);
|
|
});
|
|
const isActive = computed(() => activeRecordIndex.value > -1 && includesParams(currentRoute.params, route.value.params));
|
|
const isExactActive = computed(() => activeRecordIndex.value > -1 && activeRecordIndex.value === currentRoute.matched.length - 1 && isSameRouteLocationParams(currentRoute.params, route.value.params));
|
|
function navigate(e = {}) {
|
|
if (guardEvent(e)) {
|
|
const p2 = router2[unref(props.replace) ? "replace" : "push"](
|
|
unref(props.to)
|
|
// avoid uncaught errors are they are logged anyway
|
|
).catch(noop);
|
|
if (props.viewTransition && typeof document !== "undefined" && "startViewTransition" in document) {
|
|
document.startViewTransition(() => p2);
|
|
}
|
|
return p2;
|
|
}
|
|
return Promise.resolve();
|
|
}
|
|
return {
|
|
route,
|
|
href: computed(() => route.value.href),
|
|
isActive,
|
|
isExactActive,
|
|
navigate
|
|
};
|
|
}
|
|
function preferSingleVNode(vnodes) {
|
|
return vnodes.length === 1 ? vnodes[0] : vnodes;
|
|
}
|
|
const RouterLinkImpl = /* @__PURE__ */ defineComponent({
|
|
name: "RouterLink",
|
|
compatConfig: { MODE: 3 },
|
|
props: {
|
|
to: {
|
|
type: [String, Object],
|
|
required: true
|
|
},
|
|
replace: Boolean,
|
|
activeClass: String,
|
|
// inactiveClass: String,
|
|
exactActiveClass: String,
|
|
custom: Boolean,
|
|
ariaCurrentValue: {
|
|
type: String,
|
|
default: "page"
|
|
}
|
|
},
|
|
useLink,
|
|
setup(props, { slots }) {
|
|
const link = reactive(useLink(props));
|
|
const { options } = inject(routerKey);
|
|
const elClass = computed(() => ({
|
|
[getLinkClass(props.activeClass, options.linkActiveClass, "router-link-active")]: link.isActive,
|
|
// [getLinkClass(
|
|
// props.inactiveClass,
|
|
// options.linkInactiveClass,
|
|
// 'router-link-inactive'
|
|
// )]: !link.isExactActive,
|
|
[getLinkClass(props.exactActiveClass, options.linkExactActiveClass, "router-link-exact-active")]: link.isExactActive
|
|
}));
|
|
return () => {
|
|
const children = slots.default && preferSingleVNode(slots.default(link));
|
|
return props.custom ? children : h("a", {
|
|
"aria-current": link.isExactActive ? props.ariaCurrentValue : null,
|
|
href: link.href,
|
|
// this would override user added attrs but Vue will still add
|
|
// the listener, so we end up triggering both
|
|
onClick: link.navigate,
|
|
class: elClass.value
|
|
}, children);
|
|
};
|
|
}
|
|
});
|
|
const RouterLink = RouterLinkImpl;
|
|
function guardEvent(e) {
|
|
if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey)
|
|
return;
|
|
if (e.defaultPrevented)
|
|
return;
|
|
if (e.button !== void 0 && e.button !== 0)
|
|
return;
|
|
if (e.currentTarget && e.currentTarget.getAttribute) {
|
|
const target = e.currentTarget.getAttribute("target");
|
|
if (/\b_blank\b/i.test(target))
|
|
return;
|
|
}
|
|
if (e.preventDefault)
|
|
e.preventDefault();
|
|
return true;
|
|
}
|
|
function includesParams(outer, inner) {
|
|
for (const key in inner) {
|
|
const innerValue = inner[key];
|
|
const outerValue = outer[key];
|
|
if (typeof innerValue === "string") {
|
|
if (innerValue !== outerValue)
|
|
return false;
|
|
} else {
|
|
if (!isArray(outerValue) || outerValue.length !== innerValue.length || innerValue.some((value, i) => value !== outerValue[i]))
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function getOriginalPath(record) {
|
|
return record ? record.aliasOf ? record.aliasOf.path : record.path : "";
|
|
}
|
|
const getLinkClass = (propClass, globalClass, defaultClass) => propClass != null ? propClass : globalClass != null ? globalClass : defaultClass;
|
|
const RouterViewImpl = /* @__PURE__ */ defineComponent({
|
|
name: "RouterView",
|
|
// #674 we manually inherit them
|
|
inheritAttrs: false,
|
|
props: {
|
|
name: {
|
|
type: String,
|
|
default: "default"
|
|
},
|
|
route: Object
|
|
},
|
|
// Better compat for @vue/compat users
|
|
// https://github.com/vuejs/router/issues/1315
|
|
compatConfig: { MODE: 3 },
|
|
setup(props, { attrs, slots }) {
|
|
const injectedRoute = inject(routerViewLocationKey);
|
|
const routeToDisplay = computed(() => props.route || injectedRoute.value);
|
|
const injectedDepth = inject(viewDepthKey, 0);
|
|
const depth = computed(() => {
|
|
let initialDepth = unref(injectedDepth);
|
|
const { matched } = routeToDisplay.value;
|
|
let matchedRoute;
|
|
while ((matchedRoute = matched[initialDepth]) && !matchedRoute.components) {
|
|
initialDepth++;
|
|
}
|
|
return initialDepth;
|
|
});
|
|
const matchedRouteRef = computed(() => routeToDisplay.value.matched[depth.value]);
|
|
provide(viewDepthKey, computed(() => depth.value + 1));
|
|
provide(matchedRouteKey, matchedRouteRef);
|
|
provide(routerViewLocationKey, routeToDisplay);
|
|
const viewRef = ref();
|
|
watch(() => [viewRef.value, matchedRouteRef.value, props.name], ([instance, to, name], [oldInstance, from, oldName]) => {
|
|
if (to) {
|
|
to.instances[name] = instance;
|
|
if (from && from !== to && instance && instance === oldInstance) {
|
|
if (!to.leaveGuards.size) {
|
|
to.leaveGuards = from.leaveGuards;
|
|
}
|
|
if (!to.updateGuards.size) {
|
|
to.updateGuards = from.updateGuards;
|
|
}
|
|
}
|
|
}
|
|
if (instance && to && // if there is no instance but to and from are the same this might be
|
|
// the first visit
|
|
(!from || !isSameRouteRecord(to, from) || !oldInstance)) {
|
|
(to.enterCallbacks[name] || []).forEach((callback) => callback(instance));
|
|
}
|
|
}, { flush: "post" });
|
|
return () => {
|
|
const route = routeToDisplay.value;
|
|
const currentName = props.name;
|
|
const matchedRoute = matchedRouteRef.value;
|
|
const ViewComponent = matchedRoute && matchedRoute.components[currentName];
|
|
if (!ViewComponent) {
|
|
return normalizeSlot(slots.default, { Component: ViewComponent, route });
|
|
}
|
|
const routePropsOption = matchedRoute.props[currentName];
|
|
const routeProps = routePropsOption ? routePropsOption === true ? route.params : typeof routePropsOption === "function" ? routePropsOption(route) : routePropsOption : null;
|
|
const onVnodeUnmounted = (vnode) => {
|
|
if (vnode.component.isUnmounted) {
|
|
matchedRoute.instances[currentName] = null;
|
|
}
|
|
};
|
|
const component = h(ViewComponent, assign({}, routeProps, attrs, {
|
|
onVnodeUnmounted,
|
|
ref: viewRef
|
|
}));
|
|
return (
|
|
// pass the vnode to the slot as a prop.
|
|
// h and <component :is="..."> both accept vnodes
|
|
normalizeSlot(slots.default, { Component: component, route }) || component
|
|
);
|
|
};
|
|
}
|
|
});
|
|
function normalizeSlot(slot, data) {
|
|
if (!slot)
|
|
return null;
|
|
const slotContent = slot(data);
|
|
return slotContent.length === 1 ? slotContent[0] : slotContent;
|
|
}
|
|
const RouterView = RouterViewImpl;
|
|
function createRouter(options) {
|
|
const matcher = createRouterMatcher(options.routes, options);
|
|
const parseQuery$1 = options.parseQuery || parseQuery;
|
|
const stringifyQuery$1 = options.stringifyQuery || stringifyQuery;
|
|
const routerHistory = options.history;
|
|
const beforeGuards = useCallbacks();
|
|
const beforeResolveGuards = useCallbacks();
|
|
const afterGuards = useCallbacks();
|
|
const currentRoute = shallowRef(START_LOCATION_NORMALIZED);
|
|
let pendingLocation = START_LOCATION_NORMALIZED;
|
|
if (isBrowser && options.scrollBehavior && "scrollRestoration" in history) {
|
|
history.scrollRestoration = "manual";
|
|
}
|
|
const normalizeParams = applyToParams.bind(null, (paramValue) => "" + paramValue);
|
|
const encodeParams = applyToParams.bind(null, encodeParam);
|
|
const decodeParams = (
|
|
// @ts-expect-error: intentionally avoid the type check
|
|
applyToParams.bind(null, decode)
|
|
);
|
|
function addRoute(parentOrRoute, route) {
|
|
let parent;
|
|
let record;
|
|
if (isRouteName(parentOrRoute)) {
|
|
parent = matcher.getRecordMatcher(parentOrRoute);
|
|
record = route;
|
|
} else {
|
|
record = parentOrRoute;
|
|
}
|
|
return matcher.addRoute(record, parent);
|
|
}
|
|
function removeRoute(name) {
|
|
const recordMatcher = matcher.getRecordMatcher(name);
|
|
if (recordMatcher) {
|
|
matcher.removeRoute(recordMatcher);
|
|
}
|
|
}
|
|
function getRoutes() {
|
|
return matcher.getRoutes().map((routeMatcher) => routeMatcher.record);
|
|
}
|
|
function hasRoute(name) {
|
|
return !!matcher.getRecordMatcher(name);
|
|
}
|
|
function resolve2(rawLocation, currentLocation) {
|
|
currentLocation = assign({}, currentLocation || currentRoute.value);
|
|
if (typeof rawLocation === "string") {
|
|
const locationNormalized = parseURL(parseQuery$1, rawLocation, currentLocation.path);
|
|
const matchedRoute2 = matcher.resolve({ path: locationNormalized.path }, currentLocation);
|
|
const href2 = routerHistory.createHref(locationNormalized.fullPath);
|
|
return assign(locationNormalized, matchedRoute2, {
|
|
params: decodeParams(matchedRoute2.params),
|
|
hash: decode(locationNormalized.hash),
|
|
redirectedFrom: void 0,
|
|
href: href2
|
|
});
|
|
}
|
|
let matcherLocation;
|
|
if (rawLocation.path != null) {
|
|
matcherLocation = assign({}, rawLocation, {
|
|
path: parseURL(parseQuery$1, rawLocation.path, currentLocation.path).path
|
|
});
|
|
} else {
|
|
const targetParams = assign({}, rawLocation.params);
|
|
for (const key in targetParams) {
|
|
if (targetParams[key] == null) {
|
|
delete targetParams[key];
|
|
}
|
|
}
|
|
matcherLocation = assign({}, rawLocation, {
|
|
params: encodeParams(targetParams)
|
|
});
|
|
currentLocation.params = encodeParams(currentLocation.params);
|
|
}
|
|
const matchedRoute = matcher.resolve(matcherLocation, currentLocation);
|
|
const hash = rawLocation.hash || "";
|
|
matchedRoute.params = normalizeParams(decodeParams(matchedRoute.params));
|
|
const fullPath = stringifyURL(stringifyQuery$1, assign({}, rawLocation, {
|
|
hash: encodeHash(hash),
|
|
path: matchedRoute.path
|
|
}));
|
|
const href = routerHistory.createHref(fullPath);
|
|
return assign({
|
|
fullPath,
|
|
// keep the hash encoded so fullPath is effectively path + encodedQuery +
|
|
// hash
|
|
hash,
|
|
query: (
|
|
// if the user is using a custom query lib like qs, we might have
|
|
// nested objects, so we keep the query as is, meaning it can contain
|
|
// numbers at `$route.query`, but at the point, the user will have to
|
|
// use their own type anyway.
|
|
// https://github.com/vuejs/router/issues/328#issuecomment-649481567
|
|
stringifyQuery$1 === stringifyQuery ? normalizeQuery(rawLocation.query) : rawLocation.query || {}
|
|
)
|
|
}, matchedRoute, {
|
|
redirectedFrom: void 0,
|
|
href
|
|
});
|
|
}
|
|
function locationAsObject(to) {
|
|
return typeof to === "string" ? parseURL(parseQuery$1, to, currentRoute.value.path) : assign({}, to);
|
|
}
|
|
function checkCanceledNavigation(to, from) {
|
|
if (pendingLocation !== to) {
|
|
return createRouterError(8, {
|
|
from,
|
|
to
|
|
});
|
|
}
|
|
}
|
|
function push(to) {
|
|
return pushWithRedirect(to);
|
|
}
|
|
function replace(to) {
|
|
return push(assign(locationAsObject(to), { replace: true }));
|
|
}
|
|
function handleRedirectRecord(to) {
|
|
const lastMatched = to.matched[to.matched.length - 1];
|
|
if (lastMatched && lastMatched.redirect) {
|
|
const { redirect } = lastMatched;
|
|
let newTargetLocation = typeof redirect === "function" ? redirect(to) : redirect;
|
|
if (typeof newTargetLocation === "string") {
|
|
newTargetLocation = newTargetLocation.includes("?") || newTargetLocation.includes("#") ? newTargetLocation = locationAsObject(newTargetLocation) : (
|
|
// force empty params
|
|
{ path: newTargetLocation }
|
|
);
|
|
newTargetLocation.params = {};
|
|
}
|
|
return assign({
|
|
query: to.query,
|
|
hash: to.hash,
|
|
// avoid transferring params if the redirect has a path
|
|
params: newTargetLocation.path != null ? {} : to.params
|
|
}, newTargetLocation);
|
|
}
|
|
}
|
|
function pushWithRedirect(to, redirectedFrom) {
|
|
const targetLocation = pendingLocation = resolve2(to);
|
|
const from = currentRoute.value;
|
|
const data = to.state;
|
|
const force = to.force;
|
|
const replace2 = to.replace === true;
|
|
const shouldRedirect = handleRedirectRecord(targetLocation);
|
|
if (shouldRedirect)
|
|
return pushWithRedirect(
|
|
assign(locationAsObject(shouldRedirect), {
|
|
state: typeof shouldRedirect === "object" ? assign({}, data, shouldRedirect.state) : data,
|
|
force,
|
|
replace: replace2
|
|
}),
|
|
// keep original redirectedFrom if it exists
|
|
redirectedFrom || targetLocation
|
|
);
|
|
const toLocation = targetLocation;
|
|
toLocation.redirectedFrom = redirectedFrom;
|
|
let failure;
|
|
if (!force && isSameRouteLocation(stringifyQuery$1, from, targetLocation)) {
|
|
failure = createRouterError(16, { to: toLocation, from });
|
|
handleScroll(
|
|
from,
|
|
from,
|
|
// this is a push, the only way for it to be triggered from a
|
|
// history.listen is with a redirect, which makes it become a push
|
|
true,
|
|
// This cannot be the first navigation because the initial location
|
|
// cannot be manually navigated to
|
|
false
|
|
);
|
|
}
|
|
return (failure ? Promise.resolve(failure) : navigate(toLocation, from)).catch((error2) => isNavigationFailure(error2) ? (
|
|
// navigation redirects still mark the router as ready
|
|
isNavigationFailure(
|
|
error2,
|
|
2
|
|
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
|
|
) ? error2 : markAsReady(error2)
|
|
) : (
|
|
// reject any unknown error
|
|
triggerError(error2, toLocation, from)
|
|
)).then((failure2) => {
|
|
if (failure2) {
|
|
if (isNavigationFailure(
|
|
failure2,
|
|
2
|
|
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
|
|
)) {
|
|
return pushWithRedirect(
|
|
// keep options
|
|
assign({
|
|
// preserve an existing replacement but allow the redirect to override it
|
|
replace: replace2
|
|
}, locationAsObject(failure2.to), {
|
|
state: typeof failure2.to === "object" ? assign({}, data, failure2.to.state) : data,
|
|
force
|
|
}),
|
|
// preserve the original redirectedFrom if any
|
|
redirectedFrom || toLocation
|
|
);
|
|
}
|
|
} else {
|
|
failure2 = finalizeNavigation(toLocation, from, true, replace2, data);
|
|
}
|
|
triggerAfterEach(toLocation, from, failure2);
|
|
return failure2;
|
|
});
|
|
}
|
|
function checkCanceledNavigationAndReject(to, from) {
|
|
const error2 = checkCanceledNavigation(to, from);
|
|
return error2 ? Promise.reject(error2) : Promise.resolve();
|
|
}
|
|
function runWithContext(fn) {
|
|
const app2 = installedApps.values().next().value;
|
|
return app2 && typeof app2.runWithContext === "function" ? app2.runWithContext(fn) : fn();
|
|
}
|
|
function navigate(to, from) {
|
|
let guards;
|
|
const [leavingRecords, updatingRecords, enteringRecords] = extractChangingRecords(to, from);
|
|
guards = extractComponentsGuards(leavingRecords.reverse(), "beforeRouteLeave", to, from);
|
|
for (const record of leavingRecords) {
|
|
record.leaveGuards.forEach((guard) => {
|
|
guards.push(guardToPromiseFn(guard, to, from));
|
|
});
|
|
}
|
|
const canceledNavigationCheck = checkCanceledNavigationAndReject.bind(null, to, from);
|
|
guards.push(canceledNavigationCheck);
|
|
return runGuardQueue(guards).then(() => {
|
|
guards = [];
|
|
for (const guard of beforeGuards.list()) {
|
|
guards.push(guardToPromiseFn(guard, to, from));
|
|
}
|
|
guards.push(canceledNavigationCheck);
|
|
return runGuardQueue(guards);
|
|
}).then(() => {
|
|
guards = extractComponentsGuards(updatingRecords, "beforeRouteUpdate", to, from);
|
|
for (const record of updatingRecords) {
|
|
record.updateGuards.forEach((guard) => {
|
|
guards.push(guardToPromiseFn(guard, to, from));
|
|
});
|
|
}
|
|
guards.push(canceledNavigationCheck);
|
|
return runGuardQueue(guards);
|
|
}).then(() => {
|
|
guards = [];
|
|
for (const record of enteringRecords) {
|
|
if (record.beforeEnter) {
|
|
if (isArray(record.beforeEnter)) {
|
|
for (const beforeEnter of record.beforeEnter)
|
|
guards.push(guardToPromiseFn(beforeEnter, to, from));
|
|
} else {
|
|
guards.push(guardToPromiseFn(record.beforeEnter, to, from));
|
|
}
|
|
}
|
|
}
|
|
guards.push(canceledNavigationCheck);
|
|
return runGuardQueue(guards);
|
|
}).then(() => {
|
|
to.matched.forEach((record) => record.enterCallbacks = {});
|
|
guards = extractComponentsGuards(enteringRecords, "beforeRouteEnter", to, from, runWithContext);
|
|
guards.push(canceledNavigationCheck);
|
|
return runGuardQueue(guards);
|
|
}).then(() => {
|
|
guards = [];
|
|
for (const guard of beforeResolveGuards.list()) {
|
|
guards.push(guardToPromiseFn(guard, to, from));
|
|
}
|
|
guards.push(canceledNavigationCheck);
|
|
return runGuardQueue(guards);
|
|
}).catch((err) => isNavigationFailure(
|
|
err,
|
|
8
|
|
/* ErrorTypes.NAVIGATION_CANCELLED */
|
|
) ? err : Promise.reject(err));
|
|
}
|
|
function triggerAfterEach(to, from, failure) {
|
|
afterGuards.list().forEach((guard) => runWithContext(() => guard(to, from, failure)));
|
|
}
|
|
function finalizeNavigation(toLocation, from, isPush, replace2, data) {
|
|
const error2 = checkCanceledNavigation(toLocation, from);
|
|
if (error2)
|
|
return error2;
|
|
const isFirstNavigation = from === START_LOCATION_NORMALIZED;
|
|
const state = !isBrowser ? {} : history.state;
|
|
if (isPush) {
|
|
if (replace2 || isFirstNavigation)
|
|
routerHistory.replace(toLocation.fullPath, assign({
|
|
scroll: isFirstNavigation && state && state.scroll
|
|
}, data));
|
|
else
|
|
routerHistory.push(toLocation.fullPath, data);
|
|
}
|
|
currentRoute.value = toLocation;
|
|
handleScroll(toLocation, from, isPush, isFirstNavigation);
|
|
markAsReady();
|
|
}
|
|
let removeHistoryListener;
|
|
function setupListeners() {
|
|
if (removeHistoryListener)
|
|
return;
|
|
removeHistoryListener = routerHistory.listen((to, _from, info) => {
|
|
if (!router2.listening)
|
|
return;
|
|
const toLocation = resolve2(to);
|
|
const shouldRedirect = handleRedirectRecord(toLocation);
|
|
if (shouldRedirect) {
|
|
pushWithRedirect(assign(shouldRedirect, { replace: true, force: true }), toLocation).catch(noop);
|
|
return;
|
|
}
|
|
pendingLocation = toLocation;
|
|
const from = currentRoute.value;
|
|
if (isBrowser) {
|
|
saveScrollPosition(getScrollKey(from.fullPath, info.delta), computeScrollPosition());
|
|
}
|
|
navigate(toLocation, from).catch((error2) => {
|
|
if (isNavigationFailure(
|
|
error2,
|
|
4 | 8
|
|
/* ErrorTypes.NAVIGATION_CANCELLED */
|
|
)) {
|
|
return error2;
|
|
}
|
|
if (isNavigationFailure(
|
|
error2,
|
|
2
|
|
/* ErrorTypes.NAVIGATION_GUARD_REDIRECT */
|
|
)) {
|
|
pushWithRedirect(
|
|
assign(locationAsObject(error2.to), {
|
|
force: true
|
|
}),
|
|
toLocation
|
|
// avoid an uncaught rejection, let push call triggerError
|
|
).then((failure) => {
|
|
if (isNavigationFailure(
|
|
failure,
|
|
4 | 16
|
|
/* ErrorTypes.NAVIGATION_DUPLICATED */
|
|
) && !info.delta && info.type === NavigationType.pop) {
|
|
routerHistory.go(-1, false);
|
|
}
|
|
}).catch(noop);
|
|
return Promise.reject();
|
|
}
|
|
if (info.delta) {
|
|
routerHistory.go(-info.delta, false);
|
|
}
|
|
return triggerError(error2, toLocation, from);
|
|
}).then((failure) => {
|
|
failure = failure || finalizeNavigation(
|
|
// after navigation, all matched components are resolved
|
|
toLocation,
|
|
from,
|
|
false
|
|
);
|
|
if (failure) {
|
|
if (info.delta && // a new navigation has been triggered, so we do not want to revert, that will change the current history
|
|
// entry while a different route is displayed
|
|
!isNavigationFailure(
|
|
failure,
|
|
8
|
|
/* ErrorTypes.NAVIGATION_CANCELLED */
|
|
)) {
|
|
routerHistory.go(-info.delta, false);
|
|
} else if (info.type === NavigationType.pop && isNavigationFailure(
|
|
failure,
|
|
4 | 16
|
|
/* ErrorTypes.NAVIGATION_DUPLICATED */
|
|
)) {
|
|
routerHistory.go(-1, false);
|
|
}
|
|
}
|
|
triggerAfterEach(toLocation, from, failure);
|
|
}).catch(noop);
|
|
});
|
|
}
|
|
let readyHandlers = useCallbacks();
|
|
let errorListeners = useCallbacks();
|
|
let ready;
|
|
function triggerError(error2, to, from) {
|
|
markAsReady(error2);
|
|
const list = errorListeners.list();
|
|
if (list.length) {
|
|
list.forEach((handler) => handler(error2, to, from));
|
|
} else {
|
|
console.error(error2);
|
|
}
|
|
return Promise.reject(error2);
|
|
}
|
|
function isReady() {
|
|
if (ready && currentRoute.value !== START_LOCATION_NORMALIZED)
|
|
return Promise.resolve();
|
|
return new Promise((resolve22, reject) => {
|
|
readyHandlers.add([resolve22, reject]);
|
|
});
|
|
}
|
|
function markAsReady(err) {
|
|
if (!ready) {
|
|
ready = !err;
|
|
setupListeners();
|
|
readyHandlers.list().forEach(([resolve22, reject]) => err ? reject(err) : resolve22());
|
|
readyHandlers.reset();
|
|
}
|
|
return err;
|
|
}
|
|
function handleScroll(to, from, isPush, isFirstNavigation) {
|
|
const { scrollBehavior } = options;
|
|
if (!isBrowser || !scrollBehavior)
|
|
return Promise.resolve();
|
|
const scrollPosition = !isPush && getSavedScrollPosition(getScrollKey(to.fullPath, 0)) || (isFirstNavigation || !isPush) && history.state && history.state.scroll || null;
|
|
return nextTick().then(() => scrollBehavior(to, from, scrollPosition)).then((position) => position && scrollToPosition(position)).catch((err) => triggerError(err, to, from));
|
|
}
|
|
const go = (delta) => routerHistory.go(delta);
|
|
let started;
|
|
const installedApps = /* @__PURE__ */ new Set();
|
|
const router2 = {
|
|
currentRoute,
|
|
listening: true,
|
|
addRoute,
|
|
removeRoute,
|
|
clearRoutes: matcher.clearRoutes,
|
|
hasRoute,
|
|
getRoutes,
|
|
resolve: resolve2,
|
|
options,
|
|
push,
|
|
replace,
|
|
go,
|
|
back: () => go(-1),
|
|
forward: () => go(1),
|
|
beforeEach: beforeGuards.add,
|
|
beforeResolve: beforeResolveGuards.add,
|
|
afterEach: afterGuards.add,
|
|
onError: errorListeners.add,
|
|
isReady,
|
|
install(app2) {
|
|
const router22 = this;
|
|
app2.component("RouterLink", RouterLink);
|
|
app2.component("RouterView", RouterView);
|
|
app2.config.globalProperties.$router = router22;
|
|
Object.defineProperty(app2.config.globalProperties, "$route", {
|
|
enumerable: true,
|
|
get: () => unref(currentRoute)
|
|
});
|
|
if (isBrowser && // used for the initial navigation client side to avoid pushing
|
|
// multiple times when the router is used in multiple apps
|
|
!started && currentRoute.value === START_LOCATION_NORMALIZED) {
|
|
started = true;
|
|
push(routerHistory.location).catch((err) => {
|
|
});
|
|
}
|
|
const reactiveRoute = {};
|
|
for (const key in START_LOCATION_NORMALIZED) {
|
|
Object.defineProperty(reactiveRoute, key, {
|
|
get: () => currentRoute.value[key],
|
|
enumerable: true
|
|
});
|
|
}
|
|
app2.provide(routerKey, router22);
|
|
app2.provide(routeLocationKey, shallowReactive(reactiveRoute));
|
|
app2.provide(routerViewLocationKey, currentRoute);
|
|
const unmountApp = app2.unmount;
|
|
installedApps.add(app2);
|
|
app2.unmount = function() {
|
|
installedApps.delete(app2);
|
|
if (installedApps.size < 1) {
|
|
pendingLocation = START_LOCATION_NORMALIZED;
|
|
removeHistoryListener && removeHistoryListener();
|
|
removeHistoryListener = null;
|
|
currentRoute.value = START_LOCATION_NORMALIZED;
|
|
started = false;
|
|
ready = false;
|
|
}
|
|
unmountApp();
|
|
};
|
|
}
|
|
};
|
|
function runGuardQueue(guards) {
|
|
return guards.reduce((promise, guard) => promise.then(() => runWithContext(guard)), Promise.resolve());
|
|
}
|
|
return router2;
|
|
}
|
|
function extractChangingRecords(to, from) {
|
|
const leavingRecords = [];
|
|
const updatingRecords = [];
|
|
const enteringRecords = [];
|
|
const len = Math.max(from.matched.length, to.matched.length);
|
|
for (let i = 0; i < len; i++) {
|
|
const recordFrom = from.matched[i];
|
|
if (recordFrom) {
|
|
if (to.matched.find((record) => isSameRouteRecord(record, recordFrom)))
|
|
updatingRecords.push(recordFrom);
|
|
else
|
|
leavingRecords.push(recordFrom);
|
|
}
|
|
const recordTo = to.matched[i];
|
|
if (recordTo) {
|
|
if (!from.matched.find((record) => isSameRouteRecord(record, recordTo))) {
|
|
enteringRecords.push(recordTo);
|
|
}
|
|
}
|
|
}
|
|
return [leavingRecords, updatingRecords, enteringRecords];
|
|
}
|
|
function useRouter() {
|
|
return inject(routerKey);
|
|
}
|
|
const routes = [
|
|
{
|
|
path: "/",
|
|
children: [
|
|
{
|
|
path: "",
|
|
component: () => __vitePreload(() => import("./Log.js"), true ? __vite__mapDeps([41,42,19,7,8,9,10,20,29,28,26,14,24,25,27,30,31,12,16,32,43,44,11,5,45,17,1,46]) : void 0),
|
|
meta: { title: "日志" },
|
|
name: "log"
|
|
},
|
|
{
|
|
path: "plan-editor",
|
|
component: () => __vitePreload(() => import("./Plan.js"), true ? __vite__mapDeps([47,23,7,8,9,10,24,25,26,27,28,14,29,30,31,12,16,32,33,19,20,42,43,44,11,5,45,38,48,22,36,49]) : void 0),
|
|
meta: { title: "排班" },
|
|
name: "plan"
|
|
},
|
|
{
|
|
path: "settings",
|
|
component: () => __vitePreload(() => import("./MobileSettings.js"), true ? __vite__mapDeps([50,21,19,7,8,9,10,20,5,22,23,24,25,26,27,28,14,29,30,31,12,16,32,33,34,35,36,2,15,37,38,39]) : void 0),
|
|
meta: { title: "设置" },
|
|
name: "settings"
|
|
},
|
|
{
|
|
path: "aio",
|
|
component: () => __vitePreload(() => import("./Material_all_in_one.js"), true ? __vite__mapDeps([51,28,26,36,16,7,8,9,10,30,31,12,11,44,27]) : void 0),
|
|
meta: { title: "设置" },
|
|
name: "aio"
|
|
},
|
|
{
|
|
path: "doc",
|
|
component: () => __vitePreload(() => import("./Doc.js"), true ? __vite__mapDeps([52,15,16,53]) : void 0),
|
|
meta: { title: "文档" },
|
|
name: "doc"
|
|
},
|
|
{
|
|
path: "BasementSkill",
|
|
component: () => __vitePreload(() => import("./BasementSkill.js"), true ? __vite__mapDeps([54,15,16,28,26,38,32,25,31,55]) : void 0),
|
|
meta: { title: "基建技能" },
|
|
name: "BasementSkill"
|
|
},
|
|
{
|
|
path: "debug",
|
|
component: () => __vitePreload(() => import("./DebugConsole.js"), true ? __vite__mapDeps([56,48,5,43,15,16,24,25,7,8,9,10,26,27,37,57]) : void 0),
|
|
meta: { title: "日志" },
|
|
name: "DebugConsole"
|
|
},
|
|
{
|
|
path: "record",
|
|
children: [
|
|
{
|
|
path: "line",
|
|
component: () => __vitePreload(() => import("./RecordLine.js"), true ? __vite__mapDeps([58,59,60,61,62,16,9,63]) : void 0),
|
|
meta: { title: "心情曲线" },
|
|
name: "record_line"
|
|
},
|
|
{
|
|
path: "depot",
|
|
component: () => __vitePreload(() => import("./depot.js"), true ? __vite__mapDeps([64,35,22,62,16,9,15,34,10,2,32,25,31,65]) : void 0),
|
|
meta: { title: "仓库数据" },
|
|
name: "depot"
|
|
},
|
|
{
|
|
path: "pie",
|
|
component: () => __vitePreload(() => import("./RecordPie.js"), true ? __vite__mapDeps([66,61,67,59,62,16,9]) : void 0),
|
|
meta: { title: "心情饼图" },
|
|
name: "record_pie"
|
|
},
|
|
{
|
|
path: "report",
|
|
component: () => __vitePreload(() => import("./report.js"), true ? __vite__mapDeps([68,19,7,8,9,10,20,60,61,67,2,62,16,69]) : void 0),
|
|
meta: { title: "基建报告" },
|
|
name: "report"
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{ path: "/:pathMatch(.*)", component: () => __vitePreload(() => import("./NotFound.js"), true ? __vite__mapDeps([70,35]) : void 0) }
|
|
];
|
|
const router = createRouter({
|
|
history: createWebHistory(),
|
|
routes
|
|
});
|
|
router.beforeEach((to, from) => {
|
|
if (from.query.token && !to.query.token) {
|
|
return {
|
|
path: to.path,
|
|
query: from.query
|
|
};
|
|
}
|
|
});
|
|
function _typeof(e) {
|
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(e2) {
|
|
return typeof e2;
|
|
} : function(e2) {
|
|
return e2 && "function" == typeof Symbol && e2.constructor === Symbol && e2 !== Symbol.prototype ? "symbol" : typeof e2;
|
|
}, _typeof(e);
|
|
}
|
|
function plugin$1(e, n) {
|
|
if (!e.vueAxiosInstalled) {
|
|
var o = isAxiosLike(n) ? migrateToMultipleInstances(n) : n;
|
|
if (isValidConfig(o)) {
|
|
var t = getVueVersion(e);
|
|
if (t) {
|
|
var i = t < 3 ? registerOnVue2 : registerOnVue3;
|
|
Object.keys(o).forEach(function(n2) {
|
|
i(e, n2, o[n2]);
|
|
}), e.vueAxiosInstalled = true;
|
|
} else console.error("[vue-axios] unknown Vue version");
|
|
} else console.error("[vue-axios] configuration is invalid, expected options are either <axios_instance> or { <registration_key>: <axios_instance> }");
|
|
}
|
|
}
|
|
function registerOnVue2(e, n, o) {
|
|
Object.defineProperty(e.prototype, n, { get: function() {
|
|
return o;
|
|
} }), e[n] = o;
|
|
}
|
|
function registerOnVue3(e, n, o) {
|
|
e.config.globalProperties[n] = o, e[n] = o;
|
|
}
|
|
function isAxiosLike(e) {
|
|
return e && "function" == typeof e.get && "function" == typeof e.post;
|
|
}
|
|
function migrateToMultipleInstances(e) {
|
|
return { axios: e, $http: e };
|
|
}
|
|
function isValidConfig(e) {
|
|
return "object" === _typeof(e) && Object.keys(e).every(function(n) {
|
|
return isAxiosLike(e[n]);
|
|
});
|
|
}
|
|
function getVueVersion(e) {
|
|
return e && e.version && Number(e.version.split(".")[0]);
|
|
}
|
|
"object" == ("undefined" == typeof exports ? "undefined" : _typeof(exports)) ? module.exports = plugin$1 : "function" == typeof define && define.amd ? define([], function() {
|
|
return plugin$1;
|
|
}) : window.Vue && window.axios && window.Vue.use && Vue.use(plugin$1, window.axios);
|
|
const ElementMixin = /* @__PURE__ */ defineComponent({
|
|
inject: ["manager"],
|
|
props: {
|
|
index: {
|
|
type: Number,
|
|
required: true
|
|
},
|
|
disabled: {
|
|
type: Boolean,
|
|
default: false
|
|
}
|
|
},
|
|
data() {
|
|
return {};
|
|
},
|
|
watch: {
|
|
index(newIndex) {
|
|
if (this.$el && this.$el.sortableInfo) {
|
|
this.$el.sortableInfo.index = newIndex;
|
|
}
|
|
},
|
|
disabled(isDisabled) {
|
|
if (isDisabled) {
|
|
this.removeDraggable();
|
|
} else {
|
|
this.setDraggable(this.index);
|
|
}
|
|
}
|
|
},
|
|
mounted() {
|
|
const { disabled, index } = this.$props;
|
|
if (!disabled) {
|
|
this.setDraggable(index);
|
|
}
|
|
},
|
|
beforeUnmount() {
|
|
if (!this.disabled)
|
|
this.removeDraggable();
|
|
},
|
|
methods: {
|
|
setDraggable(index) {
|
|
const node = this.$el;
|
|
node.sortableInfo = {
|
|
index,
|
|
manager: this.manager
|
|
};
|
|
this.ref = { node };
|
|
this.manager.add(this.ref);
|
|
},
|
|
removeDraggable() {
|
|
this.manager.remove(this.ref);
|
|
}
|
|
}
|
|
});
|
|
class Manager {
|
|
constructor() {
|
|
this.refs = [];
|
|
this.active = null;
|
|
}
|
|
add(ref2) {
|
|
if (!this.refs) {
|
|
this.refs = [];
|
|
}
|
|
this.refs.push(ref2);
|
|
}
|
|
remove(ref2) {
|
|
const index = this.getIndex(ref2);
|
|
if (index !== -1) {
|
|
this.refs.splice(index, 1);
|
|
}
|
|
}
|
|
isActive() {
|
|
return !!this.active;
|
|
}
|
|
getActive() {
|
|
return this.refs.find(({ node }) => {
|
|
var _a, _b;
|
|
return ((_a = node === null || node === void 0 ? void 0 : node.sortableInfo) === null || _a === void 0 ? void 0 : _a.index) == ((_b = this === null || this === void 0 ? void 0 : this.active) === null || _b === void 0 ? void 0 : _b.index);
|
|
}) || null;
|
|
}
|
|
getIndex(ref2) {
|
|
return this.refs.indexOf(ref2);
|
|
}
|
|
getRefs() {
|
|
return this.refs;
|
|
}
|
|
getOrderedRefs() {
|
|
return this.refs.sort((a, b) => {
|
|
return a.node.sortableInfo.index - b.node.sortableInfo.index;
|
|
});
|
|
}
|
|
}
|
|
const isTouch = (e) => {
|
|
return e.touches != null;
|
|
};
|
|
function hasOwnProperty(obj, prop) {
|
|
return !!obj && Object.prototype.hasOwnProperty.call(obj, prop);
|
|
}
|
|
function arrayMove(arr, previousIndex, newIndex) {
|
|
const array = arr.slice(0);
|
|
if (newIndex >= array.length) {
|
|
let k = newIndex - array.length;
|
|
while (k-- + 1) {
|
|
array.push(void 0);
|
|
}
|
|
}
|
|
array.splice(newIndex, 0, array.splice(previousIndex, 1)[0]);
|
|
return array;
|
|
}
|
|
function arrayRemove(arr, previousIndex) {
|
|
const array = arr.slice(0);
|
|
if (previousIndex >= array.length)
|
|
return array;
|
|
array.splice(previousIndex, 1);
|
|
return array;
|
|
}
|
|
function arrayInsert(arr, newIndex, value) {
|
|
const array = arr.slice(0);
|
|
if (newIndex === array.length) {
|
|
array.push(value);
|
|
} else {
|
|
array.splice(newIndex, 0, value);
|
|
}
|
|
return array;
|
|
}
|
|
const events = {
|
|
start: ["touchstart", "mousedown"],
|
|
move: ["touchmove", "mousemove"],
|
|
end: ["touchend", "mouseup"],
|
|
cancel: ["touchcancel", "keyup"]
|
|
};
|
|
function closest(el, fn) {
|
|
while (el) {
|
|
if (fn(el))
|
|
return el;
|
|
el = el.parentNode;
|
|
}
|
|
}
|
|
function limit(min, max, value) {
|
|
if (value < min) {
|
|
return min;
|
|
}
|
|
if (value > max) {
|
|
return max;
|
|
}
|
|
return value;
|
|
}
|
|
function getCSSPixelValue(stringValue) {
|
|
if (stringValue.substr(-2) === "px") {
|
|
return parseFloat(stringValue);
|
|
}
|
|
return 0;
|
|
}
|
|
function getElementMargin(element) {
|
|
const style2 = window.getComputedStyle(element);
|
|
return {
|
|
top: getCSSPixelValue(style2.marginTop),
|
|
right: getCSSPixelValue(style2.marginRight),
|
|
bottom: getCSSPixelValue(style2.marginBottom),
|
|
left: getCSSPixelValue(style2.marginLeft)
|
|
};
|
|
}
|
|
function getPointerOffset(e, reference = "page") {
|
|
const x = `${reference}X`;
|
|
const y = `${reference}Y`;
|
|
return {
|
|
x: isTouch(e) ? e.touches[0][x] : e[x],
|
|
y: isTouch(e) ? e.touches[0][y] : e[y]
|
|
};
|
|
}
|
|
function offsetParents(node) {
|
|
const nodes = [node];
|
|
for (; node; node = node.offsetParent) {
|
|
nodes.unshift(node);
|
|
}
|
|
return nodes;
|
|
}
|
|
function commonOffsetParent(node1, node2) {
|
|
const parents1 = offsetParents(node1);
|
|
const parents2 = offsetParents(node2);
|
|
if (parents1[0] != parents2[0])
|
|
throw "No common ancestor!";
|
|
for (let i = 0; i < parents1.length; i++) {
|
|
if (parents1[i] != parents2[i])
|
|
return parents1[i - 1];
|
|
}
|
|
}
|
|
function getEdgeOffset(node, container, offset = { top: 0, left: 0 }) {
|
|
if (node) {
|
|
const nodeOffset = {
|
|
top: offset.top + node.offsetTop,
|
|
left: offset.left + node.offsetLeft
|
|
};
|
|
if (node.offsetParent !== container.offsetParent) {
|
|
return getEdgeOffset(node.offsetParent, container, nodeOffset);
|
|
} else {
|
|
return nodeOffset;
|
|
}
|
|
}
|
|
return { top: 0, left: 0 };
|
|
}
|
|
function cloneNode(node) {
|
|
const fields = node.querySelectorAll("input, textarea, select");
|
|
const clonedNode = node.cloneNode(true);
|
|
const clonedFields = [...clonedNode.querySelectorAll("input, textarea, select")];
|
|
clonedFields.forEach((field, index) => {
|
|
if (field.type !== "file" && fields[index]) {
|
|
field.value = fields[index].value;
|
|
}
|
|
});
|
|
return clonedNode;
|
|
}
|
|
function getLockPixelOffsets(lockOffset, width, height) {
|
|
if (typeof lockOffset == "string") {
|
|
lockOffset = +lockOffset;
|
|
}
|
|
if (!Array.isArray(lockOffset)) {
|
|
lockOffset = [lockOffset, lockOffset];
|
|
}
|
|
if (lockOffset.length !== 2) {
|
|
throw new Error(`lockOffset prop of SortableContainer should be a single value or an array of exactly two values. Given ${lockOffset}`);
|
|
}
|
|
const [minLockOffset, maxLockOffset] = lockOffset;
|
|
return [getLockPixelOffset(minLockOffset, width, height), getLockPixelOffset(maxLockOffset, width, height)];
|
|
}
|
|
function getLockPixelOffset(lockOffset, width, height) {
|
|
let offsetX = lockOffset;
|
|
let offsetY = lockOffset;
|
|
let unit = "px";
|
|
if (typeof lockOffset === "string") {
|
|
const match2 = /^[+-]?\d*(?:\.\d*)?(px|%)$/.exec(lockOffset);
|
|
if (match2 === null) {
|
|
throw new Error(`lockOffset value should be a number or a string of a number followed by "px" or "%". Given ${lockOffset}`);
|
|
}
|
|
offsetX = offsetY = parseFloat(lockOffset);
|
|
unit = match2[1];
|
|
}
|
|
if (!isFinite(offsetX) || !isFinite(offsetY)) {
|
|
throw new Error(`lockOffset value should be a finite. Given ${lockOffset}`);
|
|
}
|
|
if (unit === "%") {
|
|
offsetX = offsetX * width / 100;
|
|
offsetY = offsetY * height / 100;
|
|
}
|
|
return {
|
|
x: offsetX,
|
|
y: offsetY
|
|
};
|
|
}
|
|
function getDistance(x1, y1, x2, y2) {
|
|
const x = x1 - x2;
|
|
const y = y1 - y2;
|
|
return Math.sqrt(x * x + y * y);
|
|
}
|
|
function getRectCenter(clientRect) {
|
|
return {
|
|
x: clientRect.left + clientRect.width / 2,
|
|
y: clientRect.top + clientRect.height / 2
|
|
};
|
|
}
|
|
function resetTransform(nodes = []) {
|
|
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
const node = nodes[i];
|
|
const el = node.node;
|
|
if (!el)
|
|
return;
|
|
node.edgeOffset = null;
|
|
setTransform(el);
|
|
}
|
|
}
|
|
function setTransform(el, transform = "", duration2 = "") {
|
|
if (!el)
|
|
return;
|
|
el.style["transform"] = transform;
|
|
el.style["transitionDuration"] = duration2;
|
|
}
|
|
function withinBounds(pos, top, bottom) {
|
|
const upper = Math.max(top, bottom);
|
|
const lower = Math.min(top, bottom);
|
|
return lower <= pos && pos <= upper;
|
|
}
|
|
function isPointWithinRect({ x, y }, { top, left, width, height }) {
|
|
const withinX = withinBounds(x, left, left + width);
|
|
const withinY = withinBounds(y, top, top + height);
|
|
return withinX && withinY;
|
|
}
|
|
const timeout = setTimeout;
|
|
const ContainerMixin = /* @__PURE__ */ defineComponent({
|
|
inject: {
|
|
SlicksortHub: {
|
|
from: "SlicksortHub",
|
|
default: null
|
|
}
|
|
},
|
|
provide() {
|
|
return {
|
|
manager: this.manager
|
|
};
|
|
},
|
|
props: {
|
|
list: { type: Array, required: true },
|
|
axis: { type: String, default: "y" },
|
|
distance: { type: Number, default: 0 },
|
|
pressDelay: { type: Number, default: 0 },
|
|
pressThreshold: { type: Number, default: 5 },
|
|
useDragHandle: { type: Boolean, default: false },
|
|
useWindowAsScrollContainer: { type: Boolean, default: false },
|
|
hideSortableGhost: { type: Boolean, default: true },
|
|
lockToContainerEdges: { type: Boolean, default: false },
|
|
lockOffset: { type: [String, Number, Array], default: "50%" },
|
|
transitionDuration: { type: Number, default: 300 },
|
|
appendTo: { type: String, default: "body" },
|
|
draggedSettlingDuration: { type: Number, default: null },
|
|
group: { type: String, default: "" },
|
|
accept: { type: [Boolean, Array, Function], default: null },
|
|
cancelKey: { type: String, default: "Escape" },
|
|
block: { type: Array, default: () => [] },
|
|
lockAxis: { type: String, default: "" },
|
|
helperClass: { type: String, default: "" },
|
|
contentWindow: { type: Object, default: null },
|
|
shouldCancelStart: {
|
|
type: Function,
|
|
default: (e) => {
|
|
const disabledElements = ["input", "textarea", "select", "option", "button"];
|
|
return disabledElements.indexOf(e.target.tagName.toLowerCase()) !== -1;
|
|
}
|
|
},
|
|
getHelperDimensions: {
|
|
type: Function,
|
|
default: ({ node }) => ({
|
|
width: node.offsetWidth,
|
|
height: node.offsetHeight
|
|
})
|
|
}
|
|
},
|
|
emits: ["sort-start", "sort-move", "sort-end", "sort-cancel", "sort-insert", "sort-remove", "update:list"],
|
|
data() {
|
|
let useHub = false;
|
|
if (this.group) {
|
|
if (this.SlicksortHub) {
|
|
useHub = true;
|
|
}
|
|
}
|
|
return {
|
|
sorting: false,
|
|
hub: useHub ? this.SlicksortHub : null,
|
|
manager: new Manager()
|
|
};
|
|
},
|
|
mounted() {
|
|
if (this.hub) {
|
|
this.id = this.hub.getId();
|
|
}
|
|
this.container = this.$el;
|
|
this.document = this.container.ownerDocument || document;
|
|
this._window = this.contentWindow || window;
|
|
this.scrollContainer = this.useWindowAsScrollContainer ? { scrollLeft: 0, scrollTop: 0 } : this.container;
|
|
this.events = {
|
|
start: this.handleStart,
|
|
move: this.handleMove,
|
|
end: this.handleEnd
|
|
};
|
|
for (const key in this.events) {
|
|
if (hasOwnProperty(this.events, key)) {
|
|
events[key].forEach((eventName) => this.container.addEventListener(eventName, this.events[key]));
|
|
}
|
|
}
|
|
if (this.hub) {
|
|
this.hub.addContainer(this);
|
|
}
|
|
},
|
|
beforeUnmount() {
|
|
for (const key in this.events) {
|
|
if (hasOwnProperty(this.events, key)) {
|
|
events[key].forEach((eventName) => this.container.removeEventListener(eventName, this.events[key]));
|
|
}
|
|
}
|
|
if (this.hub) {
|
|
this.hub.removeContainer(this);
|
|
}
|
|
if (this.dragendTimer)
|
|
clearTimeout(this.dragendTimer);
|
|
if (this.cancelTimer)
|
|
clearTimeout(this.cancelTimer);
|
|
if (this.pressTimer)
|
|
clearTimeout(this.pressTimer);
|
|
if (this.autoscrollInterval)
|
|
clearInterval(this.autoscrollInterval);
|
|
},
|
|
methods: {
|
|
handleStart(e) {
|
|
const { distance, shouldCancelStart } = this.$props;
|
|
if (!isTouch(e) && e.button === 2 || shouldCancelStart(e)) {
|
|
return false;
|
|
}
|
|
this._touched = true;
|
|
this._pos = getPointerOffset(e);
|
|
const target = e.target;
|
|
const node = closest(target, (el) => el.sortableInfo != null);
|
|
if (node && node.sortableInfo && this.nodeIsChild(node) && !this.sorting) {
|
|
const { useDragHandle } = this.$props;
|
|
const { index } = node.sortableInfo;
|
|
if (useDragHandle && !closest(target, (el) => el.sortableHandle != null))
|
|
return;
|
|
this.manager.active = { index };
|
|
if (target.tagName.toLowerCase() === "a") {
|
|
e.preventDefault();
|
|
}
|
|
if (!distance) {
|
|
if (this.pressDelay === 0) {
|
|
this.handlePress(e);
|
|
} else {
|
|
this.pressTimer = timeout(() => this.handlePress(e), this.pressDelay);
|
|
}
|
|
}
|
|
}
|
|
},
|
|
nodeIsChild(node) {
|
|
return node.sortableInfo.manager === this.manager;
|
|
},
|
|
handleMove(e) {
|
|
const { distance, pressThreshold } = this.$props;
|
|
if (!this.sorting && this._touched) {
|
|
const offset = getPointerOffset(e);
|
|
this._delta = {
|
|
x: this._pos.x - offset.x,
|
|
y: this._pos.y - offset.y
|
|
};
|
|
const delta = Math.abs(this._delta.x) + Math.abs(this._delta.y);
|
|
if (!distance && (!pressThreshold || pressThreshold && delta >= pressThreshold)) {
|
|
if (this.cancelTimer)
|
|
clearTimeout(this.cancelTimer);
|
|
this.cancelTimer = timeout(this.cancel, 0);
|
|
} else if (distance && delta >= distance && this.manager.isActive()) {
|
|
this.handlePress(e);
|
|
}
|
|
}
|
|
},
|
|
handleEnd() {
|
|
if (!this._touched)
|
|
return;
|
|
const { distance } = this.$props;
|
|
this._touched = false;
|
|
if (!distance) {
|
|
this.cancel();
|
|
}
|
|
},
|
|
cancel() {
|
|
if (!this.sorting) {
|
|
if (this.pressTimer)
|
|
clearTimeout(this.pressTimer);
|
|
this.manager.active = null;
|
|
if (this.hub)
|
|
this.hub.cancel();
|
|
}
|
|
},
|
|
handleSortCancel(e) {
|
|
if (isTouch(e) || e.key === this.cancelKey) {
|
|
this.newIndex = this.index;
|
|
this.canceling = true;
|
|
this.translate = { x: 0, y: 0 };
|
|
this.animateNodes();
|
|
this.handleSortEnd(e);
|
|
}
|
|
},
|
|
handlePress(e) {
|
|
e.stopPropagation();
|
|
const active = this.manager.getActive();
|
|
if (active) {
|
|
const { getHelperDimensions, helperClass, hideSortableGhost, appendTo } = this.$props;
|
|
const { node } = active;
|
|
const { index } = node.sortableInfo;
|
|
const margin = getElementMargin(node);
|
|
const containerBoundingRect = this.container.getBoundingClientRect();
|
|
const dimensions = getHelperDimensions({ index, node });
|
|
this.node = node;
|
|
this.margin = margin;
|
|
this.width = dimensions.width;
|
|
this.height = dimensions.height;
|
|
this.marginOffset = {
|
|
x: this.margin.left + this.margin.right,
|
|
y: Math.max(this.margin.top, this.margin.bottom)
|
|
};
|
|
this.boundingClientRect = node.getBoundingClientRect();
|
|
this.containerBoundingRect = containerBoundingRect;
|
|
this.index = index;
|
|
this.newIndex = index;
|
|
const clonedNode = cloneNode(node);
|
|
this.helper = this.document.querySelector(appendTo).appendChild(clonedNode);
|
|
this.helper.style.position = "fixed";
|
|
this.helper.style.top = `${this.boundingClientRect.top - margin.top}px`;
|
|
this.helper.style.left = `${this.boundingClientRect.left - margin.left}px`;
|
|
this.helper.style.width = `${this.width}px`;
|
|
this.helper.style.height = `${this.height}px`;
|
|
this.helper.style.boxSizing = "border-box";
|
|
this.helper.style.pointerEvents = "none";
|
|
if (hideSortableGhost) {
|
|
this.sortableGhost = node;
|
|
node.style.visibility = "hidden";
|
|
node.style.opacity = "0";
|
|
}
|
|
if (this.hub) {
|
|
this.hub.sortStart(this);
|
|
this.hub.helper = this.helper;
|
|
this.hub.ghost = this.sortableGhost;
|
|
}
|
|
this.intializeOffsets(e, this.boundingClientRect);
|
|
this.offsetEdge = getEdgeOffset(node, this.container);
|
|
if (helperClass) {
|
|
this.helper.classList.add(...helperClass.split(" "));
|
|
}
|
|
this.listenerNode = isTouch(e) ? node : this._window;
|
|
events.move.forEach((eventName) => this.listenerNode.addEventListener(eventName, this.handleSortMove));
|
|
events.end.forEach((eventName) => this.listenerNode.addEventListener(eventName, this.handleSortEnd));
|
|
events.cancel.forEach((eventName) => this.listenerNode.addEventListener(eventName, this.handleSortCancel));
|
|
this.sorting = true;
|
|
this.$emit("sort-start", { event: e, node, index });
|
|
}
|
|
},
|
|
handleSortMove(e) {
|
|
e.preventDefault();
|
|
this.updatePosition(e);
|
|
if (this.hub) {
|
|
const payload = this.list[this.index];
|
|
this.hub.handleSortMove(e, payload);
|
|
}
|
|
if (!this.hub || this.hub.isDest(this)) {
|
|
this.animateNodes();
|
|
this.autoscroll();
|
|
}
|
|
this.$emit("sort-move", { event: e });
|
|
},
|
|
handleDropOut() {
|
|
const removed = this.list[this.index];
|
|
const newValue = arrayRemove(this.list, this.index);
|
|
this.$emit("sort-remove", {
|
|
oldIndex: this.index
|
|
});
|
|
this.$emit("update:list", newValue);
|
|
return removed;
|
|
},
|
|
handleDropIn(payload) {
|
|
const newValue = arrayInsert(this.list, this.newIndex, payload);
|
|
this.$emit("sort-insert", {
|
|
newIndex: this.newIndex,
|
|
value: payload
|
|
});
|
|
this.$emit("update:list", newValue);
|
|
this.handleDragEnd();
|
|
},
|
|
handleDragOut() {
|
|
if (this.autoscrollInterval) {
|
|
clearInterval(this.autoscrollInterval);
|
|
this.autoscrollInterval = null;
|
|
}
|
|
if (this.hub.isSource(this)) {
|
|
this.translate = {
|
|
x: 1e4,
|
|
y: 1e4
|
|
};
|
|
this.animateNodes();
|
|
} else {
|
|
this.manager.getRefs().forEach((ref2) => {
|
|
ref2.node.style["transform"] = "";
|
|
});
|
|
this.dragendTimer = timeout(this.handleDragEnd, this.transitionDuration || 0);
|
|
}
|
|
},
|
|
handleDragEnd() {
|
|
if (this.autoscrollInterval) {
|
|
clearInterval(this.autoscrollInterval);
|
|
this.autoscrollInterval = null;
|
|
}
|
|
resetTransform(this.manager.getRefs());
|
|
if (this.sortableGhost) {
|
|
this.sortableGhost.remove();
|
|
this.sortableGhost = null;
|
|
}
|
|
if (this.dragendTimer) {
|
|
clearTimeout(this.dragendTimer);
|
|
this.dragendTimer = null;
|
|
}
|
|
this.manager.active = null;
|
|
this._touched = false;
|
|
this.sorting = false;
|
|
},
|
|
intializeOffsets(e, clientRect) {
|
|
const { useWindowAsScrollContainer, containerBoundingRect, _window } = this;
|
|
this.marginOffset = {
|
|
x: this.margin.left + this.margin.right,
|
|
y: Math.max(this.margin.top, this.margin.bottom)
|
|
};
|
|
this._axis = {
|
|
x: this.axis.indexOf("x") >= 0,
|
|
y: this.axis.indexOf("y") >= 0
|
|
};
|
|
this.initialOffset = getPointerOffset(e);
|
|
this.initialScroll = {
|
|
top: this.scrollContainer.scrollTop,
|
|
left: this.scrollContainer.scrollLeft
|
|
};
|
|
this.initialWindowScroll = {
|
|
top: window.pageYOffset,
|
|
left: window.pageXOffset
|
|
};
|
|
this.translate = { x: 0, y: 0 };
|
|
this.minTranslate = {};
|
|
this.maxTranslate = {};
|
|
if (this._axis.x) {
|
|
this.minTranslate.x = (useWindowAsScrollContainer ? 0 : containerBoundingRect.left) - clientRect.left - this.width / 2;
|
|
this.maxTranslate.x = (useWindowAsScrollContainer ? _window.innerWidth : containerBoundingRect.left + containerBoundingRect.width) - clientRect.left - this.width / 2;
|
|
}
|
|
if (this._axis.y) {
|
|
this.minTranslate.y = (useWindowAsScrollContainer ? 0 : containerBoundingRect.top) - clientRect.top - this.height / 2;
|
|
this.maxTranslate.y = (useWindowAsScrollContainer ? _window.innerHeight : containerBoundingRect.top + containerBoundingRect.height) - clientRect.top - this.height / 2;
|
|
}
|
|
},
|
|
handleDragIn(e, sortableGhost, helper) {
|
|
if (this.hub.isSource(this)) {
|
|
return;
|
|
}
|
|
if (this.dragendTimer) {
|
|
this.handleDragEnd();
|
|
clearTimeout(this.dragendTimer);
|
|
this.dragendTimer = null;
|
|
}
|
|
const nodes = this.manager.getRefs();
|
|
this.index = nodes.length;
|
|
this.manager.active = { index: this.index };
|
|
const containerBoundingRect = this.container.getBoundingClientRect();
|
|
const helperBoundingRect = helper.getBoundingClientRect();
|
|
this.containerBoundingRect = containerBoundingRect;
|
|
this.sortableGhost = cloneNode(sortableGhost);
|
|
this.container.appendChild(this.sortableGhost);
|
|
const ghostRect = this.sortableGhost.getBoundingClientRect();
|
|
this.boundingClientRect = ghostRect;
|
|
this.margin = getElementMargin(this.sortableGhost);
|
|
this.width = ghostRect.width;
|
|
this.height = ghostRect.height;
|
|
this.offsetEdge = getEdgeOffset(this.sortableGhost, this.container);
|
|
this.intializeOffsets(e, ghostRect);
|
|
this.initialOffset.x += ghostRect.x - helperBoundingRect.x;
|
|
this.initialOffset.y += ghostRect.y - helperBoundingRect.y;
|
|
this.sorting = true;
|
|
},
|
|
handleSortEnd(e) {
|
|
if (this.listenerNode) {
|
|
events.move.forEach((eventName) => (
|
|
// @ts-ignore
|
|
this.listenerNode.removeEventListener(eventName, this.handleSortMove)
|
|
));
|
|
events.end.forEach((eventName) => (
|
|
// @ts-ignore
|
|
this.listenerNode.removeEventListener(eventName, this.handleSortEnd)
|
|
));
|
|
events.cancel.forEach((eventName) => (
|
|
// @ts-ignore
|
|
this.listenerNode.removeEventListener(eventName, this.handleSortCancel)
|
|
));
|
|
}
|
|
const nodes = this.manager.getRefs();
|
|
if (this.helper && this.helperClass) {
|
|
this.helper.classList.remove(...this.helperClass.split(" "));
|
|
}
|
|
if (this.autoscrollInterval)
|
|
clearInterval(this.autoscrollInterval);
|
|
this.autoscrollInterval = null;
|
|
const onEnd = () => {
|
|
if (this.helper) {
|
|
this.helper.remove();
|
|
this.helper = null;
|
|
}
|
|
if (this.hideSortableGhost && this.sortableGhost) {
|
|
this.sortableGhost.style.visibility = "";
|
|
this.sortableGhost.style.opacity = "";
|
|
}
|
|
resetTransform(nodes);
|
|
if (this.hub && !this.hub.isDest(this)) {
|
|
this.canceling ? this.hub.cancel() : this.hub.handleSortEnd();
|
|
} else if (this.canceling) {
|
|
this.$emit("sort-cancel", { event: e });
|
|
} else {
|
|
this.$emit("sort-end", {
|
|
event: e,
|
|
oldIndex: this.index,
|
|
newIndex: this.newIndex
|
|
});
|
|
this.$emit("update:list", arrayMove(this.list, this.index, this.newIndex));
|
|
}
|
|
this.manager.active = null;
|
|
this._touched = false;
|
|
this.canceling = false;
|
|
this.sorting = false;
|
|
};
|
|
if (this.transitionDuration || this.draggedSettlingDuration) {
|
|
this.transitionHelperIntoPlace(nodes, onEnd);
|
|
} else {
|
|
onEnd();
|
|
}
|
|
},
|
|
transitionHelperIntoPlace(nodes, cb) {
|
|
if (this.draggedSettlingDuration === 0 || nodes.length === 0 || !this.helper) {
|
|
return Promise.resolve();
|
|
}
|
|
const indexNode = nodes[this.index].node;
|
|
let targetX = 0;
|
|
let targetY = 0;
|
|
const scrollDifference = {
|
|
top: window.pageYOffset - this.initialWindowScroll.top,
|
|
left: window.pageXOffset - this.initialWindowScroll.left
|
|
};
|
|
if (this.hub && !this.hub.isDest(this) && !this.canceling) {
|
|
const dest = this.hub.getDest();
|
|
if (!dest)
|
|
return;
|
|
const destIndex = dest.newIndex;
|
|
const destRefs = dest.manager.getOrderedRefs();
|
|
const destNode = destIndex < destRefs.length ? destRefs[destIndex].node : dest.sortableGhost;
|
|
const ancestor = commonOffsetParent(indexNode, destNode);
|
|
const sourceOffset = getEdgeOffset(indexNode, ancestor);
|
|
const targetOffset = getEdgeOffset(destNode, ancestor);
|
|
targetX = targetOffset.left - sourceOffset.left - scrollDifference.left;
|
|
targetY = targetOffset.top - sourceOffset.top - scrollDifference.top;
|
|
} else {
|
|
const newIndexNode = nodes[this.newIndex].node;
|
|
const deltaScroll = {
|
|
left: this.scrollContainer.scrollLeft - this.initialScroll.left + scrollDifference.left,
|
|
top: this.scrollContainer.scrollTop - this.initialScroll.top + scrollDifference.top
|
|
};
|
|
targetX = -deltaScroll.left;
|
|
if (this.translate && this.translate.x > 0) {
|
|
targetX += newIndexNode.offsetLeft + newIndexNode.offsetWidth - (indexNode.offsetLeft + indexNode.offsetWidth);
|
|
} else {
|
|
targetX += newIndexNode.offsetLeft - indexNode.offsetLeft;
|
|
}
|
|
targetY = -deltaScroll.top;
|
|
if (this.translate && this.translate.y > 0) {
|
|
targetY += newIndexNode.offsetTop + newIndexNode.offsetHeight - (indexNode.offsetTop + indexNode.offsetHeight);
|
|
} else {
|
|
targetY += newIndexNode.offsetTop - indexNode.offsetTop;
|
|
}
|
|
}
|
|
const duration2 = this.draggedSettlingDuration !== null ? this.draggedSettlingDuration : this.transitionDuration;
|
|
setTransform(this.helper, `translate3d(${targetX}px,${targetY}px, 0)`, `${duration2}ms`);
|
|
const cleanup = (event) => {
|
|
if (!event || event.propertyName === "transform") {
|
|
clearTimeout(cleanupTimer);
|
|
setTransform(this.helper);
|
|
cb();
|
|
}
|
|
};
|
|
const cleanupTimer = setTimeout(cleanup, duration2 + 10);
|
|
this.helper.addEventListener("transitionend", cleanup);
|
|
},
|
|
updatePosition(e) {
|
|
const { lockAxis, lockToContainerEdges } = this.$props;
|
|
const offset = getPointerOffset(e);
|
|
const translate = {
|
|
x: offset.x - this.initialOffset.x,
|
|
y: offset.y - this.initialOffset.y
|
|
};
|
|
translate.y -= window.pageYOffset - this.initialWindowScroll.top;
|
|
translate.x -= window.pageXOffset - this.initialWindowScroll.left;
|
|
this.translate = translate;
|
|
if (lockToContainerEdges) {
|
|
const [minLockOffset, maxLockOffset] = getLockPixelOffsets(this.lockOffset, this.height, this.width);
|
|
const minOffset = {
|
|
x: this.width / 2 - minLockOffset.x,
|
|
y: this.height / 2 - minLockOffset.y
|
|
};
|
|
const maxOffset = {
|
|
x: this.width / 2 - maxLockOffset.x,
|
|
y: this.height / 2 - maxLockOffset.y
|
|
};
|
|
if (this.minTranslate.x && this.maxTranslate.x)
|
|
translate.x = limit(this.minTranslate.x + minOffset.x, this.maxTranslate.x - maxOffset.x, translate.x);
|
|
if (this.minTranslate.y && this.maxTranslate.y)
|
|
translate.y = limit(this.minTranslate.y + minOffset.y, this.maxTranslate.y - maxOffset.y, translate.y);
|
|
}
|
|
if (lockAxis === "x") {
|
|
translate.y = 0;
|
|
} else if (lockAxis === "y") {
|
|
translate.x = 0;
|
|
}
|
|
if (this.helper) {
|
|
this.helper.style["transform"] = `translate3d(${translate.x}px,${translate.y}px, 0)`;
|
|
}
|
|
},
|
|
animateNodes() {
|
|
const { transitionDuration, hideSortableGhost } = this.$props;
|
|
const nodes = this.manager.getOrderedRefs();
|
|
const deltaScroll = {
|
|
left: this.scrollContainer.scrollLeft - this.initialScroll.left,
|
|
top: this.scrollContainer.scrollTop - this.initialScroll.top
|
|
};
|
|
const sortingOffset = {
|
|
left: this.offsetEdge.left + this.translate.x + deltaScroll.left,
|
|
top: this.offsetEdge.top + this.translate.y + deltaScroll.top
|
|
};
|
|
const scrollDifference = {
|
|
top: window.pageYOffset - this.initialWindowScroll.top,
|
|
left: window.pageXOffset - this.initialWindowScroll.left
|
|
};
|
|
this.newIndex = null;
|
|
for (let i = 0, len = nodes.length; i < len; i++) {
|
|
const { node } = nodes[i];
|
|
const index = node.sortableInfo.index;
|
|
const width = node.offsetWidth;
|
|
const height = node.offsetHeight;
|
|
const offset = {
|
|
width: this.width > width ? width / 2 : this.width / 2,
|
|
height: this.height > height ? height / 2 : this.height / 2
|
|
};
|
|
const translate = {
|
|
x: 0,
|
|
y: 0
|
|
};
|
|
let { edgeOffset } = nodes[i];
|
|
if (!edgeOffset) {
|
|
nodes[i].edgeOffset = edgeOffset = getEdgeOffset(node, this.container);
|
|
}
|
|
const nextNode = i < nodes.length - 1 && nodes[i + 1];
|
|
const prevNode = i > 0 && nodes[i - 1];
|
|
if (nextNode && !nextNode.edgeOffset) {
|
|
nextNode.edgeOffset = getEdgeOffset(nextNode.node, this.container);
|
|
}
|
|
if (index === this.index) {
|
|
if (hideSortableGhost) {
|
|
this.sortableGhost = node;
|
|
node.style.visibility = "hidden";
|
|
node.style.opacity = "0";
|
|
}
|
|
continue;
|
|
}
|
|
if (transitionDuration) {
|
|
node.style["transitionDuration"] = `${transitionDuration}ms`;
|
|
}
|
|
if (this._axis.x) {
|
|
if (this._axis.y) {
|
|
if (index < this.index && (sortingOffset.left + scrollDifference.left - offset.width <= edgeOffset.left && sortingOffset.top + scrollDifference.top <= edgeOffset.top + offset.height || sortingOffset.top + scrollDifference.top + offset.height <= edgeOffset.top)) {
|
|
translate.x = this.width + this.marginOffset.x;
|
|
if (edgeOffset.left + translate.x > this.containerBoundingRect.width - offset.width && nextNode) {
|
|
translate.x = nextNode.edgeOffset.left - edgeOffset.left;
|
|
translate.y = nextNode.edgeOffset.top - edgeOffset.top;
|
|
}
|
|
if (this.newIndex === null) {
|
|
this.newIndex = index;
|
|
}
|
|
} else if (index > this.index && (sortingOffset.left + scrollDifference.left + offset.width >= edgeOffset.left && sortingOffset.top + scrollDifference.top + offset.height >= edgeOffset.top || sortingOffset.top + scrollDifference.top + offset.height >= edgeOffset.top + height)) {
|
|
translate.x = -(this.width + this.marginOffset.x);
|
|
if (edgeOffset.left + translate.x < this.containerBoundingRect.left + offset.width && prevNode) {
|
|
translate.x = prevNode.edgeOffset.left - edgeOffset.left;
|
|
translate.y = prevNode.edgeOffset.top - edgeOffset.top;
|
|
}
|
|
this.newIndex = index;
|
|
}
|
|
} else {
|
|
if (index > this.index && sortingOffset.left + scrollDifference.left + offset.width >= edgeOffset.left) {
|
|
translate.x = -(this.width + this.marginOffset.x);
|
|
this.newIndex = index;
|
|
} else if (index < this.index && sortingOffset.left + scrollDifference.left <= edgeOffset.left + offset.width) {
|
|
translate.x = this.width + this.marginOffset.x;
|
|
if (this.newIndex == null) {
|
|
this.newIndex = index;
|
|
}
|
|
}
|
|
}
|
|
} else if (this._axis.y) {
|
|
if (index > this.index && sortingOffset.top + scrollDifference.top + offset.height >= edgeOffset.top) {
|
|
translate.y = -(this.height + this.marginOffset.y);
|
|
this.newIndex = index;
|
|
} else if (index < this.index && sortingOffset.top + scrollDifference.top <= edgeOffset.top + offset.height) {
|
|
translate.y = this.height + this.marginOffset.y;
|
|
if (this.newIndex == null) {
|
|
this.newIndex = index;
|
|
}
|
|
}
|
|
}
|
|
node.style["transform"] = `translate3d(${translate.x}px,${translate.y}px,0)`;
|
|
}
|
|
if (this.newIndex == null) {
|
|
this.newIndex = this.index;
|
|
}
|
|
},
|
|
autoscroll() {
|
|
const translate = this.translate;
|
|
const direction = {
|
|
x: 0,
|
|
y: 0
|
|
};
|
|
const speed = {
|
|
x: 1,
|
|
y: 1
|
|
};
|
|
const acceleration = {
|
|
x: 10,
|
|
y: 10
|
|
};
|
|
if (translate.y >= this.maxTranslate.y - this.height / 2) {
|
|
direction.y = 1;
|
|
speed.y = acceleration.y * Math.abs((this.maxTranslate.y - this.height / 2 - translate.y) / this.height);
|
|
} else if (translate.x >= this.maxTranslate.x - this.width / 2) {
|
|
direction.x = 1;
|
|
speed.x = acceleration.x * Math.abs((this.maxTranslate.x - this.width / 2 - translate.x) / this.width);
|
|
} else if (translate.y <= this.minTranslate.y + this.height / 2) {
|
|
direction.y = -1;
|
|
speed.y = acceleration.y * Math.abs((translate.y - this.height / 2 - this.minTranslate.y) / this.height);
|
|
} else if (translate.x <= this.minTranslate.x + this.width / 2) {
|
|
direction.x = -1;
|
|
speed.x = acceleration.x * Math.abs((translate.x - this.width / 2 - this.minTranslate.x) / this.width);
|
|
}
|
|
if (this.autoscrollInterval) {
|
|
clearInterval(this.autoscrollInterval);
|
|
this.autoscrollInterval = null;
|
|
}
|
|
if (direction.x !== 0 || direction.y !== 0) {
|
|
this.autoscrollInterval = window.setInterval(() => {
|
|
const offset = {
|
|
left: 1 * speed.x * direction.x,
|
|
top: 1 * speed.y * direction.y
|
|
};
|
|
if (this.useWindowAsScrollContainer) {
|
|
this._window.scrollBy(offset.left, offset.top);
|
|
} else {
|
|
this.scrollContainer.scrollTop += offset.top;
|
|
this.scrollContainer.scrollLeft += offset.left;
|
|
}
|
|
this.translate.x += offset.left;
|
|
this.translate.y += offset.top;
|
|
this.animateNodes();
|
|
}, 5);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
const HandleDirective = {
|
|
beforeMount(el) {
|
|
el.sortableHandle = true;
|
|
}
|
|
};
|
|
const SlickItem = /* @__PURE__ */ defineComponent({
|
|
name: "SlickItem",
|
|
mixins: [ElementMixin],
|
|
props: {
|
|
tag: {
|
|
type: String,
|
|
default: "div"
|
|
}
|
|
},
|
|
render() {
|
|
var _a, _b;
|
|
return h(this.tag, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
}
|
|
});
|
|
const SlickList = /* @__PURE__ */ defineComponent({
|
|
name: "SlickList",
|
|
mixins: [ContainerMixin],
|
|
props: {
|
|
tag: {
|
|
type: String,
|
|
default: "div"
|
|
},
|
|
itemKey: {
|
|
type: [String, Function],
|
|
default: "id"
|
|
}
|
|
},
|
|
render() {
|
|
var _a, _b;
|
|
if (this.$slots.item) {
|
|
return h(this.tag, this.list.map((item, index) => {
|
|
let key;
|
|
if (item == null) {
|
|
return;
|
|
} else if (typeof this.itemKey === "function") {
|
|
key = this.itemKey(item);
|
|
} else if (typeof item === "object" && hasOwnProperty(item, this.itemKey) && typeof item[this.itemKey] == "string") {
|
|
key = item[this.itemKey];
|
|
} else if (typeof item === "string") {
|
|
key = item;
|
|
} else {
|
|
throw new Error("Cannot find key for item, use the item-key prop and pass a function or string");
|
|
}
|
|
return h(SlickItem, {
|
|
key,
|
|
index
|
|
}, {
|
|
default: () => {
|
|
var _a2, _b2;
|
|
return (_b2 = (_a2 = this.$slots).item) === null || _b2 === void 0 ? void 0 : _b2.call(_a2, { item, index });
|
|
}
|
|
});
|
|
}));
|
|
}
|
|
return h(this.tag, (_b = (_a = this.$slots).default) === null || _b === void 0 ? void 0 : _b.call(_a));
|
|
}
|
|
});
|
|
let containerIDCounter = 1;
|
|
function canAcceptElement(dest, source, payload) {
|
|
if (source.id === dest.id)
|
|
return true;
|
|
if (dest.block && dest.block.includes(source.group))
|
|
return false;
|
|
if (typeof dest.accept === "function") {
|
|
return dest.accept({ dest, source, payload });
|
|
}
|
|
if (typeof dest.accept === "boolean") {
|
|
return dest.accept;
|
|
}
|
|
if (dest.accept && dest.accept.includes(source.group))
|
|
return true;
|
|
if (dest.group === source.group)
|
|
return true;
|
|
return false;
|
|
}
|
|
function findClosestDest({ x, y }, refs, currentDest) {
|
|
if (isPointWithinRect({ x, y }, currentDest.container.getBoundingClientRect())) {
|
|
return currentDest;
|
|
}
|
|
let closest2 = null;
|
|
let minDistance = Infinity;
|
|
for (let i = 0; i < refs.length; i++) {
|
|
const ref2 = refs[i];
|
|
const rect = ref2.container.getBoundingClientRect();
|
|
const isWithin = isPointWithinRect({ x, y }, rect);
|
|
if (isWithin) {
|
|
return ref2;
|
|
}
|
|
const center = getRectCenter(rect);
|
|
const distance = getDistance(x, y, center.x, center.y);
|
|
if (distance < minDistance) {
|
|
closest2 = ref2;
|
|
minDistance = distance;
|
|
}
|
|
}
|
|
return closest2;
|
|
}
|
|
class SlicksortHub {
|
|
constructor() {
|
|
this.helper = null;
|
|
this.ghost = null;
|
|
this.refs = [];
|
|
this.source = null;
|
|
this.dest = null;
|
|
}
|
|
getId() {
|
|
return "" + containerIDCounter++;
|
|
}
|
|
isSource({ id }) {
|
|
var _a;
|
|
return ((_a = this.source) === null || _a === void 0 ? void 0 : _a.id) === id;
|
|
}
|
|
getSource() {
|
|
return this.source;
|
|
}
|
|
isDest({ id }) {
|
|
var _a;
|
|
return ((_a = this.dest) === null || _a === void 0 ? void 0 : _a.id) === id;
|
|
}
|
|
getDest() {
|
|
return this.dest;
|
|
}
|
|
addContainer(ref2) {
|
|
this.refs.push(ref2);
|
|
}
|
|
removeContainer(ref2) {
|
|
this.refs = this.refs.filter((c2) => c2.id !== ref2.id);
|
|
}
|
|
sortStart(ref2) {
|
|
this.source = ref2;
|
|
this.dest = ref2;
|
|
}
|
|
handleSortMove(e, payload) {
|
|
var _a, _b, _c, _d;
|
|
const dest = this.dest;
|
|
const source = this.source;
|
|
if (!dest || !source)
|
|
return;
|
|
const refs = this.refs;
|
|
const pointer = getPointerOffset(e, "client");
|
|
const newDest = findClosestDest(pointer, refs, dest) || dest;
|
|
if (dest.id !== newDest.id && canAcceptElement(newDest, source, payload)) {
|
|
this.dest = newDest;
|
|
dest.handleDragOut();
|
|
newDest.handleDragIn(e, this.ghost, this.helper);
|
|
}
|
|
if (dest.id !== ((_a = this.source) === null || _a === void 0 ? void 0 : _a.id)) {
|
|
(_b = this.dest) === null || _b === void 0 ? void 0 : _b.updatePosition(e);
|
|
(_c = this.dest) === null || _c === void 0 ? void 0 : _c.animateNodes();
|
|
(_d = this.dest) === null || _d === void 0 ? void 0 : _d.autoscroll();
|
|
}
|
|
}
|
|
handleSortEnd() {
|
|
var _a, _b, _c, _d;
|
|
if (((_a = this.source) === null || _a === void 0 ? void 0 : _a.id) === ((_b = this.dest) === null || _b === void 0 ? void 0 : _b.id))
|
|
return;
|
|
const payload = (_c = this.source) === null || _c === void 0 ? void 0 : _c.handleDropOut();
|
|
(_d = this.dest) === null || _d === void 0 ? void 0 : _d.handleDropIn(payload);
|
|
this.reset();
|
|
}
|
|
reset() {
|
|
this.source = null;
|
|
this.dest = null;
|
|
this.helper = null;
|
|
this.ghost = null;
|
|
}
|
|
cancel() {
|
|
var _a;
|
|
(_a = this.dest) === null || _a === void 0 ? void 0 : _a.handleDragEnd();
|
|
this.reset();
|
|
}
|
|
}
|
|
const plugin = {
|
|
install(app2) {
|
|
app2.directive("drag-handle", HandleDirective);
|
|
app2.provide("SlicksortHub", new SlicksortHub());
|
|
}
|
|
};
|
|
const app = createApp(App);
|
|
app.use(router);
|
|
app.use(plugin$1, axios);
|
|
app.provide("axios", app.config.globalProperties.axios);
|
|
app.use(createPinia());
|
|
app.provide("loaded", ref(false));
|
|
app.mount("#app");
|
|
app.use(plugin);
|
|
export {
|
|
Button$1 as Button,
|
|
ChevronRightIcon,
|
|
Comment,
|
|
CssRender,
|
|
EMPTY_OBJ,
|
|
ErrorIcon$1 as ErrorIcon,
|
|
ErrorIcon as ErrorIcon$1,
|
|
FocusTrap,
|
|
Fragment,
|
|
InfoIcon,
|
|
LazyTeleport,
|
|
Map$1 as Map,
|
|
MapCache,
|
|
NBaseClose,
|
|
NBaseIcon,
|
|
NBaseLoading,
|
|
NFadeInExpandTransition,
|
|
NIconSwitchTransition,
|
|
NLayout,
|
|
NLayoutContent,
|
|
NLayoutSider,
|
|
NO,
|
|
NOOP,
|
|
RouterLink,
|
|
Scrollbar,
|
|
SlickItem,
|
|
SlickList,
|
|
Stack,
|
|
SuccessIcon,
|
|
Symbol$1 as Symbol,
|
|
Teleport,
|
|
Text,
|
|
Transition,
|
|
TransitionGroup,
|
|
Uint8Array$1 as Uint8Array,
|
|
VResizeObserver,
|
|
WarningIcon,
|
|
Wrapper,
|
|
XButton,
|
|
XScrollbar,
|
|
__unplugin_components_0$1 as __unplugin_components_0,
|
|
__unplugin_components_4,
|
|
_export_sfc,
|
|
arrayLikeKeys,
|
|
arrayMap,
|
|
axios,
|
|
baseFor,
|
|
baseGetTag,
|
|
buildFormatLongFn,
|
|
buildLocalizeFn,
|
|
buildMatchFn,
|
|
buildMatchPatternFn,
|
|
buttonGroupInjectionKey,
|
|
buttonLight,
|
|
c,
|
|
cB,
|
|
cCB,
|
|
cE,
|
|
cM,
|
|
cNotM,
|
|
call,
|
|
camelize,
|
|
capitalize,
|
|
changeColor,
|
|
clickoutside,
|
|
cloneVNode,
|
|
color2Class,
|
|
commonVariables$3 as commonVariables,
|
|
composite,
|
|
computed,
|
|
configProviderInjectionKey,
|
|
createBaseVNode,
|
|
createBlock,
|
|
createCommentVNode,
|
|
createElementBlock,
|
|
createId,
|
|
createInjectionKey,
|
|
createKey,
|
|
createSlots,
|
|
createStaticVNode,
|
|
createTextVNode,
|
|
createTheme,
|
|
createVNode,
|
|
cssrAnchorMetaName,
|
|
deepcopy,
|
|
defineComponent,
|
|
defineStore,
|
|
depx,
|
|
derived,
|
|
drawerBodyInjectionKey,
|
|
eq,
|
|
error,
|
|
extend$1 as extend,
|
|
fadeInHeightExpandTransition,
|
|
fadeInScaleUpTransition,
|
|
fadeInTransition,
|
|
flatten,
|
|
formItemInjectionKey,
|
|
formatLength,
|
|
generateCodeFrame,
|
|
getAugmentedNamespace,
|
|
getCurrentInstance,
|
|
getCurrentScope,
|
|
getDefaultExportFromCjs,
|
|
getDefaultOptions,
|
|
getFirstSlotVNode,
|
|
getFirstSlotVNodeWithTypedProps,
|
|
getFirstVNode,
|
|
getGap,
|
|
getMargin,
|
|
getNative,
|
|
getPreciseEventTarget,
|
|
getSlot,
|
|
h,
|
|
hasInstance,
|
|
iconSwitchTransition,
|
|
identity,
|
|
inject,
|
|
insideModal,
|
|
insidePopover,
|
|
isArguments,
|
|
isArray$3 as isArray,
|
|
isArray$2 as isArray$1,
|
|
isArrayLike,
|
|
isBrowser$2 as isBrowser,
|
|
isBrowser$3 as isBrowser$1,
|
|
isBuffer$1 as isBuffer,
|
|
isBuiltInDirective,
|
|
isHTMLTag,
|
|
isIndex,
|
|
isLength,
|
|
isMathMLTag,
|
|
isMounted,
|
|
isObject$1 as isObject,
|
|
isObject$2 as isObject$1,
|
|
isObjectLike,
|
|
isOn,
|
|
isPrototype,
|
|
isProxy,
|
|
isRef,
|
|
isReservedProp,
|
|
isSVGTag,
|
|
isSafari,
|
|
isSameWeek,
|
|
isSlotEmpty,
|
|
isString$1 as isString,
|
|
isSymbol,
|
|
isSymbol$1,
|
|
isTypedArray$1 as isTypedArray,
|
|
isVoidTag,
|
|
keep,
|
|
keysOf,
|
|
layoutSiderInjectionKey,
|
|
loadingBarApiInjectionKey,
|
|
makeMap,
|
|
markEventEffectPerformed,
|
|
markRaw,
|
|
mergeModels,
|
|
mergeProps,
|
|
messageApiInjectionKey,
|
|
modalBodyInjectionKey,
|
|
nextTick,
|
|
normalizeClass,
|
|
normalizeStyle,
|
|
off,
|
|
omit,
|
|
on,
|
|
onActivated,
|
|
onBeforeMount,
|
|
onBeforeUnmount,
|
|
onBeforeUpdate,
|
|
onDeactivated,
|
|
onFontsReady,
|
|
onMounted,
|
|
onScopeDispose,
|
|
onUnmounted,
|
|
openBlock,
|
|
overArg,
|
|
parseStringStyle,
|
|
popoverBodyInjectionKey,
|
|
provide,
|
|
pxfy,
|
|
reactive,
|
|
readonly,
|
|
ref,
|
|
render,
|
|
renderList,
|
|
renderSlot,
|
|
repeat,
|
|
replaceable,
|
|
resizeObserverManager,
|
|
resolveComponent,
|
|
resolveDynamicComponent,
|
|
resolveSlot,
|
|
resolveSlotWithTypedProps,
|
|
resolveWrappedSlot,
|
|
rgba,
|
|
root,
|
|
runtimeDom_esmBundler,
|
|
scrollbarLight,
|
|
shallowRef,
|
|
shared_esmBundler,
|
|
startOfWeek,
|
|
storeToRefs,
|
|
throwError,
|
|
toDate,
|
|
toDisplayString,
|
|
toHandlerKey,
|
|
toRaw,
|
|
toRef,
|
|
toRefs,
|
|
toSource,
|
|
toString$1 as toString,
|
|
unref,
|
|
useConfig,
|
|
useConfigStore,
|
|
useCssVars,
|
|
useFormItem,
|
|
useMemo,
|
|
useMergedClsPrefix,
|
|
useMergedState,
|
|
useModel,
|
|
useMowerStore,
|
|
usePlanStore,
|
|
useRouter,
|
|
useRtl,
|
|
useSsrAdapter,
|
|
useStyle,
|
|
useTheme,
|
|
useThemeClass,
|
|
vShow,
|
|
warn,
|
|
watch,
|
|
watchEffect,
|
|
withCtx,
|
|
withDirectives,
|
|
withModifiers,
|
|
zindexable
|
|
};
|