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AI,+BACtBf,EAAQoB,QAAQT,EACpB,CAmDIU,CAAUrB,EAASA,EAAQC,GAAIO,EACnC,CAEe,SAASc,KACpB,OAA4B,YAAavB,EAC7C,C","sources":["webpack://socialUX/./ldDebugger/addBrickHyperLinks.js"],"sourcesContent":["import createElementChangeListener from \"../elementChangeListener\";\n\nconst SKELETON_SELECTOR = /^s(?:[\\w_-]+_)+(?:[0-9]+_)+[0-9]+$/i;\n\nfunction createLinkElement() {\n    const anchor = document.createElement(\"a\");\n    anchor.classList.add(\"rm-lddebugger-component-link\");\n    anchor.target = \"lddebugger\";\n    return anchor;\n}\n\nfunction addAnchor(element, elementPath, href) {\n    const anchor = createLinkElement();\n    anchor.href = href;\n    anchor.text = \"Open in l&d\";\n    anchor.title = elementPath;\n    element.classList.add(\"rm-lddebugger-anchor-holder\");\n    element.prepend(anchor);\n}\n\nfunction reduceSekeletonSelector([brickNameLength, indexPieces], piece, index) {\n    if (isNaN(piece) && indexPieces.length === 2) {\n        return [brickNameLength + 1, indexPieces];\n    }\n\n    if (!isNaN(piece) && brickNameLength > 0 && index >= brickNameLength + 3) {\n        const pieceN = parseInt(piece, 10) + 1;\n        return [brickNameLength, [...indexPieces, `:nth-child(${pieceN})`]];\n    }\n\n    return [brickNameLength, indexPieces];\n}\n\nfunction isIndexPiece(piece) {\n    // Empty pieces come from leading/repeated underscores, not DOM indices.\n    return piece !== \"\" && !isNaN(piece);\n}\n\nfunction extractPageName(selectorPieces) {\n    // Keep everything before _<number> , preserving the empty\n    // pieces so names like \"__load_experts\" survive the split/join round-trip.\n    // WARNING: The id has no delimiter between name and indices, so a name ending in a\n    // number (e.g. \"__expert_1\") is ambiguous and its trailing number is lost.\n    let lastNamePieceIndex = selectorPieces.length - 1;\n    while (lastNamePieceIndex >= 0 && isIndexPiece(selectorPieces[lastNamePieceIndex])) {\n        lastNamePieceIndex -= 1;\n    }\n    return selectorPieces.slice(0, lastNamePieceIndex + 1).join(\"_\");\n}\n\nexport function processSkeletonSelector(skeletonSelector) {\n    const selectorWithoutPadding = skeletonSelector.substr(1);\n    const selectorPieces = selectorWithoutPadding.split(\"_\");\n    const [, indexPieces] = selectorPieces.reduce(reduceSekeletonSelector, [\n        0,\n        [\":root\", \":nth-child(1)\"],\n    ]);\n    return [extractPageName(selectorPieces), indexPieces.join(\">\")];\n}\n\nfunction handlePathElement(element) {\n    if (!element.id.match(SKELETON_SELECTOR)) {\n        return;\n    }\n\n    const [pageName, selector] = processSkeletonSelector(element.id);\n    const newSearchParams = new URLSearchParams();\n    newSearchParams.append(\"select\", selector);\n    const href = `/r/layouts-editor/?${newSearchParams.toString()}#/pages/${pageName}`;\n    addAnchor(element, element.id, href);\n}\n\nexport default function addBrickHyperLinks() {\n    createElementChangeListener(`[id^=\"s\"]`, handlePathElement);\n}\n"],"names":["SKELETON_SELECTOR","reduceSekeletonSelector","brickNameLength","indexPieces","piece","index","isNaN","length","pieceN","parseInt","extractPageName","selectorPieces","lastNamePieceIndex","slice","join","processSkeletonSelector","skeletonSelector","substr","split","reduce","handlePathElement","element","id","match","pageName","selector","newSearchParams","URLSearchParams","append","href","toString","elementPath","anchor","document","createElement","classList","add","target","createLinkElement","text","title","prepend","addAnchor","addBrickHyperLinks"],"sourceRoot":""}