@ifc-lite/query 1.0.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/LICENSE +373 -0
- package/dist/parser/src/classification-extractor.d.ts +73 -0
- package/dist/parser/src/classification-extractor.d.ts.map +1 -0
- package/dist/parser/src/classification-extractor.js +218 -0
- package/dist/parser/src/classification-extractor.js.map +1 -0
- package/dist/parser/src/columnar-parser.d.ts +43 -0
- package/dist/parser/src/columnar-parser.d.ts.map +1 -0
- package/dist/parser/src/columnar-parser.js +226 -0
- package/dist/parser/src/columnar-parser.js.map +1 -0
- package/dist/parser/src/entity-extractor.d.ts +15 -0
- package/dist/parser/src/entity-extractor.d.ts.map +1 -0
- package/dist/parser/src/entity-extractor.js +144 -0
- package/dist/parser/src/entity-extractor.js.map +1 -0
- package/dist/parser/src/entity-index.d.ts +11 -0
- package/dist/parser/src/entity-index.d.ts.map +1 -0
- package/dist/parser/src/entity-index.js +24 -0
- package/dist/parser/src/entity-index.js.map +1 -0
- package/dist/parser/src/generated/entities.d.ts +6198 -0
- package/dist/parser/src/generated/entities.d.ts.map +1 -0
- package/dist/parser/src/generated/entities.js +5 -0
- package/dist/parser/src/generated/entities.js.map +1 -0
- package/dist/parser/src/generated/enums.d.ts +2260 -0
- package/dist/parser/src/generated/enums.d.ts.map +1 -0
- package/dist/parser/src/generated/enums.js +2470 -0
- package/dist/parser/src/generated/enums.js.map +1 -0
- package/dist/parser/src/generated/schema-registry.d.ts +50 -0
- package/dist/parser/src/generated/schema-registry.d.ts.map +1 -0
- package/dist/parser/src/generated/schema-registry.js +60518 -0
- package/dist/parser/src/generated/schema-registry.js.map +1 -0
- package/dist/parser/src/georef-extractor.d.ts +60 -0
- package/dist/parser/src/georef-extractor.d.ts.map +1 -0
- package/dist/parser/src/georef-extractor.js +200 -0
- package/dist/parser/src/georef-extractor.js.map +1 -0
- package/dist/parser/src/ifc-schema.d.ts +13 -0
- package/dist/parser/src/ifc-schema.d.ts.map +1 -0
- package/dist/parser/src/ifc-schema.js +203 -0
- package/dist/parser/src/ifc-schema.js.map +1 -0
- package/dist/parser/src/index.d.ts +43 -0
- package/dist/parser/src/index.d.ts.map +1 -0
- package/dist/parser/src/index.js +150 -0
- package/dist/parser/src/index.js.map +1 -0
- package/dist/parser/src/material-extractor.d.ts +97 -0
- package/dist/parser/src/material-extractor.d.ts.map +1 -0
- package/dist/parser/src/material-extractor.js +283 -0
- package/dist/parser/src/material-extractor.js.map +1 -0
- package/dist/parser/src/property-extractor.d.ts +23 -0
- package/dist/parser/src/property-extractor.d.ts.map +1 -0
- package/dist/parser/src/property-extractor.js +102 -0
- package/dist/parser/src/property-extractor.js.map +1 -0
- package/dist/parser/src/quantity-extractor.d.ts +64 -0
- package/dist/parser/src/quantity-extractor.d.ts.map +1 -0
- package/dist/parser/src/quantity-extractor.js +202 -0
- package/dist/parser/src/quantity-extractor.js.map +1 -0
- package/dist/parser/src/relationship-extractor.d.ts +18 -0
- package/dist/parser/src/relationship-extractor.d.ts.map +1 -0
- package/dist/parser/src/relationship-extractor.js +91 -0
- package/dist/parser/src/relationship-extractor.js.map +1 -0
- package/dist/parser/src/spatial-hierarchy-builder.d.ts +21 -0
- package/dist/parser/src/spatial-hierarchy-builder.d.ts.map +1 -0
- package/dist/parser/src/spatial-hierarchy-builder.js +201 -0
- package/dist/parser/src/spatial-hierarchy-builder.js.map +1 -0
- package/dist/parser/src/style-extractor.d.ts +83 -0
- package/dist/parser/src/style-extractor.d.ts.map +1 -0
- package/dist/parser/src/style-extractor.js +327 -0
- package/dist/parser/src/style-extractor.js.map +1 -0
- package/dist/parser/src/tokenizer.d.ts +26 -0
- package/dist/parser/src/tokenizer.d.ts.map +1 -0
- package/dist/parser/src/tokenizer.js +181 -0
- package/dist/parser/src/tokenizer.js.map +1 -0
- package/dist/parser/src/types.d.ts +42 -0
- package/dist/parser/src/types.d.ts.map +1 -0
- package/dist/parser/src/types.js +5 -0
- package/dist/parser/src/types.js.map +1 -0
- package/dist/query/src/duckdb-integration.d.ts +59 -0
- package/dist/query/src/duckdb-integration.d.ts.map +1 -0
- package/dist/query/src/duckdb-integration.js +380 -0
- package/dist/query/src/duckdb-integration.js.map +1 -0
- package/dist/query/src/entity-node.d.ts +30 -0
- package/dist/query/src/entity-node.d.ts.map +1 -0
- package/dist/query/src/entity-node.js +114 -0
- package/dist/query/src/entity-node.js.map +1 -0
- package/dist/query/src/entity-query.d.ts +31 -0
- package/dist/query/src/entity-query.d.ts.map +1 -0
- package/dist/query/src/entity-query.js +129 -0
- package/dist/query/src/entity-query.js.map +1 -0
- package/dist/query/src/entity-table.d.ts +26 -0
- package/dist/query/src/entity-table.d.ts.map +1 -0
- package/dist/query/src/entity-table.js +37 -0
- package/dist/query/src/entity-table.js.map +1 -0
- package/dist/query/src/fluent-api.d.ts +45 -0
- package/dist/query/src/fluent-api.d.ts.map +1 -0
- package/dist/query/src/fluent-api.js +81 -0
- package/dist/query/src/fluent-api.js.map +1 -0
- package/dist/query/src/ifc-query.d.ts +34 -0
- package/dist/query/src/ifc-query.d.ts.map +1 -0
- package/dist/query/src/ifc-query.js +117 -0
- package/dist/query/src/ifc-query.js.map +1 -0
- package/dist/query/src/index.d.ts +12 -0
- package/dist/query/src/index.d.ts.map +1 -0
- package/dist/query/src/index.js +15 -0
- package/dist/query/src/index.js.map +1 -0
- package/dist/query/src/property-table.d.ts +30 -0
- package/dist/query/src/property-table.d.ts.map +1 -0
- package/dist/query/src/property-table.js +79 -0
- package/dist/query/src/property-table.js.map +1 -0
- package/dist/query/src/query-result-entity.d.ts +33 -0
- package/dist/query/src/query-result-entity.d.ts.map +1 -0
- package/dist/query/src/query-result-entity.js +84 -0
- package/dist/query/src/query-result-entity.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
import { QueryResultEntity } from './query-result-entity.js';
|
|
5
|
+
export class EntityQuery {
|
|
6
|
+
store;
|
|
7
|
+
typeFilter;
|
|
8
|
+
idFilter;
|
|
9
|
+
propertyFilters = [];
|
|
10
|
+
limitCount = null;
|
|
11
|
+
offsetCount = 0;
|
|
12
|
+
includeFlags = {};
|
|
13
|
+
constructor(store, types, ids = null) {
|
|
14
|
+
this.store = store;
|
|
15
|
+
this.typeFilter = types;
|
|
16
|
+
this.idFilter = ids;
|
|
17
|
+
}
|
|
18
|
+
// ═══════════════════════════════════════════════════════════════
|
|
19
|
+
// FILTERING
|
|
20
|
+
// ═══════════════════════════════════════════════════════════════
|
|
21
|
+
whereProperty(psetName, propName, operator, value) {
|
|
22
|
+
this.propertyFilters.push({ pset: psetName, prop: propName, op: operator, value });
|
|
23
|
+
return this;
|
|
24
|
+
}
|
|
25
|
+
limit(count) {
|
|
26
|
+
this.limitCount = count;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
offset(count) {
|
|
30
|
+
this.offsetCount = count;
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
// ═══════════════════════════════════════════════════════════════
|
|
34
|
+
// EAGER LOADING
|
|
35
|
+
// ═══════════════════════════════════════════════════════════════
|
|
36
|
+
includeGeometry() {
|
|
37
|
+
this.includeFlags.geometry = true;
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
includeProperties() {
|
|
41
|
+
this.includeFlags.properties = true;
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
includeQuantities() {
|
|
45
|
+
this.includeFlags.quantities = true;
|
|
46
|
+
return this;
|
|
47
|
+
}
|
|
48
|
+
includeAll() {
|
|
49
|
+
this.includeFlags = { geometry: true, properties: true, quantities: true };
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
// ═══════════════════════════════════════════════════════════════
|
|
53
|
+
// EXECUTION
|
|
54
|
+
// ═══════════════════════════════════════════════════════════════
|
|
55
|
+
execute() {
|
|
56
|
+
let ids = this.getCandidateIds();
|
|
57
|
+
ids = this.applyPropertyFilters(ids);
|
|
58
|
+
if (this.offsetCount > 0) {
|
|
59
|
+
ids = ids.slice(this.offsetCount);
|
|
60
|
+
}
|
|
61
|
+
if (this.limitCount !== null) {
|
|
62
|
+
ids = ids.slice(0, this.limitCount);
|
|
63
|
+
}
|
|
64
|
+
const results = ids.map(id => new QueryResultEntity(this.store, id, this.includeFlags));
|
|
65
|
+
// Eager load based on flags
|
|
66
|
+
for (const result of results) {
|
|
67
|
+
if (this.includeFlags.properties) {
|
|
68
|
+
result.loadProperties();
|
|
69
|
+
}
|
|
70
|
+
if (this.includeFlags.quantities) {
|
|
71
|
+
result.loadQuantities();
|
|
72
|
+
}
|
|
73
|
+
if (this.includeFlags.geometry) {
|
|
74
|
+
result.loadGeometry();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return results;
|
|
78
|
+
}
|
|
79
|
+
async ids() {
|
|
80
|
+
let ids = this.getCandidateIds();
|
|
81
|
+
ids = this.applyPropertyFilters(ids);
|
|
82
|
+
if (this.offsetCount > 0)
|
|
83
|
+
ids = ids.slice(this.offsetCount);
|
|
84
|
+
if (this.limitCount !== null)
|
|
85
|
+
ids = ids.slice(0, this.limitCount);
|
|
86
|
+
return ids;
|
|
87
|
+
}
|
|
88
|
+
async count() {
|
|
89
|
+
let ids = this.getCandidateIds();
|
|
90
|
+
ids = this.applyPropertyFilters(ids);
|
|
91
|
+
return ids.length;
|
|
92
|
+
}
|
|
93
|
+
async first() {
|
|
94
|
+
const results = this.limit(1).execute();
|
|
95
|
+
return results[0] ?? null;
|
|
96
|
+
}
|
|
97
|
+
// ═══════════════════════════════════════════════════════════════
|
|
98
|
+
// PRIVATE
|
|
99
|
+
// ═══════════════════════════════════════════════════════════════
|
|
100
|
+
getCandidateIds() {
|
|
101
|
+
if (this.idFilter)
|
|
102
|
+
return [...this.idFilter];
|
|
103
|
+
if (this.typeFilter) {
|
|
104
|
+
const ids = [];
|
|
105
|
+
for (const typeEnum of this.typeFilter) {
|
|
106
|
+
ids.push(...this.store.entities.getByType(typeEnum));
|
|
107
|
+
}
|
|
108
|
+
return ids;
|
|
109
|
+
}
|
|
110
|
+
// Return all entity IDs
|
|
111
|
+
const allIds = [];
|
|
112
|
+
for (let i = 0; i < this.store.entities.count; i++) {
|
|
113
|
+
allIds.push(this.store.entities.expressId[i]);
|
|
114
|
+
}
|
|
115
|
+
return allIds;
|
|
116
|
+
}
|
|
117
|
+
applyPropertyFilters(ids) {
|
|
118
|
+
if (this.propertyFilters.length === 0)
|
|
119
|
+
return ids;
|
|
120
|
+
let filteredIds = ids;
|
|
121
|
+
for (const filter of this.propertyFilters) {
|
|
122
|
+
const matchingIds = this.store.properties.findByProperty(filter.prop, filter.op, filter.value);
|
|
123
|
+
const matchingSet = new Set(matchingIds);
|
|
124
|
+
filteredIds = filteredIds.filter(id => matchingSet.has(id));
|
|
125
|
+
}
|
|
126
|
+
return filteredIds;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=entity-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-query.js","sourceRoot":"","sources":["../../../src/entity-query.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAQ/D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAI7D,MAAM,OAAO,WAAW;IACd,KAAK,CAAe;IACpB,UAAU,CAAuB;IACjC,QAAQ,CAAkB;IAC1B,eAAe,GAA8E,EAAE,CAAC;IAChG,UAAU,GAAkB,IAAI,CAAC;IACjC,WAAW,GAAW,CAAC,CAAC;IACxB,YAAY,GAAuE,EAAE,CAAC;IAE9F,YAAY,KAAmB,EAAE,KAA2B,EAAE,MAAuB,IAAI;QACvF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB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AAK,CAAC;YAAE,OAAO,GAAG,CAAC;QAElD,IAAI,WAAW,GAAG,GAAG,CAAC;QAEtB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,eAAe,EAAE,CAAC;YAC1C,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;YAC/F,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,WAAW,CAAC,CAAC;YACzC,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity table - fast entity lookup and filtering
|
|
3
|
+
*/
|
|
4
|
+
import type { IfcEntity, EntityIndex } from '@ifc-lite/parser';
|
|
5
|
+
export declare class EntityTable {
|
|
6
|
+
private entities;
|
|
7
|
+
private index;
|
|
8
|
+
constructor(entities: Map<number, IfcEntity>, index: EntityIndex);
|
|
9
|
+
/**
|
|
10
|
+
* Get entity by ID
|
|
11
|
+
*/
|
|
12
|
+
getEntity(id: number): IfcEntity | null;
|
|
13
|
+
/**
|
|
14
|
+
* Get entities by type
|
|
15
|
+
*/
|
|
16
|
+
getEntitiesByType(type: string): IfcEntity[];
|
|
17
|
+
/**
|
|
18
|
+
* Check if entity exists
|
|
19
|
+
*/
|
|
20
|
+
hasEntity(id: number): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Get all entities
|
|
23
|
+
*/
|
|
24
|
+
getAllEntities(): IfcEntity[];
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=entity-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-table.d.ts","sourceRoot":"","sources":["../../../src/entity-table.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/D,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAyB;IACzC,OAAO,CAAC,KAAK,CAAc;gBAEf,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,KAAK,EAAE,WAAW;IAKhE;;OAEG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIvC;;OAEG;IACH,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE;IAK5C;;OAEG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAI9B;;OAEG;IACH,cAAc,IAAI,SAAS,EAAE;CAG9B"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
export class EntityTable {
|
|
5
|
+
entities;
|
|
6
|
+
index;
|
|
7
|
+
constructor(entities, index) {
|
|
8
|
+
this.entities = entities;
|
|
9
|
+
this.index = index;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Get entity by ID
|
|
13
|
+
*/
|
|
14
|
+
getEntity(id) {
|
|
15
|
+
return this.entities.get(id) || null;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Get entities by type
|
|
19
|
+
*/
|
|
20
|
+
getEntitiesByType(type) {
|
|
21
|
+
const ids = this.index.byType.get(type) || [];
|
|
22
|
+
return ids.map(id => this.entities.get(id)).filter((e) => e !== undefined);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Check if entity exists
|
|
26
|
+
*/
|
|
27
|
+
hasEntity(id) {
|
|
28
|
+
return this.entities.has(id);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Get all entities
|
|
32
|
+
*/
|
|
33
|
+
getAllEntities() {
|
|
34
|
+
return Array.from(this.entities.values());
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=entity-table.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity-table.js","sourceRoot":"","sources":["../../../src/entity-table.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAQ/D,MAAM,OAAO,WAAW;IACd,QAAQ,CAAyB;IACjC,KAAK,CAAc;IAE3B,YAAY,QAAgC,EAAE,KAAkB;QAC9D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,IAAY;QAC5B,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;QAC9C,OAAO,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAkB,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC;IAC7F,CAAC;IAED;;OAEG;IACH,SAAS,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC/B,CAAC;IAED;;OAEG;IACH,cAAc;QACZ,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fluent query API builder
|
|
3
|
+
*/
|
|
4
|
+
import type { IfcEntity } from '@ifc-lite/parser';
|
|
5
|
+
import { EntityTable } from './entity-table.js';
|
|
6
|
+
import { PropertyTable } from './property-table.js';
|
|
7
|
+
export declare class QueryBuilder {
|
|
8
|
+
private entityTable;
|
|
9
|
+
private propertyTable;
|
|
10
|
+
private currentFilter;
|
|
11
|
+
constructor(entityTable: EntityTable, propertyTable: PropertyTable);
|
|
12
|
+
/**
|
|
13
|
+
* Filter by entity type
|
|
14
|
+
*/
|
|
15
|
+
ofType(type: string): this;
|
|
16
|
+
/**
|
|
17
|
+
* Filter by property value
|
|
18
|
+
*/
|
|
19
|
+
withProperty(propertySetName: string, propertyName: string, value?: any): this;
|
|
20
|
+
/**
|
|
21
|
+
* Execute query
|
|
22
|
+
*/
|
|
23
|
+
execute(): IfcEntity[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Query interface
|
|
27
|
+
*/
|
|
28
|
+
export declare class QueryInterface {
|
|
29
|
+
private entityTable;
|
|
30
|
+
private propertyTable;
|
|
31
|
+
constructor(entityTable: EntityTable, propertyTable: PropertyTable);
|
|
32
|
+
/**
|
|
33
|
+
* Start a new query
|
|
34
|
+
*/
|
|
35
|
+
query(): QueryBuilder;
|
|
36
|
+
/**
|
|
37
|
+
* Get entity by ID
|
|
38
|
+
*/
|
|
39
|
+
getEntity(id: number): IfcEntity | null;
|
|
40
|
+
/**
|
|
41
|
+
* Get properties for entity
|
|
42
|
+
*/
|
|
43
|
+
getProperties(entityId: number): Map<string, any>;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=fluent-api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluent-api.d.ts","sourceRoot":"","sources":["../../../src/fluent-api.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,qBAAa,YAAY;IACrB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,aAAa,CAAiC;gBAE1C,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAMlE;;OAEG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAM1B;;OAEG;IACH,YAAY,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,GAAG,GAAG,IAAI;IAkB9E;;OAEG;IACH,OAAO,IAAI,SAAS,EAAE;CAIzB;AAED;;GAEG;AACH,qBAAa,cAAc;IACvB,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,aAAa;IAKlE;;OAEG;IACH,KAAK,IAAI,YAAY;IAIrB;;OAEG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAIvC;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC;CAGpD"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
export class QueryBuilder {
|
|
5
|
+
entityTable;
|
|
6
|
+
propertyTable;
|
|
7
|
+
currentFilter;
|
|
8
|
+
constructor(entityTable, propertyTable) {
|
|
9
|
+
this.entityTable = entityTable;
|
|
10
|
+
this.propertyTable = propertyTable;
|
|
11
|
+
this.currentFilter = () => true;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Filter by entity type
|
|
15
|
+
*/
|
|
16
|
+
ofType(type) {
|
|
17
|
+
const previousFilter = this.currentFilter;
|
|
18
|
+
this.currentFilter = (entity) => previousFilter(entity) && entity.type === type;
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Filter by property value
|
|
23
|
+
*/
|
|
24
|
+
withProperty(propertySetName, propertyName, value) {
|
|
25
|
+
const previousFilter = this.currentFilter;
|
|
26
|
+
if (value !== undefined) {
|
|
27
|
+
this.currentFilter = (entity) => {
|
|
28
|
+
if (!previousFilter(entity))
|
|
29
|
+
return false;
|
|
30
|
+
const prop = this.propertyTable.getProperty(entity.expressId, propertySetName, propertyName);
|
|
31
|
+
return prop !== null && prop.value === value;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
this.currentFilter = (entity) => {
|
|
36
|
+
if (!previousFilter(entity))
|
|
37
|
+
return false;
|
|
38
|
+
const prop = this.propertyTable.getProperty(entity.expressId, propertySetName, propertyName);
|
|
39
|
+
return prop !== null;
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return this;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Execute query
|
|
46
|
+
*/
|
|
47
|
+
execute() {
|
|
48
|
+
const allEntities = this.entityTable.getAllEntities();
|
|
49
|
+
return allEntities.filter(this.currentFilter);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Query interface
|
|
54
|
+
*/
|
|
55
|
+
export class QueryInterface {
|
|
56
|
+
entityTable;
|
|
57
|
+
propertyTable;
|
|
58
|
+
constructor(entityTable, propertyTable) {
|
|
59
|
+
this.entityTable = entityTable;
|
|
60
|
+
this.propertyTable = propertyTable;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Start a new query
|
|
64
|
+
*/
|
|
65
|
+
query() {
|
|
66
|
+
return new QueryBuilder(this.entityTable, this.propertyTable);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Get entity by ID
|
|
70
|
+
*/
|
|
71
|
+
getEntity(id) {
|
|
72
|
+
return this.entityTable.getEntity(id);
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Get properties for entity
|
|
76
|
+
*/
|
|
77
|
+
getProperties(entityId) {
|
|
78
|
+
return this.propertyTable.getProperties(entityId);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=fluent-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fluent-api.js","sourceRoot":"","sources":["../../../src/fluent-api.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAU/D,MAAM,OAAO,YAAY;IACb,WAAW,CAAc;IACzB,aAAa,CAAgB;IAC7B,aAAa,CAAiC;IAEtD,YAAY,WAAwB,EAAE,aAA4B;QAC9D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,aAAa,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,IAAY;QACf,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;QAC1C,IAAI,CAAC,aAAa,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,cAAc,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,IAAI,KAAK,IAAI,CAAC;QAChF,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,eAAuB,EAAE,YAAoB,EAAE,KAAW;QACnE,MAAM,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC;QAC1C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACtB,IAAI,CAAC,aAAa,GAAG,CAAC,MAAM,EAAE,EAAE;gBAC5B,IAAI,CAAC,cAAc,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AEG;IACH,aAAa,CAAC,QAAgB;QAC1B,OAAO,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IACtD,CAAC;CACJ"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main query interface - provides multiple access patterns
|
|
3
|
+
*/
|
|
4
|
+
import type { IfcDataStore } from '@ifc-lite/parser';
|
|
5
|
+
import { type SpatialHierarchy } from '@ifc-lite/data';
|
|
6
|
+
import { EntityQuery } from './entity-query.js';
|
|
7
|
+
import { EntityNode } from './entity-node.js';
|
|
8
|
+
import { type SQLResult } from './duckdb-integration.js';
|
|
9
|
+
import type { AABB } from '@ifc-lite/spatial';
|
|
10
|
+
export declare class IfcQuery {
|
|
11
|
+
private store;
|
|
12
|
+
private duckdb;
|
|
13
|
+
constructor(store: IfcDataStore);
|
|
14
|
+
sql(query: string): Promise<SQLResult>;
|
|
15
|
+
private ensureDuckDB;
|
|
16
|
+
walls(): EntityQuery;
|
|
17
|
+
doors(): EntityQuery;
|
|
18
|
+
windows(): EntityQuery;
|
|
19
|
+
slabs(): EntityQuery;
|
|
20
|
+
columns(): EntityQuery;
|
|
21
|
+
beams(): EntityQuery;
|
|
22
|
+
spaces(): EntityQuery;
|
|
23
|
+
ofType(...types: string[]): EntityQuery;
|
|
24
|
+
all(): EntityQuery;
|
|
25
|
+
byId(expressId: number): EntityQuery;
|
|
26
|
+
entity(expressId: number): EntityNode;
|
|
27
|
+
inBounds(aabb: AABB): EntityQuery;
|
|
28
|
+
onStorey(storeyId: number): EntityQuery;
|
|
29
|
+
raycast(origin: [number, number, number], direction: [number, number, number]): number[];
|
|
30
|
+
get hierarchy(): SpatialHierarchy | null;
|
|
31
|
+
get project(): EntityNode | null;
|
|
32
|
+
get storeys(): EntityNode[];
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=ifc-query.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc-query.d.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AAgB,GAAG,IAAI,CAEvC;IAED,IAAI,OAAO,IAAI,UAAU,GAAG,IAAI,CAG/B;IAED,IAAI,OAAO,IAAI,UAAU,EAAE,CAS1B;CACF"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
import { IfcTypeEnumFromString } from '@ifc-lite/data';
|
|
5
|
+
import { EntityQuery } from './entity-query.js';
|
|
6
|
+
import { EntityNode } from './entity-node.js';
|
|
7
|
+
import { DuckDBIntegration } from './duckdb-integration.js';
|
|
8
|
+
export class IfcQuery {
|
|
9
|
+
store;
|
|
10
|
+
duckdb = null;
|
|
11
|
+
constructor(store) {
|
|
12
|
+
this.store = store;
|
|
13
|
+
}
|
|
14
|
+
// ═══════════════════════════════════════════════════════════════
|
|
15
|
+
// SQL API - Full SQL power via DuckDB-WASM
|
|
16
|
+
// ═══════════════════════════════════════════════════════════════
|
|
17
|
+
async sql(query) {
|
|
18
|
+
await this.ensureDuckDB();
|
|
19
|
+
return this.duckdb.query(query);
|
|
20
|
+
}
|
|
21
|
+
async ensureDuckDB() {
|
|
22
|
+
if (!this.duckdb) {
|
|
23
|
+
const available = await DuckDBIntegration.isAvailable();
|
|
24
|
+
if (!available) {
|
|
25
|
+
throw new Error('DuckDB-WASM is not available. Install @duckdb/duckdb-wasm to use SQL queries.');
|
|
26
|
+
}
|
|
27
|
+
this.duckdb = new DuckDBIntegration();
|
|
28
|
+
await this.duckdb.init(this.store);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
// ═══════════════════════════════════════════════════════════════
|
|
32
|
+
// FLUENT API - Type-safe query builder
|
|
33
|
+
// ═══════════════════════════════════════════════════════════════
|
|
34
|
+
walls() {
|
|
35
|
+
return this.ofType('IfcWall', 'IfcWallStandardCase');
|
|
36
|
+
}
|
|
37
|
+
doors() {
|
|
38
|
+
return this.ofType('IfcDoor');
|
|
39
|
+
}
|
|
40
|
+
windows() {
|
|
41
|
+
return this.ofType('IfcWindow');
|
|
42
|
+
}
|
|
43
|
+
slabs() {
|
|
44
|
+
return this.ofType('IfcSlab');
|
|
45
|
+
}
|
|
46
|
+
columns() {
|
|
47
|
+
return this.ofType('IfcColumn');
|
|
48
|
+
}
|
|
49
|
+
beams() {
|
|
50
|
+
return this.ofType('IfcBeam');
|
|
51
|
+
}
|
|
52
|
+
spaces() {
|
|
53
|
+
return this.ofType('IfcSpace');
|
|
54
|
+
}
|
|
55
|
+
ofType(...types) {
|
|
56
|
+
const typeEnums = types.map(t => IfcTypeEnumFromString(t));
|
|
57
|
+
return new EntityQuery(this.store, typeEnums);
|
|
58
|
+
}
|
|
59
|
+
all() {
|
|
60
|
+
return new EntityQuery(this.store, null);
|
|
61
|
+
}
|
|
62
|
+
byId(expressId) {
|
|
63
|
+
return new EntityQuery(this.store, null, [expressId]);
|
|
64
|
+
}
|
|
65
|
+
// ═══════════════════════════════════════════════════════════════
|
|
66
|
+
// GRAPH API - Relationship traversal
|
|
67
|
+
// ═══════════════════════════════════════════════════════════════
|
|
68
|
+
entity(expressId) {
|
|
69
|
+
return new EntityNode(this.store, expressId);
|
|
70
|
+
}
|
|
71
|
+
// ═══════════════════════════════════════════════════════════════
|
|
72
|
+
// SPATIAL API - Geometry-based queries
|
|
73
|
+
// ═══════════════════════════════════════════════════════════════
|
|
74
|
+
inBounds(aabb) {
|
|
75
|
+
if (!this.store.spatialIndex) {
|
|
76
|
+
throw new Error('Spatial index not available. Geometry must be processed first.');
|
|
77
|
+
}
|
|
78
|
+
const ids = this.store.spatialIndex.queryAABB(aabb);
|
|
79
|
+
return new EntityQuery(this.store, null, ids);
|
|
80
|
+
}
|
|
81
|
+
onStorey(storeyId) {
|
|
82
|
+
if (!this.store.spatialHierarchy) {
|
|
83
|
+
throw new Error('Spatial hierarchy not available.');
|
|
84
|
+
}
|
|
85
|
+
const ids = this.store.spatialHierarchy.byStorey.get(storeyId) ?? [];
|
|
86
|
+
return new EntityQuery(this.store, null, ids);
|
|
87
|
+
}
|
|
88
|
+
raycast(origin, direction) {
|
|
89
|
+
if (!this.store.spatialIndex) {
|
|
90
|
+
throw new Error('Spatial index not available. Geometry must be processed first.');
|
|
91
|
+
}
|
|
92
|
+
return this.store.spatialIndex.raycast(origin, direction);
|
|
93
|
+
}
|
|
94
|
+
// ═══════════════════════════════════════════════════════════════
|
|
95
|
+
// SPATIAL HIERARCHY ACCESS
|
|
96
|
+
// ═══════════════════════════════════════════════════════════════
|
|
97
|
+
get hierarchy() {
|
|
98
|
+
return this.store.spatialHierarchy ?? null;
|
|
99
|
+
}
|
|
100
|
+
get project() {
|
|
101
|
+
if (!this.store.spatialHierarchy)
|
|
102
|
+
return null;
|
|
103
|
+
return this.entity(this.store.spatialHierarchy.project.expressId);
|
|
104
|
+
}
|
|
105
|
+
get storeys() {
|
|
106
|
+
if (!this.store.spatialHierarchy)
|
|
107
|
+
return [];
|
|
108
|
+
return [...this.store.spatialHierarchy.byStorey.keys()]
|
|
109
|
+
.sort((a, b) => {
|
|
110
|
+
const elevA = this.store.spatialHierarchy.storeyElevations.get(a) ?? 0;
|
|
111
|
+
const elevB = this.store.spatialHierarchy.storeyElevations.get(b) ?? 0;
|
|
112
|
+
return elevA - elevB;
|
|
113
|
+
})
|
|
114
|
+
.map(id => this.entity(id));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=ifc-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ifc-query.js","sourceRoot":"","sources":["../../../src/ifc-query.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAO/D,OAAO,EAAE,qBAAqB,EAAyB,MAAM,gBAAgB,CAAC;AAC9E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,C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,CAAC;YACxE,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,gBAAiB,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YACxE,OAAO,KAAK,GAAG,KAAK,CAAC;QACvB,CAAC,CAAC;aACD,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;IAChC,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @ifc-lite/query - Query system
|
|
3
|
+
*/
|
|
4
|
+
export { PropertyTable } from './property-table.js';
|
|
5
|
+
export { EntityTable } from './entity-table.js';
|
|
6
|
+
export { QueryBuilder, QueryInterface } from './fluent-api.js';
|
|
7
|
+
export { IfcQuery } from './ifc-query.js';
|
|
8
|
+
export { EntityQuery, type ComparisonOperator } from './entity-query.js';
|
|
9
|
+
export { EntityNode } from './entity-node.js';
|
|
10
|
+
export { QueryResultEntity } from './query-result-entity.js';
|
|
11
|
+
export { DuckDBIntegration, type SQLResult } from './duckdb-integration.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
+
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
4
|
+
/**
|
|
5
|
+
* @ifc-lite/query - Query system
|
|
6
|
+
*/
|
|
7
|
+
export { PropertyTable } from './property-table.js';
|
|
8
|
+
export { EntityTable } from './entity-table.js';
|
|
9
|
+
export { QueryBuilder, QueryInterface } from './fluent-api.js';
|
|
10
|
+
export { IfcQuery } from './ifc-query.js';
|
|
11
|
+
export { EntityQuery } from './entity-query.js';
|
|
12
|
+
export { EntityNode } from './entity-node.js';
|
|
13
|
+
export { QueryResultEntity } from './query-result-entity.js';
|
|
14
|
+
export { DuckDBIntegration } from './duckdb-integration.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA;;+DAE+D;AAE/D;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAA2B,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAkB,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Columnar property table - efficient storage and querying
|
|
3
|
+
*/
|
|
4
|
+
import type { PropertySet, PropertyValue } from '@ifc-lite/parser';
|
|
5
|
+
export declare class PropertyTable {
|
|
6
|
+
private propertySets;
|
|
7
|
+
private entityPropertyMap;
|
|
8
|
+
constructor();
|
|
9
|
+
/**
|
|
10
|
+
* Add property set
|
|
11
|
+
*/
|
|
12
|
+
addPropertySet(id: number, propertySet: PropertySet): void;
|
|
13
|
+
/**
|
|
14
|
+
* Associate property set with entity
|
|
15
|
+
*/
|
|
16
|
+
associatePropertySet(entityId: number, propertySetId: number): void;
|
|
17
|
+
/**
|
|
18
|
+
* Get property value for entity
|
|
19
|
+
*/
|
|
20
|
+
getProperty(entityId: number, propertySetName: string, propertyName: string): PropertyValue | null;
|
|
21
|
+
/**
|
|
22
|
+
* Get all properties for entity
|
|
23
|
+
*/
|
|
24
|
+
getProperties(entityId: number): Map<string, PropertySet>;
|
|
25
|
+
/**
|
|
26
|
+
* Find entities with property matching value
|
|
27
|
+
*/
|
|
28
|
+
findEntities(propertySetName: string, propertyName: string, value: any): number[];
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=property-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"property-table.d.ts","sourceRoot":"","sources":["../../../src/property-table.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEnE,qBAAa,aAAa;IACxB,OAAO,CAAC,YAAY,CAA2B;IAC/C,OAAO,CAAC,iBAAiB,CAAwB;;IAOjD;;OAEG;IACH,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI;IAI1D;;OAEG;IACH,oBAAoB,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IASnE;;OAEG;IACH,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI;IAclG;;OAEG;IACH,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,WAAW,CAAC;IAezD;;OAEG;IACH,YAAY,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,GAAG,MAAM,EAAE;CAkBlF"}
|