@protobase/ui 0.46.9 → 0.46.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. package/dist/app/create/create-page.js +2 -2
  2. package/dist/app/create/create-values.js +17 -2
  3. package/dist/app/nav-from-meta.js +7 -3
  4. package/dist/app-shell/sidebar.js +1 -1
  5. package/dist/auth/user-to-shell.js +4 -1
  6. package/dist/format/messages.js +2 -2
  7. package/dist/format/number.js +1 -1
  8. package/dist/forms/public-form-page.js +2 -2
  9. package/dist/package.js +1 -1
  10. package/dist/shell/assets/app-D_HKIf03.js +9 -0
  11. package/dist/shell/assets/export-worker-IJWS5-Wc.js +3 -0
  12. package/dist/shell/assets/{index-1Ue_dZiA.js → index-C6JUrzRh.js} +2 -2
  13. package/dist/shell/assets/{records-map-DPA8Y3C8.js → records-map-kVCCf9yO.js} +2 -2
  14. package/dist/shell/assets/{shared-protobase-ui-dWIf89ff.js → shared-protobase-ui-t4TJnncm.js} +2 -2
  15. package/dist/shell/index.html +3 -3
  16. package/dist/shell/protobase.shell.json +1 -1
  17. package/dist/shell/protobase.sw.js +2 -2
  18. package/dist/shell-source-maps/assets/app-D_HKIf03.js.map +1 -0
  19. package/dist/shell-source-maps/assets/export-worker-IJWS5-Wc.js.map +1 -0
  20. package/dist/shell-source-maps/assets/{index-1Ue_dZiA.js.map → index-C6JUrzRh.js.map} +1 -1
  21. package/dist/shell-source-maps/assets/{records-map-DPA8Y3C8.js.map → records-map-kVCCf9yO.js.map} +1 -1
  22. package/dist/shell-source-maps/assets/{shared-protobase-ui-dWIf89ff.js.map → shared-protobase-ui-t4TJnncm.js.map} +1 -1
  23. package/package.json +4 -4
  24. package/dist/shell/assets/app-axeIZ-10.js +0 -9
  25. package/dist/shell/assets/export-worker-ClACk00b.js +0 -3
  26. package/dist/shell-source-maps/assets/app-axeIZ-10.js.map +0 -1
  27. package/dist/shell-source-maps/assets/export-worker-ClACk00b.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export-worker-IJWS5-Wc.js","names":["text","text","text","text","message","fallback","activeLocale","setFallbackLocale","locale","formatTags","formatTag","enumLabel","labels","value","cache","cachedFormat","tag","id","key","make","defineMessages","values","message","catalogue","text$2","count","one","viewerZone","partsFormats","partsFormat","known","zone","format","wallClock","parts","ms","part","zoneOffset","clock","day","name","options","formatDate","zonedFormats","formatDateTime","formats","relative","units","formatRelativeTime","away","seconds","unit","size","text$1","isStoredFile","isFileDraft","fileShown","affixed","hints","text","displayValue","field","now","empty","isEmpty","relationLabel","column","fileText","mode","csvText","excelSerial","dateFormats","literal","affix","char","numberFormat","digits","code","numberCell","number","dateCell","type","xlsxCell","utf8Bom","needsQuotes","formulaStart","csvField","csvTextField","csvLine","fields","u8","u16","i32","fleb","fdeb","clim","freb","b","i","eb","r","j","_a","fl","revfl","_b","revfd","rev","x","hMap","s","cd","l","mb","le","co","rvb","sv","r_1","v","m","flt","fdt","flm","fdm","shft","p","slc","e","ec","err","msg","ind","nt","wbits","o","wbits16","hTree","t","d","t2","et","a","i0","i1","i2","maxSym","tr","mbt","ln","dt","lft","cst","i2_1","i2_2","i2_3","n","lc","c","cl","cli","cln","cls","w","clen","cf","wfblk","dat","pos","out","wblk","final","lf","dlt","mlb","df","ddt","mdb","_c","lclt","nlc","_d","lcdt","ndc","lcfreq","_e","lct","mlcb","nlcc","flen","bl","ftlen","dtlen","bs","lm","ll","dm","dl","llm","lcts","it","clct","len","li","sym","syms","dst","deo","dflt","st","pre","post","lst","lvl","opt","msk_1","plvl","prev","head","bs1_1","bs2_1","hsh","lc_1","wi","hv","imod","pimod","rem","ch_1","dif","maxn","maxd","ml","nl","mmd","md","ti","lin","din","crct","k","crc","cr","dopt","dict","newDat","mrg","wbytes","Deflate","opts","cb","f","endLen","chunk","newBuf","split","sync","ep","te","td","strToU8","latin1","ar_1","str","ar","ai","dbf","exfl","ex","wzh","fn","col","exl","ce","u","y","exf","wzf","ZipPassThrough","filename","ZipDeflate","_this","Zip","file","fl_1","com","hl_1","header","chks_1","pAll_1","_i","chks_2","chk","tr_1","ind_1","uf_1","nxt","cl_1","dd","bt","tl","invalidXml","escapeXml","columnLetters","letter","index","textCell","ref","style","xml","mainNs","relNs","packageRelNs","contentTypes","rootRels","workbookRels","sheetName","workbook","styles","numFmts","xfs","encoder","createXlsxWriter","zip","error","onChunk","add","path","sheet","worksheet","cols","width","letters","styleOf","cellXml","cell","rowNumber","row","cells","typedText","columnWidths","columns","longest","records","record","createCsvBuilder","plan","createXlsxBuilder","writer","start","createExportBuilder","joined","bytes","chunks","offset","handle","builder","scope","event"],"sources":["../../src/locale/active-locale.ts","../../../schema/src/enum-label.ts","../../src/format/intl-cache.ts","../../src/locale/messages.ts","../../src/format/messages.ts","../../src/format/zone.ts","../../src/format/date.ts","../../src/live/messages.ts","../../src/live/file-values.ts","../../src/live/display-value.ts","../../src/app/export/cells.ts","../../src/app/export/csv.ts","../../../../node_modules/.bun/fflate@0.8.3/node_modules/fflate/esm/browser.js","../../src/app/export/xlsx.ts","../../src/app/export/builder.ts","../../src/app/export/builder-port.ts","../../src/app/export/export-worker.ts"],"sourcesContent":["import { pickLocale, type Locale } from '@protobase/schema/internal'\n\n// The built-in screens read one locale, so plain functions (formats, messages) need no context: the app's when its\n// `/meta` names one, else the fallback the app starts with, the browser's language unless given. Both only ever get\n// set to what the app decides on each render, so a part of the tree that renders later never sees another one.\nlet fallback: Locale = 'en'\nlet app: Locale | undefined\n\n/** The language the screens are in now. */\nexport const activeLocale = (): Locale => app ?? fallback\n\n/** The language the screens are in when the app sets none: the browser's, or the one the app was given. */\nexport const setFallbackLocale = (locale: Locale) => {\n fallback = locale\n}\n\n/** The language the app sets for everyone, from its `/meta`; undefined when it sets none. */\nexport const setAppLocale = (locale: Locale | undefined) => {\n app = locale\n}\n\n/** The browser's language when the screens come in it, else English. */\nexport const browserLocale = (languages = globalThis.navigator?.languages ?? []) => pickLocale(languages)\n\n// The language tag numbers and dates are written with: English as in Ireland and Britain (`6 Oct 2026`, `1,234.5`).\nconst formatTags: Record<Locale, string> = { en: 'en-GB', nl: 'nl-NL' }\n\n/** The language tag `Intl` formats numbers and dates with, for the active locale. */\nexport const formatTag = () => formatTags[activeLocale()]\n","/** How an enum value reads: its label from the view's `valueLabels`, else the stored value unchanged (`co_signer`). */\nexport const enumLabel = (value: string, labels?: Record<string, string>) => labels?.[value] ?? value\n","import { formatTag } from '../locale/active-locale'\n\nconst cache = new Map<string, unknown>()\n\n/** One `Intl` formatter per language tag and `key`, made with `make` for the active locale's tag the first time. */\nexport const cachedFormat = <T>(key: string, make: (tag: string) => T): T => {\n const tag = formatTag()\n const id = `${tag}|${key}`\n if (!cache.has(id)) cache.set(id, make(tag))\n return cache.get(id) as T\n}\n","import type { Locale } from '@protobase/schema/internal'\nimport { activeLocale } from './active-locale'\n\n/** A built-in text: fixed, or made from the values it names, such as a count. */\ntype Message = string | ((...values: never[]) => string)\n\n/** A translation of `M`: every message of it, taking the same values. */\nexport type Translation<M extends Record<string, Message>> = { [K in keyof M]: M[K] extends string ? string : M[K] }\n\ntype Values<T> = T extends (...values: infer V) => string ? V : []\n\n/**\n * An area's built-in texts in every language the screens come in, keyed by id: the lookup returns the one for the\n * active locale, `text('search')` or `text('rows', 3)`. Dutch must translate every English text, which the types check.\n */\nexport const defineMessages = <M extends Record<string, Message>>(catalogue: { en: M } & Record<Exclude<Locale, 'en'>, Translation<M>>) =>\n <K extends keyof M>(id: K, ...values: Values<M[K]>): string => {\n const message = (catalogue[activeLocale()] as M)[id]\n return typeof message === 'function' ? (message as (...values: unknown[]) => string)(...values) : (message as string)\n }\n","import { defineMessages } from '../locale/messages'\n\nexport const text = defineMessages({\n en: {\n rows: (count: string, one: boolean) => `${count} ${one ? 'row' : 'rows'}`,\n aboutRows: (count: string) => `about ${count} rows`,\n secondsAgo: (count: number) => `${count} s ago`,\n minutesAgo: (count: number) => `${count} min ago`,\n hoursAgo: (count: number) => `${count} h ago`,\n daysAgo: (count: number) => `${count} d ago`,\n justNow: 'just now',\n },\n nl: {\n rows: (count: string, one: boolean) => `${count} ${one ? 'rij' : 'rijen'}`,\n aboutRows: (count: string) => `ongeveer ${count} rijen`,\n secondsAgo: (count: number) => `${count} s geleden`,\n minutesAgo: (count: number) => `${count} min geleden`,\n hoursAgo: (count: number) => `${count} u geleden`,\n daysAgo: (count: number) => `${count} d geleden`,\n justNow: 'zojuist',\n },\n})\n","import { cachedFormat } from './intl-cache'\n\n// Times show in the viewer's time zone, the browser's; dates (`YYYY-MM-DD`, no time) have no zone and never shift.\n\n/** The viewer's IANA time zone, such as `Europe/Amsterdam`. */\nexport const viewerZone = () => Intl.DateTimeFormat().resolvedOptions().timeZone\n\nconst partsFormats = new Map<string, Intl.DateTimeFormat>()\n\nconst partsFormat = (zone: string) => {\n const known = partsFormats.get(zone)\n if (known) return known\n const format = new Intl.DateTimeFormat('en-US', { timeZone: zone, hourCycle: 'h23', year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', second: '2-digit' })\n partsFormats.set(zone, format)\n return format\n}\n\n// The wall clock of `zone` at `ms`, as numbers\nconst wallClock = (ms: number, zone: string) => {\n const parts = Object.fromEntries(partsFormat(zone).formatToParts(ms).map((part) => [part.type, part.value]))\n return { year: Number(parts.year), month: Number(parts.month), day: Number(parts.day), hour: Number(parts.hour), minute: Number(parts.minute), second: Number(parts.second) }\n}\n\n/** How far `zone`'s clock is ahead of UTC at `ms`, in milliseconds: 7 200 000 for Amsterdam in summer. */\nexport const zoneOffset = (ms: number, zone: string) => {\n const clock = wallClock(ms, zone)\n const asUtc = Date.UTC(clock.year, clock.month - 1, clock.day, clock.hour, clock.minute, clock.second)\n return asUtc - Math.floor(ms / 1000) * 1000\n}\n\nconst pad = (value: number) => String(value).padStart(2, '0')\n\n/** The day `ms` falls on in `zone`, as `YYYY-MM-DD`. */\nexport const dayIn = (ms: number, zone: string) => {\n const clock = wallClock(ms, zone)\n return `${clock.year}-${pad(clock.month)}-${pad(clock.day)}`\n}\n\n/** The instant `zone`'s clock reads `wall`, a wall-clock time written as if it were UTC milliseconds. */\nexport const instantAt = (wall: number, zone: string) => {\n // The offset at `wall` read as UTC is right unless the zone changes its clock in the hours between; a second pass fixes that\n const guess = wall - zoneOffset(wall, zone)\n return wall - zoneOffset(guess, zone)\n}\n\n/** The instant `day` (`YYYY-MM-DD`) starts in `zone`: its local midnight. */\nexport const startOfDayIn = (day: string, zone: string) => instantAt(Date.parse(`${day}T00:00:00Z`), zone)\n\n/** The zone a time is shown in, as its hover label says: \"Europe/Amsterdam (GMT+2)\", or \"UTC\". */\nexport const zoneLabel = (ms: number, zone: string) => {\n const named = cachedFormat(`zoneName:${zone}`, (tag) => new Intl.DateTimeFormat(tag, { timeZone: zone, timeZoneName: 'shortOffset' }))\n const name = named.formatToParts(ms).find((part) => part.type === 'timeZoneName')?.value ?? zone\n return zone === 'UTC' || zone === 'Etc/UTC' ? 'UTC' : `${zone} (${name})`\n}\n","import { cachedFormat } from './intl-cache'\nimport { text } from './messages'\nimport { viewerZone } from './zone'\n\n// Dates, months and weekdays are zone-free days, kept in UTC; times are the viewer's, in `zone`.\nconst dateFormat = (name: string, options: Intl.DateTimeFormatOptions) => () => cachedFormat(`date:${name}`, (tag) => new Intl.DateTimeFormat(tag, { ...options, timeZone: 'UTC' }))\nconst day = dateFormat('day', { day: 'numeric', month: 'short', year: 'numeric' })\nconst dayShort = dateFormat('dayShort', { day: 'numeric', month: 'short' })\nconst month = dateFormat('month', { month: 'long', year: 'numeric' })\nconst monthName = dateFormat('monthName', { month: 'long' })\nconst weekday = dateFormat('weekday', { weekday: 'short' })\nconst weekdayDate = dateFormat('weekdayDate', { weekday: 'long', day: 'numeric', month: 'short', year: 'numeric' })\n\nexport const formatDate = (ms: number) => day().format(ms)\n\nexport const formatDayShort = (ms: number) => dayShort().format(ms)\n\nconst zonedFormats = (zone: string) =>\n cachedFormat(`zoned:${zone}`, (tag) => ({\n day: new Intl.DateTimeFormat(tag, { day: 'numeric', month: 'short', year: 'numeric', timeZone: zone }),\n time: new Intl.DateTimeFormat(tag, { hour: '2-digit', minute: '2-digit', hour12: false, timeZone: zone }),\n }))\n\n/** \"6 Oct 2026, 16:32\": an instant on the clock of `zone`, the viewer's unless given. */\nexport const formatDateTime = (ms: number, zone = viewerZone()) => {\n const formats = zonedFormats(zone)\n return `${formats.day.format(ms)}, ${formats.time.format(ms)}`\n}\n\n/** \"October 2026\". */\nexport const formatMonth = (ms: number) => month().format(ms)\n\n/** \"October\". */\nexport const formatMonthName = (ms: number) => monthName().format(ms)\n\n/** \"October – December 2026\": the months from `from` to `to`, both included. */\nexport const formatMonthRange = (from: number, to: number) => month().formatRange(from, to)\n\n/** \"Mon\". */\nexport const formatWeekday = (ms: number) => weekday().format(ms)\n\n/** \"Monday, 12 Oct 2026\". */\nexport const formatWeekdayDate = (ms: number) => weekdayDate().format(ms)\n\n/** \"12–18 Oct 2026\", \"28 Dec 2026 – 3 Jan 2027\": the days from `from` to `to`, both included. */\nexport const formatDayRange = (from: number, to: number) => day().formatRange(from, to)\n\n/** \"09:30\": an instant's time on the clock of `zone`, the viewer's unless given. */\nexport const formatTime = (ms: number, zone = viewerZone()) => zonedFormats(zone).time.format(ms)\n\nexport const formatAgo = (seconds: number) => {\n if (seconds < 60) return text('secondsAgo', seconds)\n if (seconds < 3600) return text('minutesAgo', Math.floor(seconds / 60))\n if (seconds < 86_400) return text('hoursAgo', Math.floor(seconds / 3600))\n return text('daysAgo', Math.floor(seconds / 86_400))\n}\n\nconst relative = () => cachedFormat('relative', (tag) => new Intl.RelativeTimeFormat(tag, { numeric: 'auto' }))\n\nconst units: Array<[Intl.RelativeTimeFormatUnit, number]> = [\n ['year', 31_536_000],\n ['month', 2_592_000],\n ['day', 86_400],\n ['hour', 3600],\n ['minute', 60],\n]\n\n/** \"5 minutes ago\", \"yesterday\", \"in 3 hours\"; `seconds` is how long ago it was, negative for a time to come. */\nexport const formatRelativeTime = (seconds: number) => {\n const away = Math.abs(seconds)\n const [unit, size] = units.find(([, size]) => away >= size) ?? ['second', 1]\n if (unit === 'second' && away < 45) return text('justNow')\n return relative().format(-Math.sign(seconds) * Math.floor(away / size), unit)\n}\n","import { defineMessages } from '../locale/messages'\n\nexport const text = defineMessages({\n en: {\n yes: 'Yes',\n no: 'No',\n shownIn: (zone: string) => `Shown in ${zone}`,\n fileMissing: 'File missing',\n },\n nl: {\n yes: 'Ja',\n no: 'Nee',\n shownIn: (zone: string) => `Getoond in ${zone}`,\n fileMissing: 'Bestand ontbreekt',\n },\n})\n","import type { StoredFile, UploadResult } from '@protobase/client'\nimport type { FieldModel } from '@protobase/schema'\nimport { text } from './messages'\n\n/** A file uploaded in the form and not yet saved: the ticket the save sends, and a local preview while there is one. */\nexport type FileDraft = { uploaded: UploadResult; preview?: string }\n\nexport const isStoredFile = (value: unknown): value is StoredFile =>\n typeof value === 'object' && value !== null && typeof (value as { uri?: unknown }).uri === 'string'\n\nexport const isFileDraft = (value: unknown): value is FileDraft =>\n typeof value === 'object' && value !== null && typeof (value as { uploaded?: { value?: unknown } }).uploaded?.value === 'string'\n\n/** What a file field shows: its name, type and size, whether stored or just uploaded; `undefined` when empty. */\nexport const fileShown = (value: unknown) => {\n if (isFileDraft(value)) return { ...value.uploaded.file, ...(value.preview && { url: value.preview }), corrected: value.uploaded.corrected }\n if (!isStoredFile(value)) return undefined\n if ('missing' in value) return { name: text('fileMissing'), type: '', missing: true as const }\n return value\n}\n\nconst units = ['bytes', 'kB', 'MB', 'GB']\n\n/** `48 kB`, `1.2 MB`: decimal units, like the field's `maxSize`. */\nexport const formatSize = (bytes: number) => {\n let size = bytes\n let unit = 0\n while (size >= 1000 && unit < units.length - 1) {\n size /= 1000\n unit += 1\n }\n return unit === 0 ? `${bytes} ${bytes === 1 ? 'byte' : 'bytes'}` : `${size < 10 ? size.toFixed(1) : Math.round(size)} ${units[unit]}`\n}\n\n/** Raster images the browser shows; SVG is never shown, since it can carry scripts. */\nexport const isPreviewable = (type: string) => type.startsWith('image/') && type !== 'image/svg+xml'\n\n/** Where a picture is drawn, in CSS pixels. */\nexport type ImageBox = { width: number; height: number }\n\n// An image for a box needs this many pixels per CSS pixel to stay sharp on a high-density screen.\nconst density = 2\n// A side a variant leaves unbounded counts as larger than any image.\nconst unbounded = 100_000\n\ntype Variant = { url: string; width?: number; height?: number }\n\nconst covers = (variant: Variant, box: ImageBox) =>\n (variant.width !== undefined || variant.height !== undefined) &&\n (variant.width ?? unbounded) >= box.width * density &&\n (variant.height ?? unbounded) >= box.height * density\n\nconst area = (variant: Variant) => (variant.width ?? unbounded) * (variant.height ?? unbounded)\n\n/**\n * The picture of a file for `box`: the link of its smallest variant large enough for it, else the file's own, with its\n * placeholder; `undefined` for a file that is no raster image with a link.\n */\nexport const shownImage = (value: unknown, box: ImageBox) => {\n const file = fileShown(value)\n if (!file || 'missing' in file || !file.url || !isPreviewable(file.type)) return undefined\n const variants: Variant[] = 'variants' in file && file.variants ? Object.values(file.variants) : []\n const best = variants.filter((variant) => covers(variant, box)).sort((a, b) => area(a) - area(b))[0]\n return { url: best?.url ?? file.url, ...('placeholder' in file && file.placeholder !== undefined && { placeholder: file.placeholder }) }\n}\n\n/** The file input's `accept`: the field's allowed types, or nothing when it takes any. */\nexport const acceptOf = (field: FieldModel) => {\n const accept = field.file?.accept ?? []\n return accept.length === 0 || accept.includes('*/*') ? undefined : accept.join(',')\n}\n\n/** What a save sends for a file field: the ticket of a new upload, `null` to clear it, the stored URI to keep it. */\nexport const filePatchValue = (draft: unknown) => {\n if (isFileDraft(draft)) return draft.uploaded.value\n if (isStoredFile(draft)) return draft.uri\n return null\n}\n\n/** Whether a file field's draft changes what is stored. */\nexport const fileDiffers = (draft: unknown, stored: unknown) => {\n if (isFileDraft(draft)) return true\n const uri = (value: unknown) => (isStoredFile(value) ? value.uri : null)\n return uri(draft) !== uri(stored)\n}\n","import { enumLabel, type FieldModel, type FieldViewModel } from '@protobase/schema'\nimport { formatDate, formatDateTime, formatRelativeTime } from '../format/date'\nimport { viewerZone, zoneLabel } from '../format/zone'\nimport { fileShown } from './file-values'\nimport { formatTag } from '../locale/active-locale'\nimport { text as message } from './messages'\n\n// A number with the view's prefix before it and suffix after it, such as `€1,200` or `120 m²`.\nconst affixed = (text: string, hints: FieldViewModel) => `${hints.prefix ?? ''}${text}${hints.suffix ?? ''}`\n\n/**\n * A read-only rendering of a stored value, following the view's prefix, suffix, decimals, format and value label hints; a\n * timestamp on the clock of `zone`, the viewer's unless given.\n */\nexport const displayValue = (field: FieldModel, value: unknown, hints: FieldViewModel = {}, zone = viewerZone(), now = Date.now()) => {\n if (value === null || value === undefined || value === '') return '—'\n switch (field.type) {\n case 'boolean':\n return value ? message('yes') : message('no')\n case 'file':\n return fileShown(value)?.name ?? '—'\n case 'enum':\n return enumLabel(String(value), hints.valueLabels)\n case 'timestamp': {\n const ms = Date.parse(String(value))\n return hints.format === 'relative' ? formatRelativeTime(Math.round((now - ms) / 1000)) : formatDateTime(ms, zone)\n }\n case 'date':\n return formatDate(Date.parse(String(value)))\n case 'decimal': {\n const text = hints.decimals === undefined ? String(value) : Number(value).toFixed(hints.decimals)\n if (hints.format === 'percent') return `${Number(value)}%`\n return affixed(Number(text).toLocaleString(formatTag(), { minimumFractionDigits: hints.decimals ?? 0, maximumFractionDigits: hints.decimals ?? 20 }), hints)\n }\n case 'integer':\n case 'bigint':\n return affixed(String(value), hints)\n default:\n return typeof value === 'object' ? JSON.stringify(value) : String(value)\n }\n}\n\n/** The hover label of a shown value: the time zone a timestamp is shown in, or its exact time when shown relative; nothing for other values. */\nexport const valueTitle = (field: FieldModel, value: unknown, zone = viewerZone(), hints: FieldViewModel = {}) => {\n if (field.type !== 'timestamp' || typeof value !== 'string') return undefined\n const ms = Date.parse(value)\n if (Number.isNaN(ms)) return undefined\n if (hints.format === 'relative') return formatDateTime(ms, zone)\n return message('shownIn', zoneLabel(ms, zone))\n}\n","import type { FieldModel, FieldViewModel } from '@protobase/schema'\nimport type { RelatedLabels } from '@protobase/client'\nimport { displayValue } from '../../live/display-value'\nimport { fileShown, isStoredFile } from '../../live/file-values'\nimport { viewerZone, zoneOffset } from '../../format/zone'\n\n/** `shown` exports values as the list shows them (labels, formatted dates and numbers), `raw` as the API stores them. */\nexport type ExportMode = 'shown' | 'raw'\n\n/** One column of an export: the field it reads, its header (the field's label) and the view's hints for it. */\nexport type ExportColumn = { name: string; header: string; field: FieldModel; hints: FieldViewModel }\n\n/** A typed spreadsheet cell; a date is a number of days since 1900 with a date format, as Excel stores it. */\nexport type Cell = { kind: 'empty' } | { kind: 'text'; value: string } | { kind: 'number'; value: number; format?: string } | { kind: 'boolean'; value: boolean }\n\nconst empty: Cell = { kind: 'empty' }\nconst text = (value: string): Cell => ({ kind: 'text', value })\n\nconst isEmpty = (value: unknown) => value === null || value === undefined || value === ''\n\nconst relationLabel = (column: ExportColumn, value: unknown, labels: RelatedLabels) => labels[column.name]?.[String(value)] ?? String(value)\n\n// A file's name as the list shows it; raw, its stored `uri`, since a private file's URL is signed for an hour or two.\nconst fileText = (value: unknown, mode: ExportMode) => {\n if (!isStoredFile(value)) return String(value)\n return mode === 'raw' ? value.uri : (fileShown(value)?.name ?? value.uri)\n}\n\n/** A value as one CSV field: as the list shows it, or as the API sends it, empty for no value. */\nexport const csvText = (column: ExportColumn, value: unknown, labels: RelatedLabels, mode: ExportMode) => {\n if (isEmpty(value)) return ''\n const { field, hints } = column\n if (field.type === 'file') return fileText(value, mode)\n if (field.type === 'relation') return mode === 'shown' ? relationLabel(column, value, labels) : String(value)\n if (mode === 'shown') return displayValue(field, value, { ...hints, format: undefined })\n if (typeof value === 'object') return JSON.stringify(value)\n return String(value)\n}\n\n// Excel counts days from 30 December 1899 and has no time zones: a shown time is on the viewer's clock, as the list shows\n// it, and a raw one in UTC, as the API sends it.\nconst excelEpochDays = 25_569\nconst msPerDay = 86_400_000\nconst excelSerial = (ms: number) => ms / msPerDay + excelEpochDays\n\nconst dateFormats = { shown: { date: 'd mmm yyyy', timestamp: 'd mmm yyyy, hh:mm' }, raw: { date: 'yyyy-mm-dd', timestamp: 'yyyy-mm-dd hh:mm:ss' } }\n\n// Every character of a prefix or suffix escaped, so Excel shows it as it is around the number.\nconst literal = (affix: string | undefined) => [...(affix ?? '')].map((char) => `\\\\${char}`).join('')\n\n/** The Excel number format that shows a number as the list does: its decimals, prefix and suffix, or a percent sign. */\nexport const numberFormat = (hints: FieldViewModel) => {\n if (hints.format === 'percent') return 'General\\\\%'\n const digits = hints.decimals === undefined ? 'General' : hints.decimals > 0 ? `#,##0.${'0'.repeat(hints.decimals)}` : '#,##0'\n const code = `${literal(hints.prefix)}${digits}${literal(hints.suffix)}`\n return code === 'General' ? undefined : code\n}\n\n// A number when the text holds one exactly enough to calculate with; a bigint past 2^53 stays text, so no digit is lost.\nconst numberCell = (column: ExportColumn, value: unknown, mode: ExportMode): Cell => {\n const number = Number(value)\n if (!Number.isFinite(number)) return text(String(value))\n if (column.field.type === 'bigint' && !Number.isSafeInteger(number)) return text(String(value))\n const format = mode === 'shown' ? numberFormat(column.hints) : undefined\n return format ? { kind: 'number', value: number, format } : { kind: 'number', value: number }\n}\n\nconst dateCell = (type: 'date' | 'timestamp', value: unknown, mode: ExportMode, zone: string): Cell => {\n const ms = Date.parse(String(value))\n if (Number.isNaN(ms)) return text(String(value))\n const clock = type === 'timestamp' && mode === 'shown' ? ms + zoneOffset(ms, zone) : ms\n return { kind: 'number', value: excelSerial(clock), format: dateFormats[mode][type] }\n}\n\n/** A value as one typed Excel cell: numbers, dates and booleans as such, labels or stored values as text. */\nexport const xlsxCell = (column: ExportColumn, value: unknown, labels: RelatedLabels, mode: ExportMode, zone = viewerZone()): Cell => {\n if (isEmpty(value)) return empty\n const { field } = column\n switch (field.type) {\n case 'boolean':\n return { kind: 'boolean', value: Boolean(value) }\n case 'integer':\n case 'bigint':\n case 'decimal':\n return numberCell(column, value, mode)\n case 'date':\n case 'timestamp':\n return dateCell(field.type, value, mode, zone)\n case 'relation':\n if (mode === 'shown') return text(relationLabel(column, value, labels))\n return typeof value === 'number' ? { kind: 'number', value } : text(String(value))\n default:\n return text(csvText(column, value, labels, mode))\n }\n}\n","/** The UTF-8 byte order mark, which makes Excel read a CSV file as UTF-8 instead of the system's code page. */\nexport const utf8Bom = new Uint8Array([0xef, 0xbb, 0xbf])\n\nconst needsQuotes = /[\",\\r\\n]/\n\n// Text Excel would run as a formula when the file is opened, such as `=HYPERLINK(...)`: a leading apostrophe keeps it\n// text (OWASP's advice on CSV injection).\nconst formulaStart = /^[=+\\-@\\t\\r]/\n\n/** One field as RFC 4180 writes it: in double quotes, its quotes doubled, when it holds a comma, quote or line break. */\nexport const csvField = (value: string) => (needsQuotes.test(value) ? `\"${value.replaceAll('\"', '\"\"')}\"` : value)\n\n/** Text from a text field, kept from running as a formula in a spreadsheet. */\nexport const csvTextField = (value: string) => csvField(formulaStart.test(value) ? `'${value}` : value)\n\n/** One record, CRLF-terminated as RFC 4180 has it. */\nexport const csvLine = (fields: string[]) => `${fields.join(',')}\\r\\n`\n","// DEFLATE is a complex format; to read this code, you should probably check the RFC first:\n// https://tools.ietf.org/html/rfc1951\n// You may also wish to take a look at the guide I made about this program:\n// https://gist.github.com/101arrowz/253f31eb5abc3d9275ab943003ffecad\n// Some of the following code is similar to that of UZIP.js:\n// https://github.com/photopea/UZIP.js\n// However, the vast majority of the codebase has diverged from UZIP.js to increase performance and reduce bundle size.\n// Sometimes 0 will appear where -1 would be more appropriate. This is because using a uint\n// is better for memory in most engines (I *think*).\nvar ch2 = {};\nvar wk = (function (c, id, msg, transfer, cb) {\n var w = new Worker(ch2[id] || (ch2[id] = URL.createObjectURL(new Blob([\n c + ';addEventListener(\"error\",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})'\n ], { type: 'text/javascript' }))));\n w.onmessage = function (e) {\n var d = e.data, ed = d.$e$;\n if (ed) {\n var err = new Error(ed[0]);\n err['code'] = ed[1];\n err.stack = ed[2];\n cb(err, null);\n }\n else\n cb(null, d);\n };\n w.postMessage(msg, transfer);\n return w;\n});\n\n// aliases for shorter compressed code (most minifers don't do this)\nvar u8 = Uint8Array, u16 = Uint16Array, i32 = Int32Array;\n// fixed length extra bits\nvar fleb = new u8([0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0, /* unused */ 0, 0, /* impossible */ 0]);\n// fixed distance extra bits\nvar fdeb = new u8([0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, /* unused */ 0, 0]);\n// code length index map\nvar clim = new u8([16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]);\n// get base, reverse index map from extra bits\nvar freb = function (eb, start) {\n var b = new u16(31);\n for (var i = 0; i < 31; ++i) {\n b[i] = start += 1 << eb[i - 1];\n }\n // numbers here are at max 18 bits\n var r = new i32(b[30]);\n for (var i = 1; i < 30; ++i) {\n for (var j = b[i]; j < b[i + 1]; ++j) {\n r[j] = ((j - b[i]) << 5) | i;\n }\n }\n return { b: b, r: r };\n};\nvar _a = freb(fleb, 2), fl = _a.b, revfl = _a.r;\n// we can ignore the fact that the other numbers are wrong; they never happen anyway\nfl[28] = 258, revfl[258] = 28;\nvar _b = freb(fdeb, 0), fd = _b.b, revfd = _b.r;\n// map of value to reverse (assuming 16 bits)\nvar rev = new u16(32768);\nfor (var i = 0; i < 32768; ++i) {\n // reverse table algorithm from SO\n var x = ((i & 0xAAAA) >> 1) | ((i & 0x5555) << 1);\n x = ((x & 0xCCCC) >> 2) | ((x & 0x3333) << 2);\n x = ((x & 0xF0F0) >> 4) | ((x & 0x0F0F) << 4);\n rev[i] = (((x & 0xFF00) >> 8) | ((x & 0x00FF) << 8)) >> 1;\n}\n// create huffman tree from u8 \"map\": index -> code length for code index\n// mb (max bits) must be at most 15\n// TODO: optimize/split up?\nvar hMap = (function (cd, mb, r) {\n var s = cd.length;\n // index\n var i = 0;\n // u16 \"map\": index -> # of codes with bit length = index\n var l = new u16(mb);\n // length of cd must be 288 (total # of codes)\n for (; i < s; ++i) {\n if (cd[i])\n ++l[cd[i] - 1];\n }\n // u16 \"map\": index -> minimum code for bit length = index\n var le = new u16(mb);\n for (i = 1; i < mb; ++i) {\n le[i] = (le[i - 1] + l[i - 1]) << 1;\n }\n var co;\n if (r) {\n // u16 \"map\": index -> number of actual bits, symbol for code\n co = new u16(1 << mb);\n // bits to remove for reverser\n var rvb = 15 - mb;\n for (i = 0; i < s; ++i) {\n // ignore 0 lengths\n if (cd[i]) {\n // num encoding both symbol and bits read\n var sv = (i << 4) | cd[i];\n // free bits\n var r_1 = mb - cd[i];\n // start value\n var v = le[cd[i] - 1]++ << r_1;\n // m is end value\n for (var m = v | ((1 << r_1) - 1); v <= m; ++v) {\n // every 16 bit value starting with the code yields the same result\n co[rev[v] >> rvb] = sv;\n }\n }\n }\n }\n else {\n co = new u16(s);\n for (i = 0; i < s; ++i) {\n if (cd[i]) {\n co[i] = rev[le[cd[i] - 1]++] >> (15 - cd[i]);\n }\n }\n }\n return co;\n});\n// fixed length tree\nvar flt = new u8(288);\nfor (var i = 0; i < 144; ++i)\n flt[i] = 8;\nfor (var i = 144; i < 256; ++i)\n flt[i] = 9;\nfor (var i = 256; i < 280; ++i)\n flt[i] = 7;\nfor (var i = 280; i < 288; ++i)\n flt[i] = 8;\n// fixed distance tree\nvar fdt = new u8(32);\nfor (var i = 0; i < 32; ++i)\n fdt[i] = 5;\n// fixed length map\nvar flm = /*#__PURE__*/ hMap(flt, 9, 0), flrm = /*#__PURE__*/ hMap(flt, 9, 1);\n// fixed distance map\nvar fdm = /*#__PURE__*/ hMap(fdt, 5, 0), fdrm = /*#__PURE__*/ hMap(fdt, 5, 1);\n// find max of array\nvar max = function (a) {\n var m = a[0];\n for (var i = 1; i < a.length; ++i) {\n if (a[i] > m)\n m = a[i];\n }\n return m;\n};\n// read d, starting at bit p and mask with m\nvar bits = function (d, p, m) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8)) >> (p & 7)) & m;\n};\n// read d, starting at bit p continuing for at least 16 bits\nvar bits16 = function (d, p) {\n var o = (p / 8) | 0;\n return ((d[o] | (d[o + 1] << 8) | (d[o + 2] << 16)) >> (p & 7));\n};\n// get end of byte\nvar shft = function (p) { return ((p + 7) / 8) | 0; };\n// typed array slice - allows garbage collector to free original reference,\n// while being more compatible than .slice\nvar slc = function (v, s, e) {\n if (s == null || s < 0)\n s = 0;\n if (e == null || e > v.length)\n e = v.length;\n // can't use .constructor in case user-supplied\n return new u8(v.subarray(s, e));\n};\n/**\n * Codes for errors generated within this library\n */\nexport var FlateErrorCode = {\n UnexpectedEOF: 0,\n InvalidBlockType: 1,\n InvalidLengthLiteral: 2,\n InvalidDistance: 3,\n StreamFinished: 4,\n NoStreamHandler: 5,\n InvalidHeader: 6,\n NoCallback: 7,\n InvalidUTF8: 8,\n ExtraFieldTooLong: 9,\n InvalidDate: 10,\n FilenameTooLong: 11,\n StreamFinishing: 12,\n InvalidZipData: 13,\n UnknownCompressionMethod: 14\n};\n// error codes\nvar ec = [\n 'unexpected EOF',\n 'invalid block type',\n 'invalid length/literal',\n 'invalid distance',\n 'stream finished',\n 'no stream handler',\n , // determined by compression function\n 'no callback',\n 'invalid UTF-8 data',\n 'extra field too long',\n 'date not in range 1980-2099',\n 'filename too long',\n 'stream finishing',\n 'invalid zip data'\n // determined by unknown compression method\n];\n;\nvar err = function (ind, msg, nt) {\n var e = new Error(msg || ec[ind]);\n e.code = ind;\n if (Error.captureStackTrace)\n Error.captureStackTrace(e, err);\n if (!nt)\n throw e;\n return e;\n};\n// expands raw DEFLATE data\nvar inflt = function (dat, st, buf, dict) {\n // source length dict length\n var sl = dat.length, dl = dict ? dict.length : 0;\n if (!sl || st.f && !st.l)\n return buf || new u8(0);\n var noBuf = !buf;\n // have to estimate size\n var resize = noBuf || st.i != 2;\n // no state\n var noSt = st.i;\n // Assumes roughly 33% compression ratio average\n if (noBuf)\n buf = new u8(sl * 3);\n // ensure buffer can fit at least l elements\n var cbuf = function (l) {\n var bl = buf.length;\n // need to increase size to fit\n if (l > bl) {\n // Double or set to necessary, whichever is greater\n var nbuf = new u8(Math.max(bl * 2, l));\n nbuf.set(buf);\n buf = nbuf;\n }\n };\n // last chunk bitpos bytes\n var final = st.f || 0, pos = st.p || 0, bt = st.b || 0, lm = st.l, dm = st.d, lbt = st.m, dbt = st.n;\n // total bits\n var tbts = sl * 8;\n do {\n if (!lm) {\n // BFINAL - this is only 1 when last chunk is next\n final = bits(dat, pos, 1);\n // type: 0 = no compression, 1 = fixed huffman, 2 = dynamic huffman\n var type = bits(dat, pos + 1, 3);\n pos += 3;\n if (!type) {\n // go to end of byte boundary\n var s = shft(pos) + 4, l = dat[s - 4] | (dat[s - 3] << 8), t = s + l;\n if (t > sl) {\n if (noSt)\n err(0);\n break;\n }\n // ensure size\n if (resize)\n cbuf(bt + l);\n // Copy over uncompressed data\n buf.set(dat.subarray(s, t), bt);\n // Get new bitpos, update byte count\n st.b = bt += l, st.p = pos = t * 8, st.f = final;\n continue;\n }\n else if (type == 1)\n lm = flrm, dm = fdrm, lbt = 9, dbt = 5;\n else if (type == 2) {\n // literal lengths\n var hLit = bits(dat, pos, 31) + 257, hcLen = bits(dat, pos + 10, 15) + 4;\n var tl = hLit + bits(dat, pos + 5, 31) + 1;\n pos += 14;\n // length+distance tree\n var ldt = new u8(tl);\n // code length tree\n var clt = new u8(19);\n for (var i = 0; i < hcLen; ++i) {\n // use index map to get real code\n clt[clim[i]] = bits(dat, pos + i * 3, 7);\n }\n pos += hcLen * 3;\n // code lengths bits\n var clb = max(clt), clbmsk = (1 << clb) - 1;\n // code lengths map\n var clm = hMap(clt, clb, 1);\n for (var i = 0; i < tl;) {\n var r = clm[bits(dat, pos, clbmsk)];\n // bits read\n pos += r & 15;\n // symbol\n var s = r >> 4;\n // code length to copy\n if (s < 16) {\n ldt[i++] = s;\n }\n else {\n // copy count\n var c = 0, n = 0;\n if (s == 16)\n n = 3 + bits(dat, pos, 3), pos += 2, c = ldt[i - 1];\n else if (s == 17)\n n = 3 + bits(dat, pos, 7), pos += 3;\n else if (s == 18)\n n = 11 + bits(dat, pos, 127), pos += 7;\n while (n--)\n ldt[i++] = c;\n }\n }\n // length tree distance tree\n var lt = ldt.subarray(0, hLit), dt = ldt.subarray(hLit);\n // max length bits\n lbt = max(lt);\n // max dist bits\n dbt = max(dt);\n lm = hMap(lt, lbt, 1);\n dm = hMap(dt, dbt, 1);\n }\n else\n err(1);\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n }\n // Make sure the buffer can hold this + the largest possible addition\n // Maximum chunk size (practically, theoretically infinite) is 2^17\n if (resize)\n cbuf(bt + 131072);\n var lms = (1 << lbt) - 1, dms = (1 << dbt) - 1;\n var lpos = pos;\n for (;; lpos = pos) {\n // bits read, code\n var c = lm[bits16(dat, pos) & lms], sym = c >> 4;\n pos += c & 15;\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (!c)\n err(2);\n if (sym < 256)\n buf[bt++] = sym;\n else if (sym == 256) {\n lpos = pos, lm = null;\n break;\n }\n else {\n var add = sym - 254;\n // no extra bits needed if less\n if (sym > 264) {\n // index\n var i = sym - 257, b = fleb[i];\n add = bits(dat, pos, (1 << b) - 1) + fl[i];\n pos += b;\n }\n // dist\n var d = dm[bits16(dat, pos) & dms], dsym = d >> 4;\n if (!d)\n err(3);\n pos += d & 15;\n var dt = fd[dsym];\n if (dsym > 3) {\n var b = fdeb[dsym];\n dt += bits16(dat, pos) & (1 << b) - 1, pos += b;\n }\n if (pos > tbts) {\n if (noSt)\n err(0);\n break;\n }\n if (resize)\n cbuf(bt + 131072);\n var end = bt + add;\n if (bt < dt) {\n var shift = dl - dt, dend = Math.min(dt, end);\n if (shift + bt < 0)\n err(3);\n for (; bt < dend; ++bt)\n buf[bt] = dict[shift + bt];\n }\n for (; bt < end; ++bt)\n buf[bt] = buf[bt - dt];\n }\n }\n st.l = lm, st.p = lpos, st.b = bt, st.f = final;\n if (lm)\n final = 1, st.m = lbt, st.d = dm, st.n = dbt;\n } while (!final);\n // don't reallocate for streams or user buffers\n return bt != buf.length && noBuf ? slc(buf, 0, bt) : buf.subarray(0, bt);\n};\n// starting at p, write the minimum number of bits that can hold v to d\nvar wbits = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) | 0;\n d[o] |= v;\n d[o + 1] |= v >> 8;\n};\n// starting at p, write the minimum number of bits (>8) that can hold v to d\nvar wbits16 = function (d, p, v) {\n v <<= p & 7;\n var o = (p / 8) | 0;\n d[o] |= v;\n d[o + 1] |= v >> 8;\n d[o + 2] |= v >> 16;\n};\n// creates code lengths from a frequency table\nvar hTree = function (d, mb) {\n // Need extra info to make a tree\n var t = [];\n for (var i = 0; i < d.length; ++i) {\n if (d[i])\n t.push({ s: i, f: d[i] });\n }\n var s = t.length;\n var t2 = t.slice();\n if (!s)\n return { t: et, l: 0 };\n if (s == 1) {\n var v = new u8(t[0].s + 1);\n v[t[0].s] = 1;\n return { t: v, l: 1 };\n }\n t.sort(function (a, b) { return a.f - b.f; });\n // after i2 reaches last ind, will be stopped\n // freq must be greater than largest possible number of symbols\n t.push({ s: -1, f: 25001 });\n var l = t[0], r = t[1], i0 = 0, i1 = 1, i2 = 2;\n t[0] = { s: -1, f: l.f + r.f, l: l, r: r };\n // efficient algorithm from UZIP.js\n // i0 is lookbehind, i2 is lookahead - after processing two low-freq\n // symbols that combined have high freq, will start processing i2 (high-freq,\n // non-composite) symbols instead\n // see https://reddit.com/r/photopea/comments/ikekht/uzipjs_questions/\n while (i1 != s - 1) {\n l = t[t[i0].f < t[i2].f ? i0++ : i2++];\n r = t[i0 != i1 && t[i0].f < t[i2].f ? i0++ : i2++];\n t[i1++] = { s: -1, f: l.f + r.f, l: l, r: r };\n }\n var maxSym = t2[0].s;\n for (var i = 1; i < s; ++i) {\n if (t2[i].s > maxSym)\n maxSym = t2[i].s;\n }\n // code lengths\n var tr = new u16(maxSym + 1);\n // max bits in tree\n var mbt = ln(t[i1 - 1], tr, 0);\n if (mbt > mb) {\n // more algorithms from UZIP.js\n // TODO: find out how this code works (debt)\n // ind debt\n var i = 0, dt = 0;\n // left cost\n var lft = mbt - mb, cst = 1 << lft;\n t2.sort(function (a, b) { return tr[b.s] - tr[a.s] || a.f - b.f; });\n for (; i < s; ++i) {\n var i2_1 = t2[i].s;\n if (tr[i2_1] > mb) {\n dt += cst - (1 << (mbt - tr[i2_1]));\n tr[i2_1] = mb;\n }\n else\n break;\n }\n dt >>= lft;\n while (dt > 0) {\n var i2_2 = t2[i].s;\n if (tr[i2_2] < mb)\n dt -= 1 << (mb - tr[i2_2]++ - 1);\n else\n ++i;\n }\n for (; i >= 0 && dt; --i) {\n var i2_3 = t2[i].s;\n if (tr[i2_3] == mb) {\n --tr[i2_3];\n ++dt;\n }\n }\n mbt = mb;\n }\n return { t: new u8(tr), l: mbt };\n};\n// get the max length and assign length codes\nvar ln = function (n, l, d) {\n return n.s == -1\n ? Math.max(ln(n.l, l, d + 1), ln(n.r, l, d + 1))\n : (l[n.s] = d);\n};\n// length codes generation\nvar lc = function (c) {\n var s = c.length;\n // Note that the semicolon was intentional\n while (s && !c[--s])\n ;\n var cl = new u16(++s);\n // ind num streak\n var cli = 0, cln = c[0], cls = 1;\n var w = function (v) { cl[cli++] = v; };\n for (var i = 1; i <= s; ++i) {\n if (c[i] == cln && i != s)\n ++cls;\n else {\n if (!cln && cls > 2) {\n for (; cls > 138; cls -= 138)\n w(32754);\n if (cls > 2) {\n w(cls > 10 ? ((cls - 11) << 5) | 28690 : ((cls - 3) << 5) | 12305);\n cls = 0;\n }\n }\n else if (cls > 3) {\n w(cln), --cls;\n for (; cls > 6; cls -= 6)\n w(8304);\n if (cls > 2)\n w(((cls - 3) << 5) | 8208), cls = 0;\n }\n while (cls--)\n w(cln);\n cls = 1;\n cln = c[i];\n }\n }\n return { c: cl.subarray(0, cli), n: s };\n};\n// calculate the length of output from tree, code lengths\nvar clen = function (cf, cl) {\n var l = 0;\n for (var i = 0; i < cl.length; ++i)\n l += cf[i] * cl[i];\n return l;\n};\n// writes a fixed block\n// returns the new bit pos\nvar wfblk = function (out, pos, dat) {\n // no need to write 00 as type: TypedArray defaults to 0\n var s = dat.length;\n var o = shft(pos + 2);\n out[o] = s & 255;\n out[o + 1] = s >> 8;\n out[o + 2] = out[o] ^ 255;\n out[o + 3] = out[o + 1] ^ 255;\n for (var i = 0; i < s; ++i)\n out[o + i + 4] = dat[i];\n return (o + 4 + s) * 8;\n};\n// writes a block\nvar wblk = function (dat, out, final, syms, lf, df, eb, li, bs, bl, p) {\n wbits(out, p++, final);\n ++lf[256];\n var _a = hTree(lf, 15), dlt = _a.t, mlb = _a.l;\n var _b = hTree(df, 15), ddt = _b.t, mdb = _b.l;\n var _c = lc(dlt), lclt = _c.c, nlc = _c.n;\n var _d = lc(ddt), lcdt = _d.c, ndc = _d.n;\n var lcfreq = new u16(19);\n for (var i = 0; i < lclt.length; ++i)\n ++lcfreq[lclt[i] & 31];\n for (var i = 0; i < lcdt.length; ++i)\n ++lcfreq[lcdt[i] & 31];\n var _e = hTree(lcfreq, 7), lct = _e.t, mlcb = _e.l;\n var nlcc = 19;\n for (; nlcc > 4 && !lct[clim[nlcc - 1]]; --nlcc)\n ;\n var flen = (bl + 5) << 3;\n var ftlen = clen(lf, flt) + clen(df, fdt) + eb;\n var dtlen = clen(lf, dlt) + clen(df, ddt) + eb + 14 + 3 * nlcc + clen(lcfreq, lct) + 2 * lcfreq[16] + 3 * lcfreq[17] + 7 * lcfreq[18];\n if (bs >= 0 && flen <= ftlen && flen <= dtlen)\n return wfblk(out, p, dat.subarray(bs, bs + bl));\n var lm, ll, dm, dl;\n wbits(out, p, 1 + (dtlen < ftlen)), p += 2;\n if (dtlen < ftlen) {\n lm = hMap(dlt, mlb, 0), ll = dlt, dm = hMap(ddt, mdb, 0), dl = ddt;\n var llm = hMap(lct, mlcb, 0);\n wbits(out, p, nlc - 257);\n wbits(out, p + 5, ndc - 1);\n wbits(out, p + 10, nlcc - 4);\n p += 14;\n for (var i = 0; i < nlcc; ++i)\n wbits(out, p + 3 * i, lct[clim[i]]);\n p += 3 * nlcc;\n var lcts = [lclt, lcdt];\n for (var it = 0; it < 2; ++it) {\n var clct = lcts[it];\n for (var i = 0; i < clct.length; ++i) {\n var len = clct[i] & 31;\n wbits(out, p, llm[len]), p += lct[len];\n if (len > 15)\n wbits(out, p, (clct[i] >> 5) & 127), p += clct[i] >> 12;\n }\n }\n }\n else {\n lm = flm, ll = flt, dm = fdm, dl = fdt;\n }\n for (var i = 0; i < li; ++i) {\n var sym = syms[i];\n if (sym > 255) {\n var len = (sym >> 18) & 31;\n wbits16(out, p, lm[len + 257]), p += ll[len + 257];\n if (len > 7)\n wbits(out, p, (sym >> 23) & 31), p += fleb[len];\n var dst = sym & 31;\n wbits16(out, p, dm[dst]), p += dl[dst];\n if (dst > 3)\n wbits16(out, p, (sym >> 5) & 8191), p += fdeb[dst];\n }\n else {\n wbits16(out, p, lm[sym]), p += ll[sym];\n }\n }\n wbits16(out, p, lm[256]);\n return p + ll[256];\n};\n// deflate options (nice << 13) | chain\nvar deo = /*#__PURE__*/ new i32([65540, 131080, 131088, 131104, 262176, 1048704, 1048832, 2114560, 2117632]);\n// empty\nvar et = /*#__PURE__*/ new u8(0);\n// compresses data into a raw DEFLATE buffer\nvar dflt = function (dat, lvl, plvl, pre, post, st) {\n var s = st.z || dat.length;\n var o = new u8(pre + s + 5 * (1 + Math.ceil(s / 7000)) + post);\n // writing to this writes to the output buffer\n var w = o.subarray(pre, o.length - post);\n var lst = st.l;\n var pos = (st.r || 0) & 7;\n if (lvl) {\n if (pos)\n w[0] = st.r >> 3;\n var opt = deo[lvl - 1];\n var n = opt >> 13, c = opt & 8191;\n var msk_1 = (1 << plvl) - 1;\n // prev 2-byte val map curr 2-byte val map\n var prev = st.p || new u16(32768), head = st.h || new u16(msk_1 + 1);\n var bs1_1 = Math.ceil(plvl / 3), bs2_1 = 2 * bs1_1;\n var hsh = function (i) { return (dat[i] ^ (dat[i + 1] << bs1_1) ^ (dat[i + 2] << bs2_1)) & msk_1; };\n // 24576 is an arbitrary number of maximum symbols per block\n // 424 buffer for last block\n var syms = new i32(25000);\n // length/literal freq distance freq\n var lf = new u16(288), df = new u16(32);\n // l/lcnt exbits index l/lind waitdx blkpos\n var lc_1 = 0, eb = 0, i = st.i || 0, li = 0, wi = st.w || 0, bs = 0;\n for (; i + 2 < s; ++i) {\n // hash value\n var hv = hsh(i);\n // index mod 32768 previous index mod\n var imod = i & 32767, pimod = head[hv];\n prev[imod] = pimod;\n head[hv] = imod;\n // We always should modify head and prev, but only add symbols if\n // this data is not yet processed (\"wait\" for wait index)\n if (wi <= i) {\n // bytes remaining\n var rem = s - i;\n if ((lc_1 > 7000 || li > 24576) && (rem > 423 || !lst)) {\n pos = wblk(dat, w, 0, syms, lf, df, eb, li, bs, i - bs, pos);\n li = lc_1 = eb = 0, bs = i;\n for (var j = 0; j < 286; ++j)\n lf[j] = 0;\n for (var j = 0; j < 30; ++j)\n df[j] = 0;\n }\n // len dist chain\n var l = 2, d = 0, ch_1 = c, dif = imod - pimod & 32767;\n if (rem > 2 && hv == hsh(i - dif)) {\n var maxn = Math.min(n, rem) - 1;\n var maxd = Math.min(32767, i);\n // max possible length\n // not capped at dif because decompressors implement \"rolling\" index population\n var ml = Math.min(258, rem);\n while (dif <= maxd && --ch_1 && imod != pimod) {\n if (dat[i + l] == dat[i + l - dif]) {\n var nl = 0;\n for (; nl < ml && dat[i + nl] == dat[i + nl - dif]; ++nl)\n ;\n if (nl > l) {\n l = nl, d = dif;\n // break out early when we reach \"nice\" (we are satisfied enough)\n if (nl > maxn)\n break;\n // now, find the rarest 2-byte sequence within this\n // length of literals and search for that instead.\n // Much faster than just using the start\n var mmd = Math.min(dif, nl - 2);\n var md = 0;\n for (var j = 0; j < mmd; ++j) {\n var ti = i - dif + j & 32767;\n var pti = prev[ti];\n var cd = ti - pti & 32767;\n if (cd > md)\n md = cd, pimod = ti;\n }\n }\n }\n // check the previous match\n imod = pimod, pimod = prev[imod];\n dif += imod - pimod & 32767;\n }\n }\n // d will be nonzero only when a match was found\n if (d) {\n // store both dist and len data in one int32\n // Make sure this is recognized as a len/dist with 28th bit (2^28)\n syms[li++] = 268435456 | (revfl[l] << 18) | revfd[d];\n var lin = revfl[l] & 31, din = revfd[d] & 31;\n eb += fleb[lin] + fdeb[din];\n ++lf[257 + lin];\n ++df[din];\n wi = i + l;\n ++lc_1;\n }\n else {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n }\n }\n for (i = Math.max(i, wi); i < s; ++i) {\n syms[li++] = dat[i];\n ++lf[dat[i]];\n }\n pos = wblk(dat, w, lst, syms, lf, df, eb, li, bs, i - bs, pos);\n if (!lst) {\n st.r = (pos & 7) | w[(pos / 8) | 0] << 3;\n // shft(pos) now 1 less if pos & 7 != 0\n pos -= 7;\n st.h = head, st.p = prev, st.i = i, st.w = wi;\n }\n }\n else {\n for (var i = st.w || 0; i < s + lst; i += 65535) {\n // end\n var e = i + 65535;\n if (e >= s) {\n // write final block\n w[(pos / 8) | 0] = lst;\n e = s;\n }\n pos = wfblk(w, pos + 1, dat.subarray(i, e));\n }\n st.i = s;\n }\n return slc(o, 0, pre + shft(pos) + post);\n};\n// CRC32 table\nvar crct = /*#__PURE__*/ (function () {\n var t = new Int32Array(256);\n for (var i = 0; i < 256; ++i) {\n var c = i, k = 9;\n while (--k)\n c = ((c & 1) && -306674912) ^ (c >>> 1);\n t[i] = c;\n }\n return t;\n})();\n// CRC32\nvar crc = function () {\n var c = -1;\n return {\n p: function (d) {\n // closures have awful performance\n var cr = c;\n for (var i = 0; i < d.length; ++i)\n cr = crct[(cr & 255) ^ d[i]] ^ (cr >>> 8);\n c = cr;\n },\n d: function () { return ~c; }\n };\n};\n// Adler32\nvar adler = function () {\n var a = 1, b = 0;\n return {\n p: function (d) {\n // closures have awful performance\n var n = a, m = b;\n var l = d.length | 0;\n for (var i = 0; i != l;) {\n var e = Math.min(i + 2655, l);\n for (; i < e; ++i)\n m += n += d[i];\n n = (n & 65535) + 15 * (n >> 16), m = (m & 65535) + 15 * (m >> 16);\n }\n a = n, b = m;\n },\n d: function () {\n a %= 65521, b %= 65521;\n return (a & 255) << 24 | (a & 0xFF00) << 8 | (b & 255) << 8 | (b >> 8);\n }\n };\n};\n;\n// deflate with opts\nvar dopt = function (dat, opt, pre, post, st) {\n if (!st) {\n st = { l: 1 };\n if (opt.dictionary) {\n var dict = opt.dictionary.subarray(-32768);\n var newDat = new u8(dict.length + dat.length);\n newDat.set(dict);\n newDat.set(dat, dict.length);\n dat = newDat;\n st.w = dict.length;\n }\n }\n return dflt(dat, opt.level == null ? 6 : opt.level, opt.mem == null ? (st.l ? Math.ceil(Math.max(8, Math.min(13, Math.log(dat.length))) * 1.5) : 20) : (12 + opt.mem), pre, post, st);\n};\n// Walmart object spread\nvar mrg = function (a, b) {\n var o = {};\n for (var k in a)\n o[k] = a[k];\n for (var k in b)\n o[k] = b[k];\n return o;\n};\n// worker clone\n// This is possibly the craziest part of the entire codebase, despite how simple it may seem.\n// The only parameter to this function is a closure that returns an array of variables outside of the function scope.\n// We're going to try to figure out the variable names used in the closure as strings because that is crucial for workerization.\n// We will return an object mapping of true variable name to value (basically, the current scope as a JS object).\n// The reason we can't just use the original variable names is minifiers mangling the toplevel scope.\n// This took me three weeks to figure out how to do.\nvar wcln = function (fn, fnStr, td) {\n var dt = fn();\n var st = fn.toString();\n var ks = st.slice(st.indexOf('[') + 1, st.lastIndexOf(']')).replace(/\\s+/g, '').split(',');\n for (var i = 0; i < dt.length; ++i) {\n var v = dt[i], k = ks[i];\n if (typeof v == 'function') {\n fnStr += ';' + k + '=';\n var st_1 = v.toString();\n if (v.prototype) {\n // for global objects\n if (st_1.indexOf('[native code]') != -1) {\n var spInd = st_1.indexOf(' ', 8) + 1;\n fnStr += st_1.slice(spInd, st_1.indexOf('(', spInd));\n }\n else {\n fnStr += st_1;\n for (var t in v.prototype)\n fnStr += ';' + k + '.prototype.' + t + '=' + v.prototype[t].toString();\n }\n }\n else\n fnStr += st_1;\n }\n else\n td[k] = v;\n }\n return fnStr;\n};\nvar ch = [];\n// clone bufs\nvar cbfs = function (v) {\n var tl = [];\n for (var k in v) {\n if (v[k].buffer) {\n tl.push((v[k] = new v[k].constructor(v[k])).buffer);\n }\n }\n return tl;\n};\n// use a worker to execute code\nvar wrkr = function (fns, init, id, cb) {\n if (!ch[id]) {\n var fnStr = '', td_1 = {}, m = fns.length - 1;\n for (var i = 0; i < m; ++i)\n fnStr = wcln(fns[i], fnStr, td_1);\n ch[id] = { c: wcln(fns[m], fnStr, td_1), e: td_1 };\n }\n var td = mrg({}, ch[id].e);\n return wk(ch[id].c + ';onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=' + init.toString() + '}', id, td, cbfs(td), cb);\n};\n// base async inflate fn\nvar bInflt = function () { return [u8, u16, i32, fleb, fdeb, clim, fl, fd, flrm, fdrm, rev, ec, hMap, max, bits, bits16, shft, slc, err, inflt, inflateSync, pbf, gopt]; };\nvar bDflt = function () { return [u8, u16, i32, fleb, fdeb, clim, revfl, revfd, flm, flt, fdm, fdt, rev, deo, et, hMap, wbits, wbits16, hTree, ln, lc, clen, wfblk, wblk, shft, slc, dflt, dopt, deflateSync, pbf]; };\n// gzip extra\nvar gze = function () { return [gzh, gzhl, wbytes, crc, crct]; };\n// gunzip extra\nvar guze = function () { return [gzs, gzl]; };\n// zlib extra\nvar zle = function () { return [zlh, wbytes, adler]; };\n// unzlib extra\nvar zule = function () { return [zls]; };\n// post buf\nvar pbf = function (msg) { return postMessage(msg, [msg.buffer]); };\n// get opts\nvar gopt = function (o) { return o && {\n out: o.size && new u8(o.size),\n dictionary: o.dictionary\n}; };\n// async helper\nvar cbify = function (dat, opts, fns, init, id, cb) {\n var w = wrkr(fns, init, id, function (err, dat) {\n w.terminate();\n cb(err, dat);\n });\n w.postMessage([dat, opts], opts.consume ? [dat.buffer] : []);\n return function () { w.terminate(); };\n};\n// auto stream\nvar astrm = function (strm) {\n strm.ondata = function (dat, final) { return postMessage([dat, final], [dat.buffer]); };\n return function (ev) {\n if (ev.data[0]) {\n strm.push(ev.data[0], ev.data[1]);\n postMessage([ev.data[0].length]);\n }\n else\n strm.flush(ev.data[1]);\n };\n};\n// async stream attach\nvar astrmify = function (fns, strm, opts, init, id, flush, ext) {\n var t;\n var w = wrkr(fns, init, id, function (err, dat) {\n if (err)\n w.terminate(), strm.ondata.call(strm, err);\n else if (!Array.isArray(dat))\n ext(dat);\n else if (dat.length == 1) {\n strm.queuedSize -= dat[0];\n if (strm.ondrain)\n strm.ondrain(dat[0]);\n }\n else {\n if (dat[1])\n w.terminate();\n strm.ondata.call(strm, err, dat[0], dat[1]);\n }\n });\n w.postMessage(opts);\n strm.queuedSize = 0;\n strm.push = function (d, f) {\n if (!strm.ondata)\n err(5);\n if (t)\n strm.ondata(err(4, 0, 1), null, !!f);\n strm.queuedSize += d.length;\n // can fail for cross-realm Uint8Array, but ok - only a small performance penalty\n w.postMessage([d, t = f], d.buffer instanceof ArrayBuffer ? [d.buffer] : []);\n };\n strm.terminate = function () { w.terminate(); };\n if (flush) {\n strm.flush = function (sync) { w.postMessage([0, sync]); };\n }\n};\n// read 2 bytes\nvar b2 = function (d, b) { return d[b] | (d[b + 1] << 8); };\n// read 4 bytes\nvar b4 = function (d, b) { return (d[b] | (d[b + 1] << 8) | (d[b + 2] << 16) | (d[b + 3] << 24)) >>> 0; };\n// read 8 bytes\nvar b8 = function (d, b) { return b4(d, b) + (b4(d, b + 4) * 4294967296); };\n// write bytes\nvar wbytes = function (d, b, v) {\n for (; v; ++b)\n d[b] = v, v >>>= 8;\n};\n// gzip header\nvar gzh = function (c, o) {\n var fn = o.filename;\n c[0] = 31, c[1] = 139, c[2] = 8, c[8] = o.level < 2 ? 4 : o.level == 9 ? 2 : 0, c[9] = 3; // assume Unix\n if (o.mtime != 0)\n wbytes(c, 4, Math.floor(new Date(o.mtime || Date.now()) / 1000));\n if (fn) {\n c[3] = 8;\n for (var i = 0; i <= fn.length; ++i)\n c[i + 10] = fn.charCodeAt(i);\n }\n};\n// gzip footer: -8 to -4 = CRC, -4 to -0 is length\n// gzip start\nvar gzs = function (d) {\n if (d[0] != 31 || d[1] != 139 || d[2] != 8)\n err(6, 'invalid gzip data');\n var flg = d[3];\n var st = 10;\n if (flg & 4)\n st += (d[10] | d[11] << 8) + 2;\n for (var zs = (flg >> 3 & 1) + (flg >> 4 & 1); zs > 0; zs -= !d[st++])\n ;\n return st + (flg & 2);\n};\n// gzip length\nvar gzl = function (d) {\n var l = d.length;\n return (d[l - 4] | d[l - 3] << 8 | d[l - 2] << 16 | d[l - 1] << 24) >>> 0;\n};\n// gzip header length\nvar gzhl = function (o) { return 10 + (o.filename ? o.filename.length + 1 : 0); };\n// zlib header\nvar zlh = function (c, o) {\n var lv = o.level, fl = lv == 0 ? 0 : lv < 6 ? 1 : lv == 9 ? 3 : 2;\n c[0] = 120, c[1] = (fl << 6) | (o.dictionary && 32);\n c[1] |= 31 - ((c[0] << 8) | c[1]) % 31;\n if (o.dictionary) {\n var h = adler();\n h.p(o.dictionary);\n wbytes(c, 2, h.d());\n }\n};\n// zlib start\nvar zls = function (d, dict) {\n if ((d[0] & 15) != 8 || (d[0] >> 4) > 7 || ((d[0] << 8 | d[1]) % 31))\n err(6, 'invalid zlib data');\n if ((d[1] >> 5 & 1) == +!dict)\n err(6, 'invalid zlib data: ' + (d[1] & 32 ? 'need' : 'unexpected') + ' dictionary');\n return (d[1] >> 3 & 4) + 2;\n};\nfunction StrmOpt(opts, cb) {\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n return opts;\n}\n/**\n * Streaming DEFLATE compression\n */\nvar Deflate = /*#__PURE__*/ (function () {\n function Deflate(opts, cb) {\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n this.o = opts || {};\n this.s = { l: 0, i: 32768, w: 32768, z: 32768 };\n // Buffer length must always be 0 mod 32768 for index calculations to be correct when modifying head and prev\n // 98304 = 32768 (lookback) + 65536 (common chunk size)\n this.b = new u8(98304);\n if (this.o.dictionary) {\n var dict = this.o.dictionary.subarray(-32768);\n this.b.set(dict, 32768 - dict.length);\n this.s.i = 32768 - dict.length;\n }\n }\n Deflate.prototype.p = function (c, f) {\n this.ondata(dopt(c, this.o, 0, 0, this.s), f);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Deflate.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (this.s.l)\n err(4);\n var endLen = chunk.length + this.s.z;\n if (endLen > this.b.length) {\n if (endLen > 2 * this.b.length - 32768) {\n var newBuf = new u8(endLen & -32768);\n newBuf.set(this.b.subarray(0, this.s.z));\n this.b = newBuf;\n }\n var split = this.b.length - this.s.z;\n this.b.set(chunk.subarray(0, split), this.s.z);\n this.s.z = this.b.length;\n this.p(this.b, false);\n this.b.set(this.b.subarray(-32768));\n this.b.set(chunk.subarray(split), 32768);\n this.s.z = chunk.length - split + 32768;\n this.s.i = 32766, this.s.w = 32768;\n }\n else {\n this.b.set(chunk, this.s.z);\n this.s.z += chunk.length;\n }\n this.s.l = final & 1;\n if (this.s.z > this.s.w + 8191 || final) {\n this.p(this.b, final || false);\n this.s.w = this.s.i, this.s.i -= 2;\n }\n if (final) {\n // cleanup unneeded buffers/state to reduce memory usage\n this.s = this.o = {};\n this.b = et;\n }\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * deflated output for small inputs.\n * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5\n * extra bytes, but guarantees all pushed data is immediately\n * decompressible. A separate DEFLATE stream may be concatenated\n * with the current output after a sync flush.\n */\n Deflate.prototype.flush = function (sync) {\n if (!this.ondata)\n err(5);\n if (this.s.l)\n err(4);\n this.p(this.b, false);\n this.s.w = this.s.i, this.s.i -= 2;\n // could technically skip writing the type-0 block for (this.s.r & 7) == 0,\n // but the deterministic trailer (00 00 FF FF) is useful in some situations\n if (sync) {\n var c = new u8(6);\n c[0] = this.s.r >> 3;\n // write empty, non-final type-0 block\n var ep = wfblk(c, this.s.r, et);\n this.s.r = 0;\n this.ondata(c.subarray(0, ep >> 3), false);\n }\n };\n return Deflate;\n}());\nexport { Deflate };\n/**\n * Asynchronous streaming DEFLATE compression\n */\nvar AsyncDeflate = /*#__PURE__*/ (function () {\n function AsyncDeflate(opts, cb) {\n astrmify([\n bDflt,\n function () { return [astrm, Deflate]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Deflate(ev.data);\n onmessage = astrm(strm);\n }, 6, 1);\n }\n return AsyncDeflate;\n}());\nexport { AsyncDeflate };\nexport function deflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n ], function (ev) { return pbf(deflateSync(ev.data[0], ev.data[1])); }, 0, cb);\n}\n/**\n * Compresses data with DEFLATE without any wrapper\n * @param data The data to compress\n * @param opts The compression options\n * @returns The deflated version of the data\n */\nexport function deflateSync(data, opts) {\n return dopt(data, opts || {}, 0, 0);\n}\n/**\n * Streaming DEFLATE decompression\n */\nvar Inflate = /*#__PURE__*/ (function () {\n function Inflate(opts, cb) {\n // no StrmOpt here to avoid adding to workerizer\n if (typeof opts == 'function')\n cb = opts, opts = {};\n this.ondata = cb;\n var dict = opts && opts.dictionary && opts.dictionary.subarray(-32768);\n this.s = { i: 0, b: dict ? dict.length : 0 };\n this.o = new u8(32768);\n this.p = new u8(0);\n if (dict)\n this.o.set(dict);\n }\n Inflate.prototype.e = function (c) {\n if (!this.ondata)\n err(5);\n if (this.d)\n err(4);\n if (!this.p.length)\n this.p = c;\n else if (c.length) {\n var n = new u8(this.p.length + c.length);\n n.set(this.p), n.set(c, this.p.length), this.p = n;\n }\n };\n Inflate.prototype.c = function (final) {\n this.s.i = +(this.d = final || false);\n var bts = this.s.b;\n var dt = inflt(this.p, this.s, this.o);\n this.ondata(slc(dt, bts, this.s.b), this.d);\n this.o = slc(dt, this.s.b - 32768), this.s.b = this.o.length;\n this.p = slc(this.p, (this.s.p / 8) | 0), this.s.p &= 7;\n };\n /**\n * Pushes a chunk to be inflated\n * @param chunk The chunk to push\n * @param final Whether this is the final chunk\n */\n Inflate.prototype.push = function (chunk, final) {\n this.e(chunk), this.c(final);\n };\n return Inflate;\n}());\nexport { Inflate };\n/**\n * Asynchronous streaming DEFLATE decompression\n */\nvar AsyncInflate = /*#__PURE__*/ (function () {\n function AsyncInflate(opts, cb) {\n astrmify([\n bInflt,\n function () { return [astrm, Inflate]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Inflate(ev.data);\n onmessage = astrm(strm);\n }, 7, 0);\n }\n return AsyncInflate;\n}());\nexport { AsyncInflate };\nexport function inflate(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt\n ], function (ev) { return pbf(inflateSync(ev.data[0], gopt(ev.data[1]))); }, 1, cb);\n}\nexport function inflateSync(data, opts) {\n return inflt(data, { i: 2 }, opts && opts.out, opts && opts.dictionary);\n}\n// before you yell at me for not just using extends, my reason is that TS inheritance is hard to workerize.\n/**\n * Streaming GZIP compression\n */\nvar Gzip = /*#__PURE__*/ (function () {\n function Gzip(opts, cb) {\n this.c = crc();\n this.l = 0;\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gzip.prototype.push = function (chunk, final) {\n this.c.p(chunk);\n this.l += chunk.length;\n Deflate.prototype.push.call(this, chunk, final);\n };\n Gzip.prototype.p = function (c, f) {\n var raw = dopt(c, this.o, this.v && gzhl(this.o), f && 8, this.s);\n if (this.v)\n gzh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 8, this.c.d()), wbytes(raw, raw.length - 4, this.l);\n this.ondata(raw, f);\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * GZIPped output for small inputs.\n * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5\n * extra bytes, but guarantees all pushed data is immediately\n * decompressible.\n */\n Gzip.prototype.flush = function (sync) {\n Deflate.prototype.flush.call(this, sync);\n };\n return Gzip;\n}());\nexport { Gzip };\n/**\n * Asynchronous streaming GZIP compression\n */\nvar AsyncGzip = /*#__PURE__*/ (function () {\n function AsyncGzip(opts, cb) {\n astrmify([\n bDflt,\n gze,\n function () { return [astrm, Deflate, Gzip]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Gzip(ev.data);\n onmessage = astrm(strm);\n }, 8, 1);\n }\n return AsyncGzip;\n}());\nexport { AsyncGzip };\nexport function gzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n gze,\n function () { return [gzipSync]; }\n ], function (ev) { return pbf(gzipSync(ev.data[0], ev.data[1])); }, 2, cb);\n}\n/**\n * Compresses data with GZIP\n * @param data The data to compress\n * @param opts The compression options\n * @returns The gzipped version of the data\n */\nexport function gzipSync(data, opts) {\n if (!opts)\n opts = {};\n var c = crc(), l = data.length;\n c.p(data);\n var d = dopt(data, opts, gzhl(opts), 8), s = d.length;\n return gzh(d, opts), wbytes(d, s - 8, c.d()), wbytes(d, s - 4, l), d;\n}\n/**\n * Streaming single or multi-member GZIP decompression\n */\nvar Gunzip = /*#__PURE__*/ (function () {\n function Gunzip(opts, cb) {\n this.v = 1;\n this.r = 0;\n Inflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be GUNZIPped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Gunzip.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n this.r += chunk.length;\n if (this.v) {\n var p = this.p.subarray(this.v - 1);\n var s = p.length > 3 ? gzs(p) : 4;\n if (s > p.length) {\n if (!final)\n return;\n }\n else if (this.v > 1 && this.onmember) {\n this.onmember(this.r - p.length);\n }\n this.p = p.subarray(s), this.v = 0;\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, 0);\n // process concatenated GZIP\n if (this.s.f && !this.s.l) {\n this.v = shft(this.s.p) + 9;\n this.s = { i: 0 };\n this.o = new u8(0);\n this.push(new u8(0), final);\n }\n else if (final) {\n Inflate.prototype.c.call(this, final);\n }\n };\n return Gunzip;\n}());\nexport { Gunzip };\n/**\n * Asynchronous streaming single or multi-member GZIP decompression\n */\nvar AsyncGunzip = /*#__PURE__*/ (function () {\n function AsyncGunzip(opts, cb) {\n var _this = this;\n astrmify([\n bInflt,\n guze,\n function () { return [astrm, Inflate, Gunzip]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Gunzip(ev.data);\n strm.onmember = function (offset) { return postMessage(offset); };\n onmessage = astrm(strm);\n }, 9, 0, function (offset) { return _this.onmember && _this.onmember(offset); });\n }\n return AsyncGunzip;\n}());\nexport { AsyncGunzip };\nexport function gunzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt,\n guze,\n function () { return [gunzipSync]; }\n ], function (ev) { return pbf(gunzipSync(ev.data[0], ev.data[1])); }, 3, cb);\n}\nexport function gunzipSync(data, opts) {\n var st = gzs(data);\n if (st + 8 > data.length)\n err(6, 'invalid gzip data');\n return inflt(data.subarray(st, -8), { i: 2 }, opts && opts.out || new u8(gzl(data)), opts && opts.dictionary);\n}\n/**\n * Streaming Zlib compression\n */\nvar Zlib = /*#__PURE__*/ (function () {\n function Zlib(opts, cb) {\n this.c = adler();\n this.v = 1;\n Deflate.call(this, opts, cb);\n }\n /**\n * Pushes a chunk to be zlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Zlib.prototype.push = function (chunk, final) {\n this.c.p(chunk);\n Deflate.prototype.push.call(this, chunk, final);\n };\n Zlib.prototype.p = function (c, f) {\n var raw = dopt(c, this.o, this.v && (this.o.dictionary ? 6 : 2), f && 4, this.s);\n if (this.v)\n zlh(raw, this.o), this.v = 0;\n if (f)\n wbytes(raw, raw.length - 4, this.c.d());\n this.ondata(raw, f);\n };\n /**\n * Flushes buffered uncompressed data. Useful to immediately retrieve the\n * zlibbed output for small inputs.\n * @param sync Whether to flush to a byte boundary. A sync flush takes 4-5\n * extra bytes, but guarantees all pushed data is immediately\n * decompressible.\n */\n Zlib.prototype.flush = function (sync) {\n Deflate.prototype.flush.call(this, sync);\n };\n return Zlib;\n}());\nexport { Zlib };\n/**\n * Asynchronous streaming Zlib compression\n */\nvar AsyncZlib = /*#__PURE__*/ (function () {\n function AsyncZlib(opts, cb) {\n astrmify([\n bDflt,\n zle,\n function () { return [astrm, Deflate, Zlib]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Zlib(ev.data);\n onmessage = astrm(strm);\n }, 10, 1);\n }\n return AsyncZlib;\n}());\nexport { AsyncZlib };\nexport function zlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bDflt,\n zle,\n function () { return [zlibSync]; }\n ], function (ev) { return pbf(zlibSync(ev.data[0], ev.data[1])); }, 4, cb);\n}\n/**\n * Compress data with Zlib\n * @param data The data to compress\n * @param opts The compression options\n * @returns The zlib-compressed version of the data\n */\nexport function zlibSync(data, opts) {\n if (!opts)\n opts = {};\n var a = adler();\n a.p(data);\n var d = dopt(data, opts, opts.dictionary ? 6 : 2, 4);\n return zlh(d, opts), wbytes(d, d.length - 4, a.d()), d;\n}\n/**\n * Streaming Zlib decompression\n */\nvar Unzlib = /*#__PURE__*/ (function () {\n function Unzlib(opts, cb) {\n Inflate.call(this, opts, cb);\n this.v = opts && opts.dictionary ? 2 : 1;\n }\n /**\n * Pushes a chunk to be unzlibbed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzlib.prototype.push = function (chunk, final) {\n Inflate.prototype.e.call(this, chunk);\n if (this.v) {\n if (this.p.length < 6 && !final)\n return;\n this.p = this.p.subarray(zls(this.p, this.v - 1)), this.v = 0;\n }\n if (final) {\n if (this.p.length < 4)\n err(6, 'invalid zlib data');\n this.p = this.p.subarray(0, -4);\n }\n // necessary to prevent TS from using the closure value\n // This allows for workerization to function correctly\n Inflate.prototype.c.call(this, final);\n };\n return Unzlib;\n}());\nexport { Unzlib };\n/**\n * Asynchronous streaming Zlib decompression\n */\nvar AsyncUnzlib = /*#__PURE__*/ (function () {\n function AsyncUnzlib(opts, cb) {\n astrmify([\n bInflt,\n zule,\n function () { return [astrm, Inflate, Unzlib]; }\n ], this, StrmOpt.call(this, opts, cb), function (ev) {\n var strm = new Unzlib(ev.data);\n onmessage = astrm(strm);\n }, 11, 0);\n }\n return AsyncUnzlib;\n}());\nexport { AsyncUnzlib };\nexport function unzlib(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return cbify(data, opts, [\n bInflt,\n zule,\n function () { return [unzlibSync]; }\n ], function (ev) { return pbf(unzlibSync(ev.data[0], gopt(ev.data[1]))); }, 5, cb);\n}\nexport function unzlibSync(data, opts) {\n return inflt(data.subarray(zls(data, opts && opts.dictionary), -4), { i: 2 }, opts && opts.out, opts && opts.dictionary);\n}\n// Default algorithm for compression (used because having a known output size allows faster decompression)\nexport { gzip as compress, AsyncGzip as AsyncCompress };\nexport { gzipSync as compressSync, Gzip as Compress };\n/**\n * Streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar Decompress = /*#__PURE__*/ (function () {\n function Decompress(opts, cb) {\n this.o = StrmOpt.call(this, opts, cb) || {};\n this.G = Gunzip;\n this.I = Inflate;\n this.Z = Unzlib;\n }\n // init substream\n // overriden by AsyncDecompress\n Decompress.prototype.i = function () {\n var _this = this;\n this.s.ondata = function (dat, final) {\n _this.ondata(dat, final);\n };\n };\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Decompress.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (!this.s) {\n if (this.p && this.p.length) {\n var n = new u8(this.p.length + chunk.length);\n n.set(this.p), n.set(chunk, this.p.length);\n }\n else\n this.p = chunk;\n if (this.p.length > 2) {\n this.s = (this.p[0] == 31 && this.p[1] == 139 && this.p[2] == 8)\n ? new this.G(this.o)\n : ((this.p[0] & 15) != 8 || (this.p[0] >> 4) > 7 || ((this.p[0] << 8 | this.p[1]) % 31))\n ? new this.I(this.o)\n : new this.Z(this.o);\n this.i();\n this.s.push(this.p, final);\n this.p = null;\n }\n }\n else\n this.s.push(chunk, final);\n };\n return Decompress;\n}());\nexport { Decompress };\n/**\n * Asynchronous streaming GZIP, Zlib, or raw DEFLATE decompression\n */\nvar AsyncDecompress = /*#__PURE__*/ (function () {\n function AsyncDecompress(opts, cb) {\n Decompress.call(this, opts, cb);\n this.queuedSize = 0;\n this.G = AsyncGunzip;\n this.I = AsyncInflate;\n this.Z = AsyncUnzlib;\n }\n AsyncDecompress.prototype.i = function () {\n var _this = this;\n this.s.ondata = function (err, dat, final) {\n _this.ondata(err, dat, final);\n };\n this.s.ondrain = function (size) {\n _this.queuedSize -= size;\n if (_this.ondrain)\n _this.ondrain(size);\n };\n };\n /**\n * Pushes a chunk to be decompressed\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncDecompress.prototype.push = function (chunk, final) {\n this.queuedSize += chunk.length;\n Decompress.prototype.push.call(this, chunk, final);\n };\n return AsyncDecompress;\n}());\nexport { AsyncDecompress };\nexport function decompress(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzip(data, opts, cb)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflate(data, opts, cb)\n : unzlib(data, opts, cb);\n}\n/**\n * Expands compressed GZIP, Zlib, or raw DEFLATE data, automatically detecting the format\n * @param data The data to decompress\n * @param opts The decompression options\n * @returns The decompressed version of the data\n */\nexport function decompressSync(data, opts) {\n return (data[0] == 31 && data[1] == 139 && data[2] == 8)\n ? gunzipSync(data, opts)\n : ((data[0] & 15) != 8 || (data[0] >> 4) > 7 || ((data[0] << 8 | data[1]) % 31))\n ? inflateSync(data, opts)\n : unzlibSync(data, opts);\n}\n// flatten a directory structure\nvar fltn = function (d, p, t, o) {\n for (var k in d) {\n var val = d[k], n = p + k, op = o;\n if (Array.isArray(val))\n op = mrg(o, val[1]), val = val[0];\n if (ArrayBuffer.isView(val))\n t[n] = [val, op];\n else {\n t[n += '/'] = [new u8(0), op];\n fltn(val, n, t, o);\n }\n }\n};\n// text encoder\nvar te = typeof TextEncoder != 'undefined' && /*#__PURE__*/ new TextEncoder();\n// text decoder\nvar td = typeof TextDecoder != 'undefined' && /*#__PURE__*/ new TextDecoder();\n// text decoder stream\nvar tds = 0;\ntry {\n td.decode(et, { stream: true });\n tds = 1;\n}\ncatch (e) { }\n// decode UTF8\nvar dutf8 = function (d) {\n for (var r = '', i = 0;;) {\n var c = d[i++];\n var eb = (c > 127) + (c > 223) + (c > 239);\n if (i + eb > d.length)\n return { s: r, r: slc(d, i - 1) };\n if (!eb)\n r += String.fromCharCode(c);\n else if (eb == 3) {\n c = ((c & 15) << 18 | (d[i++] & 63) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63)) - 65536,\n r += String.fromCharCode(55296 | (c >> 10), 56320 | (c & 1023));\n }\n else if (eb & 1)\n r += String.fromCharCode((c & 31) << 6 | (d[i++] & 63));\n else\n r += String.fromCharCode((c & 15) << 12 | (d[i++] & 63) << 6 | (d[i++] & 63));\n }\n};\n/**\n * Streaming UTF-8 decoding\n */\nvar DecodeUTF8 = /*#__PURE__*/ (function () {\n /**\n * Creates a UTF-8 decoding stream\n * @param cb The callback to call whenever data is decoded\n */\n function DecodeUTF8(cb) {\n this.ondata = cb;\n if (tds)\n this.t = new TextDecoder();\n else\n this.p = et;\n }\n /**\n * Pushes a chunk to be decoded from UTF-8 binary\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n DecodeUTF8.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n final = !!final;\n if (this.t) {\n this.ondata(this.t.decode(chunk, { stream: true }), final);\n if (final) {\n if (this.t.decode().length)\n err(8);\n this.t = null;\n }\n return;\n }\n if (!this.p)\n err(4);\n var dat = new u8(this.p.length + chunk.length);\n dat.set(this.p);\n dat.set(chunk, this.p.length);\n var _a = dutf8(dat), s = _a.s, r = _a.r;\n if (final) {\n if (r.length)\n err(8);\n this.p = null;\n }\n else\n this.p = r;\n this.ondata(s, final);\n };\n return DecodeUTF8;\n}());\nexport { DecodeUTF8 };\n/**\n * Streaming UTF-8 encoding\n */\nvar EncodeUTF8 = /*#__PURE__*/ (function () {\n /**\n * Creates a UTF-8 decoding stream\n * @param cb The callback to call whenever data is encoded\n */\n function EncodeUTF8(cb) {\n this.ondata = cb;\n }\n /**\n * Pushes a chunk to be encoded to UTF-8\n * @param chunk The string data to push\n * @param final Whether this is the last chunk\n */\n EncodeUTF8.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n if (this.d)\n err(4);\n this.ondata(strToU8(chunk), this.d = final || false);\n };\n return EncodeUTF8;\n}());\nexport { EncodeUTF8 };\n/**\n * Converts a string into a Uint8Array for use with compression/decompression methods\n * @param str The string to encode\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless decoding a binary string.\n * @returns The string encoded in UTF-8/Latin-1 binary\n */\nexport function strToU8(str, latin1) {\n if (latin1) {\n var ar_1 = new u8(str.length);\n for (var i = 0; i < str.length; ++i)\n ar_1[i] = str.charCodeAt(i);\n return ar_1;\n }\n if (te)\n return te.encode(str);\n var l = str.length;\n var ar = new u8(str.length + (str.length >> 1));\n var ai = 0;\n var w = function (v) { ar[ai++] = v; };\n for (var i = 0; i < l; ++i) {\n if (ai + 5 > ar.length) {\n var n = new u8(ai + 8 + ((l - i) << 1));\n n.set(ar);\n ar = n;\n }\n var c = str.charCodeAt(i);\n if (c < 128 || latin1)\n w(c);\n else if (c < 2048)\n w(192 | (c >> 6)), w(128 | (c & 63));\n else if (c > 55295 && c < 57344)\n c = 65536 + (c & 1023 << 10) | (str.charCodeAt(++i) & 1023),\n w(240 | (c >> 18)), w(128 | ((c >> 12) & 63)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63));\n else\n w(224 | (c >> 12)), w(128 | ((c >> 6) & 63)), w(128 | (c & 63));\n }\n return slc(ar, 0, ai);\n}\n/**\n * Converts a Uint8Array to a string\n * @param dat The data to decode to string\n * @param latin1 Whether or not to interpret the data as Latin-1. This should\n * not need to be true unless encoding to binary string.\n * @returns The original UTF-8/Latin-1 string\n */\nexport function strFromU8(dat, latin1) {\n if (latin1) {\n var r = '';\n for (var i = 0; i < dat.length; i += 16384)\n r += String.fromCharCode.apply(null, dat.subarray(i, i + 16384));\n return r;\n }\n else if (td) {\n return td.decode(dat);\n }\n else {\n var _a = dutf8(dat), s = _a.s, r = _a.r;\n if (r.length)\n err(8);\n return s;\n }\n}\n;\n// deflate bit flag\nvar dbf = function (l) { return l == 1 ? 3 : l < 6 ? 2 : l == 9 ? 1 : 0; };\n// skip local zip header\nvar slzh = function (d, b) { return b + 30 + b2(d, b + 26) + b2(d, b + 28); };\n// read zip header\nvar zh = function (d, b, z) {\n var fnl = b2(d, b + 28), efl = b2(d, b + 30), fn = strFromU8(d.subarray(b + 46, b + 46 + fnl), !(b2(d, b + 8) & 2048)), es = b + 46 + fnl;\n var _a = z64hs(d, es, efl, z, b4(d, b + 20), b4(d, b + 24), b4(d, b + 42)), sc = _a[0], su = _a[1], off = _a[2];\n return [b2(d, b + 10), sc, su, fn, es + efl + b2(d, b + 32), off];\n};\n// read zip64 header sizes\nvar z64hs = function (d, b, l, z, sc, su, off) {\n var nsc = sc == 4294967295, nsu = su == 4294967295, noff = off == 4294967295, e = b + l;\n var nf = nsc + nsu + noff;\n if (z && nf) {\n for (; b + 4 < e; b += 4 + b2(d, b + 2)) {\n if (b2(d, b) == 1) {\n return [\n nsc ? b8(d, b + 4 + 8 * nsu) : sc,\n nsu ? b8(d, b + 4) : su,\n noff ? b8(d, b + 4 + 8 * (nsu + nsc)) : off,\n 1\n ];\n }\n }\n // z == 2 for unknown whether or not zip64\n if (z < 2)\n err(13);\n }\n return [sc, su, off, 0];\n};\n// extra field length\nvar exfl = function (ex) {\n var le = 0;\n if (ex) {\n for (var k in ex) {\n var l = ex[k].length;\n if (l > 65535)\n err(9);\n le += l + 4;\n }\n }\n return le;\n};\n// write zip header\nvar wzh = function (d, b, f, fn, u, c, ce, co) {\n var fl = fn.length, ex = f.extra, col = co && co.length;\n var exl = exfl(ex);\n wbytes(d, b, ce != null ? 0x2014B50 : 0x4034B50), b += 4;\n if (ce != null)\n d[b++] = 20, d[b++] = f.os;\n d[b] = 20, b += 2; // spec compliance? what's that?\n d[b++] = (f.flag << 1) | (c < 0 && 8), d[b++] = u && 8;\n d[b++] = f.compression & 255, d[b++] = f.compression >> 8;\n var dt = new Date(f.mtime == null ? Date.now() : f.mtime), y = dt.getFullYear() - 1980;\n if (y < 0 || y > 119)\n err(10);\n wbytes(d, b, (y << 25) | ((dt.getMonth() + 1) << 21) | (dt.getDate() << 16) | (dt.getHours() << 11) | (dt.getMinutes() << 5) | (dt.getSeconds() >> 1)), b += 4;\n if (c != -1) {\n wbytes(d, b, f.crc);\n wbytes(d, b + 4, c < 0 ? -c - 2 : c);\n wbytes(d, b + 8, f.size);\n }\n wbytes(d, b + 12, fl);\n wbytes(d, b + 14, exl), b += 16;\n if (ce != null) {\n wbytes(d, b, col);\n wbytes(d, b + 6, f.attrs);\n wbytes(d, b + 10, ce), b += 14;\n }\n d.set(fn, b);\n b += fl;\n if (exl) {\n for (var k in ex) {\n var exf = ex[k], l = exf.length;\n wbytes(d, b, +k);\n wbytes(d, b + 2, l);\n d.set(exf, b + 4), b += 4 + l;\n }\n }\n if (col)\n d.set(co, b), b += col;\n return b;\n};\n// write zip footer (end of central directory)\nvar wzf = function (o, b, c, d, e) {\n wbytes(o, b, 0x6054B50); // skip disk\n wbytes(o, b + 8, c);\n wbytes(o, b + 10, c);\n wbytes(o, b + 12, d);\n wbytes(o, b + 16, e);\n};\n/**\n * A pass-through stream to keep data uncompressed in a ZIP archive.\n */\nvar ZipPassThrough = /*#__PURE__*/ (function () {\n /**\n * Creates a pass-through stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n */\n function ZipPassThrough(filename) {\n this.filename = filename;\n this.c = crc();\n this.size = 0;\n this.compression = 0;\n }\n /**\n * Processes a chunk and pushes to the output stream. You can override this\n * method in a subclass for custom behavior, but by default this passes\n * the data through. You must call this.ondata(err, chunk, final) at some\n * point in this method.\n * @param chunk The chunk to process\n * @param final Whether this is the last chunk\n */\n ZipPassThrough.prototype.process = function (chunk, final) {\n this.ondata(null, chunk, final);\n };\n /**\n * Pushes a chunk to be added. If you are subclassing this with a custom\n * compression algorithm, note that you must push data from the source\n * file only, pre-compression.\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n ZipPassThrough.prototype.push = function (chunk, final) {\n if (!this.ondata)\n err(5);\n this.c.p(chunk);\n this.size += chunk.length;\n if (final)\n this.crc = this.c.d();\n // we shouldn't really do this cast, but properly handling ArrayBufferLike\n // makes the API unergonomic with Buffer\n this.process(chunk, final || false);\n };\n return ZipPassThrough;\n}());\nexport { ZipPassThrough };\n// I don't extend because TypeScript extension adds 1kB of runtime bloat\n/**\n * Streaming DEFLATE compression for ZIP archives. Prefer using AsyncZipDeflate\n * for better performance\n */\nvar ZipDeflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n * @param opts The compression options\n */\n function ZipDeflate(filename, opts) {\n var _this = this;\n if (!opts)\n opts = {};\n ZipPassThrough.call(this, filename);\n this.d = new Deflate(opts, function (dat, final) {\n _this.ondata(null, dat, final);\n });\n this.compression = 8;\n this.flag = dbf(opts.level);\n }\n ZipDeflate.prototype.process = function (chunk, final) {\n try {\n this.d.push(chunk, final);\n }\n catch (e) {\n this.ondata(e, null, final);\n }\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n ZipDeflate.prototype.push = function (chunk, final) {\n ZipPassThrough.prototype.push.call(this, chunk, final);\n };\n return ZipDeflate;\n}());\nexport { ZipDeflate };\n/**\n * Asynchronous streaming DEFLATE compression for ZIP archives\n */\nvar AsyncZipDeflate = /*#__PURE__*/ (function () {\n /**\n * Creates an asynchronous DEFLATE stream that can be added to ZIP archives\n * @param filename The filename to associate with this data stream\n * @param opts The compression options\n */\n function AsyncZipDeflate(filename, opts) {\n var _this = this;\n if (!opts)\n opts = {};\n ZipPassThrough.call(this, filename);\n this.d = new AsyncDeflate(opts, function (err, dat, final) {\n _this.ondata(err, dat, final);\n });\n this.compression = 8;\n this.flag = dbf(opts.level);\n this.terminate = this.d.terminate;\n }\n AsyncZipDeflate.prototype.process = function (chunk, final) {\n this.d.push(chunk, final);\n };\n /**\n * Pushes a chunk to be deflated\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n AsyncZipDeflate.prototype.push = function (chunk, final) {\n ZipPassThrough.prototype.push.call(this, chunk, final);\n };\n return AsyncZipDeflate;\n}());\nexport { AsyncZipDeflate };\n// TODO: Better tree shaking\n/**\n * A zippable archive to which files can incrementally be added\n */\nvar Zip = /*#__PURE__*/ (function () {\n /**\n * Creates an empty ZIP archive to which files can be added\n * @param cb The callback to call whenever data for the generated ZIP archive\n * is available\n */\n function Zip(cb) {\n this.ondata = cb;\n this.u = [];\n this.d = 1;\n }\n /**\n * Adds a file to the ZIP archive\n * @param file The file stream to add\n */\n Zip.prototype.add = function (file) {\n var _this = this;\n if (!this.ondata)\n err(5);\n // finishing or finished\n if (this.d & 2)\n this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, false);\n else {\n var f = strToU8(file.filename), fl_1 = f.length;\n var com = file.comment, o = com && strToU8(com);\n var u = fl_1 != file.filename.length || (o && (com.length != o.length));\n var hl_1 = fl_1 + exfl(file.extra) + 30;\n if (fl_1 > 65535)\n this.ondata(err(11, 0, 1), null, false);\n var header = new u8(hl_1);\n wzh(header, 0, file, f, u, -1);\n var chks_1 = [header];\n var pAll_1 = function () {\n for (var _i = 0, chks_2 = chks_1; _i < chks_2.length; _i++) {\n var chk = chks_2[_i];\n _this.ondata(null, chk, false);\n }\n chks_1 = [];\n };\n var tr_1 = this.d;\n this.d = 0;\n var ind_1 = this.u.length;\n var uf_1 = mrg(file, {\n f: f,\n u: u,\n o: o,\n t: function () {\n if (file.terminate)\n file.terminate();\n },\n r: function () {\n pAll_1();\n if (tr_1) {\n var nxt = _this.u[ind_1 + 1];\n if (nxt)\n nxt.r();\n else\n _this.d = 1;\n }\n tr_1 = 1;\n }\n });\n var cl_1 = 0;\n file.ondata = function (err, dat, final) {\n if (err) {\n _this.ondata(err, dat, final);\n _this.terminate();\n }\n else {\n cl_1 += dat.length;\n chks_1.push(dat);\n if (final) {\n var dd = new u8(16);\n wbytes(dd, 0, 0x8074B50);\n wbytes(dd, 4, file.crc);\n wbytes(dd, 8, cl_1);\n wbytes(dd, 12, file.size);\n chks_1.push(dd);\n uf_1.c = cl_1, uf_1.b = hl_1 + cl_1 + 16, uf_1.crc = file.crc, uf_1.size = file.size;\n if (tr_1)\n uf_1.r();\n tr_1 = 1;\n }\n else if (tr_1)\n pAll_1();\n }\n };\n this.u.push(uf_1);\n }\n };\n /**\n * Ends the process of adding files and prepares to emit the final chunks.\n * This *must* be called after adding all desired files for the resulting\n * ZIP file to work properly.\n */\n Zip.prototype.end = function () {\n var _this = this;\n if (this.d & 2) {\n this.ondata(err(4 + (this.d & 1) * 8, 0, 1), null, true);\n return;\n }\n if (this.d)\n this.e();\n else\n this.u.push({\n r: function () {\n if (!(_this.d & 1))\n return;\n _this.u.splice(-1, 1);\n _this.e();\n },\n t: function () { }\n });\n this.d = 3;\n };\n Zip.prototype.e = function () {\n var bt = 0, l = 0, tl = 0;\n for (var _i = 0, _a = this.u; _i < _a.length; _i++) {\n var f = _a[_i];\n tl += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0);\n }\n var out = new u8(tl + 22);\n for (var _b = 0, _c = this.u; _b < _c.length; _b++) {\n var f = _c[_b];\n wzh(out, bt, f, f.f, f.u, -f.c - 2, l, f.o);\n bt += 46 + f.f.length + exfl(f.extra) + (f.o ? f.o.length : 0), l += f.b;\n }\n wzf(out, bt, this.u.length, tl, l);\n this.ondata(null, out, true);\n this.d = 2;\n };\n /**\n * A method to terminate any internal workers used by the stream. Subsequent\n * calls to add() will fail.\n */\n Zip.prototype.terminate = function () {\n for (var _i = 0, _a = this.u; _i < _a.length; _i++) {\n var f = _a[_i];\n f.t();\n }\n this.d = 2;\n };\n return Zip;\n}());\nexport { Zip };\nexport function zip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n var r = {};\n fltn(data, '', r, opts);\n var k = Object.keys(r);\n var lft = k.length, o = 0, tot = 0;\n var slft = lft, files = new Array(lft);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var cbd = function (a, b) {\n mt(function () { cb(a, b); });\n };\n mt(function () { cbd = cb; });\n var cbf = function () {\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n tot = 0;\n for (var i = 0; i < slft; ++i) {\n var f = files[i];\n try {\n var l = f.c.length;\n wzh(out, tot, f, f.f, f.u, l);\n var badd = 30 + f.f.length + exfl(f.extra);\n var loc = tot + badd;\n out.set(f.c, loc);\n wzh(out, o, f, f.f, f.u, l, tot, f.m), o += 16 + badd + (f.m ? f.m.length : 0), tot = loc + l;\n }\n catch (e) {\n return cbd(e, null);\n }\n }\n wzf(out, o, files.length, cdl, oe);\n cbd(null, out);\n };\n if (!lft)\n cbf();\n var _loop_1 = function (i) {\n var fn = k[i];\n var _a = r[fn], file = _a[0], p = _a[1];\n var c = crc(), size = file.length;\n c.p(file);\n var f = strToU8(fn), s = f.length;\n var com = p.comment, m = com && strToU8(com), ms = m && m.length;\n var exl = exfl(p.extra);\n var compression = p.level == 0 ? 0 : 8;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cbd(e, null);\n }\n else {\n var l = d.length;\n files[i] = mrg(p, {\n size: size,\n crc: c.d(),\n c: d,\n f: f,\n m: m,\n u: s != fn.length || (m && (com.length != ms)),\n compression: compression\n });\n o += 30 + s + exl + l;\n tot += 76 + 2 * (s + exl) + (ms || 0) + l;\n if (!--lft)\n cbf();\n }\n };\n if (s > 65535)\n cbl(err(11, 0, 1), null);\n if (!compression)\n cbl(null, file);\n else if (size < 160000) {\n try {\n cbl(null, deflateSync(file, p));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(deflate(file, p, cbl));\n };\n // Cannot use lft because it can decrease\n for (var i = 0; i < slft; ++i) {\n _loop_1(i);\n }\n return tAll;\n}\n/**\n * Synchronously creates a ZIP file. Prefer using `zip` for better performance\n * with more than one file.\n * @param data The directory structure for the ZIP archive\n * @param opts The main options, merged with per-file options\n * @returns The generated ZIP archive\n */\nexport function zipSync(data, opts) {\n if (!opts)\n opts = {};\n var r = {};\n var files = [];\n fltn(data, '', r, opts);\n var o = 0;\n var tot = 0;\n for (var fn in r) {\n var _a = r[fn], file = _a[0], p = _a[1];\n var compression = p.level == 0 ? 0 : 8;\n var f = strToU8(fn), s = f.length;\n var com = p.comment, m = com && strToU8(com), ms = m && m.length;\n var exl = exfl(p.extra);\n if (s > 65535)\n err(11);\n var d = compression ? deflateSync(file, p) : file, l = d.length;\n var c = crc();\n c.p(file);\n files.push(mrg(p, {\n size: file.length,\n crc: c.d(),\n c: d,\n f: f,\n m: m,\n u: s != fn.length || (m && (com.length != ms)),\n o: o,\n compression: compression\n }));\n o += 30 + s + exl + l;\n tot += 76 + 2 * (s + exl) + (ms || 0) + l;\n }\n var out = new u8(tot + 22), oe = o, cdl = tot - o;\n for (var i = 0; i < files.length; ++i) {\n var f = files[i];\n wzh(out, f.o, f, f.f, f.u, f.c.length);\n var badd = 30 + f.f.length + exfl(f.extra);\n out.set(f.c, f.o + badd);\n wzh(out, o, f, f.f, f.u, f.c.length, f.o, f.m), o += 16 + badd + (f.m ? f.m.length : 0);\n }\n wzf(out, o, files.length, cdl, oe);\n return out;\n}\n/**\n * Streaming pass-through decompression for ZIP archives\n */\nvar UnzipPassThrough = /*#__PURE__*/ (function () {\n function UnzipPassThrough() {\n }\n UnzipPassThrough.prototype.push = function (chunk, final) {\n // same as ZipPassThrough: cast to retain Buffer ergonomics\n this.ondata(null, chunk, final);\n };\n UnzipPassThrough.compression = 0;\n return UnzipPassThrough;\n}());\nexport { UnzipPassThrough };\n/**\n * Streaming DEFLATE decompression for ZIP archives. Prefer AsyncZipInflate for\n * better performance.\n */\nvar UnzipInflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE decompression that can be used in ZIP archives\n */\n function UnzipInflate() {\n var _this = this;\n this.i = new Inflate(function (dat, final) {\n _this.ondata(null, dat, final);\n });\n }\n UnzipInflate.prototype.push = function (chunk, final) {\n try {\n this.i.push(chunk, final);\n }\n catch (e) {\n this.ondata(e, null, final);\n }\n };\n UnzipInflate.compression = 8;\n return UnzipInflate;\n}());\nexport { UnzipInflate };\n/**\n * Asynchronous streaming DEFLATE decompression for ZIP archives\n */\nvar AsyncUnzipInflate = /*#__PURE__*/ (function () {\n /**\n * Creates a DEFLATE decompression that can be used in ZIP archives\n */\n function AsyncUnzipInflate(_, sz) {\n var _this = this;\n if (sz < 320000) {\n this.i = new Inflate(function (dat, final) {\n _this.ondata(null, dat, final);\n });\n }\n else {\n this.i = new AsyncInflate(function (err, dat, final) {\n _this.ondata(err, dat, final);\n });\n this.terminate = this.i.terminate;\n }\n }\n AsyncUnzipInflate.prototype.push = function (chunk, final) {\n if (this.i.terminate)\n chunk = slc(chunk, 0);\n this.i.push(chunk, final);\n };\n AsyncUnzipInflate.compression = 8;\n return AsyncUnzipInflate;\n}());\nexport { AsyncUnzipInflate };\n/**\n * A ZIP archive decompression stream that emits files as they are discovered\n */\nvar Unzip = /*#__PURE__*/ (function () {\n /**\n * Creates a ZIP decompression stream\n * @param cb The callback to call whenever a file in the ZIP archive is found\n */\n function Unzip(cb) {\n this.onfile = cb;\n this.k = [];\n this.o = {\n 0: UnzipPassThrough\n };\n this.p = et;\n }\n /**\n * Pushes a chunk to be unzipped\n * @param chunk The chunk to push\n * @param final Whether this is the last chunk\n */\n Unzip.prototype.push = function (chunk, final) {\n var _this = this;\n if (!this.onfile)\n err(5);\n if (!this.p)\n err(4);\n if (this.c > 0) {\n var len = Math.min(this.c, chunk.length);\n var toAdd = chunk.subarray(0, len);\n this.c -= len;\n if (this.d)\n this.d.push(toAdd, !this.c);\n else\n this.k[0].push(toAdd);\n chunk = chunk.subarray(len);\n if (chunk.length)\n return this.push(chunk, final);\n }\n else {\n var f = 0, i = 0, is = void 0, buf = void 0;\n if (!this.p.length)\n buf = chunk;\n else if (!chunk.length)\n buf = this.p;\n else {\n buf = new u8(this.p.length + chunk.length);\n buf.set(this.p), buf.set(chunk, this.p.length);\n }\n var l = buf.length, oc = this.c, add = oc && this.d;\n var _loop_2 = function () {\n var sig = b4(buf, i);\n if (sig == 0x4034B50) {\n f = 1, is = i;\n this_1.d = null;\n this_1.c = 0;\n var bf = b2(buf, i + 6), cmp_1 = b2(buf, i + 8), u = bf & 2048, dd = bf & 8, fnl = b2(buf, i + 26), es = b2(buf, i + 28);\n if (l > i + 30 + fnl + es) {\n var chks_3 = [];\n this_1.k.unshift(chks_3);\n f = 2;\n var lsc = b4(buf, i + 18), lsu = b4(buf, i + 22);\n var fn_1 = strFromU8(buf.subarray(i + 30, i += 30 + fnl), !u);\n var _a = z64hs(buf, i, es, 2, lsc, lsu, 0), sc_1 = _a[0], su_1 = _a[1], z64 = _a[3];\n if (dd)\n sc_1 = -1 - z64;\n i += es;\n this_1.c = sc_1;\n var d_1;\n var file_1 = {\n name: fn_1,\n compression: cmp_1,\n start: function () {\n if (!file_1.ondata)\n err(5);\n if (!sc_1)\n file_1.ondata(null, et, true);\n else {\n var ctr = _this.o[cmp_1];\n if (!ctr)\n file_1.ondata(err(14, 'unknown compression type ' + cmp_1, 1), null, false);\n d_1 = sc_1 < 0 ? new ctr(fn_1) : new ctr(fn_1, sc_1, su_1);\n d_1.ondata = function (err, dat, final) { file_1.ondata(err, dat, final); };\n for (var _i = 0, chks_4 = chks_3; _i < chks_4.length; _i++) {\n var dat = chks_4[_i];\n d_1.push(dat, false);\n }\n if (_this.k[0] == chks_3 && _this.c)\n _this.d = d_1;\n else\n d_1.push(et, true);\n }\n },\n terminate: function () {\n if (d_1 && d_1.terminate)\n d_1.terminate();\n }\n };\n if (sc_1 >= 0)\n file_1.size = sc_1, file_1.originalSize = su_1;\n this_1.onfile(file_1);\n }\n return \"break\";\n }\n else if (oc) {\n if (sig == 0x8074B50) {\n is = i += 12 + (oc == -2 && 8), f = 3, this_1.c = 0;\n return \"break\";\n }\n else if (sig == 0x2014B50) {\n is = i -= 4, f = 3, this_1.c = 0;\n return \"break\";\n }\n }\n };\n var this_1 = this;\n for (; i < l - 4; ++i) {\n var state_1 = _loop_2();\n if (state_1 === \"break\")\n break;\n }\n this.p = et;\n if (oc < 0) {\n var dat = f ? buf.subarray(0, is - 12 - (oc == -2 && 8) - (b4(buf, is - 16) == 0x8074B50 && 4)) : buf.subarray(0, i);\n if (add)\n add.push(dat, !!f);\n else\n this.k[+(f == 2)].push(dat);\n }\n if (f & 2)\n return this.push(buf.subarray(i), final);\n this.p = buf.subarray(i);\n }\n if (final) {\n if (this.c)\n err(13);\n this.p = null;\n }\n };\n /**\n * Registers a decoder with the stream, allowing for files compressed with\n * the compression type provided to be expanded correctly\n * @param decoder The decoder constructor\n */\n Unzip.prototype.register = function (decoder) {\n this.o[decoder.compression] = decoder;\n };\n return Unzip;\n}());\nexport { Unzip };\nvar mt = typeof queueMicrotask == 'function' ? queueMicrotask : typeof setTimeout == 'function' ? setTimeout : function (fn) { fn(); };\nexport function unzip(data, opts, cb) {\n if (!cb)\n cb = opts, opts = {};\n if (typeof cb != 'function')\n err(7);\n var term = [];\n var tAll = function () {\n for (var i = 0; i < term.length; ++i)\n term[i]();\n };\n var files = {};\n var cbd = function (a, b) {\n mt(function () { cb(a, b); });\n };\n mt(function () { cbd = cb; });\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558) {\n cbd(err(13, 0, 1), null);\n return tAll;\n }\n }\n ;\n var lft = b2(data, e + 8);\n if (lft) {\n var c = lft;\n var o = b4(data, e + 16);\n var z = b4(data, e - 20) == 0x7064B50;\n if (z) {\n var ze = b4(data, e - 12);\n z = b4(data, ze) == 0x6064B50;\n if (z) {\n c = lft = b4(data, ze + 32);\n o = b4(data, ze + 48);\n }\n }\n var fltr = opts && opts.filter;\n var _loop_3 = function (i) {\n var _a = zh(data, o, z), c_1 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n var cbl = function (e, d) {\n if (e) {\n tAll();\n cbd(e, null);\n }\n else {\n if (d)\n files[fn] = d;\n if (!--lft)\n cbd(null, files);\n }\n };\n if (!fltr || fltr({\n name: fn,\n size: sc,\n originalSize: su,\n compression: c_1\n })) {\n if (!c_1)\n cbl(null, slc(data, b, b + sc));\n else if (c_1 == 8) {\n var infl = data.subarray(b, b + sc);\n // Synchronously decompress under 512KB, or barely-compressed data\n if (su < 524288 || sc > 0.8 * su) {\n try {\n cbl(null, inflateSync(infl, { out: new u8(su) }));\n }\n catch (e) {\n cbl(e, null);\n }\n }\n else\n term.push(inflate(infl, { size: su }, cbl));\n }\n else\n cbl(err(14, 'unknown compression type ' + c_1, 1), null);\n }\n else\n cbl(null, null);\n };\n for (var i = 0; i < c; ++i) {\n _loop_3(i);\n }\n }\n else\n cbd(null, {});\n return tAll;\n}\n/**\n * Synchronously decompresses a ZIP archive. Prefer using `unzip` for better\n * performance with more than one file.\n * @param data The raw compressed ZIP file\n * @param opts The ZIP extraction options\n * @returns The decompressed files\n */\nexport function unzipSync(data, opts) {\n var files = {};\n var e = data.length - 22;\n for (; b4(data, e) != 0x6054B50; --e) {\n if (!e || data.length - e > 65558)\n err(13);\n }\n ;\n var c = b2(data, e + 8);\n if (!c)\n return {};\n var o = b4(data, e + 16);\n var z = b4(data, e - 20) == 0x7064B50;\n if (z) {\n var ze = b4(data, e - 12);\n z = b4(data, ze) == 0x6064B50;\n if (z) {\n c = b4(data, ze + 32);\n o = b4(data, ze + 48);\n }\n }\n var fltr = opts && opts.filter;\n for (var i = 0; i < c; ++i) {\n var _a = zh(data, o, z), c_2 = _a[0], sc = _a[1], su = _a[2], fn = _a[3], no = _a[4], off = _a[5], b = slzh(data, off);\n o = no;\n if (!fltr || fltr({\n name: fn,\n size: sc,\n originalSize: su,\n compression: c_2\n })) {\n if (!c_2)\n files[fn] = slc(data, b, b + sc);\n else if (c_2 == 8)\n files[fn] = inflateSync(data.subarray(b, b + sc), { out: new u8(su) });\n else\n err(14, 'unknown compression type ' + c_2);\n }\n }\n return files;\n}\n","import { Zip, ZipDeflate } from 'fflate'\nimport type { Cell } from './cells'\n\n/** The most data rows a sheet holds: Excel's 1,048,576 rows, less the header. */\nexport const xlsxMaxRows = 1_048_575\n\n// Excel refuses a cell of more text than this.\nconst maxCellText = 32_767\n\n// Characters XML 1.0 cannot hold at all, which would make the file unreadable.\nconst invalidXml = /[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f￾￿]/g\n\nconst escapeXml = (text: string) =>\n text.replace(invalidXml, '').replaceAll('&', '&amp;').replaceAll('<', '&lt;').replaceAll('>', '&gt;').replaceAll('\"', '&quot;')\n\n/** A column's letters: 0 is A, 25 is Z, 26 is AA. */\nexport const columnLetters = (index: number): string => {\n const letter = String.fromCharCode(65 + (index % 26))\n return index < 26 ? letter : columnLetters(Math.floor(index / 26) - 1) + letter\n}\n\nconst textCell = (ref: string, text: string, style = '') =>\n `<c r=\"${ref}\"${style} t=\"inlineStr\"><is><t xml:space=\"preserve\">${escapeXml(text.slice(0, maxCellText))}</t></is></c>`\n\nconst xml = '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\\n'\nconst mainNs = 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'\nconst relNs = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships'\nconst packageRelNs = 'http://schemas.openxmlformats.org/package/2006/relationships'\n\nconst contentTypes = `${xml}<Types xmlns=\"http://schemas.openxmlformats.org/package/2006/content-types\"><Default Extension=\"rels\" ContentType=\"application/vnd.openxmlformats-package.relationships+xml\"/><Default Extension=\"xml\" ContentType=\"application/xml\"/><Override PartName=\"/xl/workbook.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet.main+xml\"/><Override PartName=\"/xl/worksheets/sheet1.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml\"/><Override PartName=\"/xl/styles.xml\" ContentType=\"application/vnd.openxmlformats-officedocument.spreadsheetml.styles+xml\"/></Types>`\nconst rootRels = `${xml}<Relationships xmlns=\"${packageRelNs}\"><Relationship Id=\"rId1\" Type=\"${relNs}/officeDocument\" Target=\"xl/workbook.xml\"/></Relationships>`\nconst workbookRels = `${xml}<Relationships xmlns=\"${packageRelNs}\"><Relationship Id=\"rId1\" Type=\"${relNs}/worksheet\" Target=\"worksheets/sheet1.xml\"/><Relationship Id=\"rId2\" Type=\"${relNs}/styles\" Target=\"styles.xml\"/></Relationships>`\n\n// A sheet name is at most 31 characters, without : \\ / ? * [ ]\nconst sheetName = (name: string) => name.replace(/[:\\\\/?*[\\]]/g, ' ').slice(0, 31).trim() || 'Sheet1'\n\nconst workbook = (name: string) =>\n `${xml}<workbook xmlns=\"${mainNs}\" xmlns:r=\"${relNs}\"><sheets><sheet name=\"${escapeXml(sheetName(name))}\" sheetId=\"1\" r:id=\"rId1\"/></sheets></workbook>`\n\n// Style 0 is the default and 1 the bold header; each number format after them gets a style of its own, from 2.\nconst styles = (formats: string[]) => {\n const numFmts = formats.map((code, index) => `<numFmt numFmtId=\"${164 + index}\" formatCode=\"${escapeXml(code)}\"/>`).join('')\n const xfs = formats.map((_, index) => `<xf numFmtId=\"${164 + index}\" fontId=\"0\" fillId=\"0\" borderId=\"0\" xfId=\"0\" applyNumberFormat=\"1\"/>`).join('')\n return `${xml}<styleSheet xmlns=\"${mainNs}\">${formats.length > 0 ? `<numFmts count=\"${formats.length}\">${numFmts}</numFmts>` : ''}<fonts count=\"2\"><font><sz val=\"11\"/><name val=\"Calibri\"/></font><font><b/><sz val=\"11\"/><name val=\"Calibri\"/></font></fonts><fills count=\"2\"><fill><patternFill patternType=\"none\"/></fill><fill><patternFill patternType=\"gray125\"/></fill></fills><borders count=\"1\"><border><left/><right/><top/><bottom/><diagonal/></border></borders><cellStyleXfs count=\"1\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\"/></cellStyleXfs><cellXfs count=\"${2 + formats.length}\"><xf numFmtId=\"0\" fontId=\"0\" fillId=\"0\" borderId=\"0\" xfId=\"0\"/><xf numFmtId=\"0\" fontId=\"1\" fillId=\"0\" borderId=\"0\" xfId=\"0\" applyFont=\"1\"/>${xfs}</cellXfs><cellStyles count=\"1\"><cellStyle name=\"Normal\" xfId=\"0\" builtinId=\"0\"/></cellStyles></styleSheet>`\n}\n\nconst encoder = new TextEncoder()\n\nexport type XlsxSheet = {\n /** The sheet's name: the resource's label. */\n name: string\n headers: string[]\n /** Each column's width in characters. */\n widths: number[]\n}\n\n/**\n * Writes a one-sheet .xlsx file as it goes, handing each compressed piece to `onChunk`: a bold, frozen header row, then\n * `rows` as often as they come, and `finish` once. Text is written inline in its cell rather than in a table of shared\n * strings, so the writer holds no more than the rows it is given.\n */\nexport const createXlsxWriter = (sheet: XlsxSheet, onChunk: (chunk: Uint8Array, final: boolean) => void) => {\n const zip = new Zip((error, chunk, final) => {\n if (error) throw error\n onChunk(chunk, final)\n })\n const add = (path: string, text: string) => {\n const file = new ZipDeflate(path, { level: 6 })\n zip.add(file)\n file.push(encoder.encode(text), true)\n }\n add('[Content_Types].xml', contentTypes)\n add('_rels/.rels', rootRels)\n add('xl/workbook.xml', workbook(sheet.name))\n add('xl/_rels/workbook.xml.rels', workbookRels)\n\n const worksheet = new ZipDeflate('xl/worksheets/sheet1.xml', { level: 6 })\n zip.add(worksheet)\n const cols = sheet.widths.map((width, index) => `<col min=\"${index + 1}\" max=\"${index + 1}\" width=\"${width}\" customWidth=\"1\"/>`).join('')\n const frozen = '<sheetViews><sheetView workbookViewId=\"0\"><pane ySplit=\"1\" topLeftCell=\"A2\" activePane=\"bottomLeft\" state=\"frozen\"/></sheetView></sheetViews>'\n const header = `<row r=\"1\">${sheet.headers.map((text, index) => textCell(`${columnLetters(index)}1`, text, ' s=\"1\"')).join('')}</row>`\n worksheet.push(encoder.encode(`${xml}<worksheet xmlns=\"${mainNs}\">${frozen}${cols ? `<cols>${cols}</cols>` : ''}<sheetData>${header}`))\n\n const letters = sheet.headers.map((_, index) => columnLetters(index))\n const formats: string[] = []\n const styleOf = (format: string) => {\n const index = formats.indexOf(format)\n if (index >= 0) return index + 2\n formats.push(format)\n return formats.length + 1\n }\n const cellXml = (cell: Cell, ref: string) => {\n switch (cell.kind) {\n case 'empty':\n return ''\n case 'text':\n return textCell(ref, cell.value)\n case 'boolean':\n return `<c r=\"${ref}\" t=\"b\"><v>${cell.value ? 1 : 0}</v></c>`\n case 'number':\n return `<c r=\"${ref}\"${cell.format ? ` s=\"${styleOf(cell.format)}\"` : ''}><v>${cell.value}</v></c>`\n }\n }\n\n let rowNumber = 1\n const rows = (cells: Cell[][]) => {\n let text = ''\n for (const row of cells) {\n rowNumber += 1\n if (rowNumber > xlsxMaxRows + 1) throw new Error(`A sheet holds at most ${xlsxMaxRows} rows`)\n text += `<row r=\"${rowNumber}\">${row.map((cell, index) => cellXml(cell, `${letters[index]}${rowNumber}`)).join('')}</row>`\n }\n worksheet.push(encoder.encode(text))\n }\n\n const finish = () => {\n worksheet.push(encoder.encode('</sheetData></worksheet>'), true)\n add('xl/styles.xml', styles(formats))\n zip.end()\n }\n\n return { rows, finish }\n}\n","import type { RelatedLabels } from '@protobase/client'\nimport { csvText, xlsxCell, type ExportColumn, type ExportMode } from './cells'\nimport { csvField, csvLine, csvTextField, utf8Bom } from './csv'\nimport { createXlsxWriter } from './xlsx'\n\nexport type ExportFormat = 'xlsx' | 'csv'\n\n/** What a file is built from, everything plain data so it can be posted to a worker. */\nexport type ExportPlan = {\n format: ExportFormat\n mode: ExportMode\n /** The resource's label, which names the sheet. */\n name: string\n columns: ExportColumn[]\n}\n\nexport type ExportRecord = Record<string, unknown>\n\n// Fields whose CSV text is free text someone typed, which a spreadsheet could take for a formula.\nconst typedText = new Set(['text', 'uuid', 'enum', 'relation', 'file', 'json', 'currency', 'country'])\n\nconst minWidth = 8\nconst maxWidth = 60\n\n/** Each column's width in characters, room for its header and the longest value of the first page as shown. */\nexport const columnWidths = (columns: ExportColumn[], records: ExportRecord[], labels: RelatedLabels) =>\n columns.map((column) => {\n const longest = Math.max(column.header.length, ...records.map((record) => csvText(column, record[column.name], labels, 'shown').length))\n return Math.min(maxWidth, Math.max(minWidth, longest + 2))\n })\n\nconst createCsvBuilder = (plan: ExportPlan, onChunk: (chunk: Uint8Array) => void) => {\n const encoder = new TextEncoder()\n onChunk(utf8Bom)\n onChunk(encoder.encode(csvLine(plan.columns.map((column) => csvField(column.header)))))\n const field = (column: ExportColumn, record: ExportRecord, labels: RelatedLabels) => {\n const text = csvText(column, record[column.name], labels, plan.mode)\n return typedText.has(column.field.type) ? csvTextField(text) : csvField(text)\n }\n return {\n page: (records: ExportRecord[], labels: RelatedLabels) => {\n onChunk(encoder.encode(records.map((record) => csvLine(plan.columns.map((column) => field(column, record, labels)))).join('')))\n },\n finish: () => undefined,\n }\n}\n\n// The columns' widths come from the first page, so the sheet starts with it.\nconst createXlsxBuilder = (plan: ExportPlan, onChunk: (chunk: Uint8Array) => void) => {\n let writer: ReturnType<typeof createXlsxWriter> | undefined\n const start = (records: ExportRecord[], labels: RelatedLabels) =>\n createXlsxWriter({ name: plan.name, headers: plan.columns.map((column) => column.header), widths: columnWidths(plan.columns, records, labels) }, onChunk)\n return {\n page: (records: ExportRecord[], labels: RelatedLabels) => {\n writer ??= start(records, labels)\n writer.rows(records.map((record) => plan.columns.map((column) => xlsxCell(column, record[column.name], labels, plan.mode))))\n },\n finish: () => {\n writer ??= start([], {})\n writer.finish()\n },\n }\n}\n\n/**\n * Builds an export file page by page: `page` with each page of records and the names of the records their relations\n * point at, then `finish` once. Each piece of the file goes to `onChunk` as soon as it is made.\n */\nexport const createExportBuilder = (plan: ExportPlan, onChunk: (chunk: Uint8Array) => void) =>\n plan.format === 'csv' ? createCsvBuilder(plan, onChunk) : createXlsxBuilder(plan, onChunk)\n","import type { RelatedLabels } from '@protobase/client'\nimport type { Locale } from '@protobase/schema/internal'\nimport { createExportBuilder, type ExportPlan, type ExportRecord } from './builder'\nimport { text } from './messages'\n\n/** What the page sends the worker that builds a file, one message after the other. */\nexport type ToBuilder = { kind: 'start'; plan: ExportPlan; locale: Locale } | { kind: 'page'; records: ExportRecord[]; labels: RelatedLabels } | { kind: 'finish' }\n\n/** The worker's answer to each message: the bytes of the file it made from it, which may be none. */\nexport type FromBuilder = { bytes: Uint8Array }\n\n/** Builds a file from messages, each answered with the bytes it adds to the file. */\nexport type BuilderPort = { send: (message: ToBuilder) => Promise<Uint8Array>; close: () => void }\n\nconst joined = (chunks: Uint8Array[]) => {\n const bytes = new Uint8Array(chunks.reduce((size, chunk) => size + chunk.length, 0))\n let offset = 0\n for (const chunk of chunks) {\n bytes.set(chunk, offset)\n offset += chunk.length\n }\n return bytes\n}\n\n/** Handles one message at a time, as the worker does, returning the bytes it made; used by the worker and by tests. */\nexport const createBuilderHandler = () => {\n let builder: ReturnType<typeof createExportBuilder> | undefined\n let chunks: Uint8Array[] = []\n return (message: ToBuilder) => {\n if (message.kind === 'start') builder = createExportBuilder(message.plan, (chunk) => chunks.push(chunk))\n else if (!builder) throw new Error('The export was not started')\n else if (message.kind === 'page') builder.page(message.records, message.labels)\n else builder.finish()\n const bytes = joined(chunks)\n chunks = []\n return bytes\n }\n}\n\n/** A port that builds on the page itself, for tests and stories. */\nexport const createInlinePort = (): BuilderPort => {\n const handle = createBuilderHandler()\n return { send: async (message) => handle(message), close: () => undefined }\n}\n\n/**\n * A port to a Web Worker that builds the file, so compressing it never holds up the page. The worker answers messages\n * in the order they came; an error in it fails every message still waiting.\n */\nexport const createWorkerPort = (): BuilderPort => {\n const worker = new Worker(new URL('./export-worker.ts', import.meta.url), { type: 'module', name: 'protobase-export' })\n const waiting: Array<{ resolve: (bytes: Uint8Array) => void; reject: (error: Error) => void }> = []\n worker.onmessage = (event: MessageEvent<FromBuilder>) => waiting.shift()?.resolve(event.data.bytes)\n worker.onerror = (event) => {\n event.preventDefault()\n const error = new Error(text('couldNotBuild', event.message))\n for (const entry of waiting.splice(0)) entry.reject(error)\n }\n return {\n send: (message) => new Promise((resolve, reject) => {\n waiting.push({ resolve, reject })\n worker.postMessage(message)\n }),\n close: () => worker.terminate(),\n }\n}\n","/// <reference lib=\"webworker\" />\nimport { setFallbackLocale } from '../../locale/active-locale'\nimport { createBuilderHandler, type FromBuilder, type ToBuilder } from './builder-port'\n\n// Builds an export file off the page's thread: each message's bytes go back as they are made, moved rather than copied.\nconst handle = createBuilderHandler()\nconst scope = self as unknown as DedicatedWorkerGlobalScope\n\n// The shown values are written in the page's language, which the start of each file names.\nscope.onmessage = (event: MessageEvent<ToBuilder>) => {\n if (event.data.kind === 'start') setFallbackLocale(event.data.locale)\n const bytes = handle(event.data)\n scope.postMessage({ bytes } satisfies FromBuilder, [bytes.buffer])\n}\n"],"ignoreList":[12],"mappings":"YAKA,IAAIK,EAAmB,KAIVC,MAAoCD,EAGpCE,EAAqB,GAAmB,CACnD,EAAWC,CACb,EAWMC,EAAqC,CAAE,GAAI,QAAS,GAAI,OAAQ,EAGzDC,MAAkBD,EAAWH,EAAa,GC3B1CK,GAAa,EAAe,IAAoCC,IAASC,IAAUA,ECC1FC,kBAAQ,IAAI,IAGLC,GAAmB,EAAa,IAAgC,CAC3E,IAAMC,EAAMN,EAAU,EAChBO,EAAK,GAAGD,EAAI,GAAGE,IAErB,OADKJ,EAAM,IAAIG,CAAE,GAAGH,EAAM,IAAIG,EAAIE,EAAKH,CAAG,CAAC,EACpCF,EAAM,IAAIG,CAAE,CACrB,ECKaG,EAAqD,IAC5C,EAAO,GAAGC,IAAiC,CAC7D,IAAMC,EAAWC,EAAUjB,EAAa,EAAE,CAAOW,GACjD,OAAO,OAAOK,GAAY,WAAcA,EAA6C,GAAGD,CAAM,EAAKC,CACrG,ECjBWtB,EAAOoB,EAAe,CACjC,GAAI,CACF,MAAO,EAAe,IAAiB,GAAGK,EAAM,GAAGC,EAAM,MAAQ,SACjE,UAAY,GAAkB,SAASD,EAAM,OAC7C,WAAa,GAAkB,GAAGA,EAAM,QACxC,WAAa,GAAkB,GAAGA,EAAM,UACxC,SAAW,GAAkB,GAAGA,EAAM,QACtC,QAAU,GAAkB,GAAGA,EAAM,QACrC,QAAS,UACX,EACA,GAAI,CACF,MAAO,EAAe,IAAiB,GAAGA,EAAM,GAAGC,EAAM,MAAQ,UACjE,UAAY,GAAkB,YAAYD,EAAM,QAChD,WAAa,GAAkB,GAAGA,EAAM,YACxC,WAAa,GAAkB,GAAGA,EAAM,cACxC,SAAW,GAAkB,GAAGA,EAAM,YACtC,QAAU,GAAkB,GAAGA,EAAM,YACrC,QAAS,SACX,CACF,CAAC,EChBYE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AQD,GAAiBC,EAAMrB,CAAO,EAAIsB,GAAkBD,EAAMrB,CAAO,ECvDrF0B,GAAU,GAAyB,CACvC,IAAMC,EAAQ,IAAI,WAAWC,EAAO,QAAQ,EAAM,IAAU7S,EAAOyM,EAAM,OAAQ,CAAC,CAAC,EAC/EqG,EAAS,EACb,IAAK,IAAMrG,KAASoG,EAClBD,EAAM,IAAInG,EAAOqG,CAAM,EACvB,GAAUrG,EAAM,OAElB,OAAOmG,CACT,ECjBMG,QDoBoC,CACxC,IAAIC,EACAH,EAAuB,CAAC,EAC5B,MAAQ,IAAuB,CAC7B,GAAI3U,EAAQ,OAAS,QAAS,EAAUwU,GAAoBxU,EAAQ,KAAO,GAAU2U,EAAO,KAAKpG,CAAK,CAAC,OAClG,GAAKuG,EACD9U,EAAQ,OAAS,OAAQ8U,EAAQ,KAAK9U,EAAQ,QAASA,EAAQ,MAAM,EACzE8U,EAAQ,OAAO,OAFD,MAAU,MAAM,4BAA4B,EAG/D,IAAMJ,EAAQD,GAAOE,CAAM,EAE3B,MADA,GAAS,CAAC,EACHD,CACT,CACF,EChCe,CAAqB,EAC9BK,GAAQ,KAGd,GAAM,UAAa,GAAmC,CAChDC,EAAM,KAAK,OAAS,SAAS/V,EAAkB+V,EAAM,KAAK,MAAM,EACpE,IAAMN,EAAQG,GAAOG,EAAM,IAAI,EAC/BD,GAAM,YAAY,CAAE,OAAM,EAAyB,CAACL,EAAM,MAAM,CAAC,CACnE","debugId":"082564b9-f967-4859-91d3-bfdc32182edc"}
