@nuxt/scripts 1.3.3 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (103) hide show
  1. package/dist/devtools-client/200.html +1 -1
  2. package/dist/devtools-client/404.html +1 -1
  3. package/dist/devtools-client/_nuxt/{DAubxma0.js → 8ltZ0o6d.js} +1 -1
  4. package/dist/devtools-client/_nuxt/{CBuBrHyL.js → B8_EBdhg.js} +1 -1
  5. package/dist/devtools-client/_nuxt/Bf2Kt1P0.js +28 -0
  6. package/dist/devtools-client/_nuxt/CC0GKROJ.js +1 -0
  7. package/dist/devtools-client/_nuxt/{DvC3yV2P.js → CMXzQxJZ.js} +1 -1
  8. package/dist/devtools-client/_nuxt/{xAZ2vgo3.js → CP7c-Js6.js} +4 -4
  9. package/dist/devtools-client/_nuxt/{DzbSCA_w.js → DTP8MRtW.js} +1 -1
  10. package/dist/devtools-client/_nuxt/{DgAtAWdT.js → Dkc7iTdR.js} +1 -1
  11. package/dist/devtools-client/_nuxt/{WOtyQdps.js → KxC4Q3ev.js} +1 -1
  12. package/dist/devtools-client/_nuxt/builds/latest.json +1 -1
  13. package/dist/devtools-client/_nuxt/builds/meta/173480db-0944-415b-962d-d619682f0042.json +1 -0
  14. package/dist/devtools-client/_nuxt/{entry.9HJPJ6Hp.css → entry.CYUdJFoE.css} +1 -1
  15. package/dist/devtools-client/_nuxt/error-404.Bq2JQbJs.css +1 -0
  16. package/dist/devtools-client/_nuxt/error-500.5E_FOzlc.css +1 -0
  17. package/dist/devtools-client/_nuxt/{pages.BF1VnccH.css → pages.aU4WirOM.css} +1 -1
  18. package/dist/devtools-client/docs/index.html +1 -1
  19. package/dist/devtools-client/first-party/index.html +1 -1
  20. package/dist/devtools-client/index.html +1 -1
  21. package/dist/devtools-client/registry/index.html +1 -1
  22. package/dist/module.d.mts +1 -1
  23. package/dist/module.d.ts +1 -1
  24. package/dist/module.json +1 -1
  25. package/dist/module.mjs +270 -47
  26. package/dist/registry.mjs +2 -2
  27. package/dist/runtime/components/GoogleMaps/ScriptGoogleMaps.vue +71 -21
  28. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.d.ts +2 -1
  29. package/dist/runtime/components/GoogleMaps/useGoogleMapsResource.js +39 -25
  30. package/dist/runtime/components/ScriptCarbonAds.vue +11 -3
  31. package/dist/runtime/components/ScriptCrisp.vue +4 -1
  32. package/dist/runtime/components/ScriptIntercom.vue +4 -1
  33. package/dist/runtime/components/ScriptLemonSqueezy.d.vue.ts +13 -13
  34. package/dist/runtime/components/ScriptLemonSqueezy.vue +30 -6
  35. package/dist/runtime/components/ScriptLemonSqueezy.vue.d.ts +13 -13
  36. package/dist/runtime/components/ScriptPayPalButtons.vue +8 -1
  37. package/dist/runtime/components/ScriptPayPalMessages.vue +6 -0
  38. package/dist/runtime/components/ScriptStripePricingTable.vue +2 -0
  39. package/dist/runtime/components/ScriptVimeoPlayer.vue +8 -1
  40. package/dist/runtime/composables/useScript.js +121 -44
  41. package/dist/runtime/composables/useScriptEventPage.js +36 -20
  42. package/dist/runtime/composables/useScriptTriggerIdleTimeout.js +19 -5
  43. package/dist/runtime/composables/useScriptTriggerInteraction.js +23 -10
  44. package/dist/runtime/composables/useScriptTriggerServiceWorker.js +21 -18
  45. package/dist/runtime/devtools-standalone-bridge.client.js +28 -3
  46. package/dist/runtime/npm-script-proxy.d.ts +7 -0
  47. package/dist/runtime/npm-script-proxy.js +46 -0
  48. package/dist/runtime/npm-script-stub.js +4 -5
  49. package/dist/runtime/registry/posthog.js +11 -3
  50. package/dist/runtime/registry/speedcurve.js +33 -4
  51. package/dist/runtime/registry/usercentrics.js +4 -21
  52. package/dist/runtime/registry/youtube-player.js +16 -5
  53. package/dist/runtime/server/bluesky-embed.js +15 -6
  54. package/dist/runtime/server/google-maps-geocode-proxy.js +10 -5
  55. package/dist/runtime/server/google-static-maps-proxy.js +20 -13
  56. package/dist/runtime/server/gravatar-proxy.js +48 -11
  57. package/dist/runtime/server/instagram-embed-asset.js +1 -1
  58. package/dist/runtime/server/instagram-embed.js +44 -94
  59. package/dist/runtime/server/proxy-handler.d.ts +2 -1
  60. package/dist/runtime/server/proxy-handler.js +183 -23
  61. package/dist/runtime/server/utils/cache-config.d.ts +14 -0
  62. package/dist/runtime/server/utils/cache-config.js +13 -0
  63. package/dist/runtime/server/utils/cached-upstream.d.ts +23 -2
  64. package/dist/runtime/server/utils/cached-upstream.js +212 -15
  65. package/dist/runtime/server/utils/image-proxy.d.ts +3 -2
  66. package/dist/runtime/server/utils/image-proxy.js +26 -16
  67. package/dist/runtime/server/utils/instagram-embed.d.ts +8 -0
  68. package/dist/runtime/server/utils/instagram-embed.js +155 -0
  69. package/dist/runtime/server/utils/network-dispatcher.node.d.ts +2 -0
  70. package/dist/runtime/server/utils/network-dispatcher.node.js +21 -0
  71. package/dist/runtime/server/utils/network-dispatcher.platform.d.ts +2 -0
  72. package/dist/runtime/server/utils/network-dispatcher.platform.js +5 -0
  73. package/dist/runtime/server/utils/network-host.d.ts +20 -0
  74. package/dist/runtime/server/utils/network-host.js +51 -0
  75. package/dist/runtime/server/utils/network-hostname.d.ts +2 -0
  76. package/dist/runtime/server/utils/network-hostname.js +41 -0
  77. package/dist/runtime/server/utils/privacy.js +55 -19
  78. package/dist/runtime/server/utils/proxy-query.d.ts +2 -0
  79. package/dist/runtime/server/utils/proxy-query.js +10 -0
  80. package/dist/runtime/server/utils/sign.d.ts +1 -1
  81. package/dist/runtime/server/utils/sign.js +1 -1
  82. package/dist/runtime/server/utils/withSigning.d.ts +1 -1
  83. package/dist/runtime/server/utils/withSigning.js +3 -3
  84. package/dist/runtime/server/vercel-insights-sink.js +1 -1
  85. package/dist/runtime/server/x-embed.js +8 -4
  86. package/dist/runtime/unhead-features.d.ts +1 -0
  87. package/dist/runtime/unhead-features.js +3 -0
  88. package/dist/runtime/utils/abortable-promise.d.ts +8 -0
  89. package/dist/runtime/utils/abortable-promise.js +63 -0
  90. package/dist/runtime/utils/after-next-paint.d.ts +1 -1
  91. package/dist/runtime/utils/after-next-paint.js +16 -1
  92. package/dist/runtime/utils/usercentrics-consent.d.ts +10 -0
  93. package/dist/runtime/utils/usercentrics-consent.js +88 -0
  94. package/dist/runtime/utils/youtube-readiness.d.ts +7 -0
  95. package/dist/runtime/utils/youtube-readiness.js +45 -0
  96. package/dist/runtime/utils.d.ts +3 -1
  97. package/dist/runtime/utils.js +29 -0
  98. package/package.json +2 -1
  99. package/dist/devtools-client/_nuxt/BGGk5RYW.js +0 -1
  100. package/dist/devtools-client/_nuxt/C8xLTMBy.js +0 -28
  101. package/dist/devtools-client/_nuxt/builds/meta/0c193d7f-fdc4-4ec6-b4c0-7ba4cc94709b.json +0 -1
  102. package/dist/devtools-client/_nuxt/error-404.CIn5oEzb.css +0 -1
  103. package/dist/devtools-client/_nuxt/error-500.B1YZl8g8.css +0 -1
