lightly-studio 0.3.1__py3-none-any.whl → 0.3.3__py3-none-any.whl

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.

Potentially problematic release.


This version of lightly-studio might be problematic. Click here for more details.

Files changed (169) hide show
  1. lightly_studio/__init__.py +4 -4
  2. lightly_studio/api/app.py +7 -5
  3. lightly_studio/api/db_tables.py +0 -3
  4. lightly_studio/api/routes/api/annotation.py +32 -16
  5. lightly_studio/api/routes/api/annotation_label.py +2 -5
  6. lightly_studio/api/routes/api/annotations/__init__.py +7 -0
  7. lightly_studio/api/routes/api/annotations/create_annotation.py +52 -0
  8. lightly_studio/api/routes/api/classifier.py +2 -5
  9. lightly_studio/api/routes/api/dataset.py +5 -8
  10. lightly_studio/api/routes/api/dataset_tag.py +2 -3
  11. lightly_studio/api/routes/api/embeddings2d.py +104 -0
  12. lightly_studio/api/routes/api/export.py +73 -0
  13. lightly_studio/api/routes/api/metadata.py +2 -4
  14. lightly_studio/api/routes/api/sample.py +5 -13
  15. lightly_studio/api/routes/api/selection.py +87 -0
  16. lightly_studio/api/routes/api/settings.py +2 -6
  17. lightly_studio/api/routes/images.py +6 -6
  18. lightly_studio/core/add_samples.py +374 -0
  19. lightly_studio/core/dataset.py +272 -400
  20. lightly_studio/core/dataset_query/boolean_expression.py +67 -0
  21. lightly_studio/core/dataset_query/dataset_query.py +216 -0
  22. lightly_studio/core/dataset_query/field.py +113 -0
  23. lightly_studio/core/dataset_query/field_expression.py +79 -0
  24. lightly_studio/core/dataset_query/match_expression.py +23 -0
  25. lightly_studio/core/dataset_query/order_by.py +79 -0
  26. lightly_studio/core/dataset_query/sample_field.py +28 -0
  27. lightly_studio/core/dataset_query/tags_expression.py +46 -0
  28. lightly_studio/core/sample.py +159 -32
  29. lightly_studio/core/start_gui.py +35 -0
  30. lightly_studio/dataset/edge_embedding_generator.py +13 -8
  31. lightly_studio/dataset/embedding_generator.py +2 -3
  32. lightly_studio/dataset/embedding_manager.py +74 -6
  33. lightly_studio/dataset/env.py +4 -0
  34. lightly_studio/dataset/file_utils.py +13 -2
  35. lightly_studio/dataset/fsspec_lister.py +275 -0
  36. lightly_studio/dataset/loader.py +49 -84
  37. lightly_studio/dataset/mobileclip_embedding_generator.py +9 -6
  38. lightly_studio/db_manager.py +145 -0
  39. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/0.CA_CXIBb.css +1 -0
  40. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/_layout.DS78jgNY.css +1 -0
  41. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/index.BVs_sZj9.css +1 -0
  42. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/transform.D487hwJk.css +1 -0
  43. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/6t3IJ0vQ.js +1 -0
  44. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{D6su9Aln.js → 8NsknIT2.js} +1 -1
  45. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{x9G_hzyY.js → BND_-4Kp.js} +1 -1
  46. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{BylOuP6i.js → BdfTHw61.js} +1 -1
  47. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{DOlTMNyt.js → BfHVnyNT.js} +1 -1
  48. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BjkP1AHA.js +1 -0
  49. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BuuNVL9G.js +1 -0
  50. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{O-EABkf9.js → BzKGpnl4.js} +1 -1
  51. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CCx7Ho51.js +1 -0
  52. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{l7KrR96u.js → CH6P3X75.js} +1 -1
  53. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{D5-A_Ffd.js → CR2upx_Q.js} +2 -2
  54. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CWPZrTTJ.js +1 -0
  55. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{C8I8rFJQ.js → Cs1XmhiF.js} +1 -1
  56. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{CDnpyLsT.js → CwPowJfP.js} +1 -1
  57. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CxFKfZ9T.js +1 -0
  58. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Cxevwdid.js +1 -0
  59. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{DjfY96ND.js → D4whDBUi.js} +1 -1
  60. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D6r9vr07.js +1 -0
  61. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DA6bFLPR.js +1 -0
  62. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DEgUu98i.js +3 -0
  63. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DGTPl6Gk.js +1 -0
  64. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DKGxBSlK.js +1 -0
  65. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DQXoLcsF.js +1 -0
  66. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DQe_kdRt.js +92 -0
  67. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DcY4jgG3.js +1 -0
  68. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{Bu7uvVrG.js → RmD8FzRo.js} +1 -1
  69. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/V-MnMC1X.js +1 -0
  70. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/{Bsi3UGy5.js → keKYsoph.js} +1 -1
  71. lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/app.BVr6DYqP.js +2 -0
  72. lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/start.u7zsVvqp.js +1 -0
  73. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/0.Da2agmdd.js +1 -0
  74. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/{1.B4rNYwVp.js → 1.B11tVRJV.js} +1 -1
  75. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/10.l30Zud4h.js +1 -0
  76. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/12.CgKPGcAP.js +1 -0
  77. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/2.C8HLK8mj.js +857 -0
  78. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/{3.CWHpKonm.js → 3.CLvg3QcJ.js} +1 -1
  79. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/{4.OUWOLQeV.js → 4.BQhDtXUI.js} +1 -1
  80. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/5.-6XqWX5G.js +1 -0
  81. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/6.uBV1Lhat.js +1 -0
  82. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/7.BXsgoQZh.js +1 -0
  83. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/8.BkbcnUs8.js +1 -0
  84. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/{9.CPu3CiBc.js → 9.Bkrv-Vww.js} +1 -1
  85. lightly_studio/dist_lightly_studio_view_app/_app/immutable/workers/clustering.worker-DKqeLtG0.js +2 -0
  86. lightly_studio/dist_lightly_studio_view_app/_app/immutable/workers/search.worker-vNSty3B0.js +1 -0
  87. lightly_studio/dist_lightly_studio_view_app/_app/version.json +1 -1
  88. lightly_studio/dist_lightly_studio_view_app/index.html +14 -14
  89. lightly_studio/examples/example.py +13 -12
  90. lightly_studio/examples/example_coco.py +13 -0
  91. lightly_studio/examples/example_metadata.py +83 -98
  92. lightly_studio/examples/example_selection.py +7 -19
  93. lightly_studio/examples/example_split_work.py +12 -36
  94. lightly_studio/examples/{example_v2.py → example_yolo.py} +3 -4
  95. lightly_studio/export/export_dataset.py +65 -0
  96. lightly_studio/export/lightly_studio_label_input.py +120 -0
  97. lightly_studio/few_shot_classifier/classifier_manager.py +5 -26
  98. lightly_studio/metadata/compute_typicality.py +67 -0
  99. lightly_studio/models/annotation/annotation_base.py +18 -20
  100. lightly_studio/models/annotation/instance_segmentation.py +8 -8
  101. lightly_studio/models/annotation/object_detection.py +4 -4
  102. lightly_studio/models/dataset.py +6 -2
  103. lightly_studio/models/sample.py +10 -3
  104. lightly_studio/resolvers/annotation_label_resolver/__init__.py +2 -1
  105. lightly_studio/resolvers/annotation_label_resolver/get_all.py +15 -0
  106. lightly_studio/resolvers/annotation_resolver/__init__.py +2 -3
  107. lightly_studio/resolvers/annotation_resolver/create_many.py +3 -3
  108. lightly_studio/resolvers/annotation_resolver/delete_annotation.py +1 -1
  109. lightly_studio/resolvers/annotation_resolver/delete_annotations.py +7 -3
  110. lightly_studio/resolvers/annotation_resolver/get_by_id.py +19 -1
  111. lightly_studio/resolvers/annotation_resolver/update_annotation_label.py +0 -1
  112. lightly_studio/resolvers/annotations/annotations_filter.py +1 -11
  113. lightly_studio/resolvers/dataset_resolver.py +10 -0
  114. lightly_studio/resolvers/embedding_model_resolver.py +22 -0
  115. lightly_studio/resolvers/sample_resolver.py +53 -9
  116. lightly_studio/resolvers/tag_resolver.py +23 -0
  117. lightly_studio/selection/mundig.py +7 -10
  118. lightly_studio/selection/select.py +55 -46
  119. lightly_studio/selection/select_via_db.py +23 -19
  120. lightly_studio/selection/selection_config.py +10 -4
  121. lightly_studio/services/annotations_service/__init__.py +12 -0
  122. lightly_studio/services/annotations_service/create_annotation.py +63 -0
  123. lightly_studio/services/annotations_service/delete_annotation.py +22 -0
  124. lightly_studio/services/annotations_service/update_annotation.py +21 -32
  125. lightly_studio/services/annotations_service/update_annotation_bounding_box.py +36 -0
  126. lightly_studio-0.3.3.dist-info/METADATA +814 -0
  127. {lightly_studio-0.3.1.dist-info → lightly_studio-0.3.3.dist-info}/RECORD +130 -113
  128. lightly_studio/api/db.py +0 -133
  129. lightly_studio/api/routes/api/annotation_task.py +0 -38
  130. lightly_studio/api/routes/api/metrics.py +0 -80
  131. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/0.DenzbfeK.css +0 -1
  132. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/SelectableSvgGroup.OwPEPQZu.css +0 -1
  133. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/SelectableSvgGroup.b653GmVf.css +0 -1
  134. lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/_layout.T-zjSUd3.css +0 -1
  135. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/B2FVR0s0.js +0 -1
  136. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/B9zumHo5.js +0 -1
  137. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/BJXwVxaE.js +0 -1
  138. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/Bx1xMsFy.js +0 -1
  139. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CcaPhhk3.js +0 -1
  140. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CvOmgdoc.js +0 -93
  141. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/CxtLVaYz.js +0 -3
  142. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D6RI2Zrd.js +0 -1
  143. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/D98V7j6A.js +0 -1
  144. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DIRAtgl0.js +0 -1
  145. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/DjUWrjOv.js +0 -1
  146. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/XO7A28GO.js +0 -1
  147. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/hQVEETDE.js +0 -1
  148. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/nAHhluT7.js +0 -1
  149. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/r64xT6ao.js +0 -1
  150. lightly_studio/dist_lightly_studio_view_app/_app/immutable/chunks/vC4nQVEB.js +0 -1
  151. lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/app.CjnvpsmS.js +0 -2
  152. lightly_studio/dist_lightly_studio_view_app/_app/immutable/entry/start.0o1H7wM9.js +0 -1
  153. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/0.XRq_TUwu.js +0 -1
  154. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/10.DfBwOEhN.js +0 -1
  155. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/12.CwF2_8mP.js +0 -1
  156. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/2.CS4muRY-.js +0 -6
  157. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/5.Dm6t9F5W.js +0 -1
  158. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/6.Bw5ck4gK.js +0 -1
  159. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/7.CF0EDTR6.js +0 -1
  160. lightly_studio/dist_lightly_studio_view_app/_app/immutable/nodes/8.Cw30LEcV.js +0 -1
  161. lightly_studio/metrics/detection/__init__.py +0 -0
  162. lightly_studio/metrics/detection/map.py +0 -268
  163. lightly_studio/models/annotation_task.py +0 -28
  164. lightly_studio/resolvers/annotation_resolver/create.py +0 -19
  165. lightly_studio/resolvers/annotation_task_resolver.py +0 -31
  166. lightly_studio-0.3.1.dist-info/METADATA +0 -520
  167. /lightly_studio/{metrics → core/dataset_query}/__init__.py +0 -0
  168. /lightly_studio/dist_lightly_studio_view_app/_app/immutable/assets/{OpenSans- → OpenSans-Medium.DVUZMR_6.ttf} +0 -0
  169. {lightly_studio-0.3.1.dist-info → lightly_studio-0.3.3.dist-info}/WHEEL +0 -0
