@iebh/tera-fy 1.13.4 → 1.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,7 +4,6 @@ TERA website worker, intended to be embedded with TERA tools.
4
4
 
5
5
  * [TERA-fy API (API explorer)](https://iebh.github.io/TERA-fy/)
6
6
  * [TERA-fy API (Markdown, single page)](./api.md)
7
- * [API playground](https://iebh.github.io/TERA-fy/playground.html)
8
7
  * [TERA-Explorer](https://github.com/IEBH/TERA-explorer) - A simple example project using TERA-fy
9
8
  - [Live standalone version](https://explorer.tera-tools.com/)
10
9
  - [Live Embedded version](https://tera-tools.com/explorer)
package/api.md CHANGED
@@ -77,53 +77,53 @@
77
77
  * [Parameters][73]
78
78
  * [selectProjectFile][74]
79
79
  * [Parameters][75]
80
- * [getProjectFiles][76]
81
- * [Parameters][77]
82
- * [getProjectFile][78]
83
- * [Parameters][79]
84
- * [createProjectFile][80]
85
- * [Parameters][81]
86
- * [handshake][82]
87
- * [Properties][83]
88
- * [setServerVerbosity][84]
89
- * [Parameters][85]
90
- * [User][86]
91
- * [Properties][87]
92
- * [getUser][88]
93
- * [requireUser][89]
94
- * [Parameters][90]
95
- * [Project][91]
96
- * [getProject][92]
97
- * [getProjects][93]
98
- * [setActiveProject][94]
80
+ * [handshake][76]
81
+ * [Properties][77]
82
+ * [setServerVerbosity][78]
83
+ * [Parameters][79]
84
+ * [User][80]
85
+ * [Properties][81]
86
+ * [getUser][82]
87
+ * [requireUser][83]
88
+ * [Parameters][84]
89
+ * [Project][85]
90
+ * [getProject][86]
91
+ * [getProjects][87]
92
+ * [setActiveProject][88]
93
+ * [Parameters][89]
94
+ * [requireProject][90]
95
+ * [Parameters][91]
96
+ * [selectProject][92]
97
+ * [Parameters][93]
98
+ * [getProjectState][94]
99
99
  * [Parameters][95]
100
- * [requireProject][96]
100
+ * [setProjectState][96]
101
101
  * [Parameters][97]
102
- * [selectProject][98]
102
+ * [setProjectStateDefaults][98]
103
103
  * [Parameters][99]
104
- * [getProjectState][100]
105
- * [Parameters][101]
106
- * [setProjectState][102]
107
- * [Parameters][103]
108
- * [setProjectStateDefaults][104]
109
- * [Parameters][105]
110
- * [setProjectStateFlush][106]
111
- * [setProjectStateRefresh][107]
112
- * [saveProjectState][108]
113
- * [replaceProjectState][109]
114
- * [Parameters][110]
115
- * [applyProjectStatePatch][111]
116
- * [Parameters][112]
117
- * [subscribeProjectState][113]
118
- * [FileFilters][114]
119
- * [Properties][115]
120
- * [selectProjectFile][116]
104
+ * [setProjectStateFlush][100]
105
+ * [setProjectStateRefresh][101]
106
+ * [saveProjectState][102]
107
+ * [replaceProjectState][103]
108
+ * [Parameters][104]
109
+ * [applyProjectStatePatch][105]
110
+ * [Parameters][106]
111
+ * [subscribeProjectState][107]
112
+ * [FileFilters][108]
113
+ * [Properties][109]
114
+ * [selectProjectFile][110]
115
+ * [Parameters][111]
116
+ * [getProjectFiles][112]
117
+ * [Parameters][113]
118
+ * [getProjectFileContents][114]
119
+ * [Parameters][115]
120
+ * [getProjectFile][116]
121
121
  * [Parameters][117]
122
- * [getProjectFileContents][118]
122
+ * [createProjectFile][118]
123
123
  * [Parameters][119]
124
124
  * [deleteProjectFile][120]
125
125
  * [Parameters][121]
126
- * [setProjectFile][122]
126
+ * [setProjectFileContents][122]
127
127
  * [Parameters][123]
128
128
  * [selectProjectLibrary][124]
129
129
  * [Parameters][125]
@@ -280,7 +280,7 @@ Returns **[Blob][152]** The eventual raw file contents as a Blob
280
280
 
281
281
  ### setContents
282
282
 
283
- * **See**: setProjectFile()
283
+ * **See**: setProjectFileContents()
284
284
 
285
285
  Overwrite the contents of a file with new content
286
286
 
@@ -599,45 +599,6 @@ This is an pre-requisite step for requireProject()
599
599
 
600
600
  Returns **[Promise][155]** A promise which will resolve if the there is a user and they are logged in
601
601
 
602
- ### getProjectFiles
603
-
604
- Fetch the files associated with a given project
605
-
606
- #### Parameters
607
-
608
- * `options` **[Object][149]** Options which mutate behaviour
609
-
610
- * `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
611
- * `options.lazy` **[Boolean][157]** If true, use the fastest method to retrieve the file list such as the cache. If false, force a refresh each time (optional, default `true`)
612
- * `options.meta` **[Boolean][157]** Pull meta information for each file entity (optional, default `true`)
613
-
614
- Returns **[Promise][155]<[Array][154]<[ProjectFile][1]>>** A collection of project files for the given project
615
-
616
- ### getProjectFile
617
-
618
- Fetch a project file by its name
619
-
620
- #### Parameters
621
-
622
- * `id` **[String][148]** The name + relative directory path component
623
- * `options` **([Object][149] | [String][148])?** Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
624
-
625
- * `options.subkey` **[String][148]?** If specified only the extracted subkey is returned rather than the full object
626
- * `options.cache` **[Boolean][157]** Use the existing file cache if possible, set to false to force a refresh of files from the server first (optional, default `true`)
627
-
628
- Returns **[Promise][155]<[ProjectFile][1]>** The eventual fetched ProjectFile (or requested subkey)
629
-
630
- ### createProjectFile
631
-
632
- Create a new file
633
- This creates an empty file which can then be written to
634
-
635
- #### Parameters
636
-
637
- * `name` **[String][148]** The name + relative directory path component
638
-
639
- Returns **[Promise][155]<[ProjectFile][1]>** The eventual ProjectFile created
640
-
641
602
  ## handshake
642
603
 
643
604
  Return basic server information as a form of validation
@@ -671,7 +632,7 @@ User / active session within TERA
671
632
 
672
633
  Fetch the current session user
673
634
 
674
- Returns **[Promise][155]<[User][86]>** The current logged in user or null if none
635
+ Returns **[Promise][155]<[User][80]>** The current logged in user or null if none
675
636
 
676
637
  ## requireUser
677
638
 
@@ -685,7 +646,7 @@ This is an pre-requisite step for requireProject()
685
646
 
686
647
  * `options.forceRetry` **[Boolean][157]** Forcabily try to refresh the user state (optional, default `false`)
687
648
 
688
- Returns **[Promise][155]<[User][86]>** The current logged in user or null if none
649
+ Returns **[Promise][155]<[User][80]>** The current logged in user or null if none
689
650
 
690
651
  ## Project
691
652
 
@@ -695,13 +656,13 @@ Project entry within TERA
695
656
 
696
657
  Get the currently active project, if any
697
658
 
698
- Returns **[Promise][155]<([Project][91] | null)>** The currently active project, if any
659
+ Returns **[Promise][155]<([Project][85] | null)>** The currently active project, if any
699
660
 
700
661
  ## getProjects
701
662
 
702
663
  Get a list of projects the current session user has access to
703
664
 
704
- Returns **[Promise][155]<[Array][154]<[Project][91]>>** Collection of projects the user has access to
665
+ Returns **[Promise][155]<[Array][154]<[Project][85]>>** Collection of projects the user has access to
705
666
 
706
667
  ## setActiveProject
707
668
 
@@ -725,7 +686,7 @@ Note that this function will percist in asking the uesr even if they try to canc
725
686
  * `options.noSelectTitle` **[String][148]** Dialog title when warning the user they need to select something (optional, default `'Select project'`)
726
687
  * `options.noSelectBody` **[String][148]** Dialog body when warning the user they need to select something (optional, default `'A project needs to be selected to continue'`)
727
688
 
728
- Returns **[Promise][155]<[Project][91]>** The active project
689
+ Returns **[Promise][155]<[Project][85]>** The active project
729
690
 
730
691
  ## selectProject
731
692
 
@@ -739,7 +700,7 @@ Prompt the user to select a project from those available
739
700
  * `options.allowCancel` **[Boolean][157]** Advertise cancelling the operation, the dialog can still be cancelled by closing it (optional, default `true`)
740
701
  * `options.setActive` **[Boolean][157]** Also set the project as active when selected (optional, default `false`)
741
702
 
742
- Returns **[Promise][155]<[Project][91]>** The active project
703
+ Returns **[Promise][155]<[Project][85]>** The active project
743
704
 
744
705
  ## getProjectState
745
706
 
@@ -859,16 +820,30 @@ Prompt the user to select a library to operate on
859
820
  * `options.title` **[String][148]** The title of the dialog to display (optional, default `"Select a file"`)
860
821
  * `options.hint` **([String][148] | [Array][154]<[String][148]>)?** Hints to identify the file to select in array order of preference
861
822
  * `options.save` **[Boolean][157]** Set to truthy if saving a new file, UI will adjust to allowing overwrite OR new file name input (optional, default `false`)
862
- * `options.filters` **[FileFilters][114]?** Optional file filters
823
+ * `options.filters` **[FileFilters][108]?** Optional file filters
863
824
  * `options.allowUpload` **[Boolean][157]** Allow uploading new files (optional, default `true`)
864
825
  * `options.allowRefresh` **[Boolean][157]** Allow the user to manually refresh the file list (optional, default `true`)
865
826
  * `options.allowDownloadZip` **[Boolean][157]** Allow the user to download a Zip of all files (optional, default `true`)
866
827
  * `options.allowCancel` **[Boolean][157]** Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed (optional, default `true`)
867
828
  * `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
868
- * `options.filter` **[FileFilters][114]?** Optional file filters
829
+ * `options.filter` **[FileFilters][108]?** Optional file filters
869
830
 
870
831
  Returns **[Promise][155]<[ProjectFile][1]>** The eventually selected file, if in save mode new files are created as stubs
871
832
 
833
+ ## getProjectFiles
834
+
835
+ Fetch the files associated with a given project
836
+
837
+ ### Parameters
838
+
839
+ * `options` **[Object][149]** Options which mutate behaviour
840
+
841
+ * `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
842
+ * `options.lazy` **[Boolean][157]** If true, use the fastest method to retrieve the file list such as the cache. If false, force a refresh each time (optional, default `true`)
843
+ * `options.meta` **[Boolean][157]** Pull meta information for each file entity (optional, default `true`)
844
+
845
+ Returns **[Promise][155]<[Array][154]<[ProjectFile][1]>>** A collection of project files for the given project
846
+
872
847
  ## getProjectFileContents
873
848
 
874
849
  Fetch the raw contents of a file by its ID
@@ -882,6 +857,31 @@ Fetch the raw contents of a file by its ID
882
857
 
883
858
  Returns **any** The file contents in the requested format
884
859
 
860
+ ## getProjectFile
861
+
862
+ Fetch a project file by its name
863
+
864
+ ### Parameters
865
+
866
+ * `id` **[String][148]** The name + relative directory path component
867
+ * `options` **([Object][149] | [String][148])?** Additional options to mutate behaviour, if a string is given `options.subkey` is assumed
868
+
869
+ * `options.subkey` **[String][148]?** If specified only the extracted subkey is returned rather than the full object
870
+ * `options.cache` **[Boolean][157]** Use the existing file cache if possible, set to false to force a refresh of files from the server first (optional, default `true`)
871
+
872
+ Returns **[Promise][155]<[ProjectFile][1]>** The eventual fetched ProjectFile (or requested subkey)
873
+
874
+ ## createProjectFile
875
+
876
+ Create a new file
877
+ This creates an empty file which can then be written to
878
+
879
+ ### Parameters
880
+
881
+ * `name` **[String][148]** The name + relative directory path component
882
+
883
+ Returns **[Promise][155]<[ProjectFile][1]>** The eventual ProjectFile created
884
+
885
885
  ## deleteProjectFile
886
886
 
887
887
  Remove a project file by its ID
@@ -892,7 +892,7 @@ Remove a project file by its ID
892
892
 
893
893
  Returns **[Promise][155]** A promise which resolves when the operation has completed
894
894
 
895
- ## setProjectFile
895
+ ## setProjectFileContents
896
896
 
897
897
  Replace a project files contents
898
898
 
@@ -918,7 +918,7 @@ Prompt the user to select a library to operate on and return a array of referenc
918
918
  * `options.allowDownloadZip` **[Boolean][157]** Allow the user to download a Zip of all files (optional, default `true`)
919
919
  * `options.allowCancel` **[Boolean][157]** Allow cancelling the operation. Will throw `'CANCEL'` as the promise rejection if acationed (optional, default `true`)
920
920
  * `options.autoRequire` **[Boolean][157]** Run `requireProject()` automatically before continuing (optional, default `true`)
921
- * `options.filters` **[FileFilters][114]?** Optional file filters, defaults to citation library selection only
921
+ * `options.filters` **[FileFilters][108]?** Optional file filters, defaults to citation library selection only
922
922
  * `options` **...any?** Additional options - see `getProjectLibrary()`
923
923
 
924
924
  Returns **[Promise][155]<[Array][154]\<Ref>>** A collection of references from the selected file
@@ -1241,91 +1241,91 @@ This function is ideally called within a requestFocus() wrapper
1241
1241
 
1242
1242
  [75]: #parameters-19
1243
1243
 
1244
- [76]: #getprojectfiles
1244
+ [76]: #handshake
1245
1245
 
1246
- [77]: #parameters-20
1246
+ [77]: #properties-4
1247
1247
 
1248
- [78]: #getprojectfile
1248
+ [78]: #setserververbosity
1249
1249
 
1250
- [79]: #parameters-21
1250
+ [79]: #parameters-20
1251
1251
 
1252
- [80]: #createprojectfile
1252
+ [80]: #user
1253
1253
 
1254
- [81]: #parameters-22
1254
+ [81]: #properties-5
1255
1255
 
1256
- [82]: #handshake
1256
+ [82]: #getuser
1257
1257
 
1258
- [83]: #properties-4
1258
+ [83]: #requireuser
1259
1259
 
1260
- [84]: #setserververbosity
1260
+ [84]: #parameters-21
1261
1261
 
1262
- [85]: #parameters-23
1262
+ [85]: #project
1263
1263
 
1264
- [86]: #user
1264
+ [86]: #getproject
1265
1265
 
1266
- [87]: #properties-5
1266
+ [87]: #getprojects
1267
1267
 
1268
- [88]: #getuser
1268
+ [88]: #setactiveproject
1269
1269
 
1270
- [89]: #requireuser
1270
+ [89]: #parameters-22
1271
1271
 
1272
- [90]: #parameters-24
1272
+ [90]: #requireproject
1273
1273
 
1274
- [91]: #project
1274
+ [91]: #parameters-23
1275
1275
 
1276
- [92]: #getproject
1276
+ [92]: #selectproject
1277
1277
 
1278
- [93]: #getprojects
1278
+ [93]: #parameters-24
1279
1279
 
1280
- [94]: #setactiveproject
1280
+ [94]: #getprojectstate
1281
1281
 
1282
1282
  [95]: #parameters-25
1283
1283
 
1284
- [96]: #requireproject
1284
+ [96]: #setprojectstate
1285
1285
 
1286
1286
  [97]: #parameters-26
1287
1287
 
1288
- [98]: #selectproject
1288
+ [98]: #setprojectstatedefaults
1289
1289
 
1290
1290
  [99]: #parameters-27
1291
1291
 
1292
- [100]: #getprojectstate
1292
+ [100]: #setprojectstateflush
1293
1293
 
1294
- [101]: #parameters-28
1294
+ [101]: #setprojectstaterefresh
1295
1295
 
1296
- [102]: #setprojectstate
1296
+ [102]: #saveprojectstate
1297
1297
 
1298
- [103]: #parameters-29
1298
+ [103]: #replaceprojectstate
1299
1299
 
1300
- [104]: #setprojectstatedefaults
1300
+ [104]: #parameters-28
1301
1301
 
1302
- [105]: #parameters-30
1302
+ [105]: #applyprojectstatepatch
1303
1303
 
1304
- [106]: #setprojectstateflush
1304
+ [106]: #parameters-29
1305
1305
 
1306
- [107]: #setprojectstaterefresh
1306
+ [107]: #subscribeprojectstate
1307
1307
 
1308
- [108]: #saveprojectstate
1308
+ [108]: #filefilters
1309
1309
 
1310
- [109]: #replaceprojectstate
1310
+ [109]: #properties-6
1311
1311
 
1312
- [110]: #parameters-31
1312
+ [110]: #selectprojectfile-1
1313
1313
 
1314
- [111]: #applyprojectstatepatch
1314
+ [111]: #parameters-30
1315
1315
 
1316
- [112]: #parameters-32
1316
+ [112]: #getprojectfiles
1317
1317
 
1318
- [113]: #subscribeprojectstate
1318
+ [113]: #parameters-31
1319
1319
 
1320
- [114]: #filefilters
1320
+ [114]: #getprojectfilecontents
1321
1321
 
1322
- [115]: #properties-6
1322
+ [115]: #parameters-32
1323
1323
 
1324
- [116]: #selectprojectfile-1
1324
+ [116]: #getprojectfile
1325
1325
 
1326
1326
  [117]: #parameters-33
1327
1327
 
1328
- [118]: #getprojectfilecontents
1328
+ [118]: #createprojectfile
1329
1329
 
1330
1330
  [119]: #parameters-34
1331
1331
 
@@ -1333,7 +1333,7 @@ This function is ideally called within a requestFocus() wrapper
1333
1333
 
1334
1334
  [121]: #parameters-35
1335
1335
 
1336
- [122]: #setprojectfile
1336
+ [122]: #setprojectfilecontents
1337
1337
 
1338
1338
  [123]: #parameters-36
1339
1339
 
@@ -1,4 +1,4 @@
1
- var Io=Object.defineProperty;var _o=(t,e,r)=>e in t?Io(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var c=(t,e,r)=>_o(t,typeof e!="symbol"?e+"":e,r);function ne(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:f,basePath:u,basePathForRemoves:p,diffs:g}){var P=Object.keys(i),T=P.length,b=Object.keys(f),F=b.length,O,l=i.length-f.length;if(Fo(i,f)){for(var d=0;d<T;d++){var m=Array.isArray(i)?Number(P[d]):P[d];m in f||(O=p.concat(m),g.remove.push({op:"remove",path:r(O)}))}for(var d=0;d<F;d++){var m=Array.isArray(f)?Number(b[d]):b[d];n({key:m,obj1:i,obj2:f,path:u.concat(m),pathForRemoves:u.concat(m),diffs:g})}}else{for(var d=0;d<l;d++)O=p.concat(d),g.remove.push({op:"remove",path:r(O)});for(var C=i.slice(l),d=0;d<F;d++)n({key:d,obj1:C,obj2:f,path:u.concat(d),pathForRemoves:u.concat(d+l),diffs:g})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function n({key:i,obj1:f,obj2:u,path:p,pathForRemoves:g,diffs:P}){var T=f[i],b=u[i];if(!(i in f)&&i in u){var F=b;P.add.push({op:"add",path:r(p),value:F})}else T!==b&&(Object(T)!==T||Object(b)!==b||Eo(T,b)||!Object.keys(T).length&&!Object.keys(b).length&&String(T)!=String(b)?s(p,P,b):o({obj1:f[i],obj2:u[i],basePath:p,basePathForRemoves:g,diffs:P}))}function s(i,f,u){f.replace.push({op:"replace",path:r(i),value:u})}}function Eo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Fo(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,n=0;n<e.length&&String(t[n])===String(e[n]);n++)o++;for(var s=e.length;s>0&&String(t[s+r])===String(e[s]);s--)a++;return o>=a}return!0}var Co=typeof global=="object"&&global&&global.Object===Object&&global,wt=Co;var Mo=typeof self=="object"&&self&&self.Object===Object&&self,Ro=wt||Mo||Function("return this")(),y=Ro;var No=y.Symbol,j=No;var se=Object.prototype,Lo=se.hasOwnProperty,Bo=se.toString,ht=j?j.toStringTag:void 0;function Do(t){var e=Lo.call(t,ht),r=t[ht];try{t[ht]=void 0;var o=!0}catch{}var a=Bo.call(t);return o&&(e?t[ht]=r:delete t[ht]),a}var fe=Do;var Uo=Object.prototype,ko=Uo.toString;function Go(t){return ko.call(t)}var pe=Go;var Ko="[object Null]",zo="[object Undefined]",le=j?j.toStringTag:void 0;function Wo(t){return t==null?t===void 0?zo:Ko:le&&le in Object(t)?fe(t):pe(t)}var I=Wo;function $o(t){return t!=null&&typeof t=="object"}var A=$o;var Ho="[object Symbol]";function Vo(t){return typeof t=="symbol"||A(t)&&I(t)==Ho}var V=Vo;function qo(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var me=qo;var Yo=Array.isArray,v=Yo;var Zo=1/0,ue=j?j.prototype:void 0,de=ue?ue.toString:void 0;function ce(t){if(typeof t=="string")return t;if(v(t))return me(t,ce)+"";if(V(t))return de?de.call(t):"";var e=t+"";return e=="0"&&1/t==-Zo?"-0":e}var he=ce;function Jo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var w=Jo;function Xo(t){return t}var Tt=Xo;var Qo="[object AsyncFunction]",ta="[object Function]",ea="[object GeneratorFunction]",ra="[object Proxy]";function oa(t){if(!w(t))return!1;var e=I(t);return e==ta||e==ea||e==Qo||e==ra}var q=oa;var aa=y["__core-js_shared__"],Ot=aa;var xe=function(){var t=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ia(t){return!!xe&&xe in t}var ge=ia;var na=Function.prototype,sa=na.toString;function fa(t){if(t!=null){try{return sa.call(t)}catch{}try{return t+""}catch{}}return""}var M=fa;var pa=/[\\^$.*+?()[\]{}|]/g,la=/^\[object .+?Constructor\]$/,ma=Function.prototype,ua=Object.prototype,da=ma.toString,ca=ua.hasOwnProperty,ha=RegExp("^"+da.call(ca).replace(pa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function xa(t){if(!w(t)||ge(t))return!1;var e=q(t)?ha:la;return e.test(M(t))}var be=xa;function ga(t,e){return t==null?void 0:t[e]}var ye=ga;function ba(t,e){var r=ye(t,e);return be(r)?r:void 0}var S=ba;var ya=S(y,"WeakMap"),Pt=ya;var ve=Object.create,va=function(){function t(){}return function(e){if(!w(e))return{};if(ve)return ve(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),we=va;function wa(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var Te=wa;function Ta(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var At=Ta;var Oa=800,Pa=16,Aa=Date.now;function ja(t){var e=0,r=0;return function(){var o=Aa(),a=Pa-(o-r);if(r=o,a>0){if(++e>=Oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Oe=ja;function Sa(t){return function(){return t}}var Pe=Sa;var Ia=function(){try{var t=S(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Y=Ia;var _a=Y?function(t,e){return Y(t,"toString",{configurable:!0,enumerable:!1,value:Pe(e),writable:!0})}:Tt,Ae=_a;var Ea=Oe(Ae),jt=Ea;function Fa(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var je=Fa;var Ca=9007199254740991,Ma=/^(?:0|[1-9]\d*)$/;function Ra(t,e){var r=typeof t;return e=e==null?Ca:e,!!e&&(r=="number"||r!="symbol"&&Ma.test(t))&&t>-1&&t%1==0&&t<e}var B=Ra;function Na(t,e,r){e=="__proto__"&&Y?Y(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Z=Na;function La(t,e){return t===e||t!==t&&e!==e}var D=La;var Ba=Object.prototype,Da=Ba.hasOwnProperty;function Ua(t,e,r){var o=t[e];(!(Da.call(t,e)&&D(o,r))||r===void 0&&!(e in t))&&Z(t,e,r)}var J=Ua;function ka(t,e,r,o){var a=!r;r||(r={});for(var n=-1,s=e.length;++n<s;){var i=e[n],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?Z(r,i,f):J(r,i,f)}return r}var _=ka;var Se=Math.max;function Ga(t,e,r){return e=Se(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,n=Se(o.length-e,0),s=Array(n);++a<n;)s[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(s),Te(t,this,i)}}var St=Ga;function Ka(t,e){return jt(St(t,e,Tt),t+"")}var Ie=Ka;var za=9007199254740991;function Wa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=za}var X=Wa;function $a(t){return t!=null&&X(t.length)&&!q(t)}var U=$a;function Ha(t,e,r){if(!w(r))return!1;var o=typeof e;return(o=="number"?U(r)&&B(e,r.length):o=="string"&&e in r)?D(r[e],t):!1}var _e=Ha;function Va(t){return Ie(function(e,r){var o=-1,a=r.length,n=a>1?r[a-1]:void 0,s=a>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(a--,n):void 0,s&&_e(r[0],r[1],s)&&(n=a<3?void 0:n,a=1),e=Object(e);++o<a;){var i=r[o];i&&t(e,i,o,n)}return e})}var Ee=Va;var qa=Object.prototype;function Ya(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||qa;return t===r}var Q=Ya;function Za(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Fe=Za;var Ja="[object Arguments]";function Xa(t){return A(t)&&I(t)==Ja}var Wt=Xa;var Ce=Object.prototype,Qa=Ce.hasOwnProperty,ti=Ce.propertyIsEnumerable,ei=Wt(function(){return arguments}())?Wt:function(t){return A(t)&&Qa.call(t,"callee")&&!ti.call(t,"callee")},R=ei;function ri(){return!1}var Me=ri;var Le=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Re=Le&&typeof module=="object"&&module&&!module.nodeType&&module,oi=Re&&Re.exports===Le,Ne=oi?y.Buffer:void 0,ai=Ne?Ne.isBuffer:void 0,ii=ai||Me,tt=ii;var ni="[object Arguments]",si="[object Array]",fi="[object Boolean]",pi="[object Date]",li="[object Error]",mi="[object Function]",ui="[object Map]",di="[object Number]",ci="[object Object]",hi="[object RegExp]",xi="[object Set]",gi="[object String]",bi="[object WeakMap]",yi="[object ArrayBuffer]",vi="[object DataView]",wi="[object Float32Array]",Ti="[object Float64Array]",Oi="[object Int8Array]",Pi="[object Int16Array]",Ai="[object Int32Array]",ji="[object Uint8Array]",Si="[object Uint8ClampedArray]",Ii="[object Uint16Array]",_i="[object Uint32Array]",x={};x[wi]=x[Ti]=x[Oi]=x[Pi]=x[Ai]=x[ji]=x[Si]=x[Ii]=x[_i]=!0;x[ni]=x[si]=x[yi]=x[fi]=x[vi]=x[pi]=x[li]=x[mi]=x[ui]=x[di]=x[ci]=x[hi]=x[xi]=x[gi]=x[bi]=!1;function Ei(t){return A(t)&&X(t.length)&&!!x[I(t)]}var Be=Ei;function Fi(t){return function(e){return t(e)}}var et=Fi;var De=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xt=De&&typeof module=="object"&&module&&!module.nodeType&&module,Ci=xt&&xt.exports===De,$t=Ci&&wt.process,Mi=function(){try{var t=xt&&xt.require&&xt.require("util").types;return t||$t&&$t.binding&&$t.binding("util")}catch{}}(),N=Mi;var Ue=N&&N.isTypedArray,Ri=Ue?et(Ue):Be,It=Ri;var Ni=Object.prototype,Li=Ni.hasOwnProperty;function Bi(t,e){var r=v(t),o=!r&&R(t),a=!r&&!o&&tt(t),n=!r&&!o&&!a&&It(t),s=r||o||a||n,i=s?Fe(t.length,String):[],f=i.length;for(var u in t)(e||Li.call(t,u))&&!(s&&(u=="length"||a&&(u=="offset"||u=="parent")||n&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||B(u,f)))&&i.push(u);return i}var _t=Bi;function Di(t,e){return function(r){return t(e(r))}}var Et=Di;var Ui=Et(Object.keys,Object),ke=Ui;var ki=Object.prototype,Gi=ki.hasOwnProperty;function Ki(t){if(!Q(t))return ke(t);var e=[];for(var r in Object(t))Gi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ge=Ki;function zi(t){return U(t)?_t(t):Ge(t)}var rt=zi;function Wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ke=Wi;var $i=Object.prototype,Hi=$i.hasOwnProperty;function Vi(t){if(!w(t))return Ke(t);var e=Q(t),r=[];for(var o in t)o=="constructor"&&(e||!Hi.call(t,o))||r.push(o);return r}var ze=Vi;function qi(t){return U(t)?_t(t,!0):ze(t)}var E=qi;var Yi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zi=/^\w*$/;function Ji(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||V(t)?!0:Zi.test(t)||!Yi.test(t)||e!=null&&t in Object(e)}var We=Ji;var Xi=S(Object,"create"),L=Xi;function Qi(){this.__data__=L?L(null):{},this.size=0}var $e=Qi;function tn(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var He=tn;var en="__lodash_hash_undefined__",rn=Object.prototype,on=rn.hasOwnProperty;function an(t){var e=this.__data__;if(L){var r=e[t];return r===en?void 0:r}return on.call(e,t)?e[t]:void 0}var Ve=an;var nn=Object.prototype,sn=nn.hasOwnProperty;function fn(t){var e=this.__data__;return L?e[t]!==void 0:sn.call(e,t)}var qe=fn;var pn="__lodash_hash_undefined__";function ln(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=L&&e===void 0?pn:e,this}var Ye=ln;function ot(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}ot.prototype.clear=$e;ot.prototype.delete=He;ot.prototype.get=Ve;ot.prototype.has=qe;ot.prototype.set=Ye;var Ht=ot;function mn(){this.__data__=[],this.size=0}var Ze=mn;function un(t,e){for(var r=t.length;r--;)if(D(t[r][0],e))return r;return-1}var k=un;var dn=Array.prototype,cn=dn.splice;function hn(t){var e=this.__data__,r=k(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():cn.call(e,r,1),--this.size,!0}var Je=hn;function xn(t){var e=this.__data__,r=k(e,t);return r<0?void 0:e[r][1]}var Xe=xn;function gn(t){return k(this.__data__,t)>-1}var Qe=gn;function bn(t,e){var r=this.__data__,o=k(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var tr=bn;function at(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}at.prototype.clear=Ze;at.prototype.delete=Je;at.prototype.get=Xe;at.prototype.has=Qe;at.prototype.set=tr;var G=at;var yn=S(y,"Map"),K=yn;function vn(){this.size=0,this.__data__={hash:new Ht,map:new(K||G),string:new Ht}}var er=vn;function wn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var rr=wn;function Tn(t,e){var r=t.__data__;return rr(e)?r[typeof e=="string"?"string":"hash"]:r.map}var z=Tn;function On(t){var e=z(this,t).delete(t);return this.size-=e?1:0,e}var or=On;function Pn(t){return z(this,t).get(t)}var ar=Pn;function An(t){return z(this,t).has(t)}var ir=An;function jn(t,e){var r=z(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var nr=jn;function it(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}it.prototype.clear=er;it.prototype.delete=or;it.prototype.get=ar;it.prototype.has=ir;it.prototype.set=nr;var gt=it;var Sn="Expected a function";function Vt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Sn);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],n=r.cache;if(n.has(a))return n.get(a);var s=t.apply(this,o);return r.cache=n.set(a,s)||n,s};return r.cache=new(Vt.Cache||gt),r}Vt.Cache=gt;var sr=Vt;var In=500;function _n(t){var e=sr(t,function(o){return r.size===In&&r.clear(),o}),r=e.cache;return e}var fr=_n;var En=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Fn=/\\(\\)?/g,Cn=fr(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(En,function(r,o,a,n){e.push(a?n.replace(Fn,"$1"):o||r)}),e}),pr=Cn;function Mn(t){return t==null?"":he(t)}var lr=Mn;function Rn(t,e){return v(t)?t:We(t,e)?[t]:pr(lr(t))}var W=Rn;var Nn=1/0;function Ln(t){if(typeof t=="string"||V(t))return t;var e=t+"";return e=="0"&&1/t==-Nn?"-0":e}var nt=Ln;function Bn(t,e){e=W(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[nt(e[r++])];return r&&r==o?t:void 0}var mr=Bn;function Dn(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var st=Dn;var ur=j?j.isConcatSpreadable:void 0;function Un(t){return v(t)||R(t)||!!(ur&&t&&t[ur])}var dr=Un;function cr(t,e,r,o,a){var n=-1,s=t.length;for(r||(r=dr),a||(a=[]);++n<s;){var i=t[n];e>0&&r(i)?e>1?cr(i,e-1,r,o,a):st(a,i):o||(a[a.length]=i)}return a}var hr=cr;function kn(t){var e=t==null?0:t.length;return e?hr(t,1):[]}var xr=kn;function Gn(t){return jt(St(t,void 0,xr),t+"")}var gr=Gn;var Kn=Et(Object.getPrototypeOf,Object),ft=Kn;var zn="[object Object]",Wn=Function.prototype,$n=Object.prototype,br=Wn.toString,Hn=$n.hasOwnProperty,Vn=br.call(Object);function qn(t){if(!A(t)||I(t)!=zn)return!1;var e=ft(t);if(e===null)return!0;var r=Hn.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&br.call(r)==Vn}var yr=qn;function Yn(){this.__data__=new G,this.size=0}var vr=Yn;function Zn(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var wr=Zn;function Jn(t){return this.__data__.get(t)}var Tr=Jn;function Xn(t){return this.__data__.has(t)}var Or=Xn;var Qn=200;function ts(t,e){var r=this.__data__;if(r instanceof G){var o=r.__data__;if(!K||o.length<Qn-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new gt(o)}return r.set(t,e),this.size=r.size,this}var Pr=ts;function pt(t){var e=this.__data__=new G(t);this.size=e.size}pt.prototype.clear=vr;pt.prototype.delete=wr;pt.prototype.get=Tr;pt.prototype.has=Or;pt.prototype.set=Pr;var Ft=pt;function es(t,e){return t&&_(e,rt(e),t)}var Ar=es;function rs(t,e){return t&&_(e,E(e),t)}var jr=rs;var Er=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sr=Er&&typeof module=="object"&&module&&!module.nodeType&&module,os=Sr&&Sr.exports===Er,Ir=os?y.Buffer:void 0,_r=Ir?Ir.allocUnsafe:void 0;function as(t,e){if(e)return t.slice();var r=t.length,o=_r?_r(r):new t.constructor(r);return t.copy(o),o}var Ct=as;function is(t,e){for(var r=-1,o=t==null?0:t.length,a=0,n=[];++r<o;){var s=t[r];e(s,r,t)&&(n[a++]=s)}return n}var Fr=is;function ns(){return[]}var Mt=ns;var ss=Object.prototype,fs=ss.propertyIsEnumerable,Cr=Object.getOwnPropertySymbols,ps=Cr?function(t){return t==null?[]:(t=Object(t),Fr(Cr(t),function(e){return fs.call(t,e)}))}:Mt,lt=ps;function ls(t,e){return _(t,lt(t),e)}var Mr=ls;var ms=Object.getOwnPropertySymbols,us=ms?function(t){for(var e=[];t;)st(e,lt(t)),t=ft(t);return e}:Mt,Rt=us;function ds(t,e){return _(t,Rt(t),e)}var Rr=ds;function cs(t,e,r){var o=e(t);return v(t)?o:st(o,r(t))}var Nt=cs;function hs(t){return Nt(t,rt,lt)}var Nr=hs;function xs(t){return Nt(t,E,Rt)}var Lr=xs;var gs=S(y,"DataView"),Lt=gs;var bs=S(y,"Promise"),Bt=bs;var ys=S(y,"Set"),Dt=ys;var Br="[object Map]",vs="[object Object]",Dr="[object Promise]",Ur="[object Set]",kr="[object WeakMap]",Gr="[object DataView]",ws=M(Lt),Ts=M(K),Os=M(Bt),Ps=M(Dt),As=M(Pt),H=I;(Lt&&H(new Lt(new ArrayBuffer(1)))!=Gr||K&&H(new K)!=Br||Bt&&H(Bt.resolve())!=Dr||Dt&&H(new Dt)!=Ur||Pt&&H(new Pt)!=kr)&&(H=function(t){var e=I(t),r=e==vs?t.constructor:void 0,o=r?M(r):"";if(o)switch(o){case ws:return Gr;case Ts:return Br;case Os:return Dr;case Ps:return Ur;case As:return kr}return e});var mt=H;var js=Object.prototype,Ss=js.hasOwnProperty;function Is(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Ss.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Kr=Is;var _s=y.Uint8Array,qt=_s;function Es(t){var e=new t.constructor(t.byteLength);return new qt(e).set(new qt(t)),e}var ut=Es;function Fs(t,e){var r=e?ut(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var zr=Fs;var Cs=/\w*$/;function Ms(t){var e=new t.constructor(t.source,Cs.exec(t));return e.lastIndex=t.lastIndex,e}var Wr=Ms;var $r=j?j.prototype:void 0,Hr=$r?$r.valueOf:void 0;function Rs(t){return Hr?Object(Hr.call(t)):{}}var Vr=Rs;function Ns(t,e){var r=e?ut(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Ut=Ns;var Ls="[object Boolean]",Bs="[object Date]",Ds="[object Map]",Us="[object Number]",ks="[object RegExp]",Gs="[object Set]",Ks="[object String]",zs="[object Symbol]",Ws="[object ArrayBuffer]",$s="[object DataView]",Hs="[object Float32Array]",Vs="[object Float64Array]",qs="[object Int8Array]",Ys="[object Int16Array]",Zs="[object Int32Array]",Js="[object Uint8Array]",Xs="[object Uint8ClampedArray]",Qs="[object Uint16Array]",tf="[object Uint32Array]";function ef(t,e,r){var o=t.constructor;switch(e){case Ws:return ut(t);case Ls:case Bs:return new o(+t);case $s:return zr(t,r);case Hs:case Vs:case qs:case Ys:case Zs:case Js:case Xs:case Qs:case tf:return Ut(t,r);case Ds:return new o;case Us:case Ks:return new o(t);case ks:return Wr(t);case Gs:return new o;case zs:return Vr(t)}}var qr=ef;function rf(t){return typeof t.constructor=="function"&&!Q(t)?we(ft(t)):{}}var kt=rf;var of="[object Map]";function af(t){return A(t)&&mt(t)==of}var Yr=af;var Zr=N&&N.isMap,nf=Zr?et(Zr):Yr,Jr=nf;var sf="[object Set]";function ff(t){return A(t)&&mt(t)==sf}var Xr=ff;var Qr=N&&N.isSet,pf=Qr?et(Qr):Xr,to=pf;var lf=1,mf=2,uf=4,eo="[object Arguments]",df="[object Array]",cf="[object Boolean]",hf="[object Date]",xf="[object Error]",ro="[object Function]",gf="[object GeneratorFunction]",bf="[object Map]",yf="[object Number]",oo="[object Object]",vf="[object RegExp]",wf="[object Set]",Tf="[object String]",Of="[object Symbol]",Pf="[object WeakMap]",Af="[object ArrayBuffer]",jf="[object DataView]",Sf="[object Float32Array]",If="[object Float64Array]",_f="[object Int8Array]",Ef="[object Int16Array]",Ff="[object Int32Array]",Cf="[object Uint8Array]",Mf="[object Uint8ClampedArray]",Rf="[object Uint16Array]",Nf="[object Uint32Array]",h={};h[eo]=h[df]=h[Af]=h[jf]=h[cf]=h[hf]=h[Sf]=h[If]=h[_f]=h[Ef]=h[Ff]=h[bf]=h[yf]=h[oo]=h[vf]=h[wf]=h[Tf]=h[Of]=h[Cf]=h[Mf]=h[Rf]=h[Nf]=!0;h[xf]=h[ro]=h[Pf]=!1;function Gt(t,e,r,o,a,n){var s,i=e&lf,f=e&mf,u=e&uf;if(r&&(s=a?r(t,o,a,n):r(t)),s!==void 0)return s;if(!w(t))return t;var p=v(t);if(p){if(s=Kr(t),!i)return At(t,s)}else{var g=mt(t),P=g==ro||g==gf;if(tt(t))return Ct(t,i);if(g==oo||g==eo||P&&!a){if(s=f||P?{}:kt(t),!i)return f?Rr(t,jr(s,t)):Mr(t,Ar(s,t))}else{if(!h[g])return a?t:{};s=qr(t,g,i)}}n||(n=new Ft);var T=n.get(t);if(T)return T;n.set(t,s),to(t)?t.forEach(function(O){s.add(Gt(O,e,r,O,t,n))}):Jr(t)&&t.forEach(function(O,l){s.set(l,Gt(O,e,r,l,t,n))});var b=u?f?Lr:Nr:f?E:rt,F=p?void 0:b(t);return je(F||t,function(O,l){F&&(l=O,O=t[l]),J(s,l,Gt(O,e,r,l,t,n))}),s}var ao=Gt;var Lf=1,Bf=4;function Df(t){return ao(t,Lf|Bf)}var Yt=Df;function Uf(t,e){return t!=null&&e in Object(t)}var io=Uf;function kf(t,e,r){e=W(e,t);for(var o=-1,a=e.length,n=!1;++o<a;){var s=nt(e[o]);if(!(n=t!=null&&r(t,s)))break;t=t[s]}return n||++o!=a?n:(a=t==null?0:t.length,!!a&&X(a)&&B(s,a)&&(v(t)||R(t)))}var no=kf;function Gf(t,e){return t!=null&&no(t,e,io)}var so=Gf;function Kf(t){return function(e,r,o){for(var a=-1,n=Object(e),s=o(e),i=s.length;i--;){var f=s[t?i:++a];if(r(n[f],f,n)===!1)break}return e}}var fo=Kf;var zf=fo(),po=zf;function Wf(t,e,r){(r!==void 0&&!D(t[e],r)||r===void 0&&!(e in t))&&Z(t,e,r)}var bt=Wf;function $f(t){return A(t)&&U(t)}var lo=$f;function Hf(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var yt=Hf;function Vf(t){return _(t,E(t))}var mo=Vf;function qf(t,e,r,o,a,n,s){var i=yt(t,r),f=yt(e,r),u=s.get(f);if(u){bt(t,r,u);return}var p=n?n(i,f,r+"",t,e,s):void 0,g=p===void 0;if(g){var P=v(f),T=!P&&tt(f),b=!P&&!T&&It(f);p=f,P||T||b?v(i)?p=i:lo(i)?p=At(i):T?(g=!1,p=Ct(f,!0)):b?(g=!1,p=Ut(f,!0)):p=[]:yr(f)||R(f)?(p=i,R(i)?p=mo(i):(!w(i)||q(i))&&(p=kt(f))):g=!1}g&&(s.set(f,p),a(p,f,o,n,s),s.delete(f)),bt(t,r,p)}var uo=qf;function co(t,e,r,o,a){t!==e&&po(e,function(n,s){if(a||(a=new Ft),w(n))uo(t,e,s,r,co,o,a);else{var i=o?o(yt(t,s),n,s+"",t,e,a):void 0;i===void 0&&(i=n),bt(t,s,i)}},E)}var ho=co;var Yf=Ee(function(t,e,r){ho(t,e,r)}),Zt=Yf;function Zf(t,e,r,o){if(!w(t))return t;e=W(e,t);for(var a=-1,n=e.length,s=n-1,i=t;i!=null&&++a<n;){var f=nt(e[a]),u=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=s){var p=i[f];u=o?o(p,f,i):void 0,u===void 0&&(u=w(p)?p:B(e[a+1])?[]:{})}J(i,f,u),i=i[f]}return t}var xo=Zf;function Jf(t,e,r){for(var o=-1,a=e.length,n={};++o<a;){var s=e[o],i=mr(t,s);r(i,s)&&xo(n,W(s,t),i)}return n}var go=Jf;function Xf(t,e){return go(t,e,function(r,o){return so(t,o)})}var bo=Xf;var Qf=gr(function(t,e){return t==null?{}:bo(t,e)}),Kt=Qf;function yo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var vo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Jt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=vo[r[t]&63];return e};var tp="array",ep="bit",wo="bits",rp="byte",To="bytes",dt="",op="exponent",ap="function",Oo="iec",ip="Invalid number",np="Invalid rounding method",Xt="jedec",sp="object",Po=".",fp="round",pp="s",lp="si",mp="kbit",up="kB",dp=" ",cp="string",hp="0",Qt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Ao(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:n=dt,localeOptions:s={},separator:i=dt,spacer:f=dp,symbols:u={},standard:p=dt,output:g=cp,fullform:P=!1,fullforms:T=[],exponent:b=-1,roundingMethod:F=fp,precision:O=0}={}){let l=b,d=Number(t),m=[],C=0,zt=dt;p===lp?(o=10,p=Xt):p===Oo||p===Xt?o=2:o===2?p=Oo:(o=10,p=Xt);let vt=o===10?1e3:1024,jo=P===!0,ee=d<0,re=Math[F];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(ip);if(typeof re!==ap)throw new TypeError(np);if(ee&&(d=-d),(l===-1||isNaN(l))&&(l=Math.floor(Math.log(d)/Math.log(vt)),l<0&&(l=0)),l>8&&(O>0&&(O+=8-l),l=8),g===op)return l;if(d===0)m[0]=0,zt=m[1]=Qt.symbol[p][e?wo:To][l];else{C=d/(o===2?Math.pow(2,l*10):Math.pow(1e3,l)),e&&(C=C*8,C>=vt&&l<8&&(C=C/vt,l++));let ct=Math.pow(10,l>0?a:0);m[0]=re(C*ct)/ct,m[0]===vt&&l<8&&b===-1&&(m[0]=1,l++),zt=m[1]=o===10&&l===1?e?mp:up:Qt.symbol[p][e?wo:To][l]}if(ee&&(m[0]=-m[0]),O>0&&(m[0]=m[0].toPrecision(O)),m[1]=u[m[1]]||m[1],n===!0?m[0]=m[0].toLocaleString():n.length>0?m[0]=m[0].toLocaleString(n,s):i.length>0&&(m[0]=m[0].toString().replace(Po,i)),r&&Number.isInteger(m[0])===!1&&a>0){let ct=i||Po,oe=m[0].toString().split(ct),ae=oe[1]||dt,ie=ae.length,So=a-ie;m[0]=`${oe[0]}${ct}${ae.padEnd(ie+So,hp)}`}return jo&&(m[1]=T[l]?T[l]:Qt.fullform[p][l]+(e?ep:rp)+(m[0]===1?dt:pp)),g===tp?m:g===sp?{value:m[0],symbol:m[1],exponent:l,unit:zt}:m.join(f)}var $=class t{constructor(e){c(this,"_tera");c(this,"id");c(this,"name");c(this,"icon");c(this,"path");c(this,"url");c(this,"teraUrl");c(this,"parsedName");c(this,"created");c(this,"createdFormatted");c(this,"modified");c(this,"modifiedFormatted");c(this,"accessed");c(this,"accessedFormatted");c(this,"size");c(this,"sizeFormatted");c(this,"mime");c(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=Ao(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFile(this.id,e)}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Kt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Kt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var te=class{constructor(e){c(this,"settings",{devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child:{siteUrl:"https://dev.tera-tools.com/embed",restrictOrigin:"*"}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"https://tera-tools.com",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null});c(this,"events",yo());c(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});c(this,"methods",["handshake","setServerVerbosity","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","getProjectFileContents","deleteProjectFile","setProjectFile","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiProgress","uiPrompt","uiTrhow","uiSplat","uiWindow"]);c(this,"plugins",[]);c(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Jt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Jt(),...Yt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);else{if((r==null?void 0:r.action)=="rpc")return Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})});if((r==null?void 0:r.action)=="event")return Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o});r!=null&&r.id?this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=ne(r,e);return this.debug("INFO",3,"Created project patch",{patch:o,newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatch(e){if(this.settings.devMode&&this.settings.debugPaths){if(!Array.isArray(this.settings.debugPaths))throw new Error("teraFyClient.settings.debugPaths should be either null or an Array<String>");let r=e.filter(o=>this.settings.debugPaths.some(a=>o.path.join(".").slice(0,a.length)==a)).map(o=>o.path.join("."));if(r.length>0){console.info("Detected writes to",r,"- entering debugging mode");debugger}}return this.rpc("applyProjectStatePatch",e)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.debug("INFO",4,"[0/6] Init",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/6] Setting client mode to",o),Zt(this.settings,{mode:o,...this.settings.modeOverrides[o]})}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).catch(o=>this.debug("WARN",0,"Init process fault",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":this.debug("INFO",2,"Using TERA window parent");break;case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let n=0,s,i=setTimeout(()=>{clearTimeout(s),a("TIMEOUT")},r.handshakeTimeout),f=()=>{this.debug("INFO",4,"Trying handshake",++n),clearTimeout(s),s=setTimeout(f,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(i),clearTimeout(s)}).then(()=>o()).catch(a)};f()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
1
+ var Io=Object.defineProperty;var _o=(t,e,r)=>e in t?Io(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var c=(t,e,r)=>_o(t,typeof e!="symbol"?e+"":e,r);function ne(t,e,r){if(!t||typeof t!="object"||!e||typeof e!="object")throw new Error("both arguments must be objects or arrays");r||(r=function(i){return i});function o({obj1:i,obj2:f,basePath:u,basePathForRemoves:p,diffs:g}){var P=Object.keys(i),T=P.length,b=Object.keys(f),C=b.length,O,l=i.length-f.length;if(Co(i,f)){for(var d=0;d<T;d++){var m=Array.isArray(i)?Number(P[d]):P[d];m in f||(O=p.concat(m),g.remove.push({op:"remove",path:r(O)}))}for(var d=0;d<C;d++){var m=Array.isArray(f)?Number(b[d]):b[d];n({key:m,obj1:i,obj2:f,path:u.concat(m),pathForRemoves:u.concat(m),diffs:g})}}else{for(var d=0;d<l;d++)O=p.concat(d),g.remove.push({op:"remove",path:r(O)});for(var F=i.slice(l),d=0;d<C;d++)n({key:d,obj1:F,obj2:f,path:u.concat(d),pathForRemoves:u.concat(d+l),diffs:g})}}var a={remove:[],replace:[],add:[]};return o({obj1:t,obj2:e,basePath:[],basePathForRemoves:[],diffs:a}),a.remove.reverse().concat(a.replace).concat(a.add);function n({key:i,obj1:f,obj2:u,path:p,pathForRemoves:g,diffs:P}){var T=f[i],b=u[i];if(!(i in f)&&i in u){var C=b;P.add.push({op:"add",path:r(p),value:C})}else T!==b&&(Object(T)!==T||Object(b)!==b||Eo(T,b)||!Object.keys(T).length&&!Object.keys(b).length&&String(T)!=String(b)?s(p,P,b):o({obj1:f[i],obj2:u[i],basePath:p,basePathForRemoves:g,diffs:P}))}function s(i,f,u){f.replace.push({op:"replace",path:r(i),value:u})}}function Eo(t,e){return Object.prototype.toString.call(t)!=Object.prototype.toString.call(e)}function Co(t,e){var r=t.length-e.length;if(Array.isArray(t)&&Array.isArray(e)&&r>0){for(var o=0,a=0,n=0;n<e.length&&String(t[n])===String(e[n]);n++)o++;for(var s=e.length;s>0&&String(t[s+r])===String(e[s]);s--)a++;return o>=a}return!0}var Fo=typeof global=="object"&&global&&global.Object===Object&&global,wt=Fo;var Mo=typeof self=="object"&&self&&self.Object===Object&&self,Ro=wt||Mo||Function("return this")(),y=Ro;var No=y.Symbol,j=No;var se=Object.prototype,Lo=se.hasOwnProperty,Bo=se.toString,ht=j?j.toStringTag:void 0;function Do(t){var e=Lo.call(t,ht),r=t[ht];try{t[ht]=void 0;var o=!0}catch{}var a=Bo.call(t);return o&&(e?t[ht]=r:delete t[ht]),a}var fe=Do;var Uo=Object.prototype,ko=Uo.toString;function Go(t){return ko.call(t)}var pe=Go;var Ko="[object Null]",zo="[object Undefined]",le=j?j.toStringTag:void 0;function Wo(t){return t==null?t===void 0?zo:Ko:le&&le in Object(t)?fe(t):pe(t)}var I=Wo;function $o(t){return t!=null&&typeof t=="object"}var A=$o;var Ho="[object Symbol]";function Vo(t){return typeof t=="symbol"||A(t)&&I(t)==Ho}var V=Vo;function qo(t,e){for(var r=-1,o=t==null?0:t.length,a=Array(o);++r<o;)a[r]=e(t[r],r,t);return a}var me=qo;var Yo=Array.isArray,v=Yo;var Zo=1/0,ue=j?j.prototype:void 0,de=ue?ue.toString:void 0;function ce(t){if(typeof t=="string")return t;if(v(t))return me(t,ce)+"";if(V(t))return de?de.call(t):"";var e=t+"";return e=="0"&&1/t==-Zo?"-0":e}var he=ce;function Jo(t){var e=typeof t;return t!=null&&(e=="object"||e=="function")}var w=Jo;function Xo(t){return t}var Tt=Xo;var Qo="[object AsyncFunction]",ta="[object Function]",ea="[object GeneratorFunction]",ra="[object Proxy]";function oa(t){if(!w(t))return!1;var e=I(t);return e==ta||e==ea||e==Qo||e==ra}var q=oa;var aa=y["__core-js_shared__"],Ot=aa;var xe=function(){var t=/[^.]+$/.exec(Ot&&Ot.keys&&Ot.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}();function ia(t){return!!xe&&xe in t}var ge=ia;var na=Function.prototype,sa=na.toString;function fa(t){if(t!=null){try{return sa.call(t)}catch{}try{return t+""}catch{}}return""}var M=fa;var pa=/[\\^$.*+?()[\]{}|]/g,la=/^\[object .+?Constructor\]$/,ma=Function.prototype,ua=Object.prototype,da=ma.toString,ca=ua.hasOwnProperty,ha=RegExp("^"+da.call(ca).replace(pa,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function xa(t){if(!w(t)||ge(t))return!1;var e=q(t)?ha:la;return e.test(M(t))}var be=xa;function ga(t,e){return t==null?void 0:t[e]}var ye=ga;function ba(t,e){var r=ye(t,e);return be(r)?r:void 0}var S=ba;var ya=S(y,"WeakMap"),Pt=ya;var ve=Object.create,va=function(){function t(){}return function(e){if(!w(e))return{};if(ve)return ve(e);t.prototype=e;var r=new t;return t.prototype=void 0,r}}(),we=va;function wa(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}var Te=wa;function Ta(t,e){var r=-1,o=t.length;for(e||(e=Array(o));++r<o;)e[r]=t[r];return e}var At=Ta;var Oa=800,Pa=16,Aa=Date.now;function ja(t){var e=0,r=0;return function(){var o=Aa(),a=Pa-(o-r);if(r=o,a>0){if(++e>=Oa)return arguments[0]}else e=0;return t.apply(void 0,arguments)}}var Oe=ja;function Sa(t){return function(){return t}}var Pe=Sa;var Ia=function(){try{var t=S(Object,"defineProperty");return t({},"",{}),t}catch{}}(),Y=Ia;var _a=Y?function(t,e){return Y(t,"toString",{configurable:!0,enumerable:!1,value:Pe(e),writable:!0})}:Tt,Ae=_a;var Ea=Oe(Ae),jt=Ea;function Ca(t,e){for(var r=-1,o=t==null?0:t.length;++r<o&&e(t[r],r,t)!==!1;);return t}var je=Ca;var Fa=9007199254740991,Ma=/^(?:0|[1-9]\d*)$/;function Ra(t,e){var r=typeof t;return e=e==null?Fa:e,!!e&&(r=="number"||r!="symbol"&&Ma.test(t))&&t>-1&&t%1==0&&t<e}var B=Ra;function Na(t,e,r){e=="__proto__"&&Y?Y(t,e,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[e]=r}var Z=Na;function La(t,e){return t===e||t!==t&&e!==e}var D=La;var Ba=Object.prototype,Da=Ba.hasOwnProperty;function Ua(t,e,r){var o=t[e];(!(Da.call(t,e)&&D(o,r))||r===void 0&&!(e in t))&&Z(t,e,r)}var J=Ua;function ka(t,e,r,o){var a=!r;r||(r={});for(var n=-1,s=e.length;++n<s;){var i=e[n],f=o?o(r[i],t[i],i,r,t):void 0;f===void 0&&(f=t[i]),a?Z(r,i,f):J(r,i,f)}return r}var _=ka;var Se=Math.max;function Ga(t,e,r){return e=Se(e===void 0?t.length-1:e,0),function(){for(var o=arguments,a=-1,n=Se(o.length-e,0),s=Array(n);++a<n;)s[a]=o[e+a];a=-1;for(var i=Array(e+1);++a<e;)i[a]=o[a];return i[e]=r(s),Te(t,this,i)}}var St=Ga;function Ka(t,e){return jt(St(t,e,Tt),t+"")}var Ie=Ka;var za=9007199254740991;function Wa(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=za}var X=Wa;function $a(t){return t!=null&&X(t.length)&&!q(t)}var U=$a;function Ha(t,e,r){if(!w(r))return!1;var o=typeof e;return(o=="number"?U(r)&&B(e,r.length):o=="string"&&e in r)?D(r[e],t):!1}var _e=Ha;function Va(t){return Ie(function(e,r){var o=-1,a=r.length,n=a>1?r[a-1]:void 0,s=a>2?r[2]:void 0;for(n=t.length>3&&typeof n=="function"?(a--,n):void 0,s&&_e(r[0],r[1],s)&&(n=a<3?void 0:n,a=1),e=Object(e);++o<a;){var i=r[o];i&&t(e,i,o,n)}return e})}var Ee=Va;var qa=Object.prototype;function Ya(t){var e=t&&t.constructor,r=typeof e=="function"&&e.prototype||qa;return t===r}var Q=Ya;function Za(t,e){for(var r=-1,o=Array(t);++r<t;)o[r]=e(r);return o}var Ce=Za;var Ja="[object Arguments]";function Xa(t){return A(t)&&I(t)==Ja}var Wt=Xa;var Fe=Object.prototype,Qa=Fe.hasOwnProperty,ti=Fe.propertyIsEnumerable,ei=Wt(function(){return arguments}())?Wt:function(t){return A(t)&&Qa.call(t,"callee")&&!ti.call(t,"callee")},R=ei;function ri(){return!1}var Me=ri;var Le=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Re=Le&&typeof module=="object"&&module&&!module.nodeType&&module,oi=Re&&Re.exports===Le,Ne=oi?y.Buffer:void 0,ai=Ne?Ne.isBuffer:void 0,ii=ai||Me,tt=ii;var ni="[object Arguments]",si="[object Array]",fi="[object Boolean]",pi="[object Date]",li="[object Error]",mi="[object Function]",ui="[object Map]",di="[object Number]",ci="[object Object]",hi="[object RegExp]",xi="[object Set]",gi="[object String]",bi="[object WeakMap]",yi="[object ArrayBuffer]",vi="[object DataView]",wi="[object Float32Array]",Ti="[object Float64Array]",Oi="[object Int8Array]",Pi="[object Int16Array]",Ai="[object Int32Array]",ji="[object Uint8Array]",Si="[object Uint8ClampedArray]",Ii="[object Uint16Array]",_i="[object Uint32Array]",x={};x[wi]=x[Ti]=x[Oi]=x[Pi]=x[Ai]=x[ji]=x[Si]=x[Ii]=x[_i]=!0;x[ni]=x[si]=x[yi]=x[fi]=x[vi]=x[pi]=x[li]=x[mi]=x[ui]=x[di]=x[ci]=x[hi]=x[xi]=x[gi]=x[bi]=!1;function Ei(t){return A(t)&&X(t.length)&&!!x[I(t)]}var Be=Ei;function Ci(t){return function(e){return t(e)}}var et=Ci;var De=typeof exports=="object"&&exports&&!exports.nodeType&&exports,xt=De&&typeof module=="object"&&module&&!module.nodeType&&module,Fi=xt&&xt.exports===De,$t=Fi&&wt.process,Mi=function(){try{var t=xt&&xt.require&&xt.require("util").types;return t||$t&&$t.binding&&$t.binding("util")}catch{}}(),N=Mi;var Ue=N&&N.isTypedArray,Ri=Ue?et(Ue):Be,It=Ri;var Ni=Object.prototype,Li=Ni.hasOwnProperty;function Bi(t,e){var r=v(t),o=!r&&R(t),a=!r&&!o&&tt(t),n=!r&&!o&&!a&&It(t),s=r||o||a||n,i=s?Ce(t.length,String):[],f=i.length;for(var u in t)(e||Li.call(t,u))&&!(s&&(u=="length"||a&&(u=="offset"||u=="parent")||n&&(u=="buffer"||u=="byteLength"||u=="byteOffset")||B(u,f)))&&i.push(u);return i}var _t=Bi;function Di(t,e){return function(r){return t(e(r))}}var Et=Di;var Ui=Et(Object.keys,Object),ke=Ui;var ki=Object.prototype,Gi=ki.hasOwnProperty;function Ki(t){if(!Q(t))return ke(t);var e=[];for(var r in Object(t))Gi.call(t,r)&&r!="constructor"&&e.push(r);return e}var Ge=Ki;function zi(t){return U(t)?_t(t):Ge(t)}var rt=zi;function Wi(t){var e=[];if(t!=null)for(var r in Object(t))e.push(r);return e}var Ke=Wi;var $i=Object.prototype,Hi=$i.hasOwnProperty;function Vi(t){if(!w(t))return Ke(t);var e=Q(t),r=[];for(var o in t)o=="constructor"&&(e||!Hi.call(t,o))||r.push(o);return r}var ze=Vi;function qi(t){return U(t)?_t(t,!0):ze(t)}var E=qi;var Yi=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Zi=/^\w*$/;function Ji(t,e){if(v(t))return!1;var r=typeof t;return r=="number"||r=="symbol"||r=="boolean"||t==null||V(t)?!0:Zi.test(t)||!Yi.test(t)||e!=null&&t in Object(e)}var We=Ji;var Xi=S(Object,"create"),L=Xi;function Qi(){this.__data__=L?L(null):{},this.size=0}var $e=Qi;function tn(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e}var He=tn;var en="__lodash_hash_undefined__",rn=Object.prototype,on=rn.hasOwnProperty;function an(t){var e=this.__data__;if(L){var r=e[t];return r===en?void 0:r}return on.call(e,t)?e[t]:void 0}var Ve=an;var nn=Object.prototype,sn=nn.hasOwnProperty;function fn(t){var e=this.__data__;return L?e[t]!==void 0:sn.call(e,t)}var qe=fn;var pn="__lodash_hash_undefined__";function ln(t,e){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=L&&e===void 0?pn:e,this}var Ye=ln;function ot(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}ot.prototype.clear=$e;ot.prototype.delete=He;ot.prototype.get=Ve;ot.prototype.has=qe;ot.prototype.set=Ye;var Ht=ot;function mn(){this.__data__=[],this.size=0}var Ze=mn;function un(t,e){for(var r=t.length;r--;)if(D(t[r][0],e))return r;return-1}var k=un;var dn=Array.prototype,cn=dn.splice;function hn(t){var e=this.__data__,r=k(e,t);if(r<0)return!1;var o=e.length-1;return r==o?e.pop():cn.call(e,r,1),--this.size,!0}var Je=hn;function xn(t){var e=this.__data__,r=k(e,t);return r<0?void 0:e[r][1]}var Xe=xn;function gn(t){return k(this.__data__,t)>-1}var Qe=gn;function bn(t,e){var r=this.__data__,o=k(r,t);return o<0?(++this.size,r.push([t,e])):r[o][1]=e,this}var tr=bn;function at(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}at.prototype.clear=Ze;at.prototype.delete=Je;at.prototype.get=Xe;at.prototype.has=Qe;at.prototype.set=tr;var G=at;var yn=S(y,"Map"),K=yn;function vn(){this.size=0,this.__data__={hash:new Ht,map:new(K||G),string:new Ht}}var er=vn;function wn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}var rr=wn;function Tn(t,e){var r=t.__data__;return rr(e)?r[typeof e=="string"?"string":"hash"]:r.map}var z=Tn;function On(t){var e=z(this,t).delete(t);return this.size-=e?1:0,e}var or=On;function Pn(t){return z(this,t).get(t)}var ar=Pn;function An(t){return z(this,t).has(t)}var ir=An;function jn(t,e){var r=z(this,t),o=r.size;return r.set(t,e),this.size+=r.size==o?0:1,this}var nr=jn;function it(t){var e=-1,r=t==null?0:t.length;for(this.clear();++e<r;){var o=t[e];this.set(o[0],o[1])}}it.prototype.clear=er;it.prototype.delete=or;it.prototype.get=ar;it.prototype.has=ir;it.prototype.set=nr;var gt=it;var Sn="Expected a function";function Vt(t,e){if(typeof t!="function"||e!=null&&typeof e!="function")throw new TypeError(Sn);var r=function(){var o=arguments,a=e?e.apply(this,o):o[0],n=r.cache;if(n.has(a))return n.get(a);var s=t.apply(this,o);return r.cache=n.set(a,s)||n,s};return r.cache=new(Vt.Cache||gt),r}Vt.Cache=gt;var sr=Vt;var In=500;function _n(t){var e=sr(t,function(o){return r.size===In&&r.clear(),o}),r=e.cache;return e}var fr=_n;var En=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Cn=/\\(\\)?/g,Fn=fr(function(t){var e=[];return t.charCodeAt(0)===46&&e.push(""),t.replace(En,function(r,o,a,n){e.push(a?n.replace(Cn,"$1"):o||r)}),e}),pr=Fn;function Mn(t){return t==null?"":he(t)}var lr=Mn;function Rn(t,e){return v(t)?t:We(t,e)?[t]:pr(lr(t))}var W=Rn;var Nn=1/0;function Ln(t){if(typeof t=="string"||V(t))return t;var e=t+"";return e=="0"&&1/t==-Nn?"-0":e}var nt=Ln;function Bn(t,e){e=W(e,t);for(var r=0,o=e.length;t!=null&&r<o;)t=t[nt(e[r++])];return r&&r==o?t:void 0}var mr=Bn;function Dn(t,e){for(var r=-1,o=e.length,a=t.length;++r<o;)t[a+r]=e[r];return t}var st=Dn;var ur=j?j.isConcatSpreadable:void 0;function Un(t){return v(t)||R(t)||!!(ur&&t&&t[ur])}var dr=Un;function cr(t,e,r,o,a){var n=-1,s=t.length;for(r||(r=dr),a||(a=[]);++n<s;){var i=t[n];e>0&&r(i)?e>1?cr(i,e-1,r,o,a):st(a,i):o||(a[a.length]=i)}return a}var hr=cr;function kn(t){var e=t==null?0:t.length;return e?hr(t,1):[]}var xr=kn;function Gn(t){return jt(St(t,void 0,xr),t+"")}var gr=Gn;var Kn=Et(Object.getPrototypeOf,Object),ft=Kn;var zn="[object Object]",Wn=Function.prototype,$n=Object.prototype,br=Wn.toString,Hn=$n.hasOwnProperty,Vn=br.call(Object);function qn(t){if(!A(t)||I(t)!=zn)return!1;var e=ft(t);if(e===null)return!0;var r=Hn.call(e,"constructor")&&e.constructor;return typeof r=="function"&&r instanceof r&&br.call(r)==Vn}var yr=qn;function Yn(){this.__data__=new G,this.size=0}var vr=Yn;function Zn(t){var e=this.__data__,r=e.delete(t);return this.size=e.size,r}var wr=Zn;function Jn(t){return this.__data__.get(t)}var Tr=Jn;function Xn(t){return this.__data__.has(t)}var Or=Xn;var Qn=200;function ts(t,e){var r=this.__data__;if(r instanceof G){var o=r.__data__;if(!K||o.length<Qn-1)return o.push([t,e]),this.size=++r.size,this;r=this.__data__=new gt(o)}return r.set(t,e),this.size=r.size,this}var Pr=ts;function pt(t){var e=this.__data__=new G(t);this.size=e.size}pt.prototype.clear=vr;pt.prototype.delete=wr;pt.prototype.get=Tr;pt.prototype.has=Or;pt.prototype.set=Pr;var Ct=pt;function es(t,e){return t&&_(e,rt(e),t)}var Ar=es;function rs(t,e){return t&&_(e,E(e),t)}var jr=rs;var Er=typeof exports=="object"&&exports&&!exports.nodeType&&exports,Sr=Er&&typeof module=="object"&&module&&!module.nodeType&&module,os=Sr&&Sr.exports===Er,Ir=os?y.Buffer:void 0,_r=Ir?Ir.allocUnsafe:void 0;function as(t,e){if(e)return t.slice();var r=t.length,o=_r?_r(r):new t.constructor(r);return t.copy(o),o}var Ft=as;function is(t,e){for(var r=-1,o=t==null?0:t.length,a=0,n=[];++r<o;){var s=t[r];e(s,r,t)&&(n[a++]=s)}return n}var Cr=is;function ns(){return[]}var Mt=ns;var ss=Object.prototype,fs=ss.propertyIsEnumerable,Fr=Object.getOwnPropertySymbols,ps=Fr?function(t){return t==null?[]:(t=Object(t),Cr(Fr(t),function(e){return fs.call(t,e)}))}:Mt,lt=ps;function ls(t,e){return _(t,lt(t),e)}var Mr=ls;var ms=Object.getOwnPropertySymbols,us=ms?function(t){for(var e=[];t;)st(e,lt(t)),t=ft(t);return e}:Mt,Rt=us;function ds(t,e){return _(t,Rt(t),e)}var Rr=ds;function cs(t,e,r){var o=e(t);return v(t)?o:st(o,r(t))}var Nt=cs;function hs(t){return Nt(t,rt,lt)}var Nr=hs;function xs(t){return Nt(t,E,Rt)}var Lr=xs;var gs=S(y,"DataView"),Lt=gs;var bs=S(y,"Promise"),Bt=bs;var ys=S(y,"Set"),Dt=ys;var Br="[object Map]",vs="[object Object]",Dr="[object Promise]",Ur="[object Set]",kr="[object WeakMap]",Gr="[object DataView]",ws=M(Lt),Ts=M(K),Os=M(Bt),Ps=M(Dt),As=M(Pt),H=I;(Lt&&H(new Lt(new ArrayBuffer(1)))!=Gr||K&&H(new K)!=Br||Bt&&H(Bt.resolve())!=Dr||Dt&&H(new Dt)!=Ur||Pt&&H(new Pt)!=kr)&&(H=function(t){var e=I(t),r=e==vs?t.constructor:void 0,o=r?M(r):"";if(o)switch(o){case ws:return Gr;case Ts:return Br;case Os:return Dr;case Ps:return Ur;case As:return kr}return e});var mt=H;var js=Object.prototype,Ss=js.hasOwnProperty;function Is(t){var e=t.length,r=new t.constructor(e);return e&&typeof t[0]=="string"&&Ss.call(t,"index")&&(r.index=t.index,r.input=t.input),r}var Kr=Is;var _s=y.Uint8Array,qt=_s;function Es(t){var e=new t.constructor(t.byteLength);return new qt(e).set(new qt(t)),e}var ut=Es;function Cs(t,e){var r=e?ut(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}var zr=Cs;var Fs=/\w*$/;function Ms(t){var e=new t.constructor(t.source,Fs.exec(t));return e.lastIndex=t.lastIndex,e}var Wr=Ms;var $r=j?j.prototype:void 0,Hr=$r?$r.valueOf:void 0;function Rs(t){return Hr?Object(Hr.call(t)):{}}var Vr=Rs;function Ns(t,e){var r=e?ut(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}var Ut=Ns;var Ls="[object Boolean]",Bs="[object Date]",Ds="[object Map]",Us="[object Number]",ks="[object RegExp]",Gs="[object Set]",Ks="[object String]",zs="[object Symbol]",Ws="[object ArrayBuffer]",$s="[object DataView]",Hs="[object Float32Array]",Vs="[object Float64Array]",qs="[object Int8Array]",Ys="[object Int16Array]",Zs="[object Int32Array]",Js="[object Uint8Array]",Xs="[object Uint8ClampedArray]",Qs="[object Uint16Array]",tf="[object Uint32Array]";function ef(t,e,r){var o=t.constructor;switch(e){case Ws:return ut(t);case Ls:case Bs:return new o(+t);case $s:return zr(t,r);case Hs:case Vs:case qs:case Ys:case Zs:case Js:case Xs:case Qs:case tf:return Ut(t,r);case Ds:return new o;case Us:case Ks:return new o(t);case ks:return Wr(t);case Gs:return new o;case zs:return Vr(t)}}var qr=ef;function rf(t){return typeof t.constructor=="function"&&!Q(t)?we(ft(t)):{}}var kt=rf;var of="[object Map]";function af(t){return A(t)&&mt(t)==of}var Yr=af;var Zr=N&&N.isMap,nf=Zr?et(Zr):Yr,Jr=nf;var sf="[object Set]";function ff(t){return A(t)&&mt(t)==sf}var Xr=ff;var Qr=N&&N.isSet,pf=Qr?et(Qr):Xr,to=pf;var lf=1,mf=2,uf=4,eo="[object Arguments]",df="[object Array]",cf="[object Boolean]",hf="[object Date]",xf="[object Error]",ro="[object Function]",gf="[object GeneratorFunction]",bf="[object Map]",yf="[object Number]",oo="[object Object]",vf="[object RegExp]",wf="[object Set]",Tf="[object String]",Of="[object Symbol]",Pf="[object WeakMap]",Af="[object ArrayBuffer]",jf="[object DataView]",Sf="[object Float32Array]",If="[object Float64Array]",_f="[object Int8Array]",Ef="[object Int16Array]",Cf="[object Int32Array]",Ff="[object Uint8Array]",Mf="[object Uint8ClampedArray]",Rf="[object Uint16Array]",Nf="[object Uint32Array]",h={};h[eo]=h[df]=h[Af]=h[jf]=h[cf]=h[hf]=h[Sf]=h[If]=h[_f]=h[Ef]=h[Cf]=h[bf]=h[yf]=h[oo]=h[vf]=h[wf]=h[Tf]=h[Of]=h[Ff]=h[Mf]=h[Rf]=h[Nf]=!0;h[xf]=h[ro]=h[Pf]=!1;function Gt(t,e,r,o,a,n){var s,i=e&lf,f=e&mf,u=e&uf;if(r&&(s=a?r(t,o,a,n):r(t)),s!==void 0)return s;if(!w(t))return t;var p=v(t);if(p){if(s=Kr(t),!i)return At(t,s)}else{var g=mt(t),P=g==ro||g==gf;if(tt(t))return Ft(t,i);if(g==oo||g==eo||P&&!a){if(s=f||P?{}:kt(t),!i)return f?Rr(t,jr(s,t)):Mr(t,Ar(s,t))}else{if(!h[g])return a?t:{};s=qr(t,g,i)}}n||(n=new Ct);var T=n.get(t);if(T)return T;n.set(t,s),to(t)?t.forEach(function(O){s.add(Gt(O,e,r,O,t,n))}):Jr(t)&&t.forEach(function(O,l){s.set(l,Gt(O,e,r,l,t,n))});var b=u?f?Lr:Nr:f?E:rt,C=p?void 0:b(t);return je(C||t,function(O,l){C&&(l=O,O=t[l]),J(s,l,Gt(O,e,r,l,t,n))}),s}var ao=Gt;var Lf=1,Bf=4;function Df(t){return ao(t,Lf|Bf)}var Yt=Df;function Uf(t,e){return t!=null&&e in Object(t)}var io=Uf;function kf(t,e,r){e=W(e,t);for(var o=-1,a=e.length,n=!1;++o<a;){var s=nt(e[o]);if(!(n=t!=null&&r(t,s)))break;t=t[s]}return n||++o!=a?n:(a=t==null?0:t.length,!!a&&X(a)&&B(s,a)&&(v(t)||R(t)))}var no=kf;function Gf(t,e){return t!=null&&no(t,e,io)}var so=Gf;function Kf(t){return function(e,r,o){for(var a=-1,n=Object(e),s=o(e),i=s.length;i--;){var f=s[t?i:++a];if(r(n[f],f,n)===!1)break}return e}}var fo=Kf;var zf=fo(),po=zf;function Wf(t,e,r){(r!==void 0&&!D(t[e],r)||r===void 0&&!(e in t))&&Z(t,e,r)}var bt=Wf;function $f(t){return A(t)&&U(t)}var lo=$f;function Hf(t,e){if(!(e==="constructor"&&typeof t[e]=="function")&&e!="__proto__")return t[e]}var yt=Hf;function Vf(t){return _(t,E(t))}var mo=Vf;function qf(t,e,r,o,a,n,s){var i=yt(t,r),f=yt(e,r),u=s.get(f);if(u){bt(t,r,u);return}var p=n?n(i,f,r+"",t,e,s):void 0,g=p===void 0;if(g){var P=v(f),T=!P&&tt(f),b=!P&&!T&&It(f);p=f,P||T||b?v(i)?p=i:lo(i)?p=At(i):T?(g=!1,p=Ft(f,!0)):b?(g=!1,p=Ut(f,!0)):p=[]:yr(f)||R(f)?(p=i,R(i)?p=mo(i):(!w(i)||q(i))&&(p=kt(f))):g=!1}g&&(s.set(f,p),a(p,f,o,n,s),s.delete(f)),bt(t,r,p)}var uo=qf;function co(t,e,r,o,a){t!==e&&po(e,function(n,s){if(a||(a=new Ct),w(n))uo(t,e,s,r,co,o,a);else{var i=o?o(yt(t,s),n,s+"",t,e,a):void 0;i===void 0&&(i=n),bt(t,s,i)}},E)}var ho=co;var Yf=Ee(function(t,e,r){ho(t,e,r)}),Zt=Yf;function Zf(t,e,r,o){if(!w(t))return t;e=W(e,t);for(var a=-1,n=e.length,s=n-1,i=t;i!=null&&++a<n;){var f=nt(e[a]),u=r;if(f==="__proto__"||f==="constructor"||f==="prototype")return t;if(a!=s){var p=i[f];u=o?o(p,f,i):void 0,u===void 0&&(u=w(p)?p:B(e[a+1])?[]:{})}J(i,f,u),i=i[f]}return t}var xo=Zf;function Jf(t,e,r){for(var o=-1,a=e.length,n={};++o<a;){var s=e[o],i=mr(t,s);r(i,s)&&xo(n,W(s,t),i)}return n}var go=Jf;function Xf(t,e){return go(t,e,function(r,o){return so(t,o)})}var bo=Xf;var Qf=gr(function(t,e){return t==null?{}:bo(t,e)}),Kt=Qf;function yo(t){return{all:t=t||new Map,on:function(e,r){var o=t.get(e);o?o.push(r):t.set(e,[r])},off:function(e,r){var o=t.get(e);o&&(r?o.splice(o.indexOf(r)>>>0,1):t.set(e,[]))},emit:function(e,r){var o=t.get(e);o&&o.slice().map(function(a){a(r)}),(o=t.get("*"))&&o.slice().map(function(a){a(e,r)})}}}var vo="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var Jt=(t=21)=>{let e="",r=crypto.getRandomValues(new Uint8Array(t));for(;t--;)e+=vo[r[t]&63];return e};var tp="array",ep="bit",wo="bits",rp="byte",To="bytes",dt="",op="exponent",ap="function",Oo="iec",ip="Invalid number",np="Invalid rounding method",Xt="jedec",sp="object",Po=".",fp="round",pp="s",lp="si",mp="kbit",up="kB",dp=" ",cp="string",hp="0",Qt={symbol:{iec:{bits:["bit","Kibit","Mibit","Gibit","Tibit","Pibit","Eibit","Zibit","Yibit"],bytes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},jedec:{bits:["bit","Kbit","Mbit","Gbit","Tbit","Pbit","Ebit","Zbit","Ybit"],bytes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]}},fullform:{iec:["","kibi","mebi","gibi","tebi","pebi","exbi","zebi","yobi"],jedec:["","kilo","mega","giga","tera","peta","exa","zetta","yotta"]}};function Ao(t,{bits:e=!1,pad:r=!1,base:o=-1,round:a=2,locale:n=dt,localeOptions:s={},separator:i=dt,spacer:f=dp,symbols:u={},standard:p=dt,output:g=cp,fullform:P=!1,fullforms:T=[],exponent:b=-1,roundingMethod:C=fp,precision:O=0}={}){let l=b,d=Number(t),m=[],F=0,zt=dt;p===lp?(o=10,p=Xt):p===Oo||p===Xt?o=2:o===2?p=Oo:(o=10,p=Xt);let vt=o===10?1e3:1024,jo=P===!0,ee=d<0,re=Math[C];if(typeof t!="bigint"&&isNaN(t))throw new TypeError(ip);if(typeof re!==ap)throw new TypeError(np);if(ee&&(d=-d),(l===-1||isNaN(l))&&(l=Math.floor(Math.log(d)/Math.log(vt)),l<0&&(l=0)),l>8&&(O>0&&(O+=8-l),l=8),g===op)return l;if(d===0)m[0]=0,zt=m[1]=Qt.symbol[p][e?wo:To][l];else{F=d/(o===2?Math.pow(2,l*10):Math.pow(1e3,l)),e&&(F=F*8,F>=vt&&l<8&&(F=F/vt,l++));let ct=Math.pow(10,l>0?a:0);m[0]=re(F*ct)/ct,m[0]===vt&&l<8&&b===-1&&(m[0]=1,l++),zt=m[1]=o===10&&l===1?e?mp:up:Qt.symbol[p][e?wo:To][l]}if(ee&&(m[0]=-m[0]),O>0&&(m[0]=m[0].toPrecision(O)),m[1]=u[m[1]]||m[1],n===!0?m[0]=m[0].toLocaleString():n.length>0?m[0]=m[0].toLocaleString(n,s):i.length>0&&(m[0]=m[0].toString().replace(Po,i)),r&&Number.isInteger(m[0])===!1&&a>0){let ct=i||Po,oe=m[0].toString().split(ct),ae=oe[1]||dt,ie=ae.length,So=a-ie;m[0]=`${oe[0]}${ct}${ae.padEnd(ie+So,hp)}`}return jo&&(m[1]=T[l]?T[l]:Qt.fullform[p][l]+(e?ep:rp)+(m[0]===1?dt:pp)),g===tp?m:g===sp?{value:m[0],symbol:m[1],exponent:l,unit:zt}:m.join(f)}var $=class t{constructor(e){c(this,"_tera");c(this,"id");c(this,"name");c(this,"icon");c(this,"path");c(this,"url");c(this,"teraUrl");c(this,"parsedName");c(this,"created");c(this,"createdFormatted");c(this,"modified");c(this,"modifiedFormatted");c(this,"accessed");c(this,"accessedFormatted");c(this,"size");c(this,"sizeFormatted");c(this,"mime");c(this,"meta",{});if(!e.tera)throw new Error("Basic file requires a `tera` key to access the Tera instance");Object.assign(this,e);let r=this.tera;Object.defineProperty(this,"_tera",{enumerable:!1,configurable:!1,get(){return r}}),delete this.tera,this.teraUrl=this.url.replace(/^https?:\/\/(?:.+?)\/projects\/(?:.+?)\/project\/(.+)$/,"/project/$1"),this.sizeFormatted=Ao(this.size||0,{spacer:""}),this.createdFormatted=this.created?this.created.toLocaleDateString():"Unknown created date",this.modifiedFormatted=this.modified?this.modified.toLocaleDateString():"Unknown modified date",this.accessedFormatted=this.accessed?this.accessed.toLocaleDateString():"Unknown access date"}getContents(e){return this._tera.getProjectFileContents(this.id,e)}setContents(e){return this._tera.setProjectFileContents(this.id,e)}getRefs(){return this._tera.getProjectLibrary(this.id)}setRefs(e){return this._tera.setProjectLibrary(this.id,e)}serialize(){return Kt(this,["id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"])}static deserialize(e){return new t(Kt(e,["tera","id","name","icon","path","url","parsedName","created","modified","accessed","size","mime","meta"]))}};var te=class{constructor(e){c(this,"settings",{devMode:!0,verbosity:1,mode:"detect",modeTimeout:300,modeFallback:"child",modeOverrides:{child:{siteUrl:"https://dev.tera-tools.com/embed",restrictOrigin:"*"}},siteUrl:"https://tera-tools.com/embed",restrictOrigin:"https://tera-tools.com",frameSandbox:["allow-forms","allow-modals","allow-orientation-lock","allow-pointer-lock","allow-popups","allow-popups-to-escape-sandbox","allow-presentation","allow-same-origin","allow-scripts","allow-top-navigation"],handshakeInterval:1e3,handshakeTimeout:1e4,debugPaths:null});c(this,"events",yo());c(this,"dom",{el:null,iframe:null,popup:null,stylesheet:null});c(this,"methods",["handshake","setServerVerbosity","getUser","requireUser","bindProject","getProject","getProjects","setActiveProject","requireProject","selectProject","getProjectState","setProjectState","setProjectStateDefaults","setProjectStateFlush","setProjectStateRefresh","saveProjectState","replaceProjectState","getProjectFileContents","deleteProjectFile","setProjectFileContents","selectProjectLibrary","getProjectLibrary","setProjectLibrary","projectLog","setPage","uiAlert","uiConfirm","uiProgress","uiPrompt","uiThrow","uiSplat","uiWindow"]);c(this,"plugins",[]);c(this,"acceptPostboxes",{});e&&this.set(e)}send(e){let r=Jt();return this.acceptPostboxes[r]={},this.acceptPostboxes[r].promise=new Promise((o,a)=>{Object.assign(this.acceptPostboxes[r],{resolve:o,reject:a}),this.sendRaw({id:r,...e})}),this.acceptPostboxes[r].promise}sendRaw(e){let r;try{if(r={TERA:1,id:e.id||Jt(),...Yt(e)},this.settings.mode=="parent")window.parent.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="child")this.dom.iframe.contentWindow.postMessage(r,this.settings.restrictOrigin);else if(this.settings.mode=="popup")this.dom.popup.postMessage(r,this.settings.restrictOrigin);else throw this.settings.mode=="detect"?new Error("Call init() or detectMode() before trying to send data to determine the mode"):new Error(`Unknown TERA communication mode "${this.settings.mode}"`)}catch(o){throw this.debug("ERROR",1,"Message compose client->server:",o),this.debug("ERROR",1,"Attempted to dispatch payload client->server",r),o}}rpc(e,...r){return this.send({action:"rpc",method:e,args:r})}acceptMessage(e){if(e.origin==window.location.origin)return;let r=e.data;if(!(!r.TERA||!r.id))if(this.debug("INFO",3,"Recieved message",r),(r==null?void 0:r.action)=="response"&&this.acceptPostboxes[r.id])r.isError===!0?this.acceptPostboxes[r.id].reject(r.response):this.acceptPostboxes[r.id].resolve(r.response);else{if((r==null?void 0:r.action)=="rpc")return Promise.resolve().then(()=>this[r.method].apply(this,r.args)).then(o=>this.sendRaw({id:r.id,action:"response",response:o})).catch(o=>{console.warn(`TERA-FY client threw on RPC:${r.method}:`,o),this.sendRaw({id:r.id,action:"response",isError:!0,response:o&&o.toString()})});if((r==null?void 0:r.action)=="event")return Promise.resolve().then(()=>this.events.emit(r.event,...r.payload)).catch(o=>{throw console.warn(`TERA-FY client threw while handling emitted event "${r.event}"`,{message:r}),o});r!=null&&r.id?this.debug("INFO",3,`Ignoring message ID ${r.id} - was meant for someone else?`):this.debug("INFO",3,"Unexpected incoming TERA-FY CLIENT message",{message:r})}}createProjectStatePatch(e,r){let o=ne(r,e);return this.debug("INFO",3,"Created project patch",{patch:o,newState:e,oldState:r}),this.applyProjectStatePatch(o)}applyProjectStatePatch(e){if(this.settings.devMode&&this.settings.debugPaths){if(!Array.isArray(this.settings.debugPaths))throw new Error("teraFyClient.settings.debugPaths should be either null or an Array<String>");let r=e.filter(o=>this.settings.debugPaths.some(a=>o.path.join(".").slice(0,a.length)==a)).map(o=>o.path.join("."));if(r.length>0){console.info("Detected writes to",r,"- entering debugging mode");debugger}}return this.rpc("applyProjectStatePatch",e)}applyProjectStatePatchLocal(e){throw new Error("applyProjectStatePatchLocal() has not been sub-classed by a plugin")}init(e){if(e&&this.set(e),this.init.promise)return this.init.promise;window.addEventListener("message",this.acceptMessage.bind(this));let r=this;return this.init.promise=Promise.resolve().then(()=>this.debug("INFO",4,"[0/6] Init",this.settings.siteUrl)).then(()=>{this.settings.devMode&&(this.settings.debugPaths=this.settings.debugPaths?Array.isArray(this.settings.debugPaths)?this.settings.debugPaths.map(o=>Array.isArray(o)?o.join("."):typeof o=="string"?o:(()=>{throw new Error("Unknown path type - should be an array or string in dotted notation")})()):(()=>{throw new Error("Unknown terafyClient.settings.debugPaths type")})():null,this.debug("INFO",0,"Watching state paths",this.settings.debugPaths))}).then(()=>this.detectMode()).then(o=>{this.debug("INFO",4,"[1/6] Setting client mode to",o),Zt(this.settings,{mode:o,...this.settings.modeOverrides[o]})}).then(()=>this.debug("INFO",4,"[2/6] Injecting comms + styles + methods")).then(()=>Promise.all([this.injectComms(),this.injectStylesheet(),this.injectMethods()])).then(()=>{if(this.settings.verbosity<=1){this.debug("INFO",4,"[3/6] Skip - Server verbosity is already at 1");return}else return this.debug("INFO",4,`[3/6] Set server verbosity to ${this.settings.verbosity}`),this.rpc("setServerVerbosity",this.settings.verbosity)}).then(()=>this.debug("INFO",4,`[4/6] Set server mode to "${this.settings.mode}"`)).then(()=>this.rpc("setServerMode",this.settings.mode=="child"?"embedded":this.settings.mode=="parent"?"frame":this.settings.mode=="popup"?"popup":(()=>{throw`Unknown server mode "${this.settings.mode}"`})())).then(()=>this.debug("INFO",4,"[5/6] Run client plugins")).then(()=>Promise.all(this.plugins.map(o=>o.init.call(r,this.settings)))).then(()=>this.debug("INFO",4,"[6/6] Init complete")).catch(o=>this.debug("WARN",0,"Init process fault",o))}detectMode(){return this.settings.mode!="detect"?Promise.resolve(this.settings.mode):window.self===window.parent?Promise.resolve(this.settings.modeFallback):Promise.resolve().then(()=>this.settings.mode="parent").then(()=>new Promise((e,r)=>{let o=setTimeout(()=>r(),this.settings.modeTimeout);this.rpc("handshake").then(()=>clearTimeout(o)).then(()=>e())})).then(()=>"parent").catch(()=>this.settings.modeFallback)}injectComms(){switch(this.settings.mode){case"child":return Promise.resolve().then(()=>new Promise(e=>{this.debug("INFO",2,"Injecting TERA site as iFrame child"),this.dom.el=document.createElement("div"),this.dom.el.id="tera-fy",this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this.dom.el.classList.add("minimized"),document.body.append(this.dom.el),this.dom.el.addEventListener("click",()=>this.dom.el.classList.toggle("minimized")),this.dom.iframe=document.createElement("iframe"),this.dom.iframe.setAttribute("sandbox",this.settings.frameSandbox.join(" ")),this.dom.iframe.addEventListener("load",()=>{this.debug("INFO",3,"Embeded iframe ready"),e()}),this.dom.iframe.src=this.settings.siteUrl,this.dom.el.append(this.dom.iframe)})).then(()=>this.handshakeLoop());case"parent":this.debug("INFO",2,"Using TERA window parent");break;case"popup":return this.debug("INFO",2,"Injecting TERA site as a popup window"),this.dom.popup=window.open(this.settings.siteUrl,"_blank","popup=1, location=0, menubar=0, status=0, scrollbars=0, width=500, height=600"),this.handshakeLoop().then(()=>this.debug("INFO",3,"Popup window accepted handshake"));default:throw new Error(`Unsupported mode "${this.settings.mode}" when calling injectComms()`)}}handshakeLoop(e){let r={handshakeInterval:this.settings.handshakeInterval,handshakeTimeout:this.settings.handshakeTimeout,...e};return new Promise((o,a)=>{let n=0,s,i=setTimeout(()=>{clearTimeout(s),a("TIMEOUT")},r.handshakeTimeout),f=()=>{this.debug("INFO",4,"Trying handshake",++n),clearTimeout(s),s=setTimeout(f,r.handshakeInterval),this.rpc("handshake").then(()=>{clearTimeout(i),clearTimeout(s)}).then(()=>o()).catch(a)};f()})}injectStylesheet(){switch(this.settings.mode){case"child":this.dom.stylesheet=document.createElement("style"),this.dom.stylesheet.innerHTML=[":root {","--TERA-accent: #4d659c;","}","#tera-fy {","display: none;","position: fixed;","right: 50px;","bottom: 50px;","width: 300px;","height: 150px;","background: transparent;","body:not(.tera-fy-focus) &.minimized.dev-mode {","background: var(--TERA-accent) !important;","opacity: 0.5;","right: 0px;","bottom: 0px;","width: 30px;","height: 30px;","transition: opacity 0.2s ease-out;","cursor: pointer;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","display: flex;","justify-content: center;","align-items: center;","&::before {","margin: 2px 0 0 0;",'content: "\u{1F300}";',"color: #FFF;","}","&:hover {","opacity: 1;","}","& > iframe {","display: none;","}","}","body:not(.tera-fy-focus) &:not(.minimized) {","&::before {","display: flex;","align-items: center;","justify-content: center;","cursor: pointer;","background: var(--TERA-accent) !important;","opacity: 0.5;","transition: opacity 0.2s ease-out;","position: absolute;","right: 0px;","bottom: 0px;","width: 20px;","height: 20px;","margin: 2px 0 0 0;",'content: "\u2B68";',"color: #FFF;","border: none;","border-top-left-radius: 30px;","border-top: 2px solid var(--TERA-accent);","border-left: 2px solid var(--TERA-accent);","}","&:hover::before {","opacity: 1;","}","}","&.dev-mode {","display: flex;","border: 5px solid var(--TERA-accent);","background: #FFF;","}","& > iframe {","width: 100%;","height: 100%;","}","}","body.tera-fy-focus {","overflow: hidden;","& #tera-fy {","display: flex !important;","position: fixed !important;","top: 0px !important;","width: 100vw !important;","height: 100vh !important;","left: 0px !important;","z-index: 10000 !important;","}","}"].join(`
2
2
  `),document.head.appendChild(this.dom.stylesheet);break;case"parent":case"popup":break;default:throw new Error(`Unsupported mode "${this.settings.mode}" when injectStylesheet()`)}return Promise.resolve()}injectMethods(){this.methods.forEach(e=>this[e]=this.rpc.bind(this,e))}debug(...e){if(!this.settings.devMode||this.settings.verbosity<1)return;let r="log",o=1;typeof e[0]=="string"&&["INFO","LOG","WARN","ERROR"].includes(e[0])&&(r=e.shift().toLowerCase()),typeof e[0]=="number"&&(o=e[0],e.shift()),!(this.settings.verbosity<o)&&console[r]("%c[TERA-FY CLIENT]","font-weight: bold; color: #ff5722;",...e)}set(e,r,o){let a={ignoreNullish:!0,...o};return typeof e=="string"?(!a.ignoreNullish||r!=null)&&(this.settings[e]=r):Object.assign(this.settings,e),this.toggleDevMode(this.settings.devMode)}setIfDev(e,r,o){return!this.settings.devMode||r===void 0?this:this.set(e,r,o)}use(e,r){if(typeof e!="function")throw new Error("Expected use() call to be provided with a class initalizer");let o=new e(this,r);return this.mixin(this,o),this.plugins.push(o),this}mixin(e,r){Object.getOwnPropertyNames(Object.getPrototypeOf(r)).filter(o=>!["constructor","prototype","name"].includes(o)).filter(o=>o!="init").forEach(o=>{Object.defineProperty(e,o,{value:r[o].bind(e),enumerable:!1})})}toggleDevMode(e="toggle"){return e==="toggle"?this.settings.devMode=!this.settings.devMode:e==="proxy"?Object.assign(this.settings,{devMode:!0,siteUrl:"http://localhost:7334/embed",mode:"child"}):this.settings.devMode=!!e,this.dom.el&&this.dom.el.classList.toggle("dev-mode",this.settings.devMode),this}toggleFocus(e="toggle"){this.debug("INFO",2,"Request focus",{isFocused:e}),globalThis.document.body.classList.toggle("tera-fy-focus",e==="toggle"?void 0:e)}selectProjectFile(e){return this.rpc("selectProjectFile",e).then(r=>r&&new $({tera:this,...r}))}getProjectFiles(e){return this.rpc("getProjectFiles",e).then(r=>r.map(o=>new $({tera:this,...o})))}getProjectFile(e){return this.rpc("getProjectFile",e).then(r=>r&&new $({tera:this,...r}))}createProjectFile(e){return this.rpc("createProjectFile",e).then(r=>r&&new $({tera:this,...r}))}};export{te as default};
3
3
  /*! Bundled license information:
4
4