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.0.\n * Original file: /npm/@oplayer/react@1.2.11-beta.2/dist/index.es.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","/**\n * name: @oplayer/react\n * version: v1.2.11-beta.2\n * description: React wrapper for oplayer.\n * author: shiyiya\n * homepage: https://github.com/shiyiya/oplayer\n */\nconst _excluded = [\"playing\", \"duration\", \"aspectRatio\", \"plugins\", \"onEvent\", \"source\"];\nfunction _objectWithoutPropertiesLoose(r, e) {\n  if (null == r) return {};\n  var t = {};\n  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {\n    if (e.includes(n)) continue;\n    t[n] = r[n];\n  }\n  return t;\n}\nimport { jsx } from \"react/jsx-runtime\";\nimport Player__default from \"@oplayer/core\";\nexport * from \"@oplayer/core\";\nimport { forwardRef, useRef, useCallback, useEffect, useImperativeHandle, useMemo } from \"react\";\nconst ReactOPlayer = forwardRef((props, ref) => {\n  const playing = props.playing, duration = props.duration, _props$aspectRatio = props.aspectRatio, aspectRatio = _props$aspectRatio === void 0 ? 9 / 16 : _props$aspectRatio, _props$plugins = props.plugins, plugins = _props$plugins === void 0 ? [] : _props$plugins, onEvent = props.onEvent, source = props.source, rest = _objectWithoutPropertiesLoose(props, _excluded);\n  const onEventRef = useRef(onEvent);\n  onEventRef.current = onEvent;\n  const player = useRef(null);\n  const preSource = usePrevious(source);\n  const isReady = player.current && player.current.$root;\n  const onRefChange = useCallback((node) => {\n    if (node !== null && !isReady) {\n      const initialParams = source instanceof Promise ? rest : Object.assign({}, rest, {\n        source\n      });\n      player.current = Player__default.make(node, initialParams).use(plugins).create();\n      if (source instanceof Promise) player.current.changeSource(source);\n      if (typeof duration == \"number\") player.current.seek(duration / 1e3);\n      if (onEvent) {\n        player.current.on((payload) => {\n          var _a;\n          return (_a = onEventRef.current) == null ? void 0 : _a.call(onEventRef, payload);\n        });\n      }\n    }\n  }, []);\n  useEffectIf(isReady, () => {\n    if (playing) {\n      if (!player.current.isPlaying) player.current.play();\n    } else {\n      if (player.current.isPlaying) player.current.pause();\n    }\n  }, [playing]);\n  useEffectIf(isReady, () => {\n    if (source && (source instanceof Promise ? preSource != source : source.src && (preSource == null ? void 0 : preSource.src) !== source.src)) {\n      player.current.changeSource(source);\n    }\n  }, [source]);\n  useEffectIf(isReady && typeof duration === \"number\", () => {\n    player.current.seek(duration / 1e3);\n  }, [duration]);\n  useEffectIf(isReady, () => {\n    if (rest.muted) {\n      player.current.mute();\n    } else {\n      player.current.unmute();\n    }\n  }, [rest.muted]);\n  useEffectIf(isReady, () => {\n    player.current.setPlaybackRate(rest.playbackRate);\n  }, [rest.playbackRate]);\n  useEffect(() => {\n    return () => {\n      var _a;\n      (_a = player.current) == null ? void 0 : _a.destroy();\n      player.current = null;\n    };\n  }, []);\n  useImperativeHandle(ref, () => player.current, []);\n  return useMemo(() => {\n    if (aspectRatio == 0) {\n      return /* @__PURE__ */ jsx(\"div\", {\n        ref: onRefChange\n      });\n    }\n    return /* @__PURE__ */ jsx(\"div\", {\n      style: {\n        width: \"100%\",\n        paddingTop: aspectRatio * 100 + \"%\",\n        backgroundColor: \"#f4f4f4\",\n        position: \"relative\"\n      },\n      children: /* @__PURE__ */ jsx(\"div\", {\n        style: {\n          position: \"absolute\",\n          top: 0,\n          left: 0,\n          width: \"100%\",\n          height: \"100%\"\n        },\n        ref: onRefChange\n      })\n    });\n  }, []);\n});\nconst useEffectIf = (where, cb, deps) => {\n  useEffect(() => {\n    if (Boolean(where)) {\n      return cb();\n    }\n  }, deps);\n};\nfunction usePrevious(value) {\n  const ref = useRef();\n  useEffect(() => {\n    ref.current = value;\n  }, [value]);\n  return ref.current;\n}\nexport {\n  ReactOPlayer as default,\n  usePrevious\n};\n"]}