@@ -0,0 +1 @@
1
+ export declare function isUnheadSourceLessScriptLoaderEnabled(): boolean;
@@ -0,0 +1,3 @@
1
+ export function isUnheadSourceLessScriptLoaderEnabled() {
2
+ return typeof __NUXT_SCRIPTS_UNHEAD_SOURCELESS__ !== "undefined" && __NUXT_SCRIPTS_UNHEAD_SOURCELESS__;
3
+ }
@@ -0,0 +1,8 @@
1
+ export interface AbortablePromiseOptions {
2
+ signal?: AbortSignal;
3
+ abortMessage?: string;
4
+ }
5
+ type PromiseSetup<T> = (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: unknown) => void) => void | (() => void);
6
+ export declare function createAbortError(message?: string): Error;
7
+ export declare function createAbortablePromise<T>(setup: PromiseSetup<T>, options?: AbortablePromiseOptions): Promise<T>;
8
+ export {};
@@ -0,0 +1,63 @@
1
+ export function createAbortError(message = "Operation aborted") {
2
+ const error = new Error(message);
3
+ error.name = "AbortError";
4
+ return error;
5
+ }
6
+ export function createAbortablePromise(setup, options = {}) {
7
+ const { signal, abortMessage } = options;
8
+ return new Promise((outerResolve, outerReject) => {
9
+ let settled = false;
10
+ let cleanup;
11
+ let onAbort;
12
+ const finish = (settle, value) => {
13
+ if (settled)
14
+ return;
15
+ settled = true;
16
+ signal?.removeEventListener("abort", onAbort);
17
+ const currentCleanup = cleanup;
18
+ cleanup = void 0;
19
+ try {
20
+ currentCleanup?.();
21
+ } catch (error) {
22
+ outerReject(error);
23
+ return;
24
+ }
25
+ settle(value);
26
+ };
27
+ const reject = (reason) => finish(outerReject, reason);
28
+ const resolve = (value) => {
29
+ if (typeof value === "object" && value !== null || typeof value === "function") {
30
+ let then;
31
+ try {
32
+ then = value.then;
33
+ } catch (error) {
34
+ reject(error);
35
+ return;
36
+ }
37
+ if (typeof then === "function") {
38
+ Promise.resolve(value).then(
39
+ (resolved) => finish(outerResolve, resolved),
40
+ reject
41
+ );
42
+ return;
43
+ }
44
+ }
45
+ finish(outerResolve, value);
46
+ };
47
+ onAbort = () => reject(createAbortError(abortMessage));
48
+ if (signal?.aborted) {
49
+ onAbort();
50
+ return;
51
+ }
52
+ signal?.addEventListener("abort", onAbort, { once: true });
53
+ try {
54
+ cleanup = setup(resolve, reject) || void 0;
55
+ if (settled) {
56
+ cleanup?.();
57
+ cleanup = void 0;
58
+ }
59
+ } catch (error) {
60
+ reject(error);
61
+ }
62
+ });
63
+ }
@@ -1 +1 @@
1
- export declare function afterNextPaint(callback: () => void): void;
1
+ export declare function afterNextPaint(callback: () => void): () => void;
@@ -1,3 +1,18 @@
1
1
  export function afterNextPaint(callback) {
2
- requestAnimationFrame(() => requestAnimationFrame(callback));
2
+ let cancelled = false;
3
+ let innerFrame;
4
+ const outerFrame = requestAnimationFrame(() => {
5
+ if (cancelled)
6
+ return;
7
+ innerFrame = requestAnimationFrame(() => {
8
+ if (!cancelled)
9
+ callback();
10
+ });
11
+ });
12
+ return () => {
13
+ cancelled = true;
14
+ cancelAnimationFrame(outerFrame);
15
+ if (innerFrame !== void 0)
16
+ cancelAnimationFrame(innerFrame);
17
+ };
3
18
  }
