@budiauktioner/buildi-primitives 0.1.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/CHANGELOG.md +51 -0
- package/LICENSE +21 -0
- package/README.md +253 -0
- package/THIRD_PARTY_NOTICES.md +52 -0
- package/dist/banking/index.cjs +6491 -0
- package/dist/banking/index.cjs.map +1 -0
- package/dist/banking/index.d.cts +58 -0
- package/dist/banking/index.d.ts +58 -0
- package/dist/banking/index.js +6464 -0
- package/dist/banking/index.js.map +1 -0
- package/dist/contact/index.cjs +6678 -0
- package/dist/contact/index.cjs.map +1 -0
- package/dist/contact/index.d.cts +709 -0
- package/dist/contact/index.d.ts +709 -0
- package/dist/contact/index.js +6586 -0
- package/dist/contact/index.js.map +1 -0
- package/dist/country-BhD51LDL.d.cts +433 -0
- package/dist/country-p0n0EVQ9.d.ts +433 -0
- package/dist/finance/index.cjs +3592 -0
- package/dist/finance/index.cjs.map +1 -0
- package/dist/finance/index.d.cts +83 -0
- package/dist/finance/index.d.ts +83 -0
- package/dist/finance/index.js +3584 -0
- package/dist/finance/index.js.map +1 -0
- package/dist/geography/index.cjs +4227 -0
- package/dist/geography/index.cjs.map +1 -0
- package/dist/geography/index.d.cts +34 -0
- package/dist/geography/index.d.ts +34 -0
- package/dist/geography/index.js +4202 -0
- package/dist/geography/index.js.map +1 -0
- package/dist/index.cjs +14087 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +75 -0
- package/dist/index.d.ts +75 -0
- package/dist/index.js +13868 -0
- package/dist/index.js.map +1 -0
- package/dist/isin-EeVPpNWu.d.ts +39 -0
- package/dist/isin-ZlQLBVm8.d.cts +39 -0
- package/dist/organization/index.cjs +2376 -0
- package/dist/organization/index.cjs.map +1 -0
- package/dist/organization/index.d.cts +117 -0
- package/dist/organization/index.d.ts +117 -0
- package/dist/organization/index.js +2346 -0
- package/dist/organization/index.js.map +1 -0
- package/dist/person/index.cjs +1144 -0
- package/dist/person/index.cjs.map +1 -0
- package/dist/person/index.d.cts +60 -0
- package/dist/person/index.d.ts +60 -0
- package/dist/person/index.js +1125 -0
- package/dist/person/index.js.map +1 -0
- package/dist/person-full-name-Cmc9Ynuc.d.cts +82 -0
- package/dist/person-full-name-D6Hbsab6.d.ts +82 -0
- package/dist/phone-number-C24--ggy.d.ts +139 -0
- package/dist/phone-number-DZ-YxCQQ.d.cts +139 -0
- package/dist/property/index.cjs +487 -0
- package/dist/property/index.cjs.map +1 -0
- package/dist/property/index.d.cts +56 -0
- package/dist/property/index.d.ts +56 -0
- package/dist/property/index.js +480 -0
- package/dist/property/index.js.map +1 -0
- package/dist/sample-data/index.cjs +12310 -0
- package/dist/sample-data/index.cjs.map +1 -0
- package/dist/sample-data/index.d.cts +260 -0
- package/dist/sample-data/index.d.ts +260 -0
- package/dist/sample-data/index.js +12302 -0
- package/dist/sample-data/index.js.map +1 -0
- package/dist/swedish-address-DNC3ftRF.d.cts +297 -0
- package/dist/swedish-address-GMzjqgxb.d.ts +297 -0
- package/dist/swedish-bank-account-holder-name-BFJ8h1aO.d.cts +45 -0
- package/dist/swedish-bank-account-holder-name-CAAru07F.d.ts +45 -0
- package/dist/swedish-municipality-DlUS7g7h.d.cts +87 -0
- package/dist/swedish-municipality-nDRHYRAd.d.ts +87 -0
- package/dist/swedish-organization-name-D7NvERxA.d.cts +33 -0
- package/dist/swedish-organization-name-rR0Q836C.d.ts +33 -0
- package/dist/swedish-organization-number-Bcj7V_lh.d.cts +130 -0
- package/dist/swedish-organization-number-DM8dpXwR.d.ts +130 -0
- package/dist/swedish-organization-type-CZOdETwG.d.cts +29 -0
- package/dist/swedish-organization-type-CZOdETwG.d.ts +29 -0
- package/dist/swedish-personal-identity-number-BiIg4io3.d.ts +149 -0
- package/dist/swedish-personal-identity-number-Cp9Coz55.d.cts +149 -0
- package/dist/swedish-property-designation-BM-gdd9x.d.ts +46 -0
- package/dist/swedish-property-designation-BaHXufqV.d.cts +46 -0
- package/dist/swedish-sni-code-Ccsswpni.d.ts +53 -0
- package/dist/swedish-sni-code-CuJFyM6l.d.cts +53 -0
- package/dist/swedish-swish-number-CL6Gx_h3.d.cts +397 -0
- package/dist/swedish-swish-number-DDG3mNDg.d.ts +397 -0
- package/dist/text-candidate-qg2bD9PY.d.cts +110 -0
- package/dist/text-candidate-qg2bD9PY.d.ts +110 -0
- package/dist/text-scanning/index.cjs +10414 -0
- package/dist/text-scanning/index.cjs.map +1 -0
- package/dist/text-scanning/index.d.cts +153 -0
- package/dist/text-scanning/index.d.ts +153 -0
- package/dist/text-scanning/index.js +10406 -0
- package/dist/text-scanning/index.js.map +1 -0
- package/dist/validation/index.cjs +83 -0
- package/dist/validation/index.cjs.map +1 -0
- package/dist/validation/index.d.cts +63 -0
- package/dist/validation/index.d.ts +63 -0
- package/dist/validation/index.js +79 -0
- package/dist/validation/index.js.map +1 -0
- package/dist/web/index.cjs +3994 -0
- package/dist/web/index.cjs.map +1 -0
- package/dist/web/index.d.cts +203 -0
- package/dist/web/index.d.ts +203 -0
- package/dist/web/index.js +3987 -0
- package/dist/web/index.js.map +1 -0
- package/package.json +211 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { P as PrimitiveTypeInfo, T as TextCandidate } from './text-candidate-qg2bD9PY.cjs';
|
|
2
|
+
import { a as Country } from './country-BhD51LDL.cjs';
|
|
3
|
+
|
|
4
|
+
/** A phone country calling code (`landsnummer`) e.g. `+46` for Sweden. */
|
|
5
|
+
declare class PhoneCallingCode {
|
|
6
|
+
static readonly typeInfo: PrimitiveTypeInfo;
|
|
7
|
+
readonly value: string;
|
|
8
|
+
readonly countryCode: string | null;
|
|
9
|
+
private constructor();
|
|
10
|
+
/** @internal */
|
|
11
|
+
static _new(value: string, countryCode: string | null): PhoneCallingCode;
|
|
12
|
+
/** @internal */
|
|
13
|
+
static fromResolvedDigits(digits: string): PhoneCallingCode;
|
|
14
|
+
static tryParse(input: string | null | undefined): PhoneCallingCode | null;
|
|
15
|
+
static parse(input: string): PhoneCallingCode;
|
|
16
|
+
static isValid(input: string | null | undefined): boolean;
|
|
17
|
+
static format(input: string | null | undefined, options?: {
|
|
18
|
+
fallbackToTrimmedInputWhenInvalid?: boolean;
|
|
19
|
+
}): string | null;
|
|
20
|
+
static normalize(input: string | null | undefined, options?: {
|
|
21
|
+
fallbackToTrimmedInputWhenInvalid?: boolean;
|
|
22
|
+
}): string | null;
|
|
23
|
+
static isNormalized(input: string | null | undefined): boolean;
|
|
24
|
+
static get all(): readonly PhoneCallingCode[];
|
|
25
|
+
toNormalizedString(): string;
|
|
26
|
+
toString(): string;
|
|
27
|
+
equals(other: PhoneCallingCode | null | undefined): boolean;
|
|
28
|
+
compareTo(other: PhoneCallingCode | null | undefined): number;
|
|
29
|
+
/** Sweden (+46). */
|
|
30
|
+
static get Sweden(): PhoneCallingCode;
|
|
31
|
+
/** Norway (+47). */
|
|
32
|
+
static get Norway(): PhoneCallingCode;
|
|
33
|
+
/** Finland (+358). */
|
|
34
|
+
static get Finland(): PhoneCallingCode;
|
|
35
|
+
/** Denmark (+45). */
|
|
36
|
+
static get Denmark(): PhoneCallingCode;
|
|
37
|
+
/** Germany (+49). */
|
|
38
|
+
static get Germany(): PhoneCallingCode;
|
|
39
|
+
/** Poland (+48). */
|
|
40
|
+
static get Poland(): PhoneCallingCode;
|
|
41
|
+
/** Estonia (+372). */
|
|
42
|
+
static get Estonia(): PhoneCallingCode;
|
|
43
|
+
/** Lithuania (+370). */
|
|
44
|
+
static get Lithuania(): PhoneCallingCode;
|
|
45
|
+
/** Romania (+40). */
|
|
46
|
+
static get Romania(): PhoneCallingCode;
|
|
47
|
+
/** Bulgaria (+359). */
|
|
48
|
+
static get Bulgaria(): PhoneCallingCode;
|
|
49
|
+
/** Latvia (+371). */
|
|
50
|
+
static get Latvia(): PhoneCallingCode;
|
|
51
|
+
/** Czech Republic (+420). */
|
|
52
|
+
static get CzechRepublic(): PhoneCallingCode;
|
|
53
|
+
/** Spain (+34). */
|
|
54
|
+
static get Spain(): PhoneCallingCode;
|
|
55
|
+
/** Netherlands (+31). */
|
|
56
|
+
static get Netherlands(): PhoneCallingCode;
|
|
57
|
+
/** Greece (+30). */
|
|
58
|
+
static get Greece(): PhoneCallingCode;
|
|
59
|
+
/** Italy (+39). */
|
|
60
|
+
static get Italy(): PhoneCallingCode;
|
|
61
|
+
/** Slovenia (+386). */
|
|
62
|
+
static get Slovenia(): PhoneCallingCode;
|
|
63
|
+
/** Croatia (+385). */
|
|
64
|
+
static get Croatia(): PhoneCallingCode;
|
|
65
|
+
/** Portugal (+351). */
|
|
66
|
+
static get Portugal(): PhoneCallingCode;
|
|
67
|
+
/** Hungary (+36). */
|
|
68
|
+
static get Hungary(): PhoneCallingCode;
|
|
69
|
+
/** France (+33). */
|
|
70
|
+
static get France(): PhoneCallingCode;
|
|
71
|
+
/** Slovakia (+421). */
|
|
72
|
+
static get Slovakia(): PhoneCallingCode;
|
|
73
|
+
/** Belgium (+32). */
|
|
74
|
+
static get Belgium(): PhoneCallingCode;
|
|
75
|
+
/** United Kingdom (+44). */
|
|
76
|
+
static get UnitedKingdom(): PhoneCallingCode;
|
|
77
|
+
/** Austria (+43). */
|
|
78
|
+
static get Austria(): PhoneCallingCode;
|
|
79
|
+
/** Cyprus (+357). */
|
|
80
|
+
static get Cyprus(): PhoneCallingCode;
|
|
81
|
+
/** Iceland (+354). */
|
|
82
|
+
static get Iceland(): PhoneCallingCode;
|
|
83
|
+
/** Switzerland (+41). */
|
|
84
|
+
static get Switzerland(): PhoneCallingCode;
|
|
85
|
+
/** Ireland (+353). */
|
|
86
|
+
static get Ireland(): PhoneCallingCode;
|
|
87
|
+
/** Luxembourg (+352). */
|
|
88
|
+
static get Luxembourg(): PhoneCallingCode;
|
|
89
|
+
/** Malta (+356). */
|
|
90
|
+
static get Malta(): PhoneCallingCode;
|
|
91
|
+
/** Liechtenstein (+423). */
|
|
92
|
+
static get Liechtenstein(): PhoneCallingCode;
|
|
93
|
+
/** United States (+1). */
|
|
94
|
+
static get UnitedStates(): PhoneCallingCode;
|
|
95
|
+
/** Russia (+7). */
|
|
96
|
+
static get Russia(): PhoneCallingCode;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* A phone number (`telefonnummer`). Stored normalized as `00` + country code +
|
|
101
|
+
* subscriber digits (e.g. `0046701740633`). Use {@link toE164String} for the
|
|
102
|
+
* `+`-prefixed E.164 form.
|
|
103
|
+
*/
|
|
104
|
+
declare class PhoneNumber {
|
|
105
|
+
static readonly typeInfo: PrimitiveTypeInfo;
|
|
106
|
+
readonly digits: string;
|
|
107
|
+
readonly countryCallingCode: PhoneCallingCode;
|
|
108
|
+
readonly country: Country | null;
|
|
109
|
+
readonly isSwedish: boolean;
|
|
110
|
+
readonly isMobile: boolean;
|
|
111
|
+
private constructor();
|
|
112
|
+
get isSwedishTestPhoneNumber(): boolean;
|
|
113
|
+
get formatted(): string;
|
|
114
|
+
static tryParse(input: string | null | undefined, defaultCallingCode?: string | PhoneCallingCode | Country | null): PhoneNumber | null;
|
|
115
|
+
static parse(input: string, defaultCallingCode?: string | PhoneCallingCode | Country | null): PhoneNumber;
|
|
116
|
+
static isValid(input: string | null | undefined, defaultCallingCode?: string | PhoneCallingCode | Country | null): boolean;
|
|
117
|
+
static format(input: string | null | undefined, options?: {
|
|
118
|
+
defaultCallingCode?: string | PhoneCallingCode | Country | null;
|
|
119
|
+
fallbackToTrimmedInputWhenInvalid?: boolean;
|
|
120
|
+
}): string | null;
|
|
121
|
+
static normalize(input: string | null | undefined, options?: {
|
|
122
|
+
defaultCallingCode?: string | PhoneCallingCode | Country | null;
|
|
123
|
+
fallbackToTrimmedInputWhenInvalid?: boolean;
|
|
124
|
+
}): string | null;
|
|
125
|
+
static isNormalized(input: string | null | undefined): boolean;
|
|
126
|
+
static findCandidatesInText(text: string): readonly TextCandidate<PhoneNumber>[];
|
|
127
|
+
toNormalizedString(): string;
|
|
128
|
+
toLocalString(defaultCallingCode?: PhoneCallingCode | Country): string;
|
|
129
|
+
toE164String(): string;
|
|
130
|
+
toInternationalString(): string;
|
|
131
|
+
toDisplayInternationalString(): string;
|
|
132
|
+
toString(): string;
|
|
133
|
+
equals(other: PhoneNumber | null | undefined): boolean;
|
|
134
|
+
compareTo(other: PhoneNumber | null | undefined): number;
|
|
135
|
+
}
|
|
136
|
+
/** Mask a phone number, keeping country code and last 4 digits visible. */
|
|
137
|
+
declare function maskPhoneNumber(p: PhoneNumber): string;
|
|
138
|
+
|
|
139
|
+
export { PhoneCallingCode as P, PhoneNumber as a, maskPhoneNumber as m };
|
|
@@ -0,0 +1,487 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/primitives-defaults.ts
|
|
4
|
+
var DEFAULT_CULTURE = "sv-SE";
|
|
5
|
+
var DEFAULT_UI_CULTURE = "sv-SE";
|
|
6
|
+
var state = {
|
|
7
|
+
culture: DEFAULT_CULTURE,
|
|
8
|
+
uiCulture: DEFAULT_UI_CULTURE};
|
|
9
|
+
var PrimitivesDefaults = {
|
|
10
|
+
/**
|
|
11
|
+
* BCP-47 locale tag used for casing and number formatting.
|
|
12
|
+
* Defaults to `'sv-SE'`.
|
|
13
|
+
*/
|
|
14
|
+
get culture() {
|
|
15
|
+
return state.culture;
|
|
16
|
+
},
|
|
17
|
+
set culture(value) {
|
|
18
|
+
state.culture = value;
|
|
19
|
+
},
|
|
20
|
+
/**
|
|
21
|
+
* `true` when {@link uiCulture} is Swedish (`sv` or `sv-*`).
|
|
22
|
+
* Types use this to select between localized and English display names.
|
|
23
|
+
*/
|
|
24
|
+
get useLocalizedDisplayNames() {
|
|
25
|
+
const lang = state.uiCulture.toLowerCase().split("-")[0];
|
|
26
|
+
return lang === "sv";
|
|
27
|
+
}};
|
|
28
|
+
|
|
29
|
+
// src/internal/input-sanitization.ts
|
|
30
|
+
var FORMAT_OR_NOT_ASSIGNED = /[\p{Cf}\p{Cn}]/u;
|
|
31
|
+
var SPACE_SEPARATOR = /[\p{Zs}\p{Zl}\p{Zp}]/u;
|
|
32
|
+
var CONTROL = /\p{Cc}/u;
|
|
33
|
+
function sanitizeInput(input) {
|
|
34
|
+
let out = "";
|
|
35
|
+
for (const c of input) {
|
|
36
|
+
if (c === "\u2018" || c === "\u2019" || c === "\u201A" || c === "\u201B") {
|
|
37
|
+
out += "'";
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
if (c === "\u201C" || c === "\u201D" || c === "\u201E" || c === "\u201F" || c === "\xAB" || c === "\xBB") {
|
|
41
|
+
out += '"';
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
if (FORMAT_OR_NOT_ASSIGNED.test(c)) {
|
|
45
|
+
continue;
|
|
46
|
+
}
|
|
47
|
+
if (CONTROL.test(c)) {
|
|
48
|
+
if (c === " " || c === "\n" || c === "\r") out += " ";
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (SPACE_SEPARATOR.test(c)) {
|
|
52
|
+
out += " ";
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
out += c;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
}
|
|
59
|
+
var WHITESPACE_RUN = /\s+/g;
|
|
60
|
+
function collapseWhitespace(input) {
|
|
61
|
+
if (input == null) return "";
|
|
62
|
+
return sanitizeInput(input).trim().replace(WHITESPACE_RUN, " ");
|
|
63
|
+
}
|
|
64
|
+
function keepDigits(input) {
|
|
65
|
+
let out = "";
|
|
66
|
+
for (let i = 0; i < input.length; i++) {
|
|
67
|
+
const c = input.charCodeAt(i);
|
|
68
|
+
if (c >= 48 && c <= 57) out += input[i];
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/text-scanning/text-candidate-category.ts
|
|
74
|
+
var TextCandidateCategory = {
|
|
75
|
+
Property: "Property"};
|
|
76
|
+
|
|
77
|
+
// src/text-scanning/text-candidate.ts
|
|
78
|
+
var TextCandidate = class {
|
|
79
|
+
/** Zero-based start position in the scanned text. */
|
|
80
|
+
startIndex;
|
|
81
|
+
/** Number of characters in the original matched span. */
|
|
82
|
+
length;
|
|
83
|
+
/** The raw substring from the input text that was matched. */
|
|
84
|
+
originalText;
|
|
85
|
+
/**
|
|
86
|
+
* Short type name, e.g. `EmailAddress` or `SwedishPersonalIdentityNumber`.
|
|
87
|
+
*/
|
|
88
|
+
typeName;
|
|
89
|
+
/** Broad category of the matched type. */
|
|
90
|
+
category;
|
|
91
|
+
/** Machine-comparable canonical form of the matched value. */
|
|
92
|
+
normalizedForm;
|
|
93
|
+
/** Human-readable display form of the matched value. */
|
|
94
|
+
formattedForm;
|
|
95
|
+
/**
|
|
96
|
+
* Display form with sensitive content masked (e.g. `990807-****`).
|
|
97
|
+
* Produced by the type's `toMaskedString()` helper.
|
|
98
|
+
*/
|
|
99
|
+
maskedForm;
|
|
100
|
+
/** Heuristic confidence level. */
|
|
101
|
+
confidence;
|
|
102
|
+
/** The successfully parsed instance of the matched type. */
|
|
103
|
+
value;
|
|
104
|
+
constructor(opts) {
|
|
105
|
+
this.startIndex = opts.startIndex;
|
|
106
|
+
this.length = opts.length;
|
|
107
|
+
this.originalText = opts.originalText;
|
|
108
|
+
this.typeName = opts.typeName;
|
|
109
|
+
this.category = opts.category;
|
|
110
|
+
this.normalizedForm = opts.normalizedForm;
|
|
111
|
+
this.formattedForm = opts.formattedForm;
|
|
112
|
+
this.maskedForm = opts.maskedForm;
|
|
113
|
+
this.confidence = opts.confidence;
|
|
114
|
+
this.value = opts.value;
|
|
115
|
+
}
|
|
116
|
+
/** Exclusive end position (`startIndex + length`). */
|
|
117
|
+
get endIndex() {
|
|
118
|
+
return this.startIndex + this.length;
|
|
119
|
+
}
|
|
120
|
+
/** Returns `true` if this candidate's span overlaps with `other`. */
|
|
121
|
+
overlaps(other) {
|
|
122
|
+
return this.startIndex < other.endIndex && other.startIndex < this.endIndex;
|
|
123
|
+
}
|
|
124
|
+
/** Returns `true` if this candidate's span fully contains `other`. */
|
|
125
|
+
contains(other) {
|
|
126
|
+
return this.startIndex <= other.startIndex && this.endIndex >= other.endIndex;
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
// src/text-scanning/text-match-confidence.ts
|
|
131
|
+
var TextMatchConfidence = {
|
|
132
|
+
/**
|
|
133
|
+
* Structural match with partial validation — the format is correct but no
|
|
134
|
+
* checksum or strong distinguishing feature confirms the match.
|
|
135
|
+
*/
|
|
136
|
+
Medium: 1};
|
|
137
|
+
|
|
138
|
+
// src/property/swedish-property-designation.ts
|
|
139
|
+
var MAX_INPUT_LENGTH = 200;
|
|
140
|
+
var PARSE_PATTERN = /^(?<name>[\p{L}\p{M}\d][\p{L}\p{M}\d\s'-]*?)\s+(?<block>\d{1,6}):(?<unit>\d{1,6})$/u;
|
|
141
|
+
var SCAN_PATTERN = /(?<![\p{L}\p{M}\d])(?<name>\p{Lu}[\p{L}\p{M}'-]*(?:\s\p{Lu}[\p{L}\p{M}'-]*)?)\s+(?<block>\d{1,6}):(?<unit>\d{1,6})(?!\d)/gu;
|
|
142
|
+
var SwedishPropertyDesignation = class _SwedishPropertyDesignation {
|
|
143
|
+
static typeInfo = Object.freeze({
|
|
144
|
+
englishName: "Property Designation",
|
|
145
|
+
localizedName: "Fastighetsbeteckning",
|
|
146
|
+
emoji: "\u{1F3E0}",
|
|
147
|
+
sources: Object.freeze([
|
|
148
|
+
"https://www.lantmateriet.se/sv/kartor/vara-karttjanster/min-karta/hitta-fastighetsbeteckning-i-min-karta/",
|
|
149
|
+
"https://www2.lantmateriet.se/sv/fastighet-och-mark/information-om-fastigheter/Fastighetsregistret/registrets-innehall/",
|
|
150
|
+
"https://sv.wikipedia.org/wiki/Fastighetsbeteckning"
|
|
151
|
+
])
|
|
152
|
+
});
|
|
153
|
+
/** The full designation, e.g. `Stockholm Söder 75:2`. */
|
|
154
|
+
value;
|
|
155
|
+
/** The capitalized designation name, e.g. `Stockholm Söder`. */
|
|
156
|
+
designationName;
|
|
157
|
+
/** The register number `BLOCK:UNIT`, e.g. `75:2`. */
|
|
158
|
+
registerNumber;
|
|
159
|
+
/** Block portion of the register number. */
|
|
160
|
+
blockNumber;
|
|
161
|
+
/** Unit portion of the register number. */
|
|
162
|
+
unitNumber;
|
|
163
|
+
constructor(value, designationName, registerNumber, blockNumber, unitNumber) {
|
|
164
|
+
this.value = value;
|
|
165
|
+
this.designationName = designationName;
|
|
166
|
+
this.registerNumber = registerNumber;
|
|
167
|
+
this.blockNumber = blockNumber;
|
|
168
|
+
this.unitNumber = unitNumber;
|
|
169
|
+
}
|
|
170
|
+
static tryParse(input) {
|
|
171
|
+
if (input == null || input.trim() === "") return null;
|
|
172
|
+
const normalized = normalizeInput(input);
|
|
173
|
+
if (normalized.length > MAX_INPUT_LENGTH) return null;
|
|
174
|
+
const match = PARSE_PATTERN.exec(normalized);
|
|
175
|
+
if (!match || !match.groups) return null;
|
|
176
|
+
const name = normalizeName(match.groups.name);
|
|
177
|
+
if (name === "") return null;
|
|
178
|
+
const block = Number(match.groups.block);
|
|
179
|
+
const unit = Number(match.groups.unit);
|
|
180
|
+
if (!Number.isFinite(block) || block <= 0) return null;
|
|
181
|
+
if (!Number.isFinite(unit) || unit <= 0) return null;
|
|
182
|
+
const register = `${block}:${unit}`;
|
|
183
|
+
const value = `${name} ${register}`;
|
|
184
|
+
return new _SwedishPropertyDesignation(value, name, register, block, unit);
|
|
185
|
+
}
|
|
186
|
+
static parse(input) {
|
|
187
|
+
const r = _SwedishPropertyDesignation.tryParse(input);
|
|
188
|
+
if (r === null) throw new Error("Invalid Swedish property designation.");
|
|
189
|
+
return r;
|
|
190
|
+
}
|
|
191
|
+
static isValid(input) {
|
|
192
|
+
return _SwedishPropertyDesignation.tryParse(input) !== null;
|
|
193
|
+
}
|
|
194
|
+
static format(input, options) {
|
|
195
|
+
const r = _SwedishPropertyDesignation.tryParse(input);
|
|
196
|
+
if (r) return r.value;
|
|
197
|
+
if (options?.fallbackToTrimmedInputWhenInvalid && input != null && input.trim() !== "") {
|
|
198
|
+
return input.trim();
|
|
199
|
+
}
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
static normalize(input, options) {
|
|
203
|
+
return _SwedishPropertyDesignation.format(input, options);
|
|
204
|
+
}
|
|
205
|
+
static isNormalized(input) {
|
|
206
|
+
return input != null && _SwedishPropertyDesignation.normalize(input) === input;
|
|
207
|
+
}
|
|
208
|
+
toNormalizedString() {
|
|
209
|
+
return this.value;
|
|
210
|
+
}
|
|
211
|
+
toString() {
|
|
212
|
+
return this.value;
|
|
213
|
+
}
|
|
214
|
+
static findCandidatesInText(text) {
|
|
215
|
+
if (!text) return [];
|
|
216
|
+
const out = [];
|
|
217
|
+
const re = new RegExp(SCAN_PATTERN.source, SCAN_PATTERN.flags);
|
|
218
|
+
let m;
|
|
219
|
+
while ((m = re.exec(text)) !== null) {
|
|
220
|
+
const r = _SwedishPropertyDesignation.tryParse(m[0]);
|
|
221
|
+
if (!r) continue;
|
|
222
|
+
out.push(
|
|
223
|
+
new TextCandidate({
|
|
224
|
+
startIndex: m.index,
|
|
225
|
+
length: m[0].length,
|
|
226
|
+
originalText: m[0],
|
|
227
|
+
typeName: "SwedishPropertyDesignation",
|
|
228
|
+
category: TextCandidateCategory.Property,
|
|
229
|
+
normalizedForm: r.toNormalizedString(),
|
|
230
|
+
formattedForm: r.toString(),
|
|
231
|
+
maskedForm: maskSwedishPropertyDesignation(r),
|
|
232
|
+
confidence: TextMatchConfidence.Medium,
|
|
233
|
+
value: r
|
|
234
|
+
})
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
return out;
|
|
238
|
+
}
|
|
239
|
+
equals(other) {
|
|
240
|
+
return other != null && this.value === other.value;
|
|
241
|
+
}
|
|
242
|
+
compareTo(other) {
|
|
243
|
+
if (other == null) return 1;
|
|
244
|
+
return this.value < other.value ? -1 : this.value > other.value ? 1 : 0;
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
function normalizeInput(input) {
|
|
248
|
+
let s = collapseWhitespace(input);
|
|
249
|
+
s = s.replace(/\s*:\s*/g, ":");
|
|
250
|
+
return s;
|
|
251
|
+
}
|
|
252
|
+
function normalizeName(input) {
|
|
253
|
+
const words = collapseWhitespace(input).split(" ").filter((w) => w.length > 0);
|
|
254
|
+
return words.map(capitalizeHyphenatedWord).join(" ");
|
|
255
|
+
}
|
|
256
|
+
function capitalizeHyphenatedWord(word) {
|
|
257
|
+
if (!word) return word;
|
|
258
|
+
return word.split("-").map(capitalizeWord).join("-");
|
|
259
|
+
}
|
|
260
|
+
function capitalizeWord(word) {
|
|
261
|
+
if (!word) return word;
|
|
262
|
+
const locale = PrimitivesDefaults.culture;
|
|
263
|
+
const lowered = word.toLocaleLowerCase(locale);
|
|
264
|
+
for (let i = 0; i < lowered.length; i++) {
|
|
265
|
+
const ch = lowered[i];
|
|
266
|
+
if (isLetter(ch)) {
|
|
267
|
+
return lowered.slice(0, i) + ch.toLocaleUpperCase(locale) + lowered.slice(i + 1);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
return lowered;
|
|
271
|
+
}
|
|
272
|
+
function isLetter(ch) {
|
|
273
|
+
return /\p{L}/u.test(ch);
|
|
274
|
+
}
|
|
275
|
+
function maskSwedishPropertyDesignation(d) {
|
|
276
|
+
const block = "*".repeat(d.blockNumber.toString().length);
|
|
277
|
+
const unit = "*".repeat(d.unitNumber.toString().length);
|
|
278
|
+
return `${d.designationName} ${block}:${unit}`;
|
|
279
|
+
}
|
|
280
|
+
function getLantmaterietUrl(d) {
|
|
281
|
+
return `https://minkarta.lantmateriet.se/?search=${encodeURIComponent(d.value)}`;
|
|
282
|
+
}
|
|
283
|
+
function getPropertyHittaUrl(d) {
|
|
284
|
+
return `https://www.hitta.se/kartan?s=${encodeURIComponent(d.value)}`;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// src/property/swedish-property-taxation-code.ts
|
|
288
|
+
var MAX_INPUT_LENGTH2 = 20;
|
|
289
|
+
var SwedishPropertyTaxationCategory = {
|
|
290
|
+
Unknown: "Unknown",
|
|
291
|
+
Lantbruksenhet: "Lantbruksenhet",
|
|
292
|
+
Smahusenhet: "Smahusenhet",
|
|
293
|
+
Hyreshusenhet: "Hyreshusenhet",
|
|
294
|
+
Industrienhet: "Industrienhet",
|
|
295
|
+
Taktmark: "Taktmark",
|
|
296
|
+
Elproduktionsenhet: "Elproduktionsenhet",
|
|
297
|
+
Specialenhet: "Specialenhet",
|
|
298
|
+
OvrigMark: "OvrigMark"
|
|
299
|
+
};
|
|
300
|
+
var CATEGORY_BY_FIRST_DIGIT = {
|
|
301
|
+
1: SwedishPropertyTaxationCategory.Lantbruksenhet,
|
|
302
|
+
2: SwedishPropertyTaxationCategory.Smahusenhet,
|
|
303
|
+
3: SwedishPropertyTaxationCategory.Hyreshusenhet,
|
|
304
|
+
4: SwedishPropertyTaxationCategory.Industrienhet,
|
|
305
|
+
5: SwedishPropertyTaxationCategory.Taktmark,
|
|
306
|
+
6: SwedishPropertyTaxationCategory.Elproduktionsenhet,
|
|
307
|
+
7: SwedishPropertyTaxationCategory.Specialenhet,
|
|
308
|
+
8: SwedishPropertyTaxationCategory.OvrigMark
|
|
309
|
+
};
|
|
310
|
+
var KNOWN_CODES = {
|
|
311
|
+
110: { english: "Agricultural unit, undeveloped", swedish: "Lantbruksenhet, obebyggd" },
|
|
312
|
+
113: {
|
|
313
|
+
english: "Agricultural unit, with farm building only",
|
|
314
|
+
swedish: "Lantbruksenhet, obebyggd, enbart med ekonomibyggnad"
|
|
315
|
+
},
|
|
316
|
+
120: { english: "Agricultural unit, developed", swedish: "Lantbruksenhet, bebyggd" },
|
|
317
|
+
210: { english: "Small house unit, land only", swedish: "Sm\xE5husenhet, tomtmark" },
|
|
318
|
+
213: {
|
|
319
|
+
english: "Small house unit, land with building value under 50 000 SEK",
|
|
320
|
+
swedish: "Sm\xE5husenhet, tomtmark med byggnadsv\xE4rde under 50 000 kr"
|
|
321
|
+
},
|
|
322
|
+
220: { english: "Small house unit, developed", swedish: "Sm\xE5husenhet, bebyggd" },
|
|
323
|
+
221: {
|
|
324
|
+
english: "Small house unit, developed with two houses",
|
|
325
|
+
swedish: "Sm\xE5husenhet, bebyggd med tv\xE5 sm\xE5hus"
|
|
326
|
+
},
|
|
327
|
+
225: {
|
|
328
|
+
english: "Small house unit, on leasehold",
|
|
329
|
+
swedish: "Sm\xE5husenhet, bebyggd p\xE5 ofri grund"
|
|
330
|
+
},
|
|
331
|
+
230: {
|
|
332
|
+
english: "Small house unit, developed, cluster housing",
|
|
333
|
+
swedish: "Sm\xE5husenhet, bebyggd, grupphusomr\xE5de"
|
|
334
|
+
},
|
|
335
|
+
310: { english: "Rental property unit, land only", swedish: "Hyreshusenhet, tomtmark" },
|
|
336
|
+
313: {
|
|
337
|
+
english: "Rental property unit, land with building value under 50 000 SEK",
|
|
338
|
+
swedish: "Hyreshusenhet, tomtmark med byggnadsv\xE4rde under 50 000 kr"
|
|
339
|
+
},
|
|
340
|
+
320: {
|
|
341
|
+
english: "Rental property unit, developed, residential",
|
|
342
|
+
swedish: "Hyreshusenhet, bebyggd, bost\xE4der"
|
|
343
|
+
},
|
|
344
|
+
321: {
|
|
345
|
+
english: "Rental property unit, developed, residential and commercial",
|
|
346
|
+
swedish: "Hyreshusenhet, bebyggd, bost\xE4der och lokaler"
|
|
347
|
+
},
|
|
348
|
+
325: {
|
|
349
|
+
english: "Rental property unit, developed, commercial",
|
|
350
|
+
swedish: "Hyreshusenhet, bebyggd, lokaler"
|
|
351
|
+
},
|
|
352
|
+
381: {
|
|
353
|
+
english: "Rental property unit, developed, residential (special)",
|
|
354
|
+
swedish: "Hyreshusenhet, bebyggd, bost\xE4der (specialenhet)"
|
|
355
|
+
},
|
|
356
|
+
410: { english: "Industrial unit, land only", swedish: "Industrienhet, tomtmark" },
|
|
357
|
+
420: { english: "Industrial unit, developed", swedish: "Industrienhet, bebyggd" },
|
|
358
|
+
421: {
|
|
359
|
+
english: "Industrial unit, developed with rental property area",
|
|
360
|
+
swedish: "Industrienhet, bebyggd med hyreshusareal"
|
|
361
|
+
},
|
|
362
|
+
498: { english: "Industrial unit, petrol station", swedish: "Industrienhet, bensinstation" },
|
|
363
|
+
510: { english: "Quarry land, undeveloped", swedish: "T\xE4ktmark, obebyggd" },
|
|
364
|
+
520: { english: "Quarry land, developed", swedish: "T\xE4ktmark, bebyggd" },
|
|
365
|
+
610: {
|
|
366
|
+
english: "Power production unit, hydropower",
|
|
367
|
+
swedish: "Elproduktionsenhet, vattenkraftverk"
|
|
368
|
+
},
|
|
369
|
+
620: {
|
|
370
|
+
english: "Power production unit, thermal power",
|
|
371
|
+
swedish: "Elproduktionsenhet, v\xE4rmekraftverk"
|
|
372
|
+
},
|
|
373
|
+
630: {
|
|
374
|
+
english: "Power production unit, wind power",
|
|
375
|
+
swedish: "Elproduktionsenhet, vindkraftverk"
|
|
376
|
+
},
|
|
377
|
+
710: { english: "Communication building", swedish: "Kommunikationsbyggnad" },
|
|
378
|
+
720: { english: "Distribution building", swedish: "Distributionsbyggnad" },
|
|
379
|
+
730: { english: "Cultural building", swedish: "Kulturbyggnad" },
|
|
380
|
+
810: { english: "Special unit, undeveloped land", swedish: "Specialenhet, obebyggd mark" },
|
|
381
|
+
890: { english: "Other land", swedish: "\xD6vrig mark" }
|
|
382
|
+
};
|
|
383
|
+
var SwedishPropertyTaxationCode = class _SwedishPropertyTaxationCode {
|
|
384
|
+
static typeInfo = Object.freeze({
|
|
385
|
+
englishName: "Property Taxation Code",
|
|
386
|
+
localizedName: "Typkod",
|
|
387
|
+
emoji: "\u{1F3D7}\uFE0F",
|
|
388
|
+
sources: Object.freeze([
|
|
389
|
+
"https://www.skatteverket.se/privat/fastigheterochbostad/fastighetstaxering.4.69ef368911e1304a625800013531.html",
|
|
390
|
+
"https://sv.wikipedia.org/wiki/Typkod_(fastighet)"
|
|
391
|
+
])
|
|
392
|
+
});
|
|
393
|
+
/** The 3-digit taxation code, e.g. `220`. */
|
|
394
|
+
code;
|
|
395
|
+
/** The numeric form of the code, e.g. `220`. */
|
|
396
|
+
numericCode;
|
|
397
|
+
/** The main property category (derived from the first digit). */
|
|
398
|
+
category;
|
|
399
|
+
/** English description, or `null` when the code is not in the known list. */
|
|
400
|
+
englishDescription;
|
|
401
|
+
/** Localized (Swedish) description, or `null` when not in the known list. */
|
|
402
|
+
localizedDescription;
|
|
403
|
+
/** `true` when this code has a known description. */
|
|
404
|
+
get isKnown() {
|
|
405
|
+
return this.englishDescription !== null;
|
|
406
|
+
}
|
|
407
|
+
/** Display description in the current display language; falls back to the code. */
|
|
408
|
+
get displayDescription() {
|
|
409
|
+
const desc = PrimitivesDefaults.useLocalizedDisplayNames ? this.localizedDescription : this.englishDescription;
|
|
410
|
+
return desc ?? this.code;
|
|
411
|
+
}
|
|
412
|
+
constructor(code, numericCode, category, englishDescription, localizedDescription) {
|
|
413
|
+
this.code = code;
|
|
414
|
+
this.numericCode = numericCode;
|
|
415
|
+
this.category = category;
|
|
416
|
+
this.englishDescription = englishDescription;
|
|
417
|
+
this.localizedDescription = localizedDescription;
|
|
418
|
+
}
|
|
419
|
+
static tryParse(input) {
|
|
420
|
+
if (input == null || input.trim() === "") return null;
|
|
421
|
+
const digits = keepDigits(input);
|
|
422
|
+
if (digits.length > MAX_INPUT_LENGTH2) return null;
|
|
423
|
+
if (digits.length !== 3) return null;
|
|
424
|
+
const numeric = Number(digits);
|
|
425
|
+
if (!Number.isFinite(numeric) || numeric < 100 || numeric > 999) return null;
|
|
426
|
+
const firstDigit = Math.floor(numeric / 100);
|
|
427
|
+
const category = CATEGORY_BY_FIRST_DIGIT[firstDigit];
|
|
428
|
+
if (!category || category === SwedishPropertyTaxationCategory.Unknown) return null;
|
|
429
|
+
const known = KNOWN_CODES[numeric];
|
|
430
|
+
return new _SwedishPropertyTaxationCode(
|
|
431
|
+
digits,
|
|
432
|
+
numeric,
|
|
433
|
+
category,
|
|
434
|
+
known?.english ?? null,
|
|
435
|
+
known?.swedish ?? null
|
|
436
|
+
);
|
|
437
|
+
}
|
|
438
|
+
static parse(input) {
|
|
439
|
+
const r = _SwedishPropertyTaxationCode.tryParse(input);
|
|
440
|
+
if (r === null) throw new Error("Invalid Swedish property taxation code.");
|
|
441
|
+
return r;
|
|
442
|
+
}
|
|
443
|
+
static isValid(input) {
|
|
444
|
+
return _SwedishPropertyTaxationCode.tryParse(input) !== null;
|
|
445
|
+
}
|
|
446
|
+
static format(input, options) {
|
|
447
|
+
const r = _SwedishPropertyTaxationCode.tryParse(input);
|
|
448
|
+
if (r) return r.displayDescription;
|
|
449
|
+
if (options?.fallbackToTrimmedInputWhenInvalid && input != null && input.trim() !== "") {
|
|
450
|
+
return input.trim();
|
|
451
|
+
}
|
|
452
|
+
return null;
|
|
453
|
+
}
|
|
454
|
+
static normalize(input, options) {
|
|
455
|
+
const r = _SwedishPropertyTaxationCode.tryParse(input);
|
|
456
|
+
if (r) return r.code;
|
|
457
|
+
if (options?.fallbackToTrimmedInputWhenInvalid && input != null && input.trim() !== "") {
|
|
458
|
+
return input.trim();
|
|
459
|
+
}
|
|
460
|
+
return null;
|
|
461
|
+
}
|
|
462
|
+
static isNormalized(input) {
|
|
463
|
+
return input != null && _SwedishPropertyTaxationCode.normalize(input) === input;
|
|
464
|
+
}
|
|
465
|
+
toNormalizedString() {
|
|
466
|
+
return this.code;
|
|
467
|
+
}
|
|
468
|
+
toString() {
|
|
469
|
+
return this.displayDescription;
|
|
470
|
+
}
|
|
471
|
+
equals(other) {
|
|
472
|
+
return other != null && this.code === other.code;
|
|
473
|
+
}
|
|
474
|
+
compareTo(other) {
|
|
475
|
+
if (other == null) return 1;
|
|
476
|
+
return this.code < other.code ? -1 : this.code > other.code ? 1 : 0;
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
|
|
480
|
+
exports.SwedishPropertyDesignation = SwedishPropertyDesignation;
|
|
481
|
+
exports.SwedishPropertyTaxationCategory = SwedishPropertyTaxationCategory;
|
|
482
|
+
exports.SwedishPropertyTaxationCode = SwedishPropertyTaxationCode;
|
|
483
|
+
exports.getLantmaterietUrl = getLantmaterietUrl;
|
|
484
|
+
exports.getPropertyHittaUrl = getPropertyHittaUrl;
|
|
485
|
+
exports.maskSwedishPropertyDesignation = maskSwedishPropertyDesignation;
|
|
486
|
+
//# sourceMappingURL=index.cjs.map
|
|
487
|
+
//# sourceMappingURL=index.cjs.map
|