@@ -0,0 +1 @@
1
+ (function(){"use strict";function ce(Q){if(Q.__esModule)return Q;var y=Q.default;if(typeof y=="function"){var z=function E(){return this instanceof E?Reflect.construct(y,arguments,this.constructor):y.apply(this,arguments)};z.prototype=y.prototype}else z={};return Object.defineProperty(z,"__esModule",{value:!0}),Object.keys(Q).forEach(function(E){var q=Object.getOwnPropertyDescriptor(Q,E);Object.defineProperty(z,E,q.get?q:{enumerable:!0,get:function(){return Q[E]}})}),z}var ue={},ae=Object.freeze({__proto__:null,default:ue}),ge=ce(ae);(function(Q){var y;function z(t,i,e){const s=typeof e,n=typeof t;if(s!=="undefined"){if(n!=="undefined"){if(e){if(n==="function"&&s===n)return function(o){return t(e(o))};if(i=t.constructor,i===e.constructor){if(i===Array)return e.concat(t);if(i===Map){var r=new Map(e);for(var h of t)r.set(h[0],h[1]);return r}if(i===Set){h=new Set(e);for(r of t.values())h.add(r);return h}}}return t}return e}return n==="undefined"?i:t}function E(t,i){return typeof t>"u"?i:t}function q(){return Object.create(null)}function F(t){return typeof t=="string"}function rt(t){return typeof t=="object"}function ht(t,i){if(F(i))t=t[i];else for(let e=0;t&&e<i.length;e++)t=t[i[e]];return t}const pe=/[^\p{L}\p{N}]+/u,de=/(\d{3})/g,me=/(\D)(\d{3})/g,we=/(\d{3})(\D)/g,Ft=/[\u0300-\u036f]/g;function lt(t={}){if(!this||this.constructor!==lt)return new lt(...arguments);if(arguments.length)for(t=0;t<arguments.length;t++)this.assign(arguments[t]);else this.assign(t)}y=lt.prototype,y.assign=function(t){this.normalize=z(t.normalize,!0,this.normalize);let i=t.include,e=i||t.exclude||t.split,s;if(e||e===""){if(typeof e=="object"&&e.constructor!==RegExp){let n="";s=!i,i||(n+="\\p{Z}"),e.letter&&(n+="\\p{L}"),e.number&&(n+="\\p{N}",s=!!i),e.symbol&&(n+="\\p{S}"),e.punctuation&&(n+="\\p{P}"),e.control&&(n+="\\p{C}"),(e=e.char)&&(n+=typeof e=="object"?e.join(""):e);try{this.split=new RegExp("["+(i?"^":"")+n+"]+","u")}catch{this.split=/\s+/}}else this.split=e,s=e===!1||"a1a".split(e).length<2;this.numeric=z(t.numeric,s)}else{try{this.split=z(this.split,pe)}catch{this.split=/\s+/}this.numeric=z(t.numeric,z(this.numeric,!0))}if(this.prepare=z(t.prepare,null,this.prepare),this.finalize=z(t.finalize,null,this.finalize),e=t.filter,this.filter=typeof e=="function"?e:z(e&&new Set(e),null,this.filter),this.dedupe=z(t.dedupe,!0,this.dedupe),this.matcher=z((e=t.matcher)&&new Map(e),null,this.matcher),this.mapper=z((e=t.mapper)&&new Map(e),null,this.mapper),this.stemmer=z((e=t.stemmer)&&new Map(e),null,this.stemmer),this.replacer=z(t.replacer,null,this.replacer),this.minlength=z(t.minlength,1,this.minlength),this.maxlength=z(t.maxlength,1024,this.maxlength),this.rtl=z(t.rtl,!1,this.rtl),(this.cache=e=z(t.cache,!0,this.cache))&&(this.F=null,this.L=typeof e=="number"?e:2e5,this.B=new Map,this.D=new Map,this.I=this.H=128),this.h="",this.J=null,this.A="",this.K=null,this.matcher)for(const n of this.matcher.keys())this.h+=(this.h?"|":"")+n;if(this.stemmer)for(const n of this.stemmer.keys())this.A+=(this.A?"|":"")+n;return this},y.addStemmer=function(t,i){return this.stemmer||(this.stemmer=new Map),this.stemmer.set(t,i),this.A+=(this.A?"|":"")+t,this.K=null,this.cache&&V(this),this},y.addFilter=function(t){return typeof t=="function"?this.filter=t:(this.filter||(this.filter=new Set),this.filter.add(t)),this.cache&&V(this),this},y.addMapper=function(t,i){return typeof t=="object"?this.addReplacer(t,i):t.length>1?this.addMatcher(t,i):(this.mapper||(this.mapper=new Map),this.mapper.set(t,i),this.cache&&V(this),this)},y.addMatcher=function(t,i){return typeof t=="object"?this.addReplacer(t,i):t.length<2&&(this.dedupe||this.mapper)?this.addMapper(t,i):(this.matcher||(this.matcher=new Map),this.matcher.set(t,i),this.h+=(this.h?"|":"")+t,this.J=null,this.cache&&V(this),this)},y.addReplacer=function(t,i){return typeof t=="string"?this.addMatcher(t,i):(this.replacer||(this.replacer=[]),this.replacer.push(t,i),this.cache&&V(this),this)},y.encode=function(t,i){if(this.cache&&t.length<=this.H)if(this.F){if(this.B.has(t))return this.B.get(t)}else this.F=setTimeout(V,50,this);this.normalize&&(typeof this.normalize=="function"?t=this.normalize(t):t=Ft?t.normalize("NFKD").replace(Ft,"").toLowerCase():t.toLowerCase()),this.prepare&&(t=this.prepare(t)),this.numeric&&t.length>3&&(t=t.replace(me,"$1 $2").replace(we,"$1 $2").replace(de,"$1 "));const e=!(this.dedupe||this.mapper||this.filter||this.matcher||this.stemmer||this.replacer);let s=[],n=q(),r,h,o=this.split||this.split===""?t.split(this.split):[t];for(let f=0,c,a;f<o.length;f++)if((c=a=o[f])&&!(c.length<this.minlength||c.length>this.maxlength)){if(i){if(n[c])continue;n[c]=1}else{if(r===c)continue;r=c}if(e)s.push(c);else if(!this.filter||(typeof this.filter=="function"?this.filter(c):!this.filter.has(c))){if(this.cache&&c.length<=this.I)if(this.F){var l=this.D.get(c);if(l||l===""){l&&s.push(l);continue}}else this.F=setTimeout(V,50,this);if(this.stemmer){this.K||(this.K=new RegExp("(?!^)("+this.A+")$"));let m;for(;m!==c&&c.length>2;)m=c,c=c.replace(this.K,p=>this.stemmer.get(p))}if(c&&(this.mapper||this.dedupe&&c.length>1)){l="";for(let m=0,p="",d,u;m<c.length;m++)d=c.charAt(m),d===p&&this.dedupe||((u=this.mapper&&this.mapper.get(d))||u===""?u===p&&this.dedupe||!(p=u)||(l+=u):l+=p=d);c=l}if(this.matcher&&c.length>1&&(this.J||(this.J=new RegExp("("+this.h+")","g")),c=c.replace(this.J,m=>this.matcher.get(m))),c&&this.replacer)for(l=0;c&&l<this.replacer.length;l+=2)c=c.replace(this.replacer[l],this.replacer[l+1]);if(this.cache&&a.length<=this.I&&(this.D.set(a,c),this.D.size>this.L&&(this.D.clear(),this.I=this.I/1.1|0)),c){if(c!==a)if(i){if(n[c])continue;n[c]=1}else{if(h===c)continue;h=c}s.push(c)}}}return this.finalize&&(s=this.finalize(s)||s),this.cache&&t.length<=this.H&&(this.B.set(t,s),this.B.size>this.L&&(this.B.clear(),this.H=this.H/1.1|0)),s};function V(t){t.F=null,t.B.clear(),t.D.clear()}function _t(t,i,e){e||(i||typeof t!="object"?typeof i=="object"&&(e=i,i=0):e=t),e&&(t=e.query||t,i=e.limit||i);let s=""+(i||0);e&&(s+=(e.offset||0)+!!e.context+!!e.suggest+(e.resolve!==!1)+(e.resolution||this.resolution)+(e.boost||0)),t=(""+t).toLowerCase(),this.cache||(this.cache=new X);let n=this.cache.get(t+s);if(!n){const r=e&&e.cache;r&&(e.cache=!1),n=this.search(t,i,e),r&&(e.cache=r),this.cache.set(t+s,n)}return n}function X(t){this.limit=t&&t!==!0?t:1e3,this.cache=new Map,this.h=""}X.prototype.set=function(t,i){this.cache.set(this.h=t,i),this.cache.size>this.limit&&this.cache.delete(this.cache.keys().next().value)},X.prototype.get=function(t){const i=this.cache.get(t);return i&&this.h!==t&&(this.cache.delete(t),this.cache.set(this.h=t,i)),i},X.prototype.remove=function(t){for(const i of this.cache){const e=i[0];i[1].includes(t)&&this.cache.delete(e)}},X.prototype.clear=function(){this.cache.clear(),this.h=""};const Tt={normalize:!1,numeric:!1,dedupe:!1},at={},jt=new Map([["b","p"],["v","f"],["w","f"],["z","s"],["x","s"],["d","t"],["n","m"],["c","k"],["g","k"],["j","k"],["q","k"],["i","e"],["y","e"],["u","o"]]),Kt=new Map([["ae","a"],["oe","o"],["sh","s"],["kh","k"],["th","t"],["ph","f"],["pf","f"]]),Gt=[/([^aeo])h(.)/g,"$1$2",/([aeo])h([^aeo]|$)/g,"$1$2",/(.)\1+/g,"$1"],Jt={a:"",e:"",i:"",o:"",u:"",y:"",b:1,f:1,p:1,v:1,c:2,g:2,j:2,k:2,q:2,s:2,x:2,z:2,ß:2,d:3,t:3,l:4,m:5,n:5,r:6};var Wt={Exact:Tt,Default:at,Normalize:at,LatinBalance:{mapper:jt},LatinAdvanced:{mapper:jt,matcher:Kt,replacer:Gt},LatinExtra:{mapper:jt,replacer:Gt.concat([/(?!^)[aeo]/g,""]),matcher:Kt},LatinSoundex:{dedupe:!1,include:{letter:!0},finalize:function(t){for(let e=0;e<t.length;e++){var i=t[e];let s=i.charAt(0),n=Jt[s];for(let r=1,h;r<i.length&&(h=i.charAt(r),h==="h"||h==="w"||!(h=Jt[h])||h===n||(s+=h,n=h,s.length!==4));r++);t[e]=s}}},CJK:{split:""},LatinExact:Tt,LatinDefault:at,LatinSimple:at};function Ut(t,i,e,s){let n=[];for(let r=0,h;r<t.index.length;r++)if(h=t.index[r],i>=h.length)i-=h.length;else{i=h[s?"splice":"slice"](i,e);const o=i.length;if(o&&(n=n.length?n.concat(i):i,e-=o,s&&(t.length-=o),!e))break;i=0}return n}function H(t){if(!this||this.constructor!==H)return new H(t);this.index=t?[t]:[],this.length=t?t.length:0;const i=this;return new Proxy([],{get(e,s){if(s==="length")return i.length;if(s==="push")return function(n){i.index[i.index.length-1].push(n),i.length++};if(s==="pop")return function(){if(i.length)return i.length--,i.index[i.index.length-1].pop()};if(s==="indexOf")return function(n){let r=0;for(let h=0,o,l;h<i.index.length;h++){if(o=i.index[h],l=o.indexOf(n),l>=0)return r+l;r+=o.length}return-1};if(s==="includes")return function(n){for(let r=0;r<i.index.length;r++)if(i.index[r].includes(n))return!0;return!1};if(s==="slice")return function(n,r){return Ut(i,n||0,r||i.length,!1)};if(s==="splice")return function(n,r){return Ut(i,n||0,r||i.length,!0)};if(s==="constructor")return Array;if(typeof s!="symbol")return(e=i.index[s/2**31|0])&&e[s]},set(e,s,n){return e=s/2**31|0,(i.index[e]||(i.index[e]=[]))[s]=n,i.length++,!0}})}H.prototype.clear=function(){this.index.length=0},H.prototype.push=function(){};function T(t=8){if(!this||this.constructor!==T)return new T(t);this.index=q(),this.h=[],this.size=0,t>32?(this.B=Zt,this.A=BigInt(t)):(this.B=Rt,this.A=t)}T.prototype.get=function(t){const i=this.index[this.B(t)];return i&&i.get(t)},T.prototype.set=function(t,i){var e=this.B(t);let s=this.index[e];s?(e=s.size,s.set(t,i),(e-=s.size)&&this.size++):(this.index[e]=s=new Map([[t,i]]),this.h.push(s),this.size++)};function K(t=8){if(!this||this.constructor!==K)return new K(t);this.index=q(),this.h=[],this.size=0,t>32?(this.B=Zt,this.A=BigInt(t)):(this.B=Rt,this.A=t)}K.prototype.add=function(t){var i=this.B(t);let e=this.index[i];e?(i=e.size,e.add(t),(i-=e.size)&&this.size++):(this.index[i]=e=new Set([t]),this.h.push(e),this.size++)},y=T.prototype,y.has=K.prototype.has=function(t){const i=this.index[this.B(t)];return i&&i.has(t)},y.delete=K.prototype.delete=function(t){const i=this.index[this.B(t)];i&&i.delete(t)&&this.size--},y.clear=K.prototype.clear=function(){this.index=q(),this.h=[],this.size=0},y.values=K.prototype.values=function*(){for(let t=0;t<this.h.length;t++)for(let i of this.h[t].values())yield i},y.keys=K.prototype.keys=function*(){for(let t=0;t<this.h.length;t++)for(let i of this.h[t].keys())yield i},y.entries=K.prototype.entries=function*(){for(let t=0;t<this.h.length;t++)for(let i of this.h[t].entries())yield i};function Rt(t){let i=2**this.A-1;if(typeof t=="number")return t&i;let e=0,s=this.A+1;for(let n=0;n<t.length;n++)e=(e*s^t.charCodeAt(n))&i;return this.A===32?e+2**31:e}function Zt(t){let i=BigInt(2)**this.A-BigInt(1);var e=typeof t;if(e==="bigint")return t&i;if(e==="number")return BigInt(t)&i;e=BigInt(0);let s=this.A+BigInt(1);for(let n=0;n<t.length;n++)e=(e*s^BigInt(t.charCodeAt(n)))&i;return e}let tt,ot;async function ye(t){t=t.data;var i=t.task;const e=t.id;let s=t.args;switch(i){case"init":ot=t.options||{},(i=t.factory)?(Function("return "+i)()(self),tt=new self.FlexSearch.Index(ot),delete self.FlexSearch):tt=new G(ot),postMessage({id:e});break;default:let n;i==="export"&&(s[1]?(s[0]=ot.export,s[2]=0,s[3]=1):s=null),i==="import"?s[0]&&(t=await ot.import.call(tt,s[0]),tt.import(s[0],t)):((n=s&&tt[i].apply(tt,s))&&n.then&&(n=await n),n&&n.await&&(n=await n.await),i==="search"&&n.result&&(n=n.result)),postMessage(i==="search"?{id:e,msg:n}:{id:e})}}function Bt(t){et.call(t,"add"),et.call(t,"append"),et.call(t,"search"),et.call(t,"update"),et.call(t,"remove"),et.call(t,"searchCache")}let St,Qt,gt;function be(){St=gt=0}function et(t){this[t+"Async"]=function(){const i=arguments;var e=i[i.length-1];let s;if(typeof e=="function"&&(s=e,delete i[i.length-1]),St?gt||(gt=Date.now()-Qt>=this.priority*this.priority*3):(St=setTimeout(be,0),Qt=Date.now()),gt){const r=this;return new Promise(h=>{setTimeout(function(){h(r[t+"Async"].apply(r,i))},0)})}const n=this[t].apply(this,i);return e=n.then?n:new Promise(r=>r(n)),s&&e.then(s),e}}let U=0;function it(t={},i){function e(o){function l(f){f=f.data||f;const c=f.id,a=c&&r.h[c];a&&(a(f.msg),delete r.h[c])}if(this.worker=o,this.h=q(),this.worker)return n?this.worker.on("message",l):this.worker.onmessage=l,t.config?new Promise(function(f){U>1e9&&(U=0),r.h[++U]=function(){f(r)},r.worker.postMessage({id:U,task:"init",factory:s,options:t})}):(this.priority=t.priority||4,this.encoder=i||null,this.worker.postMessage({task:"init",factory:s,options:t}),this)}if(!this||this.constructor!==it)return new it(t);let s=typeof self<"u"?self._factory:typeof window<"u"?window._factory:null;s&&(s=s.toString());const n=typeof window>"u",r=this,h=xe(s,n,t.worker);return h.then?h.then(function(o){return e.call(r,o)}):e.call(this,h)}R("add"),R("append"),R("search"),R("update"),R("remove"),R("clear"),R("export"),R("import"),it.prototype.searchCache=_t,Bt(it.prototype);function R(t){it.prototype[t]=function(){const i=this,e=[].slice.call(arguments);var s=e[e.length-1];let n;return typeof s=="function"&&(n=s,e.pop()),s=new Promise(function(r){t==="export"&&typeof e[0]=="function"&&(e[0]=null),U>1e9&&(U=0),i.h[++U]=r,i.worker.postMessage({task:t,id:U,args:e})}),n?(s.then(n),this):s}}function xe(t,i,e){return i?new ge.Worker(__dirname+"/worker/node.js"):t?new window.Worker(URL.createObjectURL(new Blob(["onmessage="+ye.toString()],{type:"text/javascript"}))):new window.Worker(typeof e=="string"?e:self.location.href.replace("/worker.js","/worker/worker.js").replace("flexsearch.bundle.module.min.js","module/worker/worker.js").replace("flexsearch.bundle.module.min.mjs","module/worker/worker.js"),{type:"module"})}st.prototype.add=function(t,i,e){if(rt(t)&&(i=t,t=ht(i,this.key)),i&&(t||t===0)){if(!e&&this.reg.has(t))return this.update(t,i);for(let o=0,l;o<this.field.length;o++){l=this.B[o];var s=this.index.get(this.field[o]);if(typeof l=="function"){var n=l(i);n&&s.add(t,n,e,!0)}else n=l.G,(!n||n(i))&&(l.constructor===String?l=[""+l]:F(l)&&(l=[l]),Pt(i,l,this.D,0,s,t,l[0],e))}if(this.tag)for(s=0;s<this.A.length;s++){var r=this.A[s];n=this.tag.get(this.F[s]);let o=q();if(typeof r=="function"){if(r=r(i),!r)continue}else{var h=r.G;if(h&&!h(i))continue;r.constructor===String&&(r=""+r),r=ht(i,r)}if(n&&r){F(r)&&(r=[r]);for(let l=0,f,c;l<r.length;l++)if(f=r[l],!o[f]&&(o[f]=1,(h=n.get(f))?c=h:n.set(f,c=[]),!e||!c.includes(t))){if(c.length===2**31-1){if(h=new H(c),this.fastupdate)for(let a of this.reg.values())a.includes(c)&&(a[a.indexOf(c)]=h);n.set(f,c=h)}c.push(t),this.fastupdate&&((h=this.reg.get(t))?h.push(c):this.reg.set(t,[c]))}}}if(this.store&&(!e||!this.store.has(t))){let o;if(this.h){o=q();for(let l=0,f;l<this.h.length;l++){if(f=this.h[l],(e=f.G)&&!e(i))continue;let c;if(typeof f=="function"){if(c=f(i),!c)continue;f=[f.O]}else if(F(f)||f.constructor===String){o[f]=i[f];continue}Ct(i,o,f,0,f[0],c)}}this.store.set(t,o||i)}this.worker&&(this.fastupdate||this.reg.add(t))}return this};function Ct(t,i,e,s,n,r){if(t=t[n],s===e.length-1)i[n]=r||t;else if(t)if(t.constructor===Array)for(i=i[n]=Array(t.length),n=0;n<t.length;n++)Ct(t,i,e,s,n);else i=i[n]||(i[n]=q()),n=e[++s],Ct(t,i,e,s,n)}function Pt(t,i,e,s,n,r,h,o){if(t=t[h])if(s===i.length-1){if(t.constructor===Array){if(e[s]){for(i=0;i<t.length;i++)n.add(r,t[i],!0,!0);return}t=t.join(" ")}n.add(r,t,o,!0)}else if(t.constructor===Array)for(h=0;h<t.length;h++)Pt(t,i,e,s,n,r,h,o);else h=i[++s],Pt(t,i,e,s,n,r,h,o)}function qt(t,i,e,s){if(!t.length)return t;if(t.length===1)return t=t[0],t=e||t.length>i?t.slice(e,e+i):t,s?nt.call(this,t):t;let n=[];for(let r=0,h,o;r<t.length;r++)if((h=t[r])&&(o=h.length)){if(e){if(e>=o){e-=o;continue}h=h.slice(e,e+i),o=h.length,e=0}if(o>i&&(h=h.slice(0,i),o=i),!n.length&&o>=i)return s?nt.call(this,h):h;if(n.push(h),i-=o,!i)break}return n=n.length>1?[].concat.apply([],n):n[0],s?nt.call(this,n):n}function pt(t,i,e,s){var n=s[0];if(n[0]&&n[0].query)return t[i].apply(t,n);if(!(i!=="and"&&i!=="not"||t.result.length||t.await||n.suggest))return s.length>1&&(n=s[s.length-1]),(s=n.resolve)?t.await||t.result:t;let r=[],h=0,o=0,l,f,c,a,m;for(i=0;i<s.length;i++)if(n=s[i]){var p=void 0;if(n.constructor===P)p=n.await||n.result;else if(n.then||n.constructor===Array)p=n;else{h=n.limit||0,o=n.offset||0,c=n.suggest,f=n.resolve,l=((a=n.highlight||t.highlight)||n.enrich)&&f,p=n.queue;let d=n.async||p,u=n.index,g=n.query;if(u?t.index||(t.index=u):u=t.index,g||n.tag){const b=n.field||n.pluck;if(b&&(!g||t.query&&!a||(t.query=g,t.field=b,t.highlight=a),u=u.index.get(b)),p&&(m||t.await)){m=1;let w;const k=t.C.length,B=new Promise(function(S){w=S});(function(S,j){B.h=function(){j.index=null,j.resolve=!1;let A=d?S.searchAsync(j):S.search(j);return A.then?A.then(function(x){return t.C[k]=x=x.result||x,w(x),x}):(A=A.result||A,w(A),A)}})(u,Object.assign({},n)),t.C.push(B),r[i]=B;continue}else n.resolve=!1,n.index=null,p=d?u.searchAsync(n):u.search(n),n.resolve=f,n.index=u}else if(n.and)p=dt(n,"and",u);else if(n.or)p=dt(n,"or",u);else if(n.not)p=dt(n,"not",u);else if(n.xor)p=dt(n,"xor",u);else continue}p.await?(m=1,p=p.await):p.then?(m=1,p=p.then(function(d){return d.result||d})):p=p.result||p,r[i]=p}if(m&&!t.await&&(t.await=new Promise(function(d){t.return=d})),m){const d=Promise.all(r).then(function(u){for(let g=0;g<t.C.length;g++)if(t.C[g]===d){t.C[g]=function(){return e.call(t,u,h,o,l,f,c,a)};break}zt(t)});t.C.push(d)}else if(t.await)t.C.push(function(){return e.call(t,r,h,o,l,f,c,a)});else return e.call(t,r,h,o,l,f,c,a);return f?t.await||t.result:t}function dt(t,i,e){t=t[i];const s=t[0]||t;return s.index||(s.index=e),e=new P(s),t.length>1&&(e=e[i].apply(e,t.slice(1))),e}P.prototype.or=function(){return pt(this,"or",ve,arguments)};function ve(t,i,e,s,n,r,h){return t.length&&(this.result.length&&t.push(this.result),t.length<2?this.result=t[0]:(this.result=Vt(t,i,e,!1,this.h),e=0)),n&&(this.await=null),n?this.resolve(i,e,s,h):this}P.prototype.and=function(){return pt(this,"and",ke,arguments)};function ke(t,i,e,s,n,r,h){if(!r&&!this.result.length)return n?this.result:this;let o;if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{let l=0;for(let f=0,c,a;f<t.length;f++)if((c=t[f])&&(a=c.length))l<a&&(l=a);else if(!r){l=0;break}l?(this.result=wt(t,l,i,e,r,this.h,n),o=!0):this.result=[]}else r||(this.result=t);return n&&(this.await=null),n?this.resolve(i,e,s,h,o):this}P.prototype.xor=function(){return pt(this,"xor",Ae,arguments)};function Ae(t,i,e,s,n,r,h){if(t.length)if(this.result.length&&t.unshift(this.result),t.length<2)this.result=t[0];else{t:{r=e;var o=this.h;const l=[],f=q();let c=0;for(let a=0,m;a<t.length;a++)if(m=t[a]){c<m.length&&(c=m.length);for(let p=0,d;p<m.length;p++)if(d=m[p])for(let u=0,g;u<d.length;u++)g=d[u],f[g]=f[g]?2:1}for(let a=0,m,p=0;a<c;a++)for(let d=0,u;d<t.length;d++)if((u=t[d])&&(m=u[a])){for(let g=0,b;g<m.length;g++)if(b=m[g],f[b]===1)if(r)r--;else if(n){if(l.push(b),l.length===i){t=l;break t}}else{const w=a+(d?o:0);if(l[w]||(l[w]=[]),l[w].push(b),++p===i){t=l;break t}}}t=l}this.result=t,o=!0}else r||(this.result=t);return n&&(this.await=null),n?this.resolve(i,e,s,h,o):this}P.prototype.not=function(){return pt(this,"not",_e,arguments)};function _e(t,i,e,s,n,r,h){if(!r&&!this.result.length)return n?this.result:this;if(t.length&&this.result.length){t:{r=e;var o=[];t=new Set(t.flat().flat());for(let l=0,f,c=0;l<this.result.length;l++)if(f=this.result[l]){for(let a=0,m;a<f.length;a++)if(m=f[a],!t.has(m)){if(r)r--;else if(n){if(o.push(m),o.length===i){t=o;break t}}else if(o[l]||(o[l]=[]),o[l].push(m),++c===i){t=o;break t}}}t=o}this.result=t,o=!0}return n&&(this.await=null),n?this.resolve(i,e,s,h,o):this}function mt(t,i,e,s,n){let r,h,o;typeof n=="string"?(r=n,n=""):r=n.template,h=r.indexOf("$1"),o=r.substring(h+2),h=r.substring(0,h);let l=n&&n.boundary,f=!n||n.clip!==!1,c=n&&n.merge&&o&&h&&new RegExp(o+" "+h,"g");n=n&&n.ellipsis;var a=0;if(typeof n=="object"){var m=n.template;a=m.length-2,n=n.pattern}typeof n!="string"&&(n=n===!1?"":"..."),a&&(n=m.replace("$1",n)),m=n.length-a;let p,d;typeof l=="object"&&(p=l.before,p===0&&(p=-1),d=l.after,d===0&&(d=-1),l=l.total||9e5),a=new Map;for(let Et=0,I,oe,ct;Et<i.length;Et++){let ut;if(s)ut=i,ct=s;else{var u=i[Et];if(ct=u.field,!ct)continue;ut=u.result}oe=e.get(ct),I=oe.encoder,u=a.get(I),typeof u!="string"&&(u=I.encode(t),a.set(I,u));for(let kt=0;kt<ut.length;kt++){var g=ut[kt].doc;if(!g||(g=ht(g,ct),!g))continue;var b=g.trim().split(/\s+/);if(!b.length)continue;g="";var w=[];let At=[];for(var k=-1,B=-1,S=0,j=0;j<b.length;j++){var A=b[j],x=I.encode(A);x=x.length>1?x.join(" "):x[0];let v;if(x&&A){for(var _=A.length,L=(I.split?A.replace(I.split,""):A).length-x.length,C="",$=0,O=0;O<u.length;O++){var N=u[O];if(N){var M=N.length;M+=L<0?0:L,$&&M<=$||(N=x.indexOf(N),N>-1&&(C=(N?A.substring(0,N):"")+h+A.substring(N,N+M)+o+(N+M<_?A.substring(N+M):""),$=M,v=!0))}}C&&(l&&(k<0&&(k=g.length+(g?1:0)),B=g.length+(g?1:0)+C.length,S+=_,At.push(w.length),w.push({match:C})),g+=(g?" ":"")+C)}if(!v)A=b[j],g+=(g?" ":"")+A,l&&w.push({text:A});else if(l&&S>=l)break}if(S=At.length*(r.length-2),p||d||l&&g.length-S>l)if(S=l+S-m*2,j=B-k,p>0&&(j+=p),d>0&&(j+=d),j<=S)b=p?k-(p>0?p:0):k-((S-j)/2|0),w=d?B+(d>0?d:0):b+S,f||(b>0&&g.charAt(b)!==" "&&g.charAt(b-1)!==" "&&(b=g.indexOf(" ",b),b<0&&(b=0)),w<g.length&&g.charAt(w-1)!==" "&&g.charAt(w)!==" "&&(w=g.lastIndexOf(" ",w),w<B?w=B:++w)),g=(b?n:"")+g.substring(b,w)+(w<g.length?n:"");else{for(B=[],k={},S={},j={},A={},x={},C=L=_=0,O=$=1;;){var J=void 0;for(let v=0,D;v<At.length;v++){if(D=At[v],C)if(L!==C){if(j[v+1])continue;if(D+=C,k[D]){_-=m,S[v+1]=1,j[v+1]=1;continue}if(D>=w.length-1){if(D>=w.length){j[v+1]=1,D>=b.length&&(S[v+1]=1);continue}_-=m}if(g=w[D].text,M=d&&x[v])if(M>0){if(g.length>M)if(j[v+1]=1,f)g=g.substring(0,M);else continue;(M-=g.length)||(M=-1),x[v]=M}else{j[v+1]=1;continue}if(_+g.length+1<=l)g=" "+g,B[v]+=g;else if(f)J=l-_-1,J>0&&(g=" "+g.substring(0,J),B[v]+=g),j[v+1]=1;else{j[v+1]=1;continue}}else{if(j[v])continue;if(D-=L,k[D]){_-=m,j[v]=1,S[v]=1;continue}if(D<=0){if(D<0){j[v]=1,S[v]=1;continue}_-=m}if(g=w[D].text,M=p&&A[v])if(M>0){if(g.length>M)if(j[v]=1,f)g=g.substring(g.length-M);else continue;(M-=g.length)||(M=-1),A[v]=M}else{j[v]=1;continue}if(_+g.length+1<=l)g+=" ",B[v]=g+B[v];else if(f)J=g.length+1-(l-_),J>=0&&J<g.length&&(g=g.substring(J)+" ",B[v]=g+B[v]),j[v]=1;else{j[v]=1;continue}}else{g=w[D].match,p&&(A[v]=p),d&&(x[v]=d),v&&_++;let fe;if(D?!v&&m&&(_+=m):(S[v]=1,j[v]=1),D>=b.length-1||D<w.length-1&&w[D+1].match?fe=1:m&&(_+=m),_-=r.length-2,!v||_+g.length<=l)B[v]=g;else{J=$=O=S[v]=0;break}fe&&(S[v+1]=1,j[v+1]=1)}_+=g.length,J=k[D]=1}if(J)L===C?C++:L++;else{if(L===C?$=0:O=0,!$&&!O)break;$?(L++,C=L):C++}}g="";for(let v=0,D;v<B.length;v++)D=(S[v]?v?" ":"":(v&&!n?" ":"")+n)+B[v],g+=D;n&&!S[B.length]&&(g+=n)}c&&(g=g.replace(c," ")),ut[kt].highlight=g}if(s)break}return i}function P(t,i){if(!this||this.constructor!==P)return new P(t,i);let e=0,s,n,r,h,o,l;if(t&&t.index){const f=t;if(i=f.index,e=f.boost||0,n=f.query){r=f.field||f.pluck,h=f.highlight;const c=f.resolve;t=f.async||f.queue,f.resolve=!1,f.index=null,t=t?i.searchAsync(f):i.search(f),f.resolve=c,f.index=i,t=t.result||t}else t=[]}if(t&&t.then){const f=this;t=t.then(function(c){f.C[0]=f.result=c.result||c,zt(f)}),s=[t],t=[],o=new Promise(function(c){l=c})}this.index=i||null,this.result=t||[],this.h=e,this.C=s||[],this.await=o||null,this.return=l||null,this.highlight=h||null,this.query=n||"",this.field=r||""}y=P.prototype,y.limit=function(t){if(this.await){const i=this;this.C.push(function(){return i.limit(t).result})}else if(this.result.length){const i=[];for(let e=0,s;e<this.result.length;e++)if(s=this.result[e])if(s.length<=t){if(i[e]=s,t-=s.length,!t)break}else{i[e]=s.slice(0,t);break}this.result=i}return this},y.offset=function(t){if(this.await){const i=this;this.C.push(function(){return i.offset(t).result})}else if(this.result.length){const i=[];for(let e=0,s;e<this.result.length;e++)(s=this.result[e])&&(s.length<=t?t-=s.length:(i[e]=s.slice(t),t=0));this.result=i}return this},y.boost=function(t){if(this.await){const i=this;this.C.push(function(){return i.boost(t).result})}else this.h+=t;return this};function zt(t,i){let e=t.result;var s=t.await;t.await=null;for(let n=0,r;n<t.C.length;n++)if(r=t.C[n]){if(typeof r=="function")e=r(),t.C[n]=e=e.result||e,n--;else if(r.h)e=r.h(),t.C[n]=e=e.result||e,n--;else if(r.then)return t.await=s}return s=t.return,t.C=[],t.return=null,i||s(e),e}y.resolve=function(t,i,e,s,n){let r=this.await?zt(this,!0):this.result;if(r.then){const h=this;return r.then(function(){return h.resolve(t,i,e,s,n)})}return r.length&&(typeof t=="object"?(s=t.highlight||this.highlight,e=!!s||t.enrich,i=t.offset,t=t.limit):(s=s||this.highlight,e=!!s||e),r=n?e?nt.call(this.index,r):r:qt.call(this.index,r,t||100,i,e)),this.finalize(r,s)},y.finalize=function(t,i){if(t.then){const s=this;return t.then(function(n){return s.finalize(n,i)})}i&&t.length&&this.query&&(t=mt(this.query,t,this.index.index,this.field,i));const e=this.return;return this.highlight=this.index=this.result=this.C=this.await=this.return=null,this.query=this.field="",e&&e(t),t};function wt(t,i,e,s,n,r,h){const o=t.length;let l=[],f,c;f=q();for(let a=0,m,p,d,u;a<i;a++)for(let g=0;g<o;g++)if(d=t[g],a<d.length&&(m=d[a]))for(let b=0;b<m.length;b++){if(p=m[b],(c=f[p])?f[p]++:(c=0,f[p]=1),u=l[c]||(l[c]=[]),!h){let w=a+(g||!n?0:r||0);u=u[w]||(u[w]=[])}if(u.push(p),h&&e&&c===o-1&&u.length-s===e)return s?u.slice(s):u}if(t=l.length)if(n)l=l.length>1?Vt(l,e,s,h,r):(l=l[0])&&e&&l.length>e||s?l.slice(s,e+s):l;else{if(t<o)return[];if(l=l[t-1],e||s)if(h)(l.length>e||s)&&(l=l.slice(s,e+s));else{n=[];for(let a=0,m;a<l.length;a++)if(m=l[a]){if(s&&m.length>s)s-=m.length;else if((e&&m.length>e||s)&&(m=m.slice(s,e+s),e-=m.length,s&&(s-=m.length)),n.push(m),!e)break}l=n}}return l}function Vt(t,i,e,s,n){const r=[],h=q();let o;var l=t.length;let f;if(s){for(n=l-1;n>=0;n--)if(f=(s=t[n])&&s.length){for(l=0;l<f;l++)if(o=s[l],!h[o]){if(h[o]=1,e)e--;else if(r.push(o),r.length===i)return r}}}else for(let c=l-1,a,m=0;c>=0;c--){a=t[c];for(let p=0;p<a.length;p++)if(f=(s=a[p])&&s.length){for(let d=0;d<f;d++)if(o=s[d],!h[o])if(h[o]=1,e)e--;else{let u=(p+(c<l-1&&n||0))/(c+1)|0;if((r[u]||(r[u]=[])).push(o),++m===i)return r}}}return r}function je(t,i,e,s,n){const r=q(),h=[];for(let o=0,l;o<i.length;o++){l=i[o];for(let f=0;f<l.length;f++)r[l[f]]=1}if(n){for(let o=0,l;o<t.length;o++)if(l=t[o],r[l]){if(s)s--;else if(h.push(l),r[l]=0,e&&--e===0)break}}else for(let o=0,l,f;o<t.result.length;o++)for(l=t.result[o],i=0;i<l.length;i++)f=l[i],r[f]&&((h[o]||(h[o]=[])).push(f),r[f]=0);return h}st.prototype.search=function(t,i,e,s){e||(!i&&rt(t)?(e=t,t=""):rt(i)&&(e=i,i=0));let n=[];var r=[];let h,o,l,f,c,a,m=0,p=!0,d;if(e){e.constructor===Array&&(e={index:e}),t=e.query||t,h=e.pluck,o=e.merge,f=e.boost,a=h||e.field||(a=e.index)&&(a.index?null:a);var u=this.tag&&e.tag;l=e.suggest,p=e.resolve!==!1,c=e.cache,d=p&&this.store&&e.highlight;var g=!!d||p&&this.store&&e.enrich;i=e.limit||i;var b=e.offset||0;if(i||(i=p?100:0),u&&(!this.db||!s)){u.constructor!==Array&&(u=[u]);var w=[];for(let A=0,x;A<u.length;A++)if(x=u[A],x.field&&x.tag){var k=x.tag;if(k.constructor===Array)for(var B=0;B<k.length;B++)w.push(x.field,k[B]);else w.push(x.field,k)}else{k=Object.keys(x);for(let _=0,L,C;_<k.length;_++)if(L=k[_],C=x[L],C.constructor===Array)for(B=0;B<C.length;B++)w.push(L,C[B]);else w.push(L,C)}if(u=w,!t){if(r=[],w.length)for(u=0;u<w.length;u+=2){if(this.db){if(s=this.index.get(w[u]),!s)continue;r.push(s=s.db.tag(w[u+1],i,b,g))}else s=Be.call(this,w[u],w[u+1],i,b,g);n.push(p?{field:w[u],tag:w[u+1],result:s}:[s])}if(r.length){const A=this;return Promise.all(r).then(function(x){for(let _=0;_<x.length;_++)p?n[_].result=x[_]:n[_]=x[_];return p?n:new P(n.length>1?wt(n,1,0,0,l,f):n[0],A)})}return p?n:new P(n.length>1?wt(n,1,0,0,l,f):n[0],this)}}p||h||!(a=a||this.field)||(F(a)?h=a:(a.constructor===Array&&a.length===1&&(a=a[0]),h=a.field||a.index)),a&&a.constructor!==Array&&(a=[a])}a||(a=this.field);let S;w=(this.worker||this.db)&&!s&&[];for(let A=0,x,_,L;A<a.length;A++){if(_=a[A],this.db&&this.tag&&!this.B[A])continue;let C;if(F(_)||(C=_,_=C.field,t=C.query||t,i=E(C.limit,i),b=E(C.offset,b),l=E(C.suggest,l),d=p&&this.store&&E(C.highlight,d),g=!!d||p&&this.store&&E(C.enrich,g),c=E(C.cache,c)),s)x=s[A];else{k=C||e||{},B=k.enrich;var j=this.index.get(_);if(u&&(this.db&&(k.tag=u,k.field=a,S=j.db.support_tag_search),!S&&B&&(k.enrich=!1),S||(k.limit=0,k.offset=0)),x=c?j.searchCache(t,u&&!S?0:i,k):j.search(t,u&&!S?0:i,k),u&&!S&&(k.limit=i,k.offset=b),B&&(k.enrich=B),w){w[A]=x;continue}}if(L=(x=x.result||x)&&x.length,u&&L){if(k=[],B=0,this.db&&s){if(!S)for(j=a.length;j<s.length;j++){let $=s[j];if($&&$.length)B++,k.push($);else if(!l)return p?n:new P(n,this)}}else for(let $=0,O,N;$<u.length;$+=2){if(O=this.tag.get(u[$]),!O){if(l)continue;return p?n:new P(n,this)}if(N=(O=O&&O.get(u[$+1]))&&O.length)B++,k.push(O);else if(!l)return p?n:new P(n,this)}if(B){if(x=je(x,k,i,b,p),L=x.length,!L&&!l)return p?x:new P(x,this);B--}}if(L)r[m]=_,n.push(x),m++;else if(a.length===1)return p?n:new P(n,this)}if(w){if(this.db&&u&&u.length&&!S)for(g=0;g<u.length;g+=2){if(r=this.index.get(u[g]),!r){if(l)continue;return p?n:new P(n,this)}w.push(r.db.tag(u[g+1],i,b,!1))}const A=this;return Promise.all(w).then(function(x){return e&&(e.resolve=p),x.length&&(x=A.search(t,i,e,x)),x})}if(!m)return p?n:new P(n,this);if(h&&(!g||!this.store))return n=n[0],p?n:new P(n,this);for(w=[],b=0;b<r.length;b++){if(u=n[b],g&&u.length&&typeof u[0].doc>"u"&&(this.db?w.push(u=this.index.get(this.field[0]).db.enrich(u)):u=nt.call(this,u)),h)return p?d?mt(t,u,this.index,h,d):u:new P(u,this);n[b]={field:r[b],result:u}}if(g&&this.db&&w.length){const A=this;return Promise.all(w).then(function(x){for(let _=0;_<x.length;_++)n[_].result=x[_];return d&&(n=mt(t,n,A.index,h,d)),o?Xt(n):n})}return d&&(n=mt(t,n,this.index,h,d)),o?Xt(n):n};function Xt(t){const i=[],e=q(),s=q();for(let n=0,r,h,o,l,f,c,a;n<t.length;n++){r=t[n],h=r.field,o=r.result;for(let m=0;m<o.length;m++)f=o[m],typeof f!="object"?f={id:l=f}:l=f.id,(c=e[l])?c.push(h):(f.field=e[l]=[h],i.push(f)),(a=f.highlight)&&(c=s[l],c||(s[l]=c={},f.highlight=c),c[h]=a)}return i}function Be(t,i,e,s,n){return t=this.tag.get(t),t?(t=t.get(i),t?(i=t.length-s,i>0&&((e&&i>e||s)&&(t=t.slice(s,s+e)),n&&(t=nt.call(this,t))),t):[]):[]}function nt(t){if(!this||!this.store)return t;if(this.db)return this.index.get(this.field[0]).db.enrich(t);const i=Array(t.length);for(let e=0,s;e<t.length;e++)s=t[e],i[e]={id:s,doc:this.store.get(s)};return i}function st(t){if(!this||this.constructor!==st)return new st(t);const i=t.document||t.doc||t;let e,s;if(this.B=[],this.field=[],this.D=[],this.key=(e=i.key||i.id)&&yt(e,this.D)||"id",(s=t.keystore||0)&&(this.keystore=s),this.fastupdate=!!t.fastupdate,this.reg=!this.fastupdate||t.worker||t.db?s?new K(s):new Set:s?new T(s):new Map,this.h=(e=i.store||null)&&e&&e!==!0&&[],this.store=e?s?new T(s):new Map:null,this.cache=(e=t.cache||null)&&new X(e),t.cache=!1,this.worker=t.worker||!1,this.priority=t.priority||4,this.index=Se.call(this,t,i),this.tag=null,(e=i.tag)&&(typeof e=="string"&&(e=[e]),e.length)){this.tag=new Map,this.A=[],this.F=[];for(let n=0,r,h;n<e.length;n++){if(r=e[n],h=r.field||r,!h)throw Error("The tag field from the document descriptor is undefined.");r.custom?this.A[n]=r.custom:(this.A[n]=yt(h,this.D),r.filter&&(typeof this.A[n]=="string"&&(this.A[n]=new String(this.A[n])),this.A[n].G=r.filter)),this.F[n]=h,this.tag.set(h,new Map)}}if(this.worker){this.fastupdate=!1,t=[];for(const n of this.index.values())n.then&&t.push(n);if(t.length){const n=this;return Promise.all(t).then(function(r){let h=0;for(const o of n.index.entries()){const l=o[0];let f=o[1];f.then&&(f=r[h],n.index.set(l,f),h++)}return n})}}else t.db&&(this.fastupdate=!1,this.mount(t.db))}y=st.prototype,y.mount=function(t){let i=this.field;if(this.tag)for(let r=0,h;r<this.F.length;r++){h=this.F[r];var e=void 0;this.index.set(h,e=new G({},this.reg)),i===this.field&&(i=i.slice(0)),i.push(h),e.tag=this.tag.get(h)}e=[];const s={db:t.db,type:t.type,fastupdate:t.fastupdate};for(let r=0,h,o;r<i.length;r++){s.field=o=i[r],h=this.index.get(o);const l=new t.constructor(t.id,s);l.id=t.id,e[r]=l.mount(h),h.document=!0,r?h.bypass=!0:h.store=this.store}const n=this;return this.db=Promise.all(e).then(function(){n.db=!0})},y.commit=async function(){const t=[];for(const i of this.index.values())t.push(i.commit());await Promise.all(t),this.reg.clear()},y.destroy=function(){const t=[];for(const i of this.index.values())t.push(i.destroy());return Promise.all(t)};function Se(t,i){const e=new Map;let s=i.index||i.field||i;F(s)&&(s=[s]);for(let r=0,h,o;r<s.length;r++){if(h=s[r],F(h)||(o=h,h=h.field),o=rt(o)?Object.assign({},t,o):t,this.worker){var n=void 0;n=(n=o.encoder)&&n.encode?n:new lt(typeof n=="string"?Wt[n]:n||{}),n=new it(o,n),e.set(h,n)}this.worker||e.set(h,new G(o,this.reg)),o.custom?this.B[r]=o.custom:(this.B[r]=yt(h,this.D),o.filter&&(typeof this.B[r]=="string"&&(this.B[r]=new String(this.B[r])),this.B[r].G=o.filter)),this.field[r]=h}if(this.h){t=i.store,F(t)&&(t=[t]);for(let r=0,h,o;r<t.length;r++)h=t[r],o=h.field||h,h.custom?(this.h[r]=h.custom,h.custom.O=o):(this.h[r]=yt(o,this.D),h.filter&&(typeof this.h[r]=="string"&&(this.h[r]=new String(this.h[r])),this.h[r].G=h.filter))}return e}function yt(t,i){const e=t.split(":");let s=0;for(let n=0;n<e.length;n++)t=e[n],t[t.length-1]==="]"&&(t=t.substring(0,t.length-2))&&(i[s]=!0),t&&(e[s++]=t);return s<e.length&&(e.length=s),s>1?e:e[0]}y.append=function(t,i){return this.add(t,i,!0)},y.update=function(t,i){return this.remove(t).add(t,i)},y.remove=function(t){rt(t)&&(t=ht(t,this.key));for(var i of this.index.values())i.remove(t,!0);if(this.reg.has(t)){if(this.tag&&!this.fastupdate)for(let e of this.tag.values())for(let s of e){i=s[0];const n=s[1],r=n.indexOf(t);r>-1&&(n.length>1?n.splice(r,1):e.delete(i))}this.store&&this.store.delete(t),this.reg.delete(t)}return this.cache&&this.cache.remove(t),this},y.clear=function(){const t=[];for(const i of this.index.values()){const e=i.clear();e.then&&t.push(e)}if(this.tag)for(const i of this.tag.values())i.clear();return this.store&&this.store.clear(),this.cache&&this.cache.clear(),t.length?Promise.all(t):this},y.contain=function(t){return this.db?this.index.get(this.field[0]).db.has(t):this.reg.has(t)},y.cleanup=function(){for(const t of this.index.values())t.cleanup();return this},y.get=function(t){return this.db?this.index.get(this.field[0]).db.enrich(t).then(function(i){return i[0]&&i[0].doc||null}):this.store.get(t)||null},y.set=function(t,i){return typeof t=="object"&&(i=t,t=ht(i,this.key)),this.store.set(t,i),this},y.searchCache=_t,y.export=Ce,y.import=Pe,Bt(st.prototype);function Lt(t,i=0){let e=[],s=[];i&&(i=25e4/i*5e3|0);for(const n of t.entries())s.push(n),s.length===i&&(e.push(s),s=[]);return s.length&&e.push(s),e}function Dt(t,i){i||(i=new Map);for(let e=0,s;e<t.length;e++)s=t[e],i.set(s[0],s[1]);return i}function Yt(t,i=0){let e=[],s=[];i&&(i=25e4/i*1e3|0);for(const n of t.entries())s.push([n[0],Lt(n[1])[0]||[]]),s.length===i&&(e.push(s),s=[]);return s.length&&e.push(s),e}function It(t,i){i||(i=new Map);for(let e=0,s,n;e<t.length;e++)s=t[e],n=i.get(s[0]),i.set(s[0],Dt(s[1],n));return i}function Ht(t){let i=[],e=[];for(const s of t.keys())e.push(s),e.length===25e4&&(i.push(e),e=[]);return e.length&&i.push(e),i}function te(t,i){i||(i=new Set);for(let e=0;e<t.length;e++)i.add(t[e]);return i}function bt(t,i,e,s,n,r,h=0){const o=s&&s.constructor===Array;var l=o?s.shift():s;if(!l)return this.export(t,i,n,r+1);if((l=t((i?i+".":"")+(h+1)+"."+e,JSON.stringify(l)))&&l.then){const f=this;return l.then(function(){return bt.call(f,t,i,e,o?s:null,n,r,h+1)})}return bt.call(this,t,i,e,o?s:null,n,r,h+1)}function Ce(t,i,e=0,s=0){if(e<this.field.length){const h=this.field[e];if((i=this.index.get(h).export(t,h,e,s=1))&&i.then){const o=this;return i.then(function(){return o.export(t,h,e+1)})}return this.export(t,h,e+1)}let n,r;switch(s){case 0:n="reg",r=Ht(this.reg),i=null;break;case 1:n="tag",r=this.tag&&Yt(this.tag,this.reg.size),i=null;break;case 2:n="doc",r=this.store&&Lt(this.store),i=null;break;default:return}return bt.call(this,t,i,n,r||null,e,s)}function Pe(t,i){var e=t.split(".");e[e.length-1]==="json"&&e.pop();const s=e.length>2?e[0]:"";if(e=e.length>2?e[2]:e[1],this.worker&&s)return this.index.get(s).import(t);if(i){if(typeof i=="string"&&(i=JSON.parse(i)),s)return this.index.get(s).import(e,i);switch(e){case"reg":this.fastupdate=!1,this.reg=te(i,this.reg);for(let n=0,r;n<this.field.length;n++)r=this.index.get(this.field[n]),r.fastupdate=!1,r.reg=this.reg;if(this.worker){i=[];for(const n of this.index.values())i.push(n.import(t));return Promise.all(i)}break;case"tag":this.tag=It(i,this.tag);break;case"doc":this.store=Dt(i,this.store)}}}function ee(t,i){let e="";for(const s of t.entries()){t=s[0];const n=s[1];let r="";for(let h=0,o;h<n.length;h++){o=n[h]||[""];let l="";for(let f=0;f<o.length;f++)l+=(l?",":"")+(i==="string"?'"'+o[f]+'"':o[f]);l="["+l+"]",r+=(r?",":"")+l}r='["'+t+'",['+r+"]]",e+=(e?",":"")+r}return e}G.prototype.remove=function(t,i){const e=this.reg.size&&(this.fastupdate?this.reg.get(t):this.reg.has(t));if(e){if(this.fastupdate){for(let s=0,n,r;s<e.length;s++)if((n=e[s])&&(r=n.length))if(n[r-1]===t)n.pop();else{const h=n.indexOf(t);h>=0&&n.splice(h,1)}}else ft(this.map,t),this.depth&&ft(this.ctx,t);i||this.reg.delete(t)}return this.db&&(this.commit_task.push({del:t}),this.M&&re(this)),this.cache&&this.cache.remove(t),this};function ft(t,i){let e=0;var s=typeof i>"u";if(t.constructor===Array){for(let n=0,r,h,o;n<t.length;n++)if((r=t[n])&&r.length){if(s)return 1;if(h=r.indexOf(i),h>=0){if(r.length>1)return r.splice(h,1),1;if(delete t[n],e)return 1;o=1}else{if(o)return 1;e++}}}else for(let n of t.entries())s=n[0],ft(n[1],i)?e++:t.delete(s);return e}const qe={memory:{resolution:1},performance:{resolution:3,fastupdate:!0,context:{depth:1,resolution:1}},match:{tokenize:"forward"},score:{resolution:9,context:{depth:2,resolution:3}}};G.prototype.add=function(t,i,e,s){if(i&&(t||t===0)){if(!s&&!e&&this.reg.has(t))return this.update(t,i);s=this.depth,i=this.encoder.encode(i,!s);const f=i.length;if(f){const c=q(),a=q(),m=this.resolution;for(let p=0;p<f;p++){let d=i[this.rtl?f-1-p:p];var n=d.length;if(n&&(s||!a[d])){var r=this.score?this.score(i,d,p,null,0):xt(m,f,p),h="";switch(this.tokenize){case"tolerant":if(W(this,a,d,r,t,e),n>2){for(let u=1,g,b,w,k;u<n-1;u++)g=d.charAt(u),b=d.charAt(u+1),w=d.substring(0,u)+b,k=d.substring(u+2),h=w+g+k,W(this,a,h,r,t,e),h=w+k,W(this,a,h,r,t,e);W(this,a,d.substring(0,d.length-1),r,t,e)}break;case"full":if(n>2){for(let u=0,g;u<n;u++)for(r=n;r>u;r--){h=d.substring(u,r),g=this.rtl?n-1-u:u;var o=this.score?this.score(i,d,p,h,g):xt(m,f,p,n,g);W(this,a,h,o,t,e)}break}case"bidirectional":case"reverse":if(n>1){for(o=n-1;o>0;o--){h=d[this.rtl?n-1-o:o]+h;var l=this.score?this.score(i,d,p,h,o):xt(m,f,p,n,o);W(this,a,h,l,t,e)}h=""}case"forward":if(n>1){for(o=0;o<n;o++)h+=d[this.rtl?n-1-o:o],W(this,a,h,r,t,e);break}default:if(W(this,a,d,r,t,e),s&&f>1&&p<f-1)for(n=this.N,h=d,r=Math.min(s+1,this.rtl?p+1:f-p),o=1;o<r;o++){d=i[this.rtl?f-1-p-o:p+o],l=this.bidirectional&&d>h;const u=this.score?this.score(i,h,p,d,o-1):xt(n+(f/2>n?0:1),f,p,r-1,o-1);W(this,c,l?h:d,u,t,e,l?d:h)}}}}this.fastupdate||this.reg.add(t)}}return this.db&&(this.commit_task.push(e?{ins:t}:{del:t}),this.M&&re(this)),this};function W(t,i,e,s,n,r,h){let o,l;if(!(o=i[e])||h&&!o[h]){if(h?(i=o||(i[e]=q()),i[h]=1,l=t.ctx,(o=l.get(h))?l=o:l.set(h,l=t.keystore?new T(t.keystore):new Map)):(l=t.map,i[e]=1),(o=l.get(e))?l=o:l.set(e,l=o=[]),r){for(let f=0,c;f<o.length;f++)if((c=o[f])&&c.includes(n)){if(f<=s)return;c.splice(c.indexOf(n),1),t.fastupdate&&(i=t.reg.get(n))&&i.splice(i.indexOf(c),1);break}}if(l=l[s]||(l[s]=[]),l.push(n),l.length===2**31-1){if(i=new H(l),t.fastupdate)for(let f of t.reg.values())f.includes(l)&&(f[f.indexOf(l)]=i);o[s]=l=i}t.fastupdate&&((s=t.reg.get(n))?s.push(l):t.reg.set(n,[l]))}}function xt(t,i,e,s,n){return e&&t>1?i+(s||0)<=t?e+(n||0):(t-1)/(i+(s||0))*(e+(n||0))+1|0:0}G.prototype.search=function(t,i,e){if(e||(i||typeof t!="object"?typeof i=="object"&&(e=i,i=0):(e=t,t="")),e&&e.cache)return e.cache=!1,t=this.searchCache(t,i,e),e.cache=!0,t;let s=[],n,r,h,o=0,l,f,c,a,m;e&&(t=e.query||t,i=e.limit||i,o=e.offset||0,r=e.context,h=e.suggest,m=(l=e.resolve)&&e.enrich,c=e.boost,a=e.resolution,f=this.db&&e.tag),typeof l>"u"&&(l=this.resolve),r=this.depth&&r!==!1;let p=this.encoder.encode(t,!r);if(n=p.length,i=i||(l?100:0),n===1)return ne.call(this,p[0],"",i,o,l,m,f);if(n===2&&r&&!h)return ne.call(this,p[1],p[0],i,o,l,m,f);let d=q(),u=0,g;if(r&&(g=p[0],u=1),a||a===0||(a=g?this.N:this.resolution),this.db){if(this.db.search&&(e=this.db.search(this,p,i,o,h,l,m,f),e!==!1))return e;const b=this;return async function(){for(let w,k;u<n;u++){if((k=p[u])&&!d[k]){if(d[k]=1,w=await Mt(b,k,g,0,0,!1,!1),w=se(w,s,h,a)){s=w;break}g&&(h&&w&&s.length||(g=k))}h&&g&&u===n-1&&!s.length&&(a=b.resolution,g="",u=-1,d=q())}return ie(s,a,i,o,h,c,l)}()}for(let b,w;u<n;u++){if((w=p[u])&&!d[w]){if(d[w]=1,b=Mt(this,w,g,0,0,!1,!1),b=se(b,s,h,a)){s=b;break}g&&(h&&b&&s.length||(g=w))}h&&g&&u===n-1&&!s.length&&(a=this.resolution,g="",u=-1,d=q())}return ie(s,a,i,o,h,c,l)};function ie(t,i,e,s,n,r,h){let o=t.length,l=t;if(o>1)l=wt(t,i,e,s,n,r,h);else if(o===1)return h?qt.call(null,t[0],e,s):new P(t[0],this);return h?l:new P(l,this)}function ne(t,i,e,s,n,r,h){return t=Mt(this,t,i,e,s,n,r,h),this.db?t.then(function(o){return n?o||[]:new P(o,this)}):t&&t.length?n?qt.call(this,t,e,s):new P(t,this):n?[]:new P([],this)}function se(t,i,e,s){let n=[];if(t&&t.length){if(t.length<=s){i.push(t);return}for(let r=0,h;r<s;r++)(h=t[r])&&(n[r]=h);if(n.length){i.push(n);return}}if(!e)return n}function Mt(t,i,e,s,n,r,h,o){let l;return e&&(l=t.bidirectional&&i>e)&&(l=e,e=i,i=l),t.db?t.db.get(i,e,s,n,r,h,o):(t=e?(t=t.ctx.get(e))&&t.get(i):t.map.get(i),t)}function G(t,i){if(!this||this.constructor!==G)return new G(t);if(t){var e=F(t)?t:t.preset;e&&(t=Object.assign({},qe[e],t))}else t={};e=t.context;const s=e===!0?{depth:1}:e||{},n=F(t.encoder)?Wt[t.encoder]:t.encode||t.encoder||{};this.encoder=n.encode?n:typeof n=="object"?new lt(n):{encode:n},this.resolution=t.resolution||9,this.tokenize=e=(e=t.tokenize)&&e!=="default"&&e!=="exact"&&e||"strict",this.depth=e==="strict"&&s.depth||0,this.bidirectional=s.bidirectional!==!1,this.fastupdate=!!t.fastupdate,this.score=t.score||null,(e=t.keystore||0)&&(this.keystore=e),this.map=e?new T(e):new Map,this.ctx=e?new T(e):new Map,this.reg=i||(this.fastupdate?e?new T(e):new Map:e?new K(e):new Set),this.N=s.resolution||3,this.rtl=n.rtl||t.rtl||!1,this.cache=(e=t.cache||null)&&new X(e),this.resolve=t.resolve!==!1,(e=t.db)&&(this.db=this.mount(e)),this.M=t.commit!==!1,this.commit_task=[],this.commit_timer=null,this.priority=t.priority||4}y=G.prototype,y.mount=function(t){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),t.mount(this)},y.commit=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.commit(this)},y.destroy=function(){return this.commit_timer&&(clearTimeout(this.commit_timer),this.commit_timer=null),this.db.destroy()};function re(t){t.commit_timer||(t.commit_timer=setTimeout(function(){t.commit_timer=null,t.db.commit(t)},1))}y.clear=function(){return this.map.clear(),this.ctx.clear(),this.reg.clear(),this.cache&&this.cache.clear(),this.db?(this.commit_timer&&clearTimeout(this.commit_timer),this.commit_timer=null,this.commit_task=[],this.db.clear()):this},y.append=function(t,i){return this.add(t,i,!0)},y.contain=function(t){return this.db?this.db.has(t):this.reg.has(t)},y.update=function(t,i){const e=this,s=this.remove(t);return s&&s.then?s.then(()=>e.add(t,i)):this.add(t,i)},y.cleanup=function(){return this.fastupdate?(ft(this.map),this.depth&&ft(this.ctx),this):this},y.searchCache=_t,y.export=function(t,i,e=0,s=0){let n,r;switch(s){case 0:n="reg",r=Ht(this.reg);break;case 1:n="cfg",r=null;break;case 2:n="map",r=Lt(this.map,this.reg.size);break;case 3:n="ctx",r=Yt(this.ctx,this.reg.size);break;default:return}return bt.call(this,t,i,n,r,e,s)},y.import=function(t,i){if(i)switch(typeof i=="string"&&(i=JSON.parse(i)),t=t.split("."),t[t.length-1]==="json"&&t.pop(),t.length===3&&t.shift(),t=t.length>1?t[1]:t[0],t){case"reg":this.fastupdate=!1,this.reg=te(i,this.reg);break;case"map":this.map=Dt(i,this.map);break;case"ctx":this.ctx=It(i,this.ctx)}},y.serialize=function(t=!0){let i="",e="",s="";if(this.reg.size){let r;for(var n of this.reg.keys())r||(r=typeof n),i+=(i?",":"")+(r==="string"?'"'+n+'"':n);i="index.reg=new Set(["+i+"]);",e=ee(this.map,r),e="index.map=new Map(["+e+"]);";for(const h of this.ctx.entries()){n=h[0];let o=ee(h[1],r);o="new Map(["+o+"])",o='["'+n+'",'+o+"]",s+=(s?",":"")+o}s="index.ctx=new Map(["+s+"]);"}return t?"function inject(index){"+i+e+s+"}":i+e+s},Bt(G.prototype);const he=typeof window<"u"&&(window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB),vt=["map","ctx","tag","reg","cfg"],Y=q();function $t(t,i={}){if(!this||this.constructor!==$t)return new $t(t,i);typeof t=="object"&&(i=t,t=t.name),t||console.info("Default storage space was used, because a name was not passed."),this.id="flexsearch"+(t?":"+t.toLowerCase().replace(/[^a-z0-9_\-]/g,""):""),this.field=i.field?i.field.toLowerCase().replace(/[^a-z0-9_\-]/g,""):"",this.type=i.type,this.fastupdate=this.support_tag_search=!1,this.db=null,this.h={}}y=$t.prototype,y.mount=function(t){return t.index?t.mount(this):(t.db=this,this.open())},y.open=function(){if(this.db)return this.db;let t=this;navigator.storage&&navigator.storage.persist&&navigator.storage.persist(),Y[t.id]||(Y[t.id]=[]),Y[t.id].push(t.field);const i=he.open(t.id,1);return i.onupgradeneeded=function(){const e=t.db=this.result;for(let s=0,n;s<vt.length;s++){n=vt[s];for(let r=0,h;r<Y[t.id].length;r++)h=Y[t.id][r],e.objectStoreNames.contains(n+(n!=="reg"&&h?":"+h:""))||e.createObjectStore(n+(n!=="reg"&&h?":"+h:""))}},t.db=Z(i,function(e){t.db=e,t.db.onversionchange=function(){t.close()}})},y.close=function(){this.db&&this.db.close(),this.db=null},y.destroy=function(){const t=he.deleteDatabase(this.id);return Z(t)},y.clear=function(){const t=[];for(let e=0,s;e<vt.length;e++){s=vt[e];for(let n=0,r;n<Y[this.id].length;n++)r=Y[this.id][n],t.push(s+(s!=="reg"&&r?":"+r:""))}const i=this.db.transaction(t,"readwrite");for(let e=0;e<t.length;e++)i.objectStore(t[e]).clear();return Z(i)},y.get=function(t,i,e=0,s=0,n=!0,r=!1){t=this.db.transaction((i?"ctx":"map")+(this.field?":"+this.field:""),"readonly").objectStore((i?"ctx":"map")+(this.field?":"+this.field:"")).get(i?i+":"+t:t);const h=this;return Z(t).then(function(o){let l=[];if(!o||!o.length)return l;if(n){if(!e&&!s&&o.length===1)return o[0];for(let f=0,c;f<o.length;f++)if((c=o[f])&&c.length){if(s>=c.length){s-=c.length;continue}const a=e?s+Math.min(c.length-s,e):c.length;for(let m=s;m<a;m++)l.push(c[m]);if(s=0,l.length===e)break}return r?h.enrich(l):l}return o})},y.tag=function(t,i=0,e=0,s=!1){t=this.db.transaction("tag"+(this.field?":"+this.field:""),"readonly").objectStore("tag"+(this.field?":"+this.field:"")).get(t);const n=this;return Z(t).then(function(r){return!r||!r.length||e>=r.length?[]:!i&&!e?r:(r=r.slice(e,e+i),s?n.enrich(r):r)})},y.enrich=function(t){typeof t!="object"&&(t=[t]);const i=this.db.transaction("reg","readonly").objectStore("reg"),e=[];for(let s=0;s<t.length;s++)e[s]=Z(i.get(t[s]));return Promise.all(e).then(function(s){for(let n=0;n<s.length;n++)s[n]={id:t[n],doc:s[n]?JSON.parse(s[n]):null};return s})},y.has=function(t){return t=this.db.transaction("reg","readonly").objectStore("reg").getKey(t),Z(t).then(function(i){return!!i})},y.search=null,y.info=function(){},y.transaction=function(t,i,e){t+=t!=="reg"&&this.field?":"+this.field:"";let s=this.h[t+":"+i];if(s)return e.call(this,s);let n=this.db.transaction(t,i);this.h[t+":"+i]=s=n.objectStore(t);const r=e.call(this,s);return this.h[t+":"+i]=null,Z(n).finally(function(){return r})},y.commit=async function(t){let i=t.commit_task,e=[];t.commit_task=[];for(let s=0,n;s<i.length;s++)n=i[s],n.del&&e.push(n.del);e.length&&await this.remove(e),t.reg.size&&(await this.transaction("map","readwrite",function(s){for(const n of t.map){const r=n[0],h=n[1];h.length&&(s.get(r).onsuccess=function(){let o=this.result;var l;if(o&&o.length){const f=Math.max(o.length,h.length);for(let c=0,a,m;c<f;c++)if((m=h[c])&&m.length){if((a=o[c])&&a.length)for(l=0;l<m.length;l++)a.push(m[l]);else o[c]=m;l=1}}else o=h,l=1;l&&s.put(o,r)})}}),await this.transaction("ctx","readwrite",function(s){for(const n of t.ctx){const r=n[0],h=n[1];for(const o of h){const l=o[0],f=o[1];f.length&&(s.get(r+":"+l).onsuccess=function(){let c=this.result;var a;if(c&&c.length){const m=Math.max(c.length,f.length);for(let p=0,d,u;p<m;p++)if((u=f[p])&&u.length){if((d=c[p])&&d.length)for(a=0;a<u.length;a++)d.push(u[a]);else c[p]=u;a=1}}else c=f,a=1;a&&s.put(c,r+":"+l)})}}}),t.store?await this.transaction("reg","readwrite",function(s){for(const n of t.store){const r=n[0],h=n[1];s.put(typeof h=="object"?JSON.stringify(h):1,r)}}):t.bypass||await this.transaction("reg","readwrite",function(s){for(const n of t.reg.keys())s.put(1,n)}),t.tag&&await this.transaction("tag","readwrite",function(s){for(const n of t.tag){const r=n[0],h=n[1];h.length&&(s.get(r).onsuccess=function(){let o=this.result;o=o&&o.length?o.concat(h):h,s.put(o,r)})}}),t.map.clear(),t.ctx.clear(),t.tag&&t.tag.clear(),t.store&&t.store.clear(),t.document||t.reg.clear())};function Ot(t,i,e){const s=t.value;let n,r=0;for(let h=0,o;h<s.length;h++){if(o=e?s:s[h]){for(let l=0,f,c;l<i.length;l++)if(c=i[l],f=o.indexOf(c),f>=0)if(n=1,o.length>1)o.splice(f,1);else{s[h]=[];break}r+=o.length}if(e)break}r?n&&t.update(s):t.delete(),t.continue()}y.remove=function(t){return typeof t!="object"&&(t=[t]),Promise.all([this.transaction("map","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&Ot(e,t)}}),this.transaction("ctx","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&Ot(e,t)}}),this.transaction("tag","readwrite",function(i){i.openCursor().onsuccess=function(){const e=this.result;e&&Ot(e,t,!0)}}),this.transaction("reg","readwrite",function(i){for(let e=0;e<t.length;e++)i.delete(t[e])})])};function Z(t,i){return new Promise((e,s)=>{t.onsuccess=t.oncomplete=function(){i&&i(this.result),i=null,e(this.result)},t.onerror=t.onblocked=s,t=null})}const le=G;let Nt=new le;self.onmessage=t=>{switch(t.data.type){case"clear":Nt=new le,postMessage({identifier:t.data.identifier});break;case"points":for(let e of t.data.points)Nt.add(e.id,e.text);postMessage({identifier:t.data.identifier});break;case"query":let i=Nt.search(t.data.query,{limit:t.data.limit});postMessage({identifier:t.data.identifier,result:i});break}}})()})();
@@ -1 +1 @@
1
- {"version":"1756908241758"}
1
+ {"version":"1759479212790"}
@@ -5,35 +5,35 @@
5
5
  <link rel="icon" href="/favicon.png" />
