Back to Home

ESO Lua File v100034

ingame/tradinghouse/tradinghousecategories_shared.lua

[◄ back to folders ]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
ZO_TradingHouseSearchCategoryFeature_Shared = ZO_Object:Subclass()
function ZO_TradingHouseSearchCategoryFeature_Shared:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_TradingHouseSearchCategoryFeature_Shared:Initialize(...)
    -- override me
end
function ZO_TradingHouseSearchCategoryFeature_Shared:SelectCategoryParams(categoryParams, subcategoryKey)
    assert(false, "override me")
end
function ZO_TradingHouseSearchCategoryFeature_Shared:GetCategoryParams()
    assert(false, "override me")
end
function ZO_TradingHouseSearchCategoryFeature_Shared:GetSubcategoryKey()
    assert(false, "override me")
end
function ZO_TradingHouseSearchCategoryFeature_Shared:GetFeatureForKey(featureKey)
    assert(false, "override me")
end
function ZO_TradingHouseSearchCategoryFeature_Shared:SelectCategory(categoryKey, subcategoryKey)
    local categoryParams = ZO_TRADING_HOUSE_CATEGORY_KEY_TO_PARAMS[categoryKey]
    self:SelectCategoryParams(categoryParams, subcategoryKey)
end
function ZO_TradingHouseSearchCategoryFeature_Shared:ApplyToSearch(search)
    local categoryParams = self:GetCategoryParams()
    if categoryParams then
        local applyToSearch = categoryParams:GetApplyToSearchCallback()
        local subcategoryIndex = categoryParams:GetSubcategoryIndexForKey(self:GetSubcategoryKey())
        local subcategoryValue = subcategoryIndex and categoryParams:GetSubcategoryValue(subcategoryIndex)
        applyToSearch(search, subcategoryValue)
        for _, featureKey in categoryParams:FeatureKeyIterator() do
            local feature = self:GetFeatureForKey(featureKey)
            feature:ApplyToSearch(search)
        end
    end
end
function ZO_TradingHouseSearchCategoryFeature_Shared:ResetSearch()
    for _, featureObject in pairs(self.featureKeyToFeatureObjectMap) do
        featureObject:ResetSearch()
    end
    self:SelectCategory("AllItems")
end
function ZO_TradingHouseSearchCategoryFeature_Shared:SaveToTable(searchTable)
    local categoryParams = self:GetCategoryParams()
    if categoryParams then
        searchTable["SearchCategory"] = categoryParams:GetKey()
        searchTable["SearchSubcategory"] = self:GetSubcategoryKey()
        for _, featureKey in categoryParams:FeatureKeyIterator() do
            local feature = self:GetFeatureForKey(featureKey)
            feature:SaveToTable(searchTable)
        end
    end
end
function ZO_TradingHouseSearchCategoryFeature_Shared:LoadFromTable(searchTable)
    if searchTable["SearchCategory"] then
        self:SelectCategory(searchTable["SearchCategory"], searchTable["SearchSubcategory"])
        local categoryParams = self:GetCategoryParams()
        if categoryParams then
            for _, featureKey in categoryParams:FeatureKeyIterator() do
                local feature = self:GetFeatureForKey(featureKey)
                feature:LoadFromTable(searchTable)
            end
        end
    end
end
function ZO_TradingHouseSearchCategoryFeature_Shared:GetCategoryDescriptionFromTable(searchTable)
    if searchTable["SearchCategory"] then
        local categoryParams = ZO_TRADING_HOUSE_CATEGORY_KEY_TO_PARAMS[searchTable["SearchCategory"]]
        if categoryParams then
            local categoryStrings = {}
            -- skip header if the category is an 'all X' category, these tend to be redundant, eg. 'all weapons' for 'weapons'
            if not categoryParams:IsAllItemsCategory() then
                table.insert(categoryStrings, GetString("SI_TRADINGHOUSECATEGORYHEADER", categoryParams:GetHeader()))
            end
            table.insert(categoryStrings, categoryParams:GetFormattedName())
            -- skip missing or the initial 'all' subcategories, these don't add qualifying info to the description
            local subcategoryIndex = categoryParams:GetSubcategoryIndexForKey(searchTable["SearchSubcategory"])
            if subcategoryIndex and subcategoryIndex ~= 1 then
                table.insert(categoryStrings, categoryParams:GetSubcategoryName(subcategoryIndex))
            end
            return ZO_GenerateCommaSeparatedListWithoutAnd(categoryStrings)
        end
    end
    return nil
end
function ZO_TradingHouseSearchCategoryFeature_Shared:AddContextualFeatureDescriptionsFromTable(searchTable, featureDescriptions)
    if searchTable["SearchCategory"] then
        local categoryParams = ZO_TRADING_HOUSE_CATEGORY_KEY_TO_PARAMS[searchTable["SearchCategory"]]
        if categoryParams then
            local categoryDescription = self:GetCategoryDescriptionFromTable(searchTable)
            table.insert(featureDescriptions, {name = GetString("SI_TRADINGHOUSEFEATURECATEGORY", TRADING_HOUSE_FEATURE_CATEGORY_ITEM_CATEGORY), description = categoryDescription})
            for _, featureKey in categoryParams:FeatureKeyIterator() do
                local feature = self:GetFeatureForKey(featureKey)
                local description = feature:GetDescriptionFromTable(searchTable)
                if description then
                    table.insert(featureDescriptions, {name = feature:GetDisplayName(), description = description})
                end
            end
        end
    end
end
function ZO_TradingHouseSearchCategoryFeature_Shared:LoadFromItem(itemLink)
    local matchedCategory = false
    for _, categoryParams in ipairs(ZO_TRADING_HOUSE_CATEGORY_PARAMS_LIST) do
        local containsItem, subcategoryKey = categoryParams:ContainsItem(itemLink)
        if containsItem then
            --if we didn't match a specific subcategory use the first subcategory (the all subcategory)
            if subcategoryKey == nil then
                subcategoryKey = categoryParams:GetSubcategoryKey(1)
            end
            self:SelectCategoryParams(categoryParams, subcategoryKey)
            matchedCategory = true
            break
        end
    end
    if not matchedCategory then
        self:SelectCategory("AllItems")
    end
    local categoryParams = self:GetCategoryParams()
    for _, featureKey in categoryParams:FeatureKeyIterator() do
        local feature = self:GetFeatureForKey(featureKey)
        feature:LoadFromItem(itemLink)
    end
end
ZO_TradingHouseCategory_Params = ZO_Object:Subclass()
function ZO_TradingHouseCategory_Params:New(...)
    local object = ZO_Object.New(self)
    object:Initialize(...)
    return object
end
function ZO_TradingHouseCategory_Params:Initialize(key)
    self.key = key
    self.subcategories = {}
    self.subcategoryIndexForKey = {}
    self.featureKeys = {}
end
function ZO_TradingHouseCategory_Params:GetKey()
    return self.key
end
function ZO_TradingHouseCategory_Params:SetName(categoryName)
    internalassert(categoryName and categoryName ~= "")
    self.name = categoryName
end
function ZO_TradingHouseCategory_Params:GetFormattedName()
    return ZO_CachedStrFormat(SI_TRADING_HOUSE_BROWSE_CATEGORY_FORMATTER, self.name)
end
function ZO_TradingHouseCategory_Params:SetHeader(header)
    self.header = header
end
function ZO_TradingHouseCategory_Params:GetHeader()
    return self.header
end
function ZO_TradingHouseCategory_Params:SetIsAllItemsCategory(isAllItemsCategory)
    self.isAllItemsCategory = isAllItemsCategory
end
function ZO_TradingHouseCategory_Params:IsAllItemsCategory()
    return self.isAllItemsCategory
