{"version":3,"sources":["bare-rfc.js"],"names":["document","querySelector","requestFormPage","formType","dataset","formtype","newUrl","url","param","paramVal","urlString","split","baseURL","additionalURL","checkParam","RegExp","exec","newUrlParams","separator","urlParams","i","length","updateURLParameter","window","location","href","history","pushState"],"mappings":"AAAA,cAAC,WAGG,GAAOA,SAASC,cAAc,oCAA9B,CAIA,IAAMC,EAAkBF,SAASC,cAAc,uBACzCE,EAAWD,EAAgBE,QAAQC,SAEzC,GAAOF,GAAyB,YAAbA,EAAnB,CAIA,IAgCMG,EAhCqB,SAACC,EAAKC,EAAOC,GAEpC,IAAMC,EAAYH,EAAII,MAAM,KACtBC,EAAUF,EAAU,GACpBG,EAAgBH,EAAU,GAC1BI,EAAa,IAAIC,OAAO,OAAUP,EAAQ,aAAaQ,KAAKT,GAE9DU,EAAe,GACfC,EAAY,GAEhB,GAAoB,OAAfJ,GAAuBA,EAAW,KAAOL,EAC1C,OAAO,EAGX,GAAKI,EAID,IAFA,IAAMM,EAAYN,EAAcF,MAAM,KAE5BS,EAAI,EAAGA,EAAID,EAAUE,OAAQD,IAE9BD,EAAUC,GAAGT,MAAM,KAAK,KAAOH,IAEhCS,GAAgBC,EAAYC,EAAUC,GACtCF,EAAY,KAMxB,OAAON,EAAU,IAAMK,GADFC,EAAYV,EAAQ,IAAMC,EAEnD,CAEea,CACXC,OAAOC,SAASC,KAChB,WACAvB,EAAgBE,QAAQC,UAGvBC,GACDiB,OAAOG,QAAQC,UAAU,KAAM,KAAMrB,EAzCzC,CAPA,CAmDJ,CAxDC","file":"../bare-rfc.js","sourcesContent":["(function() {\n\n    // Only run on Bare RFC page\n    if ( ! document.querySelector('.page-template-template-bare-rfc') ) {\n        return;\n    }\n\n    const requestFormPage = document.querySelector('.request-form__page');\n    const formType = requestFormPage.dataset.formtype;\n\n    if ( ! formType || formType === 'default' ) {\n        return;\n    }\n\n    const updateURLParameter = (url, param, paramVal) => {\n\n        const urlString = url.split('?');\n        const baseURL = urlString[0];\n        const additionalURL = urlString[1];\n        const checkParam = new RegExp('[\\?&]' + param + '=([^&#]*)').exec(url);\n\n        let newUrlParams = '';\n        let separator = '';\n\n        if ( checkParam !== null && checkParam[1] === paramVal ) {\n            return false;\n        }\n\n        if ( additionalURL ) {\n\n            const urlParams = additionalURL.split('&');\n\n            for ( let i = 0; i < urlParams.length; i++ ){\n\n                if ( urlParams[i].split('=')[0] !== param ) {\n\n                    newUrlParams += separator + urlParams[i];\n                    separator = '&';\n                }\n            }\n        }\n\n        const updatedParam = separator + param + '=' + paramVal;\n        return baseURL + '?' + newUrlParams + updatedParam;\n    }\n\n    const newUrl = updateURLParameter(\n        window.location.href,\n        'rfc_type',\n        requestFormPage.dataset.formtype\n    );\n\n    if ( newUrl ) {\n        window.history.pushState(null, null, newUrl);\n    }\n\n})();\n"]}