6
6
  <meta name="viewport" content="width=device-width, initial-scale=1" />
7
7
 
8
- <link rel="modulepreload" href="/_app/immutable/entry/start.0o1H7wM9.js">
9
- <link rel="modulepreload" href="/_app/immutable/chunks/CxtLVaYz.js">
10
- <link rel="modulepreload" href="/_app/immutable/chunks/l7KrR96u.js">
8
+ <link rel="modulepreload" href="/_app/immutable/entry/start.u7zsVvqp.js">
9
+ <link rel="modulepreload" href="/_app/immutable/chunks/DEgUu98i.js">
10
+ <link rel="modulepreload" href="/_app/immutable/chunks/CH6P3X75.js">
11
11
  <link rel="modulepreload" href="/_app/immutable/chunks/DIeogL5L.js">
12
12
  <link rel="modulepreload" href="/_app/immutable/chunks/CYgJF_JY.js">
13
- <link rel="modulepreload" href="/_app/immutable/entry/app.CjnvpsmS.js">
14
- <link rel="modulepreload" href="/_app/immutable/chunks/D98V7j6A.js">
15
- <link rel="modulepreload" href="/_app/immutable/chunks/XO7A28GO.js">
16
- <link rel="modulepreload" href="/_app/immutable/chunks/DOlTMNyt.js">
13
+ <link rel="modulepreload" href="/_app/immutable/entry/app.BVr6DYqP.js">
14
+ <link rel="modulepreload" href="/_app/immutable/chunks/DQXoLcsF.js">
15
+ <link rel="modulepreload" href="/_app/immutable/chunks/DA6bFLPR.js">
16
+ <link rel="modulepreload" href="/_app/immutable/chunks/BfHVnyNT.js">
17
17
  <link rel="modulepreload" href="/_app/immutable/chunks/CWj6FrbW.js">