end
function ZO_TradingHouseCategory_Params:SetApplyToSearchCallback(applyToSearchCallback)
end
function ZO_TradingHouseCategory_Params:GetApplyToSearchCallback()
    return self.applyToSearchCallback
end
function ZO_TradingHouseCategory_Params:SetContainsItemCallback(containsItemCallback)
end
function ZO_TradingHouseCategory_Params:ContainsItem(itemLink)
    if self.containsItemCallback then
        return self.containsItemCallback(itemLink)
    else
        return false
    end
end
function ZO_TradingHouseCategory_Params:AddSubcategory(subcategoryKey, subcategoryName, subcategoryIcons, subcategoryValue)
    local index = #self.subcategories + 1
    self.subcategories[index] =
    {
        key = subcategoryKey,
        name = subcategoryName,
        icons = subcategoryIcons,
        value = subcategoryValue,
    }
    self.subcategoryIndexForKey[subcategoryKey] = index
end
function ZO_TradingHouseCategory_Params:GetNumSubcategories()
    return #self.subcategories
end
function ZO_TradingHouseCategory_Params:GetSubcategoryKey(subcategoryIndex)
    return self.subcategories[subcategoryIndex].key
end
function ZO_TradingHouseCategory_Params:GetSubcategoryName(subcategoryIndex)
    return self.subcategories[subcategoryIndex].name
end
function ZO_TradingHouseCategory_Params:GetSubcategoryIcons(subcategoryIndex)
    return self.subcategories[subcategoryIndex].icons
end
function ZO_TradingHouseCategory_Params:GetSubcategoryValue(subcategoryIndex)
    return self.subcategories[subcategoryIndex].value
end
function ZO_TradingHouseCategory_Params:AddFeatureKeys(...)
    for i = 1, select('#', ...) do
        local featureKey = select(i, ...)
        table.insert(self.featureKeys, featureKey)
    end
end
function ZO_TradingHouseCategory_Params:FeatureKeyIterator()
    return ipairs(self.featureKeys)
end
function ZO_TradingHouseCategory_Params:FeatureKeyReverseIterator()
    return ZO_NumericallyIndexedTableReverseIterator(self.featureKeys)
end
function ZO_TradingHouseCategory_Params:GetSubcategoryIndexForKey(subcategoryKey)
    return self.subcategoryIndexForKey[subcategoryKey]
end
-----------------------------
-- Search Category Helpers --
-----------------------------
ZO_TRADING_HOUSE_CATEGORY_PARAMS_LIST = {}
ZO_TRADING_HOUSE_CATEGORY_KEY_TO_PARAMS = {}
local function AddCategory(key)
    internalassert(ZO_TRADING_HOUSE_CATEGORY_KEY_TO_PARAMS[key] == nil)
    local categoryParams = ZO_TradingHouseCategory_Params:New(key)
    table.insert(ZO_TRADING_HOUSE_CATEGORY_PARAMS_LIST, categoryParams)
    ZO_TRADING_HOUSE_CATEGORY_KEY_TO_PARAMS[key] = categoryParams
    return categoryParams
end
local function AddAllSubcategory(params, allItemsString, value)
    allItemsString = allItemsString or GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL)
    params:AddSubcategory("AllSubcategories", allItemsString, ZO_ItemFilterUtils.GetItemTypeDisplayCategoryFilterIcons(ITEM_TYPE_DISPLAY_CATEGORY_ALL), value)
end
local function AddEnumSubcategories(categoryParams, subcategoryParams)
    local enumStringPrefix = subcategoryParams.enumStringPrefix
    local enumKeyPrefix = subcategoryParams.enumKeyPrefix
    local allItemsString = subcategoryParams.allItemsString
    local iconsForEnumValue = subcategoryParams.iconsForEnumValue
    local enumValues = subcategoryParams.enumValues
    local keyOverrideForEnumValue = subcategoryParams.keyOverrideForEnumValue or {}
    -- If there is only one enum value, make it look like an all tab
    if #enumValues == 1 then
        AddAllSubcategory(categoryParams, allItemsString, enumValues[1])
        return
    end
    local allValues = {}
    for _, enumValue in ipairs(enumValues) do
        table.insert(allValues, enumValue)
    end
    AddAllSubcategory(categoryParams, allItemsString, allValues)
    for _, enumValue in ipairs(enumValues) do
        local key = keyOverrideForEnumValue[enumValue] or string.format("%s%d", enumKeyPrefix, enumValue)
        categoryParams:AddSubcategory(key, GetString(enumStringPrefix, enumValue), iconsForEnumValue[enumValue], enumValue)
    end
end
do
    local function ApplyAllItemsToSearch(search)
        -- No filters
    end
    function AddAllItemsCategory()
        local categoryParams = AddCategory("AllItems")
        categoryParams:SetName(GetString("SI_TRADINGHOUSECATEGORYHEADER_ALLCATEGORIES", TRADING_HOUSE_CATEGORY_HEADER_ALL_ITEMS))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_ALL_ITEMS)
        categoryParams:SetIsAllItemsCategory(true)
        categoryParams:SetApplyToSearchCallback(ApplyAllItemsToSearch)
        -- no features
        AddAllSubcategory(categoryParams, GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL))
    end
end
do
    internalassert(EQUIPMENT_FILTER_TYPE_MAX_VALUE == 11, "Update weapons in trading house")
    internalassert(WEAPONTYPE_MAX_VALUE == 15, "Update weapons in trading house")
    local ICONS_FOR_WEAPON_TYPE =
    {
        [WEAPONTYPE_AXE] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_AXE),
        [WEAPONTYPE_HAMMER] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_HAMMER),
        [WEAPONTYPE_SWORD] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_SWORD),
        [WEAPONTYPE_DAGGER] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_DAGGER),
        [WEAPONTYPE_TWO_HANDED_AXE] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_TWO_HANDED_AXE),
        [WEAPONTYPE_TWO_HANDED_HAMMER] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_TWO_HANDED_HAMMER),
        [WEAPONTYPE_TWO_HANDED_SWORD] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_TWO_HANDED_SWORD),
        [WEAPONTYPE_FIRE_STAFF] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_FIRE_STAFF),
        [WEAPONTYPE_FROST_STAFF] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_FROST_STAFF),
        [WEAPONTYPE_LIGHTNING_STAFF] = ZO_ItemFilterUtils.GetWeaponTypeFilterIcons(WEAPONTYPE_LIGHTNING_STAFF),
        -- WEAPONTYPE_BOW and WEAPONTYPE_HEALING_STAFF do not have subcategories, so they do not need subcategory icons
    }
    local EVERY_VALID_WEAPON_TYPE = ZO_ItemFilterUtils.GetAllWeaponTypesInEquipmentFilterTypes()
    local function ApplyAllWeaponsToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, ITEMTYPE_WEAPON)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_WEAPON, EVERY_VALID_WEAPON_TYPE)
    end
    local function ApplyWeaponToSearch(search, weaponType)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, ITEMTYPE_WEAPON)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_WEAPON, weaponType)
    end
    function AddAllWeaponsCategory(equipmentFilterType)
        local categoryParams = AddCategory("AllWeapons")
        categoryParams:SetName(GetString("SI_TRADINGHOUSECATEGORYHEADER_ALLCATEGORIES", TRADING_HOUSE_CATEGORY_HEADER_WEAPONS))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_WEAPONS)
        categoryParams:SetIsAllItemsCategory(true)
        categoryParams:SetApplyToSearchCallback(ApplyAllWeaponsToSearch)
        categoryParams:AddFeatureKeys("LevelRange", "WeaponTraits", "WeaponEnchantments")
        AddAllSubcategory(categoryParams)
    end
    function AddWeaponCategory(equipmentFilterType)
        local weaponTypes = ZO_ItemFilterUtils.GetWeaponTypesByEquipmentFilterType(equipmentFilterType)
        local categoryParams = AddCategory(string.format("Weapons%d", equipmentFilterType))
        categoryParams:SetName(GetString("SI_EQUIPMENTFILTERTYPE", equipmentFilterType))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_WEAPONS)
        local SUBCATEGORY_ENUM_KEY_PREFIX = "WeaponType"
        categoryParams:SetApplyToSearchCallback(ApplyWeaponToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            local weaponType = GetItemLinkWeaponType(itemLink)
            for _, searchWeaponType in ipairs(weaponTypes) do
                if weaponType == searchWeaponType then
                    return true, SUBCATEGORY_ENUM_KEY_PREFIX .. weaponType
                end
            end
            return false
        end)
        categoryParams:AddFeatureKeys("LevelRange", "WeaponTraits", "WeaponEnchantments")
        AddEnumSubcategories(categoryParams,
        {
            enumKeyPrefix = SUBCATEGORY_ENUM_KEY_PREFIX,
            enumStringPrefix = "SI_WEAPONTYPE",
            allItemsString = GetString(SI_TRADING_HOUSE_BROWSE_ALL_WEAPON_TYPES),
            iconsForEnumValue = ICONS_FOR_WEAPON_TYPE,
            enumValues = weaponTypes,
        })
    end
