runtime-dom.cjs.js 54 KB

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