runtime-dom.esm-bundler.js 61 KB

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