end
do
    internalassert(ARMORTYPE_MAX_VALUE == 3, "Do you need to update the trading house?")
    local ICONS_FOR_ARMOR_EQUIP_TYPE =
    {
        [EQUIP_TYPE_CHEST] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_CHEST),
        [EQUIP_TYPE_FEET] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_FEET),
        [EQUIP_TYPE_HAND] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_HAND),
        [EQUIP_TYPE_HEAD] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_HEAD),
        [EQUIP_TYPE_LEGS] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_LEGS),
        [EQUIP_TYPE_SHOULDERS] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_SHOULDERS),
        [EQUIP_TYPE_WAIST] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_WAIST),
    }
    local ARMOR_EQUIP_TYPES =
    {
        EQUIP_TYPE_CHEST,
        EQUIP_TYPE_FEET,
        EQUIP_TYPE_HAND,
        EQUIP_TYPE_HEAD,
        EQUIP_TYPE_LEGS,
        EQUIP_TYPE_SHOULDERS,
        EQUIP_TYPE_WAIST,
    }
    -- So this is a bit clever: Each piece of apparel has a slot it can be equipped to, so we enumerate those.
    -- then we also need to catch shields, so we specify that the weapon type must either be SHIELD or NONE (which is the value all non-weapons have)
    -- This catches normal armor, and shields.
    local ALL_APPAREL_EQUIP_TYPES = { EQUIP_TYPE_OFF_HAND }
    ZO_CombineNumericallyIndexedTables(ALL_APPAREL_EQUIP_TYPES, ARMOR_EQUIP_TYPES)
    local ALL_APPAREL_WEAPON_TYPES =
    {
        WEAPON_TYPE_NONE,
        WEAPON_TYPE_SHIELD
    }
    local function ApplyAllApparelToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_EQUIP, ALL_APPAREL_EQUIP_TYPES)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_WEAPON, ALL_APPAREL_WEAPON_TYPES)
    end
    function AddAllApparelCategory()
        local categoryParams = AddCategory("AllApparel")
        categoryParams:SetName(GetString("SI_TRADINGHOUSECATEGORYHEADER_ALLCATEGORIES", TRADING_HOUSE_CATEGORY_HEADER_APPAREL))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_APPAREL)
        categoryParams:SetIsAllItemsCategory(true)
        categoryParams:SetApplyToSearchCallback(ApplyAllApparelToSearch)
        categoryParams:AddFeatureKeys("LevelRange", "ArmorTraits", "ArmorEnchantments")
        AddAllSubcategory(categoryParams)
    end
    function AddArmorCategory(armorType)
        local function ApplyArmorToSearch(search, subcategoryValue)
            search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, ITEMTYPE_ARMOR)
            search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ARMOR, armorType)
            search:SetFilter(TRADING_HOUSE_FILTER_TYPE_EQUIP, subcategoryValue)
        end
        local categoryParams = AddCategory(string.format("Armor%d", armorType))
        categoryParams:SetName(GetString("SI_ARMORTYPE_TRADINGHOUSECATEGORY", armorType))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_APPAREL)
        local SUBCATEGORY_ENUM_KEY_PREFIX = "EquipType"
        categoryParams:SetApplyToSearchCallback(ApplyArmorToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            if armorType == GetItemLinkArmorType(itemLink) then
                local equipType = GetItemLinkEquipType(itemLink)
                for _, searchEquipType in ipairs(ARMOR_EQUIP_TYPES) do
                    if searchEquipType == equipType then
                        return true, SUBCATEGORY_ENUM_KEY_PREFIX..equipType
                    end
                end
            end
            return false
        end)
        categoryParams:AddFeatureKeys("LevelRange", "ArmorTraits", "ArmorEnchantments")
        AddEnumSubcategories(categoryParams,
        {
            enumKeyPrefix = SUBCATEGORY_ENUM_KEY_PREFIX,
            enumStringPrefix = "SI_EQUIPTYPE",
            allItemsString = GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL_WORN_ARMOR_TYPES),
            iconsForEnumValue = ICONS_FOR_ARMOR_EQUIP_TYPE,
            enumValues = ARMOR_EQUIP_TYPES,
        })
    end
    local function ApplyShieldToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_WEAPON, WEAPONTYPE_SHIELD)
    end
    function AddShieldCategory()
        local categoryParams = AddCategory("Shield")
        categoryParams:SetName(GetString(SI_TRADING_HOUSE_BROWSE_ARMOR_TYPE_SHIELD))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_APPAREL)
        categoryParams:SetApplyToSearchCallback(ApplyShieldToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            return GetItemLinkWeaponType(itemLink) == WEAPONTYPE_SHIELD
        end)
        categoryParams:AddFeatureKeys("LevelRange", "ArmorTraits", "ArmorEnchantments")
        AddAllSubcategory(categoryParams)
    end
end
do
    local ICONS_FOR_JEWELRY_EQUIP_TYPE = 
    {
        [EQUIP_TYPE_NECK] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_NECK),
        [EQUIP_TYPE_RING] = ZO_ItemFilterUtils.GetEquipTypeFilterIcons(EQUIP_TYPE_RING),
    }
    local JEWELRY_EQUIP_TYPES =
    {
        EQUIP_TYPE_NECK,
        EQUIP_TYPE_RING,
    }
    local function ApplyJewelryToSearch(search, subcategoryValue)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, ITEMTYPE_ARMOR)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_EQUIP, subcategoryValue)
    end
    function AddJewelryCategory()
        local categoryParams = AddCategory("Jewelry")
        categoryParams:SetName(GetString("SI_TRADINGHOUSECATEGORYHEADER", TRADING_HOUSE_CATEGORY_HEADER_JEWELRY))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_JEWELRY)
        categoryParams:SetIsAllItemsCategory(true)
        local SUBCATEGORY_ENUM_KEY_PREFIX = "EquipType"
        categoryParams:SetApplyToSearchCallback(ApplyJewelryToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            local equipType = GetItemLinkEquipType(itemLink)
            for _, searchEquipType in ipairs(JEWELRY_EQUIP_TYPES) do
                if equipType == searchEquipType then
                    return true, SUBCATEGORY_ENUM_KEY_PREFIX..equipType
                end
            end
            return false
        end)
        categoryParams:AddFeatureKeys("LevelRange", "JewelryTraits", "JewelryEnchantments")
        AddEnumSubcategories(categoryParams,
        {
            enumKeyPrefix = SUBCATEGORY_ENUM_KEY_PREFIX,
            enumStringPrefix = "SI_EQUIPTYPE",
            allItemsString = GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL_WORN_ARMOR_TYPES),
            iconsForEnumValue = ICONS_FOR_JEWELRY_EQUIP_TYPE,
            enumValues = JEWELRY_EQUIP_TYPES,
        })
    end