@@ -1 +1 @@
1
- {"version":3,"file":"index-1Ue_dZiA.js","names":["createRoot","StrictMode","projectUi","__exportAll","__toESM","require_react","require_client","require_jsx_runtime","nativeBridgeOf","uiFromModule","App","relList","link","processPreload","mutation","mutations","node","getFetchOpts","fetchOpts","import_react","import_client","_virtual_protobase_project_ui_exports","_virtual_protobase_project_ui_default","apiOriginMeta","showKeyboardAccessoryBar","bridge","nativeViewport","content","part","applyNativeViewport","meta","doc","apiOriginOf","contents","value","url","pageApiOrigin","import_jsx_runtime","root","nativeBridge","browserLocale"],"sources":["../../../../schema/src/api-origin-meta.ts","../../../src/app/native-keyboard.ts","../../../src/app/native-viewport.ts","../../../src/app/page-api-origin.ts","../../../src/app/main.tsx"],"sourcesContent":["/**\n * The `<meta name>` whose `content` names the origin of the API the shell calls, such as `https://shop.example.com`, for\n * a page served from elsewhere: `protobase mobile` writes it into the app's `index.html`. Without it, the shell calls\n * the API on its own origin.\n */\nexport const apiOriginMeta = 'protobase-api-origin'\n","import type { NativeBridge } from './native-auth-fetch'\n\n/**\n * Gives the iOS app's keyboard back the bar above it, with the arrows to the previous and next field and Done, which\n * Capacitor's keyboard plugin hides when it loads and has no setting for. A binary built before it had the plugin,\n * and Android, which has no such bar, are left as they are.\n */\nexport const showKeyboardAccessoryBar = async (bridge: NativeBridge) => {\n if (bridge.getPlatform() !== 'ios' || !bridge.isPluginAvailable('Keyboard')) return\n await bridge.nativePromise('Keyboard', 'setAccessoryBarVisible', { isVisible: true })\n}\n","/**\n * The viewport of the iOS and Android app: as the page's, at a scale of one. Safari on iOS zooms into an input whose\n * text is smaller than 16px when it is focused, and in the app the page then stays zoomed with its right side cut off;\n * an app does not zoom, so its viewport stays at that scale, under a pinch too. The page in a browser keeps its zoom.\n */\nexport const nativeViewport = (content: string) => {\n const kept = content.split(',').map((part) => part.trim()).filter((part) => part && !/^maximum-scale\\s*=/.test(part))\n return [...kept, 'maximum-scale=1'].join(', ')\n}\n\n/** Gives the document's viewport the app's scale; a document without a viewport tag needs none. */\nexport const applyNativeViewport = (doc: Document) => {\n const meta = doc.querySelector('meta[name=\"viewport\"]')\n if (!meta) return\n meta.setAttribute('content', nativeViewport(meta.getAttribute('content') ?? ''))\n}\n","import { apiOriginMeta } from '@protobase/schema/internal'\n\n/**\n * The API origin the page's `<meta name=\"protobase-api-origin\">` tags name: `undefined` without one. Anything but one\n * tag holding exactly an http or https origin, such as `https://shop.example.com`, is an error.\n */\nexport const apiOriginOf = (contents: string[]) => {\n if (contents.length === 0) return undefined\n if (contents.length > 1) throw new Error(`The page has ${contents.length} ${apiOriginMeta} meta tags; it may have one`)\n const value = contents[0]!\n const url = URL.canParse(value) ? new URL(value) : undefined\n if (!url || (url.protocol !== 'http:' && url.protocol !== 'https:') || url.origin !== value) {\n throw new Error(`The page's ${apiOriginMeta} meta tag holds \"${value}\", which is not an http or https origin such as https://shop.example.com`)\n }\n return value\n}\n\n/** The API origin this page names in its `<meta name=\"protobase-api-origin\">` (see `apiOriginOf`). */\nexport const pageApiOrigin = () =>\n apiOriginOf([...document.querySelectorAll<HTMLMetaElement>(`meta[name=\"${apiOriginMeta}\"]`)].map((meta) => meta.content))\n","import { StrictMode } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport * as projectUi from 'virtual:protobase-project-ui'\nimport '../styles.css'\nimport { browserLocale } from '../locale/active-locale'\nimport { App } from './app'\nimport { nativeBridgeOf, type NativeBridge } from './native-auth-fetch'\nimport { showKeyboardAccessoryBar } from './native-keyboard'\nimport { applyNativeViewport } from './native-viewport'\nimport { pageApiOrigin } from './page-api-origin'\nimport { uiFromModule } from './pages/ui-from-module'\n\nconst root = document.getElementById('root')\nif (!root) throw new Error('index.html needs an element with id \"root\"')\n\nconst nativeBridge = nativeBridgeOf(window as { Capacitor?: NativeBridge })\nif (nativeBridge) {\n applyNativeViewport(document)\n void showKeyboardAccessoryBar(nativeBridge)\n}\n\ncreateRoot(root).render(\n <StrictMode>\n <App baseUrl={`${pageApiOrigin() ?? ''}/api/v1`} ui={uiFromModule(projectUi)} locale={browserLocale()} nativeBridge={nativeBridge} />\n </StrictMode>,\n)\n"],"mappings":"85BAKauB,EAAgB,uBCEhBC,EAA2B,KAAO,IAAyB,CAClEC,EAAO,YAAY,IAAM,OAAUA,EAAO,kBAAkB,UAAU,GAC1E,MAAMA,EAAO,cAAc,WAAY,yBAA0B,CAAE,UAAW,EAAK,CAAC,CACtF,ECLaC,EAAkB,GAEtB,CAAC,GADKC,EAAQ,MA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,CAAA,CACd","debugId":"3551efdd-6620-4846-9060-30313686ddd8"}
1
+ {"version":3,"file":"index-C6JUrzRh.js","names":["createRoot","StrictMode","projectUi","__exportAll","__toESM","require_react","require_client","require_jsx_runtime","nativeBridgeOf","uiFromModule","App","relList","link","processPreload","mutation","mutations","node","getFetchOpts","fetchOpts","import_react","import_client","_virtual_protobase_project_ui_exports","_virtual_protobase_project_ui_default","apiOriginMeta","showKeyboardAccessoryBar","bridge","nativeViewport","content","part","applyNativeViewport","meta","doc","apiOriginOf","contents","value","url","pageApiOrigin","import_jsx_runtime","root","nativeBridge","browserLocale"],"sources":["../../../../schema/src/api-origin-meta.ts","../../../src/app/native-keyboard.ts","../../../src/app/native-viewport.ts","../../../src/app/page-api-origin.ts","../../../src/app/main.tsx"],"sourcesContent":["/**\n * The `<meta name>` whose `content` names the origin of the API the shell calls, such as `https://shop.example.com`, for\n * a page served from elsewhere: `protobase mobile` writes it into the app's `index.html`. Without it, the shell calls\n * the API on its own origin.\n */\nexport const apiOriginMeta = 'protobase-api-origin'\n","import type { NativeBridge } from './native-auth-fetch'\n\n/**\n * Gives the iOS app's keyboard back the bar above it, with the arrows to the previous and next field and Done, which\n * Capacitor's keyboard plugin hides when it loads and has no setting for. A binary built before it had the plugin,\n * and Android, which has no such bar, are left as they are.\n */\nexport const showKeyboardAccessoryBar = async (bridge: NativeBridge) => {\n if (bridge.getPlatform() !== 'ios' || !bridge.isPluginAvailable('Keyboard')) return\n await bridge.nativePromise('Keyboard', 'setAccessoryBarVisible', { isVisible: true })\n}\n","/**\n * The viewport of the iOS and Android app: as the page's, at a scale of one. Safari on iOS zooms into an input whose\n * text is smaller than 16px when it is focused, and in the app the page then stays zoomed with its right side cut off;\n * an app does not zoom, so its viewport stays at that scale, under a pinch too. The page in a browser keeps its zoom.\n */\nexport const nativeViewport = (content: string) => {\n const kept = content.split(',').map((part) => part.trim()).filter((part) => part && !/^maximum-scale\\s*=/.test(part))\n return [...kept, 'maximum-scale=1'].join(', ')\n}\n\n/** Gives the document's viewport the app's scale; a document without a viewport tag needs none. */\nexport const applyNativeViewport = (doc: Document) => {\n const meta = doc.querySelector('meta[name=\"viewport\"]')\n if (!meta) return\n meta.setAttribute('content', nativeViewport(meta.getAttribute('content') ?? ''))\n}\n","import { apiOriginMeta } from '@protobase/schema/internal'\n\n/**\n * The API origin the page's `<meta name=\"protobase-api-origin\">` tags name: `undefined` without one. Anything but one\n * tag holding exactly an http or https origin, such as `https://shop.example.com`, is an error.\n */\nexport const apiOriginOf = (contents: string[]) => {\n if (contents.length === 0) return undefined\n if (contents.length > 1) throw new Error(`The page has ${contents.length} ${apiOriginMeta} meta tags; it may have one`)\n const value = contents[0]!\n const url = URL.canParse(value) ? new URL(value) : undefined\n if (!url || (url.protocol !== 'http:' && url.protocol !== 'https:') || url.origin !== value) {\n throw new Error(`The page's ${apiOriginMeta} meta tag holds \"${value}\", which is not an http or https origin such as https://shop.example.com`)\n }\n return value\n}\n\n/** The API origin this page names in its `<meta name=\"protobase-api-origin\">` (see `apiOriginOf`). */\nexport const pageApiOrigin = () =>\n apiOriginOf([...document.querySelectorAll<HTMLMetaElement>(`meta[name=\"${apiOriginMeta}\"]`)].map((meta) => meta.content))\n","import { StrictMode } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport * as projectUi from 'virtual:protobase-project-ui'\nimport '../styles.css'\nimport { browserLocale } from '../locale/active-locale'\nimport { App } from './app'\nimport { nativeBridgeOf, type NativeBridge } from './native-auth-fetch'\nimport { showKeyboardAccessoryBar } from './native-keyboard'\nimport { applyNativeViewport } from './native-viewport'\nimport { pageApiOrigin } from './page-api-origin'\nimport { uiFromModule } from './pages/ui-from-module'\n\nconst root = document.getElementById('root')\nif (!root) throw new Error('index.html needs an element with id \"root\"')\n\nconst nativeBridge = nativeBridgeOf(window as { Capacitor?: NativeBridge })\nif (nativeBridge) {\n applyNativeViewport(document)\n void showKeyboardAccessoryBar(nativeBridge)\n}\n\ncreateRoot(root).render(\n <StrictMode>\n <App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,EAAe,MAAsC,EACtE+B,IACFV,EAAoB,QAAQ,EAC5BL,EAA8Be,CAAY,IAG5CvC,EAAAA,EAAAA,WAAAA,CAAWsC,CAAI,CAAC,CAAC,QACf,EAAAD,EAAA,IAAA,CAACpC,EAAAA,WAAD,CAAA,UACE,EAAAoC,EAAA,IAAA,CAAC3B,EAAD,CAAK,QAAS,GAAG0B,EAAc,GAAK,GAAG,SAAU,GAAI3B,EAAaP,CAAS,EAAG,OAAQsC,EAAc,EAAiB,cAAe,CAAA,CAC1H,CAAA,CACd","debugId":"ba254af3-461a-4946-b8c8-d7b8e3f6c058"}
@@ -1 +1 @@
1
- {"version":3,"file":"records-map-DPA8Y3C8.js","names":["useRef","useState","__toESM","require_react","require_jsx_runtime","groupPoints","cachedFormat","MapPin","Source","MapLayerSwitch","Marker","Layer","Map","mapLib","cn","import_react","worldPixels","mercatorLimit","fadeFrom","zooms","zoom","positionsOf","geometry","mercatorY","radians","latitude","zoomZeroSpan","positions","longitudes","longitude","ys","width","height","areaFeatures","features","points","point","kind","selected","feature","fadeIn","full","import_jsx_runtime","areaLayerId","polygons","lines","chosen","yes","no","PositionAreas","data","color","colors","themeColor","probe","token","element","resolved","canvas","context","red","green","blue","alpha","groupRadius","fitOptions","bucketOptions","markerHeight","compact","tag","corners","bounds","RecordsMap","ref","groups","setGroups","setColors","byKey","pointKeys","fitKey","fit","regroup","map","report","center","onMove","fitNow","onFitted","chosenAt","group","key","at","covered","open","y","style","initial","container","onClear","NavigationControl","buckets","bucket","bucketLabel","event","approximate","markerLabel","onSelect"],"sources":["../../../src/app/map/area-features.ts","../../../src/app/map/position-areas.tsx","../../../src/app/map/theme-color.ts","../../../src/app/map/records-map.tsx"],"sourcesContent":["import type { ExpressionSpecification } from 'maplibre-gl'\nimport type { MapPoint } from '../displays/map-groups'\nimport type { AreaGeometry } from './approximate-position'\n\n/** An area as the map's GeoJSON source holds it: whose it is, whether it is filled or a line, its size, and whether its record is chosen. */\nexport type AreaFeature = {\n type: 'Feature'\n geometry: AreaGeometry\n properties: { key: string; kind: 'polygon' | 'line'; span: number; chosen: boolean }\n}\n\n// MapLibre draws the whole world 512 pixels across at zoom 0, each zoom level twice as wide as the one before.\nconst worldPixels = 512\n// The furthest north and south Web Mercator draws.\nconst mercatorLimit = 85.051129\n// An area fades in as it grows from about half a marker to a marker and a half across, smaller it says nothing the marker does not.\nconst fadeFrom = 16\nconst fadeTo = 48\nconst zooms = Array.from({ length: 23 }, (_, zoom) => zoom)\n\nconst positionsOf = (geometry: AreaGeometry): [number, number][] => {\n if (geometry.type === 'LineString') return geometry.coordinates\n if (geometry.type === 'MultiPolygon') return geometry.coordinates.flat(2)\n return geometry.coordinates.flat()\n}\n\n// How far down the world a latitude is drawn, from 0 at the top to 1 at the bottom.\nconst mercatorY = (latitude: number) => {\n const radians = (Math.max(-mercatorLimit, Math.min(mercatorLimit, latitude)) * Math.PI) / 180\n return 0.5 - Math.log(Math.tan(Math.PI / 4 + radians / 2)) / (2 * Math.PI)\n}\n\n/** How many pixels across the area is drawn at zoom 0, the larger of its width and height; twice as many each zoom level in. */\nexport const zoomZeroSpan = (geometry: AreaGeometry) => {\n const positions = positionsOf(geometry)\n const longitudes = positions.map(([longitude]) => longitude)\n const ys = positions.map(([, latitude]) => mercatorY(latitude))\n const width = ((Math.max(...longitudes) - Math.min(...longitudes)) / 360) * worldPixels\n const height = (Math.max(...ys) - Math.min(...ys)) * worldPixels\n return Math.max(width, height)\n}\n\n/** The areas of the points that have one, those of the chosen records last so they are drawn on top. */\nexport const areaFeatures = (points: MapPoint[], selected: string[] | undefined): { type: 'FeatureCollection'; features: AreaFeature[] } => {\n const features = points.flatMap((point): AreaFeature[] => {\n if (!point.area) return []\n const kind = point.area.type === 'LineString' || point.area.type === 'MultiLineString' ? 'line' : 'polygon'\n return [{ type: 'Feature', geometry: point.area, properties: { key: point.key, kind, span: zoomZeroSpan(point.area), chosen: selected?.includes(point.key) ?? false } }]\n })\n return { type: 'FeatureCollection', features: [...features.filter((feature) => !feature.properties.chosen), ...features.filter((feature) => feature.properties.chosen)] }\n}\n\n/**\n * An opacity of `full` for an area drawn large enough to mean something at the zoom, fading in as it grows to that\n * size: at each whole zoom level its share of `full` follows from its span, and MapLibre blends between the levels.\n */\nexport const fadeIn = (full: number | ExpressionSpecification): ExpressionSpecification =>\n [\n 'interpolate',\n ['linear'],\n ['zoom'],\n ...zooms.flatMap((zoom) => [zoom, ['*', full, ['min', 1, ['max', 0, ['/', ['-', ['*', ['get', 'span'], 2 ** zoom], fadeFrom], fadeTo - fadeFrom]]]]]),\n ] as ExpressionSpecification\n","import type { ExpressionSpecification, FilterSpecification } from 'maplibre-gl'\nimport { Layer, Source } from 'react-map-gl/maplibre'\nimport type { MapPoint } from '../displays/map-groups'\nimport { areaFeatures, fadeIn } from './area-features'\n\n/** The colours of the areas, as MapLibre reads them: the markers' own, and the chosen marker's. */\nexport type AreaColors = { area: string; chosen: string }\n\n/** The areas' lowest layer, which a layer of tiles goes under. */\nexport const areaLayerId = 'position-area-fills'\n\nconst polygons: FilterSpecification = ['==', ['get', 'kind'], 'polygon']\nconst lines: FilterSpecification = ['==', ['get', 'kind'], 'line']\nconst chosen = (yes: number, no: number): ExpressionSpecification => ['case', ['get', 'chosen'], yes, no]\n\n/**\n * The areas around the approximate positions among `points`, drawn under the markers in the markers' colour: a polygon\n * filled faintly within a dashed outline, a line such as a street as a wide stroke. Each fades in as the map zooms close\n * enough for it to be larger than a marker, and the chosen records' areas are drawn darker. Nothing without areas.\n */\nexport const PositionAreas = ({ points, selected, colors }: { points: MapPoint[]; selected: string[] | undefined; colors: AreaColors }) => {\n const data = areaFeatures(points, selected)\n if (data.features.length === 0) return null\n const color: ExpressionSpecification = ['case', ['get', 'chosen'], colors.chosen, colors.area]\n return (\n <Source id=\"position-areas\" type=\"geojson\" data={data}>\n <Layer id={areaLayerId} type=\"fill\" filter={polygons} paint={{ 'fill-color': color, 'fill-opacity': fadeIn(chosen(0.15, 0.1)) }} />\n <Layer id=\"position-area-outlines\" type=\"line\" filter={polygons} paint={{ 'line-color': color, 'line-width': 1.5, 'line-dasharray': [3, 2], 'line-opacity': fadeIn(0.8) }} />\n <Layer id=\"position-area-lines\" type=\"line\" filter={lines} layout={{ 'line-cap': 'round', 'line-join': 'round' }} paint={{ 'line-color': color, 'line-width': 6, 'line-opacity': fadeIn(chosen(0.6, 0.35)) }} />\n </Source>\n )\n}\n","/**\n * The colour a theme token such as `--primary` holds where `element` is, as `rgba()`, which MapLibre's paint reads\n * whatever the theme writes it in: the browser resolves the token, and a pixel painted with it gives its channels.\n */\nexport const themeColor = (element: HTMLElement, token: string) => {\n const probe = document.createElement('span')\n probe.style.color = `var(${token})`\n element.append(probe)\n const resolved = getComputedStyle(probe).color\n probe.remove()\n const canvas = document.createElement('canvas')\n canvas.width = 1\n canvas.height = 1\n const context = canvas.getContext('2d', { willReadFrequently: true })\n if (!context) return resolved\n context.fillStyle = resolved\n context.fillRect(0, 0, 1, 1)\n const [red, green, blue, alpha] = context.getImageData(0, 0, 1, 1).data\n return `rgba(${red}, ${green}, ${blue}, ${alpha! / 255})`\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { MapPin } from 'lucide-react'\nimport { Map, Marker, NavigationControl, type MapRef } from 'react-map-gl/maplibre'\nimport type { MapBounds, MapBucket, MapLayerModel } from '@protobase/client'\nimport type { MapView } from '@protobase/schema'\nimport { cn } from '../../lib/cn'\nimport { groupPoints, type MapGroup, type MapPoint } from '../displays/map-groups'\nimport type { MapArea } from './map-area'\nimport { MapLayerSwitch } from './map-layer-switch'\nimport { mapLib } from './maplibre'\nimport { areaLayerId, PositionAreas, type AreaColors } from './position-areas'\nimport { themeColor } from './theme-color'\nimport { cachedFormat } from '../../format/intl-cache'\n\n// How close, in pixels, records are drawn under one marker, about a marker's width.\nconst groupRadius = 28\nconst fitOptions = { padding: 48, maxZoom: 15, duration: 0 }\n// A bucket opens far enough in for the server to send its records: it does from zoom 16 on.\nconst bucketOptions = { padding: 48, maxZoom: 16, duration: 300 }\nconst markerHeight = 32\nconst compact = () => cachedFormat('compact', (tag) => new Intl.NumberFormat(tag, { notation: 'compact', maximumFractionDigits: 1 }))\n\nconst corners = (bounds: MapBounds): [[number, number], [number, number]] => [\n [bounds.west, bounds.south],\n [bounds.east, bounds.north],\n]\n\ntype RecordsMapProps = {\n style: string\n /** The layers the map may switch to in place of the style's. */\n layers?: MapLayerModel[]\n /** Where the map looks when it opens; the whole world without it. */\n initial: MapView | undefined\n points: MapPoint[]\n /** Counts of records in parts of the map, drawn as circles in place of their records. */\n buckets: MapBucket[]\n /** Bounds to move the map to, each time they change; `onFitted` says it moved there. */\n fit: MapBounds | undefined\n onFitted: () => void\n /** The map's area and view, each time it comes to rest. */\n onMove: (area: MapArea, view: MapView) => void\n /** The records whose marker is chosen, if any. */\n selected: string[] | undefined\n /** How many pixels at the map's bottom something covers, such as the chosen record's card. */\n covered: number\n onSelect: (keys: string[]) => void\n onClear: () => void\n /** What a marker for these records says to a screen reader. */\n markerLabel: (keys: string[]) => string\n /** What a bucket of this many records says to a screen reader. */\n bucketLabel: (count: number) => string\n}\n\n/**\n * A map of `style` with a marker for each group of records that lie close together at the zoom, showing how many it\n * stands for, and a circle with the count of each bucket, which zooms in on its records when chosen. A marker whose\n * records' positions are all approximate is drawn hollow with a dashed edge, over the areas around them. Choosing a\n * marker selects its records; choosing the map elsewhere clears the selection. A chosen marker the covered bottom would\n * hide moves up into the open part of the map.\n */\nexport const RecordsMap = ({ style, layers, initial, points, buckets, fit, onFitted, onMove, selected, covered, onSelect, onClear, markerLabel, bucketLabel }: RecordsMapProps) => {\n const ref = useRef<MapRef>(null)\n const [groups, setGroups] = useState<MapGroup[]>([])\n const [colors, setColors] = useState<AreaColors>()\n const byKey = new globalThis.Map(points.map((point) => [point.key, point]))\n const pointKeys = points.map((point) => point.key).join(',')\n const fitKey = fit && JSON.stringify(fit)\n\n // The groups as the map is drawn now: only the zoom changes which records lie close together\n const regroup = () => {\n const map = ref.current?.getMap()\n if (!map) return\n setGroups(\n groupPoints(\n points.map((point) => ({ key: point.key, ...map.project([point.longitude, point.latitude]) })),\n groupRadius,\n ),\n )\n }\n\n const report = () => {\n const map = ref.current?.getMap()\n if (!map) return\n const bounds = map.getBounds()\n const center = map.getCenter()\n onMove({ bounds: { south: bounds.getSouth(), west: bounds.getWest(), north: bounds.getNorth(), east: bounds.getEast() }, zoom: map.getZoom() }, { latitude: center.lat, longitude: center.lng, zoom: map.getZoom() })\n }\n\n const fitNow = () => {\n const map = ref.current?.getMap()\n if (!map || !fit) return\n map.fitBounds(corners(fit), fitOptions)\n onFitted()\n report()\n }\n\n // Other records are grouped at the zoom the map is at\n useEffect(regroup, [pointKeys])\n useEffect(fitNow, [fitKey])\n\n // The chosen marker in view above what covers the map's bottom\n const chosenAt = groups.find((group) => selected !== undefined && group.keys.some((key) => selected.includes(key)))?.at\n useEffect(() => {\n const map = ref.current?.getMap()\n const at = chosenAt === undefined ? undefined : byKey.get(chosenAt)\n if (!map || !at || covered === 0) return\n const { y } = map.project([at.longitude, at.latitude])\n const open = map.getContainer().clientHeight - covered\n if (y > markerHeight && y < open) return\n map.easeTo({ center: [at.longitude, at.latitude], offset: [0, (markerHeight - covered) / 2], duration: 300 })\n // A new choice or a new cover moves the map, not every new group\n }, [chosenAt, covered])\n\n return (\n <Map\n ref={ref}\n mapLib={mapLib}\n mapStyle={style}\n initialViewState={initial ?? { latitude: 0, longitude: 0, zoom: 1 }}\n style={{ width: '100%', height: '100%' }}\n onLoad={() => {\n const container = ref.current!.getMap().getContainer()\n setColors({ area: themeColor(container, '--primary'), chosen: themeColor(container, '--foreground') })\n regroup()\n if (fit) fitNow()\n else report()\n }}\n onZoomEnd={regroup}\n onMoveEnd={report}\n onClick={onClear}\n >\n <NavigationControl showCompass={false} />\n <MapLayerSwitch layers={layers} below={areaLayerId} />\n {colors && <PositionAreas points={points} selected={selected} colors={colors} />}\n {buckets.map((bucket) => (\n <Marker key={`${bucket.latitude},${bucket.longitude}`} latitude={bucket.latitude} longitude={bucket.longitude} anchor=\"center\">\n <button\n type=\"button\"\n aria-label={bucketLabel(bucket.count)}\n className=\"flex size-10 cursor-pointer items-center justify-center rounded-full border-2 border-background bg-primary text-xs font-semibold text-primary-foreground tabular-nums shadow\"\n onClick={(event) => {\n event.stopPropagation()\n ref.current?.getMap().fitBounds(corners(bucket.bounds), bucketOptions)\n }}\n >\n {compact().format(bucket.count)}\n </button>\n </Marker>\n ))}\n {groups.map((group) => {\n const at = byKey.get(group.at)\n if (!at) return null\n const chosen = selected !== undefined && group.keys.some((key) => selected.includes(key))\n const approximate = group.keys.every((key) => byKey.get(key)?.approximate)\n return (\n <Marker key={group.at} latitude={at.latitude} longitude={at.longitude} anchor=\"bottom\" style={{ zIndex: chosen ? 1 : 0 }}>\n <button\n type=\"button\"\n aria-label={markerLabel(group.keys)}\n aria-pressed={chosen}\n className=\"relative block cursor-pointer\"\n onClick={(event) => {\n event.stopPropagation()\n onSelect(group.keys)\n }}\n >\n <MapPin\n aria-hidden\n data-approximate={approximate || undefined}\n className={cn('size-8 drop-shadow', approximate ? (chosen ? 'fill-background text-foreground' : 'fill-background text-primary') : chosen ? 'fill-foreground text-background' : 'fill-primary text-primary-foreground')}\n strokeWidth={approximate ? 2 : 1.5}\n strokeDasharray={approximate ? '3 2' : undefined}\n />\n {group.keys.length > 1 && (\n <span className=\"absolute -right-2 -top-1 min-w-5 rounded-full border border-background bg-foreground px-1 text-center text-[11px] font-medium leading-4 text-background tabular-nums\">\n {group.keys.length}\n </span>\n )}\n </button>\n </Marker>\n )\n })}\n </Map>\n )\n}\n"],"mappings":"2RAYMgB,EAAc,IAEdC,EAAgB,UAEhBC,EAAW,GAEXC,EAAQ,MAAM,KAAK,CAAE,OAAQ,EAAG,GAAI,EAAG,IAASC,CAAI,EAEpDC,EAAe,GACfC,EAAS,OAAS,aAAqBA,EAAS,YAChDA,EAAS,OAAS,eAAuBA,EAAS,YAAY,KAAK,CAAC,EACjEA,EAAS,YAAY,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BAAsB0F,EAAe1D,EAAS,kCAAoC,+BAAkCA,EAAS,kCAAoC,sCAAsC,EACrN,YAAa0D,EAAc,EAAI,IAC/B,gBAAiBA,EAAc,MAAQ,IAAA,EACxC,CAAA,EACAf,EAAM,KAAK,OAAS,IACnB,EAAA/C,EAAA,IAAA,CAAC,OAAD,CAAM,UAAU,uKACb,SAAA+C,EAAM,KAAK,MACR,CAAA,CAEF,GACF,EAxBKA,EAAM,EAwBX,CAEZ,CAAC,CACE,GAET","debugId":"cf03c637-0bca-45b9-bdea-ce1ceee88dd5"}
1
+ {"version":3,"file":"records-map-kVCCf9yO.js","names":["useRef","useState","__toESM","require_react","require_jsx_runtime","groupPoints","cachedFormat","MapPin","Source","MapLayerSwitch","Marker","Layer","Map","mapLib","cn","import_react","worldPixels","mercatorLimit","fadeFrom","zooms","zoom","positionsOf","geometry","mercatorY","radians","latitude","zoomZeroSpan","positions","longitudes","longitude","ys","width","height","areaFeatures","features","points","point","kind","selected","feature","fadeIn","full","import_jsx_runtime","areaLayerId","polygons","lines","chosen","yes","no","PositionAreas","data","color","colors","themeColor","probe","token","element","resolved","canvas","context","red","green","blue","alpha","groupRadius","fitOptions","bucketOptions","markerHeight","compact","tag","corners","bounds","RecordsMap","ref","groups","setGroups","setColors","byKey","pointKeys","fitKey","fit","regroup","map","report","center","onMove","fitNow","onFitted","chosenAt","group","key","at","covered","open","y","style","initial","container","onClear","NavigationControl","buckets","bucket","bucketLabel","event","approximate","markerLabel","onSelect"],"sources":["../../../src/app/map/area-features.ts","../../../src/app/map/position-areas.tsx","../../../src/app/map/theme-color.ts","../../../src/app/map/records-map.tsx"],"sourcesContent":["import type { ExpressionSpecification } from 'maplibre-gl'\nimport type { MapPoint } from '../displays/map-groups'\nimport type { AreaGeometry } from './approximate-position'\n\n/** An area as the map's GeoJSON source holds it: whose it is, whether it is filled or a line, its size, and whether its record is chosen. */\nexport type AreaFeature = {\n type: 'Feature'\n geometry: AreaGeometry\n properties: { key: string; kind: 'polygon' | 'line'; span: number; chosen: boolean }\n}\n\n// MapLibre draws the whole world 512 pixels across at zoom 0, each zoom level twice as wide as the one before.\nconst worldPixels = 512\n// The furthest north and south Web Mercator draws.\nconst mercatorLimit = 85.051129\n// An area fades in as it grows from about half a marker to a marker and a half across, smaller it says nothing the marker does not.\nconst fadeFrom = 16\nconst fadeTo = 48\nconst zooms = Array.from({ length: 23 }, (_, zoom) => zoom)\n\nconst positionsOf = (geometry: AreaGeometry): [number, number][] => {\n if (geometry.type === 'LineString') return geometry.coordinates\n if (geometry.type === 'MultiPolygon') return geometry.coordinates.flat(2)\n return geometry.coordinates.flat()\n}\n\n// How far down the world a latitude is drawn, from 0 at the top to 1 at the bottom.\nconst mercatorY = (latitude: number) => {\n const radians = (Math.max(-mercatorLimit, Math.min(mercatorLimit, latitude)) * Math.PI) / 180\n return 0.5 - Math.log(Math.tan(Math.PI / 4 + radians / 2)) / (2 * Math.PI)\n}\n\n/** How many pixels across the area is drawn at zoom 0, the larger of its width and height; twice as many each zoom level in. */\nexport const zoomZeroSpan = (geometry: AreaGeometry) => {\n const positions = positionsOf(geometry)\n const longitudes = positions.map(([longitude]) => longitude)\n const ys = positions.map(([, latitude]) => mercatorY(latitude))\n const width = ((Math.max(...longitudes) - Math.min(...longitudes)) / 360) * worldPixels\n const height = (Math.max(...ys) - Math.min(...ys)) * worldPixels\n return Math.max(width, height)\n}\n\n/** The areas of the points that have one, those of the chosen records last so they are drawn on top. */\nexport const areaFeatures = (points: MapPoint[], selected: string[] | undefined): { type: 'FeatureCollection'; features: AreaFeature[] } => {\n const features = points.flatMap((point): AreaFeature[] => {\n if (!point.area) return []\n const kind = point.area.type === 'LineString' || point.area.type === 'MultiLineString' ? 'line' : 'polygon'\n return [{ type: 'Feature', geometry: point.area, properties: { key: point.key, kind, span: zoomZeroSpan(point.area), chosen: selected?.includes(point.key) ?? false } }]\n })\n return { type: 'FeatureCollection', features: [...features.filter((feature) => !feature.properties.chosen), ...features.filter((feature) => feature.properties.chosen)] }\n}\n\n/**\n * An opacity of `full` for an area drawn large enough to mean something at the zoom, fading in as it grows to that\n * size: at each whole zoom level its share of `full` follows from its span, and MapLibre blends between the levels.\n */\nexport const fadeIn = (full: number | ExpressionSpecification): ExpressionSpecification =>\n [\n 'interpolate',\n ['linear'],\n ['zoom'],\n ...zooms.flatMap((zoom) => [zoom, ['*', full, ['min', 1, ['max', 0, ['/', ['-', ['*', ['get', 'span'], 2 ** zoom], fadeFrom], fadeTo - fadeFrom]]]]]),\n ] as ExpressionSpecification\n","import type { ExpressionSpecification, FilterSpecification } from 'maplibre-gl'\nimport { Layer, Source } from 'react-map-gl/maplibre'\nimport type { MapPoint } from '../displays/map-groups'\nimport { areaFeatures, fadeIn } from './area-features'\n\n/** The colours of the areas, as MapLibre reads them: the markers' own, and the chosen marker's. */\nexport type AreaColors = { area: string; chosen: string }\n\n/** The areas' lowest layer, which a layer of tiles goes under. */\nexport const areaLayerId = 'position-area-fills'\n\nconst polygons: FilterSpecification = ['==', ['get', 'kind'], 'polygon']\nconst lines: FilterSpecification = ['==', ['get', 'kind'], 'line']\nconst chosen = (yes: number, no: number): ExpressionSpecification => ['case', ['get', 'chosen'], yes, no]\n\n/**\n * The areas around the approximate positions among `points`, drawn under the markers in the markers' colour: a polygon\n * filled faintly within a dashed outline, a line such as a street as a wide stroke. Each fades in as the map zooms close\n * enough for it to be larger than a marker, and the chosen records' areas are drawn darker. Nothing without areas.\n */\nexport const PositionAreas = ({ points, selected, colors }: { points: MapPoint[]; selected: string[] | undefined; colors: AreaColors }) => {\n const data = areaFeatures(points, selected)\n if (data.features.length === 0) return null\n const color: ExpressionSpecification = ['case', ['get', 'chosen'], colors.chosen, colors.area]\n return (\n <Source id=\"position-areas\" type=\"geojson\" data={data}>\n <Layer id={areaLayerId} type=\"fill\" filter={polygons} paint={{ 'fill-color': color, 'fill-opacity': fadeIn(chosen(0.15, 0.1)) }} />\n <Layer id=\"position-area-outlines\" type=\"line\" filter={polygons} paint={{ 'line-color': color, 'line-width': 1.5, 'line-dasharray': [3, 2], 'line-opacity': fadeIn(0.8) }} />\n <Layer id=\"position-area-lines\" type=\"line\" filter={lines} layout={{ 'line-cap': 'round', 'line-join': 'round' }} paint={{ 'line-color': color, 'line-width': 6, 'line-opacity': fadeIn(chosen(0.6, 0.35)) }} />\n </Source>\n )\n}\n","/**\n * The colour a theme token such as `--primary` holds where `element` is, as `rgba()`, which MapLibre's paint reads\n * whatever the theme writes it in: the browser resolves the token, and a pixel painted with it gives its channels.\n */\nexport const themeColor = (element: HTMLElement, token: string) => {\n const probe = document.createElement('span')\n probe.style.color = `var(${token})`\n element.append(probe)\n const resolved = getComputedStyle(probe).color\n probe.remove()\n const canvas = document.createElement('canvas')\n canvas.width = 1\n canvas.height = 1\n const context = canvas.getContext('2d', { willReadFrequently: true })\n if (!context) return resolved\n context.fillStyle = resolved\n context.fillRect(0, 0, 1, 1)\n const [red, green, blue, alpha] = context.getImageData(0, 0, 1, 1).data\n return `rgba(${red}, ${green}, ${blue}, ${alpha! / 255})`\n}\n","import { useEffect, useRef, useState } from 'react'\nimport { MapPin } from 'lucide-react'\nimport { Map, Marker, NavigationControl, type MapRef } from 'react-map-gl/maplibre'\nimport type { MapBounds, MapBucket, MapLayerModel } from '@protobase/client'\nimport type { MapView } from '@protobase/schema'\nimport { cn } from '../../lib/cn'\nimport { groupPoints, type MapGroup, type MapPoint } from '../displays/map-groups'\nimport type { MapArea } from './map-area'\nimport { MapLayerSwitch } from './map-layer-switch'\nimport { mapLib } from './maplibre'\nimport { areaLayerId, PositionAreas, type AreaColors } from './position-areas'\nimport { themeColor } from './theme-color'\nimport { cachedFormat } from '../../format/intl-cache'\n\n// How close, in pixels, records are drawn under one marker, about a marker's width.\nconst groupRadius = 28\nconst fitOptions = { padding: 48, maxZoom: 15, duration: 0 }\n// A bucket opens far enough in for the server to send its records: it does from zoom 16 on.\nconst bucketOptions = { padding: 48, maxZoom: 16, duration: 300 }\nconst markerHeight = 32\nconst compact = () => cachedFormat('compact', (tag) => new Intl.NumberFormat(tag, { notation: 'compact', maximumFractionDigits: 1 }))\n\nconst corners = (bounds: MapBounds): [[number, number], [number, number]] => [\n [bounds.west, bounds.south],\n [bounds.east, bounds.north],\n]\n\ntype RecordsMapProps = {\n style: string\n /** The layers the map may switch to in place of the style's. */\n layers?: MapLayerModel[]\n /** Where the map looks when it opens; the whole world without it. */\n initial: MapView | undefined\n points: MapPoint[]\n /** Counts of records in parts of the map, drawn as circles in place of their records. */\n buckets: MapBucket[]\n /** Bounds to move the map to, each time they change; `onFitted` says it moved there. */\n fit: MapBounds | undefined\n onFitted: () => void\n /** The map's area and view, each time it comes to rest. */\n onMove: (area: MapArea, view: MapView) => void\n /** The records whose marker is chosen, if any. */\n selected: string[] | undefined\n /** How many pixels at the map's bottom something covers, such as the chosen record's card. */\n covered: number\n onSelect: (keys: string[]) => void\n onClear: () => void\n /** What a marker for these records says to a screen reader. */\n markerLabel: (keys: string[]) => string\n /** What a bucket of this many records says to a screen reader. */\n bucketLabel: (count: number) => string\n}\n\n/**\n * A map of `style` with a marker for each group of records that lie close together at the zoom, showing how many it\n * stands for, and a circle with the count of each bucket, which zooms in on its records when chosen. A marker whose\n * records' positions are all approximate is drawn hollow with a dashed edge, over the areas around them. Choosing a\n * marker selects its records; choosing the map elsewhere clears the selection. A chosen marker the covered bottom would\n * hide moves up into the open part of the map.\n */\nexport const RecordsMap = ({ style, layers, initial, points, buckets, fit, onFitted, onMove, selected, covered, onSelect, onClear, markerLabel, bucketLabel }: RecordsMapProps) => {\n const ref = useRef<MapRef>(null)\n const [groups, setGroups] = useState<MapGroup[]>([])\n const [colors, setColors] = useState<AreaColors>()\n const byKey = new globalThis.Map(points.map((point) => [point.key, point]))\n const pointKeys = points.map((point) => point.key).join(',')\n const fitKey = fit && JSON.stringify(fit)\n\n // The groups as the map is drawn now: only the zoom changes which records lie close together\n const regroup = () => {\n const map = ref.current?.getMap()\n if (!map) return\n setGroups(\n groupPoints(\n points.map((point) => ({ key: point.key, ...map.project([point.longitude, point.latitude]) })),\n groupRadius,\n ),\n )\n }\n\n const report = () => {\n const map = ref.current?.getMap()\n if (!map) return\n const bounds = map.getBounds()\n const center = map.getCenter()\n onMove({ bounds: { south: bounds.getSouth(), west: bounds.getWest(), north: bounds.getNorth(), east: bounds.getEast() }, zoom: map.getZoom() }, { latitude: center.lat, longitude: center.lng, zoom: map.getZoom() })\n }\n\n const fitNow = () => {\n const map = ref.current?.getMap()\n if (!map || !fit) return\n map.fitBounds(corners(fit), fitOptions)\n onFitted()\n report()\n }\n\n // Other records are grouped at the zoom the map is at\n useEffect(regroup, [pointKeys])\n useEffect(fitNow, [fitKey])\n\n // The chosen marker in view above what covers the map's bottom\n const chosenAt = groups.find((group) => selected !== undefined && group.keys.some((key) => selected.includes(key)))?.at\n useEffect(() => {\n const map = ref.current?.getMap()\n const at = chosenAt === undefined ? undefined : byKey.get(chosenAt)\n if (!map || !at || covered === 0) return\n const { y } = map.project([at.longitude, at.latitude])\n const open = map.getContainer().clientHeight - covered\n if (y > markerHeight && y < open) return\n map.easeTo({ center: [at.longitude, at.latitude], offset: [0, (markerHeight - covered) / 2], duration: 300 })\n // A new choice or a new cover moves the map, not every new group\n }, [chosenAt, covered])\n\n return (\n <Map\n ref={ref}\n mapLib={mapLib}\n mapStyle={style}\n initialViewState={initial ?? { latitude: 0, longitude: 0, zoom: 1 }}\n style={{ width: '100%', height: '100%' }}\n onLoad={() => {\n const container = ref.current!.getMap().getContainer()\n setColors({ area: themeColor(container, '--primary'), chosen: themeColor(container, '--foreground') })\n regroup()\n if (fit) fitNow()\n else report()\n }}\n onZoomEnd={regroup}\n onMoveEnd={report}\n onClick={onClear}\n >\n <NavigationControl showCompass={false} />\n <MapLayerSwitch layers={layers} below={areaLayerId} />\n {colors && <PositionAreas points={points} selected={selected} colors={colors} />}\n {buckets.map((bucket) => (\n <Marker key={`${bucket.latitude},${bucket.longitude}`} latitude={bucket.latitude} longitude={bucket.longitude} anchor=\"center\">\n <button\n type=\"button\"\n aria-label={bucketLabel(bucket.count)}\n className=\"flex size-10 cursor-pointer items-center justify-center rounded-full border-2 border-background bg-primary text-xs font-semibold text-primary-foreground tabular-nums shadow\"\n onClick={(event) => {\n event.stopPropagation()\n ref.current?.getMap().fitBounds(corners(bucket.bounds), bucketOptions)\n }}\n >\n {compact().format(bucket.count)}\n </button>\n </Marker>\n ))}\n {groups.map((group) => {\n const at = byKey.get(group.at)\n if (!at) return null\n const chosen = selected !== undefined && group.keys.some((key) => selected.includes(key))\n const approximate = group.keys.every((key) => byKey.get(key)?.approximate)\n return (\n <Marker key={group.at} latitude={at.latitude} longitude={at.longitude} anchor=\"bottom\" style={{ zIndex: chosen ? 1 : 0 }}>\n <button\n type=\"button\"\n aria-label={markerLabel(group.keys)}\n aria-pressed={chosen}\n className=\"relative block cursor-pointer\"\n onClick={(event) => {\n event.stopPropagation()\n onSelect(group.keys)\n }}\n >\n <MapPin\n aria-hidden\n data-approximate={approximate || undefined}\n className={cn('size-8 drop-shadow', approximate ? (chosen ? 'fill-background text-foreground' : 'fill-background text-primary') : chosen ? 'fill-foreground text-background' : 'fill-primary text-primary-foreground')}\n strokeWidth={approximate ? 2 : 1.5}\n strokeDasharray={approximate ? '3 2' : undefined}\n />\n {group.keys.length > 1 && (\n <span className=\"absolute -right-2 -top-1 min-w-5 rounded-full border border-background bg-foreground px-1 text-center text-[11px] font-medium leading-4 text-background tabular-nums\">\n {group.keys.length}\n </span>\n )}\n </button>\n </Marker>\n )\n })}\n </Map>\n )\n}\n"],"mappings":"2RAYMgB,EAAc,IAEdC,EAAgB,UAEhBC,EAAW,GAEXC,EAAQ,MAAM,KAAK,CAAE,OAAQ,EAAG,GAAI,EAAG,IAASC,CAAI,EAEpDC,EAAe,GACfC,EAAS,OAAS,aAAqBA,EAAS,YAChDA,EAAS,OAAS,eAAuBA,EAAS,YAAY,KAAK,CAAC,EACjEA,EAAS,YAAY,KAAK,EAI7BC,EAAa,GAAqB,CACtC,IAAMC,EAA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