runtime-dom.cjs.js 44 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. var runtimeCore = require('@vue/runtime-core');
  4. var shared = require('@vue/shared');
  5. const svgNS = "http://www.w3.org/2000/svg";
  6. const doc = typeof document !== "undefined" ? document : null;
  7. const templateContainer = doc && /* @__PURE__ */ doc.createElement("template");
  8. const nodeOps = {
  9. insert: (child, parent, anchor) => {
  10. parent.insertBefore(child, anchor || null);
  11. },
  12. remove: (child) => {
  13. const parent = child.parentNode;
  14. if (parent) {
  15. parent.removeChild(child);
  16. }
  17. },
  18. createElement: (tag, isSVG, is, props) => {
  19. const el = isSVG ? doc.createElementNS(svgNS, tag) : doc.createElement(tag, is ? { is } : void 0);
  20. if (tag === "select" && props && props.multiple != null) {
  21. el.setAttribute("multiple", props.multiple);
  22. }
  23. return el;
  24. },
  25. createText: (text) => doc.createTextNode(text),
  26. createComment: (text) => doc.createComment(text),
  27. setText: (node, text) => {
  28. node.nodeValue = text;
  29. },
  30. setElementText: (el, text) => {
  31. el.textContent = text;
  32. },
  33. parentNode: (node) => node.parentNode,
  34. nextSibling: (node) => node.nextSibling,
  35. querySelector: (selector) => doc.querySelector(selector),
  36. setScopeId(el, id) {
  37. el.setAttribute(id, "");
  38. },
  39. // __UNSAFE__
  40. // Reason: innerHTML.
  41. // Static content here can only come from compiled templates.
  42. // As long as the user only uses trusted templates, this is safe.
  43. insertStaticContent(content, parent, anchor, isSVG, start, end) {
  44. const before = anchor ? anchor.previousSibling : parent.lastChild;
  45. if (start && (start === end || start.nextSibling)) {
  46. while (true) {
  47. parent.insertBefore(start.cloneNode(true), anchor);
  48. if (start === end || !(start = start.nextSibling))
  49. break;
  50. }
  51. } else {
  52. templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
  53. const template = templateContainer.content;
  54. if (isSVG) {
  55. const wrapper = template.firstChild;
  56. while (wrapper.firstChild) {
  57. template.appendChild(wrapper.firstChild);
  58. }
  59. template.removeChild(wrapper);
  60. }
  61. parent.insertBefore(template, anchor);
  62. }
  63. return [
  64. // first
  65. before ? before.nextSibling : parent.firstChild,
  66. // last
  67. anchor ? anchor.previousSibling : parent.lastChild
  68. ];
  69. }
  70. };
  71. const TRANSITION = "transition";
  72. const ANIMATION = "animation";
  73. const vtcKey = Symbol("_vtc");
  74. const Transition = (props, { slots }) => runtimeCore.h(runtimeCore.BaseTransition, resolveTransitionProps(props), slots);
  75. Transition.displayName = "Transition";
  76. const DOMTransitionPropsValidators = {
  77. name: String,
  78. type: String,
  79. css: {
  80. type: Boolean,
  81. default: true
  82. },
  83. duration: [String, Number, Object],
  84. enterFromClass: String,
  85. enterActiveClass: String,
  86. enterToClass: String,
  87. appearFromClass: String,
  88. appearActiveClass: String,
  89. appearToClass: String,
  90. leaveFromClass: String,
  91. leaveActiveClass: String,
  92. leaveToClass: String
  93. };
  94. const TransitionPropsValidators = Transition.props = /* @__PURE__ */ shared.extend(
  95. {},
  96. runtimeCore.BaseTransitionPropsValidators,
  97. DOMTransitionPropsValidators
  98. );
  99. const callHook = (hook, args = []) => {
  100. if (shared.isArray(hook)) {
  101. hook.forEach((h2) => h2(...args));
  102. } else if (hook) {
  103. hook(...args);
  104. }
  105. };
  106. const hasExplicitCallback = (hook) => {
  107. return hook ? shared.isArray(hook) ? hook.some((h2) => h2.length > 1) : hook.length > 1 : false;
  108. };
  109. function resolveTransitionProps(rawProps) {
  110. const baseProps = {};
  111. for (const key in rawProps) {
  112. if (!(key in DOMTransitionPropsValidators)) {
  113. baseProps[key] = rawProps[key];
  114. }
  115. }
  116. if (rawProps.css === false) {
  117. return baseProps;
  118. }
  119. const {
  120. name = "v",
  121. type,
  122. duration,
  123. enterFromClass = `${name}-enter-from`,
  124. enterActiveClass = `${name}-enter-active`,
  125. enterToClass = `${name}-enter-to`,
  126. appearFromClass = enterFromClass,
  127. appearActiveClass = enterActiveClass,
  128. appearToClass = enterToClass,
  129. leaveFromClass = `${name}-leave-from`,
  130. leaveActiveClass = `${name}-leave-active`,
  131. leaveToClass = `${name}-leave-to`
  132. } = rawProps;
  133. const durations = normalizeDuration(duration);
  134. const enterDuration = durations && durations[0];
  135. const leaveDuration = durations && durations[1];
  136. const {
  137. onBeforeEnter,
  138. onEnter,
  139. onEnterCancelled,
  140. onLeave,
  141. onLeaveCancelled,
  142. onBeforeAppear = onBeforeEnter,
  143. onAppear = onEnter,
  144. onAppearCancelled = onEnterCancelled
  145. } = baseProps;
  146. const finishEnter = (el, isAppear, done) => {
  147. removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
  148. removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
  149. done && done();
  150. };
  151. const finishLeave = (el, done) => {
  152. el._isLeaving = false;
  153. removeTransitionClass(el, leaveFromClass);
  154. removeTransitionClass(el, leaveToClass);
  155. removeTransitionClass(el, leaveActiveClass);
  156. done && done();
  157. };
  158. const makeEnterHook = (isAppear) => {
  159. return (el, done) => {
  160. const hook = isAppear ? onAppear : onEnter;
  161. const resolve = () => finishEnter(el, isAppear, done);
  162. callHook(hook, [el, resolve]);
  163. nextFrame(() => {
  164. removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
  165. addTransitionClass(el, isAppear ? appearToClass : enterToClass);
  166. if (!hasExplicitCallback(hook)) {
  167. whenTransitionEnds(el, type, enterDuration, resolve);
  168. }
  169. });
  170. };
  171. };
  172. return shared.extend(baseProps, {
  173. onBeforeEnter(el) {
  174. callHook(onBeforeEnter, [el]);
  175. addTransitionClass(el, enterFromClass);
  176. addTransitionClass(el, enterActiveClass);
  177. },
  178. onBeforeAppear(el) {
  179. callHook(onBeforeAppear, [el]);
  180. addTransitionClass(el, appearFromClass);
  181. addTransitionClass(el, appearActiveClass);
  182. },
  183. onEnter: makeEnterHook(false),
  184. onAppear: makeEnterHook(true),
  185. onLeave(el, done) {
  186. el._isLeaving = true;
  187. const resolve = () => finishLeave(el, done);
  188. addTransitionClass(el, leaveFromClass);
  189. forceReflow();
  190. addTransitionClass(el, leaveActiveClass);
  191. nextFrame(() => {
  192. if (!el._isLeaving) {
  193. return;
  194. }
  195. removeTransitionClass(el, leaveFromClass);
  196. addTransitionClass(el, leaveToClass);
  197. if (!hasExplicitCallback(onLeave)) {
  198. whenTransitionEnds(el, type, leaveDuration, resolve);
  199. }
  200. });
  201. callHook(onLeave, [el, resolve]);
  202. },
  203. onEnterCancelled(el) {
  204. finishEnter(el, false);
  205. callHook(onEnterCancelled, [el]);
  206. },
  207. onAppearCancelled(el) {
  208. finishEnter(el, true);
  209. callHook(onAppearCancelled, [el]);
  210. },
  211. onLeaveCancelled(el) {
  212. finishLeave(el);
  213. callHook(onLeaveCancelled, [el]);
  214. }
  215. });
  216. }
  217. function normalizeDuration(duration) {
  218. if (duration == null) {
  219. return null;
  220. } else if (shared.isObject(duration)) {
  221. return [NumberOf(duration.enter), NumberOf(duration.leave)];
  222. } else {
  223. const n = NumberOf(duration);
  224. return [n, n];
  225. }
  226. }
  227. function NumberOf(val) {
  228. const res = shared.toNumber(val);
  229. {
  230. runtimeCore.assertNumber(res, "<transition> explicit duration");
  231. }
  232. return res;
  233. }
  234. function addTransitionClass(el, cls) {
  235. cls.split(/\s+/).forEach((c) => c && el.classList.add(c));
  236. (el[vtcKey] || (el[vtcKey] = /* @__PURE__ */ new Set())).add(cls);
  237. }
  238. function removeTransitionClass(el, cls) {
  239. cls.split(/\s+/).forEach((c) => c && el.classList.remove(c));
  240. const _vtc = el[vtcKey];
  241. if (_vtc) {
  242. _vtc.delete(cls);
  243. if (!_vtc.size) {
  244. el[vtcKey] = void 0;
  245. }
  246. }
  247. }
  248. function nextFrame(cb) {
  249. requestAnimationFrame(() => {
  250. requestAnimationFrame(cb);
  251. });
  252. }
  253. let endId = 0;
  254. function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
  255. const id = el._endId = ++endId;
  256. const resolveIfNotStale = () => {
  257. if (id === el._endId) {
  258. resolve();
  259. }
  260. };
  261. if (explicitTimeout) {
  262. return setTimeout(resolveIfNotStale, explicitTimeout);
  263. }
  264. const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
  265. if (!type) {
  266. return resolve();
  267. }
  268. const endEvent = type + "end";
  269. let ended = 0;
  270. const end = () => {
  271. el.removeEventListener(endEvent, onEnd);
  272. resolveIfNotStale();
  273. };
  274. const onEnd = (e) => {
  275. if (e.target === el && ++ended >= propCount) {
  276. end();
  277. }
  278. };
  279. setTimeout(() => {
  280. if (ended < propCount) {
  281. end();
  282. }
  283. }, timeout + 1);
  284. el.addEventListener(endEvent, onEnd);
  285. }
  286. function getTransitionInfo(el, expectedType) {
  287. const styles = window.getComputedStyle(el);
  288. const getStyleProperties = (key) => (styles[key] || "").split(", ");
  289. const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
  290. const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
  291. const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
  292. const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
  293. const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
  294. const animationTimeout = getTimeout(animationDelays, animationDurations);
  295. let type = null;
  296. let timeout = 0;
  297. let propCount = 0;
  298. if (expectedType === TRANSITION) {
  299. if (transitionTimeout > 0) {
  300. type = TRANSITION;
  301. timeout = transitionTimeout;
  302. propCount = transitionDurations.length;
  303. }
  304. } else if (expectedType === ANIMATION) {
  305. if (animationTimeout > 0) {
  306. type = ANIMATION;
  307. timeout = animationTimeout;
  308. propCount = animationDurations.length;
  309. }
  310. } else {
  311. timeout = Math.max(transitionTimeout, animationTimeout);
  312. type = timeout > 0 ? transitionTimeout > animationTimeout ? TRANSITION : ANIMATION : null;
  313. propCount = type ? type === TRANSITION ? transitionDurations.length : animationDurations.length : 0;
  314. }
  315. const hasTransform = type === TRANSITION && /\b(transform|all)(,|$)/.test(
  316. getStyleProperties(`${TRANSITION}Property`).toString()
  317. );
  318. return {
  319. type,
  320. timeout,
  321. propCount,
  322. hasTransform
  323. };
  324. }
  325. function getTimeout(delays, durations) {
  326. while (delays.length < durations.length) {
  327. delays = delays.concat(delays);
  328. }
  329. return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
  330. }
  331. function toMs(s) {
  332. if (s === "auto")
  333. return 0;
  334. return Number(s.slice(0, -1).replace(",", ".")) * 1e3;
  335. }
  336. function forceReflow() {
  337. return document.body.offsetHeight;
  338. }
  339. function patchClass(el, value, isSVG) {
  340. const transitionClasses = el[vtcKey];
  341. if (transitionClasses) {
  342. value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(" ");
  343. }
  344. if (value == null) {
  345. el.removeAttribute("class");
  346. } else if (isSVG) {
  347. el.setAttribute("class", value);
  348. } else {
  349. el.className = value;
  350. }
  351. }
  352. const vShowOldKey = Symbol("_vod");
  353. const vShow = {
  354. beforeMount(el, { value }, { transition }) {
  355. el[vShowOldKey] = el.style.display === "none" ? "" : el.style.display;
  356. if (transition && value) {
  357. transition.beforeEnter(el);
  358. } else {
  359. setDisplay(el, value);
  360. }
  361. },
  362. mounted(el, { value }, { transition }) {
  363. if (transition && value) {
  364. transition.enter(el);
  365. }
  366. },
  367. updated(el, { value, oldValue }, { transition }) {
  368. if (!value === !oldValue)
  369. return;
  370. if (transition) {
  371. if (value) {
  372. transition.beforeEnter(el);
  373. setDisplay(el, true);
  374. transition.enter(el);
  375. } else {
  376. transition.leave(el, () => {
  377. setDisplay(el, false);
  378. });
  379. }
  380. } else {
  381. setDisplay(el, value);
  382. }
  383. },
  384. beforeUnmount(el, { value }) {
  385. setDisplay(el, value);
  386. }
  387. };
  388. function setDisplay(el, value) {
  389. el.style.display = value ? el[vShowOldKey] : "none";
  390. }
  391. function initVShowForSSR() {
  392. vShow.getSSRProps = ({ value }) => {
  393. if (!value) {
  394. return { style: { display: "none" } };
  395. }
  396. };
  397. }
  398. function patchStyle(el, prev, next) {
  399. const style = el.style;
  400. const isCssString = shared.isString(next);
  401. if (next && !isCssString) {
  402. if (prev && !shared.isString(prev)) {
  403. for (const key in prev) {
  404. if (next[key] == null) {
  405. setStyle(style, key, "");
  406. }
  407. }
  408. }
  409. for (const key in next) {
  410. setStyle(style, key, next[key]);
  411. }
  412. } else {
  413. const currentDisplay = style.display;
  414. if (isCssString) {
  415. if (prev !== next) {
  416. style.cssText = next;
  417. }
  418. } else if (prev) {
  419. el.removeAttribute("style");
  420. }
  421. if (vShowOldKey in el) {
  422. style.display = currentDisplay;
  423. }
  424. }
  425. }
  426. const semicolonRE = /[^\\];\s*$/;
  427. const importantRE = /\s*!important$/;
  428. function setStyle(style, name, val) {
  429. if (shared.isArray(val)) {
  430. val.forEach((v) => setStyle(style, name, v));
  431. } else {
  432. if (val == null)
  433. val = "";
  434. {
  435. if (semicolonRE.test(val)) {
  436. runtimeCore.warn(
  437. `Unexpected semicolon at the end of '${name}' style value: '${val}'`
  438. );
  439. }
  440. }
  441. if (name.startsWith("--")) {
  442. style.setProperty(name, val);
  443. } else {
  444. const prefixed = autoPrefix(style, name);
  445. if (importantRE.test(val)) {
  446. style.setProperty(
  447. shared.hyphenate(prefixed),
  448. val.replace(importantRE, ""),
  449. "important"
  450. );
  451. } else {
  452. style[prefixed] = val;
  453. }
  454. }
  455. }
  456. }
  457. const prefixes = ["Webkit", "Moz", "ms"];
  458. const prefixCache = {};
  459. function autoPrefix(style, rawName) {
  460. const cached = prefixCache[rawName];
  461. if (cached) {
  462. return cached;
  463. }
  464. let name = runtimeCore.camelize(rawName);
  465. if (name !== "filter" && name in style) {
  466. return prefixCache[rawName] = name;
  467. }
  468. name = shared.capitalize(name);
  469. for (let i = 0; i < prefixes.length; i++) {
  470. const prefixed = prefixes[i] + name;
  471. if (prefixed in style) {
  472. return prefixCache[rawName] = prefixed;
  473. }
  474. }
  475. return rawName;
  476. }
  477. const xlinkNS = "http://www.w3.org/1999/xlink";
  478. function patchAttr(el, key, value, isSVG, instance) {
  479. if (isSVG && key.startsWith("xlink:")) {
  480. if (value == null) {
  481. el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
  482. } else {
  483. el.setAttributeNS(xlinkNS, key, value);
  484. }
  485. } else {
  486. const isBoolean = shared.isSpecialBooleanAttr(key);
  487. if (value == null || isBoolean && !shared.includeBooleanAttr(value)) {
  488. el.removeAttribute(key);
  489. } else {
  490. el.setAttribute(key, isBoolean ? "" : value);
  491. }
  492. }
  493. }
  494. function patchDOMProp(el, key, value, prevChildren, parentComponent, parentSuspense, unmountChildren) {
  495. if (key === "innerHTML" || key === "textContent") {
  496. if (prevChildren) {
  497. unmountChildren(prevChildren, parentComponent, parentSuspense);
  498. }
  499. el[key] = value == null ? "" : value;
  500. return;
  501. }
  502. const tag = el.tagName;
  503. if (key === "value" && tag !== "PROGRESS" && // custom elements may use _value internally
  504. !tag.includes("-")) {
  505. el._value = value;
  506. const oldValue = tag === "OPTION" ? el.getAttribute("value") : el.value;
  507. const newValue = value == null ? "" : value;
  508. if (oldValue !== newValue) {
  509. el.value = newValue;
  510. }
  511. if (value == null) {
  512. el.removeAttribute(key);
  513. }
  514. return;
  515. }
  516. let needRemove = false;
  517. if (value === "" || value == null) {
  518. const type = typeof el[key];
  519. if (type === "boolean") {
  520. value = shared.includeBooleanAttr(value);
  521. } else if (value == null && type === "string") {
  522. value = "";
  523. needRemove = true;
  524. } else if (type === "number") {
  525. value = 0;
  526. needRemove = true;
  527. }
  528. }
  529. try {
  530. el[key] = value;
  531. } catch (e) {
  532. if (!needRemove) {
  533. runtimeCore.warn(
  534. `Failed setting prop "${key}" on <${tag.toLowerCase()}>: value ${value} is invalid.`,
  535. e
  536. );
  537. }
  538. }
  539. needRemove && el.removeAttribute(key);
  540. }
  541. function addEventListener(el, event, handler, options) {
  542. el.addEventListener(event, handler, options);
  543. }
  544. function removeEventListener(el, event, handler, options) {
  545. el.removeEventListener(event, handler, options);
  546. }
  547. const veiKey = Symbol("_vei");
  548. function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
  549. const invokers = el[veiKey] || (el[veiKey] = {});
  550. const existingInvoker = invokers[rawName];
  551. if (nextValue && existingInvoker) {
  552. existingInvoker.value = nextValue;
  553. } else {
  554. const [name, options] = parseName(rawName);
  555. if (nextValue) {
  556. const invoker = invokers[rawName] = createInvoker(nextValue, instance);
  557. addEventListener(el, name, invoker, options);
  558. } else if (existingInvoker) {
  559. removeEventListener(el, name, existingInvoker, options);
  560. invokers[rawName] = void 0;
  561. }
  562. }
  563. }
  564. const optionsModifierRE = /(?:Once|Passive|Capture)$/;
  565. function parseName(name) {
  566. let options;
  567. if (optionsModifierRE.test(name)) {
  568. options = {};
  569. let m;
  570. while (m = name.match(optionsModifierRE)) {
  571. name = name.slice(0, name.length - m[0].length);
  572. options[m[0].toLowerCase()] = true;
  573. }
  574. }
  575. const event = name[2] === ":" ? name.slice(3) : shared.hyphenate(name.slice(2));
  576. return [event, options];
  577. }
  578. let cachedNow = 0;
  579. const p = /* @__PURE__ */ Promise.resolve();
  580. const getNow = () => cachedNow || (p.then(() => cachedNow = 0), cachedNow = Date.now());
  581. function createInvoker(initialValue, instance) {
  582. const invoker = (e) => {
  583. if (!e._vts) {
  584. e._vts = Date.now();
  585. } else if (e._vts <= invoker.attached) {
  586. return;
  587. }
  588. runtimeCore.callWithAsyncErrorHandling(
  589. patchStopImmediatePropagation(e, invoker.value),
  590. instance,
  591. 5,
  592. [e]
  593. );
  594. };
  595. invoker.value = initialValue;
  596. invoker.attached = getNow();
  597. return invoker;
  598. }
  599. function patchStopImmediatePropagation(e, value) {
  600. if (shared.isArray(value)) {
  601. const originalStop = e.stopImmediatePropagation;
  602. e.stopImmediatePropagation = () => {
  603. originalStop.call(e);
  604. e._stopped = true;
  605. };
  606. return value.map((fn) => (e2) => !e2._stopped && fn && fn(e2));
  607. } else {
  608. return value;
  609. }
  610. }
  611. const isNativeOn = (key) => key.charCodeAt(0) === 111 && key.charCodeAt(1) === 110 && // lowercase letter
  612. key.charCodeAt(2) > 96 && key.charCodeAt(2) < 123;
  613. const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
  614. if (key === "class") {
  615. patchClass(el, nextValue, isSVG);
  616. } else if (key === "style") {
  617. patchStyle(el, prevValue, nextValue);
  618. } else if (shared.isOn(key)) {
  619. if (!shared.isModelListener(key)) {
  620. patchEvent(el, key, prevValue, nextValue, parentComponent);
  621. }
  622. } else if (key[0] === "." ? (key = key.slice(1), true) : key[0] === "^" ? (key = key.slice(1), false) : shouldSetAsProp(el, key, nextValue, isSVG)) {
  623. patchDOMProp(
  624. el,
  625. key,
  626. nextValue,
  627. prevChildren,
  628. parentComponent,
  629. parentSuspense,
  630. unmountChildren
  631. );
  632. } else {
  633. if (key === "true-value") {
  634. el._trueValue = nextValue;
  635. } else if (key === "false-value") {
  636. el._falseValue = nextValue;
  637. }
  638. patchAttr(el, key, nextValue, isSVG);
  639. }
  640. };
  641. function shouldSetAsProp(el, key, value, isSVG) {
  642. if (isSVG) {
  643. if (key === "innerHTML" || key === "textContent") {
  644. return true;
  645. }
  646. if (key in el && isNativeOn(key) && shared.isFunction(value)) {
  647. return true;
  648. }
  649. return false;
  650. }
  651. if (key === "spellcheck" || key === "draggable" || key === "translate") {
  652. return false;
  653. }
  654. if (key === "form") {
  655. return false;
  656. }
  657. if (key === "list" && el.tagName === "INPUT") {
  658. return false;
  659. }
  660. if (key === "type" && el.tagName === "TEXTAREA") {
  661. return false;
  662. }
  663. if (key === "width" || key === "height") {
  664. const tag = el.tagName;
  665. if (tag === "IMG" || tag === "VIDEO" || tag === "CANVAS" || tag === "SOURCE") {
  666. return false;
  667. }
  668. }
  669. if (isNativeOn(key) && shared.isString(value)) {
  670. return false;
  671. }
  672. return key in el;
  673. }
  674. /*! #__NO_SIDE_EFFECTS__ */
  675. // @__NO_SIDE_EFFECTS__
  676. function defineCustomElement(options, hydrate2) {
  677. const Comp = runtimeCore.defineComponent(options);
  678. class VueCustomElement extends VueElement {
  679. constructor(initialProps) {
  680. super(Comp, initialProps, hydrate2);
  681. }
  682. }
  683. VueCustomElement.def = Comp;
  684. return VueCustomElement;
  685. }
  686. /*! #__NO_SIDE_EFFECTS__ */
  687. const defineSSRCustomElement = /* @__NO_SIDE_EFFECTS__ */ (options) => {
  688. return /* @__PURE__ */ defineCustomElement(options, hydrate);
  689. };
  690. const BaseClass = typeof HTMLElement !== "undefined" ? HTMLElement : class {
  691. };
  692. class VueElement extends BaseClass {
  693. constructor(_def, _props = {}, hydrate2) {
  694. super();
  695. this._def = _def;
  696. this._props = _props;
  697. /**
  698. * @internal
  699. */
  700. this._instance = null;
  701. this._connected = false;
  702. this._resolved = false;
  703. this._numberProps = null;
  704. this._ob = null;
  705. if (this.shadowRoot && hydrate2) {
  706. hydrate2(this._createVNode(), this.shadowRoot);
  707. } else {
  708. if (this.shadowRoot) {
  709. runtimeCore.warn(
  710. `Custom element has pre-rendered declarative shadow root but is not defined as hydratable. Use \`defineSSRCustomElement\`.`
  711. );
  712. }
  713. this.attachShadow({ mode: "open" });
  714. if (!this._def.__asyncLoader) {
  715. this._resolveProps(this._def);
  716. }
  717. }
  718. }
  719. connectedCallback() {
  720. this._connected = true;
  721. if (!this._instance) {
  722. if (this._resolved) {
  723. this._update();
  724. } else {
  725. this._resolveDef();
  726. }
  727. }
  728. }
  729. disconnectedCallback() {
  730. this._connected = false;
  731. if (this._ob) {
  732. this._ob.disconnect();
  733. this._ob = null;
  734. }
  735. runtimeCore.nextTick(() => {
  736. if (!this._connected) {
  737. render(null, this.shadowRoot);
  738. this._instance = null;
  739. }
  740. });
  741. }
  742. /**
  743. * resolve inner component definition (handle possible async component)
  744. */
  745. _resolveDef() {
  746. this._resolved = true;
  747. for (let i = 0; i < this.attributes.length; i++) {
  748. this._setAttr(this.attributes[i].name);
  749. }
  750. this._ob = new MutationObserver((mutations) => {
  751. for (const m of mutations) {
  752. this._setAttr(m.attributeName);
  753. }
  754. });
  755. this._ob.observe(this, { attributes: true });
  756. const resolve = (def, isAsync = false) => {
  757. const { props, styles } = def;
  758. let numberProps;
  759. if (props && !shared.isArray(props)) {
  760. for (const key in props) {
  761. const opt = props[key];
  762. if (opt === Number || opt && opt.type === Number) {
  763. if (key in this._props) {
  764. this._props[key] = shared.toNumber(this._props[key]);
  765. }
  766. (numberProps || (numberProps = /* @__PURE__ */ Object.create(null)))[shared.camelize(key)] = true;
  767. }
  768. }
  769. }
  770. this._numberProps = numberProps;
  771. if (isAsync) {
  772. this._resolveProps(def);
  773. }
  774. this._applyStyles(styles);
  775. this._update();
  776. };
  777. const asyncDef = this._def.__asyncLoader;
  778. if (asyncDef) {
  779. asyncDef().then((def) => resolve(def, true));
  780. } else {
  781. resolve(this._def);
  782. }
  783. }
  784. _resolveProps(def) {
  785. const { props } = def;
  786. const declaredPropKeys = shared.isArray(props) ? props : Object.keys(props || {});
  787. for (const key of Object.keys(this)) {
  788. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  789. this._setProp(key, this[key], true, false);
  790. }
  791. }
  792. for (const key of declaredPropKeys.map(shared.camelize)) {
  793. Object.defineProperty(this, key, {
  794. get() {
  795. return this._getProp(key);
  796. },
  797. set(val) {
  798. this._setProp(key, val);
  799. }
  800. });
  801. }
  802. }
  803. _setAttr(key) {
  804. let value = this.getAttribute(key);
  805. const camelKey = shared.camelize(key);
  806. if (this._numberProps && this._numberProps[camelKey]) {
  807. value = shared.toNumber(value);
  808. }
  809. this._setProp(camelKey, value, false);
  810. }
  811. /**
  812. * @internal
  813. */
  814. _getProp(key) {
  815. return this._props[key];
  816. }
  817. /**
  818. * @internal
  819. */
  820. _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
  821. if (val !== this._props[key]) {
  822. this._props[key] = val;
  823. if (shouldUpdate && this._instance) {
  824. this._update();
  825. }
  826. if (shouldReflect) {
  827. if (val === true) {
  828. this.setAttribute(shared.hyphenate(key), "");
  829. } else if (typeof val === "string" || typeof val === "number") {
  830. this.setAttribute(shared.hyphenate(key), val + "");
  831. } else if (!val) {
  832. this.removeAttribute(shared.hyphenate(key));
  833. }
  834. }
  835. }
  836. }
  837. _update() {
  838. render(this._createVNode(), this.shadowRoot);
  839. }
  840. _createVNode() {
  841. const vnode = runtimeCore.createVNode(this._def, shared.extend({}, this._props));
  842. if (!this._instance) {
  843. vnode.ce = (instance) => {
  844. this._instance = instance;
  845. instance.isCE = true;
  846. {
  847. instance.ceReload = (newStyles) => {
  848. if (this._styles) {
  849. this._styles.forEach((s) => this.shadowRoot.removeChild(s));
  850. this._styles.length = 0;
  851. }
  852. this._applyStyles(newStyles);
  853. this._instance = null;
  854. this._update();
  855. };
  856. }
  857. const dispatch = (event, args) => {
  858. this.dispatchEvent(
  859. new CustomEvent(event, {
  860. detail: args
  861. })
  862. );
  863. };
  864. instance.emit = (event, ...args) => {
  865. dispatch(event, args);
  866. if (shared.hyphenate(event) !== event) {
  867. dispatch(shared.hyphenate(event), args);
  868. }
  869. };
  870. let parent = this;
  871. while (parent = parent && (parent.parentNode || parent.host)) {
  872. if (parent instanceof VueElement) {
  873. instance.parent = parent._instance;
  874. instance.provides = parent._instance.provides;
  875. break;
  876. }
  877. }
  878. };
  879. }
  880. return vnode;
  881. }
  882. _applyStyles(styles) {
  883. if (styles) {
  884. styles.forEach((css) => {
  885. const s = document.createElement("style");
  886. s.textContent = css;
  887. this.shadowRoot.appendChild(s);
  888. {
  889. (this._styles || (this._styles = [])).push(s);
  890. }
  891. });
  892. }
  893. }
  894. }
  895. function useCssModule(name = "$style") {
  896. {
  897. const instance = runtimeCore.getCurrentInstance();
  898. if (!instance) {
  899. runtimeCore.warn(`useCssModule must be called inside setup()`);
  900. return shared.EMPTY_OBJ;
  901. }
  902. const modules = instance.type.__cssModules;
  903. if (!modules) {
  904. runtimeCore.warn(`Current instance does not have CSS modules injected.`);
  905. return shared.EMPTY_OBJ;
  906. }
  907. const mod = modules[name];
  908. if (!mod) {
  909. runtimeCore.warn(`Current instance does not have CSS module named "${name}".`);
  910. return shared.EMPTY_OBJ;
  911. }
  912. return mod;
  913. }
  914. }
  915. function useCssVars(getter) {
  916. return;
  917. }
  918. const positionMap = /* @__PURE__ */ new WeakMap();
  919. const newPositionMap = /* @__PURE__ */ new WeakMap();
  920. const moveCbKey = Symbol("_moveCb");
  921. const enterCbKey = Symbol("_enterCb");
  922. const TransitionGroupImpl = {
  923. name: "TransitionGroup",
  924. props: /* @__PURE__ */ shared.extend({}, TransitionPropsValidators, {
  925. tag: String,
  926. moveClass: String
  927. }),
  928. setup(props, { slots }) {
  929. const instance = runtimeCore.getCurrentInstance();
  930. const state = runtimeCore.useTransitionState();
  931. let prevChildren;
  932. let children;
  933. runtimeCore.onUpdated(() => {
  934. if (!prevChildren.length) {
  935. return;
  936. }
  937. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  938. if (!hasCSSTransform(
  939. prevChildren[0].el,
  940. instance.vnode.el,
  941. moveClass
  942. )) {
  943. return;
  944. }
  945. prevChildren.forEach(callPendingCbs);
  946. prevChildren.forEach(recordPosition);
  947. const movedChildren = prevChildren.filter(applyTranslation);
  948. forceReflow();
  949. movedChildren.forEach((c) => {
  950. const el = c.el;
  951. const style = el.style;
  952. addTransitionClass(el, moveClass);
  953. style.transform = style.webkitTransform = style.transitionDuration = "";
  954. const cb = el[moveCbKey] = (e) => {
  955. if (e && e.target !== el) {
  956. return;
  957. }
  958. if (!e || /transform$/.test(e.propertyName)) {
  959. el.removeEventListener("transitionend", cb);
  960. el[moveCbKey] = null;
  961. removeTransitionClass(el, moveClass);
  962. }
  963. };
  964. el.addEventListener("transitionend", cb);
  965. });
  966. });
  967. return () => {
  968. const rawProps = runtimeCore.toRaw(props);
  969. const cssTransitionProps = resolveTransitionProps(rawProps);
  970. let tag = rawProps.tag || runtimeCore.Fragment;
  971. prevChildren = children;
  972. children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : [];
  973. for (let i = 0; i < children.length; i++) {
  974. const child = children[i];
  975. if (child.key != null) {
  976. runtimeCore.setTransitionHooks(
  977. child,
  978. runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance)
  979. );
  980. } else {
  981. runtimeCore.warn(`<TransitionGroup> children must be keyed.`);
  982. }
  983. }
  984. if (prevChildren) {
  985. for (let i = 0; i < prevChildren.length; i++) {
  986. const child = prevChildren[i];
  987. runtimeCore.setTransitionHooks(
  988. child,
  989. runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance)
  990. );
  991. positionMap.set(child, child.el.getBoundingClientRect());
  992. }
  993. }
  994. return runtimeCore.createVNode(tag, null, children);
  995. };
  996. }
  997. };
  998. const removeMode = (props) => delete props.mode;
  999. /* @__PURE__ */ removeMode(TransitionGroupImpl.props);
  1000. const TransitionGroup = TransitionGroupImpl;
  1001. function callPendingCbs(c) {
  1002. const el = c.el;
  1003. if (el[moveCbKey]) {
  1004. el[moveCbKey]();
  1005. }
  1006. if (el[enterCbKey]) {
  1007. el[enterCbKey]();
  1008. }
  1009. }
  1010. function recordPosition(c) {
  1011. newPositionMap.set(c, c.el.getBoundingClientRect());
  1012. }
  1013. function applyTranslation(c) {
  1014. const oldPos = positionMap.get(c);
  1015. const newPos = newPositionMap.get(c);
  1016. const dx = oldPos.left - newPos.left;
  1017. const dy = oldPos.top - newPos.top;
  1018. if (dx || dy) {
  1019. const s = c.el.style;
  1020. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  1021. s.transitionDuration = "0s";
  1022. return c;
  1023. }
  1024. }
  1025. function hasCSSTransform(el, root, moveClass) {
  1026. const clone = el.cloneNode();
  1027. const _vtc = el[vtcKey];
  1028. if (_vtc) {
  1029. _vtc.forEach((cls) => {
  1030. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  1031. });
  1032. }
  1033. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  1034. clone.style.display = "none";
  1035. const container = root.nodeType === 1 ? root : root.parentNode;
  1036. container.appendChild(clone);
  1037. const { hasTransform } = getTransitionInfo(clone);
  1038. container.removeChild(clone);
  1039. return hasTransform;
  1040. }
  1041. const getModelAssigner = (vnode) => {
  1042. const fn = vnode.props["onUpdate:modelValue"] || false;
  1043. return shared.isArray(fn) ? (value) => shared.invokeArrayFns(fn, value) : fn;
  1044. };
  1045. function onCompositionStart(e) {
  1046. e.target.composing = true;
  1047. }
  1048. function onCompositionEnd(e) {
  1049. const target = e.target;
  1050. if (target.composing) {
  1051. target.composing = false;
  1052. target.dispatchEvent(new Event("input"));
  1053. }
  1054. }
  1055. const assignKey = Symbol("_assign");
  1056. const vModelText = {
  1057. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  1058. el[assignKey] = getModelAssigner(vnode);
  1059. const castToNumber = number || vnode.props && vnode.props.type === "number";
  1060. addEventListener(el, lazy ? "change" : "input", (e) => {
  1061. if (e.target.composing)
  1062. return;
  1063. let domValue = el.value;
  1064. if (trim) {
  1065. domValue = domValue.trim();
  1066. }
  1067. if (castToNumber) {
  1068. domValue = shared.looseToNumber(domValue);
  1069. }
  1070. el[assignKey](domValue);
  1071. });
  1072. if (trim) {
  1073. addEventListener(el, "change", () => {
  1074. el.value = el.value.trim();
  1075. });
  1076. }
  1077. if (!lazy) {
  1078. addEventListener(el, "compositionstart", onCompositionStart);
  1079. addEventListener(el, "compositionend", onCompositionEnd);
  1080. addEventListener(el, "change", onCompositionEnd);
  1081. }
  1082. },
  1083. // set value on mounted so it's after min/max for type="range"
  1084. mounted(el, { value }) {
  1085. el.value = value == null ? "" : value;
  1086. },
  1087. beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
  1088. el[assignKey] = getModelAssigner(vnode);
  1089. if (el.composing)
  1090. return;
  1091. const elValue = number || el.type === "number" ? shared.looseToNumber(el.value) : el.value;
  1092. const newValue = value == null ? "" : value;
  1093. if (elValue === newValue) {
  1094. return;
  1095. }
  1096. if (document.activeElement === el && el.type !== "range") {
  1097. if (lazy) {
  1098. return;
  1099. }
  1100. if (trim && el.value.trim() === newValue) {
  1101. return;
  1102. }
  1103. }
  1104. el.value = newValue;
  1105. }
  1106. };
  1107. const vModelCheckbox = {
  1108. // #4096 array checkboxes need to be deep traversed
  1109. deep: true,
  1110. created(el, _, vnode) {
  1111. el[assignKey] = getModelAssigner(vnode);
  1112. addEventListener(el, "change", () => {
  1113. const modelValue = el._modelValue;
  1114. const elementValue = getValue(el);
  1115. const checked = el.checked;
  1116. const assign = el[assignKey];
  1117. if (shared.isArray(modelValue)) {
  1118. const index = shared.looseIndexOf(modelValue, elementValue);
  1119. const found = index !== -1;
  1120. if (checked && !found) {
  1121. assign(modelValue.concat(elementValue));
  1122. } else if (!checked && found) {
  1123. const filtered = [...modelValue];
  1124. filtered.splice(index, 1);
  1125. assign(filtered);
  1126. }
  1127. } else if (shared.isSet(modelValue)) {
  1128. const cloned = new Set(modelValue);
  1129. if (checked) {
  1130. cloned.add(elementValue);
  1131. } else {
  1132. cloned.delete(elementValue);
  1133. }
  1134. assign(cloned);
  1135. } else {
  1136. assign(getCheckboxValue(el, checked));
  1137. }
  1138. });
  1139. },
  1140. // set initial checked on mount to wait for true-value/false-value
  1141. mounted: setChecked,
  1142. beforeUpdate(el, binding, vnode) {
  1143. el[assignKey] = getModelAssigner(vnode);
  1144. setChecked(el, binding, vnode);
  1145. }
  1146. };
  1147. function setChecked(el, { value, oldValue }, vnode) {
  1148. el._modelValue = value;
  1149. if (shared.isArray(value)) {
  1150. el.checked = shared.looseIndexOf(value, vnode.props.value) > -1;
  1151. } else if (shared.isSet(value)) {
  1152. el.checked = value.has(vnode.props.value);
  1153. } else if (value !== oldValue) {
  1154. el.checked = shared.looseEqual(value, getCheckboxValue(el, true));
  1155. }
  1156. }
  1157. const vModelRadio = {
  1158. created(el, { value }, vnode) {
  1159. el.checked = shared.looseEqual(value, vnode.props.value);
  1160. el[assignKey] = getModelAssigner(vnode);
  1161. addEventListener(el, "change", () => {
  1162. el[assignKey](getValue(el));
  1163. });
  1164. },
  1165. beforeUpdate(el, { value, oldValue }, vnode) {
  1166. el[assignKey] = getModelAssigner(vnode);
  1167. if (value !== oldValue) {
  1168. el.checked = shared.looseEqual(value, vnode.props.value);
  1169. }
  1170. }
  1171. };
  1172. const vModelSelect = {
  1173. // <select multiple> value need to be deep traversed
  1174. deep: true,
  1175. created(el, { value, modifiers: { number } }, vnode) {
  1176. const isSetModel = shared.isSet(value);
  1177. addEventListener(el, "change", () => {
  1178. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  1179. (o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
  1180. );
  1181. el[assignKey](
  1182. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  1183. );
  1184. });
  1185. el[assignKey] = getModelAssigner(vnode);
  1186. },
  1187. // set value in mounted & updated because <select> relies on its children
  1188. // <option>s.
  1189. mounted(el, { value }) {
  1190. setSelected(el, value);
  1191. },
  1192. beforeUpdate(el, _binding, vnode) {
  1193. el[assignKey] = getModelAssigner(vnode);
  1194. },
  1195. updated(el, { value }) {
  1196. setSelected(el, value);
  1197. }
  1198. };
  1199. function setSelected(el, value) {
  1200. const isMultiple = el.multiple;
  1201. if (isMultiple && !shared.isArray(value) && !shared.isSet(value)) {
  1202. runtimeCore.warn(
  1203. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  1204. );
  1205. return;
  1206. }
  1207. for (let i = 0, l = el.options.length; i < l; i++) {
  1208. const option = el.options[i];
  1209. const optionValue = getValue(option);
  1210. if (isMultiple) {
  1211. if (shared.isArray(value)) {
  1212. option.selected = shared.looseIndexOf(value, optionValue) > -1;
  1213. } else {
  1214. option.selected = value.has(optionValue);
  1215. }
  1216. } else {
  1217. if (shared.looseEqual(getValue(option), value)) {
  1218. if (el.selectedIndex !== i)
  1219. el.selectedIndex = i;
  1220. return;
  1221. }
  1222. }
  1223. }
  1224. if (!isMultiple && el.selectedIndex !== -1) {
  1225. el.selectedIndex = -1;
  1226. }
  1227. }
  1228. function getValue(el) {
  1229. return "_value" in el ? el._value : el.value;
  1230. }
  1231. function getCheckboxValue(el, checked) {
  1232. const key = checked ? "_trueValue" : "_falseValue";
  1233. return key in el ? el[key] : checked;
  1234. }
  1235. const vModelDynamic = {
  1236. created(el, binding, vnode) {
  1237. callModelHook(el, binding, vnode, null, "created");
  1238. },
  1239. mounted(el, binding, vnode) {
  1240. callModelHook(el, binding, vnode, null, "mounted");
  1241. },
  1242. beforeUpdate(el, binding, vnode, prevVNode) {
  1243. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  1244. },
  1245. updated(el, binding, vnode, prevVNode) {
  1246. callModelHook(el, binding, vnode, prevVNode, "updated");
  1247. }
  1248. };
  1249. function resolveDynamicModel(tagName, type) {
  1250. switch (tagName) {
  1251. case "SELECT":
  1252. return vModelSelect;
  1253. case "TEXTAREA":
  1254. return vModelText;
  1255. default:
  1256. switch (type) {
  1257. case "checkbox":
  1258. return vModelCheckbox;
  1259. case "radio":
  1260. return vModelRadio;
  1261. default:
  1262. return vModelText;
  1263. }
  1264. }
  1265. }
  1266. function callModelHook(el, binding, vnode, prevVNode, hook) {
  1267. const modelToUse = resolveDynamicModel(
  1268. el.tagName,
  1269. vnode.props && vnode.props.type
  1270. );
  1271. const fn = modelToUse[hook];
  1272. fn && fn(el, binding, vnode, prevVNode);
  1273. }
  1274. function initVModelForSSR() {
  1275. vModelText.getSSRProps = ({ value }) => ({ value });
  1276. vModelRadio.getSSRProps = ({ value }, vnode) => {
  1277. if (vnode.props && shared.looseEqual(vnode.props.value, value)) {
  1278. return { checked: true };
  1279. }
  1280. };
  1281. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  1282. if (shared.isArray(value)) {
  1283. if (vnode.props && shared.looseIndexOf(value, vnode.props.value) > -1) {
  1284. return { checked: true };
  1285. }
  1286. } else if (shared.isSet(value)) {
  1287. if (vnode.props && value.has(vnode.props.value)) {
  1288. return { checked: true };
  1289. }
  1290. } else if (value) {
  1291. return { checked: true };
  1292. }
  1293. };
  1294. vModelDynamic.getSSRProps = (binding, vnode) => {
  1295. if (typeof vnode.type !== "string") {
  1296. return;
  1297. }
  1298. const modelToUse = resolveDynamicModel(
  1299. // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
  1300. vnode.type.toUpperCase(),
  1301. vnode.props && vnode.props.type
  1302. );
  1303. if (modelToUse.getSSRProps) {
  1304. return modelToUse.getSSRProps(binding, vnode);
  1305. }
  1306. };
  1307. }
  1308. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  1309. const modifierGuards = {
  1310. stop: (e) => e.stopPropagation(),
  1311. prevent: (e) => e.preventDefault(),
  1312. self: (e) => e.target !== e.currentTarget,
  1313. ctrl: (e) => !e.ctrlKey,
  1314. shift: (e) => !e.shiftKey,
  1315. alt: (e) => !e.altKey,
  1316. meta: (e) => !e.metaKey,
  1317. left: (e) => "button" in e && e.button !== 0,
  1318. middle: (e) => "button" in e && e.button !== 1,
  1319. right: (e) => "button" in e && e.button !== 2,
  1320. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  1321. };
  1322. const withModifiers = (fn, modifiers) => {
  1323. return fn._withMods || (fn._withMods = (event, ...args) => {
  1324. for (let i = 0; i < modifiers.length; i++) {
  1325. const guard = modifierGuards[modifiers[i]];
  1326. if (guard && guard(event, modifiers))
  1327. return;
  1328. }
  1329. return fn(event, ...args);
  1330. });
  1331. };
  1332. const keyNames = {
  1333. esc: "escape",
  1334. space: " ",
  1335. up: "arrow-up",
  1336. left: "arrow-left",
  1337. right: "arrow-right",
  1338. down: "arrow-down",
  1339. delete: "backspace"
  1340. };
  1341. const withKeys = (fn, modifiers) => {
  1342. return fn._withKeys || (fn._withKeys = (event) => {
  1343. if (!("key" in event)) {
  1344. return;
  1345. }
  1346. const eventKey = shared.hyphenate(event.key);
  1347. if (modifiers.some((k) => k === eventKey || keyNames[k] === eventKey)) {
  1348. return fn(event);
  1349. }
  1350. });
  1351. };
  1352. const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
  1353. let renderer;
  1354. let enabledHydration = false;
  1355. function ensureRenderer() {
  1356. return renderer || (renderer = runtimeCore.createRenderer(rendererOptions));
  1357. }
  1358. function ensureHydrationRenderer() {
  1359. renderer = enabledHydration ? renderer : runtimeCore.createHydrationRenderer(rendererOptions);
  1360. enabledHydration = true;
  1361. return renderer;
  1362. }
  1363. const render = (...args) => {
  1364. ensureRenderer().render(...args);
  1365. };
  1366. const hydrate = (...args) => {
  1367. ensureHydrationRenderer().hydrate(...args);
  1368. };
  1369. const createApp = (...args) => {
  1370. const app = ensureRenderer().createApp(...args);
  1371. {
  1372. injectNativeTagCheck(app);
  1373. injectCompilerOptionsCheck(app);
  1374. }
  1375. const { mount } = app;
  1376. app.mount = (containerOrSelector) => {
  1377. const container = normalizeContainer(containerOrSelector);
  1378. if (!container)
  1379. return;
  1380. const component = app._component;
  1381. if (!shared.isFunction(component) && !component.render && !component.template) {
  1382. component.template = container.innerHTML;
  1383. }
  1384. container.innerHTML = "";
  1385. const proxy = mount(container, false, container instanceof SVGElement);
  1386. if (container instanceof Element) {
  1387. container.removeAttribute("v-cloak");
  1388. container.setAttribute("data-v-app", "");
  1389. }
  1390. return proxy;
  1391. };
  1392. return app;
  1393. };
  1394. const createSSRApp = (...args) => {
  1395. const app = ensureHydrationRenderer().createApp(...args);
  1396. {
  1397. injectNativeTagCheck(app);
  1398. injectCompilerOptionsCheck(app);
  1399. }
  1400. const { mount } = app;
  1401. app.mount = (containerOrSelector) => {
  1402. const container = normalizeContainer(containerOrSelector);
  1403. if (container) {
  1404. return mount(container, true, container instanceof SVGElement);
  1405. }
  1406. };
  1407. return app;
  1408. };
  1409. function injectNativeTagCheck(app) {
  1410. Object.defineProperty(app.config, "isNativeTag", {
  1411. value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag),
  1412. writable: false
  1413. });
  1414. }
  1415. function injectCompilerOptionsCheck(app) {
  1416. if (runtimeCore.isRuntimeOnly()) {
  1417. const isCustomElement = app.config.isCustomElement;
  1418. Object.defineProperty(app.config, "isCustomElement", {
  1419. get() {
  1420. return isCustomElement;
  1421. },
  1422. set() {
  1423. runtimeCore.warn(
  1424. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  1425. );
  1426. }
  1427. });
  1428. const compilerOptions = app.config.compilerOptions;
  1429. const msg = `The \`compilerOptions\` config option is only respected when using a build of Vue.js that includes the runtime compiler (aka "full build"). Since you are using the runtime-only build, \`compilerOptions\` must be passed to \`@vue/compiler-dom\` in the build setup instead.
  1430. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  1431. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  1432. - For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite-plugin-vue/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-sfc`;
  1433. Object.defineProperty(app.config, "compilerOptions", {
  1434. get() {
  1435. runtimeCore.warn(msg);
  1436. return compilerOptions;
  1437. },
  1438. set() {
  1439. runtimeCore.warn(msg);
  1440. }
  1441. });
  1442. }
  1443. }
  1444. function normalizeContainer(container) {
  1445. if (shared.isString(container)) {
  1446. const res = document.querySelector(container);
  1447. if (!res) {
  1448. runtimeCore.warn(
  1449. `Failed to mount app: mount target selector "${container}" returned null.`
  1450. );
  1451. }
  1452. return res;
  1453. }
  1454. if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  1455. runtimeCore.warn(
  1456. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  1457. );
  1458. }
  1459. return container;
  1460. }
  1461. let ssrDirectiveInitialized = false;
  1462. const initDirectivesForSSR = () => {
  1463. if (!ssrDirectiveInitialized) {
  1464. ssrDirectiveInitialized = true;
  1465. initVModelForSSR();
  1466. initVShowForSSR();
  1467. }
  1468. } ;
  1469. exports.Transition = Transition;
  1470. exports.TransitionGroup = TransitionGroup;
  1471. exports.VueElement = VueElement;
  1472. exports.createApp = createApp;
  1473. exports.createSSRApp = createSSRApp;
  1474. exports.defineCustomElement = defineCustomElement;
  1475. exports.defineSSRCustomElement = defineSSRCustomElement;
  1476. exports.hydrate = hydrate;
  1477. exports.initDirectivesForSSR = initDirectivesForSSR;
  1478. exports.render = render;
  1479. exports.useCssModule = useCssModule;
  1480. exports.useCssVars = useCssVars;
  1481. exports.vModelCheckbox = vModelCheckbox;
  1482. exports.vModelDynamic = vModelDynamic;
  1483. exports.vModelRadio = vModelRadio;
  1484. exports.vModelSelect = vModelSelect;
  1485. exports.vModelText = vModelText;
  1486. exports.vShow = vShow;
  1487. exports.withKeys = withKeys;
  1488. exports.withModifiers = withModifiers;
  1489. Object.keys(runtimeCore).forEach(function (k) {
  1490. if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = runtimeCore[k];
  1491. });