end
do
    local g_allConsumableItemTypes = {}
    local function AddItemTypeToAllConsumables(itemType)
        if not ZO_IsElementInNumericallyIndexedTable(g_allConsumableItemTypes, itemType) then
            table.insert(g_allConsumableItemTypes, itemType)
        end
    end
    local function ApplyAllConsumablesToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, g_allConsumableItemTypes)
    end
    function AddAllConsumablesCategory()
        local categoryParams = AddCategory("AllConsumables")
        categoryParams:SetName(GetString("SI_TRADINGHOUSECATEGORYHEADER_ALLCATEGORIES", TRADING_HOUSE_CATEGORY_HEADER_CONSUMABLES))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_CONSUMABLES)
        categoryParams:SetIsAllItemsCategory(true)
        categoryParams:SetApplyToSearchCallback(ApplyAllConsumablesToSearch)
        categoryParams:AddFeatureKeys("LevelRange")
        AddAllSubcategory(categoryParams)
    end
    local SPECIALIZED_ITEM_TYPES_FOR_CONSUMABLE_ITEM_TYPE = 
    {
        [ITEMTYPE_RACIAL_STYLE_MOTIF] =
        {
            SPECIALIZED_ITEMTYPE_RACIAL_STYLE_MOTIF_CHAPTER,
            SPECIALIZED_ITEMTYPE_RACIAL_STYLE_MOTIF_BOOK,
        },
        [ITEMTYPE_MASTER_WRIT] =
        {
            SPECIALIZED_ITEMTYPE_MASTER_WRIT,
            SPECIALIZED_ITEMTYPE_HOLIDAY_WRIT,
        },
    }
    internalassert(PROVISIONER_SPECIAL_INGREDIENT_TYPE_MAX_VALUE == 3, "Update trading house recipe categories")
    local SPECIALIZED_ITEM_TYPES_FOR_SPECIAL_INGREDIENT_TYPE = 
    {
        [PROVISIONER_SPECIAL_INGREDIENT_TYPE_SPICES] =
        {
            SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_STANDARD_FOOD,
        },
        [PROVISIONER_SPECIAL_INGREDIENT_TYPE_FLAVORING] =
        {
            SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_STANDARD_DRINK,
        },
        [PROVISIONER_SPECIAL_INGREDIENT_TYPE_FURNISHING] =
        {
            SPECIALIZED_ITEMTYPE_RECIPE_BLACKSMITHING_DIAGRAM_FURNISHING,
            SPECIALIZED_ITEMTYPE_RECIPE_CLOTHIER_PATTERN_FURNISHING,
            SPECIALIZED_ITEMTYPE_RECIPE_ENCHANTING_SCHEMATIC_FURNISHING,
            SPECIALIZED_ITEMTYPE_RECIPE_ALCHEMY_FORMULA_FURNISHING,
            SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_DESIGN_FURNISHING,
            SPECIALIZED_ITEMTYPE_RECIPE_WOODWORKING_BLUEPRINT_FURNISHING,
            SPECIALIZED_ITEMTYPE_RECIPE_JEWELRYCRAFTING_SKETCH_FURNISHING,
        },
    }
    local FEATURES_FOR_CONSUMABLE_ITEM_TYPE = 
    {
        [ITEMTYPE_FOOD] = { "LevelRange" },
        [ITEMTYPE_DRINK] = { "LevelRange" },
        [ITEMTYPE_POTION] = { "LevelRange" },
        [ITEMTYPE_POISON] = { "LevelRange" },
    }
    local ICONS_FOR_CONSUMABLE_SPECIALIZED_ITEM_TYPE =
    {
        [SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_STANDARD_FOOD] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_STANDARD_FOOD),
        [SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_STANDARD_DRINK] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_STANDARD_DRINK),
        [SPECIALIZED_ITEMTYPE_RECIPE_BLACKSMITHING_DIAGRAM_FURNISHING] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_BLACKSMITHING_DIAGRAM_FURNISHING),
        [SPECIALIZED_ITEMTYPE_RECIPE_CLOTHIER_PATTERN_FURNISHING] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_CLOTHIER_PATTERN_FURNISHING),
        [SPECIALIZED_ITEMTYPE_RECIPE_ENCHANTING_SCHEMATIC_FURNISHING] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_ENCHANTING_SCHEMATIC_FURNISHING),
        [SPECIALIZED_ITEMTYPE_RECIPE_ALCHEMY_FORMULA_FURNISHING] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_ALCHEMY_FORMULA_FURNISHING),
        [SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_DESIGN_FURNISHING] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_PROVISIONING_DESIGN_FURNISHING),
        [SPECIALIZED_ITEMTYPE_RECIPE_WOODWORKING_BLUEPRINT_FURNISHING] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_WOODWORKING_BLUEPRINT_FURNISHING),
        [SPECIALIZED_ITEMTYPE_RECIPE_JEWELRYCRAFTING_SKETCH_FURNISHING] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RECIPE_JEWELRYCRAFTING_SKETCH_FURNISHING),
        [SPECIALIZED_ITEMTYPE_RACIAL_STYLE_MOTIF_CHAPTER] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RACIAL_STYLE_MOTIF_CHAPTER),
        [SPECIALIZED_ITEMTYPE_RACIAL_STYLE_MOTIF_BOOK] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_RACIAL_STYLE_MOTIF_BOOK),
        [SPECIALIZED_ITEMTYPE_MASTER_WRIT] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_MASTER_WRIT),
        [SPECIALIZED_ITEMTYPE_HOLIDAY_WRIT] = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_HOLIDAY_WRIT),
    }
    function AddConsumableCategory(mainItemType, ...)
        local allItemTypes = {mainItemType, ...}
        local specializedItemTypes = SPECIALIZED_ITEM_TYPES_FOR_CONSUMABLE_ITEM_TYPE[mainItemType]
        local features = FEATURES_FOR_CONSUMABLE_ITEM_TYPE[mainItemType]
        local function ApplyConsumableToSearch(search, specializedItemType)
            if specializedItemType then
                search:SetFilter(TRADING_HOUSE_FILTER_TYPE_SPECIALIZED_ITEM, specializedItemType)
            else
                search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, allItemTypes)
            end
        end
        local categoryParams = AddCategory(string.format("Consumable%d", mainItemType))
        categoryParams:SetName(GetString("SI_ITEMTYPE", mainItemType))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_CONSUMABLES)
        local SUBCATEGORY_ENUM_KEY_PREFIX = "SpecializedItemType"
        categoryParams:SetApplyToSearchCallback(ApplyConsumableToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            local itemLinkItemType, itemLinkSpecializedItemType = GetItemLinkItemType(itemLink)
            if itemLinkItemType == itemType then
                if specializedItemTypes then
                    return true, SUBCATEGORY_ENUM_KEY_PREFIX..itemLinkSpecializedItemType
                else
                    return true
                end
            else
                return false
            end
        end)
        if features then
            categoryParams:AddFeatureKeys(unpack(features))
        end
        if specializedItemTypes == nil then
            AddAllSubcategory(categoryParams)
        else
            AddEnumSubcategories(categoryParams,
            {
                enumKeyPrefix = SUBCATEGORY_ENUM_KEY_PREFIX,
                enumStringPrefix = "SI_SPECIALIZEDITEMTYPE",
                allItemsString = GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL_RECIPE_TYPES),
                iconsForEnumValue = ICONS_FOR_CONSUMABLE_SPECIALIZED_ITEM_TYPE,
                enumValues = specializedItemTypes,
            })
        end
        for _, itemType in ipairs(allItemTypes) do
            AddItemTypeToAllConsumables(itemType)
        end
    end
    function AddRecipeCategory(specialIngredientType)
        local specializedItemTypes = SPECIALIZED_ITEM_TYPES_FOR_SPECIAL_INGREDIENT_TYPE[specialIngredientType]
        local categoryParams = AddCategory(string.format("ConsumableRecipe%d", specialIngredientType))
        categoryParams:SetName(GetString("SI_PROVISIONERSPECIALINGREDIENTTYPE_TRADINGHOUSERECIPECATEGORY", specialIngredientType))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_CONSUMABLES)
        local SUBCATEGORY_ENUM_KEY_PREFIX = "SpecializedItemType"
        categoryParams:SetApplyToSearchCallback(function(search, specializedItemType)
            search:SetFilter(TRADING_HOUSE_FILTER_TYPE_SPECIALIZED_ITEM, specializedItemType)
        end)
        categoryParams:SetContainsItemCallback(function(itemLink)
            local itemLinkItemType, itemLinkSpecializedItemType = GetItemLinkItemType(itemLink)
            if ZO_IsElementInNumericallyIndexedTable(specializedItemTypes, itemLinkSpecializedItemType) then
                return true, SUBCATEGORY_ENUM_KEY_PREFIX..itemLinkSpecializedItemType
            end
            return false
        end)
        -- no features
        AddEnumSubcategories(categoryParams,
        {
            enumKeyPrefix = SUBCATEGORY_ENUM_KEY_PREFIX,
            enumStringPrefix = "SI_SPECIALIZEDITEMTYPE",
            allItemsString = GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL_RECIPE_TYPES),
            iconsForEnumValue = ICONS_FOR_CONSUMABLE_SPECIALIZED_ITEM_TYPE,
            enumValues = specializedItemTypes,
        })
        -- All recipes are consumables, even though we are only registering a subset of recipes per category.
        -- this will be called more than once, but that's okay because we deduplicate inside of AddItemTypeToAllConsumables().
        AddItemTypeToAllConsumables(ITEMTYPE_RECIPE)
    end
