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D,EAD+B,WAAZ,EAAuB,YAAc,eACrC,MAAM,QAAQ,EAAK,UAAY,EAAK,SAAS,IAAI,QAAQ,KAAK,IAAM,OAAO,EAAK,SACrG,CAEA,UADO,EAAK,SACR,eAAe,IAAI,GAAU,CAC/B,MAAM,EAAM,EACP,MAAM,QAAQ,EAAM,MACvB,EAAM,GAAO,IAEf,EAAM,GAAK,KAAK,EAClB,MACE,EAAM,GAAW,CAErB,CACA,OAAO,CAAK,GACX,CAAC,EAAmB,IACjB,EAAU,OACd,EAAK,KAAK,MAaZ,OAXA,WAAU,IACD,KACD,EAAQ,SAAS,SACnB,EAAQ,QAAQ,UAElB,EAAQ,QAAU,IAAI,GAEvB,IACH,WAAU,KACR,EAAQ,SAAS,MAAM,IAAiB,GACvC,CAAC,IACG,IAAI,SAGJ,KAAM,YAAa,QAAS,YAAa,UAAW,WAAY","file":"/npm/@unhead/react@2.1.12/dist/index.mjs","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/@unhead/react@2.1.12/dist/index.mjs\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","import React, { useEffect, useContext, useRef, useMemo, useCallback } from 'react';\nimport { ValidHeadTags, TagsWithInnerContent, HasElementTags } from 'unhead/utils';\nimport { useScript as useScript$1, useHead as useHead$1, useHeadSafe as useHeadSafe$1, useSeoMeta as useSeoMeta$1 } from 'unhead';\nimport { U as UnheadContext } from './shared/react.DF9T1fqs.mjs';\n\nconst hookImports = {\n  \"@unhead/react\": [\n    \"useUnhead\",\n    \"useHead\",\n    \"useSeoMeta\",\n    \"useHeadSafe\"\n  ]\n};\n\nfunction useUnhead() {\n  const instance = useContext(UnheadContext);\n  if (!instance) {\n    throw new Error(\"useHead() was called without provide context.\");\n  }\n  return instance;\n}\nfunction withSideEffects(input, options, fn) {\n  const unhead = options.head || useUnhead();\n  const entryRef = useRef(null);\n  const inputRef = useRef(input);\n  inputRef.current = input;\n  if (unhead.ssr && !entryRef.current) {\n    entryRef.current = fn(unhead, input, options);\n  }\n  useEffect(() => {\n    const entry = fn(unhead, inputRef.current, options);\n    entryRef.current = entry;\n    return () => {\n      entry.dispose();\n      entryRef.current = null;\n    };\n  }, [unhead]);\n  useEffect(() => {\n    entryRef.current?.patch(input);\n  }, [input]);\n  if (unhead.ssr) {\n    return entryRef.current;\n  }\n  const proxyRef = useRef(null);\n  if (!proxyRef.current) {\n    proxyRef.current = {\n      patch: (newInput) => {\n        entryRef.current?.patch(newInput);\n      },\n      dispose: () => {\n        entryRef.current?.dispose();\n        entryRef.current = null;\n      },\n      _poll: (rm) => {\n        entryRef.current?._poll(rm);\n      }\n    };\n  }\n  return proxyRef.current;\n}\nfunction useHead(input = {}, options = {}) {\n  return withSideEffects(input, options, useHead$1);\n}\nfunction useHeadSafe(input = {}, options = {}) {\n  return withSideEffects(input, options, useHeadSafe$1);\n}\nfunction useSeoMeta(input = {}, options = {}) {\n  return withSideEffects(input, options, useSeoMeta$1);\n}\nfunction useScript(_input, _options) {\n  const input = typeof _input === \"string\" ? { src: _input } : _input;\n  const options = _options || {};\n  const head = options?.head || useUnhead();\n  options.head = head;\n  const mountCbs = [];\n  let isMounted = false;\n  useEffect(() => {\n    isMounted = true;\n    mountCbs.forEach((i) => i());\n    return () => {\n      isMounted = false;\n    };\n  }, []);\n  if (typeof options.trigger === \"undefined\") {\n    options.trigger = (load) => {\n      if (isMounted) {\n        load();\n      } else {\n        mountCbs.push(load);\n      }\n    };\n  }\n  const script = useScript$1(head, input, options);\n  const sideEffects = [];\n  useEffect(() => {\n    return () => {\n      script._triggerAbortController?.abort();\n      sideEffects.forEach((i) => i());\n    };\n  }, []);\n  const _registerCb = (key, cb) => {\n    let i;\n    const destroy = () => {\n      if (i) {\n        script._cbs[key]?.splice(i - 1, 1);\n        i = null;\n      }\n    };\n    mountCbs.push(() => {\n      if (!script._cbs[key]) {\n        cb(script.instance);\n        return () => {\n        };\n      }\n      i = script._cbs[key].push(cb);\n      sideEffects.push(destroy);\n      return destroy;\n    });\n  };\n  script.onLoaded = (cb) => _registerCb(\"loaded\", cb);\n  script.onError = (cb) => _registerCb(\"error\", cb);\n  return script;\n}\n\nconst Head = ({ children, titleTemplate }) => {\n  const head = useUnhead();\n  const processedElements = useMemo(() => React.Children.toArray(children).filter(React.isValidElement), [children]);\n  const getHeadChanges = useCallback(() => {\n    const input = {\n      titleTemplate\n    };\n    for (const element of processedElements) {\n      const reactElement = element;\n      const { type, props } = reactElement;\n      const tagName = String(type);\n      if (!ValidHeadTags.has(tagName)) {\n        continue;\n      }\n      const data = { ...typeof props === \"object\" ? props : {} };\n      if (TagsWithInnerContent.has(tagName) && data.children) {\n        const contentKey = tagName === \"script\" ? \"innerHTML\" : \"textContent\";\n        data[contentKey] = Array.isArray(data.children) ? data.children.map(String).join(\"\") : String(data.children);\n      }\n      delete data.children;\n      if (HasElementTags.has(tagName)) {\n        const key = tagName;\n        if (!Array.isArray(input[key])) {\n          input[key] = [];\n        }\n        input[key].push(data);\n      } else {\n        input[tagName] = data;\n      }\n    }\n    return input;\n  }, [processedElements, titleTemplate]);\n  const headRef = useRef(\n    head.push(getHeadChanges())\n  );\n  useEffect(() => {\n    return () => {\n      if (headRef.current?.dispose) {\n        headRef.current.dispose();\n      }\n      headRef.current = null;\n    };\n  }, []);\n  useEffect(() => {\n    headRef.current?.patch(getHeadChanges());\n  }, [getHeadChanges]);\n  return null;\n};\n\nexport { Head, hookImports, useHead, useHeadSafe, useScript, useSeoMeta, useUnhead };\n"]}