runtime-dom.cjs.js 54 KB

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