end
do
    local g_allMaterialItemTypes = {}
    local function AddItemTypeToAllMaterials(itemType)
        table.insert(g_allMaterialItemTypes, itemType)
    end
    local function ApplyAllMaterialsToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, g_allMaterialItemTypes)
    end
    function AddAllMaterialsCategory()
        local categoryParams = AddCategory("AllMaterials")
        categoryParams:SetName(GetString("SI_TRADINGHOUSECATEGORYHEADER_ALLCATEGORIES", TRADING_HOUSE_CATEGORY_HEADER_MATERIALS))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MATERIALS)
        categoryParams:SetIsAllItemsCategory(true)
        categoryParams:SetApplyToSearchCallback(ApplyAllMaterialsToSearch)
        -- No features
        AddAllSubcategory(categoryParams)
    end
    internalassert(CRAFTING_TYPE_MAX_VALUE == 7, "Add new tradeskill to trading house")
    local ICONS_FOR_TRADESKILL_ITEM_TYPES =
    {
        [ITEMTYPE_BLACKSMITHING_RAW_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_BLACKSMITHING_RAW_MATERIAL),
        [ITEMTYPE_BLACKSMITHING_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_BLACKSMITHING_MATERIAL),
        [ITEMTYPE_BLACKSMITHING_BOOSTER] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_BLACKSMITHING_BOOSTER),
        [ITEMTYPE_CLOTHIER_RAW_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_CLOTHIER_RAW_MATERIAL),
        [ITEMTYPE_CLOTHIER_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_CLOTHIER_MATERIAL),
        [ITEMTYPE_CLOTHIER_BOOSTER] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_CLOTHIER_BOOSTER),
        [ITEMTYPE_WOODWORKING_RAW_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_WOODWORKING_RAW_MATERIAL),
        [ITEMTYPE_WOODWORKING_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_WOODWORKING_MATERIAL),
        [ITEMTYPE_WOODWORKING_BOOSTER] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_WOODWORKING_BOOSTER),
        [ITEMTYPE_JEWELRYCRAFTING_RAW_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_JEWELRYCRAFTING_RAW_MATERIAL),
        [ITEMTYPE_JEWELRYCRAFTING_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_JEWELRYCRAFTING_MATERIAL),
        [ITEMTYPE_JEWELRYCRAFTING_RAW_BOOSTER] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_JEWELRYCRAFTING_RAW_BOOSTER),
        [ITEMTYPE_JEWELRYCRAFTING_BOOSTER] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_JEWELRYCRAFTING_BOOSTER),
        [ITEMTYPE_ENCHANTING_RUNE_POTENCY] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_ENCHANTING_RUNE_POTENCY),
        [ITEMTYPE_ENCHANTING_RUNE_ASPECT] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_ENCHANTING_RUNE_ASPECT),
        [ITEMTYPE_ENCHANTING_RUNE_ESSENCE] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_ENCHANTING_RUNE_ESSENCE),
        [ITEMTYPE_POTION_BASE] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_POTION_BASE),
        [ITEMTYPE_POISON_BASE] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_POISON_BASE),
        [ITEMTYPE_REAGENT] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_REAGENT),
        [ITEMTYPE_RAW_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_RAW_MATERIAL),
        [ITEMTYPE_STYLE_MATERIAL] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_STYLE_MATERIAL),
        [ITEMTYPE_WEAPON_TRAIT] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_WEAPON_TRAIT),
        [ITEMTYPE_ARMOR_TRAIT] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_ARMOR_TRAIT),
        [ITEMTYPE_JEWELRY_RAW_TRAIT] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_JEWELRY_RAW_TRAIT),
        [ITEMTYPE_JEWELRY_TRAIT] = ZO_ItemFilterUtils.GetItemTypeFilterIcons(ITEMTYPE_JEWELRY_TRAIT),
    }
    -- Used to make material item types "behave" as the same itemtype, to stay selected when browsing through materials, etc.
    local KEY_OVERRIDE_FOR_TRADESKILL_ITEM_TYPE =
    {
        [ITEMTYPE_BLACKSMITHING_RAW_MATERIAL] = "RawMaterial",
        [ITEMTYPE_BLACKSMITHING_MATERIAL] = "Material",
        [ITEMTYPE_BLACKSMITHING_BOOSTER] = "Booster",
        [ITEMTYPE_CLOTHIER_RAW_MATERIAL] = "RawMaterial",
        [ITEMTYPE_CLOTHIER_MATERIAL] = "Material",
        [ITEMTYPE_CLOTHIER_BOOSTER] = "Booster",
        [ITEMTYPE_WOODWORKING_RAW_MATERIAL] = "RawMaterial",
        [ITEMTYPE_WOODWORKING_MATERIAL] = "Material",
        [ITEMTYPE_WOODWORKING_BOOSTER] = "Booster",
        [ITEMTYPE_JEWELRYCRAFTING_RAW_MATERIAL] = "RawMaterial",
        [ITEMTYPE_JEWELRYCRAFTING_MATERIAL] = "Material",
        [ITEMTYPE_JEWELRYCRAFTING_BOOSTER] = "Booster",
        [ITEMTYPE_RAW_MATERIAL] = "RawMaterial",
        [ITEMTYPE_STYLE_MATERIAL] = "Material",
    }
    local function ApplyMaterialToSearch(search, itemType)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, itemType)
    end
    function AddTradeMaterialCategory(tradeskillType)
        local tradeskillName = GetCraftingSkillName(tradeskillType)
        local itemTypes = ZO_ItemFilterUtils.GetItemTypesByCraftingType(tradeskillType)
        local categoryParams = AddCategory(string.format("TradeMaterial%d", tradeskillType))
        categoryParams:SetName(tradeskillName)
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MATERIALS)
        local SUBCATEGORY_ENUM_KEY_PREFIX = "ItemType"
        categoryParams:SetApplyToSearchCallback(ApplyMaterialToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            local itemType = GetItemLinkItemType(itemLink)
            for _, searchItemType in ipairs(itemTypes) do
                if itemType == searchItemType then
                    return true, KEY_OVERRIDE_FOR_TRADESKILL_ITEM_TYPE[itemType]
                end
            end
            return false
        end)
        -- No features
        AddEnumSubcategories(categoryParams,
        {
            enumKeyPrefix = SUBCATEGORY_ENUM_KEY_PREFIX,
            enumStringPrefix = "SI_ITEMTYPE",
            allItemsString = GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL_MATERIALS),
            iconsForEnumValue = ICONS_FOR_TRADESKILL_ITEM_TYPES,
            enumValues = itemTypes,
            keyOverrideForEnumValue = KEY_OVERRIDE_FOR_TRADESKILL_ITEM_TYPE,
        })
        for _, itemType in ipairs(itemTypes) do
            AddItemTypeToAllMaterials(itemType)
        end
    end
    local PROVISIONING_INGREDIENT_SUBCATEGORIES =
    {
        {
            name = GetString(SI_TRADING_HOUSE_BROWSE_PROVISIONING_FOOD_INGREDIENTS),
            value = ZO_ItemFilterUtils.GetSpecializedItemTypesByItemTypeDisplayCategory(ITEM_TYPE_DISPLAY_CATEGORY_FOOD_INGREDIENT),
            icons = ZO_ItemFilterUtils.GetItemTypeDisplayCategoryFilterIcons(ITEM_TYPE_DISPLAY_CATEGORY_FOOD_INGREDIENT),
        },
        {
            name = GetString(SI_TRADING_HOUSE_BROWSE_PROVISIONING_DRINK_INGREDIENTS),
            value = ZO_ItemFilterUtils.GetSpecializedItemTypesByItemTypeDisplayCategory(ITEM_TYPE_DISPLAY_CATEGORY_DRINK_INGREDIENT),
            icons = ZO_ItemFilterUtils.GetItemTypeDisplayCategoryFilterIcons(ITEM_TYPE_DISPLAY_CATEGORY_DRINK_INGREDIENT),
        },
        {
            name = GetString(SI_TRADING_HOUSE_BROWSE_PROVISIONING_RARE_INGREDIENTS),
            value =
            {
                SPECIALIZED_ITEMTYPE_INGREDIENT_RARE,
            },
            icons = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_INGREDIENT_RARE),
        },
    }
    local function ApplyProvisioningIngredientToSearch(search, specializedItemType)
        if specializedItemType then
            search:SetFilter(TRADING_HOUSE_FILTER_TYPE_SPECIALIZED_ITEM, specializedItemType)
        else
            search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, ITEMTYPE_INGREDIENT)
        end
    end
        local tradeskillName = GetCraftingSkillName(CRAFTING_TYPE_PROVISIONING)
        local categoryParams = AddCategory(string.format("TradeMaterial%d", CRAFTING_TYPE_PROVISIONING))
        categoryParams:SetName(tradeskillName)
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MATERIALS)
        local SUBCATEGORY_KEY_PREFIX = "ProvisioningIngredient"
        categoryParams:SetContainsItemCallback(function(itemLink)
            local itemLinkItemType, itemLinkSpecializedItemType = GetItemLinkItemType(itemLink)
            if itemLinkItemType == ITEMTYPE_INGREDIENT then
                for subcategoryIndex, subcategoryData in ipairs(PROVISIONING_INGREDIENT_SUBCATEGORIES) do
                    for _, specializedItemType in ipairs(subcategoryData.value) do
                        if itemLinkSpecializedItemType == specializedItemType then
                            return true, SUBCATEGORY_KEY_PREFIX..subcategoryIndex
                        end
                    end
                end
                return true
            else
                return false
            end
        end)
        -- No features
        AddAllSubcategory(categoryParams, GetString(SI_TRADING_HOUSE_BROWSE_PROVISIONING_ALL_INGREDIENTS))
        for subcategoryIndex, subcategoryData in ipairs(PROVISIONING_INGREDIENT_SUBCATEGORIES) do
            local key = SUBCATEGORY_KEY_PREFIX..subcategoryIndex
            categoryParams:AddSubcategory(key, subcategoryData.name, subcategoryData.icons, subcategoryData.value)
        end
        AddItemTypeToAllMaterials(ITEMTYPE_INGREDIENT)
    end
    local STYLE_MATERIAL_TYPES =
    {
        ITEMTYPE_RAW_MATERIAL,
        ITEMTYPE_STYLE_MATERIAL,
    }
    function AddStyleMaterialCategory()
        local categoryParams = AddCategory("StyleMaterial")
        categoryParams:SetName(GetString("SI_ITEMTYPE", ITEMTYPE_STYLE_MATERIAL))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MATERIALS)
        local SUBCATEGORY_ENUM_KEY_PREFIX = "ItemType"
        categoryParams:SetApplyToSearchCallback(ApplyMaterialToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            local itemLinkItemType = GetItemLinkItemType(itemLink)
            for _, itemType in ipairs(STYLE_MATERIAL_TYPES) do
                if itemLinkItemType == itemType then
                    return true, SUBCATEGORY_ENUM_KEY_PREFIX..itemType
                end
            end
            return false
        end)
        -- No features
        AddEnumSubcategories(categoryParams,
        {
            enumKeyPrefix = SUBCATEGORY_ENUM_KEY_PREFIX,
            enumStringPrefix = "SI_ITEMTYPE",
            allItemsString = GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL_MATERIALS),
            iconsForEnumValue = ICONS_FOR_TRADESKILL_ITEM_TYPES,
            enumValues = STYLE_MATERIAL_TYPES,
        })
        for _, itemType in ipairs(STYLE_MATERIAL_TYPES) do
            AddItemTypeToAllMaterials(itemType)
        end
    end
    local TRAIT_MATERIAL_TYPES =
    {
        ITEMTYPE_WEAPON_TRAIT,
        ITEMTYPE_ARMOR_TRAIT,
        ITEMTYPE_JEWELRY_RAW_TRAIT,
        ITEMTYPE_JEWELRY_TRAIT,
    }
    function AddTraitMaterialCategory()
        local categoryParams = AddCategory("TraitMaterial")
        categoryParams:SetName(GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_TRAIT_MATERIAL))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MATERIALS)
        local SUBCATEGORY_ENUM_KEY_PREFIX = "ItemType"
        categoryParams:SetApplyToSearchCallback(ApplyMaterialToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            local itemType = GetItemLinkItemType(itemLink)
            for _, searchItemType in ipairs(TRAIT_MATERIAL_TYPES) do
                if itemType == searchItemType then
                    return true, SUBCATEGORY_ENUM_KEY_PREFIX..itemType
                end
            end
            return false
        end)
        -- No features
        AddEnumSubcategories(categoryParams,
        {
            enumKeyPrefix = SUBCATEGORY_ENUM_KEY_PREFIX,
            enumStringPrefix = "SI_ITEMTYPE",
            allItemsString = GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL_MATERIALS),
            iconsForEnumValue = ICONS_FOR_TRADESKILL_ITEM_TYPES,
            enumValues = TRAIT_MATERIAL_TYPES,
        })
        for _, itemType in ipairs(TRAIT_MATERIAL_TYPES) do
            AddItemTypeToAllMaterials(itemType)
        end
    end
    local function ApplyFurnishingMaterialToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, ITEMTYPE_FURNISHING_MATERIAL)
    end
    function AddFurnishingMaterialCategory()
        local categoryParams = AddCategory("FurnishingMaterial")
        categoryParams:SetName(GetString("SI_ITEMTYPE", ITEMTYPE_FURNISHING_MATERIAL))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MATERIALS)
        categoryParams:SetContainsItemCallback(function(itemLink)
            return GetItemLinkItemType(itemLink) == ITEMTYPE_FURNISHING_MATERIAL
        end)
        -- No features
        AddAllSubcategory(categoryParams)
        AddItemTypeToAllMaterials(ITEMTYPE_FURNISHING_MATERIAL)
    end
