{
  "version": 3,
  "sources": ["../../renderer/src/i18n.js", "../../renderer/src/i18n-page.js"],
  "sourcesContent": ["/**\n * The editor/reader catalogue (#420), with Django's names and signatures so `makemessages` finds\n * every call. Importing it has no side effects: until a page calls `usePageCatalogue()`, calls\n * answer in source English, which is what `<scrolling-story>` gets (PCB-25).\n */\n\nconst CONTEXT_SEPARATOR = '\\x04';\nconst PAGE_CATALOGUE_ID = 'ss-catalogue';\n\nlet readSource = null;\nlet cache = null;\n\n/** Our own pages only: read `#ss-catalogue` (written by `partials/catalogue.html`) on first use. */\nexport function usePageCatalogue(doc = typeof document !== 'undefined' ? document : null) {\n    readSource = () => {\n        const el = doc ? doc.getElementById(PAGE_CATALOGUE_ID) : null;\n        if (!el || !el.textContent) return {};\n        try {\n            return JSON.parse(el.textContent) || {};\n        } catch {\n            return {};\n        }\n    };\n    cache = null;\n}\n\nfunction catalogue() {\n    if (!cache) cache = readSource ? readSource() : {};\n    return cache;\n}\n\n/** Two forms until a second language brings its own plural rule (design item 2). */\nfunction pluralidx(count) {\n    return count === 1 ? 0 : 1;\n}\n\nexport function gettext(message) {\n    const value = catalogue()[message];\n    if (typeof value === 'undefined' || value === '') return withoutContext(message);\n    return typeof value === 'string' ? value : value[0];\n}\n\n/** A `pgettext_noop` key untranslated: the English, never its context. */\nfunction withoutContext(message) {\n    const at = message.indexOf(CONTEXT_SEPARATOR);\n    return at < 0 ? message : message.slice(at + 1);\n}\n\nexport function ngettext(singular, plural, count) {\n    const value = catalogue()[singular];\n    if (typeof value === 'undefined') return count === 1 ? singular : plural;\n    if (!Array.isArray(value)) return value;\n    return value[pluralidx(count)] || (count === 1 ? singular : plural);\n}\n\nexport function pgettext(context, message) {\n    return gettext(context + CONTEXT_SEPARATOR + message);\n}\n\nexport function npgettext(context, singular, plural, count) {\n    let value = ngettext(context + CONTEXT_SEPARATOR + singular, context + CONTEXT_SEPARATOR + plural, count);\n    if (value.includes(CONTEXT_SEPARATOR)) value = ngettext(singular, plural, count);\n    return value;\n}\n\n/** Marks a msgid for `makemessages` on a constant; `gettext()` translates it where it's shown. */\nexport function gettext_noop(message) {\n    return message;\n}\n\n/** `gettext_noop` with a context: `gettext()` of what it returns reads the entry with that context. */\nexport function pgettext_noop(context, message) {\n    return context + CONTEXT_SEPARATOR + message;\n}\n\n/** `named`: `%(key)s` from `obj`. Positional: `%s` from `obj`, in order, as `django.interpolate` does. */\nexport function interpolate(fmt, obj, named) {\n    if (named) {\n        return fmt.replace(/%\\(\\w+\\)s/g, (match) => String(obj[match.slice(2, -2)]));\n    }\n    return fmt.replace(/%s/g, () => String(obj.shift()));\n}\n\n/** A test that swaps `#ss-catalogue` mid-run reads it again with this. */\nexport function _resetCatalogueCache() {\n    cache = null;\n}\n", "// #420: the component never loads this catalogue into a host page.\nimport {\n    gettext,\n    gettext_noop,\n    interpolate,\n    ngettext,\n    npgettext,\n    pgettext,\n    pgettext_noop,\n    usePageCatalogue,\n} from './i18n.js';\n\nusePageCatalogue(document);\n\nObject.assign(window, { gettext, ngettext, pgettext, npgettext, gettext_noop, pgettext_noop, interpolate });\n"],
  "mappings": "MAOA,IAAMA,EAAoB,eAEtBC,EAAa,KACbC,EAAQ,KAGL,SAASC,EAAiBC,EAAM,OAAO,SAAa,IAAc,SAAW,KAAM,CACtFH,EAAa,IAAM,CACf,IAAMI,EAAKD,EAAMA,EAAI,eAAeJ,CAAiB,EAAI,KACzD,GAAI,CAACK,GAAM,CAACA,EAAG,YAAa,MAAO,CAAC,EACpC,GAAI,CACA,OAAO,KAAK,MAAMA,EAAG,WAAW,GAAK,CAAC,CAC1C,MAAQ,CACJ,MAAO,CAAC,CACZ,CACJ,EACAH,EAAQ,IACZ,CAEA,SAASI,GAAY,CACjB,OAAKJ,IAAOA,EAAQD,EAAaA,EAAW,EAAI,CAAC,GAC1CC,CACX,CAGA,SAASK,EAAUC,EAAO,CACtB,OAAOA,IAAU,EAAI,EAAI,CAC7B,CAEO,SAASC,EAAQC,EAAS,CAC7B,IAAMC,EAA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AAc,cAAAC,EAAe,YAAAC,CAAY,CAAC",
  "names": ["PAGE_CATALOGUE_ID", "readSource", "cache", "usePageCatalogue", "doc", "el", "catalogue", "pluralidx", "count", "gettext", "message", "value", "withoutContext", "at", "ngettext", "singular", "plural", "pgettext", "context", "npgettext", "gettext_noop", "pgettext_noop", "interpolate", "fmt", "obj", "named", "match", "usePageCatalogue", "gettext", "ngettext", "pgettext", "npgettext", "gettext_noop", "pgettext_noop", "interpolate"]
}
