{"version":3,"sources":["jsdelivr-header.js","/gh/makebuild-code/typeform@1.0.34/src/localization/rewrite-untranslated-links.js"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,ACNA,MAAM,kBAAoB,WACtB,MAAM,GACK,EAIL,EAAU,CAAC,KAAM,MAkEjB,EAAkB,CACpB,GAAI,CACA,cAAe,aACf,uBAAwB,sBACxB,2BAA4B,4BAI9B,EAAgB,IAAI,OAAO,MAAM,EAAQ,KAAK,gBAG9C,EAAmB,IAAI,OAAO,WAAW,EAAQ,KAAK,oDAAqD,KAC3G,EAAkB,IAAI,IA1EH,CACrB,IACA,YACA,MACA,4BACA,cACA,WACA,SACA,wBACA,SACA,qBACA,gBACA,WACA,WACA,kBACA,yBACA,uBACA,WACA,6CACA,cACA,uBACA,mBACA,yBACA,mBACA,gBACA,oBACA,+BACA,oBACA,cACA,eACA,2BACA,eACA,mBACA,2BACA,uBACA,iBACA,6BACA,cACA,WACA,cACA,oBACA,6BACA,6BACA,oBACA,oBACA,gBACA,cACA,sBACA,gCACA,yBACA,mBACA,qBACA,iBACA,6BACA,qBACA,SACA,eA+BJ,SAAS,EAAW,GAChB,MAAM,EARV,SAAyB,GACrB,MAAM,EAAS,EAAK,MAAM,GAE1B,OAAO,GAAU,EAAO,IAAM,KAAK,QAAQ,OAAQ,KAAO,CAC9D,CAIiB,CAAgB,GAEvB,EAAQ,EAAK,MAAM,GACzB,IAAK,EAAO,OAAO,EAEnB,MAAM,EAAS,EAAM,GACf,EAlBV,SAAuB,GACnB,OAAO,EAAK,OAAS,EAAI,EAAK,QAAQ,OAAQ,IAAM,CACxD,CAgBuB,CAAc,EAAM,IAAM,KACvC,EAAe,EAAW,MAAM,YAAY,GAC5C,GAAe,EAAgB,IAAW,CAAC,GAAG,GAGpD,GAAI,GAAe,IAAe,EAAc,OAAO,EAEvD,MAAM,EAAc,EACd,EAAc,EAAW,MAAM,EAAa,QAC5C,EACN,OAAO,EAAgB,IAAI,GAAe,EAAO,CACrD,CAEA,MAAO,CACH,aAAc,WACV,SAAS,iBAAiB,WAAW,QAAQ,IACzC,MAAM,EAAM,IAAI,IAAI,EAAK,KAAM,OAAO,SAAS,QAC/C,GAAI,EAAI,SAAW,OAAO,SAAS,OAAQ,OAE3C,MAAM,EAAO,EAAW,EAAI,UACxB,IAAS,EAAI,WAEjB,EAAK,aAAa,OAAQ,GAAG,IAAO,EAAI,SAAS,EAAI,QAEjD,GAAc,QAAQ,IAAI,qBAAsB,EAAI,SAAU,KAAM,KAEhF,EAEA,KAAM,WAC0B,YAAxB,SAAS,WACT,SAAS,iBAAiB,mBAAoB,IAAM,KAAK,gBAEzD,KAAK,cAEb,EAEP,CA5IyB,GA8I1B,kBAAkB","file":"/gh/makebuild-code/typeform@1.0.34/src/localization/rewrite-untranslated-links.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.48.0.\n * Original file: /gh/makebuild-code/typeform@1.0.34/src/localization/rewrite-untranslated-links.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const UntranslatedLinks = (function() {\n    const CONFIG = {\n        debug: false\n    };\n\n    // Secondary locales, served under /<locale>/\n    const LOCALES = ['es', 'fr'];\n\n    // English paths of pages translated in every secondary locale.\n    // Links to /<locale>/<path> for any other path are pointed at the English page.\n    const TRANSLATED_PAGES = [\n        '/',\n        '/about-us',\n        '/ai',\n        '/application-form-builder',\n        '/enterprise',\n        '/explore',\n        '/forms',\n        '/landing-page-builder',\n        '/legal',\n        '/platform-overview',\n        '/poll-builder',\n        '/pricing',\n        '/quizzes',\n        '/refer-a-friend',\n        '/refer-a-friend/invite',\n        '/roles/b2b-marketing',\n        '/surveys',\n        '/surveys/product-survey-questions-examples',\n        '/test-maker',\n        '/try/active-campaign',\n        '/try/application',\n        '/try/best-form-builder',\n        '/try/faq-builder',\n        '/try/feedback',\n        '/try/form-builder',\n        '/try/googleforms-alternative',\n        '/try/googlesheets',\n        '/try/growth',\n        '/try/hubspot',\n        '/try/jotform-alternative',\n        '/try/klaviyo',\n        '/try/landingpage',\n        '/try/landingpage-builder',\n        '/try/lead-generation',\n        '/try/mailchimp',\n        '/try/microsoft-alternative',\n        '/try/notion',\n        '/try/nps',\n        '/try/paypal',\n        '/try/poll-builder',\n        '/try/qualtrics-alternative',\n        '/try/questionnaire-builder',\n        '/try/quiz-builder',\n        '/try/registration',\n        '/try/research',\n        '/try/square',\n        '/try/survey-builder',\n        '/try/surveymonkey-alternative',\n        '/try/tally-alternative',\n        '/try/typeform-ai',\n        '/try/typeformbrand',\n        '/try/wordpress',\n        '/try/zohoforms-alternative',\n        '/typeform-startups',\n        '/video',\n        '/wait-list'\n    ];\n\n    // Collections whose slug is translated in a locale, keyed by locale, mapped to the English slug.\n    // Their items live under the translated slug (/es/plantillas/<item>), so links to items are left\n    // alone. Anything else under the slug is pointed at the English slug, since /plantillas/... 404s.\n    const LOCALIZED_SLUGS = {\n        es: {\n            '/plantillas': '/templates',\n            '/plantillas-category': '/templates-category',\n            '/plantillas-sub-category': '/templates-sub-category'\n        }\n    };\n\n    const localePattern = new RegExp(`^/(${LOCALES.join('|')})(/.*)?$`);\n    // A full typeform.com URL inside the path, e.g. /es/https://www.typeform.com/es/pricing.\n    // Without this, removing the locale leaves /https://www.typeform.com/es/pricing, which 404s.\n    const nestedUrlPattern = new RegExp(`^(?:/(?:${LOCALES.join('|')}))?/https?:/+(?:www\\\\.)?typeform\\\\.com(/.*)?$`, 'i');\n    const translatedPages = new Set(TRANSLATED_PAGES);\n\n    function normalizePath(path) {\n        return path.length > 1 ? path.replace(/\\/+$/, '') : path;\n    }\n\n    function unwrapNestedUrl(path) {\n        const nested = path.match(nestedUrlPattern);\n        // Collapse leading slashes so the result can never be a protocol-relative //host URL\n        return nested ? (nested[1] || '/').replace(/^\\/+/, '/') : path;\n    }\n\n    // The path a link should point at: unchanged for translated pages, English otherwise\n    function targetPath(pathname) {\n        const path = unwrapNestedUrl(pathname);\n\n        const match = path.match(localePattern);\n        if (!match) return path;\n\n        const locale = match[1];\n        const localePath = normalizePath(match[2] || '/');\n        const firstSegment = localePath.match(/^\\/[^/]*/)[0];\n        const englishSlug = (LOCALIZED_SLUGS[locale] || {})[firstSegment];\n\n        // A collection item under a translated slug, e.g. /es/plantillas/<item>\n        if (englishSlug && localePath !== firstSegment) return path;\n\n        const englishPath = englishSlug\n            ? englishSlug + localePath.slice(firstSegment.length)\n            : localePath;\n        return translatedPages.has(englishPath) ? path : englishPath;\n    }\n\n    return {\n        rewriteLinks: function() {\n            document.querySelectorAll('a[href]').forEach(link => {\n                const url = new URL(link.href, window.location.origin);\n                if (url.origin !== window.location.origin) return;\n\n                const path = targetPath(url.pathname);\n                if (path === url.pathname) return;\n\n                link.setAttribute('href', `${path}${url.search}${url.hash}`);\n\n                if (CONFIG.debug) console.log('UntranslatedLinks:', url.pathname, '->', path);\n            });\n        },\n\n        init: function() {\n            if (document.readyState === 'loading') {\n                document.addEventListener('DOMContentLoaded', () => this.rewriteLinks());\n            } else {\n                this.rewriteLinks();\n            }\n        }\n    };\n})();\n\nUntranslatedLinks.init();\n"]}