end
do
    local function ApplyAllGlyphsToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, {ITEMTYPE_GLYPH_WEAPON, ITEMTYPE_GLYPH_ARMOR, ITEMTYPE_GLYPH_JEWELRY})
    end
    function AddAllGlyphsCategory(glyphItemType)
        local categoryParams = AddCategory("AllGlyphs")
        categoryParams:SetName(GetString("SI_TRADINGHOUSECATEGORYHEADER_ALLCATEGORIES", TRADING_HOUSE_CATEGORY_HEADER_GLYPHS))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_GLYPHS)
        categoryParams:SetIsAllItemsCategory(true)
        categoryParams:SetApplyToSearchCallback(ApplyAllGlyphsToSearch)
        categoryParams:AddFeatureKeys("GlyphLevelRange")
        AddAllSubcategory(categoryParams)
    end
    local GLYPH_TYPE_TO_FEATURE =
    {
        [ITEMTYPE_GLYPH_WEAPON] = "WeaponEnchantments",
        [ITEMTYPE_GLYPH_ARMOR] = "ArmorEnchantments",
        [ITEMTYPE_GLYPH_JEWELRY] = "JewelryEnchantments",
    }
    function AddGlyphCategory(glyphItemType)
        local function ApplyGlyphToSearch(search)
            search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, glyphItemType)
        end
        local categoryParams = AddCategory(string.format("Glyph%d", glyphItemType))
        categoryParams:SetName(GetString("SI_ITEMTYPE", glyphItemType))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_GLYPHS)
        categoryParams:SetApplyToSearchCallback(ApplyGlyphToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            return GetItemLinkItemType(itemLink) == glyphItemType
        end)
        categoryParams:AddFeatureKeys("GlyphLevelRange", internalassert(GLYPH_TYPE_TO_FEATURE[glyphItemType]))
        AddAllSubcategory(categoryParams)
    end
