Node-Red configuration
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runtime-dom.cjs.js 47KB

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