{"version":3,"file":"_utils.sMoFuN7v.mjs","names":["useState","formatPathString"],"sources":["https:/framerusercontent.com/modules/eSlbzLBXJ10sKJ49G3B9/ikylEbBVmlAiX2rGrRhS/_utils.js"],"sourcesContent":["import{useEffect,useState}from\"react\";/**\n * Formats the given path string by performing the following steps:\n * 1. Removes the '.md' extension if it exists.\n * 2. Converts camel case to kebab case (replacing uppercase letters with their lowercase equivalent, prefixed by a hyphen).\n * 3. Removes a leading hyphen, if present.\n */export function formatPathString(pathString){return pathString.replace(/\\.md$/,\"\").replace(/[A-Z]/g,match=>`-${match.toLowerCase()}`).replace(/^-/,\"\");}/**\n * Returns the current page URL if it is found in the navigation items.\n * The function iterates through the navigation items and checks if the formatted path includes the current URL.\n */export function getCurrentPageUrl(navigation,currentUrl){navigation.items.map(link=>{const formattedPath=formatPathString(link.path);if(formattedPath.includes(currentUrl)){return currentUrl;}});}/**\n * Updates the page's title with the new title and restores the original title when the component is unmounted.\n * The function re-runs the effect and cleanup when the currentPageTitle changes.\n */export function updatePageMetadata(originalTitle,newTitle,currentPageTitle){useEffect(()=>{document.title=newTitle;return()=>{// Restore the original title when the component is unmounted\ndocument.title=originalTitle;};},[currentPageTitle]);}/**\n * Generates a Markdown file name based on the last segment of the given URL.\n * The function processes the last segment by converting it to camel case and appending the '.md' extension.\n */export function getMdFileName(currentUrl){const segments=currentUrl.split(\"/\");const lastSegment=segments[segments.length-1];const capitalizedLastSegment=lastSegment.charAt(0).toUpperCase()+lastSegment.slice(1);const camelCaseLastSegment=capitalizedLastSegment.split(\"-\").map(word=>word.charAt(0).toUpperCase()+word.slice(1)).join(\"\");const mdFileName=camelCaseLastSegment+\".md\";return mdFileName;}/**\n * Removes all HTML comments from the provided content.\n */export function removeHtmlComments(content){return content.replace(/<!--[\\s\\S]*?-->/g,\"\");}export const formatPageName=pageName=>{return pageName.split(\"-\").map(word=>word.split(/(?=[A-Z])/).join(\" \").charAt(0).toUpperCase()+word.slice(1)).join(\" \");};/**\n * Returns the appropriate repository name based on the platform found in the given URL.\n */export function getRepoName(url){if(!url)return\"storyteller-sdk-kotlin\"// for testing\n;const match=url.match(/documentation\\/(.*?)\\//);if(!match||!match[1])return\"storyteller-sdk-kotlin\"// Return default value if no match found\n;const platform=match[1];switch(platform){case\"ios\":return\"storyteller-sdk-swift\";case\"android\":return\"storyteller-sdk-kotlin\";case\"web\":return\"storyteller-sdk-javascript\";case\"react-native\":return\"storyteller-sdk-react-native-internal\";case\"storyteller-cms\":return\"storyteller-cms\";default:return\"storyteller-sdk-kotlin\";}}/**\n * Returns the appropriate repository name based on the platform.\n */export const getRepoByPlatform=platform=>{switch(platform){case\"ios\":return\"storyteller-sdk-swift\";case\"android\":return\"storyteller-sdk-kotlin\";case\"web\":return\"storyteller-sdk-javascript\";case\"react-native\":return\"storyteller-sdk-react-native-internal\";default:return\"storyteller-sdk-kotlin\";}};/**\n * Returns the appropriate repository owner based on the repository name provided.\n */export function getRepoOwner(repo){switch(repo){case\"storyteller-sdk-swift\":return\"stormideas\";case\"storyteller-sdk-kotlin\":return\"stormideas\";case\"storyteller-sdk-javascript\":return\"stormideas\";case\"storyteller-sdk-react-native-internal\":return\"stormideas\";default:return\"stormideas\";}}export function parseRepoName(repoName){return repoName.replace(\"storyteller-sdk-\",\"\").replace(\"kotlin\",\"android\").replace(\"swift\",\"ios\").replace(\"javascript\",\"web\").replace(\"react-native-internal\",\"react-native\").toLowerCase();}/**\n * Returns formatted documentation url based on the platform and path provided.\n */export const createLinkHref=(section,platform,path)=>{const formattedPath=formatPathString(path);return`/${section}/${platform}/${formattedPath}`;};export const uniqueId=`custom-style-${Date.now()}-${Math.floor(Math.random()*1e5)}`;/**\n * Updates the navigation state based on the parsed content and the current URL.\n * This function sets the previous page URL, previous page title, next page URL,\n * next page title, and current page title.\n *\n */export function updateNavigation(parsedContent,currentUrl,formatPathString,setPreviousPageUrl,setPreviousPageTitle,setNextPageUrl,setNextPageTitle,setCurrentPageTitle){// Find the current, previous, and next pages\nconst currentPageIndex=parsedContent.items.findIndex(link=>currentUrl.includes(formatPathString(link.path)));if(currentPageIndex>=0){if(currentPageIndex>0){setPreviousPageUrl(formatPathString(parsedContent.items[currentPageIndex-1].path));setPreviousPageTitle(parsedContent.items[currentPageIndex-1].text);}if(currentPageIndex<parsedContent.items.length-1){setNextPageUrl(formatPathString(parsedContent.items[currentPageIndex+1].path));setNextPageTitle(parsedContent.items[currentPageIndex+1].text);setCurrentPageTitle(parsedContent.items[currentPageIndex].text);}}}/**\n * Updates the navigation state based on the parsed content and the current URL.\n * This function sets the previous page URL, previous page title, next page URL,\n * next page title, and current page title.\n *\n */export const updateUserGuideNavigation=(parsedContent,currentUrl,formatPathString,setPreviousPageUrl,setPreviousPageTitle,setNextPageUrl,setNextPageTitle,setCurrentPageTitle)=>{const items=Array.isArray(parsedContent)?{items:parsedContent}:parsedContent;const currentSectionIndex=items.items.findIndex(section=>section.items&&section.items.some(link=>currentUrl.includes(formatPathString(link.path))));if(currentSectionIndex>=0){const currentSection=items.items[currentSectionIndex].items;const currentPageIndex=currentSection.findIndex(link=>currentUrl.includes(formatPathString(link.path)));if(currentPageIndex>=0){if(currentPageIndex>0){setPreviousPageUrl(formatPathString(currentSection[currentPageIndex-1].path));setPreviousPageTitle(currentSection[currentPageIndex-1].text);}if(currentPageIndex<currentSection.length-1){setNextPageUrl(formatPathString(currentSection[currentPageIndex+1].path));setNextPageTitle(currentSection[currentPageIndex+1].text);setCurrentPageTitle(currentSection[currentPageIndex].text);}}}};function getWindowDimensions(){//NOTE: Defaults required for initial SSR so use of window doesn't cause error.\nconst defaultWidth=1e3;const defaultHeight=2e3;if(typeof window!==\"undefined\"){const{innerWidth:width,innerHeight:height}=window;return{width,height};}else{return{width:defaultWidth,height:defaultHeight};}}export function useWindowDimensions(){const[windowDimensions,setWindowDimensions]=useState(getWindowDimensions());useEffect(()=>{function handleResize(){setWindowDimensions(getWindowDimensions());}window.addEventListener(\"resize\",handleResize);return()=>window.removeEventListener(\"resize\",handleResize);},[]);return windowDimensions;}// Force smooth scroll between sections as scrollIntoView smooth behavior is not respected from component level\nexport function useSmoothScroll(){useEffect(()=>{const htmlElement=document.querySelector(\"html\");if(htmlElement){htmlElement.style.scrollBehavior=\"smooth\";}return()=>{if(htmlElement){htmlElement.style.scrollBehavior=\"\";}};},[]);}// Returns formatted title from url\nexport function getTitleFromUrl(url){const pathParts=url.split(\"/\");const lastPart=pathParts[pathParts.length-1];const title=lastPart.split(\"-\").map(word=>word.charAt(0).toUpperCase()+word.slice(1)).join(\" \");return title;}const initialState={windowLocation:\"\"};export const windowLocation=(state=initialState,action)=>{if(action.type===\"SET\"){var _window_location_href,_window_location,_window,_window_location1,_window1;return Object.assign({},state,{...state,windowLocation:typeof window!==\"undefined\"&&((_window=window)===null||_window===void 0?void 0:(_window_location=_window.location)===null||_window_location===void 0?void 0:(_window_location_href=_window_location.href)===null||_window_location_href===void 0?void 0:_window_location_href.includes(\"?\"))?(_window1=window)===null||_window1===void 0?void 0:(_window_location1=_window1.location)===null||_window_location1===void 0?void 0:_window_location1.href:state.windowLocation});}return state;};// This function returns UTM params based on window location - used in the SignUp form\nexport const useWindowLocation=()=>{var _window_location,_window;const[utmMedium,setUtmMedium]=useState(\"\");const[utmSource,setUtmSource]=useState(\"\");const[utmCampaign,setUtmCampaign]=useState(\"\");const[gclid,setGclid]=useState(\"\");const windowLocation=(_window=window)===null||_window===void 0?void 0:(_window_location=_window.location)===null||_window_location===void 0?void 0:_window_location.href;useEffect(()=>{const extractData=param=>{var _param_split;return param===null||param===void 0?void 0:(_param_split=param.split(\"=\"))===null||_param_split===void 0?void 0:_param_split.splice(1,1)[0];};if(typeof windowLocation===\"string\"){var _windowLocation_split_splice_,_windowLocation_split;const windowLocationData=windowLocation===null||windowLocation===void 0?void 0:(_windowLocation_split=windowLocation.split(\"?\"))===null||_windowLocation_split===void 0?void 0:(_windowLocation_split_splice_=_windowLocation_split.splice(1,2)[0])===null||_windowLocation_split_splice_===void 0?void 0:_windowLocation_split_splice_.split(\"&\");if(windowLocationData){windowLocationData.forEach(param=>{if(param.includes(\"utm_source\")){setUtmSource(extractData(param));}if(param.includes(\"utm_medium\")){setUtmMedium(extractData(param));}if(param.includes(\"utm_campaign\")){setUtmCampaign(extractData(param));}if(param.includes(\"gclid\")){setGclid(extractData(param));}});}}},[windowLocation]);return{utmCampaign,utmMedium,utmSource,gclid};};// Utility function that finds index by URL - used in the sidebar accordion on doc pages\nexport const findAccordionIndexByUrl=(currentUrl,navigation,isMobile,currentIndex,setCurrentIndex)=>{if(!currentUrl||!navigation)return-1;let foundIndex=isMobile?0:-1;for(let index=0;index<navigation.length;index++){const nav=navigation[index];const isCurrent=currentUrl.includes(nav.platform)&&nav.items.some(item=>currentUrl.endsWith(createLinkHref(\"documentation\",nav.platform,item.path)));if(isCurrent){foundIndex=index;}}if(foundIndex!==currentIndex){localStorage.setItem(\"docSidebarCurrentIndex\",foundIndex);setCurrentIndex(foundIndex);}return foundIndex;};// Returns true if the string does not include http(s): prefix in the URL\nexport function isInternalLink(url){return!url.includes(\"http://\")&&!url.includes(\"https://\");}\nexport const __FramerMetadata__ = {\"exports\":{\"updateUserGuideNavigation\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"isInternalLink\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useWindowDimensions\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"parseRepoName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getMdFileName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"removeHtmlComments\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getRepoByPlatform\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"createLinkHref\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"formatPathString\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getRepoOwner\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updatePageMetadata\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"formatPageName\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"windowLocation\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getCurrentPageUrl\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useSmoothScroll\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"findAccordionIndexByUrl\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"updateNavigation\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"useWindowLocation\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"uniqueId\":{\"type\":\"variable\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getTitleFromUrl\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"getRepoName\":{\"type\":\"function\",\"annotations\":{\"framerContractVersion\":\"1\"}},\"__FramerMetadata__\":{\"type\":\"variable\"}}}\n//# sourceMappingURL=./_utils.map"],"mappings":"yHAKG,SAAgB,EAAiB,EAAW,CAAC,OAAO,EAAW,QAAQ,QAAQ,GAAG,CAAC,QAAQ,SAAS,GAAO,IAAI,EAAM,aAAa,GAAG,CAAC,QAAQ,KAAK,GAAG,CAMtJ,SAAgB,EAAmB,EAAc,EAAS,EAAiB,CAAC,OAAe,SAAS,MAAM,MAAmB,CAChI,SAAS,MAAM,IAAkB,CAAC,EAAiB,CAAC,CA0B68B,SAAS,GAAqB,CACh/B,GAAU,IAAS,OAAY,CAAC,GAAK,CAAC,WAAW,EAAM,YAAY,GAAQ,EAAO,MAAM,CAAC,QAAM,SAAO,MAAO,MAAM,CAAC,MAAM,IAAa,OAAO,IAAc,CAAG,SAAgB,GAAqB,CAAC,GAAK,CAAC,EAAiB,G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