end
do
    local g_allFurnishingSpecializedItemTypes = {}
    local function AddSpecializedItemTypeToAllFurnishings(specializedItemType)
        table.insert(g_allFurnishingSpecializedItemTypes, specializedItemType)
    end
    local function ApplyAllFurnishingsToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_SPECIALIZED_ITEM, g_allFurnishingSpecializedItemTypes)
    end
    function AddAllFurnishingsCategory()
        local categoryParams = AddCategory("AllFurnishings")
        categoryParams:SetName(GetString("SI_TRADINGHOUSECATEGORYHEADER_ALLCATEGORIES", TRADING_HOUSE_CATEGORY_HEADER_FURNISHINGS))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_FURNISHINGS)
        categoryParams:SetIsAllItemsCategory(true)
        categoryParams:SetApplyToSearchCallback(ApplyAllFurnishingsToSearch)
        -- No features
        AddAllSubcategory(categoryParams)
    end
    function AddFurnishingCategory(...)
        local specializedItemTypes = {...}
        local function ApplyFurnitureToSearch(search)
            search:SetFilter(TRADING_HOUSE_FILTER_TYPE_SPECIALIZED_ITEM, specializedItemTypes)
        end
        local PRIMARY_ITEM_INDEX = 1
        local primarySpecializedItemType = specializedItemTypes[PRIMARY_ITEM_INDEX]
        local categoryParams = AddCategory(string.format("Furnishing%d", primarySpecializedItemType))
        if primarySpecializedItemType == SPECIALIZED_ITEMTYPE_FURNISHING_ORNAMENTAL then
            categoryParams:SetName(GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ORNAMENTAL_FURNISHINGS))
        else
            categoryParams:SetName(GetString("SI_SPECIALIZEDITEMTYPE", primarySpecializedItemType))
        end
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_FURNISHINGS)
        categoryParams:SetApplyToSearchCallback(ApplyFurnitureToSearch)
        categoryParams:SetContainsItemCallback(function(itemLink)
            local _, specializedItemType = GetItemLinkItemType(itemLink)
            for _, searchSpecializedItemType in ipairs(specializedItemTypes) do
                if specializedItemType == searchSpecializedItemType then
                    return true
                end
            end
            return false
        end)
        -- No features
        AddAllSubcategory(categoryParams)
        for _, specializedItemType in ipairs(specializedItemTypes) do
            AddSpecializedItemTypeToAllFurnishings(specializedItemType)
        end
    end
end
local function AddMiscCategory(itemType)
    local function ApplyItemTypeToSearch(search)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_ITEM, itemType)
    end
    local categoryParams = AddCategory(string.format("Misc%d", itemType))
    categoryParams:SetName(GetString("SI_ITEMTYPE", itemType))
    categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MISC)
    categoryParams:SetContainsItemCallback(function(itemLink)
        return GetItemLinkItemType(itemLink) == itemType
    end)
    -- no features
    AddAllSubcategory(categoryParams)
