runtime-dom.cjs.prod.js 43 KB

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