{"version":3,"file":"pathURL-CNc7yKNK.cjs","names":["defaultProps","isValidEasingValue","DATA_RZL_PROGRESS","defaultPropsInitRzlNextProgressBar","isValidEasingValue"],"sources":["../src/progress-bar/utils/validation.ts","../src/progress-bar/hooks/useCssTopLoader.ts","../src/progress-bar/utils/pathURL.ts"],"sourcesContent":["import {\n  isBoolean,\n  isInteger,\n  isNonEmptyString,\n  isNumber,\n  isPlainObject,\n  isString,\n  isUndefined\n} from \"@rzl-zone/utils-js/predicates\";\nimport { defaultPropsInitRzlNextProgressBar as defaultProps } from \"../constants\";\nimport { isValidEasingValue } from \"./rzlProgress\";\nimport type {\n  ProgressBarPagesComponentProps,\n  RzlNextProgressBarProps\n} from \"../types\";\n\n/** @internal */\nexport const validationPropsPgBar = (\n  props: RzlNextProgressBarProps &\n    Pick<\n      ProgressBarPagesComponentProps,\n      \"disableSameURL\" | \"shallowRouting\"\n    > = defaultProps\n) => {\n  if (!isPlainObject(props)) props = {};\n\n  let {\n    id,\n    name,\n    nonce,\n    style,\n    colorSpinner,\n    classNameIfLoading = defaultProps.classNameIfLoading,\n    spinnerSpeed = defaultProps.spinnerSpeed,\n    spinnerSize = defaultProps.spinnerSize,\n    spinnerEase = defaultProps.spinnerEase,\n    color = defaultProps.color,\n    height = defaultProps.height,\n    zIndex = defaultProps.zIndex,\n    showAtBottom = defaultProps.showAtBottom,\n    startPosition = defaultProps.startPosition,\n    delay = defaultProps.delay,\n    stopDelay = defaultProps.stopDelay,\n    showForHashAnchor = defaultProps.showForHashAnchor,\n    options = defaultProps.options,\n    disableSameURL = defaultProps.disableSameURL,\n    shallowRouting = defaultProps.shallowRouting\n  } = props;\n\n  if (!isUndefined(id) && !isNonEmptyString(id)) id = undefined;\n  if (!isUndefined(name) && !isNonEmptyString(name)) name = undefined;\n  if (!isUndefined(nonce) && !isString(nonce)) nonce = undefined;\n  if (!isUndefined(style) && !isNonEmptyString(style)) style = undefined;\n\n  if (\n    !isUndefined(classNameIfLoading) &&\n    !isNonEmptyString(classNameIfLoading)\n  ) {\n    classNameIfLoading = defaultProps.classNameIfLoading;\n  }\n\n  if (\n    !isUndefined(colorSpinner) &&\n    (!isPlainObject(colorSpinner) ||\n      (colorSpinner.type !== \"base\" && colorSpinner.type !== \"advance\") ||\n      (colorSpinner.type === \"base\" &&\n        !isUndefined(colorSpinner.ValueBase) &&\n        !isString(colorSpinner.ValueBase)) ||\n      (colorSpinner.type === \"advance\" &&\n        !isUndefined(colorSpinner.ValueAdvance) &&\n        !isString(colorSpinner.ValueAdvance)))\n  ) {\n    colorSpinner = undefined;\n  }\n\n  if (!isInteger(spinnerSpeed)) spinnerSpeed = defaultProps.spinnerSpeed;\n  if (!isNonEmptyString(spinnerSize)) spinnerSize = defaultProps.spinnerSize;\n  if (!isValidEasingValue(spinnerEase)) spinnerEase = defaultProps.spinnerEase;\n  if (!isNonEmptyString(color)) color = defaultProps.color;\n  if (!isNonEmptyString(height)) height = defaultProps.height;\n  if (!isInteger(zIndex)) zIndex = defaultProps.zIndex;\n  if (!isBoolean(showAtBottom)) showAtBottom = defaultProps.showAtBottom;\n  if (!isNumber(startPosition)) startPosition = defaultProps.startPosition;\n  if (!isInteger(delay)) delay = defaultProps.delay;\n  if (!isInteger(stopDelay)) stopDelay = defaultProps.stopDelay;\n  if (!isBoolean(showForHashAnchor))\n    showForHashAnchor = defaultProps.showForHashAnchor;\n  if (!isPlainObject(options)) options = defaultProps.options;\n\n  if (!isBoolean(disableSameURL)) disableSameURL = defaultProps.disableSameURL;\n  if (!isBoolean(shallowRouting)) shallowRouting = defaultProps.shallowRouting;\n\n  return {\n    id,\n    name,\n    nonce,\n    style,\n    colorSpinner,\n    classNameIfLoading,\n    spinnerSpeed,\n    spinnerSize,\n    spinnerEase,\n    color,\n    height,\n    zIndex,\n    showAtBottom,\n    startPosition,\n    delay,\n    stopDelay,\n    showForHashAnchor,\n    options,\n\n    disableSameURL,\n    shallowRouting\n  };\n};\n","\"use client\";\n\nimport { useCallback, useEffect, useMemo } from \"react\";\nimport { validateHTMLColor } from \"validate-color\";\nimport { isNonEmptyString, isUndefined } from \"@rzl-zone/utils-js/predicates\";\n\nimport type { UseCssTopLoader } from \"../types\";\nimport { isValidEasingValue } from \"../utils/rzlProgress\";\nimport {\n  DATA_RZL_PROGRESS,\n  defaultPropsInitRzlNextProgressBar\n} from \"../constants\";\n\nconst { MAIN_IDENTITY, KEY_DATA } = DATA_RZL_PROGRESS.STYLE_ELEMENT;\n\n/** @internal */\nexport const useCssTopLoader = ({\n  id,\n  name,\n  nonce,\n  style,\n  color,\n  height,\n  spinnerEase,\n  colorSpinner,\n  zIndex,\n  spinnerSize,\n  spinnerSpeed,\n  showAtBottom,\n  classNameIfLoading = defaultPropsInitRzlNextProgressBar[\"classNameIfLoading\"]\n}: UseCssTopLoader) => {\n  const positionStyle = showAtBottom ? \"bottom: 0;\" : \"top: 0;\";\n  const spinnerPositionStyle = showAtBottom ? \"bottom: 15px;\" : \"top: 15px;\";\n\n  const validationEaseSpinner = useCallback(() => {\n    if (isValidEasingValue(spinnerEase)) return spinnerEase;\n\n    return \"linear\";\n  }, [spinnerEase]);\n\n  const typeColorBase =\n    colorSpinner?.type === \"base\" && isNonEmptyString(colorSpinner.ValueBase)\n      ? colorSpinner.ValueBase\n      : undefined;\n  const typeColorHex =\n    colorSpinner?.type === \"advance\" &&\n    isNonEmptyString(colorSpinner.ValueAdvance)\n      ? colorSpinner.ValueAdvance\n      : undefined;\n\n  if (!isUndefined(classNameIfLoading) && !isNonEmptyString(classNameIfLoading))\n    classNameIfLoading =\n      defaultPropsInitRzlNextProgressBar[\"classNameIfLoading\"];\n\n  const validationOfColorSpinner = useCallback(() => {\n    if (typeColorBase && typeColorHex) {\n      return \"#29f\";\n    } else {\n      if (typeColorBase) return typeColorBase;\n      if (typeColorHex && validateHTMLColor(typeColorHex)) return typeColorHex;\n      return \"#29f\";\n    }\n  }, [\n    typeColorBase, // Use individual properties\n    typeColorHex // Use individual properties\n  ]);\n\n  const styles = useMemo(() => {\n    return (\n      typeof style === \"string\" && style.trim().length\n        ? style.replace(/\\s\\s+/g, \"\").trim()\n        : `\n        #rzl-progress {\n          pointer-events: none;\n          position: fixed;\n          z-index: ${zIndex};\n          top: 0;\n          left: 0;\n          width: 100%;height: ${height};\n        }\n\n        #rzl-progress .bar {\n          position: fixed;\n          width: 100%;\n          left: 0;\n          ${positionStyle}\n          height: ${height};\n          z-index: ${zIndex};\n          background: ${color};\n        }\n        \n        #rzl-progress .peg {\n          display: block;\n          position: absolute;\n          right: 0px;\n          width: 100px;\n          height: 100%;\n          opacity: 1.0;\n          box-shadow: 0 0 10px ${color}, 0 0 5px ${color};\n\n          -webkit-transform: rotate(3deg) translate(0px, -4px);\n              -ms-transform: rotate(3deg) translate(0px, -4px);\n                  transform: rotate(3deg) translate(0px, -4px);\n        }\n        \n        #rzl-progress .spinner {\n          display: block;\n          position: fixed;\n          z-index: ${zIndex};\n          ${spinnerPositionStyle}\n          right:15px;\n        }\n\n        #rzl-progress .spinner-icon {\n          width: 18px;\n          height: 18px;\n          box-sizing: border-box;\n          border: solid ${spinnerSize} transparent;\n          border-top-color: ${validationOfColorSpinner()};\n          border-left-color: ${validationOfColorSpinner()};\n          border-radius: 50%;\n          -webkit-animation: rzl-progress-spinner ${spinnerSpeed}ms ${validationEaseSpinner()} infinite;\n                  animation: rzl-progress-spinner ${spinnerSpeed}ms ${validationEaseSpinner()} infinite;\n        }\n\n        .rzl-progress-custom-parent {\n          overflow: hidden;\n          position: relative;\n        }\n\n        .rzl-progress-custom-parent #rzl-progress .spinner,\n        .rzl-progress-custom-parent #rzl-progress .bar {\n          position: absolute;\n        }\n\n        @-webkit-keyframes rzl-progress-spinner {\n          0%   { -webkit-transform: rotate(0deg); }\n          100% { -webkit-transform: rotate(360deg); }\n        }\n        @keyframes rzl-progress-spinner {\n          0%   { transform: rotate(0deg); }\n          100% { transform: rotate(360deg); }\n        }\n      `\n    )\n      .replace(/\\s\\s+/g, \"\")\n      .trim();\n  }, [\n    style,\n    color,\n    zIndex,\n    height,\n    positionStyle,\n    spinnerPositionStyle,\n    spinnerSize,\n    spinnerSpeed,\n    validationEaseSpinner,\n    validationOfColorSpinner\n  ]);\n\n  useEffect(() => {\n    // Create a new <style> element\n    const styleElement = document.createElement(\"style\");\n\n    styleElement.setAttribute(\"type\", \"text/css\");\n    styleElement.setAttribute(MAIN_IDENTITY.KEY, MAIN_IDENTITY.VALUE);\n\n    // Set the 'id' only if it's provided, otherwise it will be undefined\n    if (id) styleElement.id = id;\n\n    // Conditionally set the 'name' attributes if they are defined\n    if (name) styleElement.setAttribute(\"name\", name);\n\n    // Conditionally set the 'nonce' attributes if they are defined\n    if (nonce) styleElement.setAttribute(\"nonce\", nonce);\n\n    // Force set\n    if (classNameIfLoading)\n      styleElement.setAttribute(\n        KEY_DATA.CLASS_NAME_LOADING,\n        classNameIfLoading\n      );\n\n    // Set the CSS content inside the <style> element\n    styleElement.innerHTML = styles;\n\n    // Append the style element to the head\n    document.head.appendChild(styleElement);\n\n    // Cleanup when the component is unmounted\n    return () => {\n      document.head.removeChild(styleElement);\n    };\n  }, []);\n};\n","/** * Convert the url to Absolute URL based on the current window location.\n *\n * @param url {string}\n * @returns {string}\n *\n * @internal\n */\nexport const toAbsoluteURL = (url: string): string => {\n  return new URL(url, window.location.href).href;\n};\n\n/** * Check if it is hash anchor or same page anchor\n *\n * @param currentUrl {string} Current Url Location\n * @param newUrl {string} New Url detected with each anchor\n * @returns {boolean}\n *\n * @internal\n */\nexport const isHashAnchor = (currentUrl: string, newUrl: string): boolean => {\n  const current = new URL(toAbsoluteURL(currentUrl));\n  const next = new URL(toAbsoluteURL(newUrl));\n  return current.href.split(\"#\")[0] === next.href.split(\"#\")[0];\n};\n\n/** * Check if it is Same Host name\n *\n * @param currentUrl {string} Current Url Location\n * @param newUrl {string} New Url detected with each anchor\n * @returns {boolean}\n *\n * @internal\n */\nexport const isSameHostName = (currentUrl: string, newUrl: string): boolean => {\n  const current = new URL(toAbsoluteURL(currentUrl));\n  const next = new URL(toAbsoluteURL(newUrl));\n  return (\n    current.hostname.replace(/^www\\./, \"\") ===\n    next.hostname.replace(/^www\\./, \"\")\n  );\n};\n\n/** * Check if the Current Url is same as New Url\n *\n * @param currentUrl {string}\n * @param newUrl {string}\n * @returns {boolean}\n *\n * @internal\n */\nexport function isAnchorOfCurrentUrl(\n  currentUrl: string,\n  newUrl: string\n): boolean {\n  const currentUrlObj = new URL(currentUrl);\n  const newUrlObj = new URL(newUrl);\n  // Compare hostname, pathname, and search parameters\n  if (\n    currentUrlObj.hostname === newUrlObj.hostname &&\n    currentUrlObj.pathname === newUrlObj.pathname &&\n    currentUrlObj.search === newUrlObj.search\n  ) {\n    // Check if the new URL is just an anchor of the current URL page\n    const currentHash = currentUrlObj.hash;\n    const newHash = newUrlObj.hash;\n    return (\n      currentHash !== newHash &&\n      currentUrlObj.href.replace(currentHash, \"\") ===\n        newUrlObj.href.replace(newHash, \"\")\n    );\n  }\n  return false;\n}\n\n/** @internal */\nexport function isSameURL(target: URL, current: URL) {\n  const cleanTarget =\n    target.protocol + \"//\" + target.host + target.pathname + target.search;\n  const cleanCurrent =\n    current.protocol + \"//\" + current.host + current.pathname + current.search;\n\n  return cleanTarget === cleanCurrent;\n}\n\n/** @internal */\nexport function isSameURLWithoutSearch(target: URL, current: URL) {\n  const cleanTarget = target.protocol + \"//\" + target.host + target.pathname;\n  const cleanCurrent =\n    current.protocol + \"//\" + current.host + current.pathname;\n\n  return cleanTarget === cleanCurrent;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,MAAa,wBACX,QAIMA,2DACH;CACH,IAAI,kDAAe,KAAK,GAAG,QAAQ,CAAC;CAEpC,IAAI,EACF,IACA,MACA,OACA,OACA,cACA,qBAAqBA,uDAAa,oBAClC,eAAeA,uDAAa,cAC5B,cAAcA,uDAAa,aAC3B,cAAcA,uDAAa,aAC3B,QAAQA,uDAAa,OACrB,SAASA,uDAAa,QACtB,SAASA,uDAAa,QACtB,eAA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