end
do
    local TROPHY_SUBCATEGORIES =
    {
        {
            name = GetString("SI_SPECIALIZEDITEMTYPE", SPECIALIZED_ITEMTYPE_TROPHY_TREASURE_MAP),
            value = { SPECIALIZED_ITEMTYPE_TROPHY_TREASURE_MAP },
            icons = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_TROPHY_TREASURE_MAP),
        },
        {
            name = GetString("SI_SPECIALIZEDITEMTYPE", SPECIALIZED_ITEMTYPE_TROPHY_RECIPE_FRAGMENT),
            value = { SPECIALIZED_ITEMTYPE_TROPHY_RECIPE_FRAGMENT },
            icons = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_TROPHY_RECIPE_FRAGMENT),
        },
        {
            name = GetString("SI_SPECIALIZEDITEMTYPE", SPECIALIZED_ITEMTYPE_TROPHY_SCROLL),
            value = { SPECIALIZED_ITEMTYPE_TROPHY_SCROLL },
            icons = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_TROPHY_SCROLL),
        },
        {
            name = GetString("SI_SPECIALIZEDITEMTYPE", SPECIALIZED_ITEMTYPE_TROPHY_RUNEBOX_FRAGMENT),
            value = { SPECIALIZED_ITEMTYPE_TROPHY_RUNEBOX_FRAGMENT },
            icons = ZO_ItemFilterUtils.GetSpecializedItemTypeFilterIcons(SPECIALIZED_ITEMTYPE_TROPHY_RUNEBOX_FRAGMENT),
        },
        {
            name = GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_OTHER_TROPHY_TYPES),
            value =
            {
                SPECIALIZED_ITEMTYPE_TROPHY_SURVEY_REPORT,
                SPECIALIZED_ITEMTYPE_TROPHY_KEY_FRAGMENT,
                SPECIALIZED_ITEMTYPE_TROPHY_MUSEUM_PIECE,
                SPECIALIZED_ITEMTYPE_TROPHY_SCROLL,
                SPECIALIZED_ITEMTYPE_TROPHY_MATERIAL_UPGRADER,
                SPECIALIZED_ITEMTYPE_TROPHY_KEY,
                SPECIALIZED_ITEMTYPE_TROPHY_COLLECTIBLE_FRAGMENT,
                SPECIALIZED_ITEMTYPE_TROPHY_UPGRADE_FRAGMENT,
                SPECIALIZED_ITEMTYPE_TROPHY_DUNGEON_BUFF_INGREDIENT,
            },
            icons = ZO_ItemFilterUtils.GetItemTypeDisplayCategoryFilterIcons(ITEM_TYPE_DISPLAY_CATEGORY_TROPHY),
        },
    }
    -- There are some items in the game that are itemtype trophy, but have a
    -- specialized itemtype outside of this category. these should be filtered
    -- elsewhere, so instead of filtering by itemtype we need to filter by all
    -- specialized itemtypes
    local ALL_TROPHY_SPECIALIZED_ITEMTYPES = {}
    for _, subcategoryData in ipairs(TROPHY_SUBCATEGORIES) do
        ZO_CombineNumericallyIndexedTables(ALL_TROPHY_SPECIALIZED_ITEMTYPES, subcategoryData.value)
    end
    local function ApplyTrophyToSearch(search, subcategoryValue)
        search:SetFilter(TRADING_HOUSE_FILTER_TYPE_SPECIALIZED_ITEM, subcategoryValue)
    end
    local SUBCATEGORY_KEY_PREFIX = "TrophySubcategory"
    local function IsItemLinkTrophy(itemLink)
        local _, itemLinkSpecializedItemType = GetItemLinkItemType(itemLink)
        for subcategoryIndex, subcategoryData in ipairs(TROPHY_SUBCATEGORIES) do
            if ZO_IsElementInNumericallyIndexedTable(subcategoryData.value, itemLinkSpecializedItemType) then
                return true, SUBCATEGORY_KEY_PREFIX..subcategoryIndex
            end
        end
        return false
    end
    function AddTrophyCategory()
        local categoryParams = AddCategory("Trophy")
        categoryParams:SetName(GetString("SI_ITEMTYPE", ITEMTYPE_TROPHY))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MISC)
        categoryParams:SetApplyToSearchCallback(ApplyTrophyToSearch)
        categoryParams:SetContainsItemCallback(IsItemLinkTrophy)
        -- No features
        AddAllSubcategory(categoryParams, GetString(SI_TRADING_HOUSE_BROWSE_ITEM_TYPE_ALL_TROPHY_TYPES), ALL_TROPHY_SPECIALIZED_ITEMTYPES)
        for subcategoryIndex, subcategoryData in ipairs(TROPHY_SUBCATEGORIES) do
            local key = SUBCATEGORY_KEY_PREFIX..subcategoryIndex
            categoryParams:AddSubcategory(key, subcategoryData.name, subcategoryData.icons, subcategoryData.value)
        end
    end
end
do
    local function ApplyTabardToSearch(search)
        -- The only guild specific items are tabards, and tabards can't be posted to the normal trading house.
        search:SetShouldShowGuildSpecificItems(true)
    end
    function AddGuildTabardCategory()
        local categoryParams = AddCategory("Tabards")
        categoryParams:SetName(GetString("SI_ITEMTYPE", ITEMTYPE_TABARD))
        categoryParams:SetHeader(TRADING_HOUSE_CATEGORY_HEADER_MISC)
        categoryParams:SetApplyToSearchCallback(ApplyTabardToSearch)
        -- no features
        AddAllSubcategory(categoryParams)
    end
end
-----------------------
-- Search Categories --
-----------------------
--[[
This is a list of search categories in the order they will appear in the UI.
When adding a new category, create an AddXCategory function and add it to this list, making sure that it's in the same group as the other categories of its header.
Any item that could be sold on the trading house should be categorized.
]]
--
internalassert(ITEMTYPE_MAX_VALUE == 71, "Do you need to update the trading house with your new itemtype?")
internalassert(SPECIALIZED_ITEMTYPE_MAX_VALUE == 3150, "Do you need to update the trading house with your new specialized itemtype?")
internalassert(EQUIP_TYPE_MAX_VALUE == 15, "Do you need to update the trading house with your new equip type?")
-- All Items
-- Weapon
AddWeaponCategory(EQUIPMENT_FILTER_TYPE_ONE_HANDED)
AddWeaponCategory(EQUIPMENT_FILTER_TYPE_TWO_HANDED)
AddWeaponCategory(EQUIPMENT_FILTER_TYPE_BOW)
AddWeaponCategory(EQUIPMENT_FILTER_TYPE_DESTRO_STAFF)
AddWeaponCategory(EQUIPMENT_FILTER_TYPE_RESTO_STAFF)
-- Apparel
AddArmorCategory(ARMORTYPE_LIGHT)
AddArmorCategory(ARMORTYPE_MEDIUM)
AddArmorCategory(ARMORTYPE_HEAVY)
-- Jewelry
-- Consumables
AddConsumableCategory(ITEMTYPE_FOOD)
AddRecipeCategory(PROVISIONER_SPECIAL_INGREDIENT_TYPE_SPICES)
AddConsumableCategory(ITEMTYPE_DRINK)
AddRecipeCategory(PROVISIONER_SPECIAL_INGREDIENT_TYPE_FLAVORING)
AddConsumableCategory(ITEMTYPE_POTION)
AddConsumableCategory(ITEMTYPE_POISON)
AddConsumableCategory(ITEMTYPE_RACIAL_STYLE_MOTIF)
AddRecipeCategory(PROVISIONER_SPECIAL_INGREDIENT_TYPE_FURNISHING)
AddConsumableCategory(ITEMTYPE_MASTER_WRIT)
AddConsumableCategory(ITEMTYPE_CONTAINER, ITEMTYPE_CONTAINER_CURRENCY)
AddConsumableCategory(ITEMTYPE_AVA_REPAIR)
-- Materials
AddTradeMaterialCategory(CRAFTING_TYPE_BLACKSMITHING)
AddTradeMaterialCategory(CRAFTING_TYPE_CLOTHIER)
AddTradeMaterialCategory(CRAFTING_TYPE_WOODWORKING)
AddTradeMaterialCategory(CRAFTING_TYPE_JEWELRYCRAFTING)
AddTradeMaterialCategory(CRAFTING_TYPE_ALCHEMY)
AddTradeMaterialCategory(CRAFTING_TYPE_ENCHANTING)
-- Glyphs
AddGlyphCategory(ITEMTYPE_GLYPH_WEAPON)
AddGlyphCategory(ITEMTYPE_GLYPH_ARMOR)
AddGlyphCategory(ITEMTYPE_GLYPH_JEWELRY)
-- Furnishings
AddFurnishingCategory(SPECIALIZED_ITEMTYPE_FURNISHING_CRAFTING_STATION, SPECIALIZED_ITEMTYPE_FURNISHING_ATTUNABLE_STATION)
AddFurnishingCategory(SPECIALIZED_ITEMTYPE_FURNISHING_TARGET_DUMMY)
AddFurnishingCategory(SPECIALIZED_ITEMTYPE_FURNISHING_LIGHT)
AddFurnishingCategory(SPECIALIZED_ITEMTYPE_FURNISHING_SEATING)
AddFurnishingCategory(SPECIALIZED_ITEMTYPE_FURNISHING_ORNAMENTAL)
-- Misc
-- Misc does not have an "all" category
AddMiscCategory(ITEMTYPE_SOUL_GEM)
AddMiscCategory(ITEMTYPE_LURE)
AddMiscCategory(ITEMTYPE_TOOL)
AddMiscCategory(ITEMTYPE_SIEGE)