tempest-react-sdk 0.78.0 → 0.80.0
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.
- package/README.md +6 -6
- package/bin/lib/openapi/generate.hostile.test.mjs +45 -4
- package/bin/lib/openapi/generate.mjs +303 -88
- package/bin/lib/openapi/generate.pagination.test.mjs +3 -2
- package/bin/lib/openapi/generate.test.mjs +462 -1
- package/bin/lib/openapi/schema-to-zod.mjs +4 -3
- package/dist/access/Can.cjs.map +1 -1
- package/dist/access/Can.js.map +1 -1
- package/dist/access/access-control-context.cjs.map +1 -1
- package/dist/access/access-control-context.js.map +1 -1
- package/dist/access/create-role-access-control.cjs.map +1 -1
- package/dist/access/create-role-access-control.js.map +1 -1
- package/dist/access/permissions-from-token.cjs.map +1 -1
- package/dist/access/permissions-from-token.js.map +1 -1
- package/dist/access/use-can.cjs.map +1 -1
- package/dist/access/use-can.js.map +1 -1
- package/dist/app/AppProviders.cjs.map +1 -1
- package/dist/app/AppProviders.js.map +1 -1
- package/dist/audio/audio-bus.cjs.map +1 -1
- package/dist/audio/audio-bus.js.map +1 -1
- package/dist/audio/audio-output.cjs.map +1 -1
- package/dist/audio/audio-output.js.map +1 -1
- package/dist/audio/audio-player.cjs.map +1 -1
- package/dist/audio/audio-player.js.map +1 -1
- package/dist/audio/audio-recorder.cjs.map +1 -1
- package/dist/audio/audio-recorder.js.map +1 -1
- package/dist/audio/duration.cjs.map +1 -1
- package/dist/audio/duration.js.map +1 -1
- package/dist/audio/level-meter.cjs.map +1 -1
- package/dist/audio/level-meter.js.map +1 -1
- package/dist/audio/media-access.cjs.map +1 -1
- package/dist/audio/media-access.js.map +1 -1
- package/dist/audio/noise-floor.cjs.map +1 -1
- package/dist/audio/noise-floor.js.map +1 -1
- package/dist/audio/sfx-pool.cjs.map +1 -1
- package/dist/audio/sfx-pool.js.map +1 -1
- package/dist/audio/use-audio-bus.cjs.map +1 -1
- package/dist/audio/use-audio-bus.js.map +1 -1
- package/dist/audio/use-audio-recorder.cjs.map +1 -1
- package/dist/audio/use-audio-recorder.js.map +1 -1
- package/dist/audio/use-audio.cjs.map +1 -1
- package/dist/audio/use-audio.js.map +1 -1
- package/dist/audio/use-microphone.cjs +1 -1
- package/dist/audio/use-microphone.cjs.map +1 -1
- package/dist/audio/use-microphone.js +1 -5
- package/dist/audio/use-microphone.js.map +1 -1
- package/dist/audio/use-sfx-pool.cjs.map +1 -1
- package/dist/audio/use-sfx-pool.js.map +1 -1
- package/dist/audio/voice-activity.cjs.map +1 -1
- package/dist/audio/voice-activity.js.map +1 -1
- package/dist/audio/voice-chain-stages.cjs.map +1 -1
- package/dist/audio/voice-chain-stages.js.map +1 -1
- package/dist/audio/voice-chain.cjs.map +1 -1
- package/dist/audio/voice-chain.js.map +1 -1
- package/dist/audio/wav.cjs.map +1 -1
- package/dist/audio/wav.js.map +1 -1
- package/dist/auth/AuthGuard.cjs.map +1 -1
- package/dist/auth/AuthGuard.js.map +1 -1
- package/dist/auth/create-auth-store.cjs.map +1 -1
- package/dist/auth/create-auth-store.js.map +1 -1
- package/dist/auth/create-tempest-auth.cjs +1 -1
- package/dist/auth/create-tempest-auth.cjs.map +1 -1
- package/dist/auth/create-tempest-auth.js +1 -3
- package/dist/auth/create-tempest-auth.js.map +1 -1
- package/dist/auth/jwt.cjs.map +1 -1
- package/dist/auth/jwt.js.map +1 -1
- package/dist/auth/lazy-with-retry.cjs.map +1 -1
- package/dist/auth/lazy-with-retry.js.map +1 -1
- package/dist/auth/passkey.cjs.map +1 -1
- package/dist/auth/passkey.js.map +1 -1
- package/dist/auth/refresh-queue.cjs.map +1 -1
- package/dist/auth/refresh-queue.js.map +1 -1
- package/dist/auth/use-passkey.cjs +1 -1
- package/dist/auth/use-passkey.cjs.map +1 -1
- package/dist/auth/use-passkey.js +1 -1
- package/dist/auth/use-passkey.js.map +1 -1
- package/dist/br/BrazilMap.cjs.map +1 -1
- package/dist/br/BrazilMap.js.map +1 -1
- package/dist/br/BrazilMap.module.cjs.map +1 -1
- package/dist/br/BrazilMap.module.js.map +1 -1
- package/dist/br/BrazilStateCitySelect.cjs.map +1 -1
- package/dist/br/BrazilStateCitySelect.js.map +1 -1
- package/dist/br/BrazilStateMap.cjs.map +1 -1
- package/dist/br/BrazilStateMap.js.map +1 -1
- package/dist/br/MapLegend.cjs.map +1 -1
- package/dist/br/MapLegend.js.map +1 -1
- package/dist/br/MapLegend.module.cjs.map +1 -1
- package/dist/br/MapLegend.module.js.map +1 -1
- package/dist/br/MapMarkers.cjs.map +1 -1
- package/dist/br/MapMarkers.js.map +1 -1
- package/dist/br/MapTooltip.cjs.map +1 -1
- package/dist/br/MapTooltip.js.map +1 -1
- package/dist/br/MunicipalitySearch.cjs +1 -1
- package/dist/br/MunicipalitySearch.cjs.map +1 -1
- package/dist/br/MunicipalitySearch.js +2 -5
- package/dist/br/MunicipalitySearch.js.map +1 -1
- package/dist/br/MunicipalitySearch.module.cjs.map +1 -1
- package/dist/br/MunicipalitySearch.module.js.map +1 -1
- package/dist/br/PixQRCode.cjs.map +1 -1
- package/dist/br/PixQRCode.js.map +1 -1
- package/dist/br/PixQRCode.module.cjs.map +1 -1
- package/dist/br/PixQRCode.module.js.map +1 -1
- package/dist/br/boleto.cjs.map +1 -1
- package/dist/br/boleto.js.map +1 -1
- package/dist/br/br-geo.cjs.map +1 -1
- package/dist/br/br-geo.js.map +1 -1
- package/dist/br/data/br-centroids.cjs.map +1 -1
- package/dist/br/data/br-centroids.js.map +1 -1
- package/dist/br/data/br-locations.cjs.map +1 -1
- package/dist/br/data/br-locations.js.map +1 -1
- package/dist/br/data/br-uf-geo.cjs.map +1 -1
- package/dist/br/data/br-uf-geo.js.map +1 -1
- package/dist/br/data/mun/AC.cjs.map +1 -1
- package/dist/br/data/mun/AC.js.map +1 -1
- package/dist/br/data/mun/AL.cjs.map +1 -1
- package/dist/br/data/mun/AL.js.map +1 -1
- package/dist/br/data/mun/AM.cjs.map +1 -1
- package/dist/br/data/mun/AM.js.map +1 -1
- package/dist/br/data/mun/AP.cjs.map +1 -1
- package/dist/br/data/mun/AP.js.map +1 -1
- package/dist/br/data/mun/BA.cjs.map +1 -1
- package/dist/br/data/mun/BA.js.map +1 -1
- package/dist/br/data/mun/CE.cjs.map +1 -1
- package/dist/br/data/mun/CE.js.map +1 -1
- package/dist/br/data/mun/DF.cjs.map +1 -1
- package/dist/br/data/mun/DF.js.map +1 -1
- package/dist/br/data/mun/ES.cjs.map +1 -1
- package/dist/br/data/mun/ES.js.map +1 -1
- package/dist/br/data/mun/GO.cjs.map +1 -1
- package/dist/br/data/mun/GO.js.map +1 -1
- package/dist/br/data/mun/MA.cjs.map +1 -1
- package/dist/br/data/mun/MA.js.map +1 -1
- package/dist/br/data/mun/MG.cjs.map +1 -1
- package/dist/br/data/mun/MG.js.map +1 -1
- package/dist/br/data/mun/MS.cjs.map +1 -1
- package/dist/br/data/mun/MS.js.map +1 -1
- package/dist/br/data/mun/MT.cjs.map +1 -1
- package/dist/br/data/mun/MT.js.map +1 -1
- package/dist/br/data/mun/PA.cjs.map +1 -1
- package/dist/br/data/mun/PA.js.map +1 -1
- package/dist/br/data/mun/PB.cjs.map +1 -1
- package/dist/br/data/mun/PB.js.map +1 -1
- package/dist/br/data/mun/PE.cjs.map +1 -1
- package/dist/br/data/mun/PE.js.map +1 -1
- package/dist/br/data/mun/PI.cjs.map +1 -1
- package/dist/br/data/mun/PI.js.map +1 -1
- package/dist/br/data/mun/PR.cjs.map +1 -1
- package/dist/br/data/mun/PR.js.map +1 -1
- package/dist/br/data/mun/RJ.cjs.map +1 -1
- package/dist/br/data/mun/RJ.js.map +1 -1
- package/dist/br/data/mun/RN.cjs.map +1 -1
- package/dist/br/data/mun/RN.js.map +1 -1
- package/dist/br/data/mun/RO.cjs.map +1 -1
- package/dist/br/data/mun/RO.js.map +1 -1
- package/dist/br/data/mun/RR.cjs.map +1 -1
- package/dist/br/data/mun/RR.js.map +1 -1
- package/dist/br/data/mun/RS.cjs.map +1 -1
- package/dist/br/data/mun/RS.js.map +1 -1
- package/dist/br/data/mun/SC.cjs.map +1 -1
- package/dist/br/data/mun/SC.js.map +1 -1
- package/dist/br/data/mun/SE.cjs.map +1 -1
- package/dist/br/data/mun/SE.js.map +1 -1
- package/dist/br/data/mun/SP.cjs.map +1 -1
- package/dist/br/data/mun/SP.js.map +1 -1
- package/dist/br/data/mun/TO.cjs.map +1 -1
- package/dist/br/data/mun/TO.js.map +1 -1
- package/dist/br/geocode.cjs.map +1 -1
- package/dist/br/geocode.js.map +1 -1
- package/dist/br/holidays.cjs.map +1 -1
- package/dist/br/holidays.js.map +1 -1
- package/dist/br/locations.cjs.map +1 -1
- package/dist/br/locations.js.map +1 -1
- package/dist/br/nfe.cjs.map +1 -1
- package/dist/br/nfe.js.map +1 -1
- package/dist/br/pix.cjs +1 -1
- package/dist/br/pix.cjs.map +1 -1
- package/dist/br/pix.js +108 -74
- package/dist/br/pix.js.map +1 -1
- package/dist/br/regions.cjs.map +1 -1
- package/dist/br/regions.js.map +1 -1
- package/dist/br/scales.cjs.map +1 -1
- package/dist/br/scales.js.map +1 -1
- package/dist/br/state-geo.cjs.map +1 -1
- package/dist/br/state-geo.js.map +1 -1
- package/dist/br/svg-utils.cjs.map +1 -1
- package/dist/br/svg-utils.js.map +1 -1
- package/dist/br/use-map-hover.cjs.map +1 -1
- package/dist/br/use-map-hover.js.map +1 -1
- package/dist/br/use-map-zoom.cjs.map +1 -1
- package/dist/br/use-map-zoom.js.map +1 -1
- package/dist/br/whatsapp.cjs.map +1 -1
- package/dist/br/whatsapp.js.map +1 -1
- package/dist/br.cjs.map +1 -1
- package/dist/br.d.ts +6 -2
- package/dist/br.js.map +1 -1
- package/dist/capture/barcode.cjs.map +1 -1
- package/dist/capture/barcode.js.map +1 -1
- package/dist/capture/media-recorder.cjs.map +1 -1
- package/dist/capture/media-recorder.js.map +1 -1
- package/dist/capture/use-barcode-scanner.cjs.map +1 -1
- package/dist/capture/use-barcode-scanner.js.map +1 -1
- package/dist/capture/use-screen-capture.cjs +1 -1
- package/dist/capture/use-screen-capture.cjs.map +1 -1
- package/dist/capture/use-screen-capture.js +1 -7
- package/dist/capture/use-screen-capture.js.map +1 -1
- package/dist/capture/use-speech-recognition.cjs +1 -1
- package/dist/capture/use-speech-recognition.cjs.map +1 -1
- package/dist/capture/use-speech-recognition.js +35 -36
- package/dist/capture/use-speech-recognition.js.map +1 -1
- package/dist/capture/use-torch.cjs.map +1 -1
- package/dist/capture/use-torch.js.map +1 -1
- package/dist/capture/use-video-recorder.cjs.map +1 -1
- package/dist/capture/use-video-recorder.js.map +1 -1
- package/dist/capture/video-recorder.cjs.map +1 -1
- package/dist/capture/video-recorder.js.map +1 -1
- package/dist/charts/AreaChart.cjs.map +1 -1
- package/dist/charts/AreaChart.js.map +1 -1
- package/dist/charts/BarChart.cjs.map +1 -1
- package/dist/charts/BarChart.js.map +1 -1
- package/dist/charts/LineChart.cjs.map +1 -1
- package/dist/charts/LineChart.js.map +1 -1
- package/dist/charts/PieChart.cjs.map +1 -1
- package/dist/charts/PieChart.js.map +1 -1
- package/dist/charts/RadarChart.cjs.map +1 -1
- package/dist/charts/RadarChart.js.map +1 -1
- package/dist/charts/palette.cjs.map +1 -1
- package/dist/charts/palette.js.map +1 -1
- package/dist/charts/scales.cjs.map +1 -1
- package/dist/charts/scales.js.map +1 -1
- package/dist/charts/types.cjs.map +1 -1
- package/dist/charts/types.js.map +1 -1
- package/dist/charts/use-chart-colors.cjs.map +1 -1
- package/dist/charts/use-chart-colors.js.map +1 -1
- package/dist/components/AIChat/AIChat.cjs +1 -1
- package/dist/components/AIChat/AIChat.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.js +1 -5
- package/dist/components/AIChat/AIChat.js.map +1 -1
- package/dist/components/AIChat/AIChat.module.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.module.js.map +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs.map +1 -1
- package/dist/components/AIChat/AIChatComposer.js +1 -7
- package/dist/components/AIChat/AIChatComposer.js.map +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs.map +1 -1
- package/dist/components/AIChat/AIChatTurn.js.map +1 -1
- package/dist/components/AIChat/ai-chat-turns.cjs.map +1 -1
- package/dist/components/AIChat/ai-chat-turns.js.map +1 -1
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/Accordion/Accordion.module.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.module.js.map +1 -1
- package/dist/components/Alert/Alert.cjs.map +1 -1
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/Alert/Alert.module.cjs.map +1 -1
- package/dist/components/Alert/Alert.module.js.map +1 -1
- package/dist/components/AppBar/AppBar.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.js.map +1 -1
- package/dist/components/AppBar/AppBar.module.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.module.js.map +1 -1
- package/dist/components/AppBar/use-sticky-body-warning.cjs +1 -1
- package/dist/components/AppBar/use-sticky-body-warning.cjs.map +1 -1
- package/dist/components/AppBar/use-sticky-body-warning.js +1 -1
- package/dist/components/AppBar/use-sticky-body-warning.js.map +1 -1
- package/dist/components/AppShell/AppShell.cjs.map +1 -1
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/AppShell/AppShell.module.cjs.map +1 -1
- package/dist/components/AppShell/AppShell.module.js.map +1 -1
- package/dist/components/AspectRatio/AspectRatio.cjs.map +1 -1
- package/dist/components/AspectRatio/AspectRatio.js.map +1 -1
- package/dist/components/AspectRatio/AspectRatio.module.cjs.map +1 -1
- package/dist/components/AspectRatio/AspectRatio.module.js.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.cjs +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.cjs.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.js +1 -7
- package/dist/components/AudioPlayer/AudioPlayer.js.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.module.cjs.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.module.js.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.cjs +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.cjs.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.js +16 -21
- package/dist/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.module.cjs.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.module.js.map +1 -1
- package/dist/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/Avatar/Avatar.module.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.module.js.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.cjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.js.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.module.cjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.module.js.map +1 -1
- package/dist/components/Badge/Badge.cjs.map +1 -1
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Badge/Badge.module.cjs.map +1 -1
- package/dist/components/Badge/Badge.module.js.map +1 -1
- package/dist/components/Banner/Banner.cjs.map +1 -1
- package/dist/components/Banner/Banner.js.map +1 -1
- package/dist/components/Banner/Banner.module.cjs.map +1 -1
- package/dist/components/Banner/Banner.module.js.map +1 -1
- package/dist/components/BarList/BarList.cjs.map +1 -1
- package/dist/components/BarList/BarList.js.map +1 -1
- package/dist/components/BarList/BarList.module.cjs.map +1 -1
- package/dist/components/BarList/BarList.module.js.map +1 -1
- package/dist/components/BarList/bar-list-model.cjs.map +1 -1
- package/dist/components/BarList/bar-list-model.js.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.cjs.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.js.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.module.cjs.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.module.js.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.cjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.js.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.module.cjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.module.js.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.cjs.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.js.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.module.cjs.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.module.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.module.cjs.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.module.js.map +1 -1
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Button/Button.module.cjs.map +1 -1
- package/dist/components/Button/Button.module.js.map +1 -1
- package/dist/components/Button/ButtonContent.cjs.map +1 -1
- package/dist/components/Button/ButtonContent.js.map +1 -1
- package/dist/components/Button/ButtonSlot.cjs.map +1 -1
- package/dist/components/Button/ButtonSlot.js.map +1 -1
- package/dist/components/Button/button-class.cjs.map +1 -1
- package/dist/components/Button/button-class.js.map +1 -1
- package/dist/components/Button/link-rel.cjs.map +1 -1
- package/dist/components/Button/link-rel.js.map +1 -1
- package/dist/components/Button/slot.cjs.map +1 -1
- package/dist/components/Button/slot.js.map +1 -1
- package/dist/components/Calendar/Calendar.cjs.map +1 -1
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Calendar/Calendar.module.cjs.map +1 -1
- package/dist/components/Calendar/Calendar.module.js.map +1 -1
- package/dist/components/Card/Card.cjs.map +1 -1
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Card/Card.module.cjs.map +1 -1
- package/dist/components/Card/Card.module.js.map +1 -1
- package/dist/components/Carousel/Carousel.cjs.map +1 -1
- package/dist/components/Carousel/Carousel.js.map +1 -1
- package/dist/components/Carousel/Carousel.module.cjs.map +1 -1
- package/dist/components/Carousel/Carousel.module.js.map +1 -1
- package/dist/components/Center/Center.cjs.map +1 -1
- package/dist/components/Center/Center.js.map +1 -1
- package/dist/components/Center/Center.module.cjs.map +1 -1
- package/dist/components/Center/Center.module.js.map +1 -1
- package/dist/components/Chat/Chat.cjs.map +1 -1
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/Chat/Chat.module.cjs.map +1 -1
- package/dist/components/Chat/Chat.module.js.map +1 -1
- package/dist/components/Chat/ChatActionsMenu.cjs.map +1 -1
- package/dist/components/Chat/ChatActionsMenu.js.map +1 -1
- package/dist/components/Chat/ChatAttachments.cjs.map +1 -1
- package/dist/components/Chat/ChatAttachments.js.map +1 -1
- package/dist/components/Chat/ChatBubble.cjs.map +1 -1
- package/dist/components/Chat/ChatBubble.js.map +1 -1
- package/dist/components/Chat/ChatComposer.cjs.map +1 -1
- package/dist/components/Chat/ChatComposer.js.map +1 -1
- package/dist/components/Chat/chat-groups.cjs +1 -1
- package/dist/components/Chat/chat-groups.cjs.map +1 -1
- package/dist/components/Chat/chat-groups.js +2 -6
- package/dist/components/Chat/chat-groups.js.map +1 -1
- package/dist/components/Chat/chat-receipt.cjs.map +1 -1
- package/dist/components/Chat/chat-receipt.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.module.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.module.js.map +1 -1
- package/dist/components/ChipInput/ChipInput.cjs +1 -1
- package/dist/components/ChipInput/ChipInput.cjs.map +1 -1
- package/dist/components/ChipInput/ChipInput.js +2 -12
- package/dist/components/ChipInput/ChipInput.js.map +1 -1
- package/dist/components/ChipInput/ChipInput.module.cjs.map +1 -1
- package/dist/components/ChipInput/ChipInput.module.js.map +1 -1
- package/dist/components/ClickOutside/ClickOutside.cjs.map +1 -1
- package/dist/components/ClickOutside/ClickOutside.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.module.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.module.js.map +1 -1
- package/dist/components/CodeBlock/tokenize.cjs.map +1 -1
- package/dist/components/CodeBlock/tokenize.js.map +1 -1
- package/dist/components/Collapsible/Collapsible.cjs.map +1 -1
- package/dist/components/Collapsible/Collapsible.js.map +1 -1
- package/dist/components/Collapsible/Collapsible.module.cjs.map +1 -1
- package/dist/components/Collapsible/Collapsible.module.js.map +1 -1
- package/dist/components/Combobox/Combobox.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Combobox/Combobox.module.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.module.js.map +1 -1
- package/dist/components/Combobox/use-listbox-dismiss.cjs.map +1 -1
- package/dist/components/Combobox/use-listbox-dismiss.js.map +1 -1
- package/dist/components/Command/Command.cjs +1 -1
- package/dist/components/Command/Command.cjs.map +1 -1
- package/dist/components/Command/Command.js +4 -11
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/Command/Command.module.cjs.map +1 -1
- package/dist/components/Command/Command.module.js.map +1 -1
- package/dist/components/ConditionalWrapper/ConditionalWrapper.cjs.map +1 -1
- package/dist/components/ConditionalWrapper/ConditionalWrapper.js.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.cjs.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.cjs +1 -1
- package/dist/components/ContextMenu/ContextMenu.cjs.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js +1 -1
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.module.cjs.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.module.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.cjs.map +1 -1
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.module.cjs.map +1 -1
- package/dist/components/CopyButton/CopyButton.module.js.map +1 -1
- package/dist/components/DataList/DataList.cjs.map +1 -1
- package/dist/components/DataList/DataList.js.map +1 -1
- package/dist/components/DataList/DataList.module.cjs.map +1 -1
- package/dist/components/DataList/DataList.module.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +6 -14
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/DataTable.module.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.module.js.map +1 -1
- package/dist/components/DataTable/EditableCell.cjs +1 -1
- package/dist/components/DataTable/EditableCell.cjs.map +1 -1
- package/dist/components/DataTable/EditableCell.js +1 -9
- package/dist/components/DataTable/EditableCell.js.map +1 -1
- package/dist/components/DataTable/LoadingRows.cjs.map +1 -1
- package/dist/components/DataTable/LoadingRows.js.map +1 -1
- package/dist/components/DataTable/edit-labels.cjs.map +1 -1
- package/dist/components/DataTable/edit-labels.js.map +1 -1
- package/dist/components/DataTable/use-dev-warnings.cjs.map +1 -1
- package/dist/components/DataTable/use-dev-warnings.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/DatePicker/DatePicker.js.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.module.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.module.js.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.cjs.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.module.cjs.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.module.js.map +1 -1
- package/dist/components/Divider/Divider.cjs.map +1 -1
- package/dist/components/Divider/Divider.js.map +1 -1
- package/dist/components/Divider/Divider.module.cjs.map +1 -1
- package/dist/components/Divider/Divider.module.js.map +1 -1
- package/dist/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/Drawer/Drawer.module.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.module.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.cjs +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js +2 -14
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.module.cjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.module.js.map +1 -1
- package/dist/components/Dropzone/Dropzone.cjs.map +1 -1
- package/dist/components/Dropzone/Dropzone.js.map +1 -1
- package/dist/components/Dropzone/Dropzone.module.cjs.map +1 -1
- package/dist/components/Dropzone/Dropzone.module.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.cjs.map +1 -1
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.module.cjs.map +1 -1
- package/dist/components/EmptyState/EmptyState.module.js.map +1 -1
- package/dist/components/ErrorState/ErrorState.cjs.map +1 -1
- package/dist/components/ErrorState/ErrorState.js.map +1 -1
- package/dist/components/ErrorState/ErrorState.module.cjs.map +1 -1
- package/dist/components/ErrorState/ErrorState.module.js.map +1 -1
- package/dist/components/ErrorText/ErrorText.cjs.map +1 -1
- package/dist/components/ErrorText/ErrorText.js.map +1 -1
- package/dist/components/ErrorText/ErrorText.module.cjs.map +1 -1
- package/dist/components/ErrorText/ErrorText.module.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/FileUpload/FileUpload.cjs.map +1 -1
- package/dist/components/FileUpload/FileUpload.js +7 -17
- package/dist/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.module.cjs.map +1 -1
- package/dist/components/FileUpload/FileUpload.module.js.map +1 -1
- package/dist/components/FilterBar/FilterBar.cjs.map +1 -1
- package/dist/components/FilterBar/FilterBar.js.map +1 -1
- package/dist/components/FilterBar/FilterBar.module.cjs.map +1 -1
- package/dist/components/FilterBar/FilterBar.module.js.map +1 -1
- package/dist/components/FilterBar/filter-apply.cjs.map +1 -1
- package/dist/components/FilterBar/filter-apply.js.map +1 -1
- package/dist/components/FilterBar/filter-model.cjs.map +1 -1
- package/dist/components/FilterBar/filter-model.js.map +1 -1
- package/dist/components/FilterBar/filter-query.cjs +1 -1
- package/dist/components/FilterBar/filter-query.cjs.map +1 -1
- package/dist/components/FilterBar/filter-query.js +2 -5
- package/dist/components/FilterBar/filter-query.js.map +1 -1
- package/dist/components/FilterPanel/FilterPanel.cjs.map +1 -1
- package/dist/components/FilterPanel/FilterPanel.js.map +1 -1
- package/dist/components/FilterPanel/FilterPanel.module.cjs.map +1 -1
- package/dist/components/FilterPanel/FilterPanel.module.js.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.cjs.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.js.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.module.cjs.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.module.js.map +1 -1
- package/dist/components/For/For.cjs.map +1 -1
- package/dist/components/For/For.js.map +1 -1
- package/dist/components/Form/Form.cjs.map +1 -1
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/Form/Form.module.cjs.map +1 -1
- package/dist/components/Form/Form.module.js.map +1 -1
- package/dist/components/HoverCard/HoverCard.cjs.map +1 -1
- package/dist/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/components/HoverCard/HoverCard.module.cjs.map +1 -1
- package/dist/components/HoverCard/HoverCard.module.js.map +1 -1
- package/dist/components/Image/Image.cjs.map +1 -1
- package/dist/components/Image/Image.js.map +1 -1
- package/dist/components/Image/Image.module.cjs.map +1 -1
- package/dist/components/Image/Image.module.js.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.cjs +1 -1
- package/dist/components/ImageCropper/ImageCropper.cjs.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.js +4 -8
- package/dist/components/ImageCropper/ImageCropper.js.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.module.cjs.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.module.js.map +1 -1
- package/dist/components/ImageCropper/crop-geometry.cjs.map +1 -1
- package/dist/components/ImageCropper/crop-geometry.js.map +1 -1
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/Input/Input.module.cjs.map +1 -1
- package/dist/components/Input/Input.module.js.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.cjs.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.js.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.module.cjs.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.module.js.map +1 -1
- package/dist/components/InstallButton/InstallButton.cjs.map +1 -1
- package/dist/components/InstallButton/InstallButton.js.map +1 -1
- package/dist/components/InstallButton/InstallButton.module.cjs.map +1 -1
- package/dist/components/InstallButton/InstallButton.module.js.map +1 -1
- package/dist/components/InstallButton/install-hints.cjs.map +1 -1
- package/dist/components/InstallButton/install-hints.js.map +1 -1
- package/dist/components/Kanban/Kanban.cjs.map +1 -1
- package/dist/components/Kanban/Kanban.js.map +1 -1
- package/dist/components/Kanban/Kanban.module.cjs.map +1 -1
- package/dist/components/Kanban/Kanban.module.js.map +1 -1
- package/dist/components/Kbd/Kbd.cjs.map +1 -1
- package/dist/components/Kbd/Kbd.js.map +1 -1
- package/dist/components/Kbd/Kbd.module.cjs.map +1 -1
- package/dist/components/Kbd/Kbd.module.js.map +1 -1
- package/dist/components/Label/Label.cjs.map +1 -1
- package/dist/components/Label/Label.js.map +1 -1
- package/dist/components/Label/Label.module.cjs.map +1 -1
- package/dist/components/Label/Label.module.js.map +1 -1
- package/dist/components/Layout/Layout.cjs.map +1 -1
- package/dist/components/Layout/Layout.js.map +1 -1
- package/dist/components/Layout/Layout.module.cjs.map +1 -1
- package/dist/components/Layout/Layout.module.js.map +1 -1
- package/dist/components/Lightbox/Lightbox.cjs +1 -1
- package/dist/components/Lightbox/Lightbox.cjs.map +1 -1
- package/dist/components/Lightbox/Lightbox.js +1 -1
- package/dist/components/Lightbox/Lightbox.js.map +1 -1
- package/dist/components/Lightbox/Lightbox.module.cjs.map +1 -1
- package/dist/components/Lightbox/Lightbox.module.js.map +1 -1
- package/dist/components/ListTile/ListTile.cjs.map +1 -1
- package/dist/components/ListTile/ListTile.js.map +1 -1
- package/dist/components/ListTile/ListTile.module.cjs.map +1 -1
- package/dist/components/ListTile/ListTile.module.js.map +1 -1
- package/dist/components/Markdown/Markdown.cjs.map +1 -1
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/Markdown/Markdown.module.cjs.map +1 -1
- package/dist/components/Markdown/Markdown.module.js.map +1 -1
- package/dist/components/Markdown/markdown-parse.cjs +2 -2
- package/dist/components/Markdown/markdown-parse.cjs.map +1 -1
- package/dist/components/Markdown/markdown-parse.js +8 -27
- package/dist/components/Markdown/markdown-parse.js.map +1 -1
- package/dist/components/Masonry/Masonry.cjs.map +1 -1
- package/dist/components/Masonry/Masonry.js.map +1 -1
- package/dist/components/Masonry/Masonry.module.cjs.map +1 -1
- package/dist/components/Masonry/Masonry.module.js.map +1 -1
- package/dist/components/Masonry/masonry-layout.cjs.map +1 -1
- package/dist/components/Masonry/masonry-layout.js.map +1 -1
- package/dist/components/Menubar/Menubar.cjs.map +1 -1
- package/dist/components/Menubar/Menubar.js.map +1 -1
- package/dist/components/Menubar/Menubar.module.cjs.map +1 -1
- package/dist/components/Menubar/Menubar.module.js.map +1 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/Modal/Modal.module.cjs.map +1 -1
- package/dist/components/Modal/Modal.module.js.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.cjs.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.js.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.module.cjs.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.module.js.map +1 -1
- package/dist/components/Money/Money.cjs.map +1 -1
- package/dist/components/Money/Money.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.module.cjs.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.module.js.map +1 -1
- package/dist/components/NProgress/NProgress.cjs.map +1 -1
- package/dist/components/NProgress/NProgress.js.map +1 -1
- package/dist/components/NProgress/NProgress.module.cjs.map +1 -1
- package/dist/components/NProgress/NProgress.module.js.map +1 -1
- package/dist/components/Navbar/Navbar.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.js.map +1 -1
- package/dist/components/Navbar/Navbar.module.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.module.js.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.js.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.module.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.module.js.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.cjs.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.js.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.module.cjs.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.module.js.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.cjs.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.module.cjs.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.module.js.map +1 -1
- package/dist/components/NotificationCenter/use-notification-inbox.cjs.map +1 -1
- package/dist/components/NotificationCenter/use-notification-inbox.js.map +1 -1
- package/dist/components/OfflineIndicator/OfflineIndicator.cjs.map +1 -1
- package/dist/components/OfflineIndicator/OfflineIndicator.js.map +1 -1
- package/dist/components/OfflineIndicator/OfflineIndicator.module.cjs.map +1 -1
- package/dist/components/OfflineIndicator/OfflineIndicator.module.js.map +1 -1
- package/dist/components/Page/Page.cjs.map +1 -1
- package/dist/components/Page/Page.js.map +1 -1
- package/dist/components/Page/Page.module.cjs.map +1 -1
- package/dist/components/Page/Page.module.js.map +1 -1
- package/dist/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/Pagination/Pagination.module.cjs.map +1 -1
- package/dist/components/Pagination/Pagination.module.js.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.module.cjs.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.module.js.map +1 -1
- package/dist/components/PinInput/PinInput.cjs.map +1 -1
- package/dist/components/PinInput/PinInput.js.map +1 -1
- package/dist/components/PinInput/PinInput.module.cjs.map +1 -1
- package/dist/components/PinInput/PinInput.module.js.map +1 -1
- package/dist/components/Popover/Popover.cjs.map +1 -1
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Popover/Popover.module.cjs.map +1 -1
- package/dist/components/Popover/Popover.module.js.map +1 -1
- package/dist/components/Portal/Portal.cjs.map +1 -1
- package/dist/components/Portal/Portal.js.map +1 -1
- package/dist/components/Portal/anchor-position.cjs.map +1 -1
- package/dist/components/Portal/anchor-position.js.map +1 -1
- package/dist/components/Portal/escape-layer.cjs.map +1 -1
- package/dist/components/Portal/escape-layer.js.map +1 -1
- package/dist/components/Portal/portal-host.cjs.map +1 -1
- package/dist/components/Portal/portal-host.js.map +1 -1
- package/dist/components/Portal/tab-bridge.cjs +1 -1
- package/dist/components/Portal/tab-bridge.cjs.map +1 -1
- package/dist/components/Portal/tab-bridge.js +1 -5
- package/dist/components/Portal/tab-bridge.js.map +1 -1
- package/dist/components/Progress/Progress.cjs.map +1 -1
- package/dist/components/Progress/Progress.js.map +1 -1
- package/dist/components/Progress/Progress.module.cjs.map +1 -1
- package/dist/components/Progress/Progress.module.js.map +1 -1
- package/dist/components/QRCode/QRCode.cjs.map +1 -1
- package/dist/components/QRCode/QRCode.js.map +1 -1
- package/dist/components/QRCode/QRCode.module.cjs.map +1 -1
- package/dist/components/QRCode/QRCode.module.js.map +1 -1
- package/dist/components/QRCode/qr-encode.cjs +1 -1
- package/dist/components/QRCode/qr-encode.cjs.map +1 -1
- package/dist/components/QRCode/qr-encode.js +7 -13
- package/dist/components/QRCode/qr-encode.js.map +1 -1
- package/dist/components/QRCode/qr-tables.cjs.map +1 -1
- package/dist/components/QRCode/qr-tables.js.map +1 -1
- package/dist/components/Radio/Radio.cjs.map +1 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/Radio/Radio.module.cjs.map +1 -1
- package/dist/components/Radio/Radio.module.js.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.cjs.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.js.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.module.cjs.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.module.js.map +1 -1
- package/dist/components/RatingStars/RatingStars.cjs.map +1 -1
- package/dist/components/RatingStars/RatingStars.js.map +1 -1
- package/dist/components/RatingStars/RatingStars.module.cjs.map +1 -1
- package/dist/components/RatingStars/RatingStars.module.js.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.cjs +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.cjs.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.js +10 -18
- package/dist/components/RefreshIndicator/RefreshIndicator.js.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.module.cjs.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.module.js.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.cjs.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.js.map +1 -1
- package/dist/components/Resizable/Resizable.cjs +1 -1
- package/dist/components/Resizable/Resizable.cjs.map +1 -1
- package/dist/components/Resizable/Resizable.js +1 -9
- package/dist/components/Resizable/Resizable.js.map +1 -1
- package/dist/components/Resizable/Resizable.module.cjs.map +1 -1
- package/dist/components/Resizable/Resizable.module.js.map +1 -1
- package/dist/components/Responsive/Responsive.cjs.map +1 -1
- package/dist/components/Responsive/Responsive.js.map +1 -1
- package/dist/components/Reveal/Reveal.cjs.map +1 -1
- package/dist/components/Reveal/Reveal.js.map +1 -1
- package/dist/components/Reveal/Reveal.module.cjs.map +1 -1
- package/dist/components/Reveal/Reveal.module.js.map +1 -1
- package/dist/components/Reveal/reveal-threshold.cjs.map +1 -1
- package/dist/components/Reveal/reveal-threshold.js.map +1 -1
- package/dist/components/SafeArea/SafeArea.cjs.map +1 -1
- package/dist/components/SafeArea/SafeArea.js.map +1 -1
- package/dist/components/SafeArea/SafeArea.module.cjs.map +1 -1
- package/dist/components/SafeArea/SafeArea.module.js.map +1 -1
- package/dist/components/Scheduler/Scheduler.cjs.map +1 -1
- package/dist/components/Scheduler/Scheduler.js.map +1 -1
- package/dist/components/Scheduler/Scheduler.module.cjs.map +1 -1
- package/dist/components/Scheduler/Scheduler.module.js.map +1 -1
- package/dist/components/Scheduler/scheduler-layout.cjs.map +1 -1
- package/dist/components/Scheduler/scheduler-layout.js.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.cjs.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.js.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.cjs.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.module.js.map +1 -1
- package/dist/components/SearchBar/SearchBar.cjs.map +1 -1
- package/dist/components/SearchBar/SearchBar.js.map +1 -1
- package/dist/components/SearchBar/SearchBar.module.cjs.map +1 -1
- package/dist/components/SearchBar/SearchBar.module.js.map +1 -1
- package/dist/components/SectionHeader/SectionHeader.cjs.map +1 -1
- package/dist/components/SectionHeader/SectionHeader.js.map +1 -1
- package/dist/components/SectionHeader/SectionHeader.module.cjs.map +1 -1
- package/dist/components/SectionHeader/SectionHeader.module.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.cjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.module.cjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.module.js.map +1 -1
- package/dist/components/Select/CaretIcon.cjs.map +1 -1
- package/dist/components/Select/CaretIcon.js.map +1 -1
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Select/Select.module.cjs.map +1 -1
- package/dist/components/Select/Select.module.js.map +1 -1
- package/dist/components/Select/options.cjs.map +1 -1
- package/dist/components/Select/options.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.cjs +1 -1
- package/dist/components/Sidebar/Sidebar.cjs.map +1 -1
- package/dist/components/Sidebar/Sidebar.js +13 -23
- package/dist/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.module.cjs.map +1 -1
- package/dist/components/Sidebar/Sidebar.module.js.map +1 -1
- package/dist/components/Sidebar/SidebarEntry.cjs.map +1 -1
- package/dist/components/Sidebar/SidebarEntry.js.map +1 -1
- package/dist/components/Sidebar/active-nav-key.cjs.map +1 -1
- package/dist/components/Sidebar/active-nav-key.js.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.cjs +1 -1
- package/dist/components/SignaturePad/SignaturePad.cjs.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.js +1 -5
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.module.cjs.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.module.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.cjs.map +1 -1
- package/dist/components/Skeleton/Skeleton.js.map +1 -1
- package/dist/components/Skeleton/Skeleton.module.cjs.map +1 -1
- package/dist/components/Skeleton/Skeleton.module.js.map +1 -1
- package/dist/components/Slider/Slider.cjs.map +1 -1
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Slider/Slider.module.cjs.map +1 -1
- package/dist/components/Slider/Slider.module.js.map +1 -1
- package/dist/components/Spacer/Spacer.cjs.map +1 -1
- package/dist/components/Spacer/Spacer.js.map +1 -1
- package/dist/components/Spacer/Spacer.module.cjs.map +1 -1
- package/dist/components/Spacer/Spacer.module.js.map +1 -1
- package/dist/components/Sparkline/Sparkline.cjs.map +1 -1
- package/dist/components/Sparkline/Sparkline.js.map +1 -1
- package/dist/components/Sparkline/Sparkline.module.cjs.map +1 -1
- package/dist/components/Sparkline/Sparkline.module.js.map +1 -1
- package/dist/components/Sparkline/sparkline-geometry.cjs.map +1 -1
- package/dist/components/Sparkline/sparkline-geometry.js.map +1 -1
- package/dist/components/Spinner/Spinner.cjs.map +1 -1
- package/dist/components/Spinner/Spinner.js.map +1 -1
- package/dist/components/Spinner/Spinner.module.cjs.map +1 -1
- package/dist/components/Spinner/Spinner.module.js.map +1 -1
- package/dist/components/Stat/Stat.cjs.map +1 -1
- package/dist/components/Stat/Stat.js.map +1 -1
- package/dist/components/Stat/Stat.module.cjs.map +1 -1
- package/dist/components/Stat/Stat.module.js.map +1 -1
- package/dist/components/Stepper/Stepper.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/components/Stepper/Stepper.module.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.module.js.map +1 -1
- package/dist/components/StepperInput/StepperInput.cjs.map +1 -1
- package/dist/components/StepperInput/StepperInput.js.map +1 -1
- package/dist/components/StepperInput/StepperInput.module.cjs.map +1 -1
- package/dist/components/StepperInput/StepperInput.module.js.map +1 -1
- package/dist/components/Switch/Switch.cjs.map +1 -1
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/Switch/Switch.module.cjs.map +1 -1
- package/dist/components/Switch/Switch.module.js.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.cjs.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.js.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.module.cjs.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.module.js.map +1 -1
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Table/Table.module.cjs.map +1 -1
- package/dist/components/Table/Table.module.js.map +1 -1
- package/dist/components/Tabs/Tabs.cjs.map +1 -1
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tabs/Tabs.module.cjs.map +1 -1
- package/dist/components/Tabs/Tabs.module.js.map +1 -1
- package/dist/components/Tag/Tag.cjs.map +1 -1
- package/dist/components/Tag/Tag.js.map +1 -1
- package/dist/components/Tag/Tag.module.cjs.map +1 -1
- package/dist/components/Tag/Tag.module.js.map +1 -1
- package/dist/components/Textarea/Textarea.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/Textarea/Textarea.module.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.module.js.map +1 -1
- package/dist/components/TimePicker/TimePicker.cjs.map +1 -1
- package/dist/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/components/TimePicker/TimePicker.module.cjs.map +1 -1
- package/dist/components/TimePicker/TimePicker.module.js.map +1 -1
- package/dist/components/Timeline/Timeline.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.js.map +1 -1
- package/dist/components/Timeline/Timeline.module.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.module.js.map +1 -1
- package/dist/components/Toast/Toast.module.cjs.map +1 -1
- package/dist/components/Toast/Toast.module.js.map +1 -1
- package/dist/components/Toast/ToastProvider.cjs.map +1 -1
- package/dist/components/Toast/ToastProvider.js.map +1 -1
- package/dist/components/Toggle/Toggle.cjs.map +1 -1
- package/dist/components/Toggle/Toggle.js.map +1 -1
- package/dist/components/Toggle/Toggle.module.cjs.map +1 -1
- package/dist/components/Toggle/Toggle.module.js.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.cjs.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.js.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.module.cjs.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.module.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.module.cjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.module.js.map +1 -1
- package/dist/components/Tour/Tour.cjs +1 -1
- package/dist/components/Tour/Tour.cjs.map +1 -1
- package/dist/components/Tour/Tour.js +1 -5
- package/dist/components/Tour/Tour.js.map +1 -1
- package/dist/components/Tour/Tour.module.cjs.map +1 -1
- package/dist/components/Tour/Tour.module.js.map +1 -1
- package/dist/components/Tour/tour-position.cjs.map +1 -1
- package/dist/components/Tour/tour-position.js.map +1 -1
- package/dist/components/Transfer/Transfer.cjs.map +1 -1
- package/dist/components/Transfer/Transfer.js.map +1 -1
- package/dist/components/Transfer/Transfer.module.cjs.map +1 -1
- package/dist/components/Transfer/Transfer.module.js.map +1 -1
- package/dist/components/Transfer/transfer-state.cjs.map +1 -1
- package/dist/components/Transfer/transfer-state.js.map +1 -1
- package/dist/components/TreeView/TreeView.cjs.map +1 -1
- package/dist/components/TreeView/TreeView.js.map +1 -1
- package/dist/components/TreeView/TreeView.module.cjs.map +1 -1
- package/dist/components/TreeView/TreeView.module.js.map +1 -1
- package/dist/components/TruncateText/TruncateText.cjs.map +1 -1
- package/dist/components/TruncateText/TruncateText.js.map +1 -1
- package/dist/components/TruncateText/TruncateText.module.cjs.map +1 -1
- package/dist/components/TruncateText/TruncateText.module.js.map +1 -1
- package/dist/components/UpdatePrompt/UpdatePrompt.cjs.map +1 -1
- package/dist/components/UpdatePrompt/UpdatePrompt.js.map +1 -1
- package/dist/components/UpdatePrompt/UpdatePrompt.module.cjs.map +1 -1
- package/dist/components/UpdatePrompt/UpdatePrompt.module.js.map +1 -1
- package/dist/components/VideoPlayer/VideoPlayer.cjs +1 -1
- package/dist/components/VideoPlayer/VideoPlayer.cjs.map +1 -1
- package/dist/components/VideoPlayer/VideoPlayer.js +1 -7
- package/dist/components/VideoPlayer/VideoPlayer.js.map +1 -1
- package/dist/components/VideoPlayer/VideoPlayer.module.cjs.map +1 -1
- package/dist/components/VideoPlayer/VideoPlayer.module.js.map +1 -1
- package/dist/components/VideoPlayer/playback-rates.cjs.map +1 -1
- package/dist/components/VideoPlayer/playback-rates.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.module.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.module.js.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.cjs.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.js.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.module.cjs.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.module.js.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.cjs.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.js.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.module.cjs.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.module.js.map +1 -1
- package/dist/components/Wizard/Wizard.cjs +1 -1
- package/dist/components/Wizard/Wizard.cjs.map +1 -1
- package/dist/components/Wizard/Wizard.js +4 -11
- package/dist/components/Wizard/Wizard.js.map +1 -1
- package/dist/components/Wizard/Wizard.module.cjs.map +1 -1
- package/dist/components/Wizard/Wizard.module.js.map +1 -1
- package/dist/data/create-data-provider.cjs.map +1 -1
- package/dist/data/create-data-provider.js.map +1 -1
- package/dist/data/data-provider-context.cjs.map +1 -1
- package/dist/data/data-provider-context.js.map +1 -1
- package/dist/data/use-resource.cjs.map +1 -1
- package/dist/data/use-resource.js.map +1 -1
- package/dist/editor/RichTextEditor.cjs.map +1 -1
- package/dist/editor/RichTextEditor.js.map +1 -1
- package/dist/editor/RichTextEditor.module.cjs.map +1 -1
- package/dist/editor/RichTextEditor.module.js.map +1 -1
- package/dist/editor.js +1 -2
- package/dist/error-boundary/ErrorBoundary.cjs.map +1 -1
- package/dist/error-boundary/ErrorBoundary.js.map +1 -1
- package/dist/error-boundary/use-error-handler.cjs.map +1 -1
- package/dist/error-boundary/use-error-handler.js.map +1 -1
- package/dist/feature-flags/FeatureFlagsProvider.cjs.map +1 -1
- package/dist/feature-flags/FeatureFlagsProvider.js.map +1 -1
- package/dist/feature-flags/growthbook-adapter.cjs.map +1 -1
- package/dist/feature-flags/growthbook-adapter.js.map +1 -1
- package/dist/feature-flags/in-memory-adapter.cjs.map +1 -1
- package/dist/feature-flags/in-memory-adapter.js.map +1 -1
- package/dist/feature-flags/launchdarkly-adapter.cjs.map +1 -1
- package/dist/feature-flags/launchdarkly-adapter.js.map +1 -1
- package/dist/forms/FormField.cjs.map +1 -1
- package/dist/forms/FormField.js.map +1 -1
- package/dist/forms/br-validators.cjs.map +1 -1
- package/dist/forms/br-validators.js.map +1 -1
- package/dist/forms/masked-inputs.cjs.map +1 -1
- package/dist/forms/masked-inputs.js.map +1 -1
- package/dist/forms/use-viacep.cjs.map +1 -1
- package/dist/forms/use-viacep.js.map +1 -1
- package/dist/forms/use-zod-form.cjs.map +1 -1
- package/dist/forms/use-zod-form.js.map +1 -1
- package/dist/forms/validate-form.cjs.map +1 -1
- package/dist/forms/validate-form.js.map +1 -1
- package/dist/forms/zod-resolver.cjs.map +1 -1
- package/dist/forms/zod-resolver.js.map +1 -1
- package/dist/geo/TrajectoryMap.cjs.map +1 -1
- package/dist/geo/TrajectoryMap.js.map +1 -1
- package/dist/geo/TrajectoryMap.module.cjs.map +1 -1
- package/dist/geo/TrajectoryMap.module.js.map +1 -1
- package/dist/geo/bounds.cjs.map +1 -1
- package/dist/geo/bounds.js.map +1 -1
- package/dist/geo/create-position-tracker.cjs +1 -1
- package/dist/geo/create-position-tracker.cjs.map +1 -1
- package/dist/geo/create-position-tracker.js +1 -7
- package/dist/geo/create-position-tracker.js.map +1 -1
- package/dist/geo/distance.cjs.map +1 -1
- package/dist/geo/distance.js.map +1 -1
- package/dist/geo/estimate.cjs.map +1 -1
- package/dist/geo/estimate.js.map +1 -1
- package/dist/geo/leaflet-map.cjs.map +1 -1
- package/dist/geo/leaflet-map.js.map +1 -1
- package/dist/geo/projection.cjs.map +1 -1
- package/dist/geo/projection.js.map +1 -1
- package/dist/geo/routing.cjs.map +1 -1
- package/dist/geo/routing.js.map +1 -1
- package/dist/geo/types.cjs.map +1 -1
- package/dist/geo/types.js.map +1 -1
- package/dist/geo/use-position-tracker.cjs.map +1 -1
- package/dist/geo/use-position-tracker.js.map +1 -1
- package/dist/hooks/pwa-env.cjs.map +1 -1
- package/dist/hooks/pwa-env.js.map +1 -1
- package/dist/hooks/tab-sequence.cjs.map +1 -1
- package/dist/hooks/tab-sequence.js.map +1 -1
- package/dist/hooks/use-announce.cjs +1 -1
- package/dist/hooks/use-announce.cjs.map +1 -1
- package/dist/hooks/use-announce.js +2 -2
- package/dist/hooks/use-announce.js.map +1 -1
- package/dist/hooks/use-async.cjs.map +1 -1
- package/dist/hooks/use-async.js.map +1 -1
- package/dist/hooks/use-before-install-prompt.cjs.map +1 -1
- package/dist/hooks/use-before-install-prompt.js.map +1 -1
- package/dist/hooks/use-breakpoint.cjs.map +1 -1
- package/dist/hooks/use-breakpoint.js.map +1 -1
- package/dist/hooks/use-click-outside.cjs.map +1 -1
- package/dist/hooks/use-click-outside.js.map +1 -1
- package/dist/hooks/use-client-filter.cjs.map +1 -1
- package/dist/hooks/use-client-filter.js.map +1 -1
- package/dist/hooks/use-clipboard.cjs.map +1 -1
- package/dist/hooks/use-clipboard.js.map +1 -1
- package/dist/hooks/use-countdown.cjs.map +1 -1
- package/dist/hooks/use-countdown.js.map +1 -1
- package/dist/hooks/use-counter.cjs.map +1 -1
- package/dist/hooks/use-counter.js.map +1 -1
- package/dist/hooks/use-debounce.cjs.map +1 -1
- package/dist/hooks/use-debounce.js.map +1 -1
- package/dist/hooks/use-deep-memo.cjs.map +1 -1
- package/dist/hooks/use-deep-memo.js.map +1 -1
- package/dist/hooks/use-disclosure.cjs.map +1 -1
- package/dist/hooks/use-disclosure.js.map +1 -1
- package/dist/hooks/use-document-title.cjs.map +1 -1
- package/dist/hooks/use-document-title.js.map +1 -1
- package/dist/hooks/use-document-visibility.cjs.map +1 -1
- package/dist/hooks/use-document-visibility.js.map +1 -1
- package/dist/hooks/use-draft-filters.cjs.map +1 -1
- package/dist/hooks/use-draft-filters.js.map +1 -1
- package/dist/hooks/use-event-listener.cjs.map +1 -1
- package/dist/hooks/use-event-listener.js.map +1 -1
- package/dist/hooks/use-favicon.cjs.map +1 -1
- package/dist/hooks/use-favicon.js.map +1 -1
- package/dist/hooks/use-focus-trap.cjs.map +1 -1
- package/dist/hooks/use-focus-trap.js.map +1 -1
- package/dist/hooks/use-fullscreen-element.cjs.map +1 -1
- package/dist/hooks/use-fullscreen-element.js.map +1 -1
- package/dist/hooks/use-fullscreen.cjs +1 -1
- package/dist/hooks/use-fullscreen.cjs.map +1 -1
- package/dist/hooks/use-fullscreen.js +7 -23
- package/dist/hooks/use-fullscreen.js.map +1 -1
- package/dist/hooks/use-geolocation.cjs.map +1 -1
- package/dist/hooks/use-geolocation.js.map +1 -1
- package/dist/hooks/use-hover.cjs.map +1 -1
- package/dist/hooks/use-hover.js.map +1 -1
- package/dist/hooks/use-idle.cjs.map +1 -1
- package/dist/hooks/use-idle.js.map +1 -1
- package/dist/hooks/use-install-prompt.cjs +1 -1
- package/dist/hooks/use-install-prompt.cjs.map +1 -1
- package/dist/hooks/use-install-prompt.js +1 -1
- package/dist/hooks/use-install-prompt.js.map +1 -1
- package/dist/hooks/use-intersection-observer.cjs.map +1 -1
- package/dist/hooks/use-intersection-observer.js.map +1 -1
- package/dist/hooks/use-interval.cjs.map +1 -1
- package/dist/hooks/use-interval.js.map +1 -1
- package/dist/hooks/use-is-first-render.cjs.map +1 -1
- package/dist/hooks/use-is-first-render.js.map +1 -1
- package/dist/hooks/use-keyboard-shortcut.cjs.map +1 -1
- package/dist/hooks/use-keyboard-shortcut.js.map +1 -1
- package/dist/hooks/use-latest-ref.cjs.map +1 -1
- package/dist/hooks/use-latest-ref.js.map +1 -1
- package/dist/hooks/use-list-state.cjs.map +1 -1
- package/dist/hooks/use-list-state.js.map +1 -1
- package/dist/hooks/use-local-storage.cjs +1 -1
- package/dist/hooks/use-local-storage.cjs.map +1 -1
- package/dist/hooks/use-local-storage.js +2 -5
- package/dist/hooks/use-local-storage.js.map +1 -1
- package/dist/hooks/use-long-press-handlers.cjs.map +1 -1
- package/dist/hooks/use-long-press-handlers.js.map +1 -1
- package/dist/hooks/use-long-press.cjs.map +1 -1
- package/dist/hooks/use-long-press.js.map +1 -1
- package/dist/hooks/use-map.cjs.map +1 -1
- package/dist/hooks/use-map.js.map +1 -1
- package/dist/hooks/use-media-devices.cjs.map +1 -1
- package/dist/hooks/use-media-devices.js.map +1 -1
- package/dist/hooks/use-media-permission.cjs +1 -1
- package/dist/hooks/use-media-permission.cjs.map +1 -1
- package/dist/hooks/use-media-permission.js +2 -5
- package/dist/hooks/use-media-permission.js.map +1 -1
- package/dist/hooks/use-media-query.cjs.map +1 -1
- package/dist/hooks/use-media-query.js.map +1 -1
- package/dist/hooks/use-object-url.cjs.map +1 -1
- package/dist/hooks/use-object-url.js.map +1 -1
- package/dist/hooks/use-online.cjs.map +1 -1
- package/dist/hooks/use-online.js.map +1 -1
- package/dist/hooks/use-pagination.cjs.map +1 -1
- package/dist/hooks/use-pagination.js.map +1 -1
- package/dist/hooks/use-previous.cjs.map +1 -1
- package/dist/hooks/use-previous.js.map +1 -1
- package/dist/hooks/use-push-to-talk.cjs.map +1 -1
- package/dist/hooks/use-push-to-talk.js.map +1 -1
- package/dist/hooks/use-queue.cjs.map +1 -1
- package/dist/hooks/use-queue.js.map +1 -1
- package/dist/hooks/use-resize-observer.cjs.map +1 -1
- package/dist/hooks/use-resize-observer.js.map +1 -1
- package/dist/hooks/use-scroll-lock.cjs.map +1 -1
- package/dist/hooks/use-scroll-lock.js.map +1 -1
- package/dist/hooks/use-scroll-overflow.cjs.map +1 -1
- package/dist/hooks/use-scroll-overflow.js.map +1 -1
- package/dist/hooks/use-service-worker-update.cjs.map +1 -1
- package/dist/hooks/use-service-worker-update.js.map +1 -1
- package/dist/hooks/use-set.cjs.map +1 -1
- package/dist/hooks/use-set.js.map +1 -1
- package/dist/hooks/use-sortable.cjs.map +1 -1
- package/dist/hooks/use-sortable.js.map +1 -1
- package/dist/hooks/use-stable-callback.cjs.map +1 -1
- package/dist/hooks/use-stable-callback.js.map +1 -1
- package/dist/hooks/use-storage-estimate.cjs.map +1 -1
- package/dist/hooks/use-storage-estimate.js.map +1 -1
- package/dist/hooks/use-throttle.cjs.map +1 -1
- package/dist/hooks/use-throttle.js.map +1 -1
- package/dist/hooks/use-timeout.cjs.map +1 -1
- package/dist/hooks/use-timeout.js.map +1 -1
- package/dist/hooks/use-toggle.cjs.map +1 -1
- package/dist/hooks/use-toggle.js.map +1 -1
- package/dist/hooks/use-typewriter.cjs.map +1 -1
- package/dist/hooks/use-typewriter.js.map +1 -1
- package/dist/hooks/use-window-size.cjs.map +1 -1
- package/dist/hooks/use-window-size.js.map +1 -1
- package/dist/http/api-client.cjs +1 -1
- package/dist/http/api-client.cjs.map +1 -1
- package/dist/http/api-client.js +5 -1
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/build-url.cjs +1 -1
- package/dist/http/build-url.cjs.map +1 -1
- package/dist/http/build-url.js +3 -1
- package/dist/http/build-url.js.map +1 -1
- package/dist/http/credential-scope.cjs.map +1 -1
- package/dist/http/credential-scope.js.map +1 -1
- package/dist/http/csrf.cjs.map +1 -1
- package/dist/http/csrf.js.map +1 -1
- package/dist/http/decode-response.cjs.map +1 -1
- package/dist/http/decode-response.js.map +1 -1
- package/dist/http/describe-api-error.cjs.map +1 -1
- package/dist/http/describe-api-error.js.map +1 -1
- package/dist/http/errors.cjs.map +1 -1
- package/dist/http/errors.js.map +1 -1
- package/dist/http/idempotency.cjs.map +1 -1
- package/dist/http/idempotency.js.map +1 -1
- package/dist/http/parse-response.cjs.map +1 -1
- package/dist/http/parse-response.js.map +1 -1
- package/dist/http/presigned-post.cjs +2 -0
- package/dist/http/presigned-post.cjs.map +1 -0
- package/dist/http/presigned-post.js +73 -0
- package/dist/http/presigned-post.js.map +1 -0
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/retry.cjs.map +1 -1
- package/dist/http/retry.js.map +1 -1
- package/dist/http/timeout.cjs.map +1 -1
- package/dist/http/timeout.js.map +1 -1
- package/dist/http/upload-with-progress.cjs +1 -1
- package/dist/http/upload-with-progress.cjs.map +1 -1
- package/dist/http/upload-with-progress.js +2 -7
- package/dist/http/upload-with-progress.js.map +1 -1
- package/dist/http/use-describe-api-error.cjs.map +1 -1
- package/dist/http/use-describe-api-error.js.map +1 -1
- package/dist/http/use-poll.cjs +1 -1
- package/dist/http/use-poll.cjs.map +1 -1
- package/dist/http/use-poll.js +2 -5
- package/dist/http/use-poll.js.map +1 -1
- package/dist/i18n/I18nProvider.cjs.map +1 -1
- package/dist/i18n/I18nProvider.js.map +1 -1
- package/dist/i18n/create-i18n.cjs.map +1 -1
- package/dist/i18n/create-i18n.js.map +1 -1
- package/dist/icons/Icon.cjs.map +1 -1
- package/dist/icons/Icon.js.map +1 -1
- package/dist/icons/IconPicker.cjs.map +1 -1
- package/dist/icons/IconPicker.js.map +1 -1
- package/dist/icons/IconPicker.module.cjs.map +1 -1
- package/dist/icons/IconPicker.module.js.map +1 -1
- package/dist/icons/IconProvider.cjs.map +1 -1
- package/dist/icons/IconProvider.js.map +1 -1
- package/dist/icons/alias.cjs.map +1 -1
- package/dist/icons/alias.js.map +1 -1
- package/dist/icons/generated/aliases.cjs.map +1 -1
- package/dist/icons/generated/aliases.js.map +1 -1
- package/dist/icons/generated/icon-names.cjs.map +1 -1
- package/dist/icons/generated/icon-names.js.map +1 -1
- package/dist/icons/generated/loaders.cjs.map +1 -1
- package/dist/icons/generated/loaders.js.map +1 -1
- package/dist/icons/generated/shard-00.cjs.map +1 -1
- package/dist/icons/generated/shard-00.js.map +1 -1
- package/dist/icons/generated/shard-01.cjs.map +1 -1
- package/dist/icons/generated/shard-01.js.map +1 -1
- package/dist/icons/generated/shard-02.cjs.map +1 -1
- package/dist/icons/generated/shard-02.js.map +1 -1
- package/dist/icons/generated/shard-03.cjs.map +1 -1
- package/dist/icons/generated/shard-03.js.map +1 -1
- package/dist/icons/generated/shard-04.cjs.map +1 -1
- package/dist/icons/generated/shard-04.js.map +1 -1
- package/dist/icons/generated/shard-05.cjs.map +1 -1
- package/dist/icons/generated/shard-05.js.map +1 -1
- package/dist/icons/generated/shard-06.cjs.map +1 -1
- package/dist/icons/generated/shard-06.js.map +1 -1
- package/dist/icons/generated/shard-07.cjs.map +1 -1
- package/dist/icons/generated/shard-07.js.map +1 -1
- package/dist/icons/generated/shard-08.cjs.map +1 -1
- package/dist/icons/generated/shard-08.js.map +1 -1
- package/dist/icons/generated/shard-09.cjs.map +1 -1
- package/dist/icons/generated/shard-09.js.map +1 -1
- package/dist/icons/generated/shard-10.cjs.map +1 -1
- package/dist/icons/generated/shard-10.js.map +1 -1
- package/dist/icons/generated/shard-11.cjs.map +1 -1
- package/dist/icons/generated/shard-11.js.map +1 -1
- package/dist/icons/generated/shard-12.cjs.map +1 -1
- package/dist/icons/generated/shard-12.js.map +1 -1
- package/dist/icons/generated/shard-13.cjs.map +1 -1
- package/dist/icons/generated/shard-13.js.map +1 -1
- package/dist/icons/generated/shard-14.cjs.map +1 -1
- package/dist/icons/generated/shard-14.js.map +1 -1
- package/dist/icons/generated/shard-15.cjs.map +1 -1
- package/dist/icons/generated/shard-15.js.map +1 -1
- package/dist/icons/generated/shard-16.cjs.map +1 -1
- package/dist/icons/generated/shard-16.js.map +1 -1
- package/dist/icons/generated/shard-17.cjs.map +1 -1
- package/dist/icons/generated/shard-17.js.map +1 -1
- package/dist/icons/generated/shard-18.cjs.map +1 -1
- package/dist/icons/generated/shard-18.js.map +1 -1
- package/dist/icons/generated/shard-19.cjs.map +1 -1
- package/dist/icons/generated/shard-19.js.map +1 -1
- package/dist/icons/generated/shard-20.cjs.map +1 -1
- package/dist/icons/generated/shard-20.js.map +1 -1
- package/dist/icons/generated/shard-21.cjs.map +1 -1
- package/dist/icons/generated/shard-21.js.map +1 -1
- package/dist/icons/generated/shard-22.cjs.map +1 -1
- package/dist/icons/generated/shard-22.js.map +1 -1
- package/dist/icons/generated/shard-23.cjs.map +1 -1
- package/dist/icons/generated/shard-23.js.map +1 -1
- package/dist/icons/generated/shard-24.cjs.map +1 -1
- package/dist/icons/generated/shard-24.js.map +1 -1
- package/dist/icons/generated/shard-25.cjs.map +1 -1
- package/dist/icons/generated/shard-25.js.map +1 -1
- package/dist/icons/generated/shard-26.cjs.map +1 -1
- package/dist/icons/generated/shard-26.js.map +1 -1
- package/dist/icons/generated/shard-27.cjs.map +1 -1
- package/dist/icons/generated/shard-27.js.map +1 -1
- package/dist/icons/generated/shard-28.cjs.map +1 -1
- package/dist/icons/generated/shard-28.js.map +1 -1
- package/dist/icons/generated/shard-29.cjs.map +1 -1
- package/dist/icons/generated/shard-29.js.map +1 -1
- package/dist/icons/generated/shard-30.cjs.map +1 -1
- package/dist/icons/generated/shard-30.js.map +1 -1
- package/dist/icons/generated/shard-31.cjs.map +1 -1
- package/dist/icons/generated/shard-31.js.map +1 -1
- package/dist/icons/generated/shard-32.cjs.map +1 -1
- package/dist/icons/generated/shard-32.js.map +1 -1
- package/dist/icons/generated/shard-33.cjs.map +1 -1
- package/dist/icons/generated/shard-33.js.map +1 -1
- package/dist/icons/generated/shard-34.cjs.map +1 -1
- package/dist/icons/generated/shard-34.js.map +1 -1
- package/dist/icons/generated/shard-35.cjs.map +1 -1
- package/dist/icons/generated/shard-35.js.map +1 -1
- package/dist/icons/generated/shard-36.cjs.map +1 -1
- package/dist/icons/generated/shard-36.js.map +1 -1
- package/dist/icons/generated/shard-37.cjs.map +1 -1
- package/dist/icons/generated/shard-37.js.map +1 -1
- package/dist/icons/generated/shard-38.cjs.map +1 -1
- package/dist/icons/generated/shard-38.js.map +1 -1
- package/dist/icons/generated/shard-39.cjs.map +1 -1
- package/dist/icons/generated/shard-39.js.map +1 -1
- package/dist/icons/generated/shard-40.cjs.map +1 -1
- package/dist/icons/generated/shard-40.js.map +1 -1
- package/dist/icons/generated/shard-41.cjs.map +1 -1
- package/dist/icons/generated/shard-41.js.map +1 -1
- package/dist/icons/generated/shard-42.cjs.map +1 -1
- package/dist/icons/generated/shard-42.js.map +1 -1
- package/dist/icons/generated/shard-43.cjs.map +1 -1
- package/dist/icons/generated/shard-43.js.map +1 -1
- package/dist/icons/generated/shard-44.cjs.map +1 -1
- package/dist/icons/generated/shard-44.js.map +1 -1
- package/dist/icons/generated/shard-45.cjs.map +1 -1
- package/dist/icons/generated/shard-45.js.map +1 -1
- package/dist/icons/icon-context.cjs.map +1 -1
- package/dist/icons/icon-context.js.map +1 -1
- package/dist/icons/is-icon-name.cjs.map +1 -1
- package/dist/icons/is-icon-name.js.map +1 -1
- package/dist/icons/material-symbols.cjs.map +1 -1
- package/dist/icons/material-symbols.js.map +1 -1
- package/dist/icons/normalize-icon-name.cjs.map +1 -1
- package/dist/icons/normalize-icon-name.js.map +1 -1
- package/dist/icons/shard-cache.cjs +1 -1
- package/dist/icons/shard-cache.cjs.map +1 -1
- package/dist/icons/shard-cache.js +2 -5
- package/dist/icons/shard-cache.js.map +1 -1
- package/dist/icons/use-icon.cjs.map +1 -1
- package/dist/icons/use-icon.js.map +1 -1
- package/dist/icons/validate-icon-name.cjs.map +1 -1
- package/dist/icons/validate-icon-name.js.map +1 -1
- package/dist/icons-virtual.cjs.map +1 -1
- package/dist/icons-virtual.js.map +1 -1
- package/dist/imaging/canvas.cjs.map +1 -1
- package/dist/imaging/canvas.js.map +1 -1
- package/dist/imaging/compress.cjs.map +1 -1
- package/dist/imaging/compress.js.map +1 -1
- package/dist/imaging/decode.cjs.map +1 -1
- package/dist/imaging/decode.js.map +1 -1
- package/dist/imaging/encode.cjs.map +1 -1
- package/dist/imaging/encode.js.map +1 -1
- package/dist/imaging/exceptions.cjs.map +1 -1
- package/dist/imaging/exceptions.js.map +1 -1
- package/dist/imaging/frame.cjs.map +1 -1
- package/dist/imaging/frame.js.map +1 -1
- package/dist/imaging/thumbnails.cjs.map +1 -1
- package/dist/imaging/thumbnails.js.map +1 -1
- package/dist/imaging/transform.cjs.map +1 -1
- package/dist/imaging/transform.js.map +1 -1
- package/dist/imaging/use-image-processing.cjs.map +1 -1
- package/dist/imaging/use-image-processing.js.map +1 -1
- package/dist/logger/logger.cjs.map +1 -1
- package/dist/logger/logger.js.map +1 -1
- package/dist/neural.cjs.map +1 -1
- package/dist/neural.js.map +1 -1
- package/dist/oauth/GoogleSignIn.cjs +1 -1
- package/dist/oauth/GoogleSignIn.cjs.map +1 -1
- package/dist/oauth/GoogleSignIn.js +6 -9
- package/dist/oauth/GoogleSignIn.js.map +1 -1
- package/dist/oauth/callback.cjs.map +1 -1
- package/dist/oauth/callback.js.map +1 -1
- package/dist/oauth/use-oauth-callback.cjs.map +1 -1
- package/dist/oauth/use-oauth-callback.js.map +1 -1
- package/dist/offline/conflict.cjs.map +1 -1
- package/dist/offline/conflict.js.map +1 -1
- package/dist/offline/create-offline-database.cjs.map +1 -1
- package/dist/offline/create-offline-database.js.map +1 -1
- package/dist/offline/create-offline-store.cjs +1 -1
- package/dist/offline/create-offline-store.cjs.map +1 -1
- package/dist/offline/create-offline-store.js +1 -5
- package/dist/offline/create-offline-store.js.map +1 -1
- package/dist/offline/create-offline-sync.cjs +1 -1
- package/dist/offline/create-offline-sync.cjs.map +1 -1
- package/dist/offline/create-offline-sync.js +9 -14
- package/dist/offline/create-offline-sync.js.map +1 -1
- package/dist/offline/use-offline-sync.cjs.map +1 -1
- package/dist/offline/use-offline-sync.js.map +1 -1
- package/dist/perf/cache-size.cjs.map +1 -1
- package/dist/perf/cache-size.js.map +1 -1
- package/dist/perf/device.cjs.map +1 -1
- package/dist/perf/device.js.map +1 -1
- package/dist/perf/format.cjs.map +1 -1
- package/dist/perf/format.js.map +1 -1
- package/dist/perf/profiler.cjs.map +1 -1
- package/dist/perf/profiler.js.map +1 -1
- package/dist/push/use-push-subscription.cjs.map +1 -1
- package/dist/push/use-push-subscription.js.map +1 -1
- package/dist/push/utils.cjs.map +1 -1
- package/dist/push/utils.js.map +1 -1
- package/dist/push/web-push-client.cjs.map +1 -1
- package/dist/push/web-push-client.js.map +1 -1
- package/dist/query/QueryProvider.cjs.map +1 -1
- package/dist/query/QueryProvider.js.map +1 -1
- package/dist/query/constants.cjs.map +1 -1
- package/dist/query/constants.js.map +1 -1
- package/dist/query/create-query-keys.cjs.map +1 -1
- package/dist/query/create-query-keys.js.map +1 -1
- package/dist/query/foreign-client-warning.cjs.map +1 -1
- package/dist/query/foreign-client-warning.js.map +1 -1
- package/dist/query/offline-persistence.cjs +1 -1
- package/dist/query/offline-persistence.cjs.map +1 -1
- package/dist/query/offline-persistence.js +2 -10
- package/dist/query/offline-persistence.js.map +1 -1
- package/dist/query/optimistic.cjs.map +1 -1
- package/dist/query/optimistic.js.map +1 -1
- package/dist/query/pagination.cjs.map +1 -1
- package/dist/query/pagination.js.map +1 -1
- package/dist/query/retry-policy.cjs.map +1 -1
- package/dist/query/retry-policy.js.map +1 -1
- package/dist/query/use-cursor-query.cjs.map +1 -1
- package/dist/query/use-cursor-query.js.map +1 -1
- package/dist/query/use-offline-mutation.cjs.map +1 -1
- package/dist/query/use-offline-mutation.js.map +1 -1
- package/dist/query/use-paginated-query.cjs.map +1 -1
- package/dist/query/use-paginated-query.js.map +1 -1
- package/dist/router/AppRouter.cjs.map +1 -1
- package/dist/router/AppRouter.js.map +1 -1
- package/dist/router/RouteGuard.cjs.map +1 -1
- package/dist/router/RouteGuard.js.map +1 -1
- package/dist/router/index.js +2 -2
- package/dist/share/share-or-download.cjs.map +1 -1
- package/dist/share/share-or-download.js.map +1 -1
- package/dist/share/share.cjs.map +1 -1
- package/dist/share/share.js.map +1 -1
- package/dist/sse/create-event-stream.cjs +1 -1
- package/dist/sse/create-event-stream.cjs.map +1 -1
- package/dist/sse/create-event-stream.js +44 -30
- package/dist/sse/create-event-stream.js.map +1 -1
- package/dist/sse/ticket-event-stream.cjs +2 -0
- package/dist/sse/ticket-event-stream.cjs.map +1 -0
- package/dist/sse/ticket-event-stream.js +41 -0
- package/dist/sse/ticket-event-stream.js.map +1 -0
- package/dist/sse/use-event-stream.cjs +1 -1
- package/dist/sse/use-event-stream.cjs.map +1 -1
- package/dist/sse/use-event-stream.js +7 -4
- package/dist/sse/use-event-stream.js.map +1 -1
- package/dist/store/create-selectors.cjs.map +1 -1
- package/dist/store/create-selectors.js.map +1 -1
- package/dist/store/create-store.cjs.map +1 -1
- package/dist/store/create-store.js.map +1 -1
- package/dist/sw/background-sync.cjs.map +1 -1
- package/dist/sw/background-sync.js.map +1 -1
- package/dist/sw/cache-inspect.cjs.map +1 -1
- package/dist/sw/cache-inspect.js.map +1 -1
- package/dist/sw/cache.cjs +1 -1
- package/dist/sw/cache.cjs.map +1 -1
- package/dist/sw/cache.js +2 -6
- package/dist/sw/cache.js.map +1 -1
- package/dist/sw/create-push-handler.cjs.map +1 -1
- package/dist/sw/create-push-handler.js.map +1 -1
- package/dist/sw/credential-headers.cjs.map +1 -1
- package/dist/sw/credential-headers.js.map +1 -1
- package/dist/sw/periodic-sync.cjs.map +1 -1
- package/dist/sw/periodic-sync.js.map +1 -1
- package/dist/sw/register-service-worker.cjs.map +1 -1
- package/dist/sw/register-service-worker.js.map +1 -1
- package/dist/sw/session-data.cjs.map +1 -1
- package/dist/sw/session-data.js.map +1 -1
- package/dist/tabular/assets.cjs.map +1 -1
- package/dist/tabular/assets.js.map +1 -1
- package/dist/tabular/cache.cjs.map +1 -1
- package/dist/tabular/cache.js.map +1 -1
- package/dist/tabular/compact.cjs.map +1 -1
- package/dist/tabular/compact.js.map +1 -1
- package/dist/tabular/exceptions.cjs.map +1 -1
- package/dist/tabular/exceptions.js.map +1 -1
- package/dist/tabular/manifest.cjs.map +1 -1
- package/dist/tabular/manifest.js.map +1 -1
- package/dist/tabular/predictor.cjs.map +1 -1
- package/dist/tabular/predictor.js.map +1 -1
- package/dist/tabular/use-tabular-predictor.cjs.map +1 -1
- package/dist/tabular/use-tabular-predictor.js.map +1 -1
- package/dist/telemetry/TelemetryProvider.cjs.map +1 -1
- package/dist/telemetry/TelemetryProvider.js.map +1 -1
- package/dist/telemetry/app-error-adapter.cjs.map +1 -1
- package/dist/telemetry/app-error-adapter.js.map +1 -1
- package/dist/telemetry/app-error-queue.cjs.map +1 -1
- package/dist/telemetry/app-error-queue.js.map +1 -1
- package/dist/telemetry/app-error-reporter.cjs.map +1 -1
- package/dist/telemetry/app-error-reporter.js.map +1 -1
- package/dist/telemetry/app-error-schema.cjs.map +1 -1
- package/dist/telemetry/app-error-schema.js.map +1 -1
- package/dist/telemetry/app-error-transport.cjs.map +1 -1
- package/dist/telemetry/app-error-transport.js.map +1 -1
- package/dist/telemetry/console-adapter.cjs.map +1 -1
- package/dist/telemetry/console-adapter.js.map +1 -1
- package/dist/telemetry/describe-app-error.cjs.map +1 -1
- package/dist/telemetry/describe-app-error.js.map +1 -1
- package/dist/telemetry/posthog-adapter.cjs +1 -1
- package/dist/telemetry/posthog-adapter.cjs.map +1 -1
- package/dist/telemetry/posthog-adapter.js +1 -5
- package/dist/telemetry/posthog-adapter.js.map +1 -1
- package/dist/telemetry/sentry-adapter.cjs.map +1 -1
- package/dist/telemetry/sentry-adapter.js.map +1 -1
- package/dist/tempest-react-sdk.cjs +1 -1
- package/dist/tempest-react-sdk.d.ts +440 -7
- package/dist/tempest-react-sdk.js +122 -120
- package/dist/testing/create-mock-handlers.cjs.map +1 -1
- package/dist/testing/create-mock-handlers.js.map +1 -1
- package/dist/testing.js +1 -2
- package/dist/theme/ThemeProvider.cjs.map +1 -1
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/theme/apply-theme.cjs.map +1 -1
- package/dist/theme/apply-theme.js.map +1 -1
- package/dist/theme/color.cjs.map +1 -1
- package/dist/theme/color.js.map +1 -1
- package/dist/theme/create-theme.cjs.map +1 -1
- package/dist/theme/create-theme.js.map +1 -1
- package/dist/theme/data-viz-ramps.cjs.map +1 -1
- package/dist/theme/data-viz-ramps.js.map +1 -1
- package/dist/theme/initial-theme.cjs.map +1 -1
- package/dist/theme/initial-theme.js.map +1 -1
- package/dist/theme/inverse-render.cjs.map +1 -1
- package/dist/theme/inverse-render.js.map +1 -1
- package/dist/theme/inverse-restore.cjs.map +1 -1
- package/dist/theme/inverse-restore.js.map +1 -1
- package/dist/theme/inverse-surface.cjs.map +1 -1
- package/dist/theme/inverse-surface.js.map +1 -1
- package/dist/theme/status-tokens.cjs.map +1 -1
- package/dist/theme/status-tokens.js.map +1 -1
- package/dist/theme/theme-presets.cjs.map +1 -1
- package/dist/theme/theme-presets.js.map +1 -1
- package/dist/utils/absent.cjs.map +1 -1
- package/dist/utils/absent.js.map +1 -1
- package/dist/utils/arrays.cjs.map +1 -1
- package/dist/utils/arrays.js.map +1 -1
- package/dist/utils/base64.cjs.map +1 -1
- package/dist/utils/base64.js.map +1 -1
- package/dist/utils/cn.cjs.map +1 -1
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/compare-values.cjs.map +1 -1
- package/dist/utils/compare-values.js.map +1 -1
- package/dist/utils/compressed-storage.cjs.map +1 -1
- package/dist/utils/compressed-storage.js.map +1 -1
- package/dist/utils/csv.cjs.map +1 -1
- package/dist/utils/csv.js.map +1 -1
- package/dist/utils/dev-mode.cjs.map +1 -1
- package/dist/utils/dev-mode.js.map +1 -1
- package/dist/utils/duplicate-instance.cjs.map +1 -1
- package/dist/utils/duplicate-instance.js.map +1 -1
- package/dist/utils/format.cjs.map +1 -1
- package/dist/utils/format.js.map +1 -1
- package/dist/utils/functions.cjs +1 -1
- package/dist/utils/functions.cjs.map +1 -1
- package/dist/utils/functions.js +1 -1
- package/dist/utils/functions.js.map +1 -1
- package/dist/utils/guards.cjs.map +1 -1
- package/dist/utils/guards.js.map +1 -1
- package/dist/utils/ids.cjs.map +1 -1
- package/dist/utils/ids.js.map +1 -1
- package/dist/utils/intl-cache.cjs.map +1 -1
- package/dist/utils/intl-cache.js.map +1 -1
- package/dist/utils/json-frame.cjs.map +1 -1
- package/dist/utils/json-frame.js.map +1 -1
- package/dist/utils/numbers.cjs.map +1 -1
- package/dist/utils/numbers.js.map +1 -1
- package/dist/utils/objects.cjs.map +1 -1
- package/dist/utils/objects.js.map +1 -1
- package/dist/utils/owner-fingerprint.cjs.map +1 -1
- package/dist/utils/owner-fingerprint.js.map +1 -1
- package/dist/utils/promises.cjs.map +1 -1
- package/dist/utils/promises.js.map +1 -1
- package/dist/utils/relative-time.cjs.map +1 -1
- package/dist/utils/relative-time.js.map +1 -1
- package/dist/utils/safe-url.cjs.map +1 -1
- package/dist/utils/safe-url.js.map +1 -1
- package/dist/utils/schema-like.cjs.map +1 -1
- package/dist/utils/schema-like.js.map +1 -1
- package/dist/utils/storage.cjs +1 -1
- package/dist/utils/storage.cjs.map +1 -1
- package/dist/utils/storage.js +2 -2
- package/dist/utils/storage.js.map +1 -1
- package/dist/utils/strings.cjs.map +1 -1
- package/dist/utils/strings.js.map +1 -1
- package/dist/utils/xlsx.cjs.map +1 -1
- package/dist/utils/xlsx.js.map +1 -1
- package/dist/vision/core/canvas.cjs.map +1 -1
- package/dist/vision/core/canvas.js.map +1 -1
- package/dist/vision/core/dtypes.cjs.map +1 -1
- package/dist/vision/core/dtypes.js.map +1 -1
- package/dist/vision/core/exceptions.cjs.map +1 -1
- package/dist/vision/core/exceptions.js.map +1 -1
- package/dist/vision/core/graph.cjs.map +1 -1
- package/dist/vision/core/graph.js.map +1 -1
- package/dist/vision/core/metadata.cjs +1 -1
- package/dist/vision/core/metadata.cjs.map +1 -1
- package/dist/vision/core/metadata.js +9 -26
- package/dist/vision/core/metadata.js.map +1 -1
- package/dist/vision/core/providers.cjs.map +1 -1
- package/dist/vision/core/providers.js.map +1 -1
- package/dist/vision/core/session.cjs.map +1 -1
- package/dist/vision/core/session.js.map +1 -1
- package/dist/vision/core/timing.cjs.map +1 -1
- package/dist/vision/core/timing.js.map +1 -1
- package/dist/vision/fusion.cjs.map +1 -1
- package/dist/vision/fusion.js.map +1 -1
- package/dist/vision/index.cjs.map +1 -1
- package/dist/vision/index.js.map +1 -1
- package/dist/vision/io/image.cjs.map +1 -1
- package/dist/vision/io/image.js.map +1 -1
- package/dist/vision/labels.cjs.map +1 -1
- package/dist/vision/labels.js.map +1 -1
- package/dist/vision/luminance.cjs.map +1 -1
- package/dist/vision/luminance.js.map +1 -1
- package/dist/vision/normalization.cjs.map +1 -1
- package/dist/vision/normalization.js.map +1 -1
- package/dist/vision/postprocess/classification.cjs.map +1 -1
- package/dist/vision/postprocess/classification.js.map +1 -1
- package/dist/vision/postprocess/detection.cjs.map +1 -1
- package/dist/vision/postprocess/detection.js.map +1 -1
- package/dist/vision/postprocess/segmentation.cjs.map +1 -1
- package/dist/vision/postprocess/segmentation.js.map +1 -1
- package/dist/vision/preprocess/image.cjs.map +1 -1
- package/dist/vision/preprocess/image.js.map +1 -1
- package/dist/vision/preprocess/pipeline.cjs.map +1 -1
- package/dist/vision/preprocess/pipeline.js.map +1 -1
- package/dist/vision/results.cjs.map +1 -1
- package/dist/vision/results.js.map +1 -1
- package/dist/vision/tasks/base.cjs.map +1 -1
- package/dist/vision/tasks/base.js.map +1 -1
- package/dist/vision/tasks/classifier.cjs.map +1 -1
- package/dist/vision/tasks/classifier.js.map +1 -1
- package/dist/vision/tasks/detectClassify.cjs.map +1 -1
- package/dist/vision/tasks/detectClassify.js.map +1 -1
- package/dist/vision/tasks/detector.cjs.map +1 -1
- package/dist/vision/tasks/detector.js.map +1 -1
- package/dist/vision/tasks/segmenter.cjs.map +1 -1
- package/dist/vision/tasks/segmenter.js.map +1 -1
- package/dist/vision/types.cjs.map +1 -1
- package/dist/vision/types.js.map +1 -1
- package/dist/vision/use-camera-stream.cjs +1 -1
- package/dist/vision/use-camera-stream.cjs.map +1 -1
- package/dist/vision/use-camera-stream.js +3 -9
- package/dist/vision/use-camera-stream.js.map +1 -1
- package/dist/vision/use-live-luminance.cjs +1 -1
- package/dist/vision/use-live-luminance.cjs.map +1 -1
- package/dist/vision/use-live-luminance.js +1 -5
- package/dist/vision/use-live-luminance.js.map +1 -1
- package/dist/vite/base-url.cjs.map +1 -1
- package/dist/vite/base-url.js.map +1 -1
- package/dist/vite/create-vite-config.cjs.map +1 -1
- package/dist/vite/create-vite-config.js.map +1 -1
- package/dist/vite/narrow-tokens.cjs.map +1 -1
- package/dist/vite/narrow-tokens.js.map +1 -1
- package/dist/vite/tempest-csp.cjs +1 -1
- package/dist/vite/tempest-csp.cjs.map +1 -1
- package/dist/vite/tempest-csp.js +2 -10
- package/dist/vite/tempest-csp.js.map +1 -1
- package/dist/vite/tempest-icons.cjs.map +1 -1
- package/dist/vite/tempest-icons.js.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.js +9 -16
- package/dist/vite/tempest-pwa-dev-sw.js.map +1 -1
- package/dist/vite/tempest-pwa-icons.cjs.map +1 -1
- package/dist/vite/tempest-pwa-icons.js.map +1 -1
- package/dist/vite/tempest-pwa-manifest.cjs.map +1 -1
- package/dist/vite/tempest-pwa-manifest.js.map +1 -1
- package/dist/vite/tempest-styles.cjs.map +1 -1
- package/dist/vite/tempest-styles.js.map +1 -1
- package/dist/vite/tempest-vitest.cjs.map +1 -1
- package/dist/vite/tempest-vitest.js.map +1 -1
- package/dist/webrtc/link-stats.cjs.map +1 -1
- package/dist/webrtc/link-stats.js.map +1 -1
- package/dist/webrtc/mesh-quality.cjs.map +1 -1
- package/dist/webrtc/mesh-quality.js.map +1 -1
- package/dist/webrtc/opus-sdp.cjs.map +1 -1
- package/dist/webrtc/opus-sdp.js.map +1 -1
- package/dist/webrtc/peer-link.cjs +1 -1
- package/dist/webrtc/peer-link.cjs.map +1 -1
- package/dist/webrtc/peer-link.js +2 -5
- package/dist/webrtc/peer-link.js.map +1 -1
- package/dist/webrtc/peer-mesh.cjs +1 -1
- package/dist/webrtc/peer-mesh.cjs.map +1 -1
- package/dist/webrtc/peer-mesh.js +8 -24
- package/dist/webrtc/peer-mesh.js.map +1 -1
- package/dist/webrtc/sender-bitrate.cjs.map +1 -1
- package/dist/webrtc/sender-bitrate.js.map +1 -1
- package/dist/webrtc/use-link-stats.cjs.map +1 -1
- package/dist/webrtc/use-link-stats.js.map +1 -1
- package/dist/ws/create-web-socket.cjs +1 -1
- package/dist/ws/create-web-socket.cjs.map +1 -1
- package/dist/ws/create-web-socket.js +4 -22
- package/dist/ws/create-web-socket.js.map +1 -1
- package/dist/ws/resilience.cjs.map +1 -1
- package/dist/ws/resilience.js.map +1 -1
- package/dist/ws/use-web-socket.cjs.map +1 -1
- package/dist/ws/use-web-socket.js.map +1 -1
- package/package.json +9 -6
- package/template/package.json +1 -1
package/dist/br/holidays.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holidays.cjs","names":[],"sources":["../../src/br/holidays.ts"],"sourcesContent":["/**\n * How binding a non-working day is.\n *\n * - `\"national\"` — a feriado nacional in federal law. Nobody works, and a\n * deadline that lands here moves.\n * - `\"banking\"` — not a statutory holiday, but a day the national financial\n * system does not operate: Carnaval (Monday and Tuesday), Sexta-feira da\n * Paixão and Corpus Christi. Bank branches are shut and compensation does not\n * run, so a boleto or a TED dated here settles later — but an employer may\n * legally require work, which is why the two kinds are separate.\n */\nexport type HolidayKind = \"national\" | \"banking\";\n\n/** One non-working day in a given year. */\nexport interface Holiday {\n /** `YYYY-MM-DD` in the local calendar. */\n date: string;\n /** Portuguese name, as the law or the Bacen calendar spells it. */\n name: string;\n kind: HolidayKind;\n /** `true` when the date is derived from Easter rather than fixed. */\n movable: boolean;\n}\n\n/** Anything these helpers accept as a day. */\nexport type DateInput = Date | string;\n\n/** Options shared by the calendar helpers. */\nexport interface BusinessDayOptions {\n /**\n * Which kinds count as non-working. Default `[\"national\", \"banking\"]`, i.e.\n * the Bacen calendar — the right default for anything money moves through.\n * Pass `[\"national\"]` for a labour-law calendar.\n */\n kinds?: readonly HolidayKind[];\n /**\n * Extra non-working days, as `YYYY-MM-DD` or `Date`. This is where state and\n * municipal holidays go: they are **not** in the built-in table and never will\n * be — there are 5 570 municipalities, each free to declare its own.\n */\n extra?: readonly DateInput[];\n /**\n * Days of the week that are not worked, `0` = Sunday. Default `[0, 6]`.\n */\n weekend?: readonly number[];\n}\n\n/** Fixed-date national holidays, with the year each became one. */\nconst FIXED_HOLIDAYS: readonly {\n month: number;\n day: number;\n name: string;\n kind: HolidayKind;\n since?: number;\n}[] = [\n { month: 1, day: 1, name: \"Confraternização Universal\", kind: \"national\" },\n { month: 4, day: 21, name: \"Tiradentes\", kind: \"national\" },\n { month: 5, day: 1, name: \"Dia do Trabalho\", kind: \"national\" },\n { month: 9, day: 7, name: \"Independência do Brasil\", kind: \"national\" },\n { month: 10, day: 12, name: \"Nossa Senhora Aparecida\", kind: \"national\" },\n { month: 11, day: 2, name: \"Finados\", kind: \"national\" },\n { month: 11, day: 15, name: \"Proclamação da República\", kind: \"national\" },\n {\n month: 11,\n day: 20,\n name: \"Dia Nacional de Zumbi e da Consciência Negra\",\n kind: \"national\",\n since: 2024,\n },\n { month: 12, day: 25, name: \"Natal\", kind: \"national\" },\n];\n\n/** Easter-relative holidays, as a day offset from Easter Sunday. */\nconst MOVABLE_HOLIDAYS: readonly { offset: number; name: string; kind: HolidayKind }[] = [\n { offset: -48, name: \"Carnaval (segunda-feira)\", kind: \"banking\" },\n { offset: -47, name: \"Carnaval (terça-feira)\", kind: \"banking\" },\n { offset: -2, name: \"Sexta-feira da Paixão\", kind: \"banking\" },\n { offset: 60, name: \"Corpus Christi\", kind: \"banking\" },\n];\n\nconst DEFAULT_KINDS: readonly HolidayKind[] = [\"national\", \"banking\"];\nconst DEFAULT_WEEKEND: readonly number[] = [0, 6];\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * How far a walk may go before it is treated as a bug rather than a long holiday.\n *\n * A real calendar never has more than a handful of consecutive non-working days,\n * so hitting this means `extra` or `weekend` marked every day off, and looping\n * forever is worse than an error.\n */\nconst MAX_WALK_DAYS = 400;\n\n/** `YYYY-MM-DD` from a local-calendar date. */\nfunction toIso(year: number, month: number, day: number): string {\n return `${String(year).padStart(4, \"0\")}-${String(month).padStart(2, \"0\")}-${String(day).padStart(2, \"0\")}`;\n}\n\n/**\n * Local midnight for any accepted input.\n *\n * Everything here works on local calendar components, never on UTC: `new Date(y,\n * m, d)` and `getFullYear()/getMonth()/getDate()`. Going through `toISOString()`\n * would shift the day for every viewer east of Greenwich, and \"is today a\n * holiday\" is a question about the viewer's calendar.\n *\n * @throws {RangeError} When a string is not `YYYY-MM-DD` or a `Date` is invalid.\n */\nfunction toLocalDate(input: DateInput): Date {\n if (typeof input === \"string\") {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(input.trim());\n if (match === null) {\n throw new RangeError(`Expected a YYYY-MM-DD date, got ${JSON.stringify(input)}.`);\n }\n return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n }\n if (Number.isNaN(input.getTime())) throw new RangeError(\"Received an Invalid Date.\");\n return new Date(input.getFullYear(), input.getMonth(), input.getDate());\n}\n\n/** `YYYY-MM-DD` for any accepted input. */\nfunction isoOf(input: DateInput): string {\n const date = toLocalDate(input);\n return toIso(date.getFullYear(), date.getMonth() + 1, date.getDate());\n}\n\n/**\n * Easter Sunday in the Gregorian calendar.\n *\n * The anonymous Gregorian computus (Meeus/Jones/Butcher): pure integer\n * arithmetic over the year, no tables and no dependency. It is exact for every\n * Gregorian year, which is why the four movable Brazilian holidays are derived\n * from it rather than listed.\n *\n * @param year - Gregorian year.\n * @returns Local midnight of Easter Sunday.\n *\n * @example\n * easterSunday(2026); // 2026-04-05\n */\nexport function easterSunday(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n return new Date(year, month - 1, day);\n}\n\n/**\n * Every national non-working day in a year, ordered by date.\n *\n * **What is here:** the nine feriados nacionais in federal law (Lei 662/1949 as\n * amended by Lei 10.607/2002, Lei 6.802/1980 for 12 October, and Lei 14.759/2023\n * for 20 November, which is why that one only appears from 2024), plus the four\n * movable days the national financial system observes.\n *\n * **What is deliberately not here**, and will not be:\n *\n * - **State and municipal holidays.** A data magna varies by state and each of the\n * 5 570 municipalities may declare its own, including up to four religious\n * days. No table can be both complete and current; pass them through\n * `options.extra`.\n * - **Ponto facultativo.** A federal decree that lets public servants off is not a\n * holiday and binds nobody else, so it changes no deadline.\n * - **Pre-2002 history.** The table encodes the law as it stands today. Asking for\n * 1998 returns today's set shifted to 1998, not what was in force then.\n *\n * Carnaval, Sexta-feira da Paixão and Corpus Christi are the interesting case:\n * none of them is a feriado nacional in federal law, yet CMN Resolução 4.880/2020\n * closes the banks on all four days, so a payment cannot settle. They are returned\n * with `kind: \"banking\"` — counted by default, and excluded by passing\n * `kinds: [\"national\"]`.\n *\n * @param year - Gregorian year.\n * @returns The holidays of that year, ascending by date.\n *\n * @example\n * holidaysFor(2026).filter((holiday) => holiday.kind === \"national\").length; // 9\n */\nexport function holidaysFor(year: number): Holiday[] {\n const holidays: Holiday[] = FIXED_HOLIDAYS.filter(\n (entry) => entry.since === undefined || year >= entry.since,\n ).map((entry) => ({\n date: toIso(year, entry.month, entry.day),\n name: entry.name,\n kind: entry.kind,\n movable: false,\n }));\n\n const easter = easterSunday(year);\n for (const entry of MOVABLE_HOLIDAYS) {\n const date = new Date(easter.getTime() + entry.offset * MS_PER_DAY);\n holidays.push({\n date: toIso(date.getFullYear(), date.getMonth() + 1, date.getDate()),\n name: entry.name,\n kind: entry.kind,\n movable: true,\n });\n }\n\n return holidays.sort((left, right) => left.date.localeCompare(right.date));\n}\n\n/** The set of `YYYY-MM-DD` strings that count as off for a given year. */\nfunction offDays(year: number, options: BusinessDayOptions): Set<string> {\n const kinds = options.kinds ?? DEFAULT_KINDS;\n const days = new Set(\n holidaysFor(year)\n .filter((holiday) => kinds.includes(holiday.kind))\n .map((holiday) => holiday.date),\n );\n for (const entry of options.extra ?? []) days.add(isoOf(entry));\n return days;\n}\n\n/**\n * Whether a date is a national holiday.\n *\n * @param date - `YYYY-MM-DD` or a `Date`. Only the local calendar day matters.\n * @param options - See {@link BusinessDayOptions}. `weekend` is ignored here — a\n * Sunday is not a holiday, it is a Sunday.\n * @returns `true` when the day is in the table (or in `extra`).\n * @throws {RangeError} On a malformed string or an Invalid Date.\n *\n * @example\n * isHoliday(\"2026-11-20\"); // true\n * isHoliday(\"2026-02-17\"); // true — Carnaval\n * isHoliday(\"2026-02-17\", { kinds: [\"national\"] }); // false\n */\nexport function isHoliday(date: DateInput, options: BusinessDayOptions = {}): boolean {\n const iso = isoOf(date);\n return offDays(Number(iso.slice(0, 4)), options).has(iso);\n}\n\n/**\n * Whether a date is a working day: not a weekend, not a holiday.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param options - See {@link BusinessDayOptions}.\n * @returns `true` when work happens on that day.\n * @throws {RangeError} On a malformed string or an Invalid Date.\n *\n * @example\n * isBusinessDay(\"2026-04-03\"); // false — Sexta-feira da Paixão\n */\nexport function isBusinessDay(date: DateInput, options: BusinessDayOptions = {}): boolean {\n const local = toLocalDate(date);\n const weekend = options.weekend ?? DEFAULT_WEEKEND;\n if (weekend.includes(local.getDay())) return false;\n return !isHoliday(local, options);\n}\n\n/**\n * The first working day strictly after a date.\n *\n * Strictly after: calling it on a Wednesday returns Thursday, never the same\n * Wednesday. That is what a \"prazo de D+1\" means, and it makes the function safe\n * to call in a loop.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param options - See {@link BusinessDayOptions}.\n * @returns Local midnight of the next working day.\n * @throws {RangeError} On a malformed input, or when `options` marked so many days\n * off that no working day exists within {@link MAX_WALK_DAYS}.\n *\n * @example\n * nextBusinessDay(\"2026-12-24\"); // 2026-12-28 — the 25th is Natal, then a weekend\n */\nexport function nextBusinessDay(date: DateInput, options: BusinessDayOptions = {}): Date {\n const cursor = toLocalDate(date);\n for (let step = 0; step < MAX_WALK_DAYS; step += 1) {\n cursor.setDate(cursor.getDate() + 1);\n if (isBusinessDay(cursor, options)) return cursor;\n }\n throw new RangeError(\n `No business day within ${MAX_WALK_DAYS} days of ${isoOf(date)} — check \\`weekend\\` and \\`extra\\`.`,\n );\n}\n\n/**\n * Move a date by a number of working days.\n *\n * `n` days forward means `n` calls to {@link nextBusinessDay}; a negative `n`\n * walks backwards the same way. `n === 0` returns the day unchanged **even when it\n * is not a working day** — snapping silently would hide the case a caller most\n * needs to see.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param days - Working days to add. May be negative.\n * @param options - See {@link BusinessDayOptions}.\n * @returns Local midnight of the resulting day.\n * @throws {RangeError} On a malformed input, or on a calendar with no working days.\n *\n * @example\n * addBusinessDays(\"2026-04-01\", 2); // 2026-04-06 — skips Good Friday and the weekend\n */\nexport function addBusinessDays(\n date: DateInput,\n days: number,\n options: BusinessDayOptions = {},\n): Date {\n const cursor = toLocalDate(date);\n const direction = days < 0 ? -1 : 1;\n for (let moved = 0; moved < Math.abs(days); moved += 1) {\n let landed = false;\n for (let step = 0; step < MAX_WALK_DAYS && !landed; step += 1) {\n cursor.setDate(cursor.getDate() + direction);\n landed = isBusinessDay(cursor, options);\n }\n if (!landed) {\n throw new RangeError(\n `No business day within ${MAX_WALK_DAYS} days while walking from ${isoOf(date)} — ` +\n \"check `weekend` and `extra`.\",\n );\n }\n }\n return cursor;\n}\n"],"mappings":"AAgDA,IAAM,EAMA,CACF,CAAE,MAAO,EAAG,IAAK,EAAG,KAAM,6BAA8B,KAAM,UAAW,EACzE,CAAE,MAAO,EAAG,IAAK,GAAI,KAAM,aAAc,KAAM,UAAW,EAC1D,CAAE,MAAO,EAAG,IAAK,EAAG,KAAM,kBAAmB,KAAM,UAAW,EAC9D,CAAE,MAAO,EAAG,IAAK,EAAG,KAAM,0BAA2B,KAAM,UAAW,EACtE,CAAE,MAAO,GAAI,IAAK,GAAI,KAAM,0BAA2B,KAAM,UAAW,EACxE,CAAE,MAAO,GAAI,IAAK,EAAG,KAAM,UAAW,KAAM,UAAW,EACvD,CAAE,MAAO,GAAI,IAAK,GAAI,KAAM,2BAA4B,KAAM,UAAW,EACzE,CACI,MAAO,GACP,IAAK,GACL,KAAM,+CACN,KAAM,WACN,MAAO,IACX,EACA,CAAE,MAAO,GAAI,IAAK,GAAI,KAAM,QAAS,KAAM,UAAW,CAC1D,EAGM,EAAmF,CACrF,CAAE,OAAQ,IAAK,KAAM,2BAA4B,KAAM,SAAU,EACjE,CAAE,OAAQ,IAAK,KAAM,yBAA0B,KAAM,SAAU,EAC/D,CAAE,OAAQ,GAAI,KAAM,wBAAyB,KAAM,SAAU,EAC7D,CAAE,OAAQ,G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so","year","month","day","toLocalDate","input","match","isoOf","date","easterSunday","a","b","c","d","e","f","g","h","i","k","l","m","holidaysFor","holidays","entry","easter","left","right","offDays","kinds","options","days","holiday","isHoliday","iso","isBusinessDay","local","nextBusinessDay","cursor","step","addBusinessDays","direction","moved","landed"],"sources":["../../src/br/holidays.ts"],"sourcesContent":["/**\n * How binding a non-working day is.\n *\n * - `\"national\"` — a feriado nacional in federal law. Nobody works, and a\n * deadline that lands here moves.\n * - `\"banking\"` — not a statutory holiday, but a day the national financial\n * system does not operate: Carnaval (Monday and Tuesday), Sexta-feira da\n * Paixão and Corpus Christi. Bank branches are shut and compensation does not\n * run, so a boleto or a TED dated here settles later — but an employer may\n * legally require work, which is why the two kinds are separate.\n */\nexport type HolidayKind = \"national\" | \"banking\";\n\n/** One non-working day in a given year. */\nexport interface Holiday {\n /** `YYYY-MM-DD` in the local calendar. */\n date: string;\n /** Portuguese name, as the law or the Bacen calendar spells it. */\n name: string;\n kind: HolidayKind;\n /** `true` when the date is derived from Easter rather than fixed. */\n movable: boolean;\n}\n\n/** Anything these helpers accept as a day. */\nexport type DateInput = Date | string;\n\n/** Options shared by the calendar helpers. */\nexport interface BusinessDayOptions {\n /**\n * Which kinds count as non-working. Default `[\"national\", \"banking\"]`, i.e.\n * the Bacen calendar — the right default for anything money moves through.\n * Pass `[\"national\"]` for a labour-law calendar.\n */\n kinds?: readonly HolidayKind[];\n /**\n * Extra non-working days, as `YYYY-MM-DD` or `Date`. This is where state and\n * municipal holidays go: they are **not** in the built-in table and never will\n * be — there are 5 570 municipalities, each free to declare its own.\n */\n extra?: readonly DateInput[];\n /**\n * Days of the week that are not worked, `0` = Sunday. Default `[0, 6]`.\n */\n weekend?: readonly number[];\n}\n\n/** Fixed-date national holidays, with the year each became one. */\nconst FIXED_HOLIDAYS: readonly {\n month: number;\n day: number;\n name: string;\n kind: HolidayKind;\n since?: number;\n}[] = [\n { month: 1, day: 1, name: \"Confraternização Universal\", kind: \"national\" },\n { month: 4, day: 21, name: \"Tiradentes\", kind: \"national\" },\n { month: 5, day: 1, name: \"Dia do Trabalho\", kind: \"national\" },\n { month: 9, day: 7, name: \"Independência do Brasil\", kind: \"national\" },\n { month: 10, day: 12, name: \"Nossa Senhora Aparecida\", kind: \"national\" },\n { month: 11, day: 2, name: \"Finados\", kind: \"national\" },\n { month: 11, day: 15, name: \"Proclamação da República\", kind: \"national\" },\n {\n month: 11,\n day: 20,\n name: \"Dia Nacional de Zumbi e da Consciência Negra\",\n kind: \"national\",\n since: 2024,\n },\n { month: 12, day: 25, name: \"Natal\", kind: \"national\" },\n];\n\n/** Easter-relative holidays, as a day offset from Easter Sunday. */\nconst MOVABLE_HOLIDAYS: readonly { offset: number; name: string; kind: HolidayKind }[] = [\n { offset: -48, name: \"Carnaval (segunda-feira)\", kind: \"banking\" },\n { offset: -47, name: \"Carnaval (terça-feira)\", kind: \"banking\" },\n { offset: -2, name: \"Sexta-feira da Paixão\", kind: \"banking\" },\n { offset: 60, name: \"Corpus Christi\", kind: \"banking\" },\n];\n\nconst DEFAULT_KINDS: readonly HolidayKind[] = [\"national\", \"banking\"];\nconst DEFAULT_WEEKEND: readonly number[] = [0, 6];\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * How far a walk may go before it is treated as a bug rather than a long holiday.\n *\n * A real calendar never has more than a handful of consecutive non-working days,\n * so hitting this means `extra` or `weekend` marked every day off, and looping\n * forever is worse than an error.\n */\nconst MAX_WALK_DAYS = 400;\n\n/** `YYYY-MM-DD` from a local-calendar date. */\nfunction toIso(year: number, month: number, day: number): string {\n return `${String(year).padStart(4, \"0\")}-${String(month).padStart(2, \"0\")}-${String(day).padStart(2, \"0\")}`;\n}\n\n/**\n * Local midnight for any accepted input.\n *\n * Everything here works on local calendar components, never on UTC: `new Date(y,\n * m, d)` and `getFullYear()/getMonth()/getDate()`. Going through `toISOString()`\n * would shift the day for every viewer east of Greenwich, and \"is today a\n * holiday\" is a question about the viewer's calendar.\n *\n * @throws {RangeError} When a string is not `YYYY-MM-DD` or a `Date` is invalid.\n */\nfunction toLocalDate(input: DateInput): Date {\n if (typeof input === \"string\") {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(input.trim());\n if (match === null) {\n throw new RangeError(`Expected a YYYY-MM-DD date, got ${JSON.stringify(input)}.`);\n }\n return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n }\n if (Number.isNaN(input.getTime())) throw new RangeError(\"Received an Invalid Date.\");\n return new Date(input.getFullYear(), input.getMonth(), input.getDate());\n}\n\n/** `YYYY-MM-DD` for any accepted input. */\nfunction isoOf(input: DateInput): string {\n const date = toLocalDate(input);\n return toIso(date.getFullYear(), date.getMonth() + 1, date.getDate());\n}\n\n/**\n * Easter Sunday in the Gregorian calendar.\n *\n * The anonymous Gregorian computus (Meeus/Jones/Butcher): pure integer\n * arithmetic over the year, no tables and no dependency. It is exact for every\n * Gregorian year, which is why the four movable Brazilian holidays are derived\n * from it rather than listed.\n *\n * @param year - Gregorian year.\n * @returns Local midnight of Easter Sunday.\n *\n * @example\n * easterSunday(2026); // 2026-04-05\n */\nexport function easterSunday(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n return new Date(year, month - 1, day);\n}\n\n/**\n * Every national non-working day in a year, ordered by date.\n *\n * **What is here:** the nine feriados nacionais in federal law (Lei 662/1949 as\n * amended by Lei 10.607/2002, Lei 6.802/1980 for 12 October, and Lei 14.759/2023\n * for 20 November, which is why that one only appears from 2024), plus the four\n * movable days the national financial system observes.\n *\n * **What is deliberately not here**, and will not be:\n *\n * - **State and municipal holidays.** A data magna varies by state and each of the\n * 5 570 municipalities may declare its own, including up to four religious\n * days. No table can be both complete and current; pass them through\n * `options.extra`.\n * - **Ponto facultativo.** A federal decree that lets public servants off is not a\n * holiday and binds nobody else, so it changes no deadline.\n * - **Pre-2002 history.** The table encodes the law as it stands today. Asking for\n * 1998 returns today's set shifted to 1998, not what was in force then.\n *\n * Carnaval, Sexta-feira da Paixão and Corpus Christi are the interesting case:\n * none of them is a feriado nacional in federal law, yet CMN Resolução 4.880/2020\n * closes the banks on all four days, so a payment cannot settle. They are returned\n * with `kind: \"banking\"` — counted by default, and excluded by passing\n * `kinds: [\"national\"]`.\n *\n * @param year - Gregorian year.\n * @returns The holidays of that year, ascending by date.\n *\n * @example\n * holidaysFor(2026).filter((holiday) => holiday.kind === \"national\").length; // 9\n */\nexport function holidaysFor(year: number): Holiday[] {\n const holidays: Holiday[] = FIXED_HOLIDAYS.filter(\n (entry) => entry.since === undefined || year >= entry.since,\n ).map((entry) => ({\n date: toIso(year, entry.month, entry.day),\n name: entry.name,\n kind: entry.kind,\n movable: false,\n }));\n\n const easter = easterSunday(year);\n for (const entry of MOVABLE_HOLIDAYS) {\n const date = new Date(easter.getTime() + entry.offset * MS_PER_DAY);\n holidays.push({\n date: toIso(date.getFullYear(), date.getMonth() + 1, date.getDate()),\n name: entry.name,\n kind: entry.kind,\n movable: true,\n });\n }\n\n return holidays.sort((left, right) => left.date.localeCompare(right.date));\n}\n\n/** The set of `YYYY-MM-DD` strings that count as off for a given year. */\nfunction offDays(year: number, options: BusinessDayOptions): Set<string> {\n const kinds = options.kinds ?? DEFAULT_KINDS;\n const days = new Set(\n holidaysFor(year)\n .filter((holiday) => kinds.includes(holiday.kind))\n .map((holiday) => holiday.date),\n );\n for (const entry of options.extra ?? []) days.add(isoOf(entry));\n return days;\n}\n\n/**\n * Whether a date is a national holiday.\n *\n * @param date - `YYYY-MM-DD` or a `Date`. Only the local calendar day matters.\n * @param options - See {@link BusinessDayOptions}. `weekend` is ignored here — a\n * Sunday is not a holiday, it is a Sunday.\n * @returns `true` when the day is in the table (or in `extra`).\n * @throws {RangeError} On a malformed string or an Invalid Date.\n *\n * @example\n * isHoliday(\"2026-11-20\"); // true\n * isHoliday(\"2026-02-17\"); // true — Carnaval\n * isHoliday(\"2026-02-17\", { kinds: [\"national\"] }); // false\n */\nexport function isHoliday(date: DateInput, options: BusinessDayOptions = {}): boolean {\n const iso = isoOf(date);\n return offDays(Number(iso.slice(0, 4)), options).has(iso);\n}\n\n/**\n * Whether a date is a working day: not a weekend, not a holiday.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param options - See {@link BusinessDayOptions}.\n * @returns `true` when work happens on that day.\n * @throws {RangeError} On a malformed string or an Invalid Date.\n *\n * @example\n * isBusinessDay(\"2026-04-03\"); // false — Sexta-feira da Paixão\n */\nexport function isBusinessDay(date: DateInput, options: BusinessDayOptions = {}): boolean {\n const local = toLocalDate(date);\n const weekend = options.weekend ?? DEFAULT_WEEKEND;\n if (weekend.includes(local.getDay())) return false;\n return !isHoliday(local, options);\n}\n\n/**\n * The first working day strictly after a date.\n *\n * Strictly after: calling it on a Wednesday returns Thursday, never the same\n * Wednesday. That is what a \"prazo de D+1\" means, and it makes the function safe\n * to call in a loop.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param options - See {@link BusinessDayOptions}.\n * @returns Local midnight of the next working day.\n * @throws {RangeError} On a malformed input, or when `options` marked so many days\n * off that no working day exists within {@link MAX_WALK_DAYS}.\n *\n * @example\n * nextBusinessDay(\"2026-12-24\"); // 2026-12-28 — the 25th is Natal, then a weekend\n */\nexport function nextBusinessDay(date: DateInput, options: BusinessDayOptions = {}): Date {\n const cursor = toLocalDate(date);\n for (let step = 0; step < MAX_WALK_DAYS; step += 1) {\n cursor.setDate(cursor.getDate() + 1);\n if (isBusinessDay(cursor, options)) return cursor;\n }\n throw new RangeError(\n `No business day within ${MAX_WALK_DAYS} days of ${isoOf(date)} — check \\`weekend\\` and \\`extra\\`.`,\n );\n}\n\n/**\n * Move a date by a number of working days.\n *\n * `n` days forward means `n` calls to {@link nextBusinessDay}; a negative `n`\n * walks backwards the same way. `n === 0` returns the day unchanged **even when it\n * is not a working day** — snapping silently would hide the case a caller most\n * needs to see.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param days - Working days to add. May be negative.\n * @param options - See {@link BusinessDayOptions}.\n * @returns Local midnight of the resulting day.\n * @throws {RangeError} On a malformed input, or on a calendar with no working days.\n *\n * @example\n * addBusinessDays(\"2026-04-01\", 2); // 2026-04-06 — skips Good Friday and the weekend\n */\nexport function addBusinessDays(\n date: DateInput,\n days: number,\n options: BusinessDayOptions = {},\n): Date {\n const cursor = toLocalDate(date);\n const direction = days < 0 ? -1 : 1;\n for (let moved = 0; moved < Math.abs(days); moved += 1) {\n let landed = false;\n for (let step = 0; step < MAX_WALK_DAYS && !landed; step += 1) {\n cursor.setDate(cursor.getDate() + direction);\n landed = isBusinessDay(cursor, options);\n }\n if (!landed) {\n throw new RangeError(\n `No business day within ${MAX_WALK_DAYS} days while walking from ${isoOf(date)} — ` +\n \"check `weekend` and `extra`.\",\n );\n }\n }\n return cursor;\n}\n"],"mappings":"AAgDA,IAAMA,EAMA,CACF,CAAE,MAAO,EAAG,IAAK,EAAG,KAAM,6BAA8B,KAAM,UAAW,EACzE,CAAE,MAAO,EAAG,IAAK,GAAI,KAAM,aAAc,KAAM,UAAW,EAC1D,CAAE,MAAO,EAAG,IAAK,EAAG,KAAM,kBAAmB,KAAM,UAAW,EAC9D,CAAE,MAAO,EAAG,IAAK,EAAG,KAAM,0BAA2B,KAAM,UAAW,EACtE,CAAE,MAAO,GAAI,IAAK,GAAI,KAAM,0BAA2B,KAAM,UAAW,EACxE,CAAE,MAAO,GAAI,IAAK,EAAG,KAAM,UAAW,KAAM,UAAW,EACvD,CAAE,MAAO,GAAI,IAAK,GAAI,KAAM,2BAA4B,KAAM,UAAW,EACzE,C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,IAAMF,EAASlC,EAAYI,CAAI,EACzBiC,EAAYV,EAAO,EAAI,GAAK,EAClC,IAAK,IAAIW,EAAQ,EAAGA,EAAQ,KAAK,IAAIX,CAAI,EAAG,GAAS,EAAG,CACpD,IAAIY,EAAS,GACb,IAAK,IAAIJ,EAAO,EAAGA,EAAOxC,GAAiB,CAAC4C,EAAQ,GAAQ,EACxDL,EAAO,QAAQA,EAAO,QAAQ,EAAIG,CAAS,EAC3C,EAASN,EAAcG,EAAQR,CAAO,EAE1C,GAAI,CAACa,EACD,MAAU,WACN,0BAA0B5C,EAAc,2BAA2BQ,EAAMC,CAAI,EAAE,oCAEnF,CAER,CACA,OAAO8B,CACX,C"}
|
package/dist/br/holidays.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"holidays.js","names":[],"sources":["../../src/br/holidays.ts"],"sourcesContent":["/**\n * How binding a non-working day is.\n *\n * - `\"national\"` — a feriado nacional in federal law. Nobody works, and a\n * deadline that lands here moves.\n * - `\"banking\"` — not a statutory holiday, but a day the national financial\n * system does not operate: Carnaval (Monday and Tuesday), Sexta-feira da\n * Paixão and Corpus Christi. Bank branches are shut and compensation does not\n * run, so a boleto or a TED dated here settles later — but an employer may\n * legally require work, which is why the two kinds are separate.\n */\nexport type HolidayKind = \"national\" | \"banking\";\n\n/** One non-working day in a given year. */\nexport interface Holiday {\n /** `YYYY-MM-DD` in the local calendar. */\n date: string;\n /** Portuguese name, as the law or the Bacen calendar spells it. */\n name: string;\n kind: HolidayKind;\n /** `true` when the date is derived from Easter rather than fixed. */\n movable: boolean;\n}\n\n/** Anything these helpers accept as a day. */\nexport type DateInput = Date | string;\n\n/** Options shared by the calendar helpers. */\nexport interface BusinessDayOptions {\n /**\n * Which kinds count as non-working. Default `[\"national\", \"banking\"]`, i.e.\n * the Bacen calendar — the right default for anything money moves through.\n * Pass `[\"national\"]` for a labour-law calendar.\n */\n kinds?: readonly HolidayKind[];\n /**\n * Extra non-working days, as `YYYY-MM-DD` or `Date`. This is where state and\n * municipal holidays go: they are **not** in the built-in table and never will\n * be — there are 5 570 municipalities, each free to declare its own.\n */\n extra?: readonly DateInput[];\n /**\n * Days of the week that are not worked, `0` = Sunday. Default `[0, 6]`.\n */\n weekend?: readonly number[];\n}\n\n/** Fixed-date national holidays, with the year each became one. */\nconst FIXED_HOLIDAYS: readonly {\n month: number;\n day: number;\n name: string;\n kind: HolidayKind;\n since?: number;\n}[] = [\n { month: 1, day: 1, name: \"Confraternização Universal\", kind: \"national\" },\n { month: 4, day: 21, name: \"Tiradentes\", kind: \"national\" },\n { month: 5, day: 1, name: \"Dia do Trabalho\", kind: \"national\" },\n { month: 9, day: 7, name: \"Independência do Brasil\", kind: \"national\" },\n { month: 10, day: 12, name: \"Nossa Senhora Aparecida\", kind: \"national\" },\n { month: 11, day: 2, name: \"Finados\", kind: \"national\" },\n { month: 11, day: 15, name: \"Proclamação da República\", kind: \"national\" },\n {\n month: 11,\n day: 20,\n name: \"Dia Nacional de Zumbi e da Consciência Negra\",\n kind: \"national\",\n since: 2024,\n },\n { month: 12, day: 25, name: \"Natal\", kind: \"national\" },\n];\n\n/** Easter-relative holidays, as a day offset from Easter Sunday. */\nconst MOVABLE_HOLIDAYS: readonly { offset: number; name: string; kind: HolidayKind }[] = [\n { offset: -48, name: \"Carnaval (segunda-feira)\", kind: \"banking\" },\n { offset: -47, name: \"Carnaval (terça-feira)\", kind: \"banking\" },\n { offset: -2, name: \"Sexta-feira da Paixão\", kind: \"banking\" },\n { offset: 60, name: \"Corpus Christi\", kind: \"banking\" },\n];\n\nconst DEFAULT_KINDS: readonly HolidayKind[] = [\"national\", \"banking\"];\nconst DEFAULT_WEEKEND: readonly number[] = [0, 6];\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * How far a walk may go before it is treated as a bug rather than a long holiday.\n *\n * A real calendar never has more than a handful of consecutive non-working days,\n * so hitting this means `extra` or `weekend` marked every day off, and looping\n * forever is worse than an error.\n */\nconst MAX_WALK_DAYS = 400;\n\n/** `YYYY-MM-DD` from a local-calendar date. */\nfunction toIso(year: number, month: number, day: number): string {\n return `${String(year).padStart(4, \"0\")}-${String(month).padStart(2, \"0\")}-${String(day).padStart(2, \"0\")}`;\n}\n\n/**\n * Local midnight for any accepted input.\n *\n * Everything here works on local calendar components, never on UTC: `new Date(y,\n * m, d)` and `getFullYear()/getMonth()/getDate()`. Going through `toISOString()`\n * would shift the day for every viewer east of Greenwich, and \"is today a\n * holiday\" is a question about the viewer's calendar.\n *\n * @throws {RangeError} When a string is not `YYYY-MM-DD` or a `Date` is invalid.\n */\nfunction toLocalDate(input: DateInput): Date {\n if (typeof input === \"string\") {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(input.trim());\n if (match === null) {\n throw new RangeError(`Expected a YYYY-MM-DD date, got ${JSON.stringify(input)}.`);\n }\n return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n }\n if (Number.isNaN(input.getTime())) throw new RangeError(\"Received an Invalid Date.\");\n return new Date(input.getFullYear(), input.getMonth(), input.getDate());\n}\n\n/** `YYYY-MM-DD` for any accepted input. */\nfunction isoOf(input: DateInput): string {\n const date = toLocalDate(input);\n return toIso(date.getFullYear(), date.getMonth() + 1, date.getDate());\n}\n\n/**\n * Easter Sunday in the Gregorian calendar.\n *\n * The anonymous Gregorian computus (Meeus/Jones/Butcher): pure integer\n * arithmetic over the year, no tables and no dependency. It is exact for every\n * Gregorian year, which is why the four movable Brazilian holidays are derived\n * from it rather than listed.\n *\n * @param year - Gregorian year.\n * @returns Local midnight of Easter Sunday.\n *\n * @example\n * easterSunday(2026); // 2026-04-05\n */\nexport function easterSunday(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n return new Date(year, month - 1, day);\n}\n\n/**\n * Every national non-working day in a year, ordered by date.\n *\n * **What is here:** the nine feriados nacionais in federal law (Lei 662/1949 as\n * amended by Lei 10.607/2002, Lei 6.802/1980 for 12 October, and Lei 14.759/2023\n * for 20 November, which is why that one only appears from 2024), plus the four\n * movable days the national financial system observes.\n *\n * **What is deliberately not here**, and will not be:\n *\n * - **State and municipal holidays.** A data magna varies by state and each of the\n * 5 570 municipalities may declare its own, including up to four religious\n * days. No table can be both complete and current; pass them through\n * `options.extra`.\n * - **Ponto facultativo.** A federal decree that lets public servants off is not a\n * holiday and binds nobody else, so it changes no deadline.\n * - **Pre-2002 history.** The table encodes the law as it stands today. Asking for\n * 1998 returns today's set shifted to 1998, not what was in force then.\n *\n * Carnaval, Sexta-feira da Paixão and Corpus Christi are the interesting case:\n * none of them is a feriado nacional in federal law, yet CMN Resolução 4.880/2020\n * closes the banks on all four days, so a payment cannot settle. They are returned\n * with `kind: \"banking\"` — counted by default, and excluded by passing\n * `kinds: [\"national\"]`.\n *\n * @param year - Gregorian year.\n * @returns The holidays of that year, ascending by date.\n *\n * @example\n * holidaysFor(2026).filter((holiday) => holiday.kind === \"national\").length; // 9\n */\nexport function holidaysFor(year: number): Holiday[] {\n const holidays: Holiday[] = FIXED_HOLIDAYS.filter(\n (entry) => entry.since === undefined || year >= entry.since,\n ).map((entry) => ({\n date: toIso(year, entry.month, entry.day),\n name: entry.name,\n kind: entry.kind,\n movable: false,\n }));\n\n const easter = easterSunday(year);\n for (const entry of MOVABLE_HOLIDAYS) {\n const date = new Date(easter.getTime() + entry.offset * MS_PER_DAY);\n holidays.push({\n date: toIso(date.getFullYear(), date.getMonth() + 1, date.getDate()),\n name: entry.name,\n kind: entry.kind,\n movable: true,\n });\n }\n\n return holidays.sort((left, right) => left.date.localeCompare(right.date));\n}\n\n/** The set of `YYYY-MM-DD` strings that count as off for a given year. */\nfunction offDays(year: number, options: BusinessDayOptions): Set<string> {\n const kinds = options.kinds ?? DEFAULT_KINDS;\n const days = new Set(\n holidaysFor(year)\n .filter((holiday) => kinds.includes(holiday.kind))\n .map((holiday) => holiday.date),\n );\n for (const entry of options.extra ?? []) days.add(isoOf(entry));\n return days;\n}\n\n/**\n * Whether a date is a national holiday.\n *\n * @param date - `YYYY-MM-DD` or a `Date`. Only the local calendar day matters.\n * @param options - See {@link BusinessDayOptions}. `weekend` is ignored here — a\n * Sunday is not a holiday, it is a Sunday.\n * @returns `true` when the day is in the table (or in `extra`).\n * @throws {RangeError} On a malformed string or an Invalid Date.\n *\n * @example\n * isHoliday(\"2026-11-20\"); // true\n * isHoliday(\"2026-02-17\"); // true — Carnaval\n * isHoliday(\"2026-02-17\", { kinds: [\"national\"] }); // false\n */\nexport function isHoliday(date: DateInput, options: BusinessDayOptions = {}): boolean {\n const iso = isoOf(date);\n return offDays(Number(iso.slice(0, 4)), options).has(iso);\n}\n\n/**\n * Whether a date is a working day: not a weekend, not a holiday.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param options - See {@link BusinessDayOptions}.\n * @returns `true` when work happens on that day.\n * @throws {RangeError} On a malformed string or an Invalid Date.\n *\n * @example\n * isBusinessDay(\"2026-04-03\"); // false — Sexta-feira da Paixão\n */\nexport function isBusinessDay(date: DateInput, options: BusinessDayOptions = {}): boolean {\n const local = toLocalDate(date);\n const weekend = options.weekend ?? DEFAULT_WEEKEND;\n if (weekend.includes(local.getDay())) return false;\n return !isHoliday(local, options);\n}\n\n/**\n * The first working day strictly after a date.\n *\n * Strictly after: calling it on a Wednesday returns Thursday, never the same\n * Wednesday. That is what a \"prazo de D+1\" means, and it makes the function safe\n * to call in a loop.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param options - See {@link BusinessDayOptions}.\n * @returns Local midnight of the next working day.\n * @throws {RangeError} On a malformed input, or when `options` marked so many days\n * off that no working day exists within {@link MAX_WALK_DAYS}.\n *\n * @example\n * nextBusinessDay(\"2026-12-24\"); // 2026-12-28 — the 25th is Natal, then a weekend\n */\nexport function nextBusinessDay(date: DateInput, options: BusinessDayOptions = {}): Date {\n const cursor = toLocalDate(date);\n for (let step = 0; step < MAX_WALK_DAYS; step += 1) {\n cursor.setDate(cursor.getDate() + 1);\n if (isBusinessDay(cursor, options)) return cursor;\n }\n throw new RangeError(\n `No business day within ${MAX_WALK_DAYS} days of ${isoOf(date)} — check \\`weekend\\` and \\`extra\\`.`,\n );\n}\n\n/**\n * Move a date by a number of working days.\n *\n * `n` days forward means `n` calls to {@link nextBusinessDay}; a negative `n`\n * walks backwards the same way. `n === 0` returns the day unchanged **even when it\n * is not a working day** — snapping silently would hide the case a caller most\n * needs to see.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param days - Working days to add. May be negative.\n * @param options - See {@link BusinessDayOptions}.\n * @returns Local midnight of the resulting day.\n * @throws {RangeError} On a malformed input, or on a calendar with no working days.\n *\n * @example\n * addBusinessDays(\"2026-04-01\", 2); // 2026-04-06 — skips Good Friday and the weekend\n */\nexport function addBusinessDays(\n date: DateInput,\n days: number,\n options: BusinessDayOptions = {},\n): Date {\n const cursor = toLocalDate(date);\n const direction = days < 0 ? -1 : 1;\n for (let moved = 0; moved < Math.abs(days); moved += 1) {\n let landed = false;\n for (let step = 0; step < MAX_WALK_DAYS && !landed; step += 1) {\n cursor.setDate(cursor.getDate() + direction);\n landed = isBusinessDay(cursor, options);\n }\n if (!landed) {\n throw new RangeError(\n `No business day within ${MAX_WALK_DAYS} days while walking from ${isoOf(date)} — ` +\n \"check `weekend` and `extra`.\",\n );\n }\n }\n return cursor;\n}\n"],"mappings":";AAgDA,IAAM,IAMA;CACF;EAAE,OAAO;EAAG,KAAK;EAAG,MAAM;EAA8B,MAAM;CAAW;CACzE;EAAE,OAAO;EAAG,KAAK;EAAI,MAAM;EA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WACN,0BAA0B,EAAc,WAAW,EAAM,CAAI,EAAE,oCACnE;AACJ;AAmBA,SAAgB,EACZ,GACA,GACA,IAA8B,CAAC,GAC3B;CACJ,IAAM,IAAS,EAAY,CAAI,GACzB,IAAY,IAAO,IAAI,KAAK;CAClC,KAAK,IAAI,IAAQ,GAAG,IAAQ,KAAK,IAAI,CAAI,GAAG,KAAS,GAAG;EACpD,IAAI,IAAS;EACb,KAAK,IAAI,IAAO,GAAG,IAAO,KAAiB,CAAC,GAAQ,KAAQ,GAExD,AADA,EAAO,QAAQ,EAAO,QAAQ,IAAI,CAAS,GAC3C,IAAS,EAAc,GAAQ,CAAO;EAE1C,IAAI,CAAC,GACD,MAAU,WACN,0BAA0B,EAAc,2BAA2B,EAAM,CAAI,EAAE,oCAEnF;CAER;CACA,OAAO;AACX"}
|
|
1
|
+
{"version":3,"file":"holidays.js","names":["FIXED_HOLIDAYS","MOVABLE_HOLIDAYS","DEFAULT_KINDS","DEFAULT_WEEKEND","MS_PER_DAY","MAX_WALK_DAYS","toIso","year","month","day","toLocalDate","input","match","isoOf","date","easterSunday","a","b","c","d","e","f","g","h","i","k","l","m","holidaysFor","holidays","entry","easter","left","right","offDays","kinds","options","days","holiday","isHoliday","iso","isBusinessDay","local","nextBusinessDay","cursor","step","addBusinessDays","direction","moved","landed"],"sources":["../../src/br/holidays.ts"],"sourcesContent":["/**\n * How binding a non-working day is.\n *\n * - `\"national\"` — a feriado nacional in federal law. Nobody works, and a\n * deadline that lands here moves.\n * - `\"banking\"` — not a statutory holiday, but a day the national financial\n * system does not operate: Carnaval (Monday and Tuesday), Sexta-feira da\n * Paixão and Corpus Christi. Bank branches are shut and compensation does not\n * run, so a boleto or a TED dated here settles later — but an employer may\n * legally require work, which is why the two kinds are separate.\n */\nexport type HolidayKind = \"national\" | \"banking\";\n\n/** One non-working day in a given year. */\nexport interface Holiday {\n /** `YYYY-MM-DD` in the local calendar. */\n date: string;\n /** Portuguese name, as the law or the Bacen calendar spells it. */\n name: string;\n kind: HolidayKind;\n /** `true` when the date is derived from Easter rather than fixed. */\n movable: boolean;\n}\n\n/** Anything these helpers accept as a day. */\nexport type DateInput = Date | string;\n\n/** Options shared by the calendar helpers. */\nexport interface BusinessDayOptions {\n /**\n * Which kinds count as non-working. Default `[\"national\", \"banking\"]`, i.e.\n * the Bacen calendar — the right default for anything money moves through.\n * Pass `[\"national\"]` for a labour-law calendar.\n */\n kinds?: readonly HolidayKind[];\n /**\n * Extra non-working days, as `YYYY-MM-DD` or `Date`. This is where state and\n * municipal holidays go: they are **not** in the built-in table and never will\n * be — there are 5 570 municipalities, each free to declare its own.\n */\n extra?: readonly DateInput[];\n /**\n * Days of the week that are not worked, `0` = Sunday. Default `[0, 6]`.\n */\n weekend?: readonly number[];\n}\n\n/** Fixed-date national holidays, with the year each became one. */\nconst FIXED_HOLIDAYS: readonly {\n month: number;\n day: number;\n name: string;\n kind: HolidayKind;\n since?: number;\n}[] = [\n { month: 1, day: 1, name: \"Confraternização Universal\", kind: \"national\" },\n { month: 4, day: 21, name: \"Tiradentes\", kind: \"national\" },\n { month: 5, day: 1, name: \"Dia do Trabalho\", kind: \"national\" },\n { month: 9, day: 7, name: \"Independência do Brasil\", kind: \"national\" },\n { month: 10, day: 12, name: \"Nossa Senhora Aparecida\", kind: \"national\" },\n { month: 11, day: 2, name: \"Finados\", kind: \"national\" },\n { month: 11, day: 15, name: \"Proclamação da República\", kind: \"national\" },\n {\n month: 11,\n day: 20,\n name: \"Dia Nacional de Zumbi e da Consciência Negra\",\n kind: \"national\",\n since: 2024,\n },\n { month: 12, day: 25, name: \"Natal\", kind: \"national\" },\n];\n\n/** Easter-relative holidays, as a day offset from Easter Sunday. */\nconst MOVABLE_HOLIDAYS: readonly { offset: number; name: string; kind: HolidayKind }[] = [\n { offset: -48, name: \"Carnaval (segunda-feira)\", kind: \"banking\" },\n { offset: -47, name: \"Carnaval (terça-feira)\", kind: \"banking\" },\n { offset: -2, name: \"Sexta-feira da Paixão\", kind: \"banking\" },\n { offset: 60, name: \"Corpus Christi\", kind: \"banking\" },\n];\n\nconst DEFAULT_KINDS: readonly HolidayKind[] = [\"national\", \"banking\"];\nconst DEFAULT_WEEKEND: readonly number[] = [0, 6];\nconst MS_PER_DAY = 86_400_000;\n\n/**\n * How far a walk may go before it is treated as a bug rather than a long holiday.\n *\n * A real calendar never has more than a handful of consecutive non-working days,\n * so hitting this means `extra` or `weekend` marked every day off, and looping\n * forever is worse than an error.\n */\nconst MAX_WALK_DAYS = 400;\n\n/** `YYYY-MM-DD` from a local-calendar date. */\nfunction toIso(year: number, month: number, day: number): string {\n return `${String(year).padStart(4, \"0\")}-${String(month).padStart(2, \"0\")}-${String(day).padStart(2, \"0\")}`;\n}\n\n/**\n * Local midnight for any accepted input.\n *\n * Everything here works on local calendar components, never on UTC: `new Date(y,\n * m, d)` and `getFullYear()/getMonth()/getDate()`. Going through `toISOString()`\n * would shift the day for every viewer east of Greenwich, and \"is today a\n * holiday\" is a question about the viewer's calendar.\n *\n * @throws {RangeError} When a string is not `YYYY-MM-DD` or a `Date` is invalid.\n */\nfunction toLocalDate(input: DateInput): Date {\n if (typeof input === \"string\") {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(input.trim());\n if (match === null) {\n throw new RangeError(`Expected a YYYY-MM-DD date, got ${JSON.stringify(input)}.`);\n }\n return new Date(Number(match[1]), Number(match[2]) - 1, Number(match[3]));\n }\n if (Number.isNaN(input.getTime())) throw new RangeError(\"Received an Invalid Date.\");\n return new Date(input.getFullYear(), input.getMonth(), input.getDate());\n}\n\n/** `YYYY-MM-DD` for any accepted input. */\nfunction isoOf(input: DateInput): string {\n const date = toLocalDate(input);\n return toIso(date.getFullYear(), date.getMonth() + 1, date.getDate());\n}\n\n/**\n * Easter Sunday in the Gregorian calendar.\n *\n * The anonymous Gregorian computus (Meeus/Jones/Butcher): pure integer\n * arithmetic over the year, no tables and no dependency. It is exact for every\n * Gregorian year, which is why the four movable Brazilian holidays are derived\n * from it rather than listed.\n *\n * @param year - Gregorian year.\n * @returns Local midnight of Easter Sunday.\n *\n * @example\n * easterSunday(2026); // 2026-04-05\n */\nexport function easterSunday(year: number): Date {\n const a = year % 19;\n const b = Math.floor(year / 100);\n const c = year % 100;\n const d = Math.floor(b / 4);\n const e = b % 4;\n const f = Math.floor((b + 8) / 25);\n const g = Math.floor((b - f + 1) / 3);\n const h = (19 * a + b - d - g + 15) % 30;\n const i = Math.floor(c / 4);\n const k = c % 4;\n const l = (32 + 2 * e + 2 * i - h - k) % 7;\n const m = Math.floor((a + 11 * h + 22 * l) / 451);\n const month = Math.floor((h + l - 7 * m + 114) / 31);\n const day = ((h + l - 7 * m + 114) % 31) + 1;\n return new Date(year, month - 1, day);\n}\n\n/**\n * Every national non-working day in a year, ordered by date.\n *\n * **What is here:** the nine feriados nacionais in federal law (Lei 662/1949 as\n * amended by Lei 10.607/2002, Lei 6.802/1980 for 12 October, and Lei 14.759/2023\n * for 20 November, which is why that one only appears from 2024), plus the four\n * movable days the national financial system observes.\n *\n * **What is deliberately not here**, and will not be:\n *\n * - **State and municipal holidays.** A data magna varies by state and each of the\n * 5 570 municipalities may declare its own, including up to four religious\n * days. No table can be both complete and current; pass them through\n * `options.extra`.\n * - **Ponto facultativo.** A federal decree that lets public servants off is not a\n * holiday and binds nobody else, so it changes no deadline.\n * - **Pre-2002 history.** The table encodes the law as it stands today. Asking for\n * 1998 returns today's set shifted to 1998, not what was in force then.\n *\n * Carnaval, Sexta-feira da Paixão and Corpus Christi are the interesting case:\n * none of them is a feriado nacional in federal law, yet CMN Resolução 4.880/2020\n * closes the banks on all four days, so a payment cannot settle. They are returned\n * with `kind: \"banking\"` — counted by default, and excluded by passing\n * `kinds: [\"national\"]`.\n *\n * @param year - Gregorian year.\n * @returns The holidays of that year, ascending by date.\n *\n * @example\n * holidaysFor(2026).filter((holiday) => holiday.kind === \"national\").length; // 9\n */\nexport function holidaysFor(year: number): Holiday[] {\n const holidays: Holiday[] = FIXED_HOLIDAYS.filter(\n (entry) => entry.since === undefined || year >= entry.since,\n ).map((entry) => ({\n date: toIso(year, entry.month, entry.day),\n name: entry.name,\n kind: entry.kind,\n movable: false,\n }));\n\n const easter = easterSunday(year);\n for (const entry of MOVABLE_HOLIDAYS) {\n const date = new Date(easter.getTime() + entry.offset * MS_PER_DAY);\n holidays.push({\n date: toIso(date.getFullYear(), date.getMonth() + 1, date.getDate()),\n name: entry.name,\n kind: entry.kind,\n movable: true,\n });\n }\n\n return holidays.sort((left, right) => left.date.localeCompare(right.date));\n}\n\n/** The set of `YYYY-MM-DD` strings that count as off for a given year. */\nfunction offDays(year: number, options: BusinessDayOptions): Set<string> {\n const kinds = options.kinds ?? DEFAULT_KINDS;\n const days = new Set(\n holidaysFor(year)\n .filter((holiday) => kinds.includes(holiday.kind))\n .map((holiday) => holiday.date),\n );\n for (const entry of options.extra ?? []) days.add(isoOf(entry));\n return days;\n}\n\n/**\n * Whether a date is a national holiday.\n *\n * @param date - `YYYY-MM-DD` or a `Date`. Only the local calendar day matters.\n * @param options - See {@link BusinessDayOptions}. `weekend` is ignored here — a\n * Sunday is not a holiday, it is a Sunday.\n * @returns `true` when the day is in the table (or in `extra`).\n * @throws {RangeError} On a malformed string or an Invalid Date.\n *\n * @example\n * isHoliday(\"2026-11-20\"); // true\n * isHoliday(\"2026-02-17\"); // true — Carnaval\n * isHoliday(\"2026-02-17\", { kinds: [\"national\"] }); // false\n */\nexport function isHoliday(date: DateInput, options: BusinessDayOptions = {}): boolean {\n const iso = isoOf(date);\n return offDays(Number(iso.slice(0, 4)), options).has(iso);\n}\n\n/**\n * Whether a date is a working day: not a weekend, not a holiday.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param options - See {@link BusinessDayOptions}.\n * @returns `true` when work happens on that day.\n * @throws {RangeError} On a malformed string or an Invalid Date.\n *\n * @example\n * isBusinessDay(\"2026-04-03\"); // false — Sexta-feira da Paixão\n */\nexport function isBusinessDay(date: DateInput, options: BusinessDayOptions = {}): boolean {\n const local = toLocalDate(date);\n const weekend = options.weekend ?? DEFAULT_WEEKEND;\n if (weekend.includes(local.getDay())) return false;\n return !isHoliday(local, options);\n}\n\n/**\n * The first working day strictly after a date.\n *\n * Strictly after: calling it on a Wednesday returns Thursday, never the same\n * Wednesday. That is what a \"prazo de D+1\" means, and it makes the function safe\n * to call in a loop.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param options - See {@link BusinessDayOptions}.\n * @returns Local midnight of the next working day.\n * @throws {RangeError} On a malformed input, or when `options` marked so many days\n * off that no working day exists within {@link MAX_WALK_DAYS}.\n *\n * @example\n * nextBusinessDay(\"2026-12-24\"); // 2026-12-28 — the 25th is Natal, then a weekend\n */\nexport function nextBusinessDay(date: DateInput, options: BusinessDayOptions = {}): Date {\n const cursor = toLocalDate(date);\n for (let step = 0; step < MAX_WALK_DAYS; step += 1) {\n cursor.setDate(cursor.getDate() + 1);\n if (isBusinessDay(cursor, options)) return cursor;\n }\n throw new RangeError(\n `No business day within ${MAX_WALK_DAYS} days of ${isoOf(date)} — check \\`weekend\\` and \\`extra\\`.`,\n );\n}\n\n/**\n * Move a date by a number of working days.\n *\n * `n` days forward means `n` calls to {@link nextBusinessDay}; a negative `n`\n * walks backwards the same way. `n === 0` returns the day unchanged **even when it\n * is not a working day** — snapping silently would hide the case a caller most\n * needs to see.\n *\n * @param date - `YYYY-MM-DD` or a `Date`.\n * @param days - Working days to add. May be negative.\n * @param options - See {@link BusinessDayOptions}.\n * @returns Local midnight of the resulting day.\n * @throws {RangeError} On a malformed input, or on a calendar with no working days.\n *\n * @example\n * addBusinessDays(\"2026-04-01\", 2); // 2026-04-06 — skips Good Friday and the weekend\n */\nexport function addBusinessDays(\n date: DateInput,\n days: number,\n options: BusinessDayOptions = {},\n): Date {\n const cursor = toLocalDate(date);\n const direction = days < 0 ? -1 : 1;\n for (let moved = 0; moved < Math.abs(days); moved += 1) {\n let landed = false;\n for (let step = 0; step < MAX_WALK_DAYS && !landed; step += 1) {\n cursor.setDate(cursor.getDate() + direction);\n landed = isBusinessDay(cursor, options);\n }\n if (!landed) {\n throw new RangeError(\n `No business day within ${MAX_WALK_DAYS} days while walking from ${isoOf(date)} — ` +\n \"check `weekend` and `extra`.\",\n );\n }\n }\n return cursor;\n}\n"],"mappings":";AAgDA,IAAMA,IAMA;CACF;EAAE,OAAO;EAAG,KAAK;EAAG,MAAM;EAA8B,MAAM;CAAW;CACzE;EAAE,OAAO;EAAG,KAAK;EAAI,MAAM;EAAc,MAAM;CAAW;CAC1D;EAAE,OAAO;EAAG,KAAK;EAAG,MAAM;EAAmB,MAAM;CAAW;CAC9D;EAAE,OAAO;EAAG,KAAK;EAAG,MAAM;EAA2B,MAAM;CAAW;CACtE;EAAE,OAAO;EAAI,KAAK;EAAI,MAAM;EAA2B,MAAM;CAAW;CACxE;EAAE,OAAO;EAAI,KAAK;EAAG,MAAM;EAAW,MAAM;CAAW;CACvD;EAAE,OAAO;EAAI,KAAK;EAAI,MAAM;EAA4B,MAAM;CAAW;CACzE;EACI,OAAO;EACP,KAAK;EACL,MAAM;EACN,MAAM;EACN,OAAO;CACX;CACA;EAAE,OAAO;EAAI,KAAK;EAAI,MAAM;EAAS,MAAM;CAAW;AAC1D,GAGMC,IAAmF;CACrF;EAAE,QAAQ;EAAK,MAAM;EAA4B,MAAM;CAAU;CACjE;EAAE,QAAQ;EAAK,MAAM;EAA0B,MAAM;CAAU;CAC/D;EAAE,QAAQ;EAAI,MAAM;EAAyB,MAAM;CAAU;CAC7D;EAAE,QAAQ;EAAI,MAAM;EAAkB,MAAM;CAAU;AAC1D,GAEMC,IAAwC,CAAC,YAAY,SAAS,GAC9DC,IAAqC,CAAC,GAAG,CAAC,GAC1CC,IAAa,OASbC,IAAgB;AAGtB,SAASC,EAAM,GAAc,GAAe,GAAqB;CAC7D,OAAO,GAAG,OAAOC,CAAI,CAAC,CAAC,SAAS,GAAG,GAAG,EAAE,GAAG,OAAOC,CAAK,CAAC,CAAC,SAAS,GAAG,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AAG,CAAC,CAAC,GAAGJ,CAAO,CAAC,CAAC,IAAII,CAAG;AAC5D;AAaA,SAAgBC,EAAc,GAAiB,IAA8B,CAAC,GAAY;CACtF,IAAMC,IAAQhC,EAAYI,CAAI;CAG9B,OADA,EADgBsB,EAAQ,WAAWjC,EAAA,CACvB,SAASuC,EAAM,OAAO,CAAC,KAC5B,CAACH,EAAUG,GAAON,CAAO;AACpC;AAkBA,SAAgBO,EAAgB,GAAiB,IAA8B,CAAC,GAAS;CACrF,IAAMC,IAASlC,EAAYI,CAAI;CAC/B,KAAK,IAAI+B,IAAO,GAAGA,IAAOxC,GAAe,KAAQ,GAE7C,IADAuC,EAAO,QAAQA,EAAO,QAAQ,IAAI,CAAC,GAC/BH,EAAcG,GAAQR,CAAO,GAAG,OAAOQ;CAE/C,MAAU,WACN,0BAA0BvC,EAAc,WAAWQ,EAAMC,CAAI,EAAE,oCACnE;AACJ;AAmBA,SAAgBgC,EACZ,GACA,GACA,IAA8B,CAAC,GAC3B;CACJ,IAAMF,IAASlC,EAAYI,CAAI,GACzBiC,IAAYV,IAAO,IAAI,KAAK;CAClC,KAAK,IAAIW,IAAQ,GAAGA,IAAQ,KAAK,IAAIX,CAAI,GAAG,KAAS,GAAG;EACpD,IAAIY,IAAS;EACb,KAAK,IAAIJ,IAAO,GAAGA,IAAOxC,KAAiB,CAAC4C,GAAQ,KAAQ,GAExD,AADAL,EAAO,QAAQA,EAAO,QAAQ,IAAIG,CAAS,GAC3C,IAASN,EAAcG,GAAQR,CAAO;EAE1C,IAAI,CAACa,GACD,MAAU,WACN,0BAA0B5C,EAAc,2BAA2BQ,EAAMC,CAAI,EAAE,oCAEnF;CAER;CACA,OAAO8B;AACX"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locations.cjs","names":[],"sources":["../../src/br/locations.ts"],"sourcesContent":["import rawLocations from \"./data/br-locations.json\";\n\n/** The 27 Brazilian federative units (26 states + Federal District). */\nexport type UF =\n | \"AC\"\n | \"AL\"\n | \"AP\"\n | \"AM\"\n | \"BA\"\n | \"CE\"\n | \"DF\"\n | \"ES\"\n | \"GO\"\n | \"MA\"\n | \"MT\"\n | \"MS\"\n | \"MG\"\n | \"PA\"\n | \"PB\"\n | \"PR\"\n | \"PE\"\n | \"PI\"\n | \"RJ\"\n | \"RN\"\n | \"RS\"\n | \"RO\"\n | \"RR\"\n | \"SC\"\n | \"SP\"\n | \"SE\"\n | \"TO\";\n\n/** The five Brazilian macro-regions (IBGE). */\nexport type BrRegion = \"Norte\" | \"Nordeste\" | \"Centro-Oeste\" | \"Sudeste\" | \"Sul\";\n\n/** A municipality, identified by the code that survives its renames. */\nexport interface BrazilMunicipality {\n /** 7-digit IBGE code, e.g. `\"3550308\"`. Stable across a rename. */\n id: string;\n /** Current IBGE name, e.g. `\"São Paulo\"`. */\n name: string;\n}\n\n/**\n * An administrative region of the Federal District.\n *\n * The DF has exactly one municipality — Brasília — and 35 administrative\n * regions inside it. Nobody in the DF writes \"Brasília\" in an address field,\n * so the regions are listed and resolvable; they are not municipalities, and\n * `municipalityId` is what they geocode through.\n */\nexport interface BrazilAdministrativeRegion {\n /** IBGE subdistrict code, e.g. `\"53001080515\"` for Ceilândia. */\n id: string;\n /** IBGE name, e.g. `\"Sudoeste/Octogonal\"`. */\n name: string;\n /** The municipality it belongs to — Brasília (`\"5300108\"`) for all 35. */\n municipalityId: string;\n}\n\n/** A federative unit with its display name and city list. */\nexport interface BrazilState {\n /** Two-letter acronym, e.g. `\"SP\"`. */\n uf: UF;\n /** Full name, e.g. `\"São Paulo\"`. */\n name: string;\n /** Macro-region the state belongs to. */\n region: BrRegion;\n /** Municipality names within the state, alphabetically. */\n cities: string[];\n /** The same municipalities carrying their IBGE codes, same order. */\n municipalities: readonly BrazilMunicipality[];\n /** Administrative regions — 35 for `\"DF\"`, empty everywhere else. */\n administrativeRegions: readonly BrazilAdministrativeRegion[];\n}\n\n/** A `{ value, label }` option, handy for `<Select>` / `<Combobox>`. */\nexport interface Choice {\n value: string;\n label: string;\n}\n\n/** IBGE macro-region of each federative unit. */\nconst REGION_BY_UF: Record<UF, BrRegion> = {\n AC: \"Norte\",\n AP: \"Norte\",\n AM: \"Norte\",\n PA: \"Norte\",\n RO: \"Norte\",\n RR: \"Norte\",\n TO: \"Norte\",\n AL: \"Nordeste\",\n BA: \"Nordeste\",\n CE: \"Nordeste\",\n MA: \"Nordeste\",\n PB: \"Nordeste\",\n PE: \"Nordeste\",\n PI: \"Nordeste\",\n RN: \"Nordeste\",\n SE: \"Nordeste\",\n DF: \"Centro-Oeste\",\n GO: \"Centro-Oeste\",\n MT: \"Centro-Oeste\",\n MS: \"Centro-Oeste\",\n ES: \"Sudeste\",\n MG: \"Sudeste\",\n RJ: \"Sudeste\",\n SP: \"Sudeste\",\n PR: \"Sul\",\n RS: \"Sul\",\n SC: \"Sul\",\n};\n\n/** One `[IBGE code, name]` row as `br-locations.json` stores it. */\ntype RawEntry = [string, string];\n\ninterface RawState {\n uf: string;\n name: string;\n cities: RawEntry[];\n}\n\ninterface RawLocations {\n /**\n * The two IBGE vintages this file was built from: `roster` is the day the\n * municipality list was read, `mesh` the boundary release it was joined to.\n */\n vintage: { roster: string; mesh: string };\n states: RawState[];\n /** Administrative regions keyed by the municipality that contains them. */\n administrativeRegions: Record<string, RawEntry[]>;\n /** Every former name, mapped to the IBGE code that still answers to it. */\n aliases: RawEntry[];\n /** Municipalities the roster lists and the mesh has no geometry for. */\n pendingGeometry: string[];\n}\n\nconst RAW = rawLocations as unknown as RawLocations;\n\n/**\n * Strip a name down to what two spellings of the same place share.\n *\n * Accents, case and apostrophes are exactly what differs between the spelling a\n * user typed, the one an app saved five years ago and the one IBGE publishes\n * today — `\"Sant'Ana do Livramento\"` and `\"Santana do Livramento\"` are the same\n * municipality, and `\"acu\"` should find `\"Açu\"`.\n *\n * @param value - A municipality, region or alias name.\n * @returns The comparable form: lowercase, unaccented, apostrophes dropped.\n */\nfunction foldName(value: string): string {\n return value\n .trim()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/['\\u2019\\u0060]/g, \"\")\n .toLowerCase();\n}\n\n/** The federative unit each IBGE code starts with. */\nconst UF_BY_CODE: Record<string, UF> = {\n \"11\": \"RO\",\n \"12\": \"AC\",\n \"13\": \"AM\",\n \"14\": \"RR\",\n \"15\": \"PA\",\n \"16\": \"AP\",\n \"17\": \"TO\",\n \"21\": \"MA\",\n \"22\": \"PI\",\n \"23\": \"CE\",\n \"24\": \"RN\",\n \"25\": \"PB\",\n \"26\": \"PE\",\n \"27\": \"AL\",\n \"28\": \"SE\",\n \"29\": \"BA\",\n \"31\": \"MG\",\n \"32\": \"ES\",\n \"33\": \"RJ\",\n \"35\": \"SP\",\n \"41\": \"PR\",\n \"42\": \"SC\",\n \"43\": \"RS\",\n \"50\": \"MS\",\n \"51\": \"MT\",\n \"52\": \"GO\",\n \"53\": \"DF\",\n};\n\n/**\n * The municipality an IBGE code belongs to.\n *\n * A municipality code is 7 digits and a subdistrict code extends it with 4 more\n * — `\"53001080515\"` (Ceilândia) is Brasília's `\"5300108\"` plus `\"0515\"` — so the\n * containing municipality is a prefix, not a lookup.\n *\n * @param id - A municipality or subdistrict IBGE code.\n * @returns The 7-digit municipality code.\n */\nfunction municipalityIdOf(id: string): string {\n return id.slice(0, 7);\n}\n\n/** Administrative regions of a municipality, or `[]` when it has none. */\nfunction regionsOf(municipalityId: string): readonly BrazilAdministrativeRegion[] {\n return (RAW.administrativeRegions[municipalityId] ?? []).map(([id, name]) => ({\n id,\n name,\n municipalityId,\n }));\n}\n\n/** Normalized, frozen list of all 27 states (built once at module load). */\nconst STATES: readonly BrazilState[] = RAW.states\n .map((entry) => {\n const uf = entry.uf as UF;\n const municipalities = entry.cities.map(([id, name]) => ({ id, name }));\n return {\n uf,\n name: entry.name,\n region: REGION_BY_UF[uf],\n cities: municipalities.map((m) => m.name),\n municipalities,\n administrativeRegions: municipalities.flatMap((m) => regionsOf(m.id)),\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name, \"pt-BR\"));\n\nconst STATE_BY_UF = new Map<UF, BrazilState>(STATES.map((s) => [s.uf, s]));\n\n/**\n * Every name that resolves to a municipality, folded, keyed by `<UF>:<name>`.\n *\n * Three kinds of name land here and the precedence matters: a current IBGE name\n * wins, then a former name from `aliases`, then an administrative region of the\n * DF. A rename never shadows a live municipality — `Campo Grande` is a live\n * municipality in both MS and RN, and in RN it is also the former name of\n * nothing, so the live entry has to be written last.\n */\nconst ID_BY_FOLDED_NAME = new Map<string, string>();\nfor (const [name, id] of RAW.aliases) {\n const uf = UF_BY_CODE[id.slice(0, 2)];\n if (uf !== undefined) ID_BY_FOLDED_NAME.set(`${uf}:${foldName(name)}`, municipalityIdOf(id));\n}\nfor (const state of STATES) {\n for (const region of state.administrativeRegions) {\n ID_BY_FOLDED_NAME.set(`${state.uf}:${foldName(region.name)}`, region.municipalityId);\n }\n}\nfor (const state of STATES) {\n for (const municipality of state.municipalities) {\n ID_BY_FOLDED_NAME.set(`${state.uf}:${foldName(municipality.name)}`, municipality.id);\n }\n}\n\nconst MUNICIPALITY_BY_ID = new Map<string, BrazilMunicipality>(\n STATES.flatMap((s) => s.municipalities).map((m) => [m.id, m]),\n);\n\n/** All 27 federative units, sorted by name. */\nexport function listStates(): readonly BrazilState[] {\n return STATES;\n}\n\n/** Look up a single state by acronym (case-insensitive). Returns `null` if unknown. */\nexport function getState(uf: string): BrazilState | null {\n const normalized = normalizeUf(uf);\n return normalized ? (STATE_BY_UF.get(normalized) ?? null) : null;\n}\n\n/**\n * City names for a federative unit (case-insensitive acronym). Returns an empty\n * array for an unknown UF — \"no matches\" is a valid result, not an error.\n */\nexport function citiesByUf(uf: string): string[] {\n return getState(uf)?.cities ?? [];\n}\n\n/** States belonging to a macro-region. */\nexport function statesByRegion(region: BrRegion): readonly BrazilState[] {\n return STATES.filter((s) => s.region === region);\n}\n\n/** True when `value` is one of the 27 valid acronyms (case-insensitive). */\nexport function isValidUf(value: string): boolean {\n return normalizeUf(value) !== null;\n}\n\n/**\n * Normalize an acronym to canonical uppercase form, or `null` if it is not a\n * valid UF. `\"sp\"` → `\"SP\"`, `\"xx\"` → `null`.\n */\nexport function normalizeUf(value: string): UF | null {\n const upper = value.trim().toUpperCase();\n return (REGION_BY_UF as Record<string, BrRegion>)[upper] ? (upper as UF) : null;\n}\n\n/** True when `city` exists within `uf` (both case-insensitive). */\nexport function isValidCity(uf: string, city: string): boolean {\n const target = city.trim().toLowerCase();\n return citiesByUf(uf).some((c) => c.toLowerCase() === target);\n}\n\n/** `{ value: uf, label: name }` options for every state, for a `<Select>`. */\nexport function ufChoices(): Choice[] {\n return STATES.map((s) => ({ value: s.uf, label: s.name }));\n}\n\n/** `{ value, label }` options for every city in a UF (value === label). */\nexport function cityChoices(uf: string): Choice[] {\n return citiesByUf(uf).map((c) => ({ value: c, label: c }));\n}\n\n/**\n * Municipalities of a federative unit, each carrying its IBGE code.\n *\n * The code is what a backend wants stored: it survives the renames that keep\n * happening (`Presidente Juscelino` became `Serra Caiada` in 2013) and it is the\n * key every other dataset in this module joins on.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @returns The municipalities, alphabetically. Empty for an unknown UF.\n */\nexport function municipalitiesByUf(uf: string): readonly BrazilMunicipality[] {\n return getState(uf)?.municipalities ?? [];\n}\n\n/**\n * Administrative regions of a federative unit.\n *\n * Only the Federal District has any — 35 of them, inside its single\n * municipality. Every other UF answers `[]`, which is a valid result and not an\n * error.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @returns The regions, alphabetically. Empty outside the DF.\n */\nexport function administrativeRegionsByUf(uf: string): readonly BrazilAdministrativeRegion[] {\n return getState(uf)?.administrativeRegions ?? [];\n}\n\n/**\n * Find the municipality a name refers to, however it was written down.\n *\n * Four kinds of name resolve, which is the point — an address saved years ago\n * has to keep pointing at the same place:\n *\n * 1. The current IBGE name (`\"Serra Caiada\"`).\n * 2. A former name (`\"Presidente Juscelino\"`), from the alias table the\n * generator builds by diffing vintages.\n * 3. A different spelling — accents, case and apostrophes are folded, so\n * `\"sant'ana do livramento\"` finds `\"Sant'Ana do Livramento\"`.\n * 4. An administrative region of the DF (`\"Ceilândia\"`), which resolves to\n * Brasília — the municipality it is part of.\n *\n * A live municipality always wins over a former name, so a name that is current\n * in one UF and historical in another resolves to the live one in each.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @param name - The municipality, region or former name.\n * @returns The municipality, or `null` when nothing in that UF answers to it.\n */\nexport function resolveMunicipality(uf: string, name: string): BrazilMunicipality | null {\n const normalized = normalizeUf(uf);\n if (normalized === null) return null;\n const id = ID_BY_FOLDED_NAME.get(`${normalized}:${foldName(name)}`);\n return id === undefined ? null : (MUNICIPALITY_BY_ID.get(id) ?? null);\n}\n\n/**\n * The IBGE vintages the bundled datasets were built from.\n *\n * `roster` is the day the municipality list was read and `mesh` the boundary\n * release it was joined to. They differ on purpose: IBGE publishes new\n * municipalities before it publishes their boundaries, and the gap is what\n * {@link pendingGeometryIds} enumerates.\n *\n * @returns The two vintages, as they were written into the data file.\n */\nexport function datasetVintage(): { roster: string; mesh: string } {\n return RAW.vintage;\n}\n\n/**\n * Municipalities that exist in the roster and have no boundary yet.\n *\n * One today: Boa Esperança do Norte (MT), installed in 2023, for which IBGE\n * serves no mesh at any endpoint. It is listed and selectable, and it is the one\n * municipality `geocodeMunicipality` cannot place — so a caller that must plot\n * every selection can check this list up front instead of discovering it as an\n * empty result.\n *\n * @returns The IBGE codes, in the order the data file declares them.\n */\nexport function pendingGeometryIds(): readonly string[] {\n return RAW.pendingGeometry;\n}\n"],"mappings":"2CAmFA,IAAM,EAAqC,CACvC,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,eACJ,GAA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CAAC,CAAC,YAAY,EACvC,OAAO,EAAW,CAAE,CAAC,CAAC,KAAM,GAAM,EAAE,YAAY,IAAM,CAAM,CAChE,CAGA,SAAgB,GAAsB,CAClC,OAAO,EAAO,IAAK,IAAO,CAAE,MAAO,EAAE,GAAI,MAAO,EAAE,IAAK,EAAE,CAC7D,CAGA,SAAgB,EAAY,EAAsB,CAC9C,OAAO,EAAW,CAAE,CAAC,CAAC,IAAK,IAAO,CAAE,MAAO,EAAG,MAAO,CAAE,EAAE,CAC7D,CAYA,SAAgB,EAAmB,EAA2C,CAC1E,OAAO,EAAS,CAAE,CAAC,EAAE,gBAAkB,CAAC,CAC5C,CAYA,SAAgB,EAA0B,EAAmD,CACzF,OAAO,EAAS,CAAE,CAAC,EAAE,uBAAyB,CAAC,CACnD,CAuBA,SAAgB,EAAoB,EAAY,EAAyC,CACrF,IAAM,EAAa,EAAY,CAAE,EACjC,GAAI,IAAe,KAAM,OAAO,KAChC,IAAM,EAAK,EAAkB,IAAI,GAAG,EAAW,GAAG,EAAS,CAAI,GAAG,EAClE,OAAO,IAAO,IAAA,GAAY,KAAQ,EAAmB,IAAI,CAAE,GAAK,IACpE,CAYA,SAAgB,GAAmD,CAC/D,OAAO,EAAI,OACf,CAaA,SAAgB,GAAwC,CACpD,OAAO,EAAI,eACf"}
|
|
1
|
+
{"version":3,"file":"locations.cjs","names":["rawLocations","require_br_locations","REGION_BY_UF","RAW","foldName","value","UF_BY_CODE","municipalityIdOf","id","regionsOf","municipalityId","name","STATES","uf","entry","municipalities","m","a","b","STATE_BY_UF","s","ID_BY_FOLDED_NAME","state","region","municipality","MUNICIPALITY_BY_ID","listStates","getState","normalized","normalizeUf","citiesByUf","statesByRegion","isValidUf","upper","isValidCity","target","city","c","ufChoices","cityChoices","municipalitiesByUf","administrativeRegionsByUf","resolveMunicipality","datasetVintage","pendingGeometryIds"],"sources":["../../src/br/locations.ts"],"sourcesContent":["import rawLocations from \"./data/br-locations.json\";\n\n/** The 27 Brazilian federative units (26 states + Federal District). */\nexport type UF =\n | \"AC\"\n | \"AL\"\n | \"AP\"\n | \"AM\"\n | \"BA\"\n | \"CE\"\n | \"DF\"\n | \"ES\"\n | \"GO\"\n | \"MA\"\n | \"MT\"\n | \"MS\"\n | \"MG\"\n | \"PA\"\n | \"PB\"\n | \"PR\"\n | \"PE\"\n | \"PI\"\n | \"RJ\"\n | \"RN\"\n | \"RS\"\n | \"RO\"\n | \"RR\"\n | \"SC\"\n | \"SP\"\n | \"SE\"\n | \"TO\";\n\n/** The five Brazilian macro-regions (IBGE). */\nexport type BrRegion = \"Norte\" | \"Nordeste\" | \"Centro-Oeste\" | \"Sudeste\" | \"Sul\";\n\n/** A municipality, identified by the code that survives its renames. */\nexport interface BrazilMunicipality {\n /** 7-digit IBGE code, e.g. `\"3550308\"`. Stable across a rename. */\n id: string;\n /** Current IBGE name, e.g. `\"São Paulo\"`. */\n name: string;\n}\n\n/**\n * An administrative region of the Federal District.\n *\n * The DF has exactly one municipality — Brasília — and 35 administrative\n * regions inside it. Nobody in the DF writes \"Brasília\" in an address field,\n * so the regions are listed and resolvable; they are not municipalities, and\n * `municipalityId` is what they geocode through.\n */\nexport interface BrazilAdministrativeRegion {\n /** IBGE subdistrict code, e.g. `\"53001080515\"` for Ceilândia. */\n id: string;\n /** IBGE name, e.g. `\"Sudoeste/Octogonal\"`. */\n name: string;\n /** The municipality it belongs to — Brasília (`\"5300108\"`) for all 35. */\n municipalityId: string;\n}\n\n/** A federative unit with its display name and city list. */\nexport interface BrazilState {\n /** Two-letter acronym, e.g. `\"SP\"`. */\n uf: UF;\n /** Full name, e.g. `\"São Paulo\"`. */\n name: string;\n /** Macro-region the state belongs to. */\n region: BrRegion;\n /** Municipality names within the state, alphabetically. */\n cities: string[];\n /** The same municipalities carrying their IBGE codes, same order. */\n municipalities: readonly BrazilMunicipality[];\n /** Administrative regions — 35 for `\"DF\"`, empty everywhere else. */\n administrativeRegions: readonly BrazilAdministrativeRegion[];\n}\n\n/** A `{ value, label }` option, handy for `<Select>` / `<Combobox>`. */\nexport interface Choice {\n value: string;\n label: string;\n}\n\n/** IBGE macro-region of each federative unit. */\nconst REGION_BY_UF: Record<UF, BrRegion> = {\n AC: \"Norte\",\n AP: \"Norte\",\n AM: \"Norte\",\n PA: \"Norte\",\n RO: \"Norte\",\n RR: \"Norte\",\n TO: \"Norte\",\n AL: \"Nordeste\",\n BA: \"Nordeste\",\n CE: \"Nordeste\",\n MA: \"Nordeste\",\n PB: \"Nordeste\",\n PE: \"Nordeste\",\n PI: \"Nordeste\",\n RN: \"Nordeste\",\n SE: \"Nordeste\",\n DF: \"Centro-Oeste\",\n GO: \"Centro-Oeste\",\n MT: \"Centro-Oeste\",\n MS: \"Centro-Oeste\",\n ES: \"Sudeste\",\n MG: \"Sudeste\",\n RJ: \"Sudeste\",\n SP: \"Sudeste\",\n PR: \"Sul\",\n RS: \"Sul\",\n SC: \"Sul\",\n};\n\n/** One `[IBGE code, name]` row as `br-locations.json` stores it. */\ntype RawEntry = [string, string];\n\ninterface RawState {\n uf: string;\n name: string;\n cities: RawEntry[];\n}\n\ninterface RawLocations {\n /**\n * The two IBGE vintages this file was built from: `roster` is the day the\n * municipality list was read, `mesh` the boundary release it was joined to.\n */\n vintage: { roster: string; mesh: string };\n states: RawState[];\n /** Administrative regions keyed by the municipality that contains them. */\n administrativeRegions: Record<string, RawEntry[]>;\n /** Every former name, mapped to the IBGE code that still answers to it. */\n aliases: RawEntry[];\n /** Municipalities the roster lists and the mesh has no geometry for. */\n pendingGeometry: string[];\n}\n\nconst RAW = rawLocations as unknown as RawLocations;\n\n/**\n * Strip a name down to what two spellings of the same place share.\n *\n * Accents, case and apostrophes are exactly what differs between the spelling a\n * user typed, the one an app saved five years ago and the one IBGE publishes\n * today — `\"Sant'Ana do Livramento\"` and `\"Santana do Livramento\"` are the same\n * municipality, and `\"acu\"` should find `\"Açu\"`.\n *\n * @param value - A municipality, region or alias name.\n * @returns The comparable form: lowercase, unaccented, apostrophes dropped.\n */\nfunction foldName(value: string): string {\n return value\n .trim()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/['\\u2019\\u0060]/g, \"\")\n .toLowerCase();\n}\n\n/** The federative unit each IBGE code starts with. */\nconst UF_BY_CODE: Record<string, UF> = {\n \"11\": \"RO\",\n \"12\": \"AC\",\n \"13\": \"AM\",\n \"14\": \"RR\",\n \"15\": \"PA\",\n \"16\": \"AP\",\n \"17\": \"TO\",\n \"21\": \"MA\",\n \"22\": \"PI\",\n \"23\": \"CE\",\n \"24\": \"RN\",\n \"25\": \"PB\",\n \"26\": \"PE\",\n \"27\": \"AL\",\n \"28\": \"SE\",\n \"29\": \"BA\",\n \"31\": \"MG\",\n \"32\": \"ES\",\n \"33\": \"RJ\",\n \"35\": \"SP\",\n \"41\": \"PR\",\n \"42\": \"SC\",\n \"43\": \"RS\",\n \"50\": \"MS\",\n \"51\": \"MT\",\n \"52\": \"GO\",\n \"53\": \"DF\",\n};\n\n/**\n * The municipality an IBGE code belongs to.\n *\n * A municipality code is 7 digits and a subdistrict code extends it with 4 more\n * — `\"53001080515\"` (Ceilândia) is Brasília's `\"5300108\"` plus `\"0515\"` — so the\n * containing municipality is a prefix, not a lookup.\n *\n * @param id - A municipality or subdistrict IBGE code.\n * @returns The 7-digit municipality code.\n */\nfunction municipalityIdOf(id: string): string {\n return id.slice(0, 7);\n}\n\n/** Administrative regions of a municipality, or `[]` when it has none. */\nfunction regionsOf(municipalityId: string): readonly BrazilAdministrativeRegion[] {\n return (RAW.administrativeRegions[municipalityId] ?? []).map(([id, name]) => ({\n id,\n name,\n municipalityId,\n }));\n}\n\n/** Normalized, frozen list of all 27 states (built once at module load). */\nconst STATES: readonly BrazilState[] = RAW.states\n .map((entry) => {\n const uf = entry.uf as UF;\n const municipalities = entry.cities.map(([id, name]) => ({ id, name }));\n return {\n uf,\n name: entry.name,\n region: REGION_BY_UF[uf],\n cities: municipalities.map((m) => m.name),\n municipalities,\n administrativeRegions: municipalities.flatMap((m) => regionsOf(m.id)),\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name, \"pt-BR\"));\n\nconst STATE_BY_UF = new Map<UF, BrazilState>(STATES.map((s) => [s.uf, s]));\n\n/**\n * Every name that resolves to a municipality, folded, keyed by `<UF>:<name>`.\n *\n * Three kinds of name land here and the precedence matters: a current IBGE name\n * wins, then a former name from `aliases`, then an administrative region of the\n * DF. A rename never shadows a live municipality — `Campo Grande` is a live\n * municipality in both MS and RN, and in RN it is also the former name of\n * nothing, so the live entry has to be written last.\n */\nconst ID_BY_FOLDED_NAME = new Map<string, string>();\nfor (const [name, id] of RAW.aliases) {\n const uf = UF_BY_CODE[id.slice(0, 2)];\n if (uf !== undefined) ID_BY_FOLDED_NAME.set(`${uf}:${foldName(name)}`, municipalityIdOf(id));\n}\nfor (const state of STATES) {\n for (const region of state.administrativeRegions) {\n ID_BY_FOLDED_NAME.set(`${state.uf}:${foldName(region.name)}`, region.municipalityId);\n }\n}\nfor (const state of STATES) {\n for (const municipality of state.municipalities) {\n ID_BY_FOLDED_NAME.set(`${state.uf}:${foldName(municipality.name)}`, municipality.id);\n }\n}\n\nconst MUNICIPALITY_BY_ID = new Map<string, BrazilMunicipality>(\n STATES.flatMap((s) => s.municipalities).map((m) => [m.id, m]),\n);\n\n/** All 27 federative units, sorted by name. */\nexport function listStates(): readonly BrazilState[] {\n return STATES;\n}\n\n/** Look up a single state by acronym (case-insensitive). Returns `null` if unknown. */\nexport function getState(uf: string): BrazilState | null {\n const normalized = normalizeUf(uf);\n return normalized ? (STATE_BY_UF.get(normalized) ?? null) : null;\n}\n\n/**\n * City names for a federative unit (case-insensitive acronym). Returns an empty\n * array for an unknown UF — \"no matches\" is a valid result, not an error.\n */\nexport function citiesByUf(uf: string): string[] {\n return getState(uf)?.cities ?? [];\n}\n\n/** States belonging to a macro-region. */\nexport function statesByRegion(region: BrRegion): readonly BrazilState[] {\n return STATES.filter((s) => s.region === region);\n}\n\n/** True when `value` is one of the 27 valid acronyms (case-insensitive). */\nexport function isValidUf(value: string): boolean {\n return normalizeUf(value) !== null;\n}\n\n/**\n * Normalize an acronym to canonical uppercase form, or `null` if it is not a\n * valid UF. `\"sp\"` → `\"SP\"`, `\"xx\"` → `null`.\n */\nexport function normalizeUf(value: string): UF | null {\n const upper = value.trim().toUpperCase();\n return (REGION_BY_UF as Record<string, BrRegion>)[upper] ? (upper as UF) : null;\n}\n\n/** True when `city` exists within `uf` (both case-insensitive). */\nexport function isValidCity(uf: string, city: string): boolean {\n const target = city.trim().toLowerCase();\n return citiesByUf(uf).some((c) => c.toLowerCase() === target);\n}\n\n/** `{ value: uf, label: name }` options for every state, for a `<Select>`. */\nexport function ufChoices(): Choice[] {\n return STATES.map((s) => ({ value: s.uf, label: s.name }));\n}\n\n/** `{ value, label }` options for every city in a UF (value === label). */\nexport function cityChoices(uf: string): Choice[] {\n return citiesByUf(uf).map((c) => ({ value: c, label: c }));\n}\n\n/**\n * Municipalities of a federative unit, each carrying its IBGE code.\n *\n * The code is what a backend wants stored: it survives the renames that keep\n * happening (`Presidente Juscelino` became `Serra Caiada` in 2013) and it is the\n * key every other dataset in this module joins on.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @returns The municipalities, alphabetically. Empty for an unknown UF.\n */\nexport function municipalitiesByUf(uf: string): readonly BrazilMunicipality[] {\n return getState(uf)?.municipalities ?? [];\n}\n\n/**\n * Administrative regions of a federative unit.\n *\n * Only the Federal District has any — 35 of them, inside its single\n * municipality. Every other UF answers `[]`, which is a valid result and not an\n * error.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @returns The regions, alphabetically. Empty outside the DF.\n */\nexport function administrativeRegionsByUf(uf: string): readonly BrazilAdministrativeRegion[] {\n return getState(uf)?.administrativeRegions ?? [];\n}\n\n/**\n * Find the municipality a name refers to, however it was written down.\n *\n * Four kinds of name resolve, which is the point — an address saved years ago\n * has to keep pointing at the same place:\n *\n * 1. The current IBGE name (`\"Serra Caiada\"`).\n * 2. A former name (`\"Presidente Juscelino\"`), from the alias table the\n * generator builds by diffing vintages.\n * 3. A different spelling — accents, case and apostrophes are folded, so\n * `\"sant'ana do livramento\"` finds `\"Sant'Ana do Livramento\"`.\n * 4. An administrative region of the DF (`\"Ceilândia\"`), which resolves to\n * Brasília — the municipality it is part of.\n *\n * A live municipality always wins over a former name, so a name that is current\n * in one UF and historical in another resolves to the live one in each.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @param name - The municipality, region or former name.\n * @returns The municipality, or `null` when nothing in that UF answers to it.\n */\nexport function resolveMunicipality(uf: string, name: string): BrazilMunicipality | null {\n const normalized = normalizeUf(uf);\n if (normalized === null) return null;\n const id = ID_BY_FOLDED_NAME.get(`${normalized}:${foldName(name)}`);\n return id === undefined ? null : (MUNICIPALITY_BY_ID.get(id) ?? null);\n}\n\n/**\n * The IBGE vintages the bundled datasets were built from.\n *\n * `roster` is the day the municipality list was read and `mesh` the boundary\n * release it was joined to. They differ on purpose: IBGE publishes new\n * municipalities before it publishes their boundaries, and the gap is what\n * {@link pendingGeometryIds} enumerates.\n *\n * @returns The two vintages, as they were written into the data file.\n */\nexport function datasetVintage(): { roster: string; mesh: string } {\n return RAW.vintage;\n}\n\n/**\n * Municipalities that exist in the roster and have no boundary yet.\n *\n * One today: Boa Esperança do Norte (MT), installed in 2023, for which IBGE\n * serves no mesh at any endpoint. It is listed and selectable, and it is the one\n * municipality `geocodeMunicipality` cannot place — so a caller that must plot\n * every selection can check this list up front instead of discovering it as an\n * empty result.\n *\n * @returns The IBGE codes, in the order the data file declares them.\n */\nexport function pendingGeometryIds(): readonly string[] {\n return RAW.pendingGeometry;\n}\n"],"mappings":"A,2CAmFA,IAAME,EAAqC,CACvC,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,QACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ,GAAI,WACJ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CAClD,IAAMI,EAAQ5B,EAAM,KAAK,CAAC,CAAC,YAAY,EACvC,OAAQH,EAA0C+B,GAAUA,EAAe,IAC/E,CAGA,SAAgBC,EAAY,EAAY,EAAuB,CAC3D,IAAMC,EAASC,EAAK,KAAK,CAAC,CAAC,YAAY,EACvC,OAAON,EAAWjB,CAAE,CAAC,CAAC,KAAM,GAAMwB,EAAE,YAAY,IAAMF,CAAM,CAChE,CAGA,SAAgBG,GAAsB,CAClC,OAAO1B,EAAO,IAAK,IAAO,CAAE,MAAOQ,EAAE,GAAI,MAAOA,EAAE,IAAK,EAAE,CAC7D,CAGA,SAAgBmB,EAAY,EAAsB,CAC9C,OAAOT,EAAWjB,CAAE,CAAC,CAAC,IAAK,IAAO,CAAE,MAAOwB,EAAG,MAAOA,CAAE,EAAE,CAC7D,CAYA,SAAgBG,EAAmB,EAA2C,CAC1E,OAAOb,EAASd,CAAE,CAAC,EAAE,gBAAkB,CAAC,CAC5C,CAYA,SAAgB4B,EAA0B,EAAmD,CACzF,OAAOd,EAASd,CAAE,CAAC,EAAE,uBAAyB,CAAC,CACnD,CAuBA,SAAgB6B,EAAoB,EAAY,EAAyC,CACrF,IAAMd,EAAaC,EAAYhB,CAAE,EACjC,GAAIe,IAAe,KAAM,OAAO,KAChC,IAAMpB,EAAKa,EAAkB,IAAI,GAAGO,EAAW,GAAGxB,EAASO,CAAI,GAAG,EAClE,OAAOH,IAAO,IAAA,GAAY,KAAQiB,EAAmB,IAAIjB,CAAE,GAAK,IACpE,CAYA,SAAgBmC,GAAmD,CAC/D,OAAOxC,EAAI,OACf,CAaA,SAAgByC,GAAwC,CACpD,OAAOzC,EAAI,eACf,C"}
|
package/dist/br/locations.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locations.js","names":[],"sources":["../../src/br/locations.ts"],"sourcesContent":["import rawLocations from \"./data/br-locations.json\";\n\n/** The 27 Brazilian federative units (26 states + Federal District). */\nexport type UF =\n | \"AC\"\n | \"AL\"\n | \"AP\"\n | \"AM\"\n | \"BA\"\n | \"CE\"\n | \"DF\"\n | \"ES\"\n | \"GO\"\n | \"MA\"\n | \"MT\"\n | \"MS\"\n | \"MG\"\n | \"PA\"\n | \"PB\"\n | \"PR\"\n | \"PE\"\n | \"PI\"\n | \"RJ\"\n | \"RN\"\n | \"RS\"\n | \"RO\"\n | \"RR\"\n | \"SC\"\n | \"SP\"\n | \"SE\"\n | \"TO\";\n\n/** The five Brazilian macro-regions (IBGE). */\nexport type BrRegion = \"Norte\" | \"Nordeste\" | \"Centro-Oeste\" | \"Sudeste\" | \"Sul\";\n\n/** A municipality, identified by the code that survives its renames. */\nexport interface BrazilMunicipality {\n /** 7-digit IBGE code, e.g. `\"3550308\"`. Stable across a rename. */\n id: string;\n /** Current IBGE name, e.g. `\"São Paulo\"`. */\n name: string;\n}\n\n/**\n * An administrative region of the Federal District.\n *\n * The DF has exactly one municipality — Brasília — and 35 administrative\n * regions inside it. Nobody in the DF writes \"Brasília\" in an address field,\n * so the regions are listed and resolvable; they are not municipalities, and\n * `municipalityId` is what they geocode through.\n */\nexport interface BrazilAdministrativeRegion {\n /** IBGE subdistrict code, e.g. `\"53001080515\"` for Ceilândia. */\n id: string;\n /** IBGE name, e.g. `\"Sudoeste/Octogonal\"`. */\n name: string;\n /** The municipality it belongs to — Brasília (`\"5300108\"`) for all 35. */\n municipalityId: string;\n}\n\n/** A federative unit with its display name and city list. */\nexport interface BrazilState {\n /** Two-letter acronym, e.g. `\"SP\"`. */\n uf: UF;\n /** Full name, e.g. `\"São Paulo\"`. */\n name: string;\n /** Macro-region the state belongs to. */\n region: BrRegion;\n /** Municipality names within the state, alphabetically. */\n cities: string[];\n /** The same municipalities carrying their IBGE codes, same order. */\n municipalities: readonly BrazilMunicipality[];\n /** Administrative regions — 35 for `\"DF\"`, empty everywhere else. */\n administrativeRegions: readonly BrazilAdministrativeRegion[];\n}\n\n/** A `{ value, label }` option, handy for `<Select>` / `<Combobox>`. */\nexport interface Choice {\n value: string;\n label: string;\n}\n\n/** IBGE macro-region of each federative unit. */\nconst REGION_BY_UF: Record<UF, BrRegion> = {\n AC: \"Norte\",\n AP: \"Norte\",\n AM: \"Norte\",\n PA: \"Norte\",\n RO: \"Norte\",\n RR: \"Norte\",\n TO: \"Norte\",\n AL: \"Nordeste\",\n BA: \"Nordeste\",\n CE: \"Nordeste\",\n MA: \"Nordeste\",\n PB: \"Nordeste\",\n PE: \"Nordeste\",\n PI: \"Nordeste\",\n RN: \"Nordeste\",\n SE: \"Nordeste\",\n DF: \"Centro-Oeste\",\n GO: \"Centro-Oeste\",\n MT: \"Centro-Oeste\",\n MS: \"Centro-Oeste\",\n ES: \"Sudeste\",\n MG: \"Sudeste\",\n RJ: \"Sudeste\",\n SP: \"Sudeste\",\n PR: \"Sul\",\n RS: \"Sul\",\n SC: \"Sul\",\n};\n\n/** One `[IBGE code, name]` row as `br-locations.json` stores it. */\ntype RawEntry = [string, string];\n\ninterface RawState {\n uf: string;\n name: string;\n cities: RawEntry[];\n}\n\ninterface RawLocations {\n /**\n * The two IBGE vintages this file was built from: `roster` is the day the\n * municipality list was read, `mesh` the boundary release it was joined to.\n */\n vintage: { roster: string; mesh: string };\n states: RawState[];\n /** Administrative regions keyed by the municipality that contains them. */\n administrativeRegions: Record<string, RawEntry[]>;\n /** Every former name, mapped to the IBGE code that still answers to it. */\n aliases: RawEntry[];\n /** Municipalities the roster lists and the mesh has no geometry for. */\n pendingGeometry: string[];\n}\n\nconst RAW = rawLocations as unknown as RawLocations;\n\n/**\n * Strip a name down to what two spellings of the same place share.\n *\n * Accents, case and apostrophes are exactly what differs between the spelling a\n * user typed, the one an app saved five years ago and the one IBGE publishes\n * today — `\"Sant'Ana do Livramento\"` and `\"Santana do Livramento\"` are the same\n * municipality, and `\"acu\"` should find `\"Açu\"`.\n *\n * @param value - A municipality, region or alias name.\n * @returns The comparable form: lowercase, unaccented, apostrophes dropped.\n */\nfunction foldName(value: string): string {\n return value\n .trim()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/['\\u2019\\u0060]/g, \"\")\n .toLowerCase();\n}\n\n/** The federative unit each IBGE code starts with. */\nconst UF_BY_CODE: Record<string, UF> = {\n \"11\": \"RO\",\n \"12\": \"AC\",\n \"13\": \"AM\",\n \"14\": \"RR\",\n \"15\": \"PA\",\n \"16\": \"AP\",\n \"17\": \"TO\",\n \"21\": \"MA\",\n \"22\": \"PI\",\n \"23\": \"CE\",\n \"24\": \"RN\",\n \"25\": \"PB\",\n \"26\": \"PE\",\n \"27\": \"AL\",\n \"28\": \"SE\",\n \"29\": \"BA\",\n \"31\": \"MG\",\n \"32\": \"ES\",\n \"33\": \"RJ\",\n \"35\": \"SP\",\n \"41\": \"PR\",\n \"42\": \"SC\",\n \"43\": \"RS\",\n \"50\": \"MS\",\n \"51\": \"MT\",\n \"52\": \"GO\",\n \"53\": \"DF\",\n};\n\n/**\n * The municipality an IBGE code belongs to.\n *\n * A municipality code is 7 digits and a subdistrict code extends it with 4 more\n * — `\"53001080515\"` (Ceilândia) is Brasília's `\"5300108\"` plus `\"0515\"` — so the\n * containing municipality is a prefix, not a lookup.\n *\n * @param id - A municipality or subdistrict IBGE code.\n * @returns The 7-digit municipality code.\n */\nfunction municipalityIdOf(id: string): string {\n return id.slice(0, 7);\n}\n\n/** Administrative regions of a municipality, or `[]` when it has none. */\nfunction regionsOf(municipalityId: string): readonly BrazilAdministrativeRegion[] {\n return (RAW.administrativeRegions[municipalityId] ?? []).map(([id, name]) => ({\n id,\n name,\n municipalityId,\n }));\n}\n\n/** Normalized, frozen list of all 27 states (built once at module load). */\nconst STATES: readonly BrazilState[] = RAW.states\n .map((entry) => {\n const uf = entry.uf as UF;\n const municipalities = entry.cities.map(([id, name]) => ({ id, name }));\n return {\n uf,\n name: entry.name,\n region: REGION_BY_UF[uf],\n cities: municipalities.map((m) => m.name),\n municipalities,\n administrativeRegions: municipalities.flatMap((m) => regionsOf(m.id)),\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name, \"pt-BR\"));\n\nconst STATE_BY_UF = new Map<UF, BrazilState>(STATES.map((s) => [s.uf, s]));\n\n/**\n * Every name that resolves to a municipality, folded, keyed by `<UF>:<name>`.\n *\n * Three kinds of name land here and the precedence matters: a current IBGE name\n * wins, then a former name from `aliases`, then an administrative region of the\n * DF. A rename never shadows a live municipality — `Campo Grande` is a live\n * municipality in both MS and RN, and in RN it is also the former name of\n * nothing, so the live entry has to be written last.\n */\nconst ID_BY_FOLDED_NAME = new Map<string, string>();\nfor (const [name, id] of RAW.aliases) {\n const uf = UF_BY_CODE[id.slice(0, 2)];\n if (uf !== undefined) ID_BY_FOLDED_NAME.set(`${uf}:${foldName(name)}`, municipalityIdOf(id));\n}\nfor (const state of STATES) {\n for (const region of state.administrativeRegions) {\n ID_BY_FOLDED_NAME.set(`${state.uf}:${foldName(region.name)}`, region.municipalityId);\n }\n}\nfor (const state of STATES) {\n for (const municipality of state.municipalities) {\n ID_BY_FOLDED_NAME.set(`${state.uf}:${foldName(municipality.name)}`, municipality.id);\n }\n}\n\nconst MUNICIPALITY_BY_ID = new Map<string, BrazilMunicipality>(\n STATES.flatMap((s) => s.municipalities).map((m) => [m.id, m]),\n);\n\n/** All 27 federative units, sorted by name. */\nexport function listStates(): readonly BrazilState[] {\n return STATES;\n}\n\n/** Look up a single state by acronym (case-insensitive). Returns `null` if unknown. */\nexport function getState(uf: string): BrazilState | null {\n const normalized = normalizeUf(uf);\n return normalized ? (STATE_BY_UF.get(normalized) ?? null) : null;\n}\n\n/**\n * City names for a federative unit (case-insensitive acronym). Returns an empty\n * array for an unknown UF — \"no matches\" is a valid result, not an error.\n */\nexport function citiesByUf(uf: string): string[] {\n return getState(uf)?.cities ?? [];\n}\n\n/** States belonging to a macro-region. */\nexport function statesByRegion(region: BrRegion): readonly BrazilState[] {\n return STATES.filter((s) => s.region === region);\n}\n\n/** True when `value` is one of the 27 valid acronyms (case-insensitive). */\nexport function isValidUf(value: string): boolean {\n return normalizeUf(value) !== null;\n}\n\n/**\n * Normalize an acronym to canonical uppercase form, or `null` if it is not a\n * valid UF. `\"sp\"` → `\"SP\"`, `\"xx\"` → `null`.\n */\nexport function normalizeUf(value: string): UF | null {\n const upper = value.trim().toUpperCase();\n return (REGION_BY_UF as Record<string, BrRegion>)[upper] ? (upper as UF) : null;\n}\n\n/** True when `city` exists within `uf` (both case-insensitive). */\nexport function isValidCity(uf: string, city: string): boolean {\n const target = city.trim().toLowerCase();\n return citiesByUf(uf).some((c) => c.toLowerCase() === target);\n}\n\n/** `{ value: uf, label: name }` options for every state, for a `<Select>`. */\nexport function ufChoices(): Choice[] {\n return STATES.map((s) => ({ value: s.uf, label: s.name }));\n}\n\n/** `{ value, label }` options for every city in a UF (value === label). */\nexport function cityChoices(uf: string): Choice[] {\n return citiesByUf(uf).map((c) => ({ value: c, label: c }));\n}\n\n/**\n * Municipalities of a federative unit, each carrying its IBGE code.\n *\n * The code is what a backend wants stored: it survives the renames that keep\n * happening (`Presidente Juscelino` became `Serra Caiada` in 2013) and it is the\n * key every other dataset in this module joins on.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @returns The municipalities, alphabetically. Empty for an unknown UF.\n */\nexport function municipalitiesByUf(uf: string): readonly BrazilMunicipality[] {\n return getState(uf)?.municipalities ?? [];\n}\n\n/**\n * Administrative regions of a federative unit.\n *\n * Only the Federal District has any — 35 of them, inside its single\n * municipality. Every other UF answers `[]`, which is a valid result and not an\n * error.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @returns The regions, alphabetically. Empty outside the DF.\n */\nexport function administrativeRegionsByUf(uf: string): readonly BrazilAdministrativeRegion[] {\n return getState(uf)?.administrativeRegions ?? [];\n}\n\n/**\n * Find the municipality a name refers to, however it was written down.\n *\n * Four kinds of name resolve, which is the point — an address saved years ago\n * has to keep pointing at the same place:\n *\n * 1. The current IBGE name (`\"Serra Caiada\"`).\n * 2. A former name (`\"Presidente Juscelino\"`), from the alias table the\n * generator builds by diffing vintages.\n * 3. A different spelling — accents, case and apostrophes are folded, so\n * `\"sant'ana do livramento\"` finds `\"Sant'Ana do Livramento\"`.\n * 4. An administrative region of the DF (`\"Ceilândia\"`), which resolves to\n * Brasília — the municipality it is part of.\n *\n * A live municipality always wins over a former name, so a name that is current\n * in one UF and historical in another resolves to the live one in each.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @param name - The municipality, region or former name.\n * @returns The municipality, or `null` when nothing in that UF answers to it.\n */\nexport function resolveMunicipality(uf: string, name: string): BrazilMunicipality | null {\n const normalized = normalizeUf(uf);\n if (normalized === null) return null;\n const id = ID_BY_FOLDED_NAME.get(`${normalized}:${foldName(name)}`);\n return id === undefined ? null : (MUNICIPALITY_BY_ID.get(id) ?? null);\n}\n\n/**\n * The IBGE vintages the bundled datasets were built from.\n *\n * `roster` is the day the municipality list was read and `mesh` the boundary\n * release it was joined to. They differ on purpose: IBGE publishes new\n * municipalities before it publishes their boundaries, and the gap is what\n * {@link pendingGeometryIds} enumerates.\n *\n * @returns The two vintages, as they were written into the data file.\n */\nexport function datasetVintage(): { roster: string; mesh: string } {\n return RAW.vintage;\n}\n\n/**\n * Municipalities that exist in the roster and have no boundary yet.\n *\n * One today: Boa Esperança do Norte (MT), installed in 2023, for which IBGE\n * serves no mesh at any endpoint. It is listed and selectable, and it is the one\n * municipality `geocodeMunicipality` cannot place — so a caller that must plot\n * every selection can check this list up front instead of discovering it as an\n * empty result.\n *\n * @returns The IBGE codes, in the order the data file declares them.\n */\nexport function pendingGeometryIds(): readonly string[] {\n return RAW.pendingGeometry;\n}\n"],"mappings":";;AAmFA,IAAM,IAAqC;CACvC,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAA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AAK,CAAC,CAAC,YAAY;CACvC,OAAO,EAAW,CAAE,CAAC,CAAC,MAAM,MAAM,EAAE,YAAY,MAAM,CAAM;AAChE;AAGA,SAAgB,IAAsB;CAClC,OAAO,EAAO,KAAK,OAAO;EAAE,OAAO,EAAE;EAAI,OAAO,EAAE;CAAK,EAAE;AAC7D;AAGA,SAAgB,EAAY,GAAsB;CAC9C,OAAO,EAAW,CAAE,CAAC,CAAC,KAAK,OAAO;EAAE,OAAO;EAAG,OAAO;CAAE,EAAE;AAC7D;AAYA,SAAgB,EAAmB,GAA2C;CAC1E,OAAO,EAAS,CAAE,CAAC,EAAE,kBAAkB,CAAC;AAC5C;AAYA,SAAgB,EAA0B,GAAmD;CACzF,OAAO,EAAS,CAAE,CAAC,EAAE,yBAAyB,CAAC;AACnD;AAuBA,SAAgB,EAAoB,GAAY,GAAyC;CACrF,IAAM,IAAa,EAAY,CAAE;CACjC,IAAI,MAAe,MAAM,OAAO;CAChC,IAAM,IAAK,EAAkB,IAAI,GAAG,EAAW,GAAG,EAAS,CAAI,GAAG;CAClE,OAAO,MAAO,KAAA,IAAY,OAAQ,EAAmB,IAAI,CAAE,KAAK;AACpE;AAYA,SAAgB,IAAmD;CAC/D,OAAO,EAAI;AACf;AAaA,SAAgB,IAAwC;CACpD,OAAO,EAAI;AACf"}
|
|
1
|
+
{"version":3,"file":"locations.js","names":["rawLocations","br_locations_default","REGION_BY_UF","RAW","foldName","value","UF_BY_CODE","municipalityIdOf","id","regionsOf","municipalityId","name","STATES","uf","entry","municipalities","m","a","b","STATE_BY_UF","s","ID_BY_FOLDED_NAME","state","region","municipality","MUNICIPALITY_BY_ID","listStates","getState","normalized","normalizeUf","citiesByUf","statesByRegion","isValidUf","upper","isValidCity","target","city","c","ufChoices","cityChoices","municipalitiesByUf","administrativeRegionsByUf","resolveMunicipality","datasetVintage","pendingGeometryIds"],"sources":["../../src/br/locations.ts"],"sourcesContent":["import rawLocations from \"./data/br-locations.json\";\n\n/** The 27 Brazilian federative units (26 states + Federal District). */\nexport type UF =\n | \"AC\"\n | \"AL\"\n | \"AP\"\n | \"AM\"\n | \"BA\"\n | \"CE\"\n | \"DF\"\n | \"ES\"\n | \"GO\"\n | \"MA\"\n | \"MT\"\n | \"MS\"\n | \"MG\"\n | \"PA\"\n | \"PB\"\n | \"PR\"\n | \"PE\"\n | \"PI\"\n | \"RJ\"\n | \"RN\"\n | \"RS\"\n | \"RO\"\n | \"RR\"\n | \"SC\"\n | \"SP\"\n | \"SE\"\n | \"TO\";\n\n/** The five Brazilian macro-regions (IBGE). */\nexport type BrRegion = \"Norte\" | \"Nordeste\" | \"Centro-Oeste\" | \"Sudeste\" | \"Sul\";\n\n/** A municipality, identified by the code that survives its renames. */\nexport interface BrazilMunicipality {\n /** 7-digit IBGE code, e.g. `\"3550308\"`. Stable across a rename. */\n id: string;\n /** Current IBGE name, e.g. `\"São Paulo\"`. */\n name: string;\n}\n\n/**\n * An administrative region of the Federal District.\n *\n * The DF has exactly one municipality — Brasília — and 35 administrative\n * regions inside it. Nobody in the DF writes \"Brasília\" in an address field,\n * so the regions are listed and resolvable; they are not municipalities, and\n * `municipalityId` is what they geocode through.\n */\nexport interface BrazilAdministrativeRegion {\n /** IBGE subdistrict code, e.g. `\"53001080515\"` for Ceilândia. */\n id: string;\n /** IBGE name, e.g. `\"Sudoeste/Octogonal\"`. */\n name: string;\n /** The municipality it belongs to — Brasília (`\"5300108\"`) for all 35. */\n municipalityId: string;\n}\n\n/** A federative unit with its display name and city list. */\nexport interface BrazilState {\n /** Two-letter acronym, e.g. `\"SP\"`. */\n uf: UF;\n /** Full name, e.g. `\"São Paulo\"`. */\n name: string;\n /** Macro-region the state belongs to. */\n region: BrRegion;\n /** Municipality names within the state, alphabetically. */\n cities: string[];\n /** The same municipalities carrying their IBGE codes, same order. */\n municipalities: readonly BrazilMunicipality[];\n /** Administrative regions — 35 for `\"DF\"`, empty everywhere else. */\n administrativeRegions: readonly BrazilAdministrativeRegion[];\n}\n\n/** A `{ value, label }` option, handy for `<Select>` / `<Combobox>`. */\nexport interface Choice {\n value: string;\n label: string;\n}\n\n/** IBGE macro-region of each federative unit. */\nconst REGION_BY_UF: Record<UF, BrRegion> = {\n AC: \"Norte\",\n AP: \"Norte\",\n AM: \"Norte\",\n PA: \"Norte\",\n RO: \"Norte\",\n RR: \"Norte\",\n TO: \"Norte\",\n AL: \"Nordeste\",\n BA: \"Nordeste\",\n CE: \"Nordeste\",\n MA: \"Nordeste\",\n PB: \"Nordeste\",\n PE: \"Nordeste\",\n PI: \"Nordeste\",\n RN: \"Nordeste\",\n SE: \"Nordeste\",\n DF: \"Centro-Oeste\",\n GO: \"Centro-Oeste\",\n MT: \"Centro-Oeste\",\n MS: \"Centro-Oeste\",\n ES: \"Sudeste\",\n MG: \"Sudeste\",\n RJ: \"Sudeste\",\n SP: \"Sudeste\",\n PR: \"Sul\",\n RS: \"Sul\",\n SC: \"Sul\",\n};\n\n/** One `[IBGE code, name]` row as `br-locations.json` stores it. */\ntype RawEntry = [string, string];\n\ninterface RawState {\n uf: string;\n name: string;\n cities: RawEntry[];\n}\n\ninterface RawLocations {\n /**\n * The two IBGE vintages this file was built from: `roster` is the day the\n * municipality list was read, `mesh` the boundary release it was joined to.\n */\n vintage: { roster: string; mesh: string };\n states: RawState[];\n /** Administrative regions keyed by the municipality that contains them. */\n administrativeRegions: Record<string, RawEntry[]>;\n /** Every former name, mapped to the IBGE code that still answers to it. */\n aliases: RawEntry[];\n /** Municipalities the roster lists and the mesh has no geometry for. */\n pendingGeometry: string[];\n}\n\nconst RAW = rawLocations as unknown as RawLocations;\n\n/**\n * Strip a name down to what two spellings of the same place share.\n *\n * Accents, case and apostrophes are exactly what differs between the spelling a\n * user typed, the one an app saved five years ago and the one IBGE publishes\n * today — `\"Sant'Ana do Livramento\"` and `\"Santana do Livramento\"` are the same\n * municipality, and `\"acu\"` should find `\"Açu\"`.\n *\n * @param value - A municipality, region or alias name.\n * @returns The comparable form: lowercase, unaccented, apostrophes dropped.\n */\nfunction foldName(value: string): string {\n return value\n .trim()\n .normalize(\"NFD\")\n .replace(/[\\u0300-\\u036f]/g, \"\")\n .replace(/['\\u2019\\u0060]/g, \"\")\n .toLowerCase();\n}\n\n/** The federative unit each IBGE code starts with. */\nconst UF_BY_CODE: Record<string, UF> = {\n \"11\": \"RO\",\n \"12\": \"AC\",\n \"13\": \"AM\",\n \"14\": \"RR\",\n \"15\": \"PA\",\n \"16\": \"AP\",\n \"17\": \"TO\",\n \"21\": \"MA\",\n \"22\": \"PI\",\n \"23\": \"CE\",\n \"24\": \"RN\",\n \"25\": \"PB\",\n \"26\": \"PE\",\n \"27\": \"AL\",\n \"28\": \"SE\",\n \"29\": \"BA\",\n \"31\": \"MG\",\n \"32\": \"ES\",\n \"33\": \"RJ\",\n \"35\": \"SP\",\n \"41\": \"PR\",\n \"42\": \"SC\",\n \"43\": \"RS\",\n \"50\": \"MS\",\n \"51\": \"MT\",\n \"52\": \"GO\",\n \"53\": \"DF\",\n};\n\n/**\n * The municipality an IBGE code belongs to.\n *\n * A municipality code is 7 digits and a subdistrict code extends it with 4 more\n * — `\"53001080515\"` (Ceilândia) is Brasília's `\"5300108\"` plus `\"0515\"` — so the\n * containing municipality is a prefix, not a lookup.\n *\n * @param id - A municipality or subdistrict IBGE code.\n * @returns The 7-digit municipality code.\n */\nfunction municipalityIdOf(id: string): string {\n return id.slice(0, 7);\n}\n\n/** Administrative regions of a municipality, or `[]` when it has none. */\nfunction regionsOf(municipalityId: string): readonly BrazilAdministrativeRegion[] {\n return (RAW.administrativeRegions[municipalityId] ?? []).map(([id, name]) => ({\n id,\n name,\n municipalityId,\n }));\n}\n\n/** Normalized, frozen list of all 27 states (built once at module load). */\nconst STATES: readonly BrazilState[] = RAW.states\n .map((entry) => {\n const uf = entry.uf as UF;\n const municipalities = entry.cities.map(([id, name]) => ({ id, name }));\n return {\n uf,\n name: entry.name,\n region: REGION_BY_UF[uf],\n cities: municipalities.map((m) => m.name),\n municipalities,\n administrativeRegions: municipalities.flatMap((m) => regionsOf(m.id)),\n };\n })\n .sort((a, b) => a.name.localeCompare(b.name, \"pt-BR\"));\n\nconst STATE_BY_UF = new Map<UF, BrazilState>(STATES.map((s) => [s.uf, s]));\n\n/**\n * Every name that resolves to a municipality, folded, keyed by `<UF>:<name>`.\n *\n * Three kinds of name land here and the precedence matters: a current IBGE name\n * wins, then a former name from `aliases`, then an administrative region of the\n * DF. A rename never shadows a live municipality — `Campo Grande` is a live\n * municipality in both MS and RN, and in RN it is also the former name of\n * nothing, so the live entry has to be written last.\n */\nconst ID_BY_FOLDED_NAME = new Map<string, string>();\nfor (const [name, id] of RAW.aliases) {\n const uf = UF_BY_CODE[id.slice(0, 2)];\n if (uf !== undefined) ID_BY_FOLDED_NAME.set(`${uf}:${foldName(name)}`, municipalityIdOf(id));\n}\nfor (const state of STATES) {\n for (const region of state.administrativeRegions) {\n ID_BY_FOLDED_NAME.set(`${state.uf}:${foldName(region.name)}`, region.municipalityId);\n }\n}\nfor (const state of STATES) {\n for (const municipality of state.municipalities) {\n ID_BY_FOLDED_NAME.set(`${state.uf}:${foldName(municipality.name)}`, municipality.id);\n }\n}\n\nconst MUNICIPALITY_BY_ID = new Map<string, BrazilMunicipality>(\n STATES.flatMap((s) => s.municipalities).map((m) => [m.id, m]),\n);\n\n/** All 27 federative units, sorted by name. */\nexport function listStates(): readonly BrazilState[] {\n return STATES;\n}\n\n/** Look up a single state by acronym (case-insensitive). Returns `null` if unknown. */\nexport function getState(uf: string): BrazilState | null {\n const normalized = normalizeUf(uf);\n return normalized ? (STATE_BY_UF.get(normalized) ?? null) : null;\n}\n\n/**\n * City names for a federative unit (case-insensitive acronym). Returns an empty\n * array for an unknown UF — \"no matches\" is a valid result, not an error.\n */\nexport function citiesByUf(uf: string): string[] {\n return getState(uf)?.cities ?? [];\n}\n\n/** States belonging to a macro-region. */\nexport function statesByRegion(region: BrRegion): readonly BrazilState[] {\n return STATES.filter((s) => s.region === region);\n}\n\n/** True when `value` is one of the 27 valid acronyms (case-insensitive). */\nexport function isValidUf(value: string): boolean {\n return normalizeUf(value) !== null;\n}\n\n/**\n * Normalize an acronym to canonical uppercase form, or `null` if it is not a\n * valid UF. `\"sp\"` → `\"SP\"`, `\"xx\"` → `null`.\n */\nexport function normalizeUf(value: string): UF | null {\n const upper = value.trim().toUpperCase();\n return (REGION_BY_UF as Record<string, BrRegion>)[upper] ? (upper as UF) : null;\n}\n\n/** True when `city` exists within `uf` (both case-insensitive). */\nexport function isValidCity(uf: string, city: string): boolean {\n const target = city.trim().toLowerCase();\n return citiesByUf(uf).some((c) => c.toLowerCase() === target);\n}\n\n/** `{ value: uf, label: name }` options for every state, for a `<Select>`. */\nexport function ufChoices(): Choice[] {\n return STATES.map((s) => ({ value: s.uf, label: s.name }));\n}\n\n/** `{ value, label }` options for every city in a UF (value === label). */\nexport function cityChoices(uf: string): Choice[] {\n return citiesByUf(uf).map((c) => ({ value: c, label: c }));\n}\n\n/**\n * Municipalities of a federative unit, each carrying its IBGE code.\n *\n * The code is what a backend wants stored: it survives the renames that keep\n * happening (`Presidente Juscelino` became `Serra Caiada` in 2013) and it is the\n * key every other dataset in this module joins on.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @returns The municipalities, alphabetically. Empty for an unknown UF.\n */\nexport function municipalitiesByUf(uf: string): readonly BrazilMunicipality[] {\n return getState(uf)?.municipalities ?? [];\n}\n\n/**\n * Administrative regions of a federative unit.\n *\n * Only the Federal District has any — 35 of them, inside its single\n * municipality. Every other UF answers `[]`, which is a valid result and not an\n * error.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @returns The regions, alphabetically. Empty outside the DF.\n */\nexport function administrativeRegionsByUf(uf: string): readonly BrazilAdministrativeRegion[] {\n return getState(uf)?.administrativeRegions ?? [];\n}\n\n/**\n * Find the municipality a name refers to, however it was written down.\n *\n * Four kinds of name resolve, which is the point — an address saved years ago\n * has to keep pointing at the same place:\n *\n * 1. The current IBGE name (`\"Serra Caiada\"`).\n * 2. A former name (`\"Presidente Juscelino\"`), from the alias table the\n * generator builds by diffing vintages.\n * 3. A different spelling — accents, case and apostrophes are folded, so\n * `\"sant'ana do livramento\"` finds `\"Sant'Ana do Livramento\"`.\n * 4. An administrative region of the DF (`\"Ceilândia\"`), which resolves to\n * Brasília — the municipality it is part of.\n *\n * A live municipality always wins over a former name, so a name that is current\n * in one UF and historical in another resolves to the live one in each.\n *\n * @param uf - Federative unit acronym, case-insensitive.\n * @param name - The municipality, region or former name.\n * @returns The municipality, or `null` when nothing in that UF answers to it.\n */\nexport function resolveMunicipality(uf: string, name: string): BrazilMunicipality | null {\n const normalized = normalizeUf(uf);\n if (normalized === null) return null;\n const id = ID_BY_FOLDED_NAME.get(`${normalized}:${foldName(name)}`);\n return id === undefined ? null : (MUNICIPALITY_BY_ID.get(id) ?? null);\n}\n\n/**\n * The IBGE vintages the bundled datasets were built from.\n *\n * `roster` is the day the municipality list was read and `mesh` the boundary\n * release it was joined to. They differ on purpose: IBGE publishes new\n * municipalities before it publishes their boundaries, and the gap is what\n * {@link pendingGeometryIds} enumerates.\n *\n * @returns The two vintages, as they were written into the data file.\n */\nexport function datasetVintage(): { roster: string; mesh: string } {\n return RAW.vintage;\n}\n\n/**\n * Municipalities that exist in the roster and have no boundary yet.\n *\n * One today: Boa Esperança do Norte (MT), installed in 2023, for which IBGE\n * serves no mesh at any endpoint. It is listed and selectable, and it is the one\n * municipality `geocodeMunicipality` cannot place — so a caller that must plot\n * every selection can check this list up front instead of discovering it as an\n * empty result.\n *\n * @returns The IBGE codes, in the order the data file declares them.\n */\nexport function pendingGeometryIds(): readonly string[] {\n return RAW.pendingGeometry;\n}\n"],"mappings":";;AAmFA,IAAME,IAAqC;CACvC,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ,IAAI;CACJ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;CAClD,IAAMI,IAAQ5B,EAAM,KAAK,CAAC,CAAC,YAAY;CACvC,OAAQH,EAA0C+B,KAAUA,IAAe;AAC/E;AAGA,SAAgBC,EAAY,GAAY,GAAuB;CAC3D,IAAMC,IAASC,EAAK,KAAK,CAAC,CAAC,YAAY;CACvC,OAAON,EAAWjB,CAAE,CAAC,CAAC,MAAM,MAAMwB,EAAE,YAAY,MAAMF,CAAM;AAChE;AAGA,SAAgBG,IAAsB;CAClC,OAAO1B,EAAO,KAAK,OAAO;EAAE,OAAOQ,EAAE;EAAI,OAAOA,EAAE;CAAK,EAAE;AAC7D;AAGA,SAAgBmB,EAAY,GAAsB;CAC9C,OAAOT,EAAWjB,CAAE,CAAC,CAAC,KAAK,OAAO;EAAE,OAAOwB;EAAG,OAAOA;CAAE,EAAE;AAC7D;AAYA,SAAgBG,EAAmB,GAA2C;CAC1E,OAAOb,EAASd,CAAE,CAAC,EAAE,kBAAkB,CAAC;AAC5C;AAYA,SAAgB4B,EAA0B,GAAmD;CACzF,OAAOd,EAASd,CAAE,CAAC,EAAE,yBAAyB,CAAC;AACnD;AAuBA,SAAgB6B,EAAoB,GAAY,GAAyC;CACrF,IAAMd,IAAaC,EAAYhB,CAAE;CACjC,IAAIe,MAAe,MAAM,OAAO;CAChC,IAAMpB,IAAKa,EAAkB,IAAI,GAAGO,EAAW,GAAGxB,EAASO,CAAI,GAAG;CAClE,OAAOH,MAAO,KAAA,IAAY,OAAQiB,EAAmB,IAAIjB,CAAE,KAAK;AACpE;AAYA,SAAgBmC,IAAmD;CAC/D,OAAOxC,EAAI;AACf;AAaA,SAAgByC,IAAwC;CACpD,OAAOzC,EAAI;AACf"}
|
package/dist/br/nfe.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nfe.cjs","names":[],"sources":["../../src/br/nfe.ts"],"sourcesContent":["import type { UF } from \"./locations\";\n\n/**\n * A 44-digit fiscal access key could not be read.\n *\n * Its own class so a scanner screen can tell a bad key apart from a bug and show\n * the message to the operator unchanged.\n */\nexport class ChaveNFeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ChaveNFeError\";\n }\n}\n\n/** A fiscal access key taken apart. */\nexport interface ChaveNFe {\n /** Federative unit of the issuer, resolved from {@link cUF}. */\n uf: UF;\n /** The raw 2-digit IBGE code, positions 1-2. */\n cUF: string;\n /** Positions 3-6, `AAMM` — the two-digit year and the month of issue. */\n anoMes: string;\n /** Four-digit year derived from {@link anoMes}. */\n ano: number;\n /** Month of issue, 1-12. */\n mes: number;\n /** Positions 7-20, the issuer's CNPJ. */\n cnpj: string;\n /** Positions 21-22, `mod`. `\"55\"` is an NF-e, `\"65\"` an NFC-e. */\n modelo: string;\n /** Human label for {@link modelo}, or `null` for a model outside the table. */\n modeloLabel: string | null;\n /** Positions 23-25. */\n serie: string;\n /** Positions 26-34, `nNF`. */\n numero: string;\n /** Position 35, `tpEmis`. */\n tipoEmissao: string;\n /** Human label for {@link tipoEmissao}, or `null` for a value outside the table. */\n tipoEmissaoLabel: string | null;\n /** Positions 36-43, `cNF` — the issuer's random code. */\n codigoNumerico: string;\n /** Position 44, `cDV`. */\n dv: string;\n}\n\n/**\n * IBGE code of each federative unit, as `cUF` carries it.\n *\n * Only the numeric codes live here — the acronyms are the `UF` union from\n * `./locations`, so a state added or renamed there flows through. Ported from the\n * IBGE table of \"códigos dos municípios\" (the two leading digits of every\n * municipality code), which is the same table the NF-e manual points at.\n */\nconst UF_BY_CODE: Record<string, UF> = {\n \"11\": \"RO\",\n \"12\": \"AC\",\n \"13\": \"AM\",\n \"14\": \"RR\",\n \"15\": \"PA\",\n \"16\": \"AP\",\n \"17\": \"TO\",\n \"21\": \"MA\",\n \"22\": \"PI\",\n \"23\": \"CE\",\n \"24\": \"RN\",\n \"25\": \"PB\",\n \"26\": \"PE\",\n \"27\": \"AL\",\n \"28\": \"SE\",\n \"29\": \"BA\",\n \"31\": \"MG\",\n \"32\": \"ES\",\n \"33\": \"RJ\",\n \"35\": \"SP\",\n \"41\": \"PR\",\n \"42\": \"SC\",\n \"43\": \"RS\",\n \"50\": \"MS\",\n \"51\": \"MT\",\n \"52\": \"GO\",\n \"53\": \"DF\",\n};\n\n/** The document models that share the 44-digit key layout. */\nconst MODELO_LABELS: Record<string, string> = {\n \"55\": \"NF-e\",\n \"57\": \"CT-e\",\n \"58\": \"MDF-e\",\n \"59\": \"SAT-CF-e\",\n \"63\": \"BP-e\",\n \"65\": \"NFC-e\",\n \"66\": \"NF3e\",\n \"67\": \"CT-e OS\",\n};\n\n/** `tpEmis` values from the NF-e manual. */\nconst TIPO_EMISSAO_LABELS: Record<string, string> = {\n \"1\": \"Normal\",\n \"2\": \"Contingência FS-IA\",\n \"3\": \"Contingência SCAN\",\n \"4\": \"Contingência DPEC/EPEC\",\n \"5\": \"Contingência FS-DA\",\n \"6\": \"Contingência SVC-AN\",\n \"7\": \"Contingência SVC-RS\",\n \"9\": \"Contingência off-line (NFC-e)\",\n};\n\n/** Weight cycle of the módulo 11 check digit, applied right to left. */\nconst DV_WEIGHT_FIRST = 2;\nconst DV_WEIGHT_LAST = 9;\n\n/** Length of the key, and of the body the check digit protects. */\nconst CHAVE_LENGTH = 44;\nconst CHAVE_BODY_LENGTH = 43;\n\n/** Century the two-digit `AAMM` year resolves into. NF-e went live in 2006. */\nconst CHAVE_YEAR_BASE = 2000;\n\n/** Digits of a key that may carry spaces or dots from a copy-paste. */\nfunction digits(value: string): string {\n return value.replace(/\\D/g, \"\");\n}\n\n/**\n * The check digit a 43-digit key body requires.\n *\n * Módulo 11: each digit is multiplied by weights cycling `2…9` from right to\n * left, the products are summed, and the digit is `11 - (sum mod 11)` — except\n * that a remainder of `0` or `1` yields `0`, since `11` and `10` do not fit one\n * position.\n *\n * Note this is the **fiscal** flavour of módulo 11. The cobrança boleto resolves\n * those same remainders to `1`; see `mod11DacCobranca` in `./boleto`.\n *\n * @param body - The first 43 digits of the key.\n * @returns The check digit, 0-9.\n * @throws {ChaveNFeError} When `body` is not exactly 43 digits.\n */\nexport function chaveNFeCheckDigit(body: string): number {\n if (!new RegExp(`^\\\\d{${CHAVE_BODY_LENGTH}}$`).test(body)) {\n throw new ChaveNFeError(\n `The check digit is computed over ${CHAVE_BODY_LENGTH} digits, got ${body.length}.`,\n );\n }\n const span = DV_WEIGHT_LAST - DV_WEIGHT_FIRST + 1;\n let sum = 0;\n for (let index = 0; index < body.length; index += 1) {\n const fromRight = body.length - 1 - index;\n sum += Number(body[index]) * (DV_WEIGHT_FIRST + (fromRight % span));\n }\n const remainder = sum % 11;\n return remainder === 0 || remainder === 1 ? 0 : 11 - remainder;\n}\n\n/**\n * Whether a fiscal access key is well formed.\n *\n * Three things have to hold: 44 digits, a `cUF` that is a real federative unit,\n * and a check digit that recomputes. It says nothing about whether the document\n * exists or was authorised — only SEFAZ can answer that — but it catches the\n * failure that actually happens, a key transcribed by hand or truncated by a\n * spreadsheet.\n *\n * @param chave - The key, with or without the spaces a DANFE prints.\n * @returns `true` when all three hold.\n *\n * @example\n * if (!validateChaveNFe(input)) setError(\"Chave inválida.\");\n */\nexport function validateChaveNFe(chave: string): boolean {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) return false;\n if (UF_BY_CODE[raw.slice(0, 2)] === undefined) return false;\n return String(chaveNFeCheckDigit(raw.slice(0, CHAVE_BODY_LENGTH))) === raw.slice(43);\n}\n\n/**\n * Read a 44-digit fiscal access key into its fields.\n *\n * The layout is fixed and shared by every document type that carries a key —\n * NF-e, NFC-e, CT-e, MDF-e — so `modelo` is what tells you which one you are\n * holding, not the length.\n *\n * ```text\n * 35 2601 12345678000195 55 001 000000123 1 12345678 4\n * cUF AAMM CNPJ mod série nNF tp cNF cDV\n * ```\n *\n * @param chave - The key, with or without the spaces a DANFE prints.\n * @returns The parsed key.\n * @throws {ChaveNFeError} On a length other than 44, an unknown `cUF`, a month\n * outside 1-12, or a check digit that does not recompute.\n *\n * @example\n * const { uf, cnpj, numero, modeloLabel } = parseChaveNFe(scanned);\n */\nexport function parseChaveNFe(chave: string): ChaveNFe {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) {\n throw new ChaveNFeError(`An access key has ${CHAVE_LENGTH} digits, got ${raw.length}.`);\n }\n\n const cUF = raw.slice(0, 2);\n const uf = UF_BY_CODE[cUF];\n if (uf === undefined) {\n throw new ChaveNFeError(`${cUF} is not an IBGE code for a federative unit.`);\n }\n\n const anoMes = raw.slice(2, 6);\n const mes = Number(anoMes.slice(2, 4));\n if (mes < 1 || mes > 12) {\n throw new ChaveNFeError(`Month ${anoMes.slice(2, 4)} in AAMM is not a month.`);\n }\n\n const dv = raw.slice(43);\n const expected = chaveNFeCheckDigit(raw.slice(0, CHAVE_BODY_LENGTH));\n if (String(expected) !== dv) {\n throw new ChaveNFeError(`Check digit is ${dv}, recomputed ${expected}.`);\n }\n\n const modelo = raw.slice(20, 22);\n const tipoEmissao = raw.slice(34, 35);\n return {\n uf,\n cUF,\n anoMes,\n ano: CHAVE_YEAR_BASE + Number(anoMes.slice(0, 2)),\n mes,\n cnpj: raw.slice(6, 20),\n modelo,\n modeloLabel: MODELO_LABELS[modelo] ?? null,\n serie: raw.slice(22, 25),\n numero: raw.slice(25, 34),\n tipoEmissao,\n tipoEmissaoLabel: TIPO_EMISSAO_LABELS[tipoEmissao] ?? null,\n codigoNumerico: raw.slice(35, 43),\n dv,\n };\n}\n\n/**\n * Group a key in blocks of four, the way a DANFE prints it.\n *\n * @param chave - The key, masked or not.\n * @returns Eleven groups of four digits separated by spaces, or the input\n * unchanged when it is not 44 digits — this is a display helper, not a validator.\n *\n * @example\n * formatChaveNFe(\"35260112345678000195550010000001231123456784\");\n * // \"3526 0112 3456 7800 0195 5500 1000 0001 2311 2345 6784\"\n */\nexport function formatChaveNFe(chave: string): string {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) return chave;\n return raw.replace(/(\\d{4})(?=\\d)/g, \"$1 \");\n}\n"],"mappings":"AAQA,IAAa,EAAb,cAAmC,K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I,SAAW,EACZ,EAAI,QAAQ,iBAAkB,KAAK,EADF,CAE5C"}
|
|
1
|
+
{"version":3,"file":"nfe.cjs","names":["ChaveNFeError","message","UF_BY_CODE","MODELO_LABELS","TIPO_EMISSAO_LABELS","DV_WEIGHT_FIRST","CHAVE_LENGTH","CHAVE_BODY_LENGTH","CHAVE_YEAR_BASE","digits","value","chaveNFeCheckDigit","body","sum","index","fromRight","remainder","validateChaveNFe","raw","chave","parseChaveNFe","cUF","uf","anoMes","mes","dv","expected","modelo","tipoEmissao","formatChaveNFe"],"sources":["../../src/br/nfe.ts"],"sourcesContent":["import type { UF } from \"./locations\";\n\n/**\n * A 44-digit fiscal access key could not be read.\n *\n * Its own class so a scanner screen can tell a bad key apart from a bug and show\n * the message to the operator unchanged.\n */\nexport class ChaveNFeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ChaveNFeError\";\n }\n}\n\n/** A fiscal access key taken apart. */\nexport interface ChaveNFe {\n /** Federative unit of the issuer, resolved from {@link cUF}. */\n uf: UF;\n /** The raw 2-digit IBGE code, positions 1-2. */\n cUF: string;\n /** Positions 3-6, `AAMM` — the two-digit year and the month of issue. */\n anoMes: string;\n /** Four-digit year derived from {@link anoMes}. */\n ano: number;\n /** Month of issue, 1-12. */\n mes: number;\n /** Positions 7-20, the issuer's CNPJ. */\n cnpj: string;\n /** Positions 21-22, `mod`. `\"55\"` is an NF-e, `\"65\"` an NFC-e. */\n modelo: string;\n /** Human label for {@link modelo}, or `null` for a model outside the table. */\n modeloLabel: string | null;\n /** Positions 23-25. */\n serie: string;\n /** Positions 26-34, `nNF`. */\n numero: string;\n /** Position 35, `tpEmis`. */\n tipoEmissao: string;\n /** Human label for {@link tipoEmissao}, or `null` for a value outside the table. */\n tipoEmissaoLabel: string | null;\n /** Positions 36-43, `cNF` — the issuer's random code. */\n codigoNumerico: string;\n /** Position 44, `cDV`. */\n dv: string;\n}\n\n/**\n * IBGE code of each federative unit, as `cUF` carries it.\n *\n * Only the numeric codes live here — the acronyms are the `UF` union from\n * `./locations`, so a state added or renamed there flows through. Ported from the\n * IBGE table of \"códigos dos municípios\" (the two leading digits of every\n * municipality code), which is the same table the NF-e manual points at.\n */\nconst UF_BY_CODE: Record<string, UF> = {\n \"11\": \"RO\",\n \"12\": \"AC\",\n \"13\": \"AM\",\n \"14\": \"RR\",\n \"15\": \"PA\",\n \"16\": \"AP\",\n \"17\": \"TO\",\n \"21\": \"MA\",\n \"22\": \"PI\",\n \"23\": \"CE\",\n \"24\": \"RN\",\n \"25\": \"PB\",\n \"26\": \"PE\",\n \"27\": \"AL\",\n \"28\": \"SE\",\n \"29\": \"BA\",\n \"31\": \"MG\",\n \"32\": \"ES\",\n \"33\": \"RJ\",\n \"35\": \"SP\",\n \"41\": \"PR\",\n \"42\": \"SC\",\n \"43\": \"RS\",\n \"50\": \"MS\",\n \"51\": \"MT\",\n \"52\": \"GO\",\n \"53\": \"DF\",\n};\n\n/** The document models that share the 44-digit key layout. */\nconst MODELO_LABELS: Record<string, string> = {\n \"55\": \"NF-e\",\n \"57\": \"CT-e\",\n \"58\": \"MDF-e\",\n \"59\": \"SAT-CF-e\",\n \"63\": \"BP-e\",\n \"65\": \"NFC-e\",\n \"66\": \"NF3e\",\n \"67\": \"CT-e OS\",\n};\n\n/** `tpEmis` values from the NF-e manual. */\nconst TIPO_EMISSAO_LABELS: Record<string, string> = {\n \"1\": \"Normal\",\n \"2\": \"Contingência FS-IA\",\n \"3\": \"Contingência SCAN\",\n \"4\": \"Contingência DPEC/EPEC\",\n \"5\": \"Contingência FS-DA\",\n \"6\": \"Contingência SVC-AN\",\n \"7\": \"Contingência SVC-RS\",\n \"9\": \"Contingência off-line (NFC-e)\",\n};\n\n/** Weight cycle of the módulo 11 check digit, applied right to left. */\nconst DV_WEIGHT_FIRST = 2;\nconst DV_WEIGHT_LAST = 9;\n\n/** Length of the key, and of the body the check digit protects. */\nconst CHAVE_LENGTH = 44;\nconst CHAVE_BODY_LENGTH = 43;\n\n/** Century the two-digit `AAMM` year resolves into. NF-e went live in 2006. */\nconst CHAVE_YEAR_BASE = 2000;\n\n/** Digits of a key that may carry spaces or dots from a copy-paste. */\nfunction digits(value: string): string {\n return value.replace(/\\D/g, \"\");\n}\n\n/**\n * The check digit a 43-digit key body requires.\n *\n * Módulo 11: each digit is multiplied by weights cycling `2…9` from right to\n * left, the products are summed, and the digit is `11 - (sum mod 11)` — except\n * that a remainder of `0` or `1` yields `0`, since `11` and `10` do not fit one\n * position.\n *\n * Note this is the **fiscal** flavour of módulo 11. The cobrança boleto resolves\n * those same remainders to `1`; see `mod11DacCobranca` in `./boleto`.\n *\n * @param body - The first 43 digits of the key.\n * @returns The check digit, 0-9.\n * @throws {ChaveNFeError} When `body` is not exactly 43 digits.\n */\nexport function chaveNFeCheckDigit(body: string): number {\n if (!new RegExp(`^\\\\d{${CHAVE_BODY_LENGTH}}$`).test(body)) {\n throw new ChaveNFeError(\n `The check digit is computed over ${CHAVE_BODY_LENGTH} digits, got ${body.length}.`,\n );\n }\n const span = DV_WEIGHT_LAST - DV_WEIGHT_FIRST + 1;\n let sum = 0;\n for (let index = 0; index < body.length; index += 1) {\n const fromRight = body.length - 1 - index;\n sum += Number(body[index]) * (DV_WEIGHT_FIRST + (fromRight % span));\n }\n const remainder = sum % 11;\n return remainder === 0 || remainder === 1 ? 0 : 11 - remainder;\n}\n\n/**\n * Whether a fiscal access key is well formed.\n *\n * Three things have to hold: 44 digits, a `cUF` that is a real federative unit,\n * and a check digit that recomputes. It says nothing about whether the document\n * exists or was authorised — only SEFAZ can answer that — but it catches the\n * failure that actually happens, a key transcribed by hand or truncated by a\n * spreadsheet.\n *\n * @param chave - The key, with or without the spaces a DANFE prints.\n * @returns `true` when all three hold.\n *\n * @example\n * if (!validateChaveNFe(input)) setError(\"Chave inválida.\");\n */\nexport function validateChaveNFe(chave: string): boolean {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) return false;\n if (UF_BY_CODE[raw.slice(0, 2)] === undefined) return false;\n return String(chaveNFeCheckDigit(raw.slice(0, CHAVE_BODY_LENGTH))) === raw.slice(43);\n}\n\n/**\n * Read a 44-digit fiscal access key into its fields.\n *\n * The layout is fixed and shared by every document type that carries a key —\n * NF-e, NFC-e, CT-e, MDF-e — so `modelo` is what tells you which one you are\n * holding, not the length.\n *\n * ```text\n * 35 2601 12345678000195 55 001 000000123 1 12345678 4\n * cUF AAMM CNPJ mod série nNF tp cNF cDV\n * ```\n *\n * @param chave - The key, with or without the spaces a DANFE prints.\n * @returns The parsed key.\n * @throws {ChaveNFeError} On a length other than 44, an unknown `cUF`, a month\n * outside 1-12, or a check digit that does not recompute.\n *\n * @example\n * const { uf, cnpj, numero, modeloLabel } = parseChaveNFe(scanned);\n */\nexport function parseChaveNFe(chave: string): ChaveNFe {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) {\n throw new ChaveNFeError(`An access key has ${CHAVE_LENGTH} digits, got ${raw.length}.`);\n }\n\n const cUF = raw.slice(0, 2);\n const uf = UF_BY_CODE[cUF];\n if (uf === undefined) {\n throw new ChaveNFeError(`${cUF} is not an IBGE code for a federative unit.`);\n }\n\n const anoMes = raw.slice(2, 6);\n const mes = Number(anoMes.slice(2, 4));\n if (mes < 1 || mes > 12) {\n throw new ChaveNFeError(`Month ${anoMes.slice(2, 4)} in AAMM is not a month.`);\n }\n\n const dv = raw.slice(43);\n const expected = chaveNFeCheckDigit(raw.slice(0, CHAVE_BODY_LENGTH));\n if (String(expected) !== dv) {\n throw new ChaveNFeError(`Check digit is ${dv}, recomputed ${expected}.`);\n }\n\n const modelo = raw.slice(20, 22);\n const tipoEmissao = raw.slice(34, 35);\n return {\n uf,\n cUF,\n anoMes,\n ano: CHAVE_YEAR_BASE + Number(anoMes.slice(0, 2)),\n mes,\n cnpj: raw.slice(6, 20),\n modelo,\n modeloLabel: MODELO_LABELS[modelo] ?? null,\n serie: raw.slice(22, 25),\n numero: raw.slice(25, 34),\n tipoEmissao,\n tipoEmissaoLabel: TIPO_EMISSAO_LABELS[tipoEmissao] ?? null,\n codigoNumerico: raw.slice(35, 43),\n dv,\n };\n}\n\n/**\n * Group a key in blocks of four, the way a DANFE prints it.\n *\n * @param chave - The key, masked or not.\n * @returns Eleven groups of four digits separated by spaces, or the input\n * unchanged when it is not 44 digits — this is a display helper, not a validator.\n *\n * @example\n * formatChaveNFe(\"35260112345678000195550010000001231123456784\");\n * // \"3526 0112 3456 7800 0195 5500 1000 0001 2311 2345 6784\"\n */\nexport function formatChaveNFe(chave: string): string {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) return chave;\n return raw.replace(/(\\d{4})(?=\\d)/g, \"$1 \");\n}\n"],"mappings":"AAQA,IAAaA,EAAb,cAAmC,KAAM,CACrC,YAAY,EAAiB,CACzB,MAAMC,CAAO,EACb,KAAK,KAAO,eAChB,CACJ,EA0CMC,EAAiC,CACnC,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,KACN,GAAM,IACV,EAGMC,EAAwC,CAC1C,GAAM,OACN,GAAM,OACN,GAAM,QACN,GAAM,WACN,GAAM,OACN,GAAM,QACN,GAAM,OACN,GAAM,SACV,EAGMC,EAA8C,CAChD,EAAK,SACL,EAAK,qBACL,EAAK,oBACL,EAAK,yBACL,EAAK,qBACL,EAAK,sBACL,EAAK,sBACL,EAAK,+BACT,EAGMC,EAAkB,EAIlBC,EAAe,GACfC,EAAoB,GAGpBC,EAAkB,IAGxB,SAASC,EAAO,EAAuB,CACnC,OAAOC,EAAM,QAAQ,MAAO,EAAE,CAClC,CAiBA,SAAgBC,EAAmB,EAAsB,CACrD,GAA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E,GAAI,OAAOmB,CAAQ,IAAMD,EACrB,MAAM,IAAIzB,EAAc,kBAAkByB,EAAG,eAAeC,EAAS,EAAE,EAG3E,IAAMC,EAAST,EAAI,MAAM,GAAI,EAAE,EACzBU,EAAcV,EAAI,MAAM,GAAI,EAAE,EACpC,MAAO,CACH,KACA,MACA,SACA,IAAKV,EAAkB,OAAOe,EAAO,MAAM,EAAG,CAAC,CAAC,EAChD,MACA,KAAML,EAAI,MAAM,EAAG,EAAE,EACrB,SACA,YAAaf,EAAcwB,IAAW,KACtC,MAAOT,EAAI,MAAM,GAAI,EAAE,EACvB,OAAQA,EAAI,MAAM,GAAI,EAAE,EACxB,cACA,iBAAkBd,EAAoBwB,IAAgB,KACtD,eAAgBV,EAAI,MAAM,GAAI,EAAE,EAChC,IACJ,CACJ,CAaA,SAAgBW,EAAe,EAAuB,CAClD,IAAMX,EAAMT,EAAOU,CAAK,EAExB,OADID,EAAI,SAAWZ,EACZY,EAAI,QAAQ,iBAAkB,KAAK,EADFC,CAE5C,C"}
|
package/dist/br/nfe.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nfe.js","names":[],"sources":["../../src/br/nfe.ts"],"sourcesContent":["import type { UF } from \"./locations\";\n\n/**\n * A 44-digit fiscal access key could not be read.\n *\n * Its own class so a scanner screen can tell a bad key apart from a bug and show\n * the message to the operator unchanged.\n */\nexport class ChaveNFeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ChaveNFeError\";\n }\n}\n\n/** A fiscal access key taken apart. */\nexport interface ChaveNFe {\n /** Federative unit of the issuer, resolved from {@link cUF}. */\n uf: UF;\n /** The raw 2-digit IBGE code, positions 1-2. */\n cUF: string;\n /** Positions 3-6, `AAMM` — the two-digit year and the month of issue. */\n anoMes: string;\n /** Four-digit year derived from {@link anoMes}. */\n ano: number;\n /** Month of issue, 1-12. */\n mes: number;\n /** Positions 7-20, the issuer's CNPJ. */\n cnpj: string;\n /** Positions 21-22, `mod`. `\"55\"` is an NF-e, `\"65\"` an NFC-e. */\n modelo: string;\n /** Human label for {@link modelo}, or `null` for a model outside the table. */\n modeloLabel: string | null;\n /** Positions 23-25. */\n serie: string;\n /** Positions 26-34, `nNF`. */\n numero: string;\n /** Position 35, `tpEmis`. */\n tipoEmissao: string;\n /** Human label for {@link tipoEmissao}, or `null` for a value outside the table. */\n tipoEmissaoLabel: string | null;\n /** Positions 36-43, `cNF` — the issuer's random code. */\n codigoNumerico: string;\n /** Position 44, `cDV`. */\n dv: string;\n}\n\n/**\n * IBGE code of each federative unit, as `cUF` carries it.\n *\n * Only the numeric codes live here — the acronyms are the `UF` union from\n * `./locations`, so a state added or renamed there flows through. Ported from the\n * IBGE table of \"códigos dos municípios\" (the two leading digits of every\n * municipality code), which is the same table the NF-e manual points at.\n */\nconst UF_BY_CODE: Record<string, UF> = {\n \"11\": \"RO\",\n \"12\": \"AC\",\n \"13\": \"AM\",\n \"14\": \"RR\",\n \"15\": \"PA\",\n \"16\": \"AP\",\n \"17\": \"TO\",\n \"21\": \"MA\",\n \"22\": \"PI\",\n \"23\": \"CE\",\n \"24\": \"RN\",\n \"25\": \"PB\",\n \"26\": \"PE\",\n \"27\": \"AL\",\n \"28\": \"SE\",\n \"29\": \"BA\",\n \"31\": \"MG\",\n \"32\": \"ES\",\n \"33\": \"RJ\",\n \"35\": \"SP\",\n \"41\": \"PR\",\n \"42\": \"SC\",\n \"43\": \"RS\",\n \"50\": \"MS\",\n \"51\": \"MT\",\n \"52\": \"GO\",\n \"53\": \"DF\",\n};\n\n/** The document models that share the 44-digit key layout. */\nconst MODELO_LABELS: Record<string, string> = {\n \"55\": \"NF-e\",\n \"57\": \"CT-e\",\n \"58\": \"MDF-e\",\n \"59\": \"SAT-CF-e\",\n \"63\": \"BP-e\",\n \"65\": \"NFC-e\",\n \"66\": \"NF3e\",\n \"67\": \"CT-e OS\",\n};\n\n/** `tpEmis` values from the NF-e manual. */\nconst TIPO_EMISSAO_LABELS: Record<string, string> = {\n \"1\": \"Normal\",\n \"2\": \"Contingência FS-IA\",\n \"3\": \"Contingência SCAN\",\n \"4\": \"Contingência DPEC/EPEC\",\n \"5\": \"Contingência FS-DA\",\n \"6\": \"Contingência SVC-AN\",\n \"7\": \"Contingência SVC-RS\",\n \"9\": \"Contingência off-line (NFC-e)\",\n};\n\n/** Weight cycle of the módulo 11 check digit, applied right to left. */\nconst DV_WEIGHT_FIRST = 2;\nconst DV_WEIGHT_LAST = 9;\n\n/** Length of the key, and of the body the check digit protects. */\nconst CHAVE_LENGTH = 44;\nconst CHAVE_BODY_LENGTH = 43;\n\n/** Century the two-digit `AAMM` year resolves into. NF-e went live in 2006. */\nconst CHAVE_YEAR_BASE = 2000;\n\n/** Digits of a key that may carry spaces or dots from a copy-paste. */\nfunction digits(value: string): string {\n return value.replace(/\\D/g, \"\");\n}\n\n/**\n * The check digit a 43-digit key body requires.\n *\n * Módulo 11: each digit is multiplied by weights cycling `2…9` from right to\n * left, the products are summed, and the digit is `11 - (sum mod 11)` — except\n * that a remainder of `0` or `1` yields `0`, since `11` and `10` do not fit one\n * position.\n *\n * Note this is the **fiscal** flavour of módulo 11. The cobrança boleto resolves\n * those same remainders to `1`; see `mod11DacCobranca` in `./boleto`.\n *\n * @param body - The first 43 digits of the key.\n * @returns The check digit, 0-9.\n * @throws {ChaveNFeError} When `body` is not exactly 43 digits.\n */\nexport function chaveNFeCheckDigit(body: string): number {\n if (!new RegExp(`^\\\\d{${CHAVE_BODY_LENGTH}}$`).test(body)) {\n throw new ChaveNFeError(\n `The check digit is computed over ${CHAVE_BODY_LENGTH} digits, got ${body.length}.`,\n );\n }\n const span = DV_WEIGHT_LAST - DV_WEIGHT_FIRST + 1;\n let sum = 0;\n for (let index = 0; index < body.length; index += 1) {\n const fromRight = body.length - 1 - index;\n sum += Number(body[index]) * (DV_WEIGHT_FIRST + (fromRight % span));\n }\n const remainder = sum % 11;\n return remainder === 0 || remainder === 1 ? 0 : 11 - remainder;\n}\n\n/**\n * Whether a fiscal access key is well formed.\n *\n * Three things have to hold: 44 digits, a `cUF` that is a real federative unit,\n * and a check digit that recomputes. It says nothing about whether the document\n * exists or was authorised — only SEFAZ can answer that — but it catches the\n * failure that actually happens, a key transcribed by hand or truncated by a\n * spreadsheet.\n *\n * @param chave - The key, with or without the spaces a DANFE prints.\n * @returns `true` when all three hold.\n *\n * @example\n * if (!validateChaveNFe(input)) setError(\"Chave inválida.\");\n */\nexport function validateChaveNFe(chave: string): boolean {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) return false;\n if (UF_BY_CODE[raw.slice(0, 2)] === undefined) return false;\n return String(chaveNFeCheckDigit(raw.slice(0, CHAVE_BODY_LENGTH))) === raw.slice(43);\n}\n\n/**\n * Read a 44-digit fiscal access key into its fields.\n *\n * The layout is fixed and shared by every document type that carries a key —\n * NF-e, NFC-e, CT-e, MDF-e — so `modelo` is what tells you which one you are\n * holding, not the length.\n *\n * ```text\n * 35 2601 12345678000195 55 001 000000123 1 12345678 4\n * cUF AAMM CNPJ mod série nNF tp cNF cDV\n * ```\n *\n * @param chave - The key, with or without the spaces a DANFE prints.\n * @returns The parsed key.\n * @throws {ChaveNFeError} On a length other than 44, an unknown `cUF`, a month\n * outside 1-12, or a check digit that does not recompute.\n *\n * @example\n * const { uf, cnpj, numero, modeloLabel } = parseChaveNFe(scanned);\n */\nexport function parseChaveNFe(chave: string): ChaveNFe {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) {\n throw new ChaveNFeError(`An access key has ${CHAVE_LENGTH} digits, got ${raw.length}.`);\n }\n\n const cUF = raw.slice(0, 2);\n const uf = UF_BY_CODE[cUF];\n if (uf === undefined) {\n throw new ChaveNFeError(`${cUF} is not an IBGE code for a federative unit.`);\n }\n\n const anoMes = raw.slice(2, 6);\n const mes = Number(anoMes.slice(2, 4));\n if (mes < 1 || mes > 12) {\n throw new ChaveNFeError(`Month ${anoMes.slice(2, 4)} in AAMM is not a month.`);\n }\n\n const dv = raw.slice(43);\n const expected = chaveNFeCheckDigit(raw.slice(0, CHAVE_BODY_LENGTH));\n if (String(expected) !== dv) {\n throw new ChaveNFeError(`Check digit is ${dv}, recomputed ${expected}.`);\n }\n\n const modelo = raw.slice(20, 22);\n const tipoEmissao = raw.slice(34, 35);\n return {\n uf,\n cUF,\n anoMes,\n ano: CHAVE_YEAR_BASE + Number(anoMes.slice(0, 2)),\n mes,\n cnpj: raw.slice(6, 20),\n modelo,\n modeloLabel: MODELO_LABELS[modelo] ?? null,\n serie: raw.slice(22, 25),\n numero: raw.slice(25, 34),\n tipoEmissao,\n tipoEmissaoLabel: TIPO_EMISSAO_LABELS[tipoEmissao] ?? null,\n codigoNumerico: raw.slice(35, 43),\n dv,\n };\n}\n\n/**\n * Group a key in blocks of four, the way a DANFE prints it.\n *\n * @param chave - The key, masked or not.\n * @returns Eleven groups of four digits separated by spaces, or the input\n * unchanged when it is not 44 digits — this is a display helper, not a validator.\n *\n * @example\n * formatChaveNFe(\"35260112345678000195550010000001231123456784\");\n * // \"3526 0112 3456 7800 0195 5500 1000 0001 2311 2345 6784\"\n */\nexport function formatChaveNFe(chave: string): string {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) return chave;\n return raw.replace(/(\\d{4})(?=\\d)/g, \"$1 \");\n}\n"],"mappings":";AAQA,IAAa,IAAb,cAAmC,MAAM;CACrC,YAAY,GAAiB;EAEzB,AADA,MAAM,CAAO,GACb,KAAK,OAAO;CAChB;AACJ,GA0CM,IAAiC;CACnC,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;CACN,IAAM;AACV,GAGM,IAAw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CAG/E,IAAM,IAAS,EAAI,MAAM,GAAG,CAAC,GACvB,IAAM,OAAO,EAAO,MAAM,GAAG,CAAC,CAAC;CACrC,IAAI,IAAM,KAAK,IAAM,IACjB,MAAM,IAAI,EAAc,SAAS,EAAO,MAAM,GAAG,CAAC,EAAE,yBAAyB;CAGjF,IAAM,IAAK,EAAI,MAAM,EAAE,GACjB,IAAW,EAAmB,EAAI,MAAM,GAAG,CAAiB,CAAC;CACnE,IAAI,OAAO,CAAQ,MAAM,GACrB,MAAM,IAAI,EAAc,kBAAkB,EAAG,eAAe,EAAS,EAAE;CAG3E,IAAM,IAAS,EAAI,MAAM,IAAI,EAAE,GACzB,IAAc,EAAI,MAAM,IAAI,EAAE;CACpC,OAAO;EACH;EACA;EACA;EACA,KAAK,IAAkB,OAAO,EAAO,MAAM,GAAG,CAAC,CAAC;EAChD;EACA,MAAM,EAAI,MAAM,GAAG,EAAE;EACrB;EACA,aAAa,EAAc,MAAW;EACtC,OAAO,EAAI,MAAM,IAAI,EAAE;EACvB,QAAQ,EAAI,MAAM,IAAI,EAAE;EACxB;EACA,kBAAkB,EAAoB,MAAgB;EACtD,gBAAgB,EAAI,MAAM,IAAI,EAAE;EAChC;CACJ;AACJ;AAaA,SAAgB,EAAe,GAAuB;CAClD,IAAM,IAAM,EAAO,CAAK;CAExB,OADI,EAAI,WAAW,IACZ,EAAI,QAAQ,kBAAkB,KAAK,IADF;AAE5C"}
|
|
1
|
+
{"version":3,"file":"nfe.js","names":["ChaveNFeError","message","UF_BY_CODE","MODELO_LABELS","TIPO_EMISSAO_LABELS","DV_WEIGHT_FIRST","CHAVE_LENGTH","CHAVE_BODY_LENGTH","CHAVE_YEAR_BASE","digits","value","chaveNFeCheckDigit","body","sum","index","fromRight","remainder","validateChaveNFe","raw","chave","parseChaveNFe","cUF","uf","anoMes","mes","dv","expected","modelo","tipoEmissao","formatChaveNFe"],"sources":["../../src/br/nfe.ts"],"sourcesContent":["import type { UF } from \"./locations\";\n\n/**\n * A 44-digit fiscal access key could not be read.\n *\n * Its own class so a scanner screen can tell a bad key apart from a bug and show\n * the message to the operator unchanged.\n */\nexport class ChaveNFeError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ChaveNFeError\";\n }\n}\n\n/** A fiscal access key taken apart. */\nexport interface ChaveNFe {\n /** Federative unit of the issuer, resolved from {@link cUF}. */\n uf: UF;\n /** The raw 2-digit IBGE code, positions 1-2. */\n cUF: string;\n /** Positions 3-6, `AAMM` — the two-digit year and the month of issue. */\n anoMes: string;\n /** Four-digit year derived from {@link anoMes}. */\n ano: number;\n /** Month of issue, 1-12. */\n mes: number;\n /** Positions 7-20, the issuer's CNPJ. */\n cnpj: string;\n /** Positions 21-22, `mod`. `\"55\"` is an NF-e, `\"65\"` an NFC-e. */\n modelo: string;\n /** Human label for {@link modelo}, or `null` for a model outside the table. */\n modeloLabel: string | null;\n /** Positions 23-25. */\n serie: string;\n /** Positions 26-34, `nNF`. */\n numero: string;\n /** Position 35, `tpEmis`. */\n tipoEmissao: string;\n /** Human label for {@link tipoEmissao}, or `null` for a value outside the table. */\n tipoEmissaoLabel: string | null;\n /** Positions 36-43, `cNF` — the issuer's random code. */\n codigoNumerico: string;\n /** Position 44, `cDV`. */\n dv: string;\n}\n\n/**\n * IBGE code of each federative unit, as `cUF` carries it.\n *\n * Only the numeric codes live here — the acronyms are the `UF` union from\n * `./locations`, so a state added or renamed there flows through. Ported from the\n * IBGE table of \"códigos dos municípios\" (the two leading digits of every\n * municipality code), which is the same table the NF-e manual points at.\n */\nconst UF_BY_CODE: Record<string, UF> = {\n \"11\": \"RO\",\n \"12\": \"AC\",\n \"13\": \"AM\",\n \"14\": \"RR\",\n \"15\": \"PA\",\n \"16\": \"AP\",\n \"17\": \"TO\",\n \"21\": \"MA\",\n \"22\": \"PI\",\n \"23\": \"CE\",\n \"24\": \"RN\",\n \"25\": \"PB\",\n \"26\": \"PE\",\n \"27\": \"AL\",\n \"28\": \"SE\",\n \"29\": \"BA\",\n \"31\": \"MG\",\n \"32\": \"ES\",\n \"33\": \"RJ\",\n \"35\": \"SP\",\n \"41\": \"PR\",\n \"42\": \"SC\",\n \"43\": \"RS\",\n \"50\": \"MS\",\n \"51\": \"MT\",\n \"52\": \"GO\",\n \"53\": \"DF\",\n};\n\n/** The document models that share the 44-digit key layout. */\nconst MODELO_LABELS: Record<string, string> = {\n \"55\": \"NF-e\",\n \"57\": \"CT-e\",\n \"58\": \"MDF-e\",\n \"59\": \"SAT-CF-e\",\n \"63\": \"BP-e\",\n \"65\": \"NFC-e\",\n \"66\": \"NF3e\",\n \"67\": \"CT-e OS\",\n};\n\n/** `tpEmis` values from the NF-e manual. */\nconst TIPO_EMISSAO_LABELS: Record<string, string> = {\n \"1\": \"Normal\",\n \"2\": \"Contingência FS-IA\",\n \"3\": \"Contingência SCAN\",\n \"4\": \"Contingência DPEC/EPEC\",\n \"5\": \"Contingência FS-DA\",\n \"6\": \"Contingência SVC-AN\",\n \"7\": \"Contingência SVC-RS\",\n \"9\": \"Contingência off-line (NFC-e)\",\n};\n\n/** Weight cycle of the módulo 11 check digit, applied right to left. */\nconst DV_WEIGHT_FIRST = 2;\nconst DV_WEIGHT_LAST = 9;\n\n/** Length of the key, and of the body the check digit protects. */\nconst CHAVE_LENGTH = 44;\nconst CHAVE_BODY_LENGTH = 43;\n\n/** Century the two-digit `AAMM` year resolves into. NF-e went live in 2006. */\nconst CHAVE_YEAR_BASE = 2000;\n\n/** Digits of a key that may carry spaces or dots from a copy-paste. */\nfunction digits(value: string): string {\n return value.replace(/\\D/g, \"\");\n}\n\n/**\n * The check digit a 43-digit key body requires.\n *\n * Módulo 11: each digit is multiplied by weights cycling `2…9` from right to\n * left, the products are summed, and the digit is `11 - (sum mod 11)` — except\n * that a remainder of `0` or `1` yields `0`, since `11` and `10` do not fit one\n * position.\n *\n * Note this is the **fiscal** flavour of módulo 11. The cobrança boleto resolves\n * those same remainders to `1`; see `mod11DacCobranca` in `./boleto`.\n *\n * @param body - The first 43 digits of the key.\n * @returns The check digit, 0-9.\n * @throws {ChaveNFeError} When `body` is not exactly 43 digits.\n */\nexport function chaveNFeCheckDigit(body: string): number {\n if (!new RegExp(`^\\\\d{${CHAVE_BODY_LENGTH}}$`).test(body)) {\n throw new ChaveNFeError(\n `The check digit is computed over ${CHAVE_BODY_LENGTH} digits, got ${body.length}.`,\n );\n }\n const span = DV_WEIGHT_LAST - DV_WEIGHT_FIRST + 1;\n let sum = 0;\n for (let index = 0; index < body.length; index += 1) {\n const fromRight = body.length - 1 - index;\n sum += Number(body[index]) * (DV_WEIGHT_FIRST + (fromRight % span));\n }\n const remainder = sum % 11;\n return remainder === 0 || remainder === 1 ? 0 : 11 - remainder;\n}\n\n/**\n * Whether a fiscal access key is well formed.\n *\n * Three things have to hold: 44 digits, a `cUF` that is a real federative unit,\n * and a check digit that recomputes. It says nothing about whether the document\n * exists or was authorised — only SEFAZ can answer that — but it catches the\n * failure that actually happens, a key transcribed by hand or truncated by a\n * spreadsheet.\n *\n * @param chave - The key, with or without the spaces a DANFE prints.\n * @returns `true` when all three hold.\n *\n * @example\n * if (!validateChaveNFe(input)) setError(\"Chave inválida.\");\n */\nexport function validateChaveNFe(chave: string): boolean {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) return false;\n if (UF_BY_CODE[raw.slice(0, 2)] === undefined) return false;\n return String(chaveNFeCheckDigit(raw.slice(0, CHAVE_BODY_LENGTH))) === raw.slice(43);\n}\n\n/**\n * Read a 44-digit fiscal access key into its fields.\n *\n * The layout is fixed and shared by every document type that carries a key —\n * NF-e, NFC-e, CT-e, MDF-e — so `modelo` is what tells you which one you are\n * holding, not the length.\n *\n * ```text\n * 35 2601 12345678000195 55 001 000000123 1 12345678 4\n * cUF AAMM CNPJ mod série nNF tp cNF cDV\n * ```\n *\n * @param chave - The key, with or without the spaces a DANFE prints.\n * @returns The parsed key.\n * @throws {ChaveNFeError} On a length other than 44, an unknown `cUF`, a month\n * outside 1-12, or a check digit that does not recompute.\n *\n * @example\n * const { uf, cnpj, numero, modeloLabel } = parseChaveNFe(scanned);\n */\nexport function parseChaveNFe(chave: string): ChaveNFe {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) {\n throw new ChaveNFeError(`An access key has ${CHAVE_LENGTH} digits, got ${raw.length}.`);\n }\n\n const cUF = raw.slice(0, 2);\n const uf = UF_BY_CODE[cUF];\n if (uf === undefined) {\n throw new ChaveNFeError(`${cUF} is not an IBGE code for a federative unit.`);\n }\n\n const anoMes = raw.slice(2, 6);\n const mes = Number(anoMes.slice(2, 4));\n if (mes < 1 || mes > 12) {\n throw new ChaveNFeError(`Month ${anoMes.slice(2, 4)} in AAMM is not a month.`);\n }\n\n const dv = raw.slice(43);\n const expected = chaveNFeCheckDigit(raw.slice(0, CHAVE_BODY_LENGTH));\n if (String(expected) !== dv) {\n throw new ChaveNFeError(`Check digit is ${dv}, recomputed ${expected}.`);\n }\n\n const modelo = raw.slice(20, 22);\n const tipoEmissao = raw.slice(34, 35);\n return {\n uf,\n cUF,\n anoMes,\n ano: CHAVE_YEAR_BASE + Number(anoMes.slice(0, 2)),\n mes,\n cnpj: raw.slice(6, 20),\n modelo,\n modeloLabel: MODELO_LABELS[modelo] ?? null,\n serie: raw.slice(22, 25),\n numero: raw.slice(25, 34),\n tipoEmissao,\n tipoEmissaoLabel: TIPO_EMISSAO_LABELS[tipoEmissao] ?? null,\n codigoNumerico: raw.slice(35, 43),\n dv,\n };\n}\n\n/**\n * Group a key in blocks of four, the way a DANFE prints it.\n *\n * @param chave - The key, masked or not.\n * @returns Eleven groups of four digits separated by spaces, or the input\n * unchanged when it is not 44 digits — this is a display helper, not a validator.\n *\n * @example\n * formatChaveNFe(\"35260112345678000195550010000001231123456784\");\n * // \"3526 0112 3456 7800 0195 5500 1000 0001 2311 2345 6784\"\n */\nexport function formatChaveNFe(chave: string): string {\n const raw = digits(chave);\n if (raw.length !== CHAVE_LENGTH) return chave;\n return raw.replace(/(\\d{4})(?=\\d)/g, \"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EACxB;EACA,kBAAkBd,EAAoBwB,MAAgB;EACtD,gBAAgBV,EAAI,MAAM,IAAI,EAAE;EAChC;CACJ;AACJ;AAaA,SAAgBW,EAAe,GAAuB;CAClD,IAAMX,IAAMT,EAAOU,CAAK;CAExB,OADID,EAAI,WAAWZ,IACZY,EAAI,QAAQ,kBAAkB,KAAK,IADFC;AAE5C"}
|
package/dist/br/pix.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const e=require("../forms/br-validators.cjs");var t=class extends Error{constructor(e){super(e),this.name=`PixError`}},n=4129,r=65535,i=65535,a=`00`,o=`01`,s=`26`,c=`52`,l=`53`,u=`54`,d=`58`,f=`59`,p=`60`,m=`61`,h=`62`,g=`63`,_=`
|
|
1
|
+
const e=require("../forms/br-validators.cjs");var t=class extends Error{constructor(e){super(e),this.name=`PixError`}},n=4129,r=65535,i=65535,a=`00`,o=`01`,s=`26`,c=`52`,l=`53`,u=`54`,d=`58`,f=`59`,p=`60`,m=`61`,h=`62`,g=`63`,_=`64`,v=80,y=`00`,b=`01`,x=`02`,S=`25`,C=`05`,w=`br.gov.bcb.pix`,T=`01`,E=`11`,D=`12`,O=`0000`,k=`986`,A=`BR`,j=`***`,M=25,N=15,P=25,F=99,I=77,L=/^\d+(?:\.\d{0,2})?$/,R=13;function z(e){let t=new TextEncoder().encode(e),a=r;for(let e of t){a^=e<<8;for(let e=0;e<8;e+=1)a=a&32768?(a<<1^n)&i:a<<1&i}return a.toString(16).toUpperCase().padStart(4,`0`)}function B(e){return e.replace(/\D/g,``)}function V(e,n){let r=e.normalize(`NFD`).replace(/\p{Diacritic}/gu,``);if(/[^\x20-\x7E]/.test(r))throw new t(`${n} has characters the BR Code cannot carry: ${JSON.stringify(e)}. Use unaccented ASCII.`);return r}var H=/^[\x20-\x7E]*$/;function U(e,n){if(!H.test(n))throw new t(`Tag ${e} has characters outside the EMV common character set (printable ASCII): ${JSON.stringify(n)}.`);if(n.length>F)throw new t(`Tag ${e} is ${n.length} characters; the EMV length field holds at most ${F}.`);return`${e}${String(n.length).padStart(2,`0`)}${n}`}function W(t){let n=t.trim();if(n===``)return null;if(n.includes(`@`))return/^[^\s@]+@[^\s@]+\.[^\s@]{2,}$/.test(n)&&n.length<=I?`email`:null;if(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(n))return`evp`;let r=B(n);return r.length===14?e.validateCNPJ(r)?`cnpj`:null:r.length===11&&e.validateCPF(r)?`cpf`:n.startsWith(`+`)?/^\+55\d{10,11}$/.test(`+${r}`)?`phone`:null:r.length===10||r.length===11||(r.length===12||r.length===13)&&r.startsWith(`55`)?`phone`:null}function G(e){let n=e.trim(),r=W(n);if(r===null)throw new t(`Not a Pix key: ${JSON.stringify(e)}. Expected a CPF, CNPJ, e-mail, phone (+5511987654321) or EVP (UUID).`);if(r===`email`||r===`evp`)return{type:r,value:n.toLowerCase()};if(r===`phone`){let e=B(n);return{type:r,value:`+55${e.length>11?e.slice(2):e}`}}return{type:r,value:B(n)}}function K(e){if(!Number.isFinite(e))throw new t(`Amount must be a finite number, got ${e}.`);if(e<=0)throw new t(`Amount must be positive, got ${e}. Omit \`amount\` for a QR whose value the payer types.`);let n=e.toFixed(2);if(Number(n)<=0)throw new t(`Amount ${e} rounds to ${n} at two decimals. Omit \`amount\` for a QR whose value the payer types.`);if(n.length>13)throw new t(`Amount ${n} does not fit tag 54, which holds 13 characters.`);return n}function q(e,n,r){let i=V(e.trim(),r);if(i===``)throw new t(`${r} is required.`);if(i.length>n)throw new t(`${r} is ${i.length} characters; the BR Code allows ${n}. Shorten it — truncating here would silently change what the payer sees.`);return i}function ee(e){let n=e?.trim()??``;if(n===``||n===j)return U(h,U(C,j));if(!RegExp(`^[A-Za-z0-9]{1,${P}}$`).test(n))throw new t(`txid must be 1 to ${P} letters or digits, got ${JSON.stringify(e)}.`);return U(h,U(C,n))}function J(e){let{value:n}=G(e.key),r=U(y,w)+U(b,n),i=e.description?.trim();if(i!==void 0&&i!==``&&(r+=U(x,V(i,`description`))),r.length>F)throw new t(`Tag 26 is ${r.length} characters, over the ${F} the length field allows. Shorten \`description\`.`);return U(s,r)}function Y(e){let n=V(e.url.trim(),`url`).replace(/^https?:\/\//i,``);if(n===``)throw new t(`url is required for a dynamic BR Code.`);let r=U(y,w)+U(S,n);if(r.length>F)throw new t(`Tag 26 is ${r.length} characters, over the ${F} the length field allows. Shorten the payload URL.`);return U(s,r)}function X(e){let t=e.kind===`dynamic`,n=e.oneTime??t,r=U(a,T);r+=U(o,n?D:E),r+=t?Y(e):J(e),r+=U(c,O),r+=U(l,k),!t&&e.amount!==void 0&&(r+=U(u,K(e.amount))),r+=U(d,A),r+=U(f,q(e.merchantName,M,`merchantName`)),r+=U(p,q(e.merchantCity,N,`merchantCity`));let i=e.postalCode===void 0?``:B(e.postalCode);i!==``&&(r+=U(m,i)),r+=ee(t?j:e.txid);let s=`${r}${g}04`;return`${s}${z(s)}`}function Z(e,n){let r=Array.from(e),i=[],a=0;for(;a<r.length;){let e=r.slice(a,a+2).join(``),o=r.slice(a+2,a+4).join(``);if(!/^\d{2}$/.test(e)||!/^\d{2}$/.test(o))throw new t(`Malformed TLV in ${n} at offset ${a}: expected a 2-digit tag and length.`);let s=Number(o),c=a+4;if(c+s>r.length)throw new t(`Tag ${e} in ${n} declares ${s} characters but only ${r.length-c} remain.`);if(i.some(t=>t.id===e))throw new t(`Tag ${e} in ${n} appears more than once; a BR Code carries each tag once per level.`);i.push({id:e,value:r.slice(c,c+s).join(``)}),a=c+s}return i}function Q(e){return e===_||Number(e)>=v}var te=[{name:`UTF-8 bytes`,width:e=>e<128?1:e<2048?2:e<65536?3:4},{name:`UTF-16 units`,width:e=>e>65535?2:1}];function ne(e,t){let n=[],r=0;for(;r<e.length;){let i=e.slice(r,r+2).join(``),a=e.slice(r+2,r+4).join(``);if(!/^\d{2}$/.test(i)||!/^\d{2}$/.test(a))return null;let o=Number(a),s=r+4;for(;o>0&&s<e.length;)o-=t(e[s]?.codePointAt(0)??0),s+=1;if(o!==0)return null;n.push({id:i,value:e.slice(r+4,s).join(``)}),r=s}return n}function re(e,n){for(let e of n)if(!Q(e.id)&&!H.test(e.value))throw new t(`Tag ${e.id} has characters outside the EMV common character set (printable ASCII): ${JSON.stringify(e.value)}. Only tag 64 and the unreserved templates 80–99 may carry other text.`);if(H.test(e))return;let r=Array.from(e);for(let e of te){let i=ne(r,e.width);if(i!==null&&JSON.stringify(i)!==JSON.stringify(n))throw new t(`Payload reads as other tags when its TLV lengths count ${e.name}: ${i.map(e=>e.id).join()}.`)}}function $(e,t){return e.find(e=>e.id===t)?.value}function ie(e){if(e.length>R||!L.test(e))throw new t(`Tag 54 (amount) must be an amount like "25.50", with "." as the decimal mark, at most two decimals and ${R} characters; got ${JSON.stringify(e)}.`);return Number(e)}function ae(e,n={}){let{requireCrc:r=!0}=n,i=e.trim();if(i.length<8)throw new t(`Payload is too short to be a BR Code.`);let _=i.length-8;if(i.slice(_,_+4)!==`${g}04`)throw new t("Payload does not end in a `6304` CRC tag.");let v=i.slice(-4).toUpperCase(),T=z(i.slice(0,-4)),E=v===T;if(!E&&r)throw new t(`CRC mismatch: payload says ${v}, recomputed ${T}.`);let O=i.slice(0,_),k=Z(O,`payload`);if(re(O,k),k[0]?.id!==a)throw new t(`Tag 00 (payload format indicator) must be the first tag of a BR Code.`);if(k.some(e=>e.id===g))throw new t(`Tag 63 (CRC) must be the last tag of a BR Code; this payload carries another one before the end.`);let A=$(k,s);if(A===void 0)throw new t(`Payload has no tag 26 (merchant account information).`);let j=Z(A,`tag 26`),M=$(j,y);if(M?.toLowerCase()!==w)throw new t(`Tag 26 is not a Pix account: expected GUI ${w}, got ${JSON.stringify(M)}.`);let N=$(j,S),P=$(j,b);if(N!==void 0&&P!==void 0)throw new t(`Tag 26 carries both a key (01) and a URL (25); a BR Code is either static or dynamic, not both.`);let F=$(k,u),I=$(Z($(k,h)??``,`tag 62`),C);return{kind:N===void 0?`static`:`dynamic`,...P===void 0?{}:{key:P,keyType:W(P)??void 0},...N===void 0?{}:{url:N},merchantName:$(k,f)??``,merchantCity:$(k,p)??``,...F===void 0?{}:{amount:ie(F)},currency:$(k,l)??``,countryCode:$(k,d)??``,merchantCategoryCode:$(k,c)??``,...I===void 0?{}:{txid:I},...$(j,x)===void 0?{}:{description:$(j,x)},...$(k,m)===void 0?{}:{postalCode:$(k,m)},oneTime:$(k,o)===D,crc:v,crcValid:E,fields:k}}exports.PixError=t,exports.normalizePixKey=G,exports.parsePixPayload=ae,exports.pixCrc16=z,exports.pixKeyType=W,exports.pixPayload=X;
|
|
2
2
|
//# sourceMappingURL=pix.cjs.map
|