runtime-dom.cjs.js 54 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829
  1. /**
  2. * @vue/runtime-dom v3.5.18
  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((def) => {
  915. def.configureApp = this._def.configureApp;
  916. resolve(this._def = def, true);
  917. });
  918. } else {
  919. resolve(this._def);
  920. }
  921. }
  922. _mount(def) {
  923. if (!def.name) {
  924. def.name = "VueElement";
  925. }
  926. this._app = this._createApp(def);
  927. this._inheritParentContext();
  928. if (def.configureApp) {
  929. def.configureApp(this._app);
  930. }
  931. this._app._ceVNode = this._createVNode();
  932. this._app.mount(this._root);
  933. const exposed = this._instance && this._instance.exposed;
  934. if (!exposed) return;
  935. for (const key in exposed) {
  936. if (!shared.hasOwn(this, key)) {
  937. Object.defineProperty(this, key, {
  938. // unwrap ref to be consistent with public instance behavior
  939. get: () => runtimeCore.unref(exposed[key])
  940. });
  941. } else {
  942. runtimeCore.warn(`Exposed property "${key}" already exists on custom element.`);
  943. }
  944. }
  945. }
  946. _resolveProps(def) {
  947. const { props } = def;
  948. const declaredPropKeys = shared.isArray(props) ? props : Object.keys(props || {});
  949. for (const key of Object.keys(this)) {
  950. if (key[0] !== "_" && declaredPropKeys.includes(key)) {
  951. this._setProp(key, this[key]);
  952. }
  953. }
  954. for (const key of declaredPropKeys.map(shared.camelize)) {
  955. Object.defineProperty(this, key, {
  956. get() {
  957. return this._getProp(key);
  958. },
  959. set(val) {
  960. this._setProp(key, val, true, true);
  961. }
  962. });
  963. }
  964. }
  965. _setAttr(key) {
  966. if (key.startsWith("data-v-")) return;
  967. const has = this.hasAttribute(key);
  968. let value = has ? this.getAttribute(key) : REMOVAL;
  969. const camelKey = shared.camelize(key);
  970. if (has && this._numberProps && this._numberProps[camelKey]) {
  971. value = shared.toNumber(value);
  972. }
  973. this._setProp(camelKey, value, false, true);
  974. }
  975. /**
  976. * @internal
  977. */
  978. _getProp(key) {
  979. return this._props[key];
  980. }
  981. /**
  982. * @internal
  983. */
  984. _setProp(key, val, shouldReflect = true, shouldUpdate = false) {
  985. if (val !== this._props[key]) {
  986. if (val === REMOVAL) {
  987. delete this._props[key];
  988. } else {
  989. this._props[key] = val;
  990. if (key === "key" && this._app) {
  991. this._app._ceVNode.key = val;
  992. }
  993. }
  994. if (shouldUpdate && this._instance) {
  995. this._update();
  996. }
  997. if (shouldReflect) {
  998. const ob = this._ob;
  999. ob && ob.disconnect();
  1000. if (val === true) {
  1001. this.setAttribute(shared.hyphenate(key), "");
  1002. } else if (typeof val === "string" || typeof val === "number") {
  1003. this.setAttribute(shared.hyphenate(key), val + "");
  1004. } else if (!val) {
  1005. this.removeAttribute(shared.hyphenate(key));
  1006. }
  1007. ob && ob.observe(this, { attributes: true });
  1008. }
  1009. }
  1010. }
  1011. _update() {
  1012. const vnode = this._createVNode();
  1013. if (this._app) vnode.appContext = this._app._context;
  1014. render(vnode, this._root);
  1015. }
  1016. _createVNode() {
  1017. const baseProps = {};
  1018. if (!this.shadowRoot) {
  1019. baseProps.onVnodeMounted = baseProps.onVnodeUpdated = this._renderSlots.bind(this);
  1020. }
  1021. const vnode = runtimeCore.createVNode(this._def, shared.extend(baseProps, this._props));
  1022. if (!this._instance) {
  1023. vnode.ce = (instance) => {
  1024. this._instance = instance;
  1025. instance.ce = this;
  1026. instance.isCE = true;
  1027. {
  1028. instance.ceReload = (newStyles) => {
  1029. if (this._styles) {
  1030. this._styles.forEach((s) => this._root.removeChild(s));
  1031. this._styles.length = 0;
  1032. }
  1033. this._applyStyles(newStyles);
  1034. this._instance = null;
  1035. this._update();
  1036. };
  1037. }
  1038. const dispatch = (event, args) => {
  1039. this.dispatchEvent(
  1040. new CustomEvent(
  1041. event,
  1042. shared.isPlainObject(args[0]) ? shared.extend({ detail: args }, args[0]) : { detail: args }
  1043. )
  1044. );
  1045. };
  1046. instance.emit = (event, ...args) => {
  1047. dispatch(event, args);
  1048. if (shared.hyphenate(event) !== event) {
  1049. dispatch(shared.hyphenate(event), args);
  1050. }
  1051. };
  1052. this._setParent();
  1053. };
  1054. }
  1055. return vnode;
  1056. }
  1057. _applyStyles(styles, owner) {
  1058. if (!styles) return;
  1059. if (owner) {
  1060. if (owner === this._def || this._styleChildren.has(owner)) {
  1061. return;
  1062. }
  1063. this._styleChildren.add(owner);
  1064. }
  1065. const nonce = this._nonce;
  1066. for (let i = styles.length - 1; i >= 0; i--) {
  1067. const s = document.createElement("style");
  1068. if (nonce) s.setAttribute("nonce", nonce);
  1069. s.textContent = styles[i];
  1070. this.shadowRoot.prepend(s);
  1071. {
  1072. if (owner) {
  1073. if (owner.__hmrId) {
  1074. if (!this._childStyles) this._childStyles = /* @__PURE__ */ new Map();
  1075. let entry = this._childStyles.get(owner.__hmrId);
  1076. if (!entry) {
  1077. this._childStyles.set(owner.__hmrId, entry = []);
  1078. }
  1079. entry.push(s);
  1080. }
  1081. } else {
  1082. (this._styles || (this._styles = [])).push(s);
  1083. }
  1084. }
  1085. }
  1086. }
  1087. /**
  1088. * Only called when shadowRoot is false
  1089. */
  1090. _parseSlots() {
  1091. const slots = this._slots = {};
  1092. let n;
  1093. while (n = this.firstChild) {
  1094. const slotName = n.nodeType === 1 && n.getAttribute("slot") || "default";
  1095. (slots[slotName] || (slots[slotName] = [])).push(n);
  1096. this.removeChild(n);
  1097. }
  1098. }
  1099. /**
  1100. * Only called when shadowRoot is false
  1101. */
  1102. _renderSlots() {
  1103. const outlets = (this._teleportTarget || this).querySelectorAll("slot");
  1104. const scopeId = this._instance.type.__scopeId;
  1105. for (let i = 0; i < outlets.length; i++) {
  1106. const o = outlets[i];
  1107. const slotName = o.getAttribute("name") || "default";
  1108. const content = this._slots[slotName];
  1109. const parent = o.parentNode;
  1110. if (content) {
  1111. for (const n of content) {
  1112. if (scopeId && n.nodeType === 1) {
  1113. const id = scopeId + "-s";
  1114. const walker = document.createTreeWalker(n, 1);
  1115. n.setAttribute(id, "");
  1116. let child;
  1117. while (child = walker.nextNode()) {
  1118. child.setAttribute(id, "");
  1119. }
  1120. }
  1121. parent.insertBefore(n, o);
  1122. }
  1123. } else {
  1124. while (o.firstChild) parent.insertBefore(o.firstChild, o);
  1125. }
  1126. parent.removeChild(o);
  1127. }
  1128. }
  1129. /**
  1130. * @internal
  1131. */
  1132. _injectChildStyle(comp) {
  1133. this._applyStyles(comp.styles, comp);
  1134. }
  1135. /**
  1136. * @internal
  1137. */
  1138. _removeChildStyle(comp) {
  1139. {
  1140. this._styleChildren.delete(comp);
  1141. if (this._childStyles && comp.__hmrId) {
  1142. const oldStyles = this._childStyles.get(comp.__hmrId);
  1143. if (oldStyles) {
  1144. oldStyles.forEach((s) => this._root.removeChild(s));
  1145. oldStyles.length = 0;
  1146. }
  1147. }
  1148. }
  1149. }
  1150. }
  1151. function useHost(caller) {
  1152. const instance = runtimeCore.getCurrentInstance();
  1153. const el = instance && instance.ce;
  1154. if (el) {
  1155. return el;
  1156. } else {
  1157. if (!instance) {
  1158. runtimeCore.warn(
  1159. `${caller || "useHost"} called without an active component instance.`
  1160. );
  1161. } else {
  1162. runtimeCore.warn(
  1163. `${caller || "useHost"} can only be used in components defined via defineCustomElement.`
  1164. );
  1165. }
  1166. }
  1167. return null;
  1168. }
  1169. function useShadowRoot() {
  1170. const el = useHost("useShadowRoot") ;
  1171. return el && el.shadowRoot;
  1172. }
  1173. function useCssModule(name = "$style") {
  1174. {
  1175. const instance = runtimeCore.getCurrentInstance();
  1176. if (!instance) {
  1177. runtimeCore.warn(`useCssModule must be called inside setup()`);
  1178. return shared.EMPTY_OBJ;
  1179. }
  1180. const modules = instance.type.__cssModules;
  1181. if (!modules) {
  1182. runtimeCore.warn(`Current instance does not have CSS modules injected.`);
  1183. return shared.EMPTY_OBJ;
  1184. }
  1185. const mod = modules[name];
  1186. if (!mod) {
  1187. runtimeCore.warn(`Current instance does not have CSS module named "${name}".`);
  1188. return shared.EMPTY_OBJ;
  1189. }
  1190. return mod;
  1191. }
  1192. }
  1193. const positionMap = /* @__PURE__ */ new WeakMap();
  1194. const newPositionMap = /* @__PURE__ */ new WeakMap();
  1195. const moveCbKey = Symbol("_moveCb");
  1196. const enterCbKey = Symbol("_enterCb");
  1197. const decorate = (t) => {
  1198. delete t.props.mode;
  1199. return t;
  1200. };
  1201. const TransitionGroupImpl = /* @__PURE__ */ decorate({
  1202. name: "TransitionGroup",
  1203. props: /* @__PURE__ */ shared.extend({}, TransitionPropsValidators, {
  1204. tag: String,
  1205. moveClass: String
  1206. }),
  1207. setup(props, { slots }) {
  1208. const instance = runtimeCore.getCurrentInstance();
  1209. const state = runtimeCore.useTransitionState();
  1210. let prevChildren;
  1211. let children;
  1212. runtimeCore.onUpdated(() => {
  1213. if (!prevChildren.length) {
  1214. return;
  1215. }
  1216. const moveClass = props.moveClass || `${props.name || "v"}-move`;
  1217. if (!hasCSSTransform(
  1218. prevChildren[0].el,
  1219. instance.vnode.el,
  1220. moveClass
  1221. )) {
  1222. prevChildren = [];
  1223. return;
  1224. }
  1225. prevChildren.forEach(callPendingCbs);
  1226. prevChildren.forEach(recordPosition);
  1227. const movedChildren = prevChildren.filter(applyTranslation);
  1228. forceReflow();
  1229. movedChildren.forEach((c) => {
  1230. const el = c.el;
  1231. const style = el.style;
  1232. addTransitionClass(el, moveClass);
  1233. style.transform = style.webkitTransform = style.transitionDuration = "";
  1234. const cb = el[moveCbKey] = (e) => {
  1235. if (e && e.target !== el) {
  1236. return;
  1237. }
  1238. if (!e || /transform$/.test(e.propertyName)) {
  1239. el.removeEventListener("transitionend", cb);
  1240. el[moveCbKey] = null;
  1241. removeTransitionClass(el, moveClass);
  1242. }
  1243. };
  1244. el.addEventListener("transitionend", cb);
  1245. });
  1246. prevChildren = [];
  1247. });
  1248. return () => {
  1249. const rawProps = runtimeCore.toRaw(props);
  1250. const cssTransitionProps = resolveTransitionProps(rawProps);
  1251. let tag = rawProps.tag || runtimeCore.Fragment;
  1252. prevChildren = [];
  1253. if (children) {
  1254. for (let i = 0; i < children.length; i++) {
  1255. const child = children[i];
  1256. if (child.el && child.el instanceof Element) {
  1257. prevChildren.push(child);
  1258. runtimeCore.setTransitionHooks(
  1259. child,
  1260. runtimeCore.resolveTransitionHooks(
  1261. child,
  1262. cssTransitionProps,
  1263. state,
  1264. instance
  1265. )
  1266. );
  1267. positionMap.set(
  1268. child,
  1269. child.el.getBoundingClientRect()
  1270. );
  1271. }
  1272. }
  1273. }
  1274. children = slots.default ? runtimeCore.getTransitionRawChildren(slots.default()) : [];
  1275. for (let i = 0; i < children.length; i++) {
  1276. const child = children[i];
  1277. if (child.key != null) {
  1278. runtimeCore.setTransitionHooks(
  1279. child,
  1280. runtimeCore.resolveTransitionHooks(child, cssTransitionProps, state, instance)
  1281. );
  1282. } else if (child.type !== runtimeCore.Text) {
  1283. runtimeCore.warn(`<TransitionGroup> children must be keyed.`);
  1284. }
  1285. }
  1286. return runtimeCore.createVNode(tag, null, children);
  1287. };
  1288. }
  1289. });
  1290. const TransitionGroup = TransitionGroupImpl;
  1291. function callPendingCbs(c) {
  1292. const el = c.el;
  1293. if (el[moveCbKey]) {
  1294. el[moveCbKey]();
  1295. }
  1296. if (el[enterCbKey]) {
  1297. el[enterCbKey]();
  1298. }
  1299. }
  1300. function recordPosition(c) {
  1301. newPositionMap.set(c, c.el.getBoundingClientRect());
  1302. }
  1303. function applyTranslation(c) {
  1304. const oldPos = positionMap.get(c);
  1305. const newPos = newPositionMap.get(c);
  1306. const dx = oldPos.left - newPos.left;
  1307. const dy = oldPos.top - newPos.top;
  1308. if (dx || dy) {
  1309. const s = c.el.style;
  1310. s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
  1311. s.transitionDuration = "0s";
  1312. return c;
  1313. }
  1314. }
  1315. function hasCSSTransform(el, root, moveClass) {
  1316. const clone = el.cloneNode();
  1317. const _vtc = el[vtcKey];
  1318. if (_vtc) {
  1319. _vtc.forEach((cls) => {
  1320. cls.split(/\s+/).forEach((c) => c && clone.classList.remove(c));
  1321. });
  1322. }
  1323. moveClass.split(/\s+/).forEach((c) => c && clone.classList.add(c));
  1324. clone.style.display = "none";
  1325. const container = root.nodeType === 1 ? root : root.parentNode;
  1326. container.appendChild(clone);
  1327. const { hasTransform } = getTransitionInfo(clone);
  1328. container.removeChild(clone);
  1329. return hasTransform;
  1330. }
  1331. const getModelAssigner = (vnode) => {
  1332. const fn = vnode.props["onUpdate:modelValue"] || false;
  1333. return shared.isArray(fn) ? (value) => shared.invokeArrayFns(fn, value) : fn;
  1334. };
  1335. function onCompositionStart(e) {
  1336. e.target.composing = true;
  1337. }
  1338. function onCompositionEnd(e) {
  1339. const target = e.target;
  1340. if (target.composing) {
  1341. target.composing = false;
  1342. target.dispatchEvent(new Event("input"));
  1343. }
  1344. }
  1345. const assignKey = Symbol("_assign");
  1346. const vModelText = {
  1347. created(el, { modifiers: { lazy, trim, number } }, vnode) {
  1348. el[assignKey] = getModelAssigner(vnode);
  1349. const castToNumber = number || vnode.props && vnode.props.type === "number";
  1350. addEventListener(el, lazy ? "change" : "input", (e) => {
  1351. if (e.target.composing) return;
  1352. let domValue = el.value;
  1353. if (trim) {
  1354. domValue = domValue.trim();
  1355. }
  1356. if (castToNumber) {
  1357. domValue = shared.looseToNumber(domValue);
  1358. }
  1359. el[assignKey](domValue);
  1360. });
  1361. if (trim) {
  1362. addEventListener(el, "change", () => {
  1363. el.value = el.value.trim();
  1364. });
  1365. }
  1366. if (!lazy) {
  1367. addEventListener(el, "compositionstart", onCompositionStart);
  1368. addEventListener(el, "compositionend", onCompositionEnd);
  1369. addEventListener(el, "change", onCompositionEnd);
  1370. }
  1371. },
  1372. // set value on mounted so it's after min/max for type="range"
  1373. mounted(el, { value }) {
  1374. el.value = value == null ? "" : value;
  1375. },
  1376. beforeUpdate(el, { value, oldValue, modifiers: { lazy, trim, number } }, vnode) {
  1377. el[assignKey] = getModelAssigner(vnode);
  1378. if (el.composing) return;
  1379. const elValue = (number || el.type === "number") && !/^0\d/.test(el.value) ? shared.looseToNumber(el.value) : el.value;
  1380. const newValue = value == null ? "" : value;
  1381. if (elValue === newValue) {
  1382. return;
  1383. }
  1384. if (document.activeElement === el && el.type !== "range") {
  1385. if (lazy && value === oldValue) {
  1386. return;
  1387. }
  1388. if (trim && el.value.trim() === newValue) {
  1389. return;
  1390. }
  1391. }
  1392. el.value = newValue;
  1393. }
  1394. };
  1395. const vModelCheckbox = {
  1396. // #4096 array checkboxes need to be deep traversed
  1397. deep: true,
  1398. created(el, _, vnode) {
  1399. el[assignKey] = getModelAssigner(vnode);
  1400. addEventListener(el, "change", () => {
  1401. const modelValue = el._modelValue;
  1402. const elementValue = getValue(el);
  1403. const checked = el.checked;
  1404. const assign = el[assignKey];
  1405. if (shared.isArray(modelValue)) {
  1406. const index = shared.looseIndexOf(modelValue, elementValue);
  1407. const found = index !== -1;
  1408. if (checked && !found) {
  1409. assign(modelValue.concat(elementValue));
  1410. } else if (!checked && found) {
  1411. const filtered = [...modelValue];
  1412. filtered.splice(index, 1);
  1413. assign(filtered);
  1414. }
  1415. } else if (shared.isSet(modelValue)) {
  1416. const cloned = new Set(modelValue);
  1417. if (checked) {
  1418. cloned.add(elementValue);
  1419. } else {
  1420. cloned.delete(elementValue);
  1421. }
  1422. assign(cloned);
  1423. } else {
  1424. assign(getCheckboxValue(el, checked));
  1425. }
  1426. });
  1427. },
  1428. // set initial checked on mount to wait for true-value/false-value
  1429. mounted: setChecked,
  1430. beforeUpdate(el, binding, vnode) {
  1431. el[assignKey] = getModelAssigner(vnode);
  1432. setChecked(el, binding, vnode);
  1433. }
  1434. };
  1435. function setChecked(el, { value, oldValue }, vnode) {
  1436. el._modelValue = value;
  1437. let checked;
  1438. if (shared.isArray(value)) {
  1439. checked = shared.looseIndexOf(value, vnode.props.value) > -1;
  1440. } else if (shared.isSet(value)) {
  1441. checked = value.has(vnode.props.value);
  1442. } else {
  1443. if (value === oldValue) return;
  1444. checked = shared.looseEqual(value, getCheckboxValue(el, true));
  1445. }
  1446. if (el.checked !== checked) {
  1447. el.checked = checked;
  1448. }
  1449. }
  1450. const vModelRadio = {
  1451. created(el, { value }, vnode) {
  1452. el.checked = shared.looseEqual(value, vnode.props.value);
  1453. el[assignKey] = getModelAssigner(vnode);
  1454. addEventListener(el, "change", () => {
  1455. el[assignKey](getValue(el));
  1456. });
  1457. },
  1458. beforeUpdate(el, { value, oldValue }, vnode) {
  1459. el[assignKey] = getModelAssigner(vnode);
  1460. if (value !== oldValue) {
  1461. el.checked = shared.looseEqual(value, vnode.props.value);
  1462. }
  1463. }
  1464. };
  1465. const vModelSelect = {
  1466. // <select multiple> value need to be deep traversed
  1467. deep: true,
  1468. created(el, { value, modifiers: { number } }, vnode) {
  1469. const isSetModel = shared.isSet(value);
  1470. addEventListener(el, "change", () => {
  1471. const selectedVal = Array.prototype.filter.call(el.options, (o) => o.selected).map(
  1472. (o) => number ? shared.looseToNumber(getValue(o)) : getValue(o)
  1473. );
  1474. el[assignKey](
  1475. el.multiple ? isSetModel ? new Set(selectedVal) : selectedVal : selectedVal[0]
  1476. );
  1477. el._assigning = true;
  1478. runtimeCore.nextTick(() => {
  1479. el._assigning = false;
  1480. });
  1481. });
  1482. el[assignKey] = getModelAssigner(vnode);
  1483. },
  1484. // set value in mounted & updated because <select> relies on its children
  1485. // <option>s.
  1486. mounted(el, { value }) {
  1487. setSelected(el, value);
  1488. },
  1489. beforeUpdate(el, _binding, vnode) {
  1490. el[assignKey] = getModelAssigner(vnode);
  1491. },
  1492. updated(el, { value }) {
  1493. if (!el._assigning) {
  1494. setSelected(el, value);
  1495. }
  1496. }
  1497. };
  1498. function setSelected(el, value) {
  1499. const isMultiple = el.multiple;
  1500. const isArrayValue = shared.isArray(value);
  1501. if (isMultiple && !isArrayValue && !shared.isSet(value)) {
  1502. runtimeCore.warn(
  1503. `<select multiple v-model> expects an Array or Set value for its binding, but got ${Object.prototype.toString.call(value).slice(8, -1)}.`
  1504. );
  1505. return;
  1506. }
  1507. for (let i = 0, l = el.options.length; i < l; i++) {
  1508. const option = el.options[i];
  1509. const optionValue = getValue(option);
  1510. if (isMultiple) {
  1511. if (isArrayValue) {
  1512. const optionType = typeof optionValue;
  1513. if (optionType === "string" || optionType === "number") {
  1514. option.selected = value.some((v) => String(v) === String(optionValue));
  1515. } else {
  1516. option.selected = shared.looseIndexOf(value, optionValue) > -1;
  1517. }
  1518. } else {
  1519. option.selected = value.has(optionValue);
  1520. }
  1521. } else if (shared.looseEqual(getValue(option), value)) {
  1522. if (el.selectedIndex !== i) el.selectedIndex = i;
  1523. return;
  1524. }
  1525. }
  1526. if (!isMultiple && el.selectedIndex !== -1) {
  1527. el.selectedIndex = -1;
  1528. }
  1529. }
  1530. function getValue(el) {
  1531. return "_value" in el ? el._value : el.value;
  1532. }
  1533. function getCheckboxValue(el, checked) {
  1534. const key = checked ? "_trueValue" : "_falseValue";
  1535. return key in el ? el[key] : checked;
  1536. }
  1537. const vModelDynamic = {
  1538. created(el, binding, vnode) {
  1539. callModelHook(el, binding, vnode, null, "created");
  1540. },
  1541. mounted(el, binding, vnode) {
  1542. callModelHook(el, binding, vnode, null, "mounted");
  1543. },
  1544. beforeUpdate(el, binding, vnode, prevVNode) {
  1545. callModelHook(el, binding, vnode, prevVNode, "beforeUpdate");
  1546. },
  1547. updated(el, binding, vnode, prevVNode) {
  1548. callModelHook(el, binding, vnode, prevVNode, "updated");
  1549. }
  1550. };
  1551. function resolveDynamicModel(tagName, type) {
  1552. switch (tagName) {
  1553. case "SELECT":
  1554. return vModelSelect;
  1555. case "TEXTAREA":
  1556. return vModelText;
  1557. default:
  1558. switch (type) {
  1559. case "checkbox":
  1560. return vModelCheckbox;
  1561. case "radio":
  1562. return vModelRadio;
  1563. default:
  1564. return vModelText;
  1565. }
  1566. }
  1567. }
  1568. function callModelHook(el, binding, vnode, prevVNode, hook) {
  1569. const modelToUse = resolveDynamicModel(
  1570. el.tagName,
  1571. vnode.props && vnode.props.type
  1572. );
  1573. const fn = modelToUse[hook];
  1574. fn && fn(el, binding, vnode, prevVNode);
  1575. }
  1576. function initVModelForSSR() {
  1577. vModelText.getSSRProps = ({ value }) => ({ value });
  1578. vModelRadio.getSSRProps = ({ value }, vnode) => {
  1579. if (vnode.props && shared.looseEqual(vnode.props.value, value)) {
  1580. return { checked: true };
  1581. }
  1582. };
  1583. vModelCheckbox.getSSRProps = ({ value }, vnode) => {
  1584. if (shared.isArray(value)) {
  1585. if (vnode.props && shared.looseIndexOf(value, vnode.props.value) > -1) {
  1586. return { checked: true };
  1587. }
  1588. } else if (shared.isSet(value)) {
  1589. if (vnode.props && value.has(vnode.props.value)) {
  1590. return { checked: true };
  1591. }
  1592. } else if (value) {
  1593. return { checked: true };
  1594. }
  1595. };
  1596. vModelDynamic.getSSRProps = (binding, vnode) => {
  1597. if (typeof vnode.type !== "string") {
  1598. return;
  1599. }
  1600. const modelToUse = resolveDynamicModel(
  1601. // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
  1602. vnode.type.toUpperCase(),
  1603. vnode.props && vnode.props.type
  1604. );
  1605. if (modelToUse.getSSRProps) {
  1606. return modelToUse.getSSRProps(binding, vnode);
  1607. }
  1608. };
  1609. }
  1610. const systemModifiers = ["ctrl", "shift", "alt", "meta"];
  1611. const modifierGuards = {
  1612. stop: (e) => e.stopPropagation(),
  1613. prevent: (e) => e.preventDefault(),
  1614. self: (e) => e.target !== e.currentTarget,
  1615. ctrl: (e) => !e.ctrlKey,
  1616. shift: (e) => !e.shiftKey,
  1617. alt: (e) => !e.altKey,
  1618. meta: (e) => !e.metaKey,
  1619. left: (e) => "button" in e && e.button !== 0,
  1620. middle: (e) => "button" in e && e.button !== 1,
  1621. right: (e) => "button" in e && e.button !== 2,
  1622. exact: (e, modifiers) => systemModifiers.some((m) => e[`${m}Key`] && !modifiers.includes(m))
  1623. };
  1624. const withModifiers = (fn, modifiers) => {
  1625. const cache = fn._withMods || (fn._withMods = {});
  1626. const cacheKey = modifiers.join(".");
  1627. return cache[cacheKey] || (cache[cacheKey] = (event, ...args) => {
  1628. for (let i = 0; i < modifiers.length; i++) {
  1629. const guard = modifierGuards[modifiers[i]];
  1630. if (guard && guard(event, modifiers)) return;
  1631. }
  1632. return fn(event, ...args);
  1633. });
  1634. };
  1635. const keyNames = {
  1636. esc: "escape",
  1637. space: " ",
  1638. up: "arrow-up",
  1639. left: "arrow-left",
  1640. right: "arrow-right",
  1641. down: "arrow-down",
  1642. delete: "backspace"
  1643. };
  1644. const withKeys = (fn, modifiers) => {
  1645. const cache = fn._withKeys || (fn._withKeys = {});
  1646. const cacheKey = modifiers.join(".");
  1647. return cache[cacheKey] || (cache[cacheKey] = (event) => {
  1648. if (!("key" in event)) {
  1649. return;
  1650. }
  1651. const eventKey = shared.hyphenate(event.key);
  1652. if (modifiers.some(
  1653. (k) => k === eventKey || keyNames[k] === eventKey
  1654. )) {
  1655. return fn(event);
  1656. }
  1657. });
  1658. };
  1659. const rendererOptions = /* @__PURE__ */ shared.extend({ patchProp }, nodeOps);
  1660. let renderer;
  1661. let enabledHydration = false;
  1662. function ensureRenderer() {
  1663. return renderer || (renderer = runtimeCore.createRenderer(rendererOptions));
  1664. }
  1665. function ensureHydrationRenderer() {
  1666. renderer = enabledHydration ? renderer : runtimeCore.createHydrationRenderer(rendererOptions);
  1667. enabledHydration = true;
  1668. return renderer;
  1669. }
  1670. const render = (...args) => {
  1671. ensureRenderer().render(...args);
  1672. };
  1673. const hydrate = (...args) => {
  1674. ensureHydrationRenderer().hydrate(...args);
  1675. };
  1676. const createApp = (...args) => {
  1677. const app = ensureRenderer().createApp(...args);
  1678. {
  1679. injectNativeTagCheck(app);
  1680. injectCompilerOptionsCheck(app);
  1681. }
  1682. const { mount } = app;
  1683. app.mount = (containerOrSelector) => {
  1684. const container = normalizeContainer(containerOrSelector);
  1685. if (!container) return;
  1686. const component = app._component;
  1687. if (!shared.isFunction(component) && !component.render && !component.template) {
  1688. component.template = container.innerHTML;
  1689. }
  1690. if (container.nodeType === 1) {
  1691. container.textContent = "";
  1692. }
  1693. const proxy = mount(container, false, resolveRootNamespace(container));
  1694. if (container instanceof Element) {
  1695. container.removeAttribute("v-cloak");
  1696. container.setAttribute("data-v-app", "");
  1697. }
  1698. return proxy;
  1699. };
  1700. return app;
  1701. };
  1702. const createSSRApp = (...args) => {
  1703. const app = ensureHydrationRenderer().createApp(...args);
  1704. {
  1705. injectNativeTagCheck(app);
  1706. injectCompilerOptionsCheck(app);
  1707. }
  1708. const { mount } = app;
  1709. app.mount = (containerOrSelector) => {
  1710. const container = normalizeContainer(containerOrSelector);
  1711. if (container) {
  1712. return mount(container, true, resolveRootNamespace(container));
  1713. }
  1714. };
  1715. return app;
  1716. };
  1717. function resolveRootNamespace(container) {
  1718. if (container instanceof SVGElement) {
  1719. return "svg";
  1720. }
  1721. if (typeof MathMLElement === "function" && container instanceof MathMLElement) {
  1722. return "mathml";
  1723. }
  1724. }
  1725. function injectNativeTagCheck(app) {
  1726. Object.defineProperty(app.config, "isNativeTag", {
  1727. value: (tag) => shared.isHTMLTag(tag) || shared.isSVGTag(tag) || shared.isMathMLTag(tag),
  1728. writable: false
  1729. });
  1730. }
  1731. function injectCompilerOptionsCheck(app) {
  1732. if (runtimeCore.isRuntimeOnly()) {
  1733. const isCustomElement = app.config.isCustomElement;
  1734. Object.defineProperty(app.config, "isCustomElement", {
  1735. get() {
  1736. return isCustomElement;
  1737. },
  1738. set() {
  1739. runtimeCore.warn(
  1740. `The \`isCustomElement\` config option is deprecated. Use \`compilerOptions.isCustomElement\` instead.`
  1741. );
  1742. }
  1743. });
  1744. const compilerOptions = app.config.compilerOptions;
  1745. 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.
  1746. - For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.
  1747. - For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader
  1748. - 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`;
  1749. Object.defineProperty(app.config, "compilerOptions", {
  1750. get() {
  1751. runtimeCore.warn(msg);
  1752. return compilerOptions;
  1753. },
  1754. set() {
  1755. runtimeCore.warn(msg);
  1756. }
  1757. });
  1758. }
  1759. }
  1760. function normalizeContainer(container) {
  1761. if (shared.isString(container)) {
  1762. const res = document.querySelector(container);
  1763. if (!res) {
  1764. runtimeCore.warn(
  1765. `Failed to mount app: mount target selector "${container}" returned null.`
  1766. );
  1767. }
  1768. return res;
  1769. }
  1770. if (window.ShadowRoot && container instanceof window.ShadowRoot && container.mode === "closed") {
  1771. runtimeCore.warn(
  1772. `mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`
  1773. );
  1774. }
  1775. return container;
  1776. }
  1777. let ssrDirectiveInitialized = false;
  1778. const initDirectivesForSSR = () => {
  1779. if (!ssrDirectiveInitialized) {
  1780. ssrDirectiveInitialized = true;
  1781. initVModelForSSR();
  1782. initVShowForSSR();
  1783. }
  1784. } ;
  1785. exports.Transition = Transition;
  1786. exports.TransitionGroup = TransitionGroup;
  1787. exports.VueElement = VueElement;
  1788. exports.createApp = createApp;
  1789. exports.createSSRApp = createSSRApp;
  1790. exports.defineCustomElement = defineCustomElement;
  1791. exports.defineSSRCustomElement = defineSSRCustomElement;
  1792. exports.hydrate = hydrate;
  1793. exports.initDirectivesForSSR = initDirectivesForSSR;
  1794. exports.render = render;
  1795. exports.useCssModule = useCssModule;
  1796. exports.useCssVars = useCssVars;
  1797. exports.useHost = useHost;
  1798. exports.useShadowRoot = useShadowRoot;
  1799. exports.vModelCheckbox = vModelCheckbox;
  1800. exports.vModelDynamic = vModelDynamic;
  1801. exports.vModelRadio = vModelRadio;
  1802. exports.vModelSelect = vModelSelect;
  1803. exports.vModelText = vModelText;
  1804. exports.vShow = vShow;
  1805. exports.withKeys = withKeys;
  1806. exports.withModifiers = withModifiers;
  1807. Object.keys(runtimeCore).forEach(function (k) {
  1808. if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) exports[k] = runtimeCore[k];
  1809. });