@@ -0,0 +1,10 @@
1
+ import type { UseScriptContext } from '#nuxt-scripts/types';
2
+ import type { UsercentricsApi, UsercentricsCmp, UsercentricsConsent } from '../registry/usercentrics.js';
3
+ interface UsercentricsEventTarget {
4
+ __ucCmp?: UsercentricsCmp;
5
+ addEventListener: Window['addEventListener'];
6
+ removeEventListener: Window['removeEventListener'];
7
+ }
8
+ type HookAppUnmount = (callback: () => void) => () => void;
9
+ export declare function attachUsercentricsConsent<T extends UsercentricsApi>(instance: UseScriptContext<T, UsercentricsConsent>, target: UsercentricsEventTarget, hookAppUnmount: HookAppUnmount): void;
10
+ export {};
@@ -0,0 +1,88 @@
1
+ import { logger } from "../logger.js";
2
+ import { createAbortablePromise, createAbortError } from "./abortable-promise.js";
3
+ export function attachUsercentricsConsent(instance, target, hookAppUnmount) {
4
+ if (instance.consent)
5
+ return;
6
+ let readyApi;
7
+ let readyPromise;
8
+ let readyController;
9
+ let stopAppUnmount = () => {
10
+ };
11
+ let disposed = true;
12
+ const cleanupReadyListener = () => {
13
+ if (disposed)
14
+ return;
15
+ disposed = true;
16
+ readyController?.abort();
17
+ readyController = void 0;
18
+ const stop = stopAppUnmount;
19
+ stopAppUnmount = () => {
20
+ };
21
+ stop();
22
+ };
23
+ const armReadyListener = () => {
24
+ readyApi = void 0;
25
+ readyPromise = void 0;
26
+ readyController = new AbortController();
27
+ disposed = false;
28
+ stopAppUnmount = hookAppUnmount(cleanupReadyListener);
29
+ };
30
+ const whenReady = () => {
31
+ const controller = readyController;
32
+ if (disposed || !controller)
33
+ return Promise.reject(createAbortError("Usercentrics readiness wait was aborted"));
34
+ if (readyApi)
35
+ return Promise.resolve(readyApi);
36
+ if (!readyPromise) {
37
+ readyPromise = createAbortablePromise((resolve) => {
38
+ const onReady = () => {
39
+ const api2 = target.__ucCmp;
40
+ if (!api2)
41
+ return;
42
+ readyApi = api2;
43
+ resolve(api2);
44
+ };
45
+ target.addEventListener("UC_CMP_API_READY", onReady);
46
+ const api = target.__ucCmp;
47
+ if (api?.isInitialized) {
48
+ Promise.resolve().then(() => api.isInitialized()).then((initialized) => {
49
+ if (initialized && !controller.signal.aborted)
50
+ onReady();
51
+ }).catch((error) => {
52
+ if (!controller.signal.aborted)
53
+ logger.debug("[usercentrics] Waiting for UC_CMP_API_READY after isInitialized() failed", error);
54
+ });
55
+ }
56
+ return () => target.removeEventListener("UC_CMP_API_READY", onReady);
57
+ }, {
58
+ signal: controller.signal,
59
+ abortMessage: "Usercentrics readiness wait was aborted"
60
+ });
61
+ }
62
+ return readyPromise;
63
+ };
64
+ armReadyListener();
65
+ const originalRemove = instance.remove;
66
+ const originalLoad = instance.load;
67
+ instance.remove = () => {
68
+ cleanupReadyListener();
69
+ return originalRemove();
70
+ };
71
+ instance.load = () => {
72
+ if (disposed)
73
+ armReadyListener();
74
+ return originalLoad();
75
+ };
76
+ instance.consent = {
77
+ whenReady,
78
+ onConsentChange(cb) {
79
+ const handler = (event) => cb(event.detail, event);
80
+ target.addEventListener("UC_UI_CMP_EVENT", handler);
81
+ return () => target.removeEventListener("UC_UI_CMP_EVENT", handler);
82
+ },
83
+ showFirstLayer: () => target.__ucCmp?.showFirstLayer?.(),
84
+ showSecondLayer: () => target.__ucCmp?.showSecondLayer?.(),
85
+ acceptAll: () => target.__ucCmp?.acceptAllConsents?.(),
86
+ denyAll: () => target.__ucCmp?.denyAllConsents?.()
87
+ };
88
+ }
@@ -0,0 +1,7 @@
1
+ interface YouTubeReadinessState {
2
+ controller?: AbortController;
3
+ promise: Promise<void>;
4
+ }
5
+ export declare function useYouTubeReadinessState(): YouTubeReadinessState;
6
+ export declare function armYouTubeReadiness(state: YouTubeReadinessState): void;
7
+ export {};
@@ -0,0 +1,45 @@
1
+ import { createAbortablePromise } from "./abortable-promise.js";
2
+ const readinessByWindow = /* @__PURE__ */ new WeakMap();
3
+ export function useYouTubeReadinessState() {
4
+ const existing = readinessByWindow.get(window);
5
+ if (existing)
6
+ return existing;
7
+ const state = { promise: Promise.resolve() };
8
+ readinessByWindow.set(window, state);
9
+ return state;
10
+ }
11
+ export function armYouTubeReadiness(state) {
12
+ state.controller?.abort();
13
+ const controller = new AbortController();
14
+ const target = window;
15
+ state.controller = controller;
16
+ state.promise = createAbortablePromise((resolve) => {
17
+ const previousReady = target.onYouTubeIframeAPIReady;
18
+ let onReady;
19
+ const restoreReady = () => {
20
+ if (target.onYouTubeIframeAPIReady !== onReady)
21
+ return;
22
+ if (previousReady)
23
+ target.onYouTubeIframeAPIReady = previousReady;
24
+ else
25
+ delete target.onYouTubeIframeAPIReady;
26
+ };
27
+ onReady = () => {
28
+ restoreReady();
29
+ try {
30
+ previousReady?.call(target);
31
+ } catch (error) {
32
+ if (import.meta.dev)
33
+ console.error("[nuxt-scripts] Previous onYouTubeIframeAPIReady handler failed:", error);
34
+ } finally {
35
+ resolve();
36
+ }
37
+ };
38
+ target.onYouTubeIframeAPIReady = onReady;
39
+ return restoreReady;
40
+ }, {
41
+ signal: controller.signal,
42
+ abortMessage: "YouTube API readiness wait was aborted"
43
+ });
44
+ void state.promise.then(void 0, () => void 0);
45
+ }
@@ -11,7 +11,9 @@ type OptionsFn<O> = (options: InferIfSchema<O>, ctx: {
11
11
  scriptInput?: UseScriptInput;
12
12
  scriptOptions?: NuxtUseScriptOptions;
13
13
  schema?: O extends ObjectSchema<any, any> | UnionSchema<any, any> ? O : undefined;
14
- clientInit?: () => void | Promise<any>;
14
+ clientInit?: (ctx?: {
15
+ signal: AbortSignal;
16
+ }) => any | Promise<any>;
15
17
  scriptMode?: 'external' | 'npm';
16
18
  /**
17
19
  * Opt-in: this script consumes GCMv2 Consent Mode. `useRegistryScript` auto-attaches
@@ -3,12 +3,15 @@ import { createError, useRuntimeConfig } from "nuxt/app";
3
3
  import { parseQuery, parseURL, withQuery } from "ufo";
4
4
  import { parse } from "valibot";
5
5
  import { useScript } from "./composables/useScript.js";
6
+ import { createNpmScriptProxy } from "./npm-script-proxy.js";
6
7
  import { createNpmScriptStub } from "./npm-script-stub.js";
7
8
  import { attachGcmConsent } from "./registry/_gcm-consent.js";
9
+ import { isUnheadSourceLessScriptLoaderEnabled } from "./unhead-features.js";
8
10
  const URL_MATCH_RE = /https?:\/\/[^/]+\/_nuxt\/(.+\.vue)(?:\?[^)]*)?:(\d+):(\d+)/;
9
11
  const URL_PAREN_MATCH_RE = /\(https?:\/\/[^/]+\/_nuxt\/(.+\.vue)(?:\?[^)]*)?:(\d+):(\d+)\)/;
10
12
  const VUE_MATCH_RE = /([^/\s]+\.vue):(\d+):(\d+)/;
11
13
  const CLEAN_CALLER_RE = /^\s*at\s+/;
14
+ const NPM_SCRIPT_PROXY_DECORATED = Symbol("nuxt-scripts:npm-proxy-decorated");
12
15
  function validateScriptInputSchema(schema, options) {
13
16
  if (import.meta.dev) {
14
17
  try {
@@ -45,6 +48,32 @@ export function useRegistryScript(registryKey, optionsFn, _userOptions) {
45
48
  const userOptions = defu(_userOptions || {}, typeof scriptConfig === "object" ? scriptConfig : {});
46
49
  const options = optionsFn(userOptions, { scriptInput: userOptions.scriptInput });
47
50
  if (options.scriptMode === "npm") {
51
+ if (isUnheadSourceLessScriptLoaderEnabled()) {
52
+ const scriptOptions2 = { ...userOptions.scriptOptions, ...options.scriptOptions };
53
+ const resolveApi = scriptOptions2.use;
54
+ const clientUse = resolveClientUse(resolveApi);
55
+ delete scriptOptions2.use;
56
+ if (typeof scriptOptions2.trigger === "undefined")
57
+ scriptOptions2.trigger = "client";
58
+ let api;
59
+ const instance2 = useScript({
60
+ key: String(registryKey),
61
+ async loader({ signal }) {
62
+ const initialized = await options.clientInit?.({ signal });
63
+ if (signal.aborted)
64
+ throw signal.reason || new Error(`Loading ${String(registryKey)} was aborted`);
65
+ api = await Promise.resolve(api || resolveApi?.() || initialized || {});
66
+ return api;
67
+ }
68
+ }, scriptOptions2);
69
+ const sharedInstance = instance2.script || instance2;
70
+ if (!sharedInstance[NPM_SCRIPT_PROXY_DECORATED]) {
71
+ api = clientUse?.();
72
+ sharedInstance.proxy = createNpmScriptProxy(sharedInstance.proxy, () => api);
73
+ Object.defineProperty(sharedInstance, NPM_SCRIPT_PROXY_DECORATED, { value: true });
74
+ }
75
+ return instance2;
76
+ }
48
77
  return createNpmScriptStub({
49
78
  key: String(registryKey),
50
79
  use: resolveClientUse(options.scriptOptions?.use),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nuxt/scripts",
3
3
  "type": "module",
4
- "version": "1.3.3",
4
+ "version": "1.3.5",
5
5
  "description": "Load third-party scripts with better performance, privacy and DX in Nuxt Apps.",
6
6
  "author": {
7
7
  "name": "Harlan Wilton",
@@ -126,6 +126,7 @@
126
126
  "std-env": "^4.2.0",
127
127
  "ufo": "^1.6.4",
128
128
  "ultrahtml": "^1.7.0",
129
+ "undici": "^6.27.0",
129
130
  "unplugin": "^3.3.0",
130
131
  "unstorage": "^1.17.5",
131
132
  "valibot": "^1.4.2"
@@ -1 +0,0 @@
1
- import{_ as e,g as t,i as n,m as r,v as i}from"./B551Pnuh.js";import{En as a,H as o,J as s,L as c,Ut as l,an as u,it as d,nt as f,ot as p,un as m,vn as h}from"./BKdLzFmX.js";var g=i({docsBase:t,reporters:e}),_=new Set([`link`,`style`,`script`,`noscript`]),v=new Set([`title`,`titleTemplate`,`script`,`style`,`noscript`]),y=new Set([`base`,`meta`,`link`,`style`,`script`,`noscript`]),b=new Set([`title`,`base`,`htmlAttrs`,`bodyAttrs`,`meta`,`link`,`style`,`script`,`noscript`]),x=new Set([`base`,`title`,`titleTemplate`,`bodyAttrs`,`htmlAttrs`,`templateParams`]),S=new Set([`key`,`tagPosition`,`tagPriority`,`tagDuplicateStrategy`,`innerHTML`,`textContent`,`processTemplateParams`]),C=new Set([`templateParams`,`htmlAttrs`,`bodyAttrs`]),ee=new Set([`theme-color`,`google-site-verification`,`og`,`article`,`book`,`profile`,`twitter`,`author`]),w={critical:-8,high:-1,low:2};function T(e){return e===`__proto__`||e===`constructor`||e===`prototype`}function E(e){let t=new r;for(let n in e||{})t.hook(n,e[n]);return t}function D(e,t,n){if(e.hooks?._hooks?.[t]?.length)return e.hooks?.callHook(t,n)}var O=/^(?:viewport|description|keywords|robots)$/,k=[`name`,`property`,`http-equiv`];function A(e){let t=e.indexOf(`:`);if(t===-1)return!1;let n=e.indexOf(`:`,t+1);return ee.has(e.slice(t+1,n===-1?e.length:n))}function j(e){let{props:t,tag:n,key:r}=e;if(x.has(n))return n;if(n===`link`&&t.rel===`canonical`)return`canonical`;if(n===`link`&&t.rel===`alternate`){if(t.hreflang)return`alternate:${t.hreflang}`;if(t.type)return`alternate:${t.type}:${t.href||``}`}if(t.charset)return`charset`;if(n===`meta`)for(let e of k){let n=t[e];if(n!==void 0)return`meta:${n}${(typeof n!=`string`||!n.includes(`:`))&&!O.test(n)&&r?`:key:${r}`:``}`}return r?`${n}:key:${r}`:t.id?`${n}:id:${t.id}`:n===`link`&&t.rel===`alternate`?`alternate:${t.href||``}`:v.has(n)&&(e.textContent||e.innerHTML)?`${n}:content:${e.textContent||e.innerHTML}`:void 0}function M(e){let t=e._h||e._d||e.textContent||e.innerHTML;if(t)return t;let n=`${e.tag}:`,r=``;for(let t in e.props)Object.hasOwn(e.props,t)&&(n+=`${r}${t}:${String(e.props[t])}`,r=`,`);return n}function N(e,t,n){if(n===`_resolver`)return e;typeof e==`function`&&(!n||n!==`titleTemplate`&&!n.startsWith(`on`))&&(e=e());let r=t?t(n,e):e;if(Array.isArray(r)){let e;for(let n=0;n<r.length;n++){let i=N(r[n],t);e?e[n]=i:i!==r[n]&&(e=r.slice(0,n),e[n]=i)}return e||r}if(r?.constructor===Object){let e;for(let n in r){let i=T(n),a=i?void 0:N(r[n],t,n);if(!e&&(i||a!==r[n])){e={};for(let t in r){if(t===n)break;e[t]=r[t]}}e&&!i&&(e[n]=a)}return e||r}return r}var P=/[\s"'<>/=\x00-\x1F\x7F]/;function F(e,t){let n=e===`style`,r=n?new Map:new Set,i=e=>{if(e)if(n){let t=e.indexOf(`:`);t>0&&r.set(e.slice(0,t).trim(),e.slice(t+1).trim())}else e.split(` `).forEach(e=>e&&r.add(e))};if(typeof t==`string`)(n?t.split(`;`):[t]).forEach(i);else if(Array.isArray(t))t.forEach(i);else if(t&&typeof t==`object`)for(let e in t){let a=t[e];a&&a!==`false`&&(n?r.set(e.trim(),String(a)):i(e))}return r}function I(e,t){if(e.props=e.props||{},!t)return e;if(e.tag===`templateParams`)return e.props=t,e;let n=y.has(e.tag)||e.tag===`htmlAttrs`||e.tag===`bodyAttrs`;for(let r in t){if(T(r))continue;let i=r.startsWith(`data-`),a=n&&!S.has(r),o=a&&!i?r.toLowerCase():r;if(a&&(!o||P.test(o)))continue;let s=t[r];if(s===null)e.props[o]=null;else if(r===`class`||r===`style`)e.props[r]=F(r,s);else if(S.has(r))if((r===`textContent`||r===`innerHTML`)&&typeof s==`object`){let n=t.type||`application/json`;(n.endsWith(`json`)||n===`speculationrules`||n===`importmap`)&&(e.props.type=t.type=n,e[r]=JSON.stringify(s))}else e[r]=s;else if(s!==void 0){let t=String(s),n=e.tag===`meta`&&o===`content`;e.props[o]=t===`true`||t===``?i||n?t:!0:!s&&i&&t===`false`?`false`:s}}return e}function L(e,t){let n=I({tag:e,props:{}},typeof t==`object`&&typeof t!=`function`?t:{[e===`script`||e===`noscript`||e===`style`?`innerHTML`:`textContent`]:t});if(n.key&&_.has(n.tag)&&(n.props[`data-hid`]=n._h=n.key),n.tag===`script`&&typeof n.innerHTML==`object`&&(n.innerHTML=JSON.stringify(n.innerHTML),n.props.type=n.props.type||`application/json`),Array.isArray(n.props.content)){let e=[];for(let t of n.props.content)e.push({...n,props:{...n.props,content:t}});return e}return n}function R(e,t){if(Array.isArray(t))for(let n of t)e.push(n);else e.push(t)}function te(e,t){if(!e)return[];typeof e==`function`&&(e=e());let n;t.length&&(n=(e,n)=>{for(let r=0;r<t.length;r++)n=t[r](e,n);return n},e=n(void 0,e)),e=N(e,n);let r=[];for(let t in e){let n=e[t];if(n!==void 0)if(Array.isArray(n))for(let e of n)R(r,L(t,e));else R(r,L(t,n))}return r}var z=/</g,B=/<\/script/g,V=(e,t)=>e._w===t._w?e._p-t._p:e._w-t._w,H=()=>100;function U(e){for(let t in e)return!1;return!0}var W=/^tags:|:render/;function G(e,t,n){for(let r of t)for(let t of r)if(n){let n={...t.props};n.class instanceof Set&&(n.class=new Set(n.class)),n.style instanceof Map&&(n.style=new Map(n.style)),e.tags.push({...t,props:n})}else e.tags.push(t)}function K(e,t){e.tags=[];for(let t of e.tagMap.values())if(Array.isArray(t))for(let n of t)e.tags.push(n);else e.tags.push(t);t&&e.tags.sort(V)}function q(e){let t=!1;for(let n of e.tags.sort(V)){let r=n._d||M(n);if(!r)continue;let i=e.tagMap.get(r);if(!i){e.tagMap.set(r,n);continue}if((n.tagDuplicateStrategy||(C.has(n.tag)?`merge`:null)||(n.key&&n.key===i.key?`merge`:null))===`merge`){let t={...i.props};for(let e in n.props)t[e]=e===`style`?new Map([...i.props.style||new Map,...n.props[e]]):e===`class`?new Set([...i.props.class||[],...n.props[e]]):n.props[e];e.tagMap.set(r,{...n,props:t})}else n._p>>10==i._p>>10&&n.tag===`meta`&&A(r)?(e.tagMap.set(r,Object.assign([...Array.isArray(i)?i:[i],n],n)),t=!0):(n._w===i._w?n._p>i._p:n._w<i._w)&&e.tagMap.set(r,n)}return t}function J(e,t){let n=e.tagMap.get(`title`),r=e.tagMap.get(`titleTemplate`);if(t._title=n?.textContent,!r)return;let i=r.textContent;if(t._titleTemplate=i,!i)return;let a=typeof i==`function`?i(n?.textContent):i;typeof a==`string`&&!t.plugins.has(`template-params`)&&(a=a.replace(`%s`,n?.textContent||``)),n?a===null?e.tagMap.delete(`title`):e.tagMap.set(`title`,{...n,textContent:a}):e.tagMap.set(`titleTemplate`,{...r,tag:`title`,textContent:a})}function Y(e){let t=[];for(let n of e){let{innerHTML:e,tag:r,props:i}=n;if(!(!b.has(r)||U(i)&&!e&&!n.textContent)&&!(r===`meta`&&!i.content&&!i[`http-equiv`]&&!i.charset)){if(r===`script`&&(e||n.textContent)){let t=String(i.type),r=t.endsWith(`json`)||t===`importmap`||t===`speculationrules`,a=e=>r?(typeof e==`string`?e:JSON.stringify(e)).replace(z,`\\u003C`):typeof e==`string`?e.replace(B,`<\\/script`):e;n={...n},e&&(n.innerHTML=a(e)),n.textContent&&=a(n.textContent),n._d=j(n)}t.push(n)}}return t}function X(e,t){let n=t?.tagWeight??e.resolvedOptions._tagWeight??H,r={tagMap:new Map,tags:[]},i=e.hooks?._hooks||{},a=[...e.entries.values()];for(let e of a)e._pending!==void 0&&(e.input=e._pending,delete e._pending,delete e._tags);D(e,`entries:resolve`,{entries:a,...r});let o=[];for(let t of a){if(!t._tags){let r=te(t.input,e.resolvedOptions.propResolvers||[]);for(let e of r)Object.assign(e,t.options);let i={tags:r,entry:t};D(e,`entries:normalize`,i);for(let e=0;e<i.tags.length;e++){let r=i.tags[e];r._w=n(r),r._p=(t._i<<10)+e,r._d=j(r),r._d||(r._h=M(r))}t._tags=i.tags}o.push(t._tags)}let s=!1;for(let e in i)if(W.test(e)&&i[e]?.some(e=>!e._nonMutating)){s=!0;break}G(r,o,s);let c=q(r);return J(r,e),K(r,c),D(e,`tags:beforeResolve`,r),D(e,`tags:resolve`,r),D(e,`tags:afterResolve`,r),Y(r.tags)}var Z=`usehead`;function Q(){if(o()){let e=s(Z);if(e)return e}throw Error(`useHead() was called without provide context, ensure you call it through the setup() function.`)}function ne(e){return{install(t){t.config.globalProperties.$unhead=e,t.config.globalProperties.$head=e,t.provide(Z,e)}}.install}var re=(e,t)=>m(t)?a(t):t;function ie(e,t={}){let n=t.head||Q();return n.ssr?n.push(e||{},t):ae(n,e,t)}function ae(e,t,n={}){let r=u();if(r&&!r.active)return{patch(){},dispose(){},_i:-1};let i=h(!1);if(n.onRendered&&r){let e=n.onRendered;n={...n,onRendered:t=>r.run(()=>e(t))}}let a;return l(()=>{let r=i.value?{}:N(t,re);a?a.patch(r):a=e.push(r,n)}),c()&&(d(()=>{a.dispose()}),p(()=>{i.value=!0}),f(()=>{i.value=!1})),a}function $(e){let t=e||n();return t.ssrContext?.head||t.runWithContext(()=>{if(o()){let e=s(`usehead`);if(!e)throw g.NUXT_E6001();return e}})}function oe(e,t={}){return ie(e,{head:t.head||$(t.nuxt),...t})}export{M as a,X as c,y as d,w as f,j as i,D as l,oe as n,A as o,ne as r,I as s,$ as t,E as u};