18
18
  <link rel="modulepreload" href="/_app/immutable/chunks/69_IOA4Y.js">
19
- <link rel="modulepreload" href="/_app/immutable/chunks/C8I8rFJQ.js">
20
- <link rel="modulepreload" href="/_app/immutable/chunks/D6RI2Zrd.js">
21
- <link rel="modulepreload" href="/_app/immutable/chunks/DjfY96ND.js">
22
- <link rel="modulepreload" href="/_app/immutable/chunks/Bu7uvVrG.js">
19
+ <link rel="modulepreload" href="/_app/immutable/chunks/Cs1XmhiF.js">
20
+ <link rel="modulepreload" href="/_app/immutable/chunks/DGTPl6Gk.js">
21
+ <link rel="modulepreload" href="/_app/immutable/chunks/D4whDBUi.js">
22
+ <link rel="modulepreload" href="/_app/immutable/chunks/RmD8FzRo.js">
23
23
  </head>
24
24
  <body data-sveltekit-preload-data="hover" class="flex h-screen w-screen flex-col dark:bg-black">
25
25
  <div style="display: contents">
26
26
  <script>
27
27
  {
28
- __sveltekit_vpwkcc = {
28
+ __sveltekit_1gqf9ui = {
29
29
  base: ""
30
30
  };
31
31
 
32
32
  const element = document.currentScript.parentElement;
33
33
 
34
34
  Promise.all([
35
- import("/_app/immutable/entry/start.0o1H7wM9.js"),
36
- import("/_app/immutable/entry/app.CjnvpsmS.js")
35
+ import("/_app/immutable/entry/start.u7zsVvqp.js"),
36
+ import("/_app/immutable/entry/app.BVr6DYqP.js")
37
37
  ]).then(([kit, app]) => {
38
38
  kit.start(app, element);
39
39
  });
@@ -1,23 +1,24 @@
1
- """Example of how to use the DatasetLoader class."""
1
+ """Example of how to load samples from path with the dataset class."""
2
+
3
+ from pathlib import Path
2
4
 
3
5
  from environs import Env
4
6
 
5
- from lightly_studio import DatasetLoader
7
+ import lightly_studio as ls
6
8
 
7
9
  # Read environment variables
8
10
  env = Env()
9
11
  env.read_env()
10
12
 
11
- # Create a DatasetLoader instance
12
- loader = DatasetLoader()
13
+ # Define the path to the dataset directory
14
+ dataset_path = Path(env.path("DATASET_PATH", "/path/to/your/dataset"))
15
+ dataset_path = dataset_path.parent if dataset_path.is_file() else dataset_path
13
16
 
14
- # Define the path to the dataset (folder containing data.yaml)
15
- dataset_path = env.path("DATASET_PATH", "/path/to/your/yolo/dataset/data.yaml")
17
+ # Create a DatasetLoader from a path
18
+ dataset = ls.Dataset.create()
19
+ dataset.add_samples_from_path(path=dataset_path)
16
20
 
17
- # Load YOLO dataset using data.yaml path
18
- loader.from_yolo(
19
- str(dataset_path),
20
- input_split=env.str("LIGHTLY_STUDIO_DATASET_SPLIT", "test"),
21
- )
21
+ for sample in dataset:
22
+ print(sample)
22
23
 
23
- loader.start_gui()
24
+ ls.start_gui()
@@ -0,0 +1,13 @@
1
+ """Example of how to add samples in coco format to a dataset."""
2
+
3
+ import lightly_studio as ls
4
+
5
+ # Create a DatasetLoader from a path
6
+ dataset = ls.Dataset.create()
7
+ dataset.add_samples_from_coco(
8
+ annotations_json="/path/to/your/dataset",
9
+ images_path="/path/to/your/dataset",
10
+ annotation_type=ls.AnnotationType.INSTANCE_SEGMENTATION,
11
+ )
12
+
13
+ ls.start_gui()
@@ -16,14 +16,11 @@ from uuid import UUID
16
16
  from environs import Env
17
17
  from sqlmodel import Session
18
18
 
19
- from lightly_studio import DatasetLoader
20
- from lightly_studio.api.db import db_manager
19
+ import lightly_studio as ls
20
+ from lightly_studio import db_manager
21
+ from lightly_studio.core.sample import Sample
21
22
  from lightly_studio.metadata.gps_coordinate import GPSCoordinate
22
- from lightly_studio.models.dataset import DatasetTable
23
- from lightly_studio.resolvers import (
24
- metadata_resolver,
25
- sample_resolver,
26
- )
23
+ from lightly_studio.resolvers import metadata_resolver
27
24
  from lightly_studio.resolvers.metadata_resolver.metadata_filter import Metadata
28
25
  from lightly_studio.resolvers.samples_filter import SampleFilter
29
26
 
@@ -34,25 +31,24 @@ dataset_path = env.path("DATASET_PATH", "/path/to/your/yolo/dataset/data.yaml")
34
31
  LIGHTLY_STUDIO_DATASET_SPLIT = env.str("LIGHTLY_STUDIO_DATASET_SPLIT", "test")
35
32
 
36
33
 
37
- def load_existing_dataset() -> tuple[DatasetTable, list[UUID], DatasetLoader]:
34
+ def load_existing_dataset() -> tuple[ls.Dataset, list[Sample]]:
38
35
  """Load an existing dataset using DatasetLoader.
39
36
 
40
37
  Returns:
41
- Tuple of (dataset, sample_ids, loader).
38
+ Tuple of (dataset, samples).
42
39
  """
43
40
  print(" Loading existing dataset...")
44
41
 
45
- loader = DatasetLoader()
46
- dataset = loader.from_yolo(
47
- str(dataset_path),
42
+ dataset = ls.Dataset.create()
43
+ dataset.add_samples_from_yolo(
44
+ data_yaml=str(dataset_path),
48
45
  input_split=LIGHTLY_STUDIO_DATASET_SPLIT,
49
46
  )
50
- # Get all sample IDs from the dataset
51
- samples = dataset.get_samples()
52
- sample_ids = [s.sample_id for s in samples]
47
+ # Get all samples from the dataset
48
+ samples = dataset.query().to_list()
53
49
 
54
- print(f"✅ Loaded dataset with {len(sample_ids)} samples")
55
- return dataset, sample_ids, loader
50
+ print(f"✅ Loaded dataset with {len(samples)} samples")
51
+ return dataset, samples
56
52
 
57
53
 
58
54
  def add_bulk_metadata(session: Session, sample_ids: list[UUID]) -> None:
@@ -93,56 +89,38 @@ def add_bulk_metadata(session: Session, sample_ids: list[UUID]) -> None:
93
89
  print(f"✅ Added metadata to {len(sample_ids)} samples in {elapsed_time:.2f}s")
94
90
 
95
91
 
96
- def add_individual_metadata(session: Session, sample_ids: list[UUID]) -> None:
92
+ def add_individual_metadata(samples: list[Sample]) -> None:
97
93
  """Add metadata to individual samples."""
98
94
  print("\n Adding individual metadata to specific samples...")
99
95
 
100
96
  # Add metadata to first 5 samples individually
101
- for i, sample_id in enumerate(sample_ids[:5]):
97
+ for i, sample in enumerate(samples[:5]):
98
+ print(f" Adding metadata to sample {sample.file_name} {sample.sample_id}...")
102
99
  # Add some specific metadata
103
- metadata_resolver.set_value_for_sample(
104
- session=session,
105
- sample_id=sample_id,
106
- key="special_metadata",
107
- value=f"sample_{i + 1}_special",
100
+ sample.metadata["special_metadata"] = f"sample_{i + 1}_special"
101
+ sample.metadata["priority"] = random.randint(1, 10)
102
+ sample.metadata["list"] = [1, 2, 3]
103
+ sample.metadata["custom_gps"] = GPSCoordinate(
104
+ lat=40.7128 + i * 0.1, # Slightly different coordinates
105
+ lon=-74.0060 + i * 0.1,
108
106
  )
109
107
 
110
- metadata_resolver.set_value_for_sample(
111
- session=session,
112
- sample_id=sample_id,
113
- key="priority",
114
- value=random.randint(1, 10),
115
- )
116
-
117
- metadata_resolver.set_value_for_sample(
118
- session=session,
119
- sample_id=sample_id,
120
- key="list",
121
- value=[1, 2, 3],
122
- )
123
-
124
- metadata_resolver.set_value_for_sample(
125
- session=session,
126
- sample_id=sample_id,
127
- key="custom_gps",
128
- value=GPSCoordinate(
129
- lat=40.7128 + i * 0.1, # Slightly different coordinates
130
- lon=-74.0060 + i * 0.1,
131
- ),
132
- )
108
+ print(f"✅ Added individual metadata to {min(5, len(samples))} samples")
133
109
 
134
- print(f"✅ Added individual metadata to {min(5, len(sample_ids))} samples")
135
110
 
136
-
137
- def demonstrate_bulk_metadata_filters(dataset: DatasetTable) -> None:
111
+ def demonstrate_bulk_metadata_filters(dataset: ls.Dataset) -> None:
138
112
  """Demonstrate filtering with bulk-added metadata."""
113
+ # TODO(Michal, 09/2025): Update with native metadata filtering instead of accessing
114
+ # `dataset._inner` when implemented.
115
+ dataset_table = dataset._inner # noqa: SLF001
116
+
139
117
  print("\n Bulk Metadata Filters:")
140
118
  print("=" * 50)
141
119
 
142
120
  # Filter by temperature
143
121
  print("\n1. Filter by temperature > 25:")
144
122
  filter_temp = SampleFilter(metadata_filters=[Metadata("temperature") > 25]) # noqa PLR2004
145
- samples = dataset.get_samples(filters=filter_temp)
123
+ samples = dataset_table.get_samples(filters=filter_temp)
146
124
  print(f" Found {len(samples)} samples with temperature > 25")
147
125
  for sample in samples[:3]: # Show first 3
148
126
  print(f" {sample.file_name}: {sample['temperature']}")
@@ -150,7 +128,7 @@ def demonstrate_bulk_metadata_filters(dataset: DatasetTable) -> None:
150
128
  # Filter by location
151
129
  print("\n2. Filter by location == 'city':")
152
130
  filter_location = SampleFilter(metadata_filters=[Metadata("location") == "city"])
153
- samples = dataset.get_samples(filters=filter_location)
131
+ samples = dataset_table.get_samples(filters=filter_location)
154
132
  print(f" Found {len(samples)} samples from cities")
155
133
  for sample in samples[:3]: # Show first 3
156
134
  print(f" {sample.file_name}: {sample['location']}")
@@ -158,7 +136,7 @@ def demonstrate_bulk_metadata_filters(dataset: DatasetTable) -> None:
158
136
  # Filter by GPS coordinates
159
137
  print("\n3. Filter by latitude > 0° (Northern hemisphere):")
160
138
  filter_lat = SampleFilter(metadata_filters=[Metadata("gps_coordinates.lat") > 0])
161
- samples = dataset.get_samples(filters=filter_lat)
139
+ samples = dataset_table.get_samples(filters=filter_lat)
162
140
  print(f" Found {len(samples)} samples in Northern hemisphere")
163
141
  for sample in samples[:3]: # Show first 3
164
142
  gps = sample["gps_coordinates"]
@@ -169,14 +147,18 @@ def demonstrate_bulk_metadata_filters(dataset: DatasetTable) -> None:
169
147
  filter_confidence = SampleFilter(
170
148
  metadata_filters=[Metadata("confidence") > 0.9] # noqa PLR2004
171
149
  )
172
- samples = dataset.get_samples(filters=filter_confidence)
150
+ samples = dataset_table.get_samples(filters=filter_confidence)
173
151
  print(f" Found {len(samples)} samples with confidence > 0.9")
174
152
  for sample in samples[:3]: # Show first 3
175
153
  print(f" 📸 {sample.file_name}: confidence={sample['confidence']:.3f}")
176
154
 
177
155
 
178
- def demonstrate_individual_metadata_filters(dataset: DatasetTable) -> None:
156
+ def demonstrate_individual_metadata_filters(dataset: ls.Dataset) -> None:
179
157
  """Demonstrate filtering with individually-added metadata."""
158
+ # TODO(Michal, 09/2025): Update with native metadata filtering instead of accessing
159
+ # `dataset._inner` when implemented.
160
+ dataset_table = dataset._inner # noqa: SLF001
161
+
180
162
  print("\n Individual Metadata Filters:")
181
163
  print("=" * 50)
182
164
 
@@ -185,7 +167,7 @@ def demonstrate_individual_metadata_filters(dataset: DatasetTable) -> None:
185
167
  filter_special = SampleFilter(
186
168
  metadata_filters=[Metadata("special_metadata") == "sample_1_special"]
187
169
  )
188
- samples = dataset.get_samples(filters=filter_special)
170
+ samples = dataset_table.get_samples(filters=filter_special)
189
171
  print(f" Found {len(samples)} samples with special metadata")
190
172
  for sample in samples:
191
173
  print(f" {sample.file_name}: {sample['special_metadata']}")
@@ -193,7 +175,7 @@ def demonstrate_individual_metadata_filters(dataset: DatasetTable) -> None:
193
175
  # Filter by priority
194
176
  print("\n2. Filter by high priority (> 7):")
195
177
  filter_priority = SampleFilter(metadata_filters=[Metadata("priority") > 7]) # noqa PLR2004
196
- samples = dataset.get_samples(filters=filter_priority)
178
+ samples = dataset_table.get_samples(filters=filter_priority)
197
179
  print(f" Found {len(samples)} samples with priority > 7")
198
180
  for sample in samples:
199
181
  print(f" {sample.file_name}: priority={sample['priority']}")
@@ -203,15 +185,19 @@ def demonstrate_individual_metadata_filters(dataset: DatasetTable) -> None:
203
185
  filter_custom_gps = SampleFilter(
204
186
  metadata_filters=[Metadata("custom_gps.lat") > 40.8] # noqa PLR2004
205
187
  )
206
- samples = dataset.get_samples(filters=filter_custom_gps)
188
+ samples = dataset_table.get_samples(filters=filter_custom_gps)
207
189
  print(f" Found {len(samples)} samples with custom GPS lat > 40.8")
208
190
  for sample in samples:
209
191
  gps = sample["custom_gps"]
210
192
  print(f" {sample.file_name}: lat={gps.lat:.4f}, lon={gps.lon:.4f}")
211
193
 
212
194
 
213
- def demonstrate_combined_filters(dataset: DatasetTable) -> None:
195
+ def demonstrate_combined_filters(dataset: ls.Dataset) -> None:
214
196
  """Demonstrate combining multiple filters."""
197
+ # TODO(Michal, 09/2025): Update with native metadata filtering instead of accessing
198
+ # `dataset._inner` when implemented.
199
+ dataset_table = dataset._inner # noqa: SLF001
200
+
215
201
  print("\n Combined Filters:")
216
202
  print("=" * 50)
217
203
 
@@ -224,7 +210,7 @@ def demonstrate_combined_filters(dataset: DatasetTable) -> None:
224
210
  Metadata("temperature") > 25, # noqa PLR2004
225
211
  ]
226
212
  )
227
- samples = dataset.get_samples(filters=filter_combined)
213
+ samples = dataset_table.get_samples(filters=filter_combined)
228
214
  print(f" Found {len(samples)} samples matching all criteria")
229
215
  for sample in samples[:3]:
230
216
  print(
@@ -241,64 +227,64 @@ def demonstrate_combined_filters(dataset: DatasetTable) -> None:
241
227
  Metadata("location") == "city",
242
228
  ]
243
229
  )
244
- samples = dataset.get_samples(filters=filter_gps_combined)
230
+ samples = dataset_table.get_samples(filters=filter_gps_combined)
245
231
  print(f" Found {len(samples)} samples in northern hemisphere cities with high confidence")
246
232
  for sample in samples[:3]:
247
233
  gps = sample["gps_coordinates"]
248
234
  print(f" {sample.file_name}: lat={gps.lat:.4f}, conf={sample['confidence']:.2f}")
249
235
 
250
236
 
251
- def demonstrate_dictionary_like_access(session: Session, sample_ids: list[UUID]) -> None:
237
+ def demonstrate_dictionary_like_access(samples: list[Sample]) -> None:
252
238
  """Demonstrate adding metadata using dictionary-like access."""
253
239
  print("\n Dictionary-like Metadata Access:")
254
240
  print("=" * 50)
255
241
 
256
242
  # Get the first few samples to demonstrate
257
- samples = sample_resolver.get_many_by_id(session, sample_ids[:2])
243
+ samples = samples[:2]
258
244
 
259
- print("\n1. Adding metadata using sample['key'] = value syntax:")
245
+ print("\n1. Adding metadata using sample.metadata['key'] = value syntax:")
260
246
 
261
247
  # Add different types of metadata to different samples
262
- samples[0]["temperature"] = 25
263
- samples[0]["location"] = "city"
264
- samples[0]["is_processed"] = True
265
- samples[0]["confidence"] = 0.95
248
+ samples[0].metadata["temperature"] = 25
249
+ samples[0].metadata["location"] = "city"
250
+ samples[0].metadata["is_processed"] = True
251
+ samples[0].metadata["confidence"] = 0.95
266
252
  print(
267
- f" {samples[0].file_name}: temp={samples[0]['temperature']}°C, "
268
- f"location={samples[0]['location']},"
269
- f" processed={samples[0]['is_processed']}"
253
+ f" {samples[0].file_name}: temp={samples[0].metadata['temperature']}°C, "
254
+ f"location={samples[0].metadata['location']},"
255
+ f" processed={samples[0].metadata['is_processed']}"
270
256
  )
271
257
 
272
- samples[1]["temperature"] = 15
273
- samples[1]["location"] = "mountain"
274
- samples[1]["gps_coordinates"] = GPSCoordinate(lat=40.7128, lon=-74.0060)
275
- samples[1]["tags"] = ["outdoor", "nature", "landscape"]
258
+ samples[1].metadata["temperature"] = 15
259
+ samples[1].metadata["location"] = "mountain"
260
+ samples[1].metadata["gps_coordinates"] = GPSCoordinate(lat=40.7128, lon=-74.0060)
261
+ samples[1].metadata["tags"] = ["outdoor", "nature", "landscape"]
276
262
  print(
277
- f" {samples[1].file_name}: temp={samples[1]['temperature']}°C, "
278
- f"location={samples[1]['location']}, tags={samples[1]['tags']}"
263
+ f" {samples[1].file_name}: temp={samples[1].metadata['temperature']}°C, "
264
+ f"location={samples[1].metadata['location']}, tags={samples[1].metadata['tags']}"
279
265
  )
280
266
 
281
267
  # Demonstrate reading metadata
282
- print("\n2. Reading metadata using sample['key'] syntax:")
268
+ print("\n2. Reading metadata using sample.metadata['key'] syntax:")
283
269
  for sample in samples:
284
270
  print(f" {sample.file_name}:")
285
- print(f" Temperature: {sample['temperature']}°C")
286
- print(f" Location: {sample['location']}")
287
- gps = sample["gps_coordinates"]
271
+ print(f" Temperature: {sample.metadata['temperature']}°C")
272
+ print(f" Location: {sample.metadata['location']}")
273
+ gps = sample.metadata["gps_coordinates"]
288
274
  print(f" GPS: lat={gps.lat:.4f}, lon={gps.lon:.4f}")
289
- print(f" Tags: {sample['tags']}")
275
+ print(f" Tags: {sample.metadata['tags']}")
290
276
 
291
277
  # Demonstrate None return for missing keys
292
- print(" Note: sample['key'] returns None for missing keys")
293
- missing_value = samples[0]["nonexistent_key"]
278
+ print(" Note: sample.metadata['key'] returns None for missing keys")
279
+ missing_value = samples[0].metadata["nonexistent_key"]
294
280
  if missing_value is None:
295
- print(f" sample['nonexistent_key']: {missing_value}")
281
+ print(f" sample.metadata['nonexistent_key']: {missing_value}")
296
282
 
297
283
  print(f"✅ Added metadata to {len(samples)} samples using dictionary-like access")
298
284
 
299
285
  # Demonstrate schema presentation
300
286
  try:
301
- samples[0]["temperature"] = "string_value" # Invalid type for demonstration
287
+ samples[0].metadata["temperature"] = "string_value" # Invalid type for demonstration
302
288
  print(f" ❌ This should not print: {missing_value}")
303
289
  except ValueError:
304
290
  print(" ✅ Correctly raised ValueError for invalid type")
@@ -308,22 +294,21 @@ def main() -> None:
308
294
  """Main function to demonstrate metadata functionality."""
309
295
  try:
310
296
  # Load existing dataset
311
- dataset, sample_ids, loader = load_existing_dataset()
297
+ dataset, samples = load_existing_dataset()
312
298
 
313
- with db_manager.session() as session:
314
- # Add bulk metadata
315
- add_bulk_metadata(session, sample_ids)
299
+ # Add bulk metadata
300
+ add_bulk_metadata(db_manager.persistent_session(), [s.sample_id for s in samples])
316
301
 
317
- # Add individual metadata
318
- add_individual_metadata(session, sample_ids)
302
+ # Add individual metadata
303
+ add_individual_metadata(samples)
319
304
 
320
- # Demonstrate different types of filtering
321
- demonstrate_bulk_metadata_filters(dataset)
322
- demonstrate_individual_metadata_filters(dataset)
323
- demonstrate_combined_filters(dataset)
324
- demonstrate_dictionary_like_access(session, sample_ids)
305
+ # Demonstrate different types of filtering
306
+ demonstrate_bulk_metadata_filters(dataset)
307
+ demonstrate_individual_metadata_filters(dataset)
308
+ demonstrate_combined_filters(dataset)
309
+ demonstrate_dictionary_like_access(samples)
325
310
 
326
- loader.start_gui()
311
+ ls.start_gui()
327
312
 
328
313
  except ValueError as e:
329
314
  print(f"❌ Error: {e}")
@@ -4,8 +4,7 @@ from pathlib import Path
4
4
 
5
5
  from environs import Env
6
6
 
7
- from lightly_studio import DatasetLoader
8
- from lightly_studio.selection.select import Selection
7
+ import lightly_studio as ls
9
8
 
10
9
  # Read environment variables
11
10
  env = Env()
@@ -15,25 +14,14 @@ env.read_env()
15
14
  dataset_path = Path(env.path("DATASET_PATH", "/path/to/your/dataset"))
16
15
  dataset_path = dataset_path.parent if dataset_path.is_file() else dataset_path
17
16
 
18
- # Create a DatasetLoader from a path
19
- loader = DatasetLoader()
20
- dataset = loader.from_directory(
21
- dataset_name="clothing_small_test",
22
- img_dir=str(dataset_path),
23
- )
24
-
25
- # Create the selection interface
26
- # TODO(Malte, 08/2025): Replace this with using a DatasetView.
27
- # See the Select class for more details on the TODO.
28
- select = Selection(
29
- dataset_id=dataset.dataset_id,
30
- session=loader.session,
31
- )
17
+ # Create a Dataset from a path
18
+ dataset = ls.Dataset.create()
19
+ dataset.add_samples_from_path(path=str(dataset_path))
32
20
 
33
- # Select a diverse subset of 10 samples.
34
- select.diverse(
21
+ # Run selection via the dataset query
22
+ dataset.query().selection().diverse(
35
23
  n_samples_to_select=10,
36
24
  selection_result_tag_name="diverse_selection",
37
25
  )
38
26
 
39
- loader.start_gui()
27
+ ls.start_gui()