@rugal.tu/vuemodel3 1.2.0 → 1.2.1-2.1

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.
@@ -344,6 +344,8 @@ class DomQueryer {
344
344
  var Queryer = new DomQueryer();
345
345
  export { DomQueryer, Queryer };
346
346
  export class FileItem {
347
+ OnChangeBase64;
348
+ OnChangeBuffer;
347
349
  $Store;
348
350
  constructor(File, ConvertType = 'none') {
349
351
  if (File == null)
@@ -382,12 +384,14 @@ export class FileItem {
382
384
  }
383
385
  set Base64(Value) {
384
386
  this.$Store.Base64 = Value;
387
+ this.OnChangeBase64?.call(this, this.$Store.Base64);
385
388
  }
386
389
  get Buffer() {
387
390
  return this.$Store.Buffer;
388
391
  }
389
392
  set Buffer(Value) {
390
393
  this.$Store.Buffer = Value;
394
+ this.OnChangeBuffer?.call(this, this.$Store.Buffer);
391
395
  }
392
396
  get InnerStore() {
393
397
  return this.$Store;
@@ -586,8 +590,13 @@ export class ApiStore extends FuncBase {
586
590
  throw ApiResponse;
587
591
  let ConvertResult = await this.$ProcessApiReturn(ApiResponse);
588
592
  if (IsUpdateStore) {
589
- if (this.#ExportSuccessStore != null) {
590
- ConvertResult = this.#ExportSuccessStore?.call(this, ConvertResult, ApiResponse);
593
+ if (Api.Export != false) {
594
+ if (typeof Api.Export === 'function') {
595
+ ConvertResult = Api.Export?.call(this, ConvertResult, ApiResponse);
596
+ }
597
+ else if (this.#ExportSuccessStore != null) {
598
+ ConvertResult = this.#ExportSuccessStore?.call(this, ConvertResult, ApiResponse);
599
+ }
591
600
  }
592
601
  let StoreKey = Api.ApiKey;
593
602
  this.UpdateStore(StoreKey, ConvertResult);
@@ -683,42 +692,22 @@ export class ApiStore extends FuncBase {
683
692
  for (let Item of EventFuncs)
684
693
  Item(EventArg);
685
694
  }
686
- UpdateStore(StorePath, StoreData) {
687
- StorePath = this.ToJoin(StorePath);
688
- this.$RCS_SetStore(StorePath, StoreData, this.Store, {
689
- IsDeepSet: true,
690
- });
691
- this.$EventTrigger(this.#EventName.UpdateStore, {
692
- Path: StorePath,
693
- Data: StoreData,
694
- });
695
- return this;
695
+ GetStore(StorePath, Option) {
696
+ return this.GetStoreFrom(this.Store, StorePath, Option);
696
697
  }
697
698
  AddStore(StorePath, StoreData = null) {
698
- StorePath = this.ToJoin(StorePath);
699
- if (this.GetStore(StorePath) != null)
700
- return this;
701
- this.$RCS_SetStore(StorePath, StoreData, this.Store, {
702
- IsDeepSet: true,
703
- });
704
- this.$EventTrigger(this.#EventName.AddStore, {
705
- Path: StorePath,
706
- Data: StoreData,
707
- });
708
- return this;
699
+ return this.AddStoreFrom(this.Store, StorePath, StoreData);
709
700
  }
710
701
  SetStore(StorePath, StoreData) {
711
- StorePath = this.ToJoin(StorePath);
712
- this.$RCS_SetStore(StorePath, StoreData, this.Store, {
713
- IsDeepSet: false,
714
- });
715
- this.$EventTrigger(this.#EventName.SetStore, {
716
- Path: StorePath,
717
- Data: StoreData,
718
- });
719
- return this;
702
+ return this.SetStoreFrom(this.Store, StorePath, StoreData);
720
703
  }
721
- GetStore(StorePath, Option) {
704
+ UpdateStore(StorePath, StoreData) {
705
+ return this.UpdateStoreFrom(this.Store, StorePath, StoreData);
706
+ }
707
+ ClearStore(StorePath) {
708
+ return this.ClearStoreFrom(this.Store, StorePath);
709
+ }
710
+ GetStoreFrom(SourceStore, StorePath, Option) {
722
711
  if (typeof Option == 'boolean')
723
712
  Option = { Clone: Option };
724
713
  Option ??= {};
@@ -727,7 +716,7 @@ export class ApiStore extends FuncBase {
727
716
  if (Option.DefaultValue == null)
728
717
  Option.DefaultValue = {};
729
718
  StorePath = this.ToJoin(StorePath);
730
- let FindStore = this.$RCS_GetStore(StorePath, this.Store, {
719
+ let FindStore = this.$RCS_GetStore(StorePath, SourceStore, {
731
720
  CreateIfNull: Option.CreateIfNull,
732
721
  DefaultValue: Option.DefaultValue,
733
722
  });
@@ -742,8 +731,43 @@ export class ApiStore extends FuncBase {
742
731
  }
743
732
  return FindStore;
744
733
  }
745
- ClearStore(StorePath) {
746
- let TargetStore = this.GetStore(StorePath);
734
+ AddStoreFrom(SourceStore, StorePath, StoreData = null) {
735
+ StorePath = this.ToJoin(StorePath);
736
+ if (this.GetStore(StorePath) != null)
737
+ return this;
738
+ this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
739
+ IsDeepSet: true,
740
+ });
741
+ this.$EventTrigger(this.#EventName.AddStore, {
742
+ Path: StorePath,
743
+ Data: StoreData,
744
+ });
745
+ return this;
746
+ }
747
+ SetStoreFrom(SourceStore, StorePath, StoreData) {
748
+ StorePath = this.ToJoin(StorePath);
749
+ this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
750
+ IsDeepSet: false,
751
+ });
752
+ this.$EventTrigger(this.#EventName.SetStore, {
753
+ Path: StorePath,
754
+ Data: StoreData,
755
+ });
756
+ return this;
757
+ }
758
+ UpdateStoreFrom(SourceStore, StorePath, StoreData) {
759
+ StorePath = this.ToJoin(StorePath);
760
+ this.$RCS_SetStore(StorePath, StoreData, SourceStore, {
761
+ IsDeepSet: true,
762
+ });
763
+ this.$EventTrigger(this.#EventName.UpdateStore, {
764
+ Path: StorePath,
765
+ Data: StoreData,
766
+ });
767
+ return this;
768
+ }
769
+ ClearStoreFrom(SourceStore, StorePath) {
770
+ let TargetStore = this.GetStoreFrom(SourceStore, StorePath);
747
771
  if (TargetStore == null)
748
772
  return this;
749
773
  let AllProperty = Object.getOwnPropertyNames(TargetStore);
@@ -765,6 +789,7 @@ export class ApiStore extends FuncBase {
765
789
  $RCS_GetStore(StorePath, FindStore, Option) {
766
790
  if (FindStore == null)
767
791
  return null;
792
+ StorePath = StorePath.replaceAll(/\[|\]/g, '.').replace(/\.+/g, '.').replace(/\.$/, '');
768
793
  let StorePaths = StorePath.split('.');
769
794
  let FirstKey = StorePaths.shift();
770
795
  if (FindStore[FirstKey] == null && Option.CreateIfNull) {
@@ -784,6 +809,7 @@ export class ApiStore extends FuncBase {
784
809
  $RCS_SetStore(StorePath, StoreData, FindStore, Option = {
785
810
  IsDeepSet: true,
786
811
  }) {
812
+ StorePath = StorePath.replaceAll(/\[|\]/g, '.').replace(/\.+/g, '.').replace(/\.$/, '');
787
813
  if (StorePath.includes('.')) {
788
814
  let StorePaths = StorePath.split('.');
789
815
  let FirstKey = StorePaths.shift();
@@ -967,8 +993,8 @@ export class ApiStore extends FuncBase {
967
993
  return Form;
968
994
  }
969
995
  }
996
+ import { createApp, reactive, } from 'vue';
970
997
  import { watch } from 'vue';
971
- import { createApp, reactive } from 'vue';
972
998
  export class VueStore extends ApiStore {
973
999
  $VueProxy = null;
974
1000
  $VueOption = {
@@ -1131,15 +1157,19 @@ export class VueCommand extends VueStore {
1131
1157
  this.$AddCommand(DomName, `v-on`, SetOption);
1132
1158
  return this;
1133
1159
  }
1134
- AddV_Watch(WatchPath, Func, Deep = false, Option = {}) {
1135
- let SetWatch = {
1136
- handler: Func,
1137
- deep: Deep,
1138
- ...Option,
1139
- };
1140
- Model.WithMounted(() => {
1160
+ Watch(WatchPath, Callback, Option = {}) {
1161
+ let Handle;
1162
+ if (typeof WatchPath == 'function')
1163
+ Handle = watch(WatchPath, Callback, Option);
1164
+ else {
1141
1165
  Model.AddStore(WatchPath);
1142
- watch(() => Model.GetStore(WatchPath), Func, SetWatch);
1166
+ Handle = watch(() => Model.GetStore(WatchPath), Callback, Option);
1167
+ }
1168
+ return Handle;
1169
+ }
1170
+ AddV_Watch(WatchPath, Callback, Option = {}) {
1171
+ Model.WithMounted(() => {
1172
+ this.Watch(WatchPath, Callback, Option);
1143
1173
  });
1144
1174
  return this;
1145
1175
  }
@@ -1245,6 +1275,12 @@ export class VueCommand extends VueStore {
1245
1275
  }
1246
1276
  Model.AddV_Slot(Option.TargetDom, Info.CommandKey, Option.TargetPath);
1247
1277
  },
1278
+ 'v-on-mounted': (Info, Option) => {
1279
+ Model.AddV_OnMounted(Option.TargetDom, Option.TargetValue, Info.CommandKey);
1280
+ },
1281
+ 'v-on-unmounted': (Info, Option) => {
1282
+ Model.AddV_OnUnMounted(Option.TargetDom, Option.TargetValue, Info.CommandKey);
1283
+ },
1248
1284
  'watch': (Info, Option) => {
1249
1285
  if (typeof (Info.StoreValue) != 'function') {
1250
1286
  Model.$Error(`watch command value must be a function, path: ${this.ToJoin(Info.DomPaths)}`);
@@ -1369,16 +1405,19 @@ export class VueCommand extends VueStore {
1369
1405
  }
1370
1406
  }
1371
1407
  AddV_Property(PropertyPath, Option) {
1408
+ return this.AddV_PropertyFrom(this.Store, PropertyPath, Option);
1409
+ }
1410
+ AddV_PropertyFrom(SourceStore, PropertyPath, Option) {
1372
1411
  if (PropertyPath == null)
1373
1412
  return;
1374
- let SetStore = this.Store;
1413
+ let SetStore = SourceStore;
1375
1414
  PropertyPath = this.ToJoin(PropertyPath);
1376
1415
  let PropertyKey = PropertyPath;
1377
1416
  if (PropertyPath.includes('.')) {
1378
1417
  let PropertyPaths = PropertyPath.split('.');
1379
1418
  PropertyKey = PropertyPaths.pop();
1380
1419
  let FindPath = PropertyPaths.join('.');
1381
- SetStore = this.GetStore(FindPath, {
1420
+ SetStore = this.GetStoreFrom(SourceStore, FindPath, {
1382
1421
  CreateIfNull: true,
1383
1422
  });
1384
1423
  }
@@ -1417,6 +1456,7 @@ export class VueCommand extends VueStore {
1417
1456
  PropertyContent.get = Option.get;
1418
1457
  if (Option.set != null)
1419
1458
  PropertyContent.set = Option.set;
1459
+ let OriginalValue = PropertyStore[PropertyKey];
1420
1460
  let SetProperty = Object.defineProperty(PropertyStore, PropertyKey, PropertyContent);
1421
1461
  SetProperty.$properties ??= {};
1422
1462
  SetProperty.$properties[PropertyKey] = { ...Option };
@@ -1433,8 +1473,10 @@ export class VueCommand extends VueStore {
1433
1473
  else
1434
1474
  PropertyOption[`$${PropertyKey}`] = Value;
1435
1475
  };
1436
- if (SetProperty[PropertyKey] == null && Option.Value != null)
1476
+ if (Option.Value != null)
1437
1477
  SetProperty[PropertyKey] = Option.Value;
1478
+ else if (OriginalValue != null)
1479
+ SetProperty[PropertyKey] = OriginalValue;
1438
1480
  return SetProperty;
1439
1481
  }
1440
1482
  $ConvertCommandOption(DomName, Option) {
@@ -1,2 +1,2 @@
1
- export class FuncBase{$NavigateToFunc;$DefaultDateJoinChar;constructor(){this.$NavigateToFunc=null;this.WithDateTextJoinChar("-")}WithNavigateTo(n){return this.$NavigateToFunc=n,this}WithDateTextJoinChar(n){return this.$DefaultDateJoinChar=n,this}GenerateId(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let t=crypto.getRandomValues(new Uint8Array(1))[0]&15,i=n==="x"?t:t&3|8;return i.toString(16)})}GenerateIdReplace(n){return this.GenerateId().replaceAll("-",n)}GenerateUrl(n,t=null){let i=this.Paths(n);(i==null||i.length==0||i[0].length==0)&&this.$Throw("Url can not be null or empty");i=i.map(n=>n.replace(/\/+$/g,"").replace(/^\/+/g,"/"));let r=this.ToJoin(i,"/");return t!=null&&(t=this.ConvertTo_UrlQuery(t),r+=`?${t}`),r}$BaseNavigateTo(n){this.$NavigateToFunc?this.$NavigateToFunc(n):window.location.href=n}NavigateToRoot(){return this.$BaseNavigateTo("/"),this}NavigateTo(n,t=null){let i=this.GenerateUrl(n,t);return this.$BaseNavigateTo(i),this}$BaseNavigateBlank(n){let t=document.createElement("a");t.href=n;t.target="_blank";t.rel="noopener noreferrer";t.click()}NavigateBlank(n,t=null){let i=this.GenerateUrl(n,t);return this.$BaseNavigateBlank(i),this}ForEachObject(n,t){for(let i of Object.getOwnPropertyNames(n))if(!i.match(/^$/g)){let r=n[i];t!=null&&t.call(this,i,r)}}DeepObjectExtend(n,t,i=10){if(i==0)return{...n,...t};let r=Object.keys(t);for(let u=0;u<r.length;u++){let f=r[u];if(f in n)if(typeof t[f]!="object")n[f]=t[f];else{let r={...this.DeepObjectExtend(n[f],t[f],i-1)};n[f]=r}else n[f]=t[f]}return n}ToDateInfo(n){n??=new Date;return this.$CreateDateInfo(n)}ToDateText(n,t){n=this.$CreateDateInfo(n);t??={};typeof t=="string"&&(t={Format:t});t.DateJoinChar??=this.$DefaultDateJoinChar;t.Format??=`yyyy${t.DateJoinChar}MM${t.DateJoinChar}dd`;let i=t.Format;return i=i.replaceAll("yyyy",n.Year.toString().padStart(4,"0")),i=i.replaceAll("MM",n.Month.toString().padStart(2,"0")),i=i.replaceAll("dd",n.Day.toString().padStart(2,"0")),t.Format=i,i}ToDateTimeText(n,t){t??={};typeof t=="string"&&(t={Format:t});t.DateJoinChar??=this.$DefaultDateJoinChar;t.Format??=`yyyy${t.DateJoinChar}MM${t.DateJoinChar}dd HH:mm:ss`;t={...t};n=this.$CreateDateInfo(n);this.ToDateText(n,t);let i=t.Format;return i=i.replaceAll("HH",n.Hour.toString().padStart(2,"0")),i=i.replaceAll("mm",n.Minute.toString().padStart(2,"0")),i.replaceAll("ss",n.Second.toString().padStart(2,"0"))}$CreateDateInfo(n){if(n??=new Date,typeof n=="string"&&(n=new Date(n)),n instanceof Date==!1)return n;return{Date:n,Year:n.getFullYear(),Month:n.getMonth()+1,Day:n.getDate(),Hour:n.getHours(),Minute:n.getMinutes(),Second:n.getSeconds()}}ConvertTo_UrlQuery(n){if(typeof n=="string")return n;let t=[];this.ForEachObject(n,(n,i)=>{t.push(`${n}=${i}`)});return t.join("&")}ClearUrl(n){return n.replace(/^\/+|\/+$/g,"")}ToJoin(n,t="."){let i=this.Paths(n);return i.join(t)}Paths(...n){if(!Array.isArray(n))return[n];let t=[];for(let i of n)if(i!=null){if(!Array.isArray(i)){t.push(i);continue}i.length!=0&&t.push(...this.Paths(...i))}return t}IsPathType(n){if(Array.isArray(n)){for(let t of n){let n=this.IsPathType(t);if(!n)return!1}return!0}return typeof n=="string"?!0:!1}$Throw(n){throw new Error(n);}$Error(n){console.error(n)}}class i extends FuncBase{Dom;DomName=null;Parent=null;Children=[];ElementDeep=0;NodeDeep=0;constructor(n){super();this.Dom=n}Query(n,t){return this.$RCS_QueryChildrens(this,n,t)}Selector(n){return this.Dom.querySelector(n)}SelectorAll(n){return this.Dom.querySelectorAll(n)}$RCS_QueryChildrens(n,t,i){if(t==null)return null;t=this.Paths(t);t.length==1&&(t=t[0]);let r=[];for(let u of n.Children){if(Array.isArray(t)){let n=[...t],f=n.shift();if(u.DomName==f){n.length==1&&(n=n[0]);let t=this.$RCS_QueryChildrens(u,n,i);if(t!=null){r.push(...t);continue}}}else if(u.DomName==t&&(r.push(u),i.Mode=="Multi"))continue;let n=this.$RCS_QueryChildrens(u,t,i);n!=null&&r.push(...n)}return r}}class u{$Root=null;$RootNode=null;$Nodes=[];$QueryDomName=null;IsInited=false;WithRoot(n){return this.$Root=document.querySelector(n),this}WithDomName(n){return this.$QueryDomName=n,this}Init(n=false){return this.IsInited&&!n?this:(this.$Root??=document.body,this.$RootNode=new i(this.$Root),this.$RCS_Visit(this.$Root,this.$RootNode,0),this.$Nodes=this.$Nodes.sort((n,t)=>n.NodeDeep-t.NodeDeep),this.IsInited=!0,this)}Query(n,r){return t.IsInited||t.Init(),r==null?r={Mode:"Multi"}:r instanceof i&&(r={Mode:"Multi",TargetNode:r}),r.TargetNode==null&&(r.TargetNode=this.$RootNode),r.TargetNode.Query(n,r)}Using(n,t,i){let r=this.Query(n,{Mode:"Multi",TargetNode:i});return r!=null&&r.length>0&&t({QueryNodes:r}),this}$RCS_Visit(n,t,i){let u=this.$AddNode(n,t,i);u??=t;let r=n.children;if(n instanceof HTMLTemplateElement&&(r=n.content.children),r!=null&&r.length!=0)for(let n=0;n<r.length;n++){let t=r[n];t instanceof HTMLElement&&this.$RCS_Visit(t,u,i+1)}}$AddNode(n,t,r){if(this.$QueryDomName!=null&&!n.matches(`[${this.$QueryDomName}]`))return null;let f=n.getAttribute(this.$QueryDomName),u=new i(n);return u.DomName=f,u.ElementDeep=r,this.$Nodes.push(u),t!=null&&(u.Parent=t,u.NodeDeep=t.NodeDeep+1,t.Children.push(u)),u}}var t=new u;export class FileItem{$Store;constructor(n,t="none"){n==null?this.$Store=r({}):(this.$Store=r({FileId:(new FuncBase).GenerateId(),File:n,ConvertType:t,Base64:null,Buffer:null}),this.$ConvertFile())}get FileId(){return this.$Store.FileId}set FileId(n){this.$Store.FileId=n}get File(){return this.$Store.File}set File(n){this.$Store.File=n}get ConvertType(){return this.$Store.ConvertType}set ConvertType(n){this.$Store.ConvertType=n}get Base64(){return this.$Store.Base64}set Base64(n){this.$Store.Base64=n}get Buffer(){return this.$Store.Buffer}set Buffer(n){this.$Store.Buffer=n}get InnerStore(){return this.$Store}Clear(){this.$Store.Base64=null;this.$Store.Buffer=null;this.$Store.File=null}From(n){this.$Store=n.InnerStore}$ConvertFile(){if(this.ConvertType!=null){let n=[];n=Array.isArray(this.ConvertType)?this.ConvertType:[this.ConvertType];for(let t=0;t<n.length;t++){let i=n[t];switch(i){case"base64":this.$ConvertBase64();break;case"buffer":this.$ConvertBuffer()}}}}$ConvertBase64(n=false){if(this.File==null||this.Base64!=null&&n==!1)return this;let t=new FileReader;return t.readAsDataURL(this.File),t.onload=()=>this.Base64=t.result,this}$ConvertBuffer(){let n=new FileReader;n.readAsArrayBuffer(this.File);n.onload=()=>this.Buffer=n.result}}export class ApiStore extends FuncBase{#ApiDomain=null;#RootRoute=null;#AccessToken=null;#RefreshToken=null;#HeaderFuncs=[];#OnEventFunc={};#OnEventName={ApiStore:{AddApi:"AddApi",UpdateStore:"UpdateStore",AddStore:"AddStore",SetStore:"SetStore"}};#OnSuccess;#OnError;#OnComplete;#ExportSuccessStore;#Store={FileStore:{}};#Func_ConvertTo_FormData=[];$ApiStore={};constructor(){super();this.SetStore("api",this.$ApiStore)}get ApiDomain(){return this.#ApiDomain==null?null:this.ClearUrl(this.#ApiDomain)}set ApiDomain(n){this.#ApiDomain=this.ClearUrl(n)}get OnEventName(){return this.#OnEventName}get #EventName(){return this.OnEventName.ApiStore}get Store(){return this.#Store}set Store(n){this.#Store=n}get FileStore(){return this.Store.FileStore}WithAccessToken(n){return this.#AccessToken=n,this}WithRefreshToken(n){return this.#RefreshToken=n,this}WithApiDomain(n){return this.ApiDomain=n,this}WithRootRoute(n){return this.#RootRoute=n,this}WithHeader(n){return this.#HeaderFuncs.push(n),this}WithOnSuccess(n){return this.#OnSuccess=n,this}WithOnError(n){return this.#OnError=n,this}WithOnComplete(n){return this.#OnComplete=n,this}WithExportSuccessStore(n){return this.#ExportSuccessStore=n,this}WithConvertTo_FormParam(n){return this.#Func_ConvertTo_FormData.push(n),this}ClearConvertTo_FormParam(){return this.#Func_ConvertTo_FormData=[],this}ConvertTo_ApiUrl(n,t=null){let i=n;return this.ApiDomain==null||i.includes("http")||(i=`${this.ApiDomain}/${this.ClearUrl(i)}`),t!=null&&(i=`${i}?${this.ConvertTo_UrlQuery(t)}`),i}AddApi(n){for(let t in n){let r=n[t],i={ApiKey:t,...r};this.$ApiStore[t]=i;this.$EventTrigger(this.#EventName.AddApi,i)}return this}ApiCall(n,t=null){return this.$BaseApiCall(n,t,!1),this}ApiCall_Form(n,t=null){return this.$BaseApiCall(n,t,!0),this}$BaseApiCall(n,t,i){let r=this.$ApiStore[n];r==null&&this.$Throw(`Api setting not found of "${n}"`);let u=t?.Query??r.Query,f=t?.Body??r.Body,e=t?.File??r.File;typeof u=="function"&&(u=u());typeof f=="function"&&(f=f());typeof e=="function"&&(e=e());let s=t?.IsUpdateStore??r.IsUpdateStore??!0,h=this.ConvertTo_ApiUrl(r.Url,u),o=this.$GenerateFetchRequest(r,f,e,i);r.IsCalling=!0;r.OnCalling?.call(this,o);t?.OnCalling?.call(this,o);fetch(h,o).then(async n=>{if(!n.ok)throw n;let i=await this.$ProcessApiReturn(n);if(s){this.#ExportSuccessStore!=null&&(i=this.#ExportSuccessStore?.call(this,i,n));let t=r.ApiKey;this.UpdateStore(t,i)}return r.IsSuccess=!0,r.IsError=!1,r.OnSuccess?.call(this,i,n),t?.OnSuccess?.call(this,i,n),this.#OnSuccess?.call(this,i,n),{ConvertResult:i,ApiResponse:n}}).catch(n=>{r.IsError=!0,r.IsSuccess=!1,this.$Error(n.message),r.OnError?.call(this,n),t?.OnError?.call(this,n),this.#OnError?.call(this,n)}).then(n=>{r.IsCalling=!1,r.IsComplete=!0,n instanceof Object?(r.OnComplete?.call(this,n.ConvertResult,n.ApiResponse),t?.OnComplete?.call(this,n.ConvertResult,n.ApiResponse),this.#OnComplete?.call(this,n.ConvertResult,n.ApiResponse)):(r.OnComplete?.call(this),t?.OnComplete?.call(this),this.#OnComplete?.call(this,null,null))})}$GenerateFetchRequest(n,t,i,r){let u=new Headers;if(u.set("Authorization",`Bearer ${this.#AccessToken}`),this.#HeaderFuncs.length>0)for(let n of this.#HeaderFuncs)n(u);let f={method:n.Method,headers:u};if(r){let n=this.$ConvertTo_FormData(t,new FormData);n=this.$ConvertTo_FormFile(i,n);f.body=n;f.method="POST"}else u.set("content-type","application/json"),n.Method!="GET"&&(f.body=JSON.stringify(t??{}));return f}UseFormJsonBody(n="Body"){return this.WithConvertTo_FormParam(t=>{let i={};return i[n]=JSON.stringify(t),i}),this}EventAdd_AddApi(n){return this.$EventAdd(this.#EventName.AddApi,n),this}EventAdd_UpdateStore(n){return this.$EventAdd(this.#EventName.UpdateStore,n),this}EventAdd_AddStore(n){return this.$EventAdd(this.#EventName.AddStore,n),this}EventAdd_SetStore(n){return this.$EventAdd(this.#EventName.SetStore,n),this}$EventAdd(n,t){n in this.#OnEventFunc==!1&&(this.#OnEventFunc[n]=[]);this.#OnEventFunc[n].push(t)}$EventTrigger(n,t){let i=this.#OnEventFunc[n];if(i!=null)for(let n of i)n(t)}UpdateStore(n,t){return n=this.ToJoin(n),this.$RCS_SetStore(n,t,this.Store,{IsDeepSet:!0}),this.$EventTrigger(this.#EventName.UpdateStore,{Path:n,Data:t}),this}AddStore(n,t=null){return(n=this.ToJoin(n),this.GetStore(n)!=null)?this:(this.$RCS_SetStore(n,t,this.Store,{IsDeepSet:!0}),this.$EventTrigger(this.#EventName.AddStore,{Path:n,Data:t}),this)}SetStore(n,t){return n=this.ToJoin(n),this.$RCS_SetStore(n,t,this.Store,{IsDeepSet:!1}),this.$EventTrigger(this.#EventName.SetStore,{Path:n,Data:t}),this}GetStore(n,t){typeof t=="boolean"&&(t={Clone:t});t??={};t.Clone??=!1;t.CreateIfNull??=!1;t.DefaultValue==null&&(t.DefaultValue={});n=this.ToJoin(n);let i=this.$RCS_GetStore(n,this.Store,{CreateIfNull:t.CreateIfNull,DefaultValue:t.DefaultValue});if(t.Clone){let n={},t=Object.getOwnPropertyNames(i);for(let r of t)r.match(/^\$/g)||(n[r]=i[r]);return n}return i}ClearStore(n){let t=this.GetStore(n);if(t==null)return this;let i=Object.getOwnPropertyNames(t);for(let n of i)if(!n.match(/^\$/g)){let i=t[n];if(typeof i!="function"){if(Array.isArray(i)){i.splice(0,i.length);continue}t[n]=null}}return this}$RCS_GetStore(n,t,i){if(t==null)return null;let r=n.split("."),u=r.shift();t[u]==null&&i.CreateIfNull&&(t[u]=Array.isArray(i.DefaultValue)?[...i.DefaultValue]:typeof i.DefaultValue=="object"?{...i.DefaultValue}:i.DefaultValue);let f=t[u];if(r.length==0)return f;let e=r.join(".");return this.$RCS_GetStore(e,f,i)}$RCS_SetStore(n,t,i,r={IsDeepSet:true}){if(n.includes(".")){let f=n.split("."),u=f.shift();i[u]==null&&(i[u]={});let e=i[u],o=f.join(".");return this.$RCS_SetStore(o,t,e,r)}let u=!r.IsDeepSet||i[n]==null||t==null||typeof t!="object";return u?(i[n]=t,t):(this.$DeepSetObject(n,t,i),t)}$DeepSetObject(n,t,i){if(t==null){i[n]=t;return}if(!Array.isArray(t)){this.ForEachObject(t,(t,r)=>{if(Array.isArray(r)||typeof r=="object"){this.$DeepSetObject(t,r,i[n]);return}i[n]==null&&(i[n]={});i[n][t]=r});return}Array.isArray(i[n])||(i[n]=[]);i[n]=t.slice()}AddFileStore(n,t){return t??={},this.FileStore[n]==null&&(this.FileStore[n]=t.Multi==!0?[]:new FileItem),this}Files(n,t=null){let i=this.FileStore[n];if(i==null)return[];Array.isArray(i)||(i=[i]);t!=null&&(i=i.filter(n=>t(n)));return i.map(n=>n.File)}File(n,t=null){let i=this.Files(n,t);return i==null||i.length==0?null:i[0]}AddFile(n,t,i="none"){if(t!=null){this.AddFileStore(n);let r=this.FileStore[n];return Array.isArray(t)?Array.isArray(r)?t.forEach(t=>this.AddFile(n,t)):this.AddFile(n,t[0]):(t instanceof FileItem==!1&&(t=new FileItem(t,i)),Array.isArray(r)?r.push(t):r.From(t)),this}}RemoveFile(n,t){let i=this.FileStore[n];if(i==null)return this;if(Array.isArray(t))t.forEach(t=>this.RemoveFile(n,t));else if(Array.isArray(i)){let n=i.findIndex(n=>n.FileId==t);n>=0&&i.splice(n,1)}else i.Clear();return this}ClearFile(n){let t=this.FileStore[n];return t==null?this:(Array.isArray(t)?t.splice(0,t.length):t.Clear(),this)}$ProcessApiReturn(n){let t=n.headers.get("content-type");return t.includes("application/json")?n.json():t.includes("text")?n.text():new Promise(t=>{t(n)})}NavigateToRoot(){let n=this.#RootRoute??"/";return super.$BaseNavigateTo(n),this}$ConvertTo_FormData(n,t){return(t??=new FormData,n==null)?t:(this.#Func_ConvertTo_FormData.forEach(i=>{n=i(n,t)}),n instanceof FormData)?n:(this.ForEachObject(n,(n,i)=>{t.append(n,i)}),t)}$ConvertTo_FormFile(n,t){if(t??=new FormData,n==null)return t;if(Array.isArray(n)||n instanceof File||n instanceof FileItem)return this.$AppendFileToFormData("Files",t,n),t;let i=Object.keys(n);for(let r=0;r<i.length;r++){let u=i[r],f=n[u];this.$AppendFileToFormData(u,t,f)}return t}$AppendFileToFormData(n,t,i){if(Array.isArray(i))for(let r=0;r<i.length;r++)this.$AppendFileToFormData(n,t,i[r]);else i instanceof File?t.append(n,i):t.append(n,i.File);return t}}import{watch as f}from"vue";import{createApp as e,reactive as r}from"vue";export class VueStore extends ApiStore{$VueProxy=null;$VueOption={methods:{},components:{},computed:{}};$VueApp=null;$VueUse=[];$CoreStore="app";$MountedFuncs=[];$Directive=[];constructor(){super();this.#Setup()}#Setup(){this.EventAdd_AddApi(n=>{this.AddStore(n.ApiKey)}).EventAdd_UpdateStore(()=>{this.ForceUpdate()}).EventAdd_AddStore(()=>{this.ForceUpdate()}).EventAdd_SetStore(()=>{this.ForceUpdate()}).AddStore(this.$CoreStore,{}).WithMounted(()=>{this.UpdateStore([this.$CoreStore,"IsMounted"],!0)})}get Store(){return this.$VueProxy!=null?this.$VueProxy:super.Store}set Store(n){super.Store=n}WithVueOption(n={}){return this.$VueOption=this.DeepObjectExtend(this.$VueOption,n),this}WithMounted(n=()=>{}){return this.$MountedFuncs.push(n),this}WithComponent(n={}){return this.$VueOption.components=this.DeepObjectExtend(this.$VueOption.components,n),this}WithVueUse(...n){for(let t of n)this.$VueUse.push(t);return this}WithDirective(n,t){return this.$Directive.push({Name:n,Directive:t}),this}ForceUpdate(){return this.$VueProxy?.$forceUpdate(),this}Refs(t){return this.$VueProxy?this.$VueProxy.$refs[n.ToJoin(t)]:null}}export class VueCommand extends VueStore{$IsInited=false;$QueryDomName=null;WithQueryDomName(n){return this.$QueryDomName=n,t.WithDomName(this.$QueryDomName),this}AddV_Text(t,i){let r=this.$ConvertCommandOption(t,i);return typeof r.Target!="function"&&n.AddStore(r.Target),this.$AddCommand(t,"v-text",r),this}AddV_Model(n,t,i){let r=this.$ConvertCommandOption(t);return i??={},i.DefaultValue??=null,r.CommandKey=i.ModelValue,this.AddStore(t,i.DefaultValue),this.$AddCommand(n,"v-model",r),this}AddV_Slot(n,t,i){let r=this.$ConvertCommandOption(i);return r.CommandKey=t,this.$AddCommand(n,`v-slot`,r),this}AddV_For(t,i,r){let u=this.$ConvertCommandOption(t,i);r&&(r=this.ToJoin(r),/^\(/.test(r)||(r=`(${r}`),/\)$/.test(r)||(r+=")"),u.TargetHead=`${r} in `);let f=n.ToJoin(u.Target);return f.includes("in")||(u.TargetHead??="(item, index) in "),this.$AddCommand(t,"v-for",u),this}AddV_If(n,t){let i=this.$ConvertCommandOption(n,t);return this.$AddCommand(n,"v-if",i),this}AddV_ElseIf(n,t){let i=this.$ConvertCommandOption(n,t);return this.$AddCommand(n,"v-else-if",i),this}AddV_Else(n){let t=this.$ConvertCommandOption(n);return t.Target="",this.$AddCommand(n,"v-else",t),this}AddV_Show(n,t){let i=this.$ConvertCommandOption(n,t);return this.$AddCommand(n,"v-show",i),this}AddV_Bind(n,t,i,r){let u=this.$ConvertCommandOption(n,i);return r&&(u.FuncArgs=r),u.CommandKey=t,this.$AddCommand(n,"v-bind",u),this}AddV_On(n,t,i,r){let u=this.$ConvertCommandOption(n,i);return r&&(u.FuncArgs=r),u.FuncAction=!1,u.CommandKey=t,this.$AddCommand(n,`v-on`,u),this}AddV_Watch(t,i,r=false,u={}){let e={handler:i,deep:r,...u};return n.WithMounted(()=>{n.AddStore(t),f(()=>n.GetStore(t),i,e)}),this}AddV_Function(t,i){return this.$IsInited&&!Array.isArray(t)?this.$VueOption.methods[t]=i:n.UpdateStore(t,i),this}AddV_OnChange(n,t,i){return this.AddV_On(n,"change",t,i),this}AddV_Click(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i),this.AddV_On(n,"click",r),this}AddV_FilePicker(n,t){let i=null,u=null,f="none",r=!1;return typeof t=="string"?i=t:(i=t.Store,f=t.ConvertType,r=t.Multiple,u=Array.isArray(t.Accept)?t.Accept.join(" "):t.Accept),this.AddFileStore(i,{Multi:r}),this.AddV_Click(n,()=>{let n=document.createElement("input");n.type="file";u!=null&&(n.accept=u);r!=null&&(n.multiple=r);n.onchange=()=>{if(n.files!=null&&n.files.length!=0){let t=n.files;for(let n=0;n<t.length;n++){let r=t[n];this.AddFile(i,r,f)}}};n.click()}),this}AddV_Tree(i,r,u){let f=[],e=this.Paths(i);this.$ParseTreeSet(e,r,f);let o={"v-text":(t,i)=>{n.AddV_Text(i.TargetDom,i.TargetValue)},"v-model":(t,i)=>{if(typeof t.StoreValue=="function"){n.$Error(`v-model command value must be a string or string[], path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Model(i.TargetDom,i.TargetPath,{ModelValue:t.CommandKey})},"v-for":(t,i)=>{n.AddV_For(i.TargetDom,i.TargetValue,t.CommandKey)},"v-if":(t,i)=>{n.AddV_If(i.TargetDom,i.TargetValue)},"v-else-if":(t,i)=>{n.AddV_ElseIf(i.TargetDom,i.TargetValue)},"v-else":(t,i)=>{n.AddV_Else(i.TargetDom)},"v-show":(t,i)=>{n.AddV_Show(i.TargetDom,i.TargetValue)},"v-bind":(t,i)=>{n.AddV_Bind(i.TargetDom,t.CommandKey,i.TargetValue,t.Params)},"v-on":(t,i)=>{n.AddV_On(i.TargetDom,t.CommandKey,i.TargetValue,t.Params)},"v-slot":(t,i)=>{if(Array.isArray(t.StoreValue)||typeof t.StoreValue=="function"){n.$Error(`v-slot command value must be a string, path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Slot(i.TargetDom,t.CommandKey,i.TargetPath)},watch:t=>{if(typeof t.StoreValue!="function"){n.$Error(`watch command value must be a function, path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Watch(t.DomPaths,t.StoreValue)},func:t=>{if(typeof t.StoreValue!="function"){n.$Error(`func command value must be a function, path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Function(["event",...t.DomPaths,t.CommandKey],t.StoreValue)},using:n=>{typeof n.StoreValue=="function"&&n.StoreValue(n.DomPaths)}};for(let i of f){let f=o[i.Command];if(f==null){n.$Error(`${i.Command} command is not allowed, path: ${this.ToJoin(i.DomPaths)}`);continue}if(u?.UseDeepQuery){let n=t.Query(i.DomPaths,{Mode:"DeepMulti"});i.Nodes=n}let s=u?.UseDeepQuery?i.Nodes:i.DomPaths,r=[],e;typeof i.StoreValue!="function"&&(u?.UseTreePath&&(r=[...i.TreePaths]),u?.UseDomStore||i.StoreValue=="."?r.push(i.DomName):i.StoreValue!=null&&i.StoreValue!=""&&(r=this.Paths(r,i.StoreValue)));e=r.length>0?r:i.StoreValue;f(i,{TargetDom:s,TargetPath:r,TargetValue:e})}return this}$ParseTreeSet(t,i,r){let u=Object.keys(i),f=/^(.+?)\(([^)]*)\)$/;for(let e=0;e<u.length;e++){let o=u[e],h=i[o],c=[...t],a=[...t],y=a.pop();if(!o.includes(":")){let n=o.match(f),t=null;n&&n.length>=3&&(o=n[1],t=n[2]);r.push({Command:o,StoreValue:h,TreePaths:a,DomPaths:c,DomName:y,CommandKey:t});continue}let s=o.split(":");if(o.length<2){n.$Error(`command ${o} invalid`);continue}o=s.shift();let v=null;if(s.length>0){let t=s.pop(),n=t.match(f);n&&n.length>=3?(s.push(n[1]),v=n[2]):s.push(t)}let l=n.ToJoin(s,":");if(o==""){typeof h!="function"?this.$ParseTreeSet([...t,l],h,r):r.push({Command:"using",CommandKey:null,StoreValue:h,TreePaths:[...c],DomPaths:[...c,l],DomName:l,Params:v});continue}r.push({Command:o,CommandKey:l,StoreValue:h,TreePaths:a,DomPaths:c,DomName:y,Params:v})}}AddV_Property(n,t){if(n!=null){let i=this.Store;n=this.ToJoin(n);let r=n;if(n.includes(".")){let t=n.split(".");r=t.pop();let u=t.join(".");i=this.GetStore(u,{CreateIfNull:!0})}let u=this.$BaseAddProperty(i,r,t);if(t.Bind){Array.isArray(t.Bind)||(t.Bind=[t.Bind]);for(let i of t.Bind)i!=null&&this.AddV_Property(i,{Target:n});u.Bind=t.Bind}return this}}$BaseAddProperty(n,t,i){let f=this,u={get(){return i.get?i.get():this.$get(t)},set(n){if(i.set){i.set(n);return}this.$set(t,n)}};i.get&&(u.get=i.get);i.set!=null&&(u.set=i.set);let r=Object.defineProperty(n,t,u);return r.$properties??={},r.$properties[t]={...i},r.$get??=n=>{let t=r.$properties[n];return t?.Target==null?t[`$${n}`]:f.GetStore(t.Target)},r.$set??=(n,t)=>{let i=r.$properties[n];i?.Target?f.SetStore(i.Target,t):i[`$${n}`]=t},r[t]==null&&i.Value!=null&&(r[t]=i.Value),r}$ConvertCommandOption(n,t){if(t==null)if(this.IsPathType(n))return{Target:n,FuncAction:!1};else{let t=n,i=t.map(n=>n.DomName);return{Target:i,FuncAction:!1}}return typeof t=="string"||typeof t=="function"||Array.isArray(t)?{Target:t,FuncAction:!0}:(t.FuncAction??=!0,t)}$AddCommand(n,r,u){if(n!=null){Array.isArray(n)||(n=[n]);let o=n[0]instanceof i,e;e=o?n:t.Query(n);let f=u.Target;if(typeof f=="function"){let t=n;if(f=this.$GenerateEventFunction(t,f,r),u.FuncArgs){let n=this.ToJoin(u.FuncArgs,",");/^\(/.test(n)||(n=`(${n}`);/\)$/.test(n)||(n+=")");f+=n}else u.FuncAction&&(f+=`()`)}else f=this.ToJoin(f);u.TargetHead&&(f=u.TargetHead+f);u.TargetTail&&(f+=u.TargetTail);u.CommandKey&&(r+=`:${u.CommandKey}`);for(let n=0;n<e.length;n++){let t=e[n],i=t.Dom;this.$SetAttribute(i,r,f)}}}$SetAttribute(n,t,i){if(n==null){let n=`Dom Element is null. ${i}`;console.warn(n);return}n.setAttribute(t,i)}$RandomFuncName(n){return`${n}${this.GenerateIdReplace("")}`.replace(/[-:.]/g,"_")}$GenerateEventFunction(n,t,i){let u=this.$RandomFuncName(`${i}_`);n=this.Paths(n);let r=["event",...n,u];return this.AddV_Function(r,t),this.ToJoin(r)}}export class VueModel extends VueCommand{$NativeWarn;$IsEnableVueWarn;$MountId=null;Id;constructor(){super();this.Id=this.GenerateId();this.$MountId="app";this.WithVueWarn(!1);this.WithLifeCycleDirective()}WithMountId(n){return this.$MountId=n,this}WithVueWarn(n){return this.$IsEnableVueWarn=n,this.$NativeWarn=console.warn,console.warn=(...n)=>{n!=null&&n.length!=0&&(n[0].toLowerCase().includes("[vue warn]")&&this.$IsEnableVueWarn==!1||this.$NativeWarn(n))},this}WithLifeCycleDirective(){this.WithDirective("on-mounted",{mounted(n,t,i){typeof t.value=="function"&&t.value(i.props,i.el,i)}});this.WithDirective("on-unmounted",{unmounted(n,t,i){typeof t.value=="function"&&t.value(i.props,i.el,i)}})}Init(){if(this.$IsInited)return this;this.Store=r(this.Store);let n=this.Store,t=this.$MountedFuncs;this.$VueApp=e({...this.$VueOption,data(){return n},mounted:()=>{for(let n of t)n()}});for(let n of this.$VueUse)this.$VueApp.use(n);for(let n of this.$Directive)this.$VueApp.directive(n.Name,n.Directive);return this.$VueProxy=this.$VueApp.mount(`#${this.$MountId}`),this.$IsInited=!0,this}Using(n=()=>{}){return n(),this}UsingVueApp(n){return n?.call(this,this.$VueApp),this.$VueApp.directive,this}AddV_OnMounted(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($props, $el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-mounted`,r),this}AddV_OnUnMounted(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($props, $el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-unmounted`,r),this}}const n=new VueModel;window.Model=n;export{u as DomQueryer,t as Queryer,n as Model};
1
+ export class FuncBase{$NavigateToFunc;$DefaultDateJoinChar;constructor(){this.$NavigateToFunc=null;this.WithDateTextJoinChar("-")}WithNavigateTo(n){return this.$NavigateToFunc=n,this}WithDateTextJoinChar(n){return this.$DefaultDateJoinChar=n,this}GenerateId(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,n=>{let t=crypto.getRandomValues(new Uint8Array(1))[0]&15,i=n==="x"?t:t&3|8;return i.toString(16)})}GenerateIdReplace(n){return this.GenerateId().replaceAll("-",n)}GenerateUrl(n,t=null){let i=this.Paths(n);(i==null||i.length==0||i[0].length==0)&&this.$Throw("Url can not be null or empty");i=i.map(n=>n.replace(/\/+$/g,"").replace(/^\/+/g,"/"));let r=this.ToJoin(i,"/");return t!=null&&(t=this.ConvertTo_UrlQuery(t),r+=`?${t}`),r}$BaseNavigateTo(n){this.$NavigateToFunc?this.$NavigateToFunc(n):window.location.href=n}NavigateToRoot(){return this.$BaseNavigateTo("/"),this}NavigateTo(n,t=null){let i=this.GenerateUrl(n,t);return this.$BaseNavigateTo(i),this}$BaseNavigateBlank(n){let t=document.createElement("a");t.href=n;t.target="_blank";t.rel="noopener noreferrer";t.click()}NavigateBlank(n,t=null){let i=this.GenerateUrl(n,t);return this.$BaseNavigateBlank(i),this}ForEachObject(n,t){for(let i of Object.getOwnPropertyNames(n))if(!i.match(/^$/g)){let r=n[i];t!=null&&t.call(this,i,r)}}DeepObjectExtend(n,t,i=10){if(i==0)return{...n,...t};let r=Object.keys(t);for(let u=0;u<r.length;u++){let f=r[u];if(f in n)if(typeof t[f]!="object")n[f]=t[f];else{let r={...this.DeepObjectExtend(n[f],t[f],i-1)};n[f]=r}else n[f]=t[f]}return n}ToDateInfo(n){n??=new Date;return this.$CreateDateInfo(n)}ToDateText(n,t){n=this.$CreateDateInfo(n);t??={};typeof t=="string"&&(t={Format:t});t.DateJoinChar??=this.$DefaultDateJoinChar;t.Format??=`yyyy${t.DateJoinChar}MM${t.DateJoinChar}dd`;let i=t.Format;return i=i.replaceAll("yyyy",n.Year.toString().padStart(4,"0")),i=i.replaceAll("MM",n.Month.toString().padStart(2,"0")),i=i.replaceAll("dd",n.Day.toString().padStart(2,"0")),t.Format=i,i}ToDateTimeText(n,t){t??={};typeof t=="string"&&(t={Format:t});t.DateJoinChar??=this.$DefaultDateJoinChar;t.Format??=`yyyy${t.DateJoinChar}MM${t.DateJoinChar}dd HH:mm:ss`;t={...t};n=this.$CreateDateInfo(n);this.ToDateText(n,t);let i=t.Format;return i=i.replaceAll("HH",n.Hour.toString().padStart(2,"0")),i=i.replaceAll("mm",n.Minute.toString().padStart(2,"0")),i.replaceAll("ss",n.Second.toString().padStart(2,"0"))}$CreateDateInfo(n){if(n??=new Date,typeof n=="string"&&(n=new Date(n)),n instanceof Date==!1)return n;return{Date:n,Year:n.getFullYear(),Month:n.getMonth()+1,Day:n.getDate(),Hour:n.getHours(),Minute:n.getMinutes(),Second:n.getSeconds()}}ConvertTo_UrlQuery(n){if(typeof n=="string")return n;let t=[];this.ForEachObject(n,(n,i)=>{t.push(`${n}=${i}`)});return t.join("&")}ClearUrl(n){return n.replace(/^\/+|\/+$/g,"")}ToJoin(n,t="."){let i=this.Paths(n);return i.join(t)}Paths(...n){if(!Array.isArray(n))return[n];let t=[];for(let i of n)if(i!=null){if(!Array.isArray(i)){t.push(i);continue}i.length!=0&&t.push(...this.Paths(...i))}return t}IsPathType(n){if(Array.isArray(n)){for(let t of n){let n=this.IsPathType(t);if(!n)return!1}return!0}return typeof n=="string"?!0:!1}$Throw(n){throw new Error(n);}$Error(n){console.error(n)}}class i extends FuncBase{Dom;DomName=null;Parent=null;Children=[];ElementDeep=0;NodeDeep=0;constructor(n){super();this.Dom=n}Query(n,t){return this.$RCS_QueryChildrens(this,n,t)}Selector(n){return this.Dom.querySelector(n)}SelectorAll(n){return this.Dom.querySelectorAll(n)}$RCS_QueryChildrens(n,t,i){if(t==null)return null;t=this.Paths(t);t.length==1&&(t=t[0]);let r=[];for(let u of n.Children){if(Array.isArray(t)){let n=[...t],f=n.shift();if(u.DomName==f){n.length==1&&(n=n[0]);let t=this.$RCS_QueryChildrens(u,n,i);if(t!=null){r.push(...t);continue}}}else if(u.DomName==t&&(r.push(u),i.Mode=="Multi"))continue;let n=this.$RCS_QueryChildrens(u,t,i);n!=null&&r.push(...n)}return r}}class u{$Root=null;$RootNode=null;$Nodes=[];$QueryDomName=null;IsInited=false;WithRoot(n){return this.$Root=document.querySelector(n),this}WithDomName(n){return this.$QueryDomName=n,this}Init(n=false){return this.IsInited&&!n?this:(this.$Root??=document.body,this.$RootNode=new i(this.$Root),this.$RCS_Visit(this.$Root,this.$RootNode,0),this.$Nodes=this.$Nodes.sort((n,t)=>n.NodeDeep-t.NodeDeep),this.IsInited=!0,this)}Query(n,r){return t.IsInited||t.Init(),r==null?r={Mode:"Multi"}:r instanceof i&&(r={Mode:"Multi",TargetNode:r}),r.TargetNode==null&&(r.TargetNode=this.$RootNode),r.TargetNode.Query(n,r)}Using(n,t,i){let r=this.Query(n,{Mode:"Multi",TargetNode:i});return r!=null&&r.length>0&&t({QueryNodes:r}),this}$RCS_Visit(n,t,i){let u=this.$AddNode(n,t,i);u??=t;let r=n.children;if(n instanceof HTMLTemplateElement&&(r=n.content.children),r!=null&&r.length!=0)for(let n=0;n<r.length;n++){let t=r[n];t instanceof HTMLElement&&this.$RCS_Visit(t,u,i+1)}}$AddNode(n,t,r){if(this.$QueryDomName!=null&&!n.matches(`[${this.$QueryDomName}]`))return null;let f=n.getAttribute(this.$QueryDomName),u=new i(n);return u.DomName=f,u.ElementDeep=r,this.$Nodes.push(u),t!=null&&(u.Parent=t,u.NodeDeep=t.NodeDeep+1,t.Children.push(u)),u}}var t=new u;export class FileItem{OnChangeBase64;OnChangeBuffer;$Store;constructor(n,t="none"){n==null?this.$Store=r({}):(this.$Store=r({FileId:(new FuncBase).GenerateId(),File:n,ConvertType:t,Base64:null,Buffer:null}),this.$ConvertFile())}get FileId(){return this.$Store.FileId}set FileId(n){this.$Store.FileId=n}get File(){return this.$Store.File}set File(n){this.$Store.File=n}get ConvertType(){return this.$Store.ConvertType}set ConvertType(n){this.$Store.ConvertType=n}get Base64(){return this.$Store.Base64}set Base64(n){this.$Store.Base64=n;this.OnChangeBase64?.call(this,this.$Store.Base64)}get Buffer(){return this.$Store.Buffer}set Buffer(n){this.$Store.Buffer=n;this.OnChangeBuffer?.call(this,this.$Store.Buffer)}get InnerStore(){return this.$Store}Clear(){this.$Store.Base64=null;this.$Store.Buffer=null;this.$Store.File=null}From(n){this.$Store=n.InnerStore}$ConvertFile(){if(this.ConvertType!=null){let n=[];n=Array.isArray(this.ConvertType)?this.ConvertType:[this.ConvertType];for(let t=0;t<n.length;t++){let i=n[t];switch(i){case"base64":this.$ConvertBase64();break;case"buffer":this.$ConvertBuffer()}}}}$ConvertBase64(n=false){if(this.File==null||this.Base64!=null&&n==!1)return this;let t=new FileReader;return t.readAsDataURL(this.File),t.onload=()=>this.Base64=t.result,this}$ConvertBuffer(){let n=new FileReader;n.readAsArrayBuffer(this.File);n.onload=()=>this.Buffer=n.result}}export class ApiStore extends FuncBase{#ApiDomain=null;#RootRoute=null;#AccessToken=null;#RefreshToken=null;#HeaderFuncs=[];#OnEventFunc={};#OnEventName={ApiStore:{AddApi:"AddApi",UpdateStore:"UpdateStore",AddStore:"AddStore",SetStore:"SetStore"}};#OnSuccess;#OnError;#OnComplete;#ExportSuccessStore;#Store={FileStore:{}};#Func_ConvertTo_FormData=[];$ApiStore={};constructor(){super();this.SetStore("api",this.$ApiStore)}get ApiDomain(){return this.#ApiDomain==null?null:this.ClearUrl(this.#ApiDomain)}set ApiDomain(n){this.#ApiDomain=this.ClearUrl(n)}get OnEventName(){return this.#OnEventName}get #EventName(){return this.OnEventName.ApiStore}get Store(){return this.#Store}set Store(n){this.#Store=n}get FileStore(){return this.Store.FileStore}WithAccessToken(n){return this.#AccessToken=n,this}WithRefreshToken(n){return this.#RefreshToken=n,this}WithApiDomain(n){return this.ApiDomain=n,this}WithRootRoute(n){return this.#RootRoute=n,this}WithHeader(n){return this.#HeaderFuncs.push(n),this}WithOnSuccess(n){return this.#OnSuccess=n,this}WithOnError(n){return this.#OnError=n,this}WithOnComplete(n){return this.#OnComplete=n,this}WithExportSuccessStore(n){return this.#ExportSuccessStore=n,this}WithConvertTo_FormParam(n){return this.#Func_ConvertTo_FormData.push(n),this}ClearConvertTo_FormParam(){return this.#Func_ConvertTo_FormData=[],this}ConvertTo_ApiUrl(n,t=null){let i=n;return this.ApiDomain==null||i.includes("http")||(i=`${this.ApiDomain}/${this.ClearUrl(i)}`),t!=null&&(i=`${i}?${this.ConvertTo_UrlQuery(t)}`),i}AddApi(n){for(let t in n){let r=n[t],i={ApiKey:t,...r};this.$ApiStore[t]=i;this.$EventTrigger(this.#EventName.AddApi,i)}return this}ApiCall(n,t=null){return this.$BaseApiCall(n,t,!1),this}ApiCall_Form(n,t=null){return this.$BaseApiCall(n,t,!0),this}$BaseApiCall(n,t,i){let r=this.$ApiStore[n];r==null&&this.$Throw(`Api setting not found of "${n}"`);let u=t?.Query??r.Query,f=t?.Body??r.Body,e=t?.File??r.File;typeof u=="function"&&(u=u());typeof f=="function"&&(f=f());typeof e=="function"&&(e=e());let s=t?.IsUpdateStore??r.IsUpdateStore??!0,h=this.ConvertTo_ApiUrl(r.Url,u),o=this.$GenerateFetchRequest(r,f,e,i);r.IsCalling=!0;r.OnCalling?.call(this,o);t?.OnCalling?.call(this,o);fetch(h,o).then(async n=>{if(!n.ok)throw n;let i=await this.$ProcessApiReturn(n);if(s){r.Export!=!1&&(typeof r.Export=="function"?i=r.Export?.call(this,i,n):this.#ExportSuccessStore!=null&&(i=this.#ExportSuccessStore?.call(this,i,n)));let t=r.ApiKey;this.UpdateStore(t,i)}return r.IsSuccess=!0,r.IsError=!1,r.OnSuccess?.call(this,i,n),t?.OnSuccess?.call(this,i,n),this.#OnSuccess?.call(this,i,n),{ConvertResult:i,ApiResponse:n}}).catch(n=>{r.IsError=!0,r.IsSuccess=!1,this.$Error(n.message),r.OnError?.call(this,n),t?.OnError?.call(this,n),this.#OnError?.call(this,n)}).then(n=>{r.IsCalling=!1,r.IsComplete=!0,n instanceof Object?(r.OnComplete?.call(this,n.ConvertResult,n.ApiResponse),t?.OnComplete?.call(this,n.ConvertResult,n.ApiResponse),this.#OnComplete?.call(this,n.ConvertResult,n.ApiResponse)):(r.OnComplete?.call(this),t?.OnComplete?.call(this),this.#OnComplete?.call(this,null,null))})}$GenerateFetchRequest(n,t,i,r){let u=new Headers;if(u.set("Authorization",`Bearer ${this.#AccessToken}`),this.#HeaderFuncs.length>0)for(let n of this.#HeaderFuncs)n(u);let f={method:n.Method,headers:u};if(r){let n=this.$ConvertTo_FormData(t,new FormData);n=this.$ConvertTo_FormFile(i,n);f.body=n;f.method="POST"}else u.set("content-type","application/json"),n.Method!="GET"&&(f.body=JSON.stringify(t??{}));return f}UseFormJsonBody(n="Body"){return this.WithConvertTo_FormParam(t=>{let i={};return i[n]=JSON.stringify(t),i}),this}EventAdd_AddApi(n){return this.$EventAdd(this.#EventName.AddApi,n),this}EventAdd_UpdateStore(n){return this.$EventAdd(this.#EventName.UpdateStore,n),this}EventAdd_AddStore(n){return this.$EventAdd(this.#EventName.AddStore,n),this}EventAdd_SetStore(n){return this.$EventAdd(this.#EventName.SetStore,n),this}$EventAdd(n,t){n in this.#OnEventFunc==!1&&(this.#OnEventFunc[n]=[]);this.#OnEventFunc[n].push(t)}$EventTrigger(n,t){let i=this.#OnEventFunc[n];if(i!=null)for(let n of i)n(t)}GetStore(n,t){return this.GetStoreFrom(this.Store,n,t)}AddStore(n,t=null){return this.AddStoreFrom(this.Store,n,t)}SetStore(n,t){return this.SetStoreFrom(this.Store,n,t)}UpdateStore(n,t){return this.UpdateStoreFrom(this.Store,n,t)}ClearStore(n){return this.ClearStoreFrom(this.Store,n)}GetStoreFrom(n,t,i){typeof i=="boolean"&&(i={Clone:i});i??={};i.Clone??=!1;i.CreateIfNull??=!1;i.DefaultValue==null&&(i.DefaultValue={});t=this.ToJoin(t);let r=this.$RCS_GetStore(t,n,{CreateIfNull:i.CreateIfNull,DefaultValue:i.DefaultValue});if(i.Clone){let n={},t=Object.getOwnPropertyNames(r);for(let i of t)i.match(/^\$/g)||(n[i]=r[i]);return n}return r}AddStoreFrom(n,t,i=null){return(t=this.ToJoin(t),this.GetStore(t)!=null)?this:(this.$RCS_SetStore(t,i,n,{IsDeepSet:!0}),this.$EventTrigger(this.#EventName.AddStore,{Path:t,Data:i}),this)}SetStoreFrom(n,t,i){return t=this.ToJoin(t),this.$RCS_SetStore(t,i,n,{IsDeepSet:!1}),this.$EventTrigger(this.#EventName.SetStore,{Path:t,Data:i}),this}UpdateStoreFrom(n,t,i){return t=this.ToJoin(t),this.$RCS_SetStore(t,i,n,{IsDeepSet:!0}),this.$EventTrigger(this.#EventName.UpdateStore,{Path:t,Data:i}),this}ClearStoreFrom(n,t){let i=this.GetStoreFrom(n,t);if(i==null)return this;let r=Object.getOwnPropertyNames(i);for(let n of r)if(!n.match(/^\$/g)){let t=i[n];if(typeof t!="function"){if(Array.isArray(t)){t.splice(0,t.length);continue}i[n]=null}}return this}$RCS_GetStore(n,t,i){if(t==null)return null;n=n.replaceAll(/\[|\]/g,".").replace(/\.+/g,".").replace(/\.$/,"");let r=n.split("."),u=r.shift();t[u]==null&&i.CreateIfNull&&(t[u]=Array.isArray(i.DefaultValue)?[...i.DefaultValue]:typeof i.DefaultValue=="object"?{...i.DefaultValue}:i.DefaultValue);let f=t[u];if(r.length==0)return f;let e=r.join(".");return this.$RCS_GetStore(e,f,i)}$RCS_SetStore(n,t,i,r={IsDeepSet:true}){if(n=n.replaceAll(/\[|\]/g,".").replace(/\.+/g,".").replace(/\.$/,""),n.includes(".")){let f=n.split("."),u=f.shift();i[u]==null&&(i[u]={});let e=i[u],o=f.join(".");return this.$RCS_SetStore(o,t,e,r)}let u=!r.IsDeepSet||i[n]==null||t==null||typeof t!="object";return u?(i[n]=t,t):(this.$DeepSetObject(n,t,i),t)}$DeepSetObject(n,t,i){if(t==null){i[n]=t;return}if(!Array.isArray(t)){this.ForEachObject(t,(t,r)=>{if(Array.isArray(r)||typeof r=="object"){this.$DeepSetObject(t,r,i[n]);return}i[n]==null&&(i[n]={});i[n][t]=r});return}Array.isArray(i[n])||(i[n]=[]);i[n]=t.slice()}AddFileStore(n,t){return t??={},this.FileStore[n]==null&&(this.FileStore[n]=t.Multi==!0?[]:new FileItem),this}Files(n,t=null){let i=this.FileStore[n];if(i==null)return[];Array.isArray(i)||(i=[i]);t!=null&&(i=i.filter(n=>t(n)));return i.map(n=>n.File)}File(n,t=null){let i=this.Files(n,t);return i==null||i.length==0?null:i[0]}AddFile(n,t,i="none"){if(t!=null){this.AddFileStore(n);let r=this.FileStore[n];return Array.isArray(t)?Array.isArray(r)?t.forEach(t=>this.AddFile(n,t)):this.AddFile(n,t[0]):(t instanceof FileItem==!1&&(t=new FileItem(t,i)),Array.isArray(r)?r.push(t):r.From(t)),this}}RemoveFile(n,t){let i=this.FileStore[n];if(i==null)return this;if(Array.isArray(t))t.forEach(t=>this.RemoveFile(n,t));else if(Array.isArray(i)){let n=i.findIndex(n=>n.FileId==t);n>=0&&i.splice(n,1)}else i.Clear();return this}ClearFile(n){let t=this.FileStore[n];return t==null?this:(Array.isArray(t)?t.splice(0,t.length):t.Clear(),this)}$ProcessApiReturn(n){let t=n.headers.get("content-type");return t.includes("application/json")?n.json():t.includes("text")?n.text():new Promise(t=>{t(n)})}NavigateToRoot(){let n=this.#RootRoute??"/";return super.$BaseNavigateTo(n),this}$ConvertTo_FormData(n,t){return(t??=new FormData,n==null)?t:(this.#Func_ConvertTo_FormData.forEach(i=>{n=i(n,t)}),n instanceof FormData)?n:(this.ForEachObject(n,(n,i)=>{t.append(n,i)}),t)}$ConvertTo_FormFile(n,t){if(t??=new FormData,n==null)return t;if(Array.isArray(n)||n instanceof File||n instanceof FileItem)return this.$AppendFileToFormData("Files",t,n),t;let i=Object.keys(n);for(let r=0;r<i.length;r++){let u=i[r],f=n[u];this.$AppendFileToFormData(u,t,f)}return t}$AppendFileToFormData(n,t,i){if(Array.isArray(i))for(let r=0;r<i.length;r++)this.$AppendFileToFormData(n,t,i[r]);else i instanceof File?t.append(n,i):t.append(n,i.File);return t}}import{createApp as e,reactive as r}from"vue";import{watch as f}from"vue";export class VueStore extends ApiStore{$VueProxy=null;$VueOption={methods:{},components:{},computed:{}};$VueApp=null;$VueUse=[];$CoreStore="app";$MountedFuncs=[];$Directive=[];constructor(){super();this.#Setup()}#Setup(){this.EventAdd_AddApi(n=>{this.AddStore(n.ApiKey)}).EventAdd_UpdateStore(()=>{this.ForceUpdate()}).EventAdd_AddStore(()=>{this.ForceUpdate()}).EventAdd_SetStore(()=>{this.ForceUpdate()}).AddStore(this.$CoreStore,{}).WithMounted(()=>{this.UpdateStore([this.$CoreStore,"IsMounted"],!0)})}get Store(){return this.$VueProxy!=null?this.$VueProxy:super.Store}set Store(n){super.Store=n}WithVueOption(n={}){return this.$VueOption=this.DeepObjectExtend(this.$VueOption,n),this}WithMounted(n=()=>{}){return this.$MountedFuncs.push(n),this}WithComponent(n={}){return this.$VueOption.components=this.DeepObjectExtend(this.$VueOption.components,n),this}WithVueUse(...n){for(let t of n)this.$VueUse.push(t);return this}WithDirective(n,t){return this.$Directive.push({Name:n,Directive:t}),this}ForceUpdate(){return this.$VueProxy?.$forceUpdate(),this}Refs(t){return this.$VueProxy?this.$VueProxy.$refs[n.ToJoin(t)]:null}}export class VueCommand extends VueStore{$IsInited=false;$QueryDomName=null;WithQueryDomName(n){return this.$QueryDomName=n,t.WithDomName(this.$QueryDomName),this}AddV_Text(t,i){let r=this.$ConvertCommandOption(t,i);return typeof r.Target!="function"&&n.AddStore(r.Target),this.$AddCommand(t,"v-text",r),this}AddV_Model(n,t,i){let r=this.$ConvertCommandOption(t);return i??={},i.DefaultValue??=null,r.CommandKey=i.ModelValue,this.AddStore(t,i.DefaultValue),this.$AddCommand(n,"v-model",r),this}AddV_Slot(n,t,i){let r=this.$ConvertCommandOption(i);return r.CommandKey=t,this.$AddCommand(n,`v-slot`,r),this}AddV_For(t,i,r){let u=this.$ConvertCommandOption(t,i);r&&(r=this.ToJoin(r),/^\(/.test(r)||(r=`(${r}`),/\)$/.test(r)||(r+=")"),u.TargetHead=`${r} in `);let f=n.ToJoin(u.Target);return f.includes("in")||(u.TargetHead??="(item, index) in "),this.$AddCommand(t,"v-for",u),this}AddV_If(n,t){let i=this.$ConvertCommandOption(n,t);return this.$AddCommand(n,"v-if",i),this}AddV_ElseIf(n,t){let i=this.$ConvertCommandOption(n,t);return this.$AddCommand(n,"v-else-if",i),this}AddV_Else(n){let t=this.$ConvertCommandOption(n);return t.Target="",this.$AddCommand(n,"v-else",t),this}AddV_Show(n,t){let i=this.$ConvertCommandOption(n,t);return this.$AddCommand(n,"v-show",i),this}AddV_Bind(n,t,i,r){let u=this.$ConvertCommandOption(n,i);return r&&(u.FuncArgs=r),u.CommandKey=t,this.$AddCommand(n,"v-bind",u),this}AddV_On(n,t,i,r){let u=this.$ConvertCommandOption(n,i);return r&&(u.FuncArgs=r),u.FuncAction=!1,u.CommandKey=t,this.$AddCommand(n,`v-on`,u),this}Watch(t,i,r={}){let u;return typeof t=="function"?u=f(t,i,r):(n.AddStore(t),u=f(()=>n.GetStore(t),i,r)),u}AddV_Watch(t,i,r={}){return n.WithMounted(()=>{this.Watch(t,i,r)}),this}AddV_Function(t,i){return this.$IsInited&&!Array.isArray(t)?this.$VueOption.methods[t]=i:n.UpdateStore(t,i),this}AddV_OnChange(n,t,i){return this.AddV_On(n,"change",t,i),this}AddV_Click(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i),this.AddV_On(n,"click",r),this}AddV_FilePicker(n,t){let i=null,u=null,f="none",r=!1;return typeof t=="string"?i=t:(i=t.Store,f=t.ConvertType,r=t.Multiple,u=Array.isArray(t.Accept)?t.Accept.join(" "):t.Accept),this.AddFileStore(i,{Multi:r}),this.AddV_Click(n,()=>{let n=document.createElement("input");n.type="file";u!=null&&(n.accept=u);r!=null&&(n.multiple=r);n.onchange=()=>{if(n.files!=null&&n.files.length!=0){let t=n.files;for(let n=0;n<t.length;n++){let r=t[n];this.AddFile(i,r,f)}}};n.click()}),this}AddV_Tree(i,r,u){let f=[],e=this.Paths(i);this.$ParseTreeSet(e,r,f);let o={"v-text":(t,i)=>{n.AddV_Text(i.TargetDom,i.TargetValue)},"v-model":(t,i)=>{if(typeof t.StoreValue=="function"){n.$Error(`v-model command value must be a string or string[], path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Model(i.TargetDom,i.TargetPath,{ModelValue:t.CommandKey})},"v-for":(t,i)=>{n.AddV_For(i.TargetDom,i.TargetValue,t.CommandKey)},"v-if":(t,i)=>{n.AddV_If(i.TargetDom,i.TargetValue)},"v-else-if":(t,i)=>{n.AddV_ElseIf(i.TargetDom,i.TargetValue)},"v-else":(t,i)=>{n.AddV_Else(i.TargetDom)},"v-show":(t,i)=>{n.AddV_Show(i.TargetDom,i.TargetValue)},"v-bind":(t,i)=>{n.AddV_Bind(i.TargetDom,t.CommandKey,i.TargetValue,t.Params)},"v-on":(t,i)=>{n.AddV_On(i.TargetDom,t.CommandKey,i.TargetValue,t.Params)},"v-slot":(t,i)=>{if(Array.isArray(t.StoreValue)||typeof t.StoreValue=="function"){n.$Error(`v-slot command value must be a string, path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Slot(i.TargetDom,t.CommandKey,i.TargetPath)},"v-on-mounted":(t,i)=>{n.AddV_OnMounted(i.TargetDom,i.TargetValue,t.CommandKey)},"v-on-unmounted":(t,i)=>{n.AddV_OnUnMounted(i.TargetDom,i.TargetValue,t.CommandKey)},watch:t=>{if(typeof t.StoreValue!="function"){n.$Error(`watch command value must be a function, path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Watch(t.DomPaths,t.StoreValue)},func:t=>{if(typeof t.StoreValue!="function"){n.$Error(`func command value must be a function, path: ${this.ToJoin(t.DomPaths)}`);return}n.AddV_Function(["event",...t.DomPaths,t.CommandKey],t.StoreValue)},using:n=>{typeof n.StoreValue=="function"&&n.StoreValue(n.DomPaths)}};for(let i of f){let f=o[i.Command];if(f==null){n.$Error(`${i.Command} command is not allowed, path: ${this.ToJoin(i.DomPaths)}`);continue}if(u?.UseDeepQuery){let n=t.Query(i.DomPaths,{Mode:"DeepMulti"});i.Nodes=n}let s=u?.UseDeepQuery?i.Nodes:i.DomPaths,r=[],e;typeof i.StoreValue!="function"&&(u?.UseTreePath&&(r=[...i.TreePaths]),u?.UseDomStore||i.StoreValue=="."?r.push(i.DomName):i.StoreValue!=null&&i.StoreValue!=""&&(r=this.Paths(r,i.StoreValue)));e=r.length>0?r:i.StoreValue;f(i,{TargetDom:s,TargetPath:r,TargetValue:e})}return this}$ParseTreeSet(t,i,r){let u=Object.keys(i),f=/^(.+?)\(([^)]*)\)$/;for(let e=0;e<u.length;e++){let o=u[e],h=i[o],c=[...t],a=[...t],y=a.pop();if(!o.includes(":")){let n=o.match(f),t=null;n&&n.length>=3&&(o=n[1],t=n[2]);r.push({Command:o,StoreValue:h,TreePaths:a,DomPaths:c,DomName:y,CommandKey:t});continue}let s=o.split(":");if(o.length<2){n.$Error(`command ${o} invalid`);continue}o=s.shift();let v=null;if(s.length>0){let t=s.pop(),n=t.match(f);n&&n.length>=3?(s.push(n[1]),v=n[2]):s.push(t)}let l=n.ToJoin(s,":");if(o==""){typeof h!="function"?this.$ParseTreeSet([...t,l],h,r):r.push({Command:"using",CommandKey:null,StoreValue:h,TreePaths:[...c],DomPaths:[...c,l],DomName:l,Params:v});continue}r.push({Command:o,CommandKey:l,StoreValue:h,TreePaths:a,DomPaths:c,DomName:y,Params:v})}}AddV_Property(n,t){return this.AddV_PropertyFrom(this.Store,n,t)}AddV_PropertyFrom(n,t,i){if(t!=null){let r=n;t=this.ToJoin(t);let u=t;if(t.includes(".")){let i=t.split(".");u=i.pop();let f=i.join(".");r=this.GetStoreFrom(n,f,{CreateIfNull:!0})}let f=this.$BaseAddProperty(r,u,i);if(i.Bind){Array.isArray(i.Bind)||(i.Bind=[i.Bind]);for(let n of i.Bind)n!=null&&this.AddV_Property(n,{Target:t});f.Bind=i.Bind}return this}}$BaseAddProperty(n,t,i){let f=this,u={get(){return i.get?i.get():this.$get(t)},set(n){if(i.set){i.set(n);return}this.$set(t,n)}};i.get&&(u.get=i.get);i.set!=null&&(u.set=i.set);let e=n[t],r=Object.defineProperty(n,t,u);return r.$properties??={},r.$properties[t]={...i},r.$get??=n=>{let t=r.$properties[n];return t?.Target==null?t[`$${n}`]:f.GetStore(t.Target)},r.$set??=(n,t)=>{let i=r.$properties[n];i?.Target?f.SetStore(i.Target,t):i[`$${n}`]=t},i.Value!=null?r[t]=i.Value:e!=null&&(r[t]=e),r}$ConvertCommandOption(n,t){if(t==null)if(this.IsPathType(n))return{Target:n,FuncAction:!1};else{let t=n,i=t.map(n=>n.DomName);return{Target:i,FuncAction:!1}}return typeof t=="string"||typeof t=="function"||Array.isArray(t)?{Target:t,FuncAction:!0}:(t.FuncAction??=!0,t)}$AddCommand(n,r,u){if(n!=null){Array.isArray(n)||(n=[n]);let o=n[0]instanceof i,e;e=o?n:t.Query(n);let f=u.Target;if(typeof f=="function"){let t=n;if(f=this.$GenerateEventFunction(t,f,r),u.FuncArgs){let n=this.ToJoin(u.FuncArgs,",");/^\(/.test(n)||(n=`(${n}`);/\)$/.test(n)||(n+=")");f+=n}else u.FuncAction&&(f+=`()`)}else f=this.ToJoin(f);u.TargetHead&&(f=u.TargetHead+f);u.TargetTail&&(f+=u.TargetTail);u.CommandKey&&(r+=`:${u.CommandKey}`);for(let n=0;n<e.length;n++){let t=e[n],i=t.Dom;this.$SetAttribute(i,r,f)}}}$SetAttribute(n,t,i){if(n==null){let n=`Dom Element is null. ${i}`;console.warn(n);return}n.setAttribute(t,i)}$RandomFuncName(n){return`${n}${this.GenerateIdReplace("")}`.replace(/[-:.]/g,"_")}$GenerateEventFunction(n,t,i){let u=this.$RandomFuncName(`${i}_`);n=this.Paths(n);let r=["event",...n,u];return this.AddV_Function(r,t),this.ToJoin(r)}}export class VueModel extends VueCommand{$NativeWarn;$IsEnableVueWarn;$MountId=null;Id;constructor(){super();this.Id=this.GenerateId();this.$MountId="app";this.WithVueWarn(!1);this.WithLifeCycleDirective()}WithMountId(n){return this.$MountId=n,this}WithVueWarn(n){return this.$IsEnableVueWarn=n,this.$NativeWarn=console.warn,console.warn=(...n)=>{n!=null&&n.length!=0&&(n[0].toLowerCase().includes("[vue warn]")&&this.$IsEnableVueWarn==!1||this.$NativeWarn(n))},this}WithLifeCycleDirective(){this.WithDirective("on-mounted",{mounted(n,t,i){typeof t.value=="function"&&t.value(i.props,i.el,i)}});this.WithDirective("on-unmounted",{unmounted(n,t,i){typeof t.value=="function"&&t.value(i.props,i.el,i)}})}Init(){if(this.$IsInited)return this;this.Store=r(this.Store);let n=this.Store,t=this.$MountedFuncs;this.$VueApp=e({...this.$VueOption,data(){return n},mounted:()=>{for(let n of t)n()}});for(let n of this.$VueUse)this.$VueApp.use(n);for(let n of this.$Directive)this.$VueApp.directive(n.Name,n.Directive);return this.$VueProxy=this.$VueApp.mount(`#${this.$MountId}`),this.$IsInited=!0,this}Using(n=()=>{}){return n(),this}UsingVueApp(n){return n?.call(this,this.$VueApp),this.$VueApp.directive,this}AddV_OnMounted(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($props, $el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-mounted`,r),this}AddV_OnUnMounted(n,t,i){let r=this.$ConvertCommandOption(n,t);return i&&(r.FuncArgs=i,r.TargetHead="($props, $el, $vnode) => "),r.FuncAction=!1,this.$AddCommand(n,`v-on-unmounted`,r),this}}const n=new VueModel;window.Model=n;export{u as DomQueryer,t as Queryer,n as Model};
2
2
  //# sourceMappingURL=VueModel.esm.min.js.map