@budibase/server 3.13.15 → 3.13.16
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.
|
@@ -538,7 +538,7 @@ Please report this to https://github.com/markedjs/marked.`,ue){const ro="<p>An e
|
|
|
538
538
|
issue persists.`),attr(ro,"href","https://budibase.com/support/"),attr(ro,"target","_blank"),attr(ro,"class","svelte-1kjb5e")},m(io,so){insert$1(io,ue,so),insert$1(io,eo,so),insert$1(io,no,so),insert$1(io,ro,so),insert$1(io,oo,so)},d(io){io&&(detach(ue),detach(eo),detach(no),detach(ro),detach(oo))}}}function create_if_block$58(to){let ue,eo,no,ro,oo;return{c(){ue=text(`Please wait and we'll be back in a second!
|
|
539
539
|
`),eo=element("br"),no=text(`
|
|
540
540
|
Check out the
|
|
541
|
-
`),ro=element("a"),ro.textContent="documentation",oo=text(" on app migrations."),attr(ro,"href","https://docs.budibase.com/docs/app-migrations"),attr(ro,"target","_blank"),attr(ro,"class","svelte-1kjb5e")},m(io,so){insert$1(io,ue,so),insert$1(io,eo,so),insert$1(io,no,so),insert$1(io,ro,so),insert$1(io,oo,so)},d(io){io&&(detach(ue),detach(eo),detach(no),detach(ro),detach(oo))}}}function create_fragment$aJ(to){let ue,eo,no,ro;function oo(co,fo){return co[0]?create_else_block_1$x:create_if_block_1$2W}let io=oo(to),so=io(to);function ao(co,fo){return co[0]?create_else_block$22:create_if_block$58}let lo=ao(to),uo=lo(to);return{c(){ue=element("div"),eo=element("span"),so.c(),no=space$1(),ro=element("span"),uo.c(),attr(eo,"class","header svelte-1kjb5e"),attr(ro,"class","subtext svelte-1kjb5e"),attr(ue,"class","loading svelte-1kjb5e"),toggle_class(ue,"timeout",to[0])},m(co,fo){insert$1(co,ue,fo),append$2(ue,eo),so.m(eo,null),append$2(ue,no),append$2(ue,ro),uo.m(ro,null)},p(co,[fo]){io!==(io=oo(co))&&(so.d(1),so=io(co),so&&(so.c(),so.m(eo,null))),lo!==(lo=ao(co))&&(uo.d(1),uo=lo(co),uo&&(uo.c(),uo.m(ro,null))),fo&1&&toggle_class(ue,"timeout",co[0])},i:noop$5,o:noop$5,d(co){co&&detach(ue),so.d(),uo.d()}}}function instance$aM(to,ue,eo){let{isMigrationDone:no}=ue,{onMigrationDone:ro}=ue,{timeoutSeconds:oo=60}=ue,io=!1;async function so(){let ao=0;for(;;){const lo=5e3+Math.random()*5e3;if(await new Promise(co=>setTimeout(co,lo)),ao+=lo,await no()){ro();return}if(ao>oo*1e3){eo(0,io=!0);return}}}return so(),to.$$set=ao=>{"isMigrationDone"in ao&&eo(1,no=ao.isMigrationDone),"onMigrationDone"in ao&&eo(2,ro=ao.onMigrationDone),"timeoutSeconds"in ao&&eo(3,oo=ao.timeoutSeconds)},[io,no,ro,oo]}class Updating extends SvelteComponent{constructor(ue){super(),init$3(this,ue,instance$aM,create_fragment$aJ,safe_not_equal,{isMigrationDone:1,onMigrationDone:2,timeoutSeconds:3})}}const createEventManagers=()=>{const to=createEventDispatcher();let ue={};return{dispatch:(ro,oo)=>{to(ro,oo);const io=ue[ro]||[];for(let so=0;so<io.length;so++)io[so](oo)},subscribe:(ro,oo)=>{const io=ue[ro]||[];return ue[ro]=[...io,oo],()=>{ue[ro]=ue[ro].filter(so=>so!==oo)}}}},createStores$g=()=>{const to=writable({left:0,top:0,width:0,height:0}),ue=derived(to,no=>no.width,0),eo=derived(to,no=>no.height,0);return{bounds:to,height:eo,width:ue}},Bounds=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$g},Symbol.toStringTag,{value:"Module"})),SmallRowHeight=36,MediumRowHeight=64,LargeRowHeight=92,DefaultRowHeight=SmallRowHeight,VPadding=0,HPadding=80,ScrollBarSize=8,GutterWidth=72,DefaultColumnWidth=200,MinColumnWidth=56,NewRowID="new",BlankRowID="blank",GeneratedIDPrefix="‽‽",CellIDSeparator="‽‽",RowPageSize=100,FocusedCellMinOffset=ScrollBarSize*3,ControlsHeight=50,PopoverMinWidth=200,PopoverMaxWidth=400,PopoverMaxHeight=236,MaxCellRenderOverflow=222,Constants=Object.freeze(Object.defineProperty({__proto__:null,BlankRowID,CellIDSeparator,ControlsHeight,DefaultColumnWidth,DefaultRowHeight,FocusedCellMinOffset,GeneratedIDPrefix,GutterWidth,HPadding,LargeRowHeight,MaxCellRenderOverflow,MediumRowHeight,MinColumnWidth,NewRowID,PopoverMaxHeight,PopoverMaxWidth,PopoverMinWidth,RowPageSize,ScrollBarSize,SmallRowHeight,VPadding},Symbol.toStringTag,{value:"Module"})),createStores$f=()=>{const to=writable([]),ue=derived(to,eo=>{let no=GutterWidth,ro=0;return eo.map(oo=>{const io={...oo,__idx:ro,__left:no};return oo.visible&&(ro++,no+=oo.width??0),io})});return{columns:{...to,subscribe:ue.subscribe}}},deriveStores$b=to=>{const{columns:ue}=to,eo=derived(ue,ao=>{let lo={};return ao.forEach(uo=>{lo[uo.name]=uo}),lo}),no=derived(ue,ao=>ao.filter(lo=>!lo.related)),ro=derived(ue,ao=>ao.filter(lo=>lo.visible)),oo=derived(ro,ao=>ao.find(lo=>lo.primaryDisplay)),io=derived(ro,ao=>ao.filter(lo=>!lo.primaryDisplay)),so=derived(ue,ao=>ao.filter(uo=>{var co;return!((co=uo.schema)!=null&&co.autocolumn)}).length>0);return{tableColumns:no,displayColumn:oo,columnLookupMap:eo,visibleColumns:ro,scrollableColumns:io,hasNonAutoColumn:so}},createActions$e=to=>{const{columns:ue,datasource:eo}=to;return{columns:{...ue,actions:{changeAllColumnWidths:async oo=>{get_store_value(ue).forEach(so=>{const{related:ao}=so,lo={width:oo};ao?eo.actions.addSubSchemaMutation(ao.subField,ao.field,lo):eo.actions.addSchemaMutation(so.name,lo)}),await eo.actions.saveSchemaMutations()},isReadonly:oo=>oo!=null&&oo.schema?oo.schema.autocolumn||oo.schema.disabled||oo.schema.type==="formula"||oo.schema.type==="ai"||oo.schema.readonly:!1}}}},initialise$d=to=>{const{definition:ue,columns:eo,displayColumn:no,enrichedSchema:ro}=to,oo=io=>{const so=get_store_value(ue);if(!io||!so){eo.set([]);return}const ao=get_store_value(no);let lo;const uo=so.primaryDisplay||(ao==null?void 0:ao.name);uo&&io[uo]&&(lo=uo);const co=Object.values(io).find(fo=>fo.visible!=null);eo.set(Object.keys(io).map(fo=>{const po=io[fo],mo={type:po.type,name:fo,label:po.displayName||fo,schema:po,width:po.width||DefaultColumnWidth,visible:po.visible??!co,readonly:po.readonly,order:po.order,conditions:po.conditions,related:po.related,calculationType:po.calculationType,format:po.format,__left:void 0,__idx:void 0};return fo===lo&&(mo.order=0,mo.primaryDisplay=!0),mo}).sort((fo,po)=>{var bo,vo;if(fo.name===lo)return-1;if(po.name===lo)return 1;const mo=fo.order,_o=po.order;if(mo!=null&&_o!=null)return mo<_o?-1:1;if(mo!=null)return-1;if(_o!=null)return 1;const ho=(bo=fo.schema)==null?void 0:bo.autocolumn,go=(vo=po.schema)==null?void 0:vo.autocolumn;return ho===go?0:ho?1:-1}))};ro.subscribe(oo)},Columns=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$e,createStores:createStores$f,deriveStores:deriveStores$b,initialise:initialise$d},Symbol.toStringTag,{value:"Module"})),parseCellID=to=>{if(!to)return{rowId:void 0,field:void 0};const ue=to.split(CellIDSeparator),eo=ue.pop();return{rowId:ue.join(CellIDSeparator),field:eo}},getCellID=(to,ue)=>`${to}${CellIDSeparator}${ue}`,parseEventLocation=to=>{var eo,no,ro,oo;const ue=to;return{x:ue.clientX??((no=(eo=ue.touches)==null?void 0:eo[0])==null?void 0:no.clientX),y:ue.clientY??((oo=(ro=ue.touches)==null?void 0:ro[0])==null?void 0:oo.clientY)}},generateRowID=()=>`${GeneratedIDPrefix}${uuid$1()}`,isGeneratedRowID=to=>to==null?void 0:to.startsWith(GeneratedIDPrefix),createStores$e=()=>({menu:writable({left:0,top:0,visible:!1,multiRowMode:!1,multiCellMode:!1})}),createActions$d=to=>{const{menu:ue,focusedCellId:eo,gridID:no,selectedRows:ro,selectedRowCount:oo,selectedCellMap:io,selectedCellCount:so}=to;return{menu:{...ue,actions:{open:(uo,co)=>{var bo;co.preventDefault(),co.stopPropagation();const fo=document.getElementById(no),po=(bo=fo==null?void 0:fo.getElementsByClassName("grid-data-outer"))==null?void 0:bo[0];if(!po)return;const mo=co.target.getBoundingClientRect(),_o=po.getBoundingClientRect();let ho=!1;if(get_store_value(oo)>1){const{rowId:vo}=parseCellID(uo);vo!==void 0&&get_store_value(ro)[vo]&&(ho=!0)}let go=!1;!ho&&get_store_value(so)>1&&get_store_value(io)[uo]&&(go=!0),!ho&&!go&&eo.set(uo),ue.set({left:mo.left-_o.left+co.offsetX,top:mo.top-_o.top+co.offsetY,visible:!0,multiRowMode:ho,multiCellMode:go})},close:()=>{ue.update(uo=>({...uo,visible:!1}))}}}}},Menu=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$d,createStores:createStores$e},Symbol.toStringTag,{value:"Module"})),initialise$c=to=>{const{scrolledRowCount:ue,rows:eo,visualRowCapacity:no}=to,ro=derived(eo,so=>so.length,0),oo=derived([ue,ro,no],([so,ao,lo])=>Math.max(0,ao-so-lo));derived([oo,ro],([so,ao])=>so<25&&ao).subscribe(so=>{so&&eo.actions.loadNextPage()})},Pagination=Object.freeze(Object.defineProperty({__proto__:null,initialise:initialise$c},Symbol.toStringTag,{value:"Module"})),reorderInitialState={sourceColumn:null,targetColumn:null,insertAfter:!1,breakpoints:[],gridLeft:0,width:0,increment:0},createStores$d=()=>{const to=writable(reorderInitialState),ue=derived(to,eo=>!!eo.sourceColumn,!1);return{reorder:to,isReordering:ue}},createActions$c=to=>{const{reorder:ue,columns:eo,columnLookupMap:no,scrollableColumns:ro,scroll:oo,bounds:io,visibleColumns:so,datasource:ao,stickyWidth:lo,width:uo,scrollLeft:co,maxScrollLeft:fo}=to;let po=0,mo,_o;const ho=(Io,Ao)=>{const Eo=get_store_value(ro),Lo=get_store_value(io),No=get_store_value(lo),Do=Eo.map(Mo=>({x:Mo.__left-No,column:Mo.name,insertAfter:!1})),Po=Eo[Eo.length-1];Po&&Do.push({x:Po.__left+Po.width-No,column:Po.name,insertAfter:!0}),ue.set({sourceColumn:Io,targetColumn:null,breakpoints:Do,gridLeft:Lo.left,width:Lo.width}),document.addEventListener("mousemove",go),document.addEventListener("mouseup",wo),document.addEventListener("touchmove",go),document.addEventListener("touchend",wo),document.addEventListener("touchcancel",wo),go(Ao)},go=Io=>{const{x:Ao}=parseEventLocation(Io);po=Ao,bo();const Eo=get_store_value(co),Lo=get_store_value(fo),No=get_store_value(ue),Do=Math.min(140,get_store_value(uo)/6),Po=16,Mo=Math.max(0,No.gridLeft+No.width-Ao),Uo=Math.max(0,Ao-No.gridLeft);if(Mo<Do&&Eo<Lo){const Wo=(Do-Mo)/Do*Po;ue.update(Zo=>({...Zo,increment:Wo})),vo()}else if(Uo<Do&&Eo>0){const Wo=-1*(Do-Uo)/Do*Po;ue.update(Zo=>({...Zo,increment:Wo})),vo()}else $o()},bo=()=>{const Io=get_store_value(ue),Ao=get_store_value(co);let Eo,Lo=Number.MAX_SAFE_INTEGER;const No=po-Io.gridLeft+Ao;Io.breakpoints.forEach(Do=>{const Po=Math.abs(Do.x-No);Po<Lo&&(Lo=Po,Eo=Do)}),Eo&&(Eo.column!==Io.targetColumn||Eo.insertAfter!==Io.insertAfter)&&ue.update(Do=>({...Do,targetColumn:Eo.column,insertAfter:Eo.insertAfter}))},vo=()=>{_o||(_o=!0,mo=setInterval(()=>{const Io=get_store_value(fo),{increment:Ao}=get_store_value(ue);oo.update(Eo=>({...Eo,left:Math.max(0,Math.min(Io,Eo.left+Ao))})),bo()},10))},$o=()=>{_o=!1,clearInterval(mo)},wo=async()=>{$o(),document.removeEventListener("mousemove",go),document.removeEventListener("mouseup",wo),document.removeEventListener("touchmove",go),document.removeEventListener("touchend",wo),document.removeEventListener("touchcancel",wo);const{sourceColumn:Io,targetColumn:Ao,insertAfter:Eo}=get_store_value(ue);ue.set(reorderInitialState),Io!==Ao&&await ko({sourceColumn:Io,targetColumn:Ao,insertAfter:Eo})},ko=async({sourceColumn:Io,targetColumn:Ao,insertAfter:Eo=!1})=>{const Lo=get_store_value(eo);let No=Lo.findIndex(Po=>Po.name===Io),Do=Lo.findIndex(Po=>Po.name===Ao);Eo&&Do++,eo.update(Po=>{const Mo=Po.splice(No,1);return--Do<No&&Do++,Po.toSpliced(Do,0,Mo[0])}),get_store_value(eo).forEach((Po,Mo)=>{const{related:Uo}=Po,Vo={order:Mo};Uo?ao.actions.addSubSchemaMutation(Uo.subField,Uo.field,Vo):ao.actions.addSchemaMutation(Po.name,Vo)}),await ao.actions.saveSchemaMutations()};return{reorder:{...ue,actions:{startReordering:ho,stopReordering:wo,moveColumnLeft:async Io=>{var No;const Ao=get_store_value(so),Lo=get_store_value(no)[Io].__idx;await ko({sourceColumn:Io,targetColumn:(No=Ao[Lo-1])==null?void 0:No.name})},moveColumnRight:async Io=>{var No;const Ao=get_store_value(so),Lo=get_store_value(no)[Io].__idx;Lo!==Ao.length-1&&await ko({sourceColumn:Io,targetColumn:(No=Ao[Lo+1])==null?void 0:No.name,insertAfter:!0})}}}}},Reorder=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$c,createStores:createStores$d},Symbol.toStringTag,{value:"Module"})),initialState$3={initialMouseX:null,initialWidth:null,column:null,width:0,left:0},createStores$c=()=>{const to=writable(initialState$3),ue=derived(to,eo=>eo.column!=null,!1);return{resize:to,isResizing:ue}},createActions$b=to=>{const{resize:ue,ui:eo,datasource:no}=to,ro=(ao,lo)=>{const{x:uo}=parseEventLocation(lo);lo.stopPropagation(),lo.preventDefault(),eo.actions.blur(),ue.set({width:ao.width,left:ao.__left,initialWidth:ao.width,initialMouseX:uo,column:ao.name,related:ao.related}),document.addEventListener("mousemove",oo),document.addEventListener("mouseup",io),document.addEventListener("touchmove",oo),document.addEventListener("touchend",io),document.addEventListener("touchcancel",io)},oo=ao=>{const{initialMouseX:lo,initialWidth:uo,width:co,column:fo,related:po}=get_store_value(ue),{x:mo}=parseEventLocation(ao),_o=mo-lo,ho=Math.round(Math.max(MinColumnWidth,uo+_o));Math.abs(co-ho)<5||(po?no.actions.addSubSchemaMutation(po.subField,po.field,{width:co}):no.actions.addSchemaMutation(fo,{width:co}),ue.update(go=>({...go,width:ho})))},io=async()=>{const ao=get_store_value(ue);ue.set(initialState$3),document.removeEventListener("mousemove",oo),document.removeEventListener("mouseup",io),document.removeEventListener("touchmove",oo),document.removeEventListener("touchend",io),document.removeEventListener("touchcancel",io),ao.width!==ao.initialWidth&&await no.actions.saveSchemaMutations()};return{resize:{...ue,actions:{startResizing:ro,resetSize:async ao=>{no.actions.addSchemaMutation(ao.name,{width:DefaultColumnWidth}),await no.actions.saveSchemaMutations()}}}}},Resize=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$b,createStores:createStores$c},Symbol.toStringTag,{value:"Module"})),createStores$b=()=>{const to=writable([]),ue=writable(!1),eo=writable(!1),no=writable(!1),ro=writable({}),oo=writable({}),io=writable(!1),so=writable(null),ao=writable(null);let lo=!1;return ue.subscribe(uo=>{uo?lo=!0:lo&&eo.set(!0)}),{rows:to,fetch:ao,loaded:eo,refreshing:no,loading:ue,rowChangeCache:ro,inProgressChanges:oo,hasNextPage:io,error:so}},deriveStores$a=to=>{const{rows:ue,enrichedSchema:eo}=to,no=derived([ue,eo],([oo,io])=>{const so=Object.values(io||{}),ao=so.filter(uo=>uo.related),lo=so.filter(uo=>uo.format);return oo.map((uo,co)=>{const fo=ao.reduce((mo,_o)=>{const ho=io[_o.related.field];return mo[_o.name]=getRelatedTableValues(uo,{..._o,related:_o.related},ho),mo},{}),po=lo.reduce((mo,_o)=>(mo[_o.name]=_o.format(uo),mo),{});return{...uo,...fo,__formatted:po,__idx:co}})}),ro=derived(no,oo=>{let io={};for(let so=0;so<oo.length;so++)io[oo[so]._id]=oo[so];return io});return{rows:{...ue,subscribe:no.subscribe},rowLookupMap:ro}},createActions$a=to=>{const{rows:ue,rowLookupMap:eo,definition:no,allFilters:ro,loading:oo,sort:io,datasource:so,API:ao,scroll:lo,validation:uo,focusedCellId:co,columns:fo,rowChangeCache:po,inProgressChanges:mo,hasNextPage:_o,error:ho,notifications:go,fetch:bo,hasBudibaseIdentifiers:vo,refreshing:$o,columnLookupMap:wo}=to,ko=writable(!1);let So={},To=null,Io=null;so.subscribe(async ls=>{if(To==null||To(),To=null,bo.set(null),ko.set(!1),oo.set(!0),!so.actions.isDatasourceValid(ls)){ho.set("Datasource is invalid");return}await tick();const Jo=get_store_value(ro),hs=get_store_value(io),ks=fetchData({API:ao,datasource:ls,options:{filter:Jo,sortColumn:hs.column,sortOrder:hs.order,limit:RowPageSize,paginate:!0,clientSideLimiting:!1}});To=ks.subscribe(async cs=>{if(cs.error){let _s="An unknown error occurred";cs.error.status===403?_s="You don't have access to this data":cs.error.message&&(_s=cs.error.message),ho.set(_s)}else if(cs.loaded&&!cs.loading){ho.set(null),_o.set(cs.hasNextPage);const _s=get_store_value(ko),Is=cs.resetKey!==Io,Bs=Io;Io=cs.resetKey,!_s&&Bs&&(ue.set([]),await tick()),(!_s||Is)&&no.set(cs.definition??null),_s?Is&&lo.update(Hs=>({...Hs,top:0})):(ko.set(!0),lo.set({top:0,left:0})),Go(cs.rows,Is),oo.set(!1)}$o.set(cs.loading)}),bo.set(ks)});const Ao=(ls,Jo)=>{var ks,cs;let hs;if(typeof Jo=="string"?hs=Jo:typeof(Jo==null?void 0:Jo.message)=="string"&&(hs=Jo.message),typeof Jo!="string"&&!((ks=Jo==null?void 0:Jo.json)!=null&&ks.validationErrors)&&hs){const{field:_s}=parseCellID(get_store_value(co));_s&&(Jo={json:{validationErrors:{[_s]:Jo.message}}})}if(typeof Jo!="string"&&((cs=Jo==null?void 0:Jo.json)!=null&&cs.validationErrors)){const _s=Object.keys(Jo.json.validationErrors),Is=get_store_value(fo);let Bs=[],Hs=[];for(let Ds of _s)so.actions.canUseColumn(Ds)?Bs.push(Ds):Hs.push(Ds);const{json:Rs}=Jo;for(let Ds of Bs){let Js=Rs.validationErrors[Ds];Array.isArray(Js)&&(Js=Js[0]),(typeof Js!="string"||!Js.length)&&(Jo="Something went wrong"),uo.actions.setError(getCellID(ls,Ds),capitalise$1(Js));const Cs=Is.findIndex(da=>da.name===Ds);Cs!==-1&&!Is[Cs].visible&&fo.update(da=>(da[Cs].visible=!0,da.slice()))}for(let Ds of Hs)get_store_value(go).error(`${Ds} is required but is missing`)}else get_store_value(go).error(hs||"An unknown error occurred")},Eo=async({row:ls,idx:Jo,bubble:hs=!1,notify:ks=!0})=>{try{const cs=await so.actions.addRow(ls);return Jo!=null?(So[cs._id]=!0,ue.update(_s=>(_s.splice(Jo,0,cs),_s.slice()))):Go([cs]),ks&&get_store_value(go).success("Row created successfully"),cs}catch(cs){if(hs)throw cs;Ao(NewRowID,cs),uo.actions.focusFirstRowError(NewRowID)}},Lo=async ls=>{let Jo=Ko(ls);delete Jo._id,delete Jo._rev;try{const hs=await Eo({row:Jo,idx:ls.__idx+1,bubble:!0,notify:!1});return get_store_value(go).success("Duplicated 1 row"),hs}catch(hs){Ao(ls._id,hs),uo.actions.focusFirstRowError(ls._id)}},No=async(ls,Jo)=>{const hs=get_store_value(eo),ks=ls.map(Rs=>{var Ds;return(Ds=hs[Rs._id])==null?void 0:Ds.__idx}),cs=Math.max(...ks),_s=ls.length,Is=ls.map(Rs=>{let Ds=Ko(Rs);return delete Ds._id,delete Ds._rev,Ds});let Bs=[],Hs=0;for(let Rs=0;Rs<_s;Rs++){try{const Ds=await so.actions.addRow(Is[Rs]);Bs.push(Ds),So[Ds._id]=!0,await sleep$2(50)}catch(Ds){Hs++,console.error("Duplicating row failed",Ds)}Jo==null||Jo((Rs+1)/_s)}return Bs.length&&ue.update(Rs=>Rs.toSpliced(cs+1,0,...Bs)),Hs?get_store_value(go).error(`Failed to duplicate ${Hs} of ${_s} rows`):Bs.length&&get_store_value(go).success(`Duplicated ${Bs.length} rows`),Bs},Do=(ls,Jo)=>{var _s;const hs=get_store_value(ue),cs=(_s=get_store_value(eo)[ls])==null?void 0:_s.__idx;Jo?cs!=null?ue.update(Is=>(Is[cs]={...Jo},Is)):Go([Jo]):cs!=null&&Xo([hs[cs]])},Po=async ls=>{try{const Jo=await so.actions.getRow(ls);Do(ls,Jo)}catch{}},Mo=async()=>{var ls;await((ls=get_store_value(bo))==null?void 0:ls.getInitialData())},Uo=(ls,Jo)=>{const hs=Object.keys(Jo||{});return!ls||!hs.length?!1:hs.some(ks=>ls[ks]!==Jo[ks])},Vo=(ls,Jo)=>{var _s,Is;const hs=get_store_value(eo),ks=get_store_value(wo),cs=hs[ls];for(let Bs of Object.keys(Jo||{})){const Hs=(Is=(_s=ks[Bs])==null?void 0:_s.schema)==null?void 0:Is.type;(Hs===FieldType.STRING||Hs==FieldType.LONGFORM)&&Jo[Bs]!=null&&typeof Jo[Bs]!="string"&&(Jo[Bs]=JSON.stringify(Jo[Bs]))}return!cs||!Uo(cs,Jo)?!1:(po.update(Bs=>({...Bs,[ls]:{...Bs[ls],...Jo}})),!0)},Wo=async({rowId:ls,changes:Jo=null,updateState:hs=!0,handleErrors:ks=!0})=>{const _s=get_store_value(eo)[ls];if(_s==null)return;let Is;try{mo.update(Ds=>({...Ds,[ls]:(Ds[ls]||0)+1}));const Bs=get_store_value(po)[ls],Hs={...Ko(_s),...Bs,...Jo};Is=await so.actions.updateRow(Hs),Is!=null&&Is._id?hs&&ue.update(Ds=>(Ds[_s.__idx]=Is,Ds.slice())):Is!=null&&Is.id&&await Po(Is.id);const Rs=get_store_value(po)[ls];po.update(Ds=>(Object.keys(Bs||{}).forEach(Js=>{Bs[Js]===(Rs==null?void 0:Rs[Js])&&delete Ds[ls][Js]}),Ds))}catch(Bs){ks&&(Ao(ls,Bs),uo.actions.focusFirstRowError(ls))}return mo.update(Bs=>({...Bs,[ls]:(Bs[ls]||1)-1})),Is},Zo=async({rowId:ls,column:Jo,value:hs,apply:ks=!0})=>{Vo(ls,{[Jo]:hs})&&ks&&await Wo({rowId:ls})},Yo=async(ls,Jo)=>{const hs=Object.keys(ls||{}),ks=hs.length;if(!ks)return;const cs=get_store_value(wo);let _s=[],Is=0;for(let Bs=0;Bs<ks;Bs++){const Hs=hs[Bs];let Rs=ls[Hs]||{};for(let Ds of Object.keys(Rs)){const Js=cs[Ds];fo.actions.isReadonly(Js)&&delete Rs[Ds]}if(!Object.keys(Rs).length){Jo==null||Jo((Bs+1)/ks);continue}try{const Ds=await Wo({rowId:Hs,changes:ls[Hs],updateState:!1,handleErrors:!1});Ds?_s.push(Ds):Is++,await sleep$2(50)}catch(Ds){Is++,console.error("Failed to update row",Ds)}Jo==null||Jo((Bs+1)/ks)}if(_s.length){const Bs=get_store_value(eo);ue.update(Hs=>{for(let Rs of _s){const Ds=Bs[Rs._id].__idx;Hs[Ds]=Rs}return Hs.slice()})}if(Is){const Bs=`row${ks===1?"":"s"}`;get_store_value(go).error(`Failed to update ${Is} of ${ks} ${Bs}`)}else if(_s.length){const Bs=`row${_s.length===1?"":"s"}`;get_store_value(go).success(`Updated ${_s.length} ${Bs}`)}},xo=async ls=>{ls!=null&&ls.length&&(ls.forEach(Jo=>delete Jo.__idx),await so.actions.deleteRows(ls),Xo(ls))},Go=(ls,Jo)=>{var _s;Jo&&(So={});let hs=[],ks;const cs=get_store_value(vo);for(let Is=0;Is<ls.length;Is++)ks=ls[Is],!cs&&!((_s=ks._id)!=null&&_s.length)&&(ks._id=generateRowID()),So[ks._id]||(So[ks._id]=!0,hs.push(ks));Jo?ue.set(hs):hs.length&&ue.update(Is=>[...Is,...hs])},Xo=ls=>{const Jo=ls.map(hs=>hs._id);ue.update(hs=>hs.filter(ks=>!Jo.includes(ks._id)))},as=()=>{var ls;(ls=get_store_value(bo))==null||ls.nextPage()},Ko=ls=>{let Jo={...ls};return delete Jo.__idx,delete Jo.__metadata,delete Jo.__formatted,!get_store_value(vo)&&isGeneratedRowID(Jo._id)&&delete Jo._id,Jo};return{rows:{...ue,actions:{addRow:Eo,duplicateRow:Lo,bulkDuplicate:No,updateValue:Zo,applyRowChanges:Wo,deleteRows:xo,loadNextPage:as,refreshRow:Po,replaceRow:Do,refreshData:Mo,cleanRow:Ko,bulkUpdate:Yo}}}},initialise$b=to=>{const{rowChangeCache:ue,inProgressChanges:eo,previousFocusedRowId:no,previousFocusedCellId:ro,rows:oo,validation:io}=to;no.subscribe(so=>{so&&!get_store_value(eo)[so]&&Object.keys(get_store_value(ue)[so]||{}).length&&ue.update(ao=>(delete ao[so],ao))}),ro.subscribe(async so=>{if(!so)return;let{rowId:ao,field:lo}=parseCellID(so);ao=ao,lo=lo;const uo=lo in(get_store_value(ue)[ao]||{}),co=io.actions.rowHasErrors(ao),fo=get_store_value(eo)[ao];ao&&!co&&uo&&!fo&&await oo.actions.applyRowChanges({rowId:ao})})},Rows=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$a,createStores:createStores$b,deriveStores:deriveStores$a,initialise:initialise$b},Symbol.toStringTag,{value:"Module"})),createStores$a=()=>{const to=writable({left:0,top:0}),ue=derived(to,no=>Math.round(no.top)),eo=derived(to,no=>Math.round(no.left));return{scroll:to,scrollTop:ue,scrollLeft:eo}},deriveStores$9=to=>{const{rows:ue,visibleColumns:eo,displayColumn:no,rowHeight:ro,width:oo,height:io,buttonColumnWidth:so,config:ao}=to,lo=derived(no,go=>((go==null?void 0:go.width)||0)+GutterWidth),uo=derived([eo,so],([go,bo])=>{let vo=GutterWidth+Math.max(bo,HPadding);return go.forEach($o=>{vo+=$o.width}),vo}),co=derived([oo,lo],([go,bo])=>go+bo),fo=derived([uo,co],([go,bo])=>Math.round(Math.max(go-bo,0))),po=derived([uo,co],([go,bo])=>go>bo),mo=derived([ue,ro,po,ao],([go,bo,vo,$o])=>{let wo=go.length*bo+VPadding;return vo&&(wo+=ScrollBarSize*3),$o.canAddRows&&(wo+=bo),wo}),_o=derived([io,mo],([go,bo])=>Math.round(Math.max(bo-go,0))),ho=derived([mo,io],([go,bo])=>go>bo);return{stickyWidth:lo,contentHeight:mo,contentWidth:uo,screenWidth:co,maxScrollTop:_o,maxScrollLeft:fo,showHScrollbar:po,showVScrollbar:ho}},initialise$a=to=>{const{focusedCellId:ue,focusedRow:eo,scroll:no,bounds:ro,rowHeight:oo,stickyWidth:io,scrollTop:so,maxScrollTop:ao,scrollLeft:lo,maxScrollLeft:uo,buttonColumnWidth:co,columnLookupMap:fo}=to,po=derived([so,ao],([_o,ho])=>_o>ho,!1),mo=derived([lo,uo],([_o,ho])=>_o>ho,!1);po.subscribe(_o=>{_o&&no.update(ho=>({...ho,top:get_store_value(ao)}))}),mo.subscribe(_o=>{_o&&no.update(ho=>({...ho,left:get_store_value(uo)}))}),ue.subscribe(async _o=>{await tick();const ho=get_store_value(eo),go=get_store_value(no),bo=get_store_value(ro),vo=get_store_value(oo);if(ho){const To=ho.__idx*vo,Io=go.top+bo.height-vo-FocusedCellMinOffset;let Ao=To-Io;if(Ao>0)no.update(Eo=>({...Eo,top:Eo.top+Ao}));else{const Eo=go.top-To+FocusedCellMinOffset;Eo>0&&no.update(Lo=>({...Lo,top:Math.max(0,Lo.top-Eo)}))}}const{field:$o}=parseCellID(_o),wo=get_store_value(fo)[$o];if(!wo||wo.primaryDisplay)return;const ko=get_store_value(io);let So=go.left-wo.__left+FocusedCellMinOffset+ko;if(So>0)no.update(To=>({...To,left:Math.max(0,To.left-So)}));else{const To=get_store_value(co),Io=wo.__left+wo.width,Ao=bo.width+go.left-FocusedCellMinOffset-To;So=Io-Ao-ko,So>0&&no.update(Eo=>({...Eo,left:Eo.left+So}))}})},Scroll=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$a,deriveStores:deriveStores$9,initialise:initialise$a},Symbol.toStringTag,{value:"Module"})),createStores$9=to=>{const{props:ue}=to,eo=writable(null),no=writable(null),ro=writable({}),oo=writable(null),io=writable(get_store_value(ue).fixedRowHeight||DefaultRowHeight),so=writable(null),ao=writable(null),lo=writable(!1),uo=writable(!1),co=writable(!1),fo=writable(0),po=writable({active:!1,sourceCellId:null,targetCellId:null});return{focusedCellId:eo,focusedCellAPI:no,previousFocusedRowId:so,previousFocusedCellId:ao,hoveredRowId:oo,rowHeight:io,gridFocused:lo,keyboardBlocked:uo,isDragging:co,buttonColumnWidth:fo,selectedRows:ro,cellSelection:po}},deriveStores$8=to=>{const{focusedCellId:ue,rows:eo,rowLookupMap:no,rowHeight:ro,width:oo,selectedRows:io,cellSelection:so,columnLookupMap:ao,visibleColumns:lo}=to,uo=derived(ue,vo=>parseCellID(vo).rowId??null),co=derived([uo,no],([vo,$o])=>{if(vo!==null)return vo===NewRowID?{_id:NewRowID}:$o[vo]}),fo=derived(ro,vo=>vo>=LargeRowHeight?3:vo>=MediumRowHeight?2:1),po=derived(oo,vo=>vo<600),mo=derived(io,vo=>Object.keys(vo).length),_o=derived(so,vo=>vo.active),ho=derived([so,no,ao],([vo,$o,wo])=>{var Go,Xo;const{sourceCellId:ko,targetCellId:So}=vo;if(!ko||!So||ko===So)return[];const To=get_store_value(eo),Io=get_store_value(lo),Ao=parseCellID(ko),Eo=parseCellID(So);if(Ao.rowId===NewRowID)return[];const Lo=(Go=$o[Ao.rowId])==null?void 0:Go.__idx,No=(Xo=$o[Eo.rowId])==null?void 0:Xo.__idx;if(Lo==null||No==null)return[];const Do=Math.min(Lo,No);let Po=Math.max(Lo,No);Po=Math.min(Po,Do+49);const Mo=wo[Ao.field].__idx||0,Uo=wo[Eo.field].__idx||0,Vo=Math.min(Mo,Uo),Wo=Math.max(Mo,Uo);let Zo=[],Yo,xo;for(let as=Do;as<=Po;as++){let Ko=[];for(let ls=Vo;ls<=Wo;ls++)Yo=To[as]._id,xo=Io[ls].name,Ko.push(getCellID(Yo,xo));Zo.push(Ko)}return Zo}),go=derived(ho,vo=>{let $o={};for(let wo of vo)for(let ko of wo)$o[ko]=!0;return $o}),bo=derived(go,vo=>Object.keys(vo).length);return{focusedRowId:uo,focusedRow:co,contentLines:fo,compact:po,selectedRowCount:mo,isSelectingCells:_o,selectedCells:ho,selectedCellMap:go,selectedCellCount:bo}},createActions$9=to=>{const{focusedCellId:ue,hoveredRowId:eo,selectedRows:no,rowLookupMap:ro,rows:oo,selectedRowCount:io,cellSelection:so,selectedCells:ao}=to;let lo=null;const uo=()=>{ue.set(null),eo.set(null),go()},co=bo=>{no.update(vo=>{let $o={...vo,[bo]:!vo[bo]};return $o[bo]?lo=get_store_value(ro)[bo].__idx:delete $o[bo],$o})},fo=bo=>{if(!get_store_value(io)){co(bo);return}if(lo==null)return;const vo=get_store_value(ro)[bo].__idx;if(lo===vo)return;const $o=Math.min(lo,vo),wo=Math.max(lo,vo),ko=get_store_value(oo);no.update(So=>{for(let To=$o;To<=wo;To++)So[ko[To]._id]=!0;return So})},po=bo=>{so.set({active:!0,sourceCellId:bo,targetCellId:bo})},mo=bo=>{so.update(vo=>({...vo,targetCellId:bo}))},_o=()=>{so.update(bo=>({...bo,active:!1}))},ho=(bo,vo)=>{so.set({active:!1,sourceCellId:bo,targetCellId:vo})},go=()=>{so.set({active:!1,sourceCellId:null,targetCellId:null})};return{ui:{actions:{blur:uo}},selectedRows:{...no,actions:{toggleRow:co,bulkSelectRows:fo}},selectedCells:{...ao,actions:{startSelecting:po,updateTarget:mo,stopSelecting:_o,selectRange:ho,clear:go}}}},initialise$9=to=>{const{focusedRowId:ue,previousFocusedRowId:eo,previousFocusedCellId:no,rowLookupMap:ro,focusedCellId:oo,selectedRows:io,hoveredRowId:so,definition:ao,rowHeight:lo,fixedRowHeight:uo,selectedRowCount:co,menu:fo,selectedCellCount:po,selectedCells:mo,cellSelection:_o}=to;ro.subscribe(async bo=>{await tick();const vo=get_store_value(ue),$o=get_store_value(io),wo=get_store_value(so),ko=To=>bo[To]!=null;vo&&!ko(vo)&&oo.set(null),wo&&!ko(wo)&&so.set(null);const So=Object.keys($o);if(So.length){let To={...$o},Io=!1;for(let Ao=0;Ao<So.length;Ao++)ko(So[Ao])||(delete To[So[Ao]],Io=!0);Io&&io.set(To)}});let ho=null;ue.subscribe(bo=>{eo.set(ho),ho=bo});let go=null;oo.subscribe(bo=>{no.set(go),go=bo,bo&&get_store_value(so)&&so.set(null),bo&&get_store_value(co)&&io.set({}),bo&&get_store_value(po)&&mo.actions.clear(),fo.actions.close()}),ao.subscribe(bo=>{get_store_value(uo)||lo.set((bo==null?void 0:bo.rowHeight)||DefaultRowHeight)}),uo.subscribe(bo=>{var vo;bo?lo.set(bo):lo.set(((vo=get_store_value(ao))==null?void 0:vo.rowHeight)||DefaultRowHeight)}),co.subscribe(bo=>{bo&&(get_store_value(oo)&&oo.set(null),get_store_value(po)&&mo.actions.clear())}),po.subscribe(bo=>{bo&&get_store_value(co)&&io.set({})}),_o.subscribe(async({sourceCellId:bo,targetCellId:vo})=>{bo&&bo!==vo&&get_store_value(oo)!==bo&&oo.set(bo)})},UI=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$9,createStores:createStores$9,deriveStores:deriveStores$8,initialise:initialise$9},Symbol.toStringTag,{value:"Module"})),createStores$8=()=>{const to=writable([]),ue=derived(to,eo=>eo.map(no=>({...no,color:getUserColor(no),label:getUserLabel(no)})));return{users:{...to,subscribe:ue.subscribe}}},deriveStores$7=to=>{const{users:ue,focusedCellId:eo}=to;return{userCellMap:derived([ue,eo],([ro,oo])=>{let io={};return ro.forEach(so=>{var lo;const ao=(lo=so.gridMetadata)==null?void 0:lo.focusedCellId;ao&&ao!==oo&&(io[ao]=so)}),io})}},createActions$8=to=>{const{users:ue}=to;return{users:{...ue,actions:{updateUser:ro=>{const oo=get_store_value(ue);oo.some(io=>io.sessionId===ro.sessionId)?ue.update(io=>{const so=io.findIndex(ao=>ao.sessionId===ro.sessionId);return io[so]=ro,io.slice()}):ue.set([...oo,ro])},removeUser:ro=>{ue.update(oo=>oo.filter(io=>io.sessionId!==ro))}}}}},Users$2=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$8,createStores:createStores$8,deriveStores:deriveStores$7},Symbol.toStringTag,{value:"Module"})),createStores$7=()=>({validation:writable({})}),deriveStores$6=to=>{const{validation:ue}=to;return{validationRowLookupMap:derived(ue,no=>{const ro={};return Object.entries(no).forEach(([oo,io])=>{if(io){const{rowId:so}=parseCellID(oo);so!==void 0&&(ro[so]||(ro[so]=[]),ro[so].push(oo))}}),ro})}},createActions$7=to=>{const{validation:ue,focusedCellId:eo,validationRowLookupMap:no}=to;return{validation:{...ue,actions:{setError:(so,ao)=>{so&&ue.update(lo=>({...lo,[so]:ao}))},rowHasErrors:so=>{var ao;return((ao=get_store_value(no)[so])==null?void 0:ao.length)>0},focusFirstRowError:so=>{const ao=get_store_value(no)[so],lo=ao==null?void 0:ao[0];lo&&eo.set(lo)}}}}},initialise$8=to=>{const{validation:ue,previousFocusedRowId:eo,validationRowLookupMap:no}=to;eo.subscribe(ro=>{if(ro){const oo=get_store_value(no)[ro];oo!=null&&oo.length&&ue.update(io=>{for(let so of oo)delete io[so];return io})}})},Validation=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$7,createStores:createStores$7,deriveStores:deriveStores$6,initialise:initialise$8},Symbol.toStringTag,{value:"Module"})),deriveStores$5=to=>{const{rowHeight:ue,scrollableColumns:eo,rows:no,scrollTop:ro,scrollLeft:oo,width:io,height:so,rowChangeCache:ao,metadata:lo}=to,uo=derived([ro,ue],([_o,ho])=>Math.floor(_o/ho)),co=derived([so,ue],([_o,ho])=>Math.ceil(_o/ho)+1),fo=derived([no,uo,co,ao,lo],([_o,ho,go,bo,vo])=>_o.slice(ho,ho+go).map($o=>({...$o,...bo[$o._id],__metadata:vo[$o._id]}))),po=derived(oo,_o=>{const ho=MinColumnWidth;return Math.round(_o/ho)*ho}),mo=derived([eo,po,io],([_o,ho,go])=>{if(!_o.length)return{};let bo=0,vo=_o[0].width;for(;vo<ho&&bo<_o.length-1;)bo++,vo+=_o[bo].width;let $o=bo+1,wo=vo;for(;wo<go+ho&&$o<_o.length;)wo+=_o[$o].width,$o++;let ko={};return _o.slice(Math.max(0,bo),$o).forEach(So=>{ko[So.name]=!0}),ko});return{scrolledRowCount:uo,visualRowCapacity:co,renderedRows:fo,columnRenderMap:mo}},Viewport$2=Object.freeze(Object.defineProperty({__proto__:null,deriveStores:deriveStores$5},Symbol.toStringTag,{value:"Module"})),createStores$6=()=>({clipboard:writable({value:null,multiCellCopy:!1})}),deriveStores$4=to=>{const{clipboard:ue,focusedCellAPI:eo,selectedCellCount:no,config:ro,focusedRowId:oo}=to,io=derived(eo,ao=>ao!=null),so=derived([ue,eo,no,ro,oo],([ao,lo,uo,co,fo])=>{if(ao.value==null||!co.canEditRows||!lo||fo===NewRowID)return!1;const po=uo>1;return!(!ao.multiCellCopy&&!po&&lo.isReadonly())});return{copyAllowed:io,pasteAllowed:so}},createActions$6=to=>{const{clipboard:ue,focusedCellAPI:eo,copyAllowed:no,pasteAllowed:ro,selectedCells:oo,selectedCellCount:io,rowLookupMap:so,rowChangeCache:ao,rows:lo,focusedCellId:uo,columnLookupMap:co,visibleColumns:fo}=to,po=()=>{if(!get_store_value(no))return;const ho=get_store_value(oo),go=get_store_value(eo),vo=get_store_value(io)>1;if(vo){const $o=get_store_value(so),wo=get_store_value(ao),ko=[];for(const So of ho){const To=[];for(const Io of So){const{rowId:Ao="",field:Eo=""}=parseCellID(Io),Lo={...$o[Ao],...wo[Ao]};To.push(Lo[Eo])}ko.push(To)}ue.set({value:ko,multiCellCopy:!0})}else{const $o=go==null?void 0:go.getValue();ue.set({value:$o,multiCellCopy:vo});let wo="";$o!=null&&$o!==""&&(wo=typeof $o=="object"?JSON.stringify($o):$o),copyToClipboard(wo)}},mo=async ho=>{var $o,wo;if(!get_store_value(ro))return;const{value:go,multiCellCopy:bo}=get_store_value(ue),vo=get_store_value(io)>1;if(bo)if(vo){let ko=go;const So=get_store_value(oo),To=So.length,Io=So[0].length,Ao=go.length,Eo=go[0].length;if(To>Ao&&Io===Eo){ko=[];for(let Lo=0;Lo<To;Lo++)ko.push(go[Lo%Ao])}await _o(ko,ho)}else{const ko=get_store_value(uo),{rowId:So,field:To}=parseCellID(ko),Io=get_store_value(so),Ao=get_store_value(co),Eo=Io[So].__idx,Lo=Ao[To].__idx||0,No=get_store_value(lo),Do=get_store_value(fo),Po=Do.length,Mo=No.length,Uo=go.length,Vo=go[0].length,Wo=Math.min(Uo,Mo-Eo)-1,Zo=Math.min(Vo,Po-Lo)-1,Yo=No[Eo+Wo]._id,xo=Do[Lo+Zo].name,Go=getCellID(Yo,xo);Go===ko?($o=get_store_value(eo))==null||$o.setValue(go[0][0]):(oo.actions.selectRange(ko,Go),await _o(go,ho))}else if(vo){const ko=get_store_value(oo).map(So=>So.map(()=>go));await _o(ko,ho)}else(wo=get_store_value(eo))==null||wo.setValue(go??null)},_o=async(ho,go)=>{const bo=get_store_value(oo),vo=Math.min(ho.length,bo.length),$o=Math.min(ho[0].length,bo[0].length);let wo={};for(let ko=0;ko<vo;ko++)for(let So=0;So<$o;So++){const To=bo[ko][So];let{rowId:Io,field:Ao}=parseCellID(To);Io=Io,Ao=Ao,wo[Io]||(wo[Io]={}),wo[Io][Ao]=ho[ko][So]}await lo.actions.bulkUpdate(wo,go)};return{clipboard:{...ue,actions:{copy:po,paste:mo}}}},Clipboard=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$6,createStores:createStores$6,deriveStores:deriveStores$4},Symbol.toStringTag,{value:"Module"})),createStores$5=to=>{const{props:ue}=to,eo=co=>derivedMemo(ue,fo=>fo[co]),no=eo("datasource"),ro=eo("initialSortColumn"),oo=eo("initialSortOrder"),io=eo("initialFilter"),so=eo("fixedRowHeight"),ao=eo("schemaOverrides"),lo=eo("notifySuccess"),uo=eo("notifyError");return{datasource:no,initialSortColumn:ro,initialSortOrder:oo,initialFilter:io,fixedRowHeight:so,schemaOverrides:ao,notifySuccess:lo,notifyError:uo}},deriveStores$3=to=>{const{props:ue,definition:eo,hasNonAutoColumn:no}=to;return{config:derived([ue,eo,no],([oo,io,so])=>{var uo;let ao={...oo,canSelectRows:!1};const lo=(uo=oo.datasource)==null?void 0:uo.type;return lo==="viewV2"&&(ao.canEditColumns=!1,(io==null?void 0:io.type)===ViewV2Type.CALCULATION&&(ao.canAddRows=!1,ao.canEditRows=!1,ao.canDeleteRows=!1,ao.canExpandRows=!1)),so||(ao.canAddRows=!1),lo&&!["table","viewV2"].includes(lo)&&(ao.canAddRows=!1,ao.canEditRows=!1,ao.canDeleteRows=!1,ao.canExpandRows=!1,ao.canSaveSchema=!1,ao.canEditColumns=!1),ao.canSelectRows=!0,ao})}},Config=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$5,deriveStores:deriveStores$3},Symbol.toStringTag,{value:"Module"})),createStores$4=to=>{const{props:ue}=to,eo=get_store_value(ue);return{sort:memo({column:eo.initialSortColumn,order:eo.initialSortOrder||SortOrder.ASCENDING})}},initialise$7=to=>{const{sort:ue,initialSortColumn:eo,initialSortOrder:no,schema:ro}=to;eo.subscribe(io=>{ue.update(so=>({...so,column:io}))}),no.subscribe(io=>{ue.update(so=>({...so,order:io||SortOrder.ASCENDING}))}),derived([ue,ro],([io,so])=>!(io!=null&&io.column)||!so?!0:so[io.column]!=null).subscribe(io=>{io||ue.set({column:null,order:SortOrder.ASCENDING})})},Sort=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$4,initialise:initialise$7},Symbol.toStringTag,{value:"Module"})),createStores$3=to=>{const{props:ue}=to,eo=memo(get_store_value(ue).initialFilter??void 0),no=memo([]);return{filter:eo,inlineFilters:no}},deriveStores$2=to=>{const{filter:ue,inlineFilters:eo}=to;return{allFilters:derived([ue,eo],([ro,oo])=>{var so;if(!(oo!=null&&oo.length))return ro;const io={logicalOperator:UILogicalOperator.ALL,groups:[{logicalOperator:UILogicalOperator.ALL,filters:oo}]};return(so=ro==null?void 0:ro.groups)!=null&&so.length&&(io.groups=[...io.groups,...ro.groups]),io})}},createActions$5=to=>{const{filter:ue,inlineFilters:eo}=to;return{filter:{...ue,actions:{addInlineFilter:(ro,oo)=>{const io=`inline-${ro.name}`,so=ro.schema.type,ao={field:ro.name,id:io,operator:BasicOperator.STRING,valueType:"value",type:so,value:oo};so===FieldType.NUMBER?(ao.value=parseFloat(oo),ao.operator=BasicOperator.EQUAL):so===FieldType.BIGINT?ao.operator=BasicOperator.EQUAL:so===FieldType.ARRAY&&(ao.operator=ArrayOperator.CONTAINS),eo.update(lo=>(lo=lo==null?void 0:lo.filter(uo=>uo.id!==io),oo&&lo.push(ao),lo))}}}}},initialise$6=to=>{const{filter:ue,initialFilter:eo}=to;eo.subscribe(no=>ue.set(no??void 0))},Filter=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$5,createStores:createStores$3,deriveStores:deriveStores$2,initialise:initialise$6},Symbol.toStringTag,{value:"Module"})),createStores$2=to=>{const{notifySuccess:ue,notifyError:eo}=to;return{notifications:derived([ue,eo],([ro,oo])=>({success:ro||notifications.success,error:oo||notifications.error}))}},Notifications=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$2},Symbol.toStringTag,{value:"Module"})),createStores$1=()=>{const to=memo(null),ue=memo({}),eo=memo({});return{definition:to,schemaMutations:ue,subSchemaMutations:eo}},deriveStores$1=to=>{const{API:ue,definition:eo,schemaOverrides:no,datasource:ro,schemaMutations:oo,subSchemaMutations:io}=to,so=derived(eo,uo=>{const co=getDatasourceSchema({API:ue,datasource:get_store_value(ro),definition:uo??void 0});return co?(Object.keys(co).forEach(fo=>{typeof co[fo]!="object"&&(co[fo]={name:fo,type:co[fo]})}),co):null}),ao=derived([so,no,oo,io],([uo,co,fo,po])=>{if(!uo)return null;const mo=enrichSchemaWithRelColumns(uo),_o={};return Object.keys(mo||{}).forEach(ho=>{var go;if(_o[ho]={...mo==null?void 0:mo[ho],...co==null?void 0:co[ho],...fo[ho]},po[ho]){(go=_o[ho]).columns??(go.columns={});for(const bo of Object.keys(po[ho])){const vo=po[ho][bo];_o[ho].columns[bo]={..._o[ho].columns[bo],...vo}}}}),_o}),lo=derived([ro,eo],([uo,co])=>{var po,mo;let fo=uo==null?void 0:uo.type;return fo==="provider"&&(fo=(mo=(po=uo.value)==null?void 0:po.datasource)==null?void 0:mo.type),fo==="viewV2"&&co&&"type"in co&&co.type===ViewV2Type.CALCULATION?!1:!!fo&&["table","viewV2","link"].includes(fo)});return{schema:so,enrichedSchema:ao,hasBudibaseIdentifiers:lo}},createActions$4=to=>{const{API:ue,datasource:eo,definition:no,config:ro,dispatch:oo,table:io,viewV2:so,nonPlus:ao,schemaMutations:lo,subSchemaMutations:uo,schema:co,notifications:fo}=to,po=()=>{const Eo=get_store_value(eo),Lo=Eo==null?void 0:Eo.type;if(!Lo)return null;switch(Lo){case"table":return io;case"viewV2":return so;default:return ao}},mo=async()=>{const Eo=await getDatasourceDefinition({API:ue,datasource:get_store_value(eo)});no.set(Eo??null)},_o=async Eo=>{var No;const Lo=get_store_value(no);if(no.set(Eo),get_store_value(ro).canSaveSchema)try{await((No=po())==null?void 0:No.actions.saveDefinition(Eo)),oo("updatedatasource",Eo)}catch(Do){const Po=(Do==null?void 0:Do.message)||Do||"Unknown error";get_store_value(fo).error(`Error saving schema: ${Po}`),no.set(Lo)}},ho=async Eo=>{let Lo=lodashExports.cloneDeep(get_store_value(no));return Lo.primaryDisplay=Eo,Lo.schema&&(Lo.schema[Eo].constraints||(Lo.schema[Eo].constraints={}),Lo.schema[Eo].constraints.presence={allowEmpty:!1},"default"in Lo.schema[Eo]&&delete Lo.schema[Eo].default),await _o(Lo)},go=(Eo,Lo)=>{!Eo||!Lo||lo.update(No=>({...No,[Eo]:{...No[Eo],...Lo}}))},bo=(Eo,Lo,No)=>{!Eo||!Lo||!No||uo.update(Do=>({...Do,[Lo]:{...Do[Lo],[Eo]:{...(Do[Lo]||{})[Eo],...No}}}))},vo=async()=>{if(!get_store_value(ro).canSaveSchema)return;const Eo=get_store_value(no),Lo=get_store_value(lo),No=get_store_value(uo),Do=get_store_value(co)||{};let Po={};Object.keys(Do).forEach(Mo=>{var Uo;if(Po[Mo]={...Do[Mo],...Lo[Mo]},No[Mo]){(Uo=Po[Mo]).columns??(Uo.columns={});for(const Vo of Object.keys(No[Mo])){const Wo=No[Mo][Vo];Po[Mo].columns[Vo]={...Po[Mo].columns[Vo],...Wo}}}}),await _o({...Eo,schema:Po}),$o()},$o=()=>{lo.set({}),uo.set({})};return{datasource:{...eo,actions:{refreshDefinition:mo,saveDefinition:_o,addRow:async Eo=>{var Lo;return await((Lo=po())==null?void 0:Lo.actions.addRow(Eo))},updateRow:async Eo=>{var Lo;return await((Lo=po())==null?void 0:Lo.actions.updateRow(Eo))},deleteRows:async Eo=>{var Lo;return await((Lo=po())==null?void 0:Lo.actions.deleteRows(Eo))},getRow:async Eo=>{var Lo;return await((Lo=po())==null?void 0:Lo.actions.getRow(Eo))},isDatasourceValid:Eo=>{var Lo;return(Lo=po())==null?void 0:Lo.actions.isDatasourceValid(Eo)},canUseColumn:Eo=>{var Lo;return(Lo=po())==null?void 0:Lo.actions.canUseColumn(Eo)},changePrimaryDisplay:ho,addSchemaMutation:go,addSubSchemaMutation:bo,saveSchemaMutations:vo,resetSchemaMutations:$o}}}},Datasource$1=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$4,createStores:createStores$1,deriveStores:deriveStores$1},Symbol.toStringTag,{value:"Module"})),SuppressErrors$1=!0,createActions$3=to=>{const{API:ue,datasource:eo,columns:no}=to,ro=async uo=>{await ue.saveTable(uo)},oo=async uo=>{var fo;uo={...uo,tableId:(fo=get_store_value(eo))==null?void 0:fo.tableId};const co=await ue.saveRow(uo,SuppressErrors$1);return{...co,_id:co._id}};return{table:{actions:{saveDefinition:ro,addRow:oo,updateRow:oo,deleteRows:async uo=>{await ue.deleteRows(get_store_value(eo).tableId,uo)},getRow:async uo=>{var po;const co=await ue.searchTable(get_store_value(eo).tableId,{limit:1,query:{equal:{_id:uo}},paginate:!1}),fo=(po=co==null?void 0:co.rows)==null?void 0:po[0];if(fo)return{...fo,_id:fo._id}},isDatasourceValid:uo=>(uo==null?void 0:uo.type)==="table"&&!!(uo!=null&&uo.tableId),canUseColumn:uo=>get_store_value(no).some(co=>co.name===uo)}}}},initialise$5=to=>{const{datasource:ue,fetch:eo,filter:no,inlineFilters:ro,allFilters:oo,sort:io,table:so,initialFilter:ao,initialSortColumn:lo,initialSortOrder:uo}=to;let co=[];ue.subscribe(fo=>{co==null||co.forEach(po=>po()),co=[],so.actions.isDatasourceValid(fo)&&(no.set(get_store_value(ao)??void 0),ro.set([]),io.set({column:get_store_value(lo),order:get_store_value(uo)||SortOrder.ASCENDING}),co.push(oo.subscribe(po=>{var _o,ho;const mo=get_store_value(eo);((ho=(_o=mo==null?void 0:mo.options)==null?void 0:_o.datasource)==null?void 0:ho.tableId)===fo.tableId&&mo.update({filter:po})})),co.push(io.subscribe(po=>{var _o,ho;const mo=get_store_value(eo);((ho=(_o=mo==null?void 0:mo.options)==null?void 0:_o.datasource)==null?void 0:ho.tableId)===fo.tableId&&mo.update({sortOrder:po.order||SortOrder.ASCENDING,sortColumn:po.column??void 0})})))})},Table$1=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$3,initialise:initialise$5},Symbol.toStringTag,{value:"Module"})),SuppressErrors=!0,createActions$2=to=>{const{API:ue,datasource:eo,columns:no}=to,ro=async uo=>{await ue.viewV2.update(uo)},oo=async uo=>{const co=get_store_value(eo);uo={...uo,tableId:co==null?void 0:co.tableId,_viewId:co==null?void 0:co.id};const fo=await ue.saveRow(uo,SuppressErrors);return{...fo,_id:fo._id,_viewId:uo._viewId}};return{viewV2:{actions:{saveDefinition:ro,addRow:oo,updateRow:oo,deleteRows:async uo=>{await ue.deleteRows(get_store_value(eo).id,uo)},getRow:async uo=>{var po;const co=await ue.viewV2.fetch(get_store_value(eo).id,{limit:1,query:{equal:{_id:uo}},paginate:!1}),fo=(po=co==null?void 0:co.rows)==null?void 0:po[0];if(fo)return{...fo,_id:fo._id}},isDatasourceValid:uo=>(uo==null?void 0:uo.type)==="viewV2"&&!!(uo!=null&&uo.id)&&!!(uo!=null&&uo.tableId),canUseColumn:uo=>get_store_value(no).some(co=>co.name===uo&&co.visible)}}}},initialise$4=to=>{const{definition:ue,datasource:eo,sort:no,rows:ro,filter:oo,inlineFilters:io,allFilters:so,subscribe:ao,viewV2:lo,initialFilter:uo,initialSortColumn:co,initialSortOrder:fo,config:po,fetch:mo}=to;let _o=[];eo.subscribe(ho=>{if(_o==null||_o.forEach(bo=>bo()),_o=[],!lo.actions.isDatasourceValid(ho))return;oo.set(get_store_value(uo)??void 0),io.set([]),no.set({column:get_store_value(co),order:get_store_value(fo)||SortOrder.ASCENDING}),_o.push(ue.subscribe(bo=>{var vo,$o;get_store_value(po).canSaveSchema&&(!bo||!("id"in bo)||(bo==null?void 0:bo.id)===ho.id&&(get_store_value(co)||no.set({column:(vo=bo.sort)==null?void 0:vo.field,order:(($o=bo.sort)==null?void 0:$o.order)||SortOrder.ASCENDING}),get_store_value(uo)||oo.set(bo.queryUI)))}));function go(bo,vo){const $o=bo.column??null,wo=(vo==null?void 0:vo.field)??null;if($o!==wo)return!0;if(!$o)return!1;const ko=bo.order??null,So=(vo==null?void 0:vo.order)??null;return ko!==So}_o.push(no.subscribe(async bo=>{var wo,ko;const vo=get_store_value(ue);if(!vo||!("id"in vo)||(vo==null?void 0:vo.id)!==ho.id||!go(bo,vo.sort))return;get_store_value(po).canSaveSchema&&await eo.actions.saveDefinition({...vo,sort:{field:bo.column,order:bo.order||SortOrder.ASCENDING}});const $o=get_store_value(mo);((ko=(wo=$o==null?void 0:$o.options)==null?void 0:wo.datasource)==null?void 0:ko.id)===ho.id&&$o.update({sortOrder:bo.order,sortColumn:bo.column??void 0})})),_o==null||_o.push(oo.subscribe(async bo=>{if(!get_store_value(po).canSaveSchema)return;const vo=get_store_value(ue);!vo||!("id"in vo)||(vo==null?void 0:vo.id)===ho.id&&JSON.stringify(bo)!==JSON.stringify(vo.queryUI)&&(await eo.actions.saveDefinition({...vo,queryUI:bo}),await ro.actions.refreshData())})),_o.push(io.subscribe(bo=>{var $o,wo;if(!get_store_value(po).canSaveSchema)return;const vo=get_store_value(mo);((wo=($o=vo==null?void 0:vo.options)==null?void 0:$o.datasource)==null?void 0:wo.id)===ho.id&&vo.update({filter:bo})})),_o.push(so.subscribe(bo=>{var $o,wo;if(get_store_value(po).canSaveSchema)return;const vo=get_store_value(mo);((wo=($o=vo==null?void 0:vo.options)==null?void 0:$o.datasource)==null?void 0:wo.id)===ho.id&&vo.update({filter:bo})})),_o.push(ao("show-column",async()=>{await ro.actions.refreshData()}))})},ViewV2=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$2,initialise:initialise$4},Symbol.toStringTag,{value:"Module"})),createActions$1=to=>{const{columns:ue,table:eo,viewV2:no}=to,ro=async()=>{throw"This datasource does not support updating the definition"},oo=async()=>{throw"This datasource does not support saving rows"};return{nonPlus:{actions:{saveDefinition:ro,addRow:oo,updateRow:oo,deleteRows:async()=>{throw"This datasource does not support deleting rows"},getRow:()=>{throw"This datasource does not support fetching individual rows"},isDatasourceValid:uo=>!eo.actions.isDatasourceValid(uo)&&!no.actions.isDatasourceValid(uo)&&(uo==null?void 0:uo.type)!=null,canUseColumn:uo=>get_store_value(ue).some(co=>co.name===uo)}}}},isSameDatasource=(to,ue)=>JSON.stringify(to)===JSON.stringify(ue),initialise$3=to=>{const{datasource:ue,sort:eo,filter:no,inlineFilters:ro,allFilters:oo,nonPlus:io,initialFilter:so,initialSortColumn:ao,initialSortOrder:lo,fetch:uo}=to;let co=[];ue.subscribe(fo=>{co==null||co.forEach(po=>po()),co=[],io.actions.isDatasourceValid(fo)&&(no.set(get_store_value(so)??void 0),ro.set([]),eo.set({column:get_store_value(ao),order:get_store_value(lo)||SortOrder.ASCENDING}),co.push(oo.subscribe(po=>{var _o;const mo=get_store_value(uo);isSameDatasource((_o=mo==null?void 0:mo.options)==null?void 0:_o.datasource,fo)&&(mo==null||mo.update({filter:po}))})),co.push(eo.subscribe(po=>{var _o;const mo=get_store_value(uo);isSameDatasource((_o=mo==null?void 0:mo.options)==null?void 0:_o.datasource,fo)&&(mo==null||mo.update({sortOrder:po.order||SortOrder.ASCENDING,sortColumn:po.column??void 0}))})))})},NonPlus=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$1,initialise:initialise$3},Symbol.toStringTag,{value:"Module"})),createActions=to=>{const{API:ue}=to;let eo={};const no=()=>{eo={}},ro=async so=>(eo[so]||(eo[so]=ue.fetchTableDefinition(so)),await eo[so]);return{cache:{actions:{getPrimaryDisplayForTableId:async so=>{var uo,co;const ao=await ro(so);return(ao==null?void 0:ao.primaryDisplay)||((co=(uo=ao==null?void 0:ao.schema)==null?void 0:uo[0])==null?void 0:co.name)},getTable:async so=>await ro(so),resetCache:no}}}},initialise$2=to=>{const{datasource:ue,cache:eo}=to;ue.subscribe(eo.actions.resetCache)},Cache=Object.freeze(Object.defineProperty({__proto__:null,createActions,initialise:initialise$2},Symbol.toStringTag,{value:"Module"})),createStores=()=>({metadata:writable({})}),deriveStores=to=>{const{columns:ue}=to;return{conditions:derivedMemo(ue,no=>{let ro=[];for(let oo of no)for(let io of oo.conditions||[])ro.push({...io,column:oo.name,type:oo.schema.type});return ro})}},initialise$1=to=>{const{metadata:ue,conditions:eo,rows:no}=to;eo.subscribe(ro=>{let oo={};if(ro!=null&&ro.length)for(let io of get_store_value(no))oo[io._id]=evaluateConditions(io,ro);ue.set(oo)}),no.subscribe(ro=>{const oo=get_store_value(eo);if(!(oo!=null&&oo.length))return;const io=get_store_value(ue);let so={};for(let ao of ro){const lo=io[ao._id];!(!ao._rev||lo&&lo.version!==ao._rev||ao._rev===EXTERNAL_ROW_REV)&&lo||(io[ao._id]=evaluateConditions(ao,oo))}Object.keys(so).length&&ue.update(ao=>({...ao,...so}))})},TypeCoercionMap={[FieldType.NUMBER]:parseFloat,[FieldType.DATETIME]:to=>to?new Date(to).toISOString():null,[FieldType.BOOLEAN]:to=>`${to}`.toLowerCase().trim()==="true"?!0:`${to}`.toLowerCase().trim()==="false"?!1:null},evaluateConditions=(to,ue)=>{const eo={version:to._rev,row:{},cell:{}};for(let no of ue)try{let{column:ro,type:oo,referenceValue:io,operator:so,metadataKey:ao,metadataValue:lo,target:uo}=no,co=to[ro],fo=oo;oo===FieldType.FORMULA&&(co===!0||co===!1?fo=FieldType.BOOLEAN:typeof co=="number"&&(fo=FieldType.NUMBER));const po=TypeCoercionMap[fo];po&&(co=po(co),io=po(io));let _o=buildQuery$1([{operator:so,type:oo,field:"value",value:io}]);_o.onEmptyFilter=EmptyFilterOption.RETURN_NONE,runQuery$1([{value:co}],_o).length>0&&(uo==="row"?eo.row={...eo.row,[ao]:lo}:eo.cell[ro]={...eo.cell[ro],[ao]:lo})}catch{}return eo},Conditions=Object.freeze(Object.defineProperty({__proto__:null,createStores,deriveStores,initialise:initialise$1},Symbol.toStringTag,{value:"Module"})),DependencyOrderedStores=[Sort,Filter,Bounds,Table$1,ViewV2,NonPlus,Datasource$1,Columns,Config,Scroll,Validation,Rows,Conditions,UI,Resize,Viewport$2,Reorder,Users$2,Menu,Pagination,Clipboard,Notifications,Cache],attachStores=to=>{var ue,eo,no,ro;for(let oo of DependencyOrderedStores)"createStores"in oo&&(to={...to,...(ue=oo.createStores)==null?void 0:ue.call(oo,to)});for(let oo of DependencyOrderedStores)"deriveStores"in oo&&(to={...to,...(eo=oo.deriveStores)==null?void 0:eo.call(oo,to)});for(let oo of DependencyOrderedStores)"createActions"in oo&&(to={...to,...(no=oo.createActions)==null?void 0:no.call(oo,to)});for(let oo of DependencyOrderedStores)"initialise"in oo&&((ro=oo.initialise)==null||ro.call(oo,to));return to};function create_if_block_1$2V(to){let ue,eo;return ue=new ProgressBar({props:{size:"L",value:to[3],duration:duration$2,width:"100%"}}),{c(){create_component(ue.$$.fragment)},m(no,ro){mount_component(ue,no,ro),eo=!0},p(no,ro){const oo={};ro&8&&(oo.value=no[3]),ue.$set(oo)},i(no){eo||(transition_in(ue.$$.fragment,no),eo=!0)},o(no){transition_out(ue.$$.fragment,no),eo=!1},d(no){destroy_component(ue,no)}}}function create_default_slot_3$2q(to){let ue,eo,no,ro,oo,io=to[2]&&create_if_block_1$2V(to);return{c(){ue=text("Are you sure you want to delete "),eo=text(to[4]),no=text(` rows?
|
|
541
|
+
`),ro=element("a"),ro.textContent="documentation",oo=text(" on app migrations."),attr(ro,"href","https://docs.budibase.com/docs/app-migrations"),attr(ro,"target","_blank"),attr(ro,"class","svelte-1kjb5e")},m(io,so){insert$1(io,ue,so),insert$1(io,eo,so),insert$1(io,no,so),insert$1(io,ro,so),insert$1(io,oo,so)},d(io){io&&(detach(ue),detach(eo),detach(no),detach(ro),detach(oo))}}}function create_fragment$aJ(to){let ue,eo,no,ro;function oo(co,fo){return co[0]?create_else_block_1$x:create_if_block_1$2W}let io=oo(to),so=io(to);function ao(co,fo){return co[0]?create_else_block$22:create_if_block$58}let lo=ao(to),uo=lo(to);return{c(){ue=element("div"),eo=element("span"),so.c(),no=space$1(),ro=element("span"),uo.c(),attr(eo,"class","header svelte-1kjb5e"),attr(ro,"class","subtext svelte-1kjb5e"),attr(ue,"class","loading svelte-1kjb5e"),toggle_class(ue,"timeout",to[0])},m(co,fo){insert$1(co,ue,fo),append$2(ue,eo),so.m(eo,null),append$2(ue,no),append$2(ue,ro),uo.m(ro,null)},p(co,[fo]){io!==(io=oo(co))&&(so.d(1),so=io(co),so&&(so.c(),so.m(eo,null))),lo!==(lo=ao(co))&&(uo.d(1),uo=lo(co),uo&&(uo.c(),uo.m(ro,null))),fo&1&&toggle_class(ue,"timeout",co[0])},i:noop$5,o:noop$5,d(co){co&&detach(ue),so.d(),uo.d()}}}function instance$aM(to,ue,eo){let{isMigrationDone:no}=ue,{onMigrationDone:ro}=ue,{timeoutSeconds:oo=60}=ue,io=!1;async function so(){let ao=0;for(;;){const lo=5e3+Math.random()*5e3;if(await new Promise(co=>setTimeout(co,lo)),ao+=lo,await no()){ro();return}if(ao>oo*1e3){eo(0,io=!0);return}}}return so(),to.$$set=ao=>{"isMigrationDone"in ao&&eo(1,no=ao.isMigrationDone),"onMigrationDone"in ao&&eo(2,ro=ao.onMigrationDone),"timeoutSeconds"in ao&&eo(3,oo=ao.timeoutSeconds)},[io,no,ro,oo]}class Updating extends SvelteComponent{constructor(ue){super(),init$3(this,ue,instance$aM,create_fragment$aJ,safe_not_equal,{isMigrationDone:1,onMigrationDone:2,timeoutSeconds:3})}}const createEventManagers=()=>{const to=createEventDispatcher();let ue={};return{dispatch:(ro,oo)=>{to(ro,oo);const io=ue[ro]||[];for(let so=0;so<io.length;so++)io[so](oo)},subscribe:(ro,oo)=>{const io=ue[ro]||[];return ue[ro]=[...io,oo],()=>{ue[ro]=ue[ro].filter(so=>so!==oo)}}}},createStores$g=()=>{const to=writable({left:0,top:0,width:0,height:0}),ue=derived(to,no=>no.width,0),eo=derived(to,no=>no.height,0);return{bounds:to,height:eo,width:ue}},Bounds=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$g},Symbol.toStringTag,{value:"Module"})),SmallRowHeight=36,MediumRowHeight=64,LargeRowHeight=92,DefaultRowHeight=SmallRowHeight,VPadding=0,HPadding=80,ScrollBarSize=8,GutterWidth=72,DefaultColumnWidth=200,MinColumnWidth=56,NewRowID="new",BlankRowID="blank",GeneratedIDPrefix="‽‽",CellIDSeparator="‽‽",RowPageSize=100,FocusedCellMinOffset=ScrollBarSize*3,ControlsHeight=50,PopoverMinWidth=200,PopoverMaxWidth=400,PopoverMaxHeight=236,MaxCellRenderOverflow=222,Constants=Object.freeze(Object.defineProperty({__proto__:null,BlankRowID,CellIDSeparator,ControlsHeight,DefaultColumnWidth,DefaultRowHeight,FocusedCellMinOffset,GeneratedIDPrefix,GutterWidth,HPadding,LargeRowHeight,MaxCellRenderOverflow,MediumRowHeight,MinColumnWidth,NewRowID,PopoverMaxHeight,PopoverMaxWidth,PopoverMinWidth,RowPageSize,ScrollBarSize,SmallRowHeight,VPadding},Symbol.toStringTag,{value:"Module"})),createStores$f=()=>{const to=writable([]),ue=derived(to,eo=>{let no=GutterWidth,ro=0;return eo.map(oo=>{const io={...oo,__idx:ro,__left:no};return oo.visible&&(ro++,no+=oo.width??0),io})});return{columns:{...to,subscribe:ue.subscribe}}},deriveStores$b=to=>{const{columns:ue}=to,eo=derived(ue,ao=>{let lo={};return ao.forEach(uo=>{lo[uo.name]=uo}),lo}),no=derived(ue,ao=>ao.filter(lo=>!lo.related)),ro=derived(ue,ao=>ao.filter(lo=>lo.visible)),oo=derived(ro,ao=>ao.find(lo=>lo.primaryDisplay)),io=derived(ro,ao=>ao.filter(lo=>!lo.primaryDisplay)),so=derived(ue,ao=>ao.filter(uo=>{var co;return!((co=uo.schema)!=null&&co.autocolumn)}).length>0);return{tableColumns:no,displayColumn:oo,columnLookupMap:eo,visibleColumns:ro,scrollableColumns:io,hasNonAutoColumn:so}},createActions$e=to=>{const{columns:ue,datasource:eo}=to;return{columns:{...ue,actions:{changeAllColumnWidths:async oo=>{get_store_value(ue).forEach(so=>{const{related:ao}=so,lo={width:oo};ao?eo.actions.addSubSchemaMutation(ao.subField,ao.field,lo):eo.actions.addSchemaMutation(so.name,lo)}),await eo.actions.saveSchemaMutations()},isReadonly:oo=>oo!=null&&oo.schema?oo.schema.autocolumn||oo.schema.disabled||oo.schema.type==="formula"||oo.schema.type==="ai"||oo.schema.readonly:!1}}}},initialise$d=to=>{const{definition:ue,columns:eo,displayColumn:no,enrichedSchema:ro}=to,oo=io=>{const so=get_store_value(ue);if(!io||!so){eo.set([]);return}const ao=get_store_value(no);let lo;const uo=so.primaryDisplay||(ao==null?void 0:ao.name);uo&&io[uo]&&(lo=uo),eo.set(Object.keys(io).map(co=>{const fo=io[co],po={type:fo.type,name:co,label:fo.displayName||co,schema:fo,width:fo.width||DefaultColumnWidth,visible:fo.visible??!0,readonly:fo.readonly,order:fo.order,conditions:fo.conditions,related:fo.related,calculationType:fo.calculationType,format:fo.format,__left:void 0,__idx:void 0};return co===lo&&(po.order=0,po.primaryDisplay=!0),po}).sort((co,fo)=>{var go,bo;if(co.name===lo)return-1;if(fo.name===lo)return 1;const po=co.order,mo=fo.order;if(po!=null&&mo!=null)return po<mo?-1:1;if(po!=null)return-1;if(mo!=null)return 1;const _o=(go=co.schema)==null?void 0:go.autocolumn,ho=(bo=fo.schema)==null?void 0:bo.autocolumn;return _o===ho?0:_o?1:-1}))};ro.subscribe(oo)},Columns=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$e,createStores:createStores$f,deriveStores:deriveStores$b,initialise:initialise$d},Symbol.toStringTag,{value:"Module"})),parseCellID=to=>{if(!to)return{rowId:void 0,field:void 0};const ue=to.split(CellIDSeparator),eo=ue.pop();return{rowId:ue.join(CellIDSeparator),field:eo}},getCellID=(to,ue)=>`${to}${CellIDSeparator}${ue}`,parseEventLocation=to=>{var eo,no,ro,oo;const ue=to;return{x:ue.clientX??((no=(eo=ue.touches)==null?void 0:eo[0])==null?void 0:no.clientX),y:ue.clientY??((oo=(ro=ue.touches)==null?void 0:ro[0])==null?void 0:oo.clientY)}},generateRowID=()=>`${GeneratedIDPrefix}${uuid$1()}`,isGeneratedRowID=to=>to==null?void 0:to.startsWith(GeneratedIDPrefix),createStores$e=()=>({menu:writable({left:0,top:0,visible:!1,multiRowMode:!1,multiCellMode:!1})}),createActions$d=to=>{const{menu:ue,focusedCellId:eo,gridID:no,selectedRows:ro,selectedRowCount:oo,selectedCellMap:io,selectedCellCount:so}=to;return{menu:{...ue,actions:{open:(uo,co)=>{var bo;co.preventDefault(),co.stopPropagation();const fo=document.getElementById(no),po=(bo=fo==null?void 0:fo.getElementsByClassName("grid-data-outer"))==null?void 0:bo[0];if(!po)return;const mo=co.target.getBoundingClientRect(),_o=po.getBoundingClientRect();let ho=!1;if(get_store_value(oo)>1){const{rowId:vo}=parseCellID(uo);vo!==void 0&&get_store_value(ro)[vo]&&(ho=!0)}let go=!1;!ho&&get_store_value(so)>1&&get_store_value(io)[uo]&&(go=!0),!ho&&!go&&eo.set(uo),ue.set({left:mo.left-_o.left+co.offsetX,top:mo.top-_o.top+co.offsetY,visible:!0,multiRowMode:ho,multiCellMode:go})},close:()=>{ue.update(uo=>({...uo,visible:!1}))}}}}},Menu=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$d,createStores:createStores$e},Symbol.toStringTag,{value:"Module"})),initialise$c=to=>{const{scrolledRowCount:ue,rows:eo,visualRowCapacity:no}=to,ro=derived(eo,so=>so.length,0),oo=derived([ue,ro,no],([so,ao,lo])=>Math.max(0,ao-so-lo));derived([oo,ro],([so,ao])=>so<25&&ao).subscribe(so=>{so&&eo.actions.loadNextPage()})},Pagination=Object.freeze(Object.defineProperty({__proto__:null,initialise:initialise$c},Symbol.toStringTag,{value:"Module"})),reorderInitialState={sourceColumn:null,targetColumn:null,insertAfter:!1,breakpoints:[],gridLeft:0,width:0,increment:0},createStores$d=()=>{const to=writable(reorderInitialState),ue=derived(to,eo=>!!eo.sourceColumn,!1);return{reorder:to,isReordering:ue}},createActions$c=to=>{const{reorder:ue,columns:eo,columnLookupMap:no,scrollableColumns:ro,scroll:oo,bounds:io,visibleColumns:so,datasource:ao,stickyWidth:lo,width:uo,scrollLeft:co,maxScrollLeft:fo}=to;let po=0,mo,_o;const ho=(Io,Ao)=>{const Eo=get_store_value(ro),Lo=get_store_value(io),No=get_store_value(lo),Do=Eo.map(Mo=>({x:Mo.__left-No,column:Mo.name,insertAfter:!1})),Po=Eo[Eo.length-1];Po&&Do.push({x:Po.__left+Po.width-No,column:Po.name,insertAfter:!0}),ue.set({sourceColumn:Io,targetColumn:null,breakpoints:Do,gridLeft:Lo.left,width:Lo.width}),document.addEventListener("mousemove",go),document.addEventListener("mouseup",wo),document.addEventListener("touchmove",go),document.addEventListener("touchend",wo),document.addEventListener("touchcancel",wo),go(Ao)},go=Io=>{const{x:Ao}=parseEventLocation(Io);po=Ao,bo();const Eo=get_store_value(co),Lo=get_store_value(fo),No=get_store_value(ue),Do=Math.min(140,get_store_value(uo)/6),Po=16,Mo=Math.max(0,No.gridLeft+No.width-Ao),Uo=Math.max(0,Ao-No.gridLeft);if(Mo<Do&&Eo<Lo){const Wo=(Do-Mo)/Do*Po;ue.update(Zo=>({...Zo,increment:Wo})),vo()}else if(Uo<Do&&Eo>0){const Wo=-1*(Do-Uo)/Do*Po;ue.update(Zo=>({...Zo,increment:Wo})),vo()}else $o()},bo=()=>{const Io=get_store_value(ue),Ao=get_store_value(co);let Eo,Lo=Number.MAX_SAFE_INTEGER;const No=po-Io.gridLeft+Ao;Io.breakpoints.forEach(Do=>{const Po=Math.abs(Do.x-No);Po<Lo&&(Lo=Po,Eo=Do)}),Eo&&(Eo.column!==Io.targetColumn||Eo.insertAfter!==Io.insertAfter)&&ue.update(Do=>({...Do,targetColumn:Eo.column,insertAfter:Eo.insertAfter}))},vo=()=>{_o||(_o=!0,mo=setInterval(()=>{const Io=get_store_value(fo),{increment:Ao}=get_store_value(ue);oo.update(Eo=>({...Eo,left:Math.max(0,Math.min(Io,Eo.left+Ao))})),bo()},10))},$o=()=>{_o=!1,clearInterval(mo)},wo=async()=>{$o(),document.removeEventListener("mousemove",go),document.removeEventListener("mouseup",wo),document.removeEventListener("touchmove",go),document.removeEventListener("touchend",wo),document.removeEventListener("touchcancel",wo);const{sourceColumn:Io,targetColumn:Ao,insertAfter:Eo}=get_store_value(ue);ue.set(reorderInitialState),Io!==Ao&&await ko({sourceColumn:Io,targetColumn:Ao,insertAfter:Eo})},ko=async({sourceColumn:Io,targetColumn:Ao,insertAfter:Eo=!1})=>{const Lo=get_store_value(eo);let No=Lo.findIndex(Po=>Po.name===Io),Do=Lo.findIndex(Po=>Po.name===Ao);Eo&&Do++,eo.update(Po=>{const Mo=Po.splice(No,1);return--Do<No&&Do++,Po.toSpliced(Do,0,Mo[0])}),get_store_value(eo).forEach((Po,Mo)=>{const{related:Uo}=Po,Vo={order:Mo};Uo?ao.actions.addSubSchemaMutation(Uo.subField,Uo.field,Vo):ao.actions.addSchemaMutation(Po.name,Vo)}),await ao.actions.saveSchemaMutations()};return{reorder:{...ue,actions:{startReordering:ho,stopReordering:wo,moveColumnLeft:async Io=>{var No;const Ao=get_store_value(so),Lo=get_store_value(no)[Io].__idx;await ko({sourceColumn:Io,targetColumn:(No=Ao[Lo-1])==null?void 0:No.name})},moveColumnRight:async Io=>{var No;const Ao=get_store_value(so),Lo=get_store_value(no)[Io].__idx;Lo!==Ao.length-1&&await ko({sourceColumn:Io,targetColumn:(No=Ao[Lo+1])==null?void 0:No.name,insertAfter:!0})}}}}},Reorder=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$c,createStores:createStores$d},Symbol.toStringTag,{value:"Module"})),initialState$3={initialMouseX:null,initialWidth:null,column:null,width:0,left:0},createStores$c=()=>{const to=writable(initialState$3),ue=derived(to,eo=>eo.column!=null,!1);return{resize:to,isResizing:ue}},createActions$b=to=>{const{resize:ue,ui:eo,datasource:no}=to,ro=(ao,lo)=>{const{x:uo}=parseEventLocation(lo);lo.stopPropagation(),lo.preventDefault(),eo.actions.blur(),ue.set({width:ao.width,left:ao.__left,initialWidth:ao.width,initialMouseX:uo,column:ao.name,related:ao.related}),document.addEventListener("mousemove",oo),document.addEventListener("mouseup",io),document.addEventListener("touchmove",oo),document.addEventListener("touchend",io),document.addEventListener("touchcancel",io)},oo=ao=>{const{initialMouseX:lo,initialWidth:uo,width:co,column:fo,related:po}=get_store_value(ue),{x:mo}=parseEventLocation(ao),_o=mo-lo,ho=Math.round(Math.max(MinColumnWidth,uo+_o));Math.abs(co-ho)<5||(po?no.actions.addSubSchemaMutation(po.subField,po.field,{width:co}):no.actions.addSchemaMutation(fo,{width:co}),ue.update(go=>({...go,width:ho})))},io=async()=>{const ao=get_store_value(ue);ue.set(initialState$3),document.removeEventListener("mousemove",oo),document.removeEventListener("mouseup",io),document.removeEventListener("touchmove",oo),document.removeEventListener("touchend",io),document.removeEventListener("touchcancel",io),ao.width!==ao.initialWidth&&await no.actions.saveSchemaMutations()};return{resize:{...ue,actions:{startResizing:ro,resetSize:async ao=>{no.actions.addSchemaMutation(ao.name,{width:DefaultColumnWidth}),await no.actions.saveSchemaMutations()}}}}},Resize=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$b,createStores:createStores$c},Symbol.toStringTag,{value:"Module"})),createStores$b=()=>{const to=writable([]),ue=writable(!1),eo=writable(!1),no=writable(!1),ro=writable({}),oo=writable({}),io=writable(!1),so=writable(null),ao=writable(null);let lo=!1;return ue.subscribe(uo=>{uo?lo=!0:lo&&eo.set(!0)}),{rows:to,fetch:ao,loaded:eo,refreshing:no,loading:ue,rowChangeCache:ro,inProgressChanges:oo,hasNextPage:io,error:so}},deriveStores$a=to=>{const{rows:ue,enrichedSchema:eo}=to,no=derived([ue,eo],([oo,io])=>{const so=Object.values(io||{}),ao=so.filter(uo=>uo.related),lo=so.filter(uo=>uo.format);return oo.map((uo,co)=>{const fo=ao.reduce((mo,_o)=>{const ho=io[_o.related.field];return mo[_o.name]=getRelatedTableValues(uo,{..._o,related:_o.related},ho),mo},{}),po=lo.reduce((mo,_o)=>(mo[_o.name]=_o.format(uo),mo),{});return{...uo,...fo,__formatted:po,__idx:co}})}),ro=derived(no,oo=>{let io={};for(let so=0;so<oo.length;so++)io[oo[so]._id]=oo[so];return io});return{rows:{...ue,subscribe:no.subscribe},rowLookupMap:ro}},createActions$a=to=>{const{rows:ue,rowLookupMap:eo,definition:no,allFilters:ro,loading:oo,sort:io,datasource:so,API:ao,scroll:lo,validation:uo,focusedCellId:co,columns:fo,rowChangeCache:po,inProgressChanges:mo,hasNextPage:_o,error:ho,notifications:go,fetch:bo,hasBudibaseIdentifiers:vo,refreshing:$o,columnLookupMap:wo}=to,ko=writable(!1);let So={},To=null,Io=null;so.subscribe(async ls=>{if(To==null||To(),To=null,bo.set(null),ko.set(!1),oo.set(!0),!so.actions.isDatasourceValid(ls)){ho.set("Datasource is invalid");return}await tick();const Jo=get_store_value(ro),hs=get_store_value(io),ks=fetchData({API:ao,datasource:ls,options:{filter:Jo,sortColumn:hs.column,sortOrder:hs.order,limit:RowPageSize,paginate:!0,clientSideLimiting:!1}});To=ks.subscribe(async cs=>{if(cs.error){let _s="An unknown error occurred";cs.error.status===403?_s="You don't have access to this data":cs.error.message&&(_s=cs.error.message),ho.set(_s)}else if(cs.loaded&&!cs.loading){ho.set(null),_o.set(cs.hasNextPage);const _s=get_store_value(ko),Is=cs.resetKey!==Io,Bs=Io;Io=cs.resetKey,!_s&&Bs&&(ue.set([]),await tick()),(!_s||Is)&&no.set(cs.definition??null),_s?Is&&lo.update(Hs=>({...Hs,top:0})):(ko.set(!0),lo.set({top:0,left:0})),Go(cs.rows,Is),oo.set(!1)}$o.set(cs.loading)}),bo.set(ks)});const Ao=(ls,Jo)=>{var ks,cs;let hs;if(typeof Jo=="string"?hs=Jo:typeof(Jo==null?void 0:Jo.message)=="string"&&(hs=Jo.message),typeof Jo!="string"&&!((ks=Jo==null?void 0:Jo.json)!=null&&ks.validationErrors)&&hs){const{field:_s}=parseCellID(get_store_value(co));_s&&(Jo={json:{validationErrors:{[_s]:Jo.message}}})}if(typeof Jo!="string"&&((cs=Jo==null?void 0:Jo.json)!=null&&cs.validationErrors)){const _s=Object.keys(Jo.json.validationErrors),Is=get_store_value(fo);let Bs=[],Hs=[];for(let Ds of _s)so.actions.canUseColumn(Ds)?Bs.push(Ds):Hs.push(Ds);const{json:Rs}=Jo;for(let Ds of Bs){let Js=Rs.validationErrors[Ds];Array.isArray(Js)&&(Js=Js[0]),(typeof Js!="string"||!Js.length)&&(Jo="Something went wrong"),uo.actions.setError(getCellID(ls,Ds),capitalise$1(Js));const Cs=Is.findIndex(da=>da.name===Ds);Cs!==-1&&!Is[Cs].visible&&fo.update(da=>(da[Cs].visible=!0,da.slice()))}for(let Ds of Hs)get_store_value(go).error(`${Ds} is required but is missing`)}else get_store_value(go).error(hs||"An unknown error occurred")},Eo=async({row:ls,idx:Jo,bubble:hs=!1,notify:ks=!0})=>{try{const cs=await so.actions.addRow(ls);return Jo!=null?(So[cs._id]=!0,ue.update(_s=>(_s.splice(Jo,0,cs),_s.slice()))):Go([cs]),ks&&get_store_value(go).success("Row created successfully"),cs}catch(cs){if(hs)throw cs;Ao(NewRowID,cs),uo.actions.focusFirstRowError(NewRowID)}},Lo=async ls=>{let Jo=Ko(ls);delete Jo._id,delete Jo._rev;try{const hs=await Eo({row:Jo,idx:ls.__idx+1,bubble:!0,notify:!1});return get_store_value(go).success("Duplicated 1 row"),hs}catch(hs){Ao(ls._id,hs),uo.actions.focusFirstRowError(ls._id)}},No=async(ls,Jo)=>{const hs=get_store_value(eo),ks=ls.map(Rs=>{var Ds;return(Ds=hs[Rs._id])==null?void 0:Ds.__idx}),cs=Math.max(...ks),_s=ls.length,Is=ls.map(Rs=>{let Ds=Ko(Rs);return delete Ds._id,delete Ds._rev,Ds});let Bs=[],Hs=0;for(let Rs=0;Rs<_s;Rs++){try{const Ds=await so.actions.addRow(Is[Rs]);Bs.push(Ds),So[Ds._id]=!0,await sleep$2(50)}catch(Ds){Hs++,console.error("Duplicating row failed",Ds)}Jo==null||Jo((Rs+1)/_s)}return Bs.length&&ue.update(Rs=>Rs.toSpliced(cs+1,0,...Bs)),Hs?get_store_value(go).error(`Failed to duplicate ${Hs} of ${_s} rows`):Bs.length&&get_store_value(go).success(`Duplicated ${Bs.length} rows`),Bs},Do=(ls,Jo)=>{var _s;const hs=get_store_value(ue),cs=(_s=get_store_value(eo)[ls])==null?void 0:_s.__idx;Jo?cs!=null?ue.update(Is=>(Is[cs]={...Jo},Is)):Go([Jo]):cs!=null&&Xo([hs[cs]])},Po=async ls=>{try{const Jo=await so.actions.getRow(ls);Do(ls,Jo)}catch{}},Mo=async()=>{var ls;await((ls=get_store_value(bo))==null?void 0:ls.getInitialData())},Uo=(ls,Jo)=>{const hs=Object.keys(Jo||{});return!ls||!hs.length?!1:hs.some(ks=>ls[ks]!==Jo[ks])},Vo=(ls,Jo)=>{var _s,Is;const hs=get_store_value(eo),ks=get_store_value(wo),cs=hs[ls];for(let Bs of Object.keys(Jo||{})){const Hs=(Is=(_s=ks[Bs])==null?void 0:_s.schema)==null?void 0:Is.type;(Hs===FieldType.STRING||Hs==FieldType.LONGFORM)&&Jo[Bs]!=null&&typeof Jo[Bs]!="string"&&(Jo[Bs]=JSON.stringify(Jo[Bs]))}return!cs||!Uo(cs,Jo)?!1:(po.update(Bs=>({...Bs,[ls]:{...Bs[ls],...Jo}})),!0)},Wo=async({rowId:ls,changes:Jo=null,updateState:hs=!0,handleErrors:ks=!0})=>{const _s=get_store_value(eo)[ls];if(_s==null)return;let Is;try{mo.update(Ds=>({...Ds,[ls]:(Ds[ls]||0)+1}));const Bs=get_store_value(po)[ls],Hs={...Ko(_s),...Bs,...Jo};Is=await so.actions.updateRow(Hs),Is!=null&&Is._id?hs&&ue.update(Ds=>(Ds[_s.__idx]=Is,Ds.slice())):Is!=null&&Is.id&&await Po(Is.id);const Rs=get_store_value(po)[ls];po.update(Ds=>(Object.keys(Bs||{}).forEach(Js=>{Bs[Js]===(Rs==null?void 0:Rs[Js])&&delete Ds[ls][Js]}),Ds))}catch(Bs){ks&&(Ao(ls,Bs),uo.actions.focusFirstRowError(ls))}return mo.update(Bs=>({...Bs,[ls]:(Bs[ls]||1)-1})),Is},Zo=async({rowId:ls,column:Jo,value:hs,apply:ks=!0})=>{Vo(ls,{[Jo]:hs})&&ks&&await Wo({rowId:ls})},Yo=async(ls,Jo)=>{const hs=Object.keys(ls||{}),ks=hs.length;if(!ks)return;const cs=get_store_value(wo);let _s=[],Is=0;for(let Bs=0;Bs<ks;Bs++){const Hs=hs[Bs];let Rs=ls[Hs]||{};for(let Ds of Object.keys(Rs)){const Js=cs[Ds];fo.actions.isReadonly(Js)&&delete Rs[Ds]}if(!Object.keys(Rs).length){Jo==null||Jo((Bs+1)/ks);continue}try{const Ds=await Wo({rowId:Hs,changes:ls[Hs],updateState:!1,handleErrors:!1});Ds?_s.push(Ds):Is++,await sleep$2(50)}catch(Ds){Is++,console.error("Failed to update row",Ds)}Jo==null||Jo((Bs+1)/ks)}if(_s.length){const Bs=get_store_value(eo);ue.update(Hs=>{for(let Rs of _s){const Ds=Bs[Rs._id].__idx;Hs[Ds]=Rs}return Hs.slice()})}if(Is){const Bs=`row${ks===1?"":"s"}`;get_store_value(go).error(`Failed to update ${Is} of ${ks} ${Bs}`)}else if(_s.length){const Bs=`row${_s.length===1?"":"s"}`;get_store_value(go).success(`Updated ${_s.length} ${Bs}`)}},xo=async ls=>{ls!=null&&ls.length&&(ls.forEach(Jo=>delete Jo.__idx),await so.actions.deleteRows(ls),Xo(ls))},Go=(ls,Jo)=>{var _s;Jo&&(So={});let hs=[],ks;const cs=get_store_value(vo);for(let Is=0;Is<ls.length;Is++)ks=ls[Is],!cs&&!((_s=ks._id)!=null&&_s.length)&&(ks._id=generateRowID()),So[ks._id]||(So[ks._id]=!0,hs.push(ks));Jo?ue.set(hs):hs.length&&ue.update(Is=>[...Is,...hs])},Xo=ls=>{const Jo=ls.map(hs=>hs._id);ue.update(hs=>hs.filter(ks=>!Jo.includes(ks._id)))},as=()=>{var ls;(ls=get_store_value(bo))==null||ls.nextPage()},Ko=ls=>{let Jo={...ls};return delete Jo.__idx,delete Jo.__metadata,delete Jo.__formatted,!get_store_value(vo)&&isGeneratedRowID(Jo._id)&&delete Jo._id,Jo};return{rows:{...ue,actions:{addRow:Eo,duplicateRow:Lo,bulkDuplicate:No,updateValue:Zo,applyRowChanges:Wo,deleteRows:xo,loadNextPage:as,refreshRow:Po,replaceRow:Do,refreshData:Mo,cleanRow:Ko,bulkUpdate:Yo}}}},initialise$b=to=>{const{rowChangeCache:ue,inProgressChanges:eo,previousFocusedRowId:no,previousFocusedCellId:ro,rows:oo,validation:io}=to;no.subscribe(so=>{so&&!get_store_value(eo)[so]&&Object.keys(get_store_value(ue)[so]||{}).length&&ue.update(ao=>(delete ao[so],ao))}),ro.subscribe(async so=>{if(!so)return;let{rowId:ao,field:lo}=parseCellID(so);ao=ao,lo=lo;const uo=lo in(get_store_value(ue)[ao]||{}),co=io.actions.rowHasErrors(ao),fo=get_store_value(eo)[ao];ao&&!co&&uo&&!fo&&await oo.actions.applyRowChanges({rowId:ao})})},Rows=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$a,createStores:createStores$b,deriveStores:deriveStores$a,initialise:initialise$b},Symbol.toStringTag,{value:"Module"})),createStores$a=()=>{const to=writable({left:0,top:0}),ue=derived(to,no=>Math.round(no.top)),eo=derived(to,no=>Math.round(no.left));return{scroll:to,scrollTop:ue,scrollLeft:eo}},deriveStores$9=to=>{const{rows:ue,visibleColumns:eo,displayColumn:no,rowHeight:ro,width:oo,height:io,buttonColumnWidth:so,config:ao}=to,lo=derived(no,go=>((go==null?void 0:go.width)||0)+GutterWidth),uo=derived([eo,so],([go,bo])=>{let vo=GutterWidth+Math.max(bo,HPadding);return go.forEach($o=>{vo+=$o.width}),vo}),co=derived([oo,lo],([go,bo])=>go+bo),fo=derived([uo,co],([go,bo])=>Math.round(Math.max(go-bo,0))),po=derived([uo,co],([go,bo])=>go>bo),mo=derived([ue,ro,po,ao],([go,bo,vo,$o])=>{let wo=go.length*bo+VPadding;return vo&&(wo+=ScrollBarSize*3),$o.canAddRows&&(wo+=bo),wo}),_o=derived([io,mo],([go,bo])=>Math.round(Math.max(bo-go,0))),ho=derived([mo,io],([go,bo])=>go>bo);return{stickyWidth:lo,contentHeight:mo,contentWidth:uo,screenWidth:co,maxScrollTop:_o,maxScrollLeft:fo,showHScrollbar:po,showVScrollbar:ho}},initialise$a=to=>{const{focusedCellId:ue,focusedRow:eo,scroll:no,bounds:ro,rowHeight:oo,stickyWidth:io,scrollTop:so,maxScrollTop:ao,scrollLeft:lo,maxScrollLeft:uo,buttonColumnWidth:co,columnLookupMap:fo}=to,po=derived([so,ao],([_o,ho])=>_o>ho,!1),mo=derived([lo,uo],([_o,ho])=>_o>ho,!1);po.subscribe(_o=>{_o&&no.update(ho=>({...ho,top:get_store_value(ao)}))}),mo.subscribe(_o=>{_o&&no.update(ho=>({...ho,left:get_store_value(uo)}))}),ue.subscribe(async _o=>{await tick();const ho=get_store_value(eo),go=get_store_value(no),bo=get_store_value(ro),vo=get_store_value(oo);if(ho){const To=ho.__idx*vo,Io=go.top+bo.height-vo-FocusedCellMinOffset;let Ao=To-Io;if(Ao>0)no.update(Eo=>({...Eo,top:Eo.top+Ao}));else{const Eo=go.top-To+FocusedCellMinOffset;Eo>0&&no.update(Lo=>({...Lo,top:Math.max(0,Lo.top-Eo)}))}}const{field:$o}=parseCellID(_o),wo=get_store_value(fo)[$o];if(!wo||wo.primaryDisplay)return;const ko=get_store_value(io);let So=go.left-wo.__left+FocusedCellMinOffset+ko;if(So>0)no.update(To=>({...To,left:Math.max(0,To.left-So)}));else{const To=get_store_value(co),Io=wo.__left+wo.width,Ao=bo.width+go.left-FocusedCellMinOffset-To;So=Io-Ao-ko,So>0&&no.update(Eo=>({...Eo,left:Eo.left+So}))}})},Scroll=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$a,deriveStores:deriveStores$9,initialise:initialise$a},Symbol.toStringTag,{value:"Module"})),createStores$9=to=>{const{props:ue}=to,eo=writable(null),no=writable(null),ro=writable({}),oo=writable(null),io=writable(get_store_value(ue).fixedRowHeight||DefaultRowHeight),so=writable(null),ao=writable(null),lo=writable(!1),uo=writable(!1),co=writable(!1),fo=writable(0),po=writable({active:!1,sourceCellId:null,targetCellId:null});return{focusedCellId:eo,focusedCellAPI:no,previousFocusedRowId:so,previousFocusedCellId:ao,hoveredRowId:oo,rowHeight:io,gridFocused:lo,keyboardBlocked:uo,isDragging:co,buttonColumnWidth:fo,selectedRows:ro,cellSelection:po}},deriveStores$8=to=>{const{focusedCellId:ue,rows:eo,rowLookupMap:no,rowHeight:ro,width:oo,selectedRows:io,cellSelection:so,columnLookupMap:ao,visibleColumns:lo}=to,uo=derived(ue,vo=>parseCellID(vo).rowId??null),co=derived([uo,no],([vo,$o])=>{if(vo!==null)return vo===NewRowID?{_id:NewRowID}:$o[vo]}),fo=derived(ro,vo=>vo>=LargeRowHeight?3:vo>=MediumRowHeight?2:1),po=derived(oo,vo=>vo<600),mo=derived(io,vo=>Object.keys(vo).length),_o=derived(so,vo=>vo.active),ho=derived([so,no,ao],([vo,$o,wo])=>{var Go,Xo;const{sourceCellId:ko,targetCellId:So}=vo;if(!ko||!So||ko===So)return[];const To=get_store_value(eo),Io=get_store_value(lo),Ao=parseCellID(ko),Eo=parseCellID(So);if(Ao.rowId===NewRowID)return[];const Lo=(Go=$o[Ao.rowId])==null?void 0:Go.__idx,No=(Xo=$o[Eo.rowId])==null?void 0:Xo.__idx;if(Lo==null||No==null)return[];const Do=Math.min(Lo,No);let Po=Math.max(Lo,No);Po=Math.min(Po,Do+49);const Mo=wo[Ao.field].__idx||0,Uo=wo[Eo.field].__idx||0,Vo=Math.min(Mo,Uo),Wo=Math.max(Mo,Uo);let Zo=[],Yo,xo;for(let as=Do;as<=Po;as++){let Ko=[];for(let ls=Vo;ls<=Wo;ls++)Yo=To[as]._id,xo=Io[ls].name,Ko.push(getCellID(Yo,xo));Zo.push(Ko)}return Zo}),go=derived(ho,vo=>{let $o={};for(let wo of vo)for(let ko of wo)$o[ko]=!0;return $o}),bo=derived(go,vo=>Object.keys(vo).length);return{focusedRowId:uo,focusedRow:co,contentLines:fo,compact:po,selectedRowCount:mo,isSelectingCells:_o,selectedCells:ho,selectedCellMap:go,selectedCellCount:bo}},createActions$9=to=>{const{focusedCellId:ue,hoveredRowId:eo,selectedRows:no,rowLookupMap:ro,rows:oo,selectedRowCount:io,cellSelection:so,selectedCells:ao}=to;let lo=null;const uo=()=>{ue.set(null),eo.set(null),go()},co=bo=>{no.update(vo=>{let $o={...vo,[bo]:!vo[bo]};return $o[bo]?lo=get_store_value(ro)[bo].__idx:delete $o[bo],$o})},fo=bo=>{if(!get_store_value(io)){co(bo);return}if(lo==null)return;const vo=get_store_value(ro)[bo].__idx;if(lo===vo)return;const $o=Math.min(lo,vo),wo=Math.max(lo,vo),ko=get_store_value(oo);no.update(So=>{for(let To=$o;To<=wo;To++)So[ko[To]._id]=!0;return So})},po=bo=>{so.set({active:!0,sourceCellId:bo,targetCellId:bo})},mo=bo=>{so.update(vo=>({...vo,targetCellId:bo}))},_o=()=>{so.update(bo=>({...bo,active:!1}))},ho=(bo,vo)=>{so.set({active:!1,sourceCellId:bo,targetCellId:vo})},go=()=>{so.set({active:!1,sourceCellId:null,targetCellId:null})};return{ui:{actions:{blur:uo}},selectedRows:{...no,actions:{toggleRow:co,bulkSelectRows:fo}},selectedCells:{...ao,actions:{startSelecting:po,updateTarget:mo,stopSelecting:_o,selectRange:ho,clear:go}}}},initialise$9=to=>{const{focusedRowId:ue,previousFocusedRowId:eo,previousFocusedCellId:no,rowLookupMap:ro,focusedCellId:oo,selectedRows:io,hoveredRowId:so,definition:ao,rowHeight:lo,fixedRowHeight:uo,selectedRowCount:co,menu:fo,selectedCellCount:po,selectedCells:mo,cellSelection:_o}=to;ro.subscribe(async bo=>{await tick();const vo=get_store_value(ue),$o=get_store_value(io),wo=get_store_value(so),ko=To=>bo[To]!=null;vo&&!ko(vo)&&oo.set(null),wo&&!ko(wo)&&so.set(null);const So=Object.keys($o);if(So.length){let To={...$o},Io=!1;for(let Ao=0;Ao<So.length;Ao++)ko(So[Ao])||(delete To[So[Ao]],Io=!0);Io&&io.set(To)}});let ho=null;ue.subscribe(bo=>{eo.set(ho),ho=bo});let go=null;oo.subscribe(bo=>{no.set(go),go=bo,bo&&get_store_value(so)&&so.set(null),bo&&get_store_value(co)&&io.set({}),bo&&get_store_value(po)&&mo.actions.clear(),fo.actions.close()}),ao.subscribe(bo=>{get_store_value(uo)||lo.set((bo==null?void 0:bo.rowHeight)||DefaultRowHeight)}),uo.subscribe(bo=>{var vo;bo?lo.set(bo):lo.set(((vo=get_store_value(ao))==null?void 0:vo.rowHeight)||DefaultRowHeight)}),co.subscribe(bo=>{bo&&(get_store_value(oo)&&oo.set(null),get_store_value(po)&&mo.actions.clear())}),po.subscribe(bo=>{bo&&get_store_value(co)&&io.set({})}),_o.subscribe(async({sourceCellId:bo,targetCellId:vo})=>{bo&&bo!==vo&&get_store_value(oo)!==bo&&oo.set(bo)})},UI=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$9,createStores:createStores$9,deriveStores:deriveStores$8,initialise:initialise$9},Symbol.toStringTag,{value:"Module"})),createStores$8=()=>{const to=writable([]),ue=derived(to,eo=>eo.map(no=>({...no,color:getUserColor(no),label:getUserLabel(no)})));return{users:{...to,subscribe:ue.subscribe}}},deriveStores$7=to=>{const{users:ue,focusedCellId:eo}=to;return{userCellMap:derived([ue,eo],([ro,oo])=>{let io={};return ro.forEach(so=>{var lo;const ao=(lo=so.gridMetadata)==null?void 0:lo.focusedCellId;ao&&ao!==oo&&(io[ao]=so)}),io})}},createActions$8=to=>{const{users:ue}=to;return{users:{...ue,actions:{updateUser:ro=>{const oo=get_store_value(ue);oo.some(io=>io.sessionId===ro.sessionId)?ue.update(io=>{const so=io.findIndex(ao=>ao.sessionId===ro.sessionId);return io[so]=ro,io.slice()}):ue.set([...oo,ro])},removeUser:ro=>{ue.update(oo=>oo.filter(io=>io.sessionId!==ro))}}}}},Users$2=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$8,createStores:createStores$8,deriveStores:deriveStores$7},Symbol.toStringTag,{value:"Module"})),createStores$7=()=>({validation:writable({})}),deriveStores$6=to=>{const{validation:ue}=to;return{validationRowLookupMap:derived(ue,no=>{const ro={};return Object.entries(no).forEach(([oo,io])=>{if(io){const{rowId:so}=parseCellID(oo);so!==void 0&&(ro[so]||(ro[so]=[]),ro[so].push(oo))}}),ro})}},createActions$7=to=>{const{validation:ue,focusedCellId:eo,validationRowLookupMap:no}=to;return{validation:{...ue,actions:{setError:(so,ao)=>{so&&ue.update(lo=>({...lo,[so]:ao}))},rowHasErrors:so=>{var ao;return((ao=get_store_value(no)[so])==null?void 0:ao.length)>0},focusFirstRowError:so=>{const ao=get_store_value(no)[so],lo=ao==null?void 0:ao[0];lo&&eo.set(lo)}}}}},initialise$8=to=>{const{validation:ue,previousFocusedRowId:eo,validationRowLookupMap:no}=to;eo.subscribe(ro=>{if(ro){const oo=get_store_value(no)[ro];oo!=null&&oo.length&&ue.update(io=>{for(let so of oo)delete io[so];return io})}})},Validation=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$7,createStores:createStores$7,deriveStores:deriveStores$6,initialise:initialise$8},Symbol.toStringTag,{value:"Module"})),deriveStores$5=to=>{const{rowHeight:ue,scrollableColumns:eo,rows:no,scrollTop:ro,scrollLeft:oo,width:io,height:so,rowChangeCache:ao,metadata:lo}=to,uo=derived([ro,ue],([_o,ho])=>Math.floor(_o/ho)),co=derived([so,ue],([_o,ho])=>Math.ceil(_o/ho)+1),fo=derived([no,uo,co,ao,lo],([_o,ho,go,bo,vo])=>_o.slice(ho,ho+go).map($o=>({...$o,...bo[$o._id],__metadata:vo[$o._id]}))),po=derived(oo,_o=>{const ho=MinColumnWidth;return Math.round(_o/ho)*ho}),mo=derived([eo,po,io],([_o,ho,go])=>{if(!_o.length)return{};let bo=0,vo=_o[0].width;for(;vo<ho&&bo<_o.length-1;)bo++,vo+=_o[bo].width;let $o=bo+1,wo=vo;for(;wo<go+ho&&$o<_o.length;)wo+=_o[$o].width,$o++;let ko={};return _o.slice(Math.max(0,bo),$o).forEach(So=>{ko[So.name]=!0}),ko});return{scrolledRowCount:uo,visualRowCapacity:co,renderedRows:fo,columnRenderMap:mo}},Viewport$2=Object.freeze(Object.defineProperty({__proto__:null,deriveStores:deriveStores$5},Symbol.toStringTag,{value:"Module"})),createStores$6=()=>({clipboard:writable({value:null,multiCellCopy:!1})}),deriveStores$4=to=>{const{clipboard:ue,focusedCellAPI:eo,selectedCellCount:no,config:ro,focusedRowId:oo}=to,io=derived(eo,ao=>ao!=null),so=derived([ue,eo,no,ro,oo],([ao,lo,uo,co,fo])=>{if(ao.value==null||!co.canEditRows||!lo||fo===NewRowID)return!1;const po=uo>1;return!(!ao.multiCellCopy&&!po&&lo.isReadonly())});return{copyAllowed:io,pasteAllowed:so}},createActions$6=to=>{const{clipboard:ue,focusedCellAPI:eo,copyAllowed:no,pasteAllowed:ro,selectedCells:oo,selectedCellCount:io,rowLookupMap:so,rowChangeCache:ao,rows:lo,focusedCellId:uo,columnLookupMap:co,visibleColumns:fo}=to,po=()=>{if(!get_store_value(no))return;const ho=get_store_value(oo),go=get_store_value(eo),vo=get_store_value(io)>1;if(vo){const $o=get_store_value(so),wo=get_store_value(ao),ko=[];for(const So of ho){const To=[];for(const Io of So){const{rowId:Ao="",field:Eo=""}=parseCellID(Io),Lo={...$o[Ao],...wo[Ao]};To.push(Lo[Eo])}ko.push(To)}ue.set({value:ko,multiCellCopy:!0})}else{const $o=go==null?void 0:go.getValue();ue.set({value:$o,multiCellCopy:vo});let wo="";$o!=null&&$o!==""&&(wo=typeof $o=="object"?JSON.stringify($o):$o),copyToClipboard(wo)}},mo=async ho=>{var $o,wo;if(!get_store_value(ro))return;const{value:go,multiCellCopy:bo}=get_store_value(ue),vo=get_store_value(io)>1;if(bo)if(vo){let ko=go;const So=get_store_value(oo),To=So.length,Io=So[0].length,Ao=go.length,Eo=go[0].length;if(To>Ao&&Io===Eo){ko=[];for(let Lo=0;Lo<To;Lo++)ko.push(go[Lo%Ao])}await _o(ko,ho)}else{const ko=get_store_value(uo),{rowId:So,field:To}=parseCellID(ko),Io=get_store_value(so),Ao=get_store_value(co),Eo=Io[So].__idx,Lo=Ao[To].__idx||0,No=get_store_value(lo),Do=get_store_value(fo),Po=Do.length,Mo=No.length,Uo=go.length,Vo=go[0].length,Wo=Math.min(Uo,Mo-Eo)-1,Zo=Math.min(Vo,Po-Lo)-1,Yo=No[Eo+Wo]._id,xo=Do[Lo+Zo].name,Go=getCellID(Yo,xo);Go===ko?($o=get_store_value(eo))==null||$o.setValue(go[0][0]):(oo.actions.selectRange(ko,Go),await _o(go,ho))}else if(vo){const ko=get_store_value(oo).map(So=>So.map(()=>go));await _o(ko,ho)}else(wo=get_store_value(eo))==null||wo.setValue(go??null)},_o=async(ho,go)=>{const bo=get_store_value(oo),vo=Math.min(ho.length,bo.length),$o=Math.min(ho[0].length,bo[0].length);let wo={};for(let ko=0;ko<vo;ko++)for(let So=0;So<$o;So++){const To=bo[ko][So];let{rowId:Io,field:Ao}=parseCellID(To);Io=Io,Ao=Ao,wo[Io]||(wo[Io]={}),wo[Io][Ao]=ho[ko][So]}await lo.actions.bulkUpdate(wo,go)};return{clipboard:{...ue,actions:{copy:po,paste:mo}}}},Clipboard=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$6,createStores:createStores$6,deriveStores:deriveStores$4},Symbol.toStringTag,{value:"Module"})),createStores$5=to=>{const{props:ue}=to,eo=co=>derivedMemo(ue,fo=>fo[co]),no=eo("datasource"),ro=eo("initialSortColumn"),oo=eo("initialSortOrder"),io=eo("initialFilter"),so=eo("fixedRowHeight"),ao=eo("schemaOverrides"),lo=eo("notifySuccess"),uo=eo("notifyError");return{datasource:no,initialSortColumn:ro,initialSortOrder:oo,initialFilter:io,fixedRowHeight:so,schemaOverrides:ao,notifySuccess:lo,notifyError:uo}},deriveStores$3=to=>{const{props:ue,definition:eo,hasNonAutoColumn:no}=to;return{config:derived([ue,eo,no],([oo,io,so])=>{var uo;let ao={...oo,canSelectRows:!1};const lo=(uo=oo.datasource)==null?void 0:uo.type;return lo==="viewV2"&&(ao.canEditColumns=!1,(io==null?void 0:io.type)===ViewV2Type.CALCULATION&&(ao.canAddRows=!1,ao.canEditRows=!1,ao.canDeleteRows=!1,ao.canExpandRows=!1)),so||(ao.canAddRows=!1),lo&&!["table","viewV2"].includes(lo)&&(ao.canAddRows=!1,ao.canEditRows=!1,ao.canDeleteRows=!1,ao.canExpandRows=!1,ao.canSaveSchema=!1,ao.canEditColumns=!1),ao.canSelectRows=!0,ao})}},Config=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$5,deriveStores:deriveStores$3},Symbol.toStringTag,{value:"Module"})),createStores$4=to=>{const{props:ue}=to,eo=get_store_value(ue);return{sort:memo({column:eo.initialSortColumn,order:eo.initialSortOrder||SortOrder.ASCENDING})}},initialise$7=to=>{const{sort:ue,initialSortColumn:eo,initialSortOrder:no,schema:ro}=to;eo.subscribe(io=>{ue.update(so=>({...so,column:io}))}),no.subscribe(io=>{ue.update(so=>({...so,order:io||SortOrder.ASCENDING}))}),derived([ue,ro],([io,so])=>!(io!=null&&io.column)||!so?!0:so[io.column]!=null).subscribe(io=>{io||ue.set({column:null,order:SortOrder.ASCENDING})})},Sort=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$4,initialise:initialise$7},Symbol.toStringTag,{value:"Module"})),createStores$3=to=>{const{props:ue}=to,eo=memo(get_store_value(ue).initialFilter??void 0),no=memo([]);return{filter:eo,inlineFilters:no}},deriveStores$2=to=>{const{filter:ue,inlineFilters:eo}=to;return{allFilters:derived([ue,eo],([ro,oo])=>{var so;if(!(oo!=null&&oo.length))return ro;const io={logicalOperator:UILogicalOperator.ALL,groups:[{logicalOperator:UILogicalOperator.ALL,filters:oo}]};return(so=ro==null?void 0:ro.groups)!=null&&so.length&&(io.groups=[...io.groups,...ro.groups]),io})}},createActions$5=to=>{const{filter:ue,inlineFilters:eo}=to;return{filter:{...ue,actions:{addInlineFilter:(ro,oo)=>{const io=`inline-${ro.name}`,so=ro.schema.type,ao={field:ro.name,id:io,operator:BasicOperator.STRING,valueType:"value",type:so,value:oo};so===FieldType.NUMBER?(ao.value=parseFloat(oo),ao.operator=BasicOperator.EQUAL):so===FieldType.BIGINT?ao.operator=BasicOperator.EQUAL:so===FieldType.ARRAY&&(ao.operator=ArrayOperator.CONTAINS),eo.update(lo=>(lo=lo==null?void 0:lo.filter(uo=>uo.id!==io),oo&&lo.push(ao),lo))}}}}},initialise$6=to=>{const{filter:ue,initialFilter:eo}=to;eo.subscribe(no=>ue.set(no??void 0))},Filter=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$5,createStores:createStores$3,deriveStores:deriveStores$2,initialise:initialise$6},Symbol.toStringTag,{value:"Module"})),createStores$2=to=>{const{notifySuccess:ue,notifyError:eo}=to;return{notifications:derived([ue,eo],([ro,oo])=>({success:ro||notifications.success,error:oo||notifications.error}))}},Notifications=Object.freeze(Object.defineProperty({__proto__:null,createStores:createStores$2},Symbol.toStringTag,{value:"Module"})),createStores$1=()=>{const to=memo(null),ue=memo({}),eo=memo({});return{definition:to,schemaMutations:ue,subSchemaMutations:eo}},deriveStores$1=to=>{const{API:ue,definition:eo,schemaOverrides:no,datasource:ro,schemaMutations:oo,subSchemaMutations:io}=to,so=derived(eo,uo=>{const co=getDatasourceSchema({API:ue,datasource:get_store_value(ro),definition:uo??void 0});return co?(Object.keys(co).forEach(fo=>{typeof co[fo]!="object"&&(co[fo]={name:fo,type:co[fo]})}),co):null}),ao=derived([so,no,oo,io],([uo,co,fo,po])=>{if(!uo)return null;const mo=enrichSchemaWithRelColumns(uo),_o={};return Object.keys(mo||{}).forEach(ho=>{var go;if(_o[ho]={...mo==null?void 0:mo[ho],...co==null?void 0:co[ho],...fo[ho]},po[ho]){(go=_o[ho]).columns??(go.columns={});for(const bo of Object.keys(po[ho])){const vo=po[ho][bo];_o[ho].columns[bo]={..._o[ho].columns[bo],...vo}}}}),_o}),lo=derived([ro,eo],([uo,co])=>{var po,mo;let fo=uo==null?void 0:uo.type;return fo==="provider"&&(fo=(mo=(po=uo.value)==null?void 0:po.datasource)==null?void 0:mo.type),fo==="viewV2"&&co&&"type"in co&&co.type===ViewV2Type.CALCULATION?!1:!!fo&&["table","viewV2","link"].includes(fo)});return{schema:so,enrichedSchema:ao,hasBudibaseIdentifiers:lo}},createActions$4=to=>{const{API:ue,datasource:eo,definition:no,config:ro,dispatch:oo,table:io,viewV2:so,nonPlus:ao,schemaMutations:lo,subSchemaMutations:uo,schema:co,notifications:fo}=to,po=()=>{const Eo=get_store_value(eo),Lo=Eo==null?void 0:Eo.type;if(!Lo)return null;switch(Lo){case"table":return io;case"viewV2":return so;default:return ao}},mo=async()=>{const Eo=await getDatasourceDefinition({API:ue,datasource:get_store_value(eo)});no.set(Eo??null)},_o=async Eo=>{var No;const Lo=get_store_value(no);if(no.set(Eo),get_store_value(ro).canSaveSchema)try{await((No=po())==null?void 0:No.actions.saveDefinition(Eo)),oo("updatedatasource",Eo)}catch(Do){const Po=(Do==null?void 0:Do.message)||Do||"Unknown error";get_store_value(fo).error(`Error saving schema: ${Po}`),no.set(Lo)}},ho=async Eo=>{let Lo=lodashExports.cloneDeep(get_store_value(no));return Lo.primaryDisplay=Eo,Lo.schema&&(Lo.schema[Eo].constraints||(Lo.schema[Eo].constraints={}),Lo.schema[Eo].constraints.presence={allowEmpty:!1},"default"in Lo.schema[Eo]&&delete Lo.schema[Eo].default),await _o(Lo)},go=(Eo,Lo)=>{!Eo||!Lo||lo.update(No=>({...No,[Eo]:{...No[Eo],...Lo}}))},bo=(Eo,Lo,No)=>{!Eo||!Lo||!No||uo.update(Do=>({...Do,[Lo]:{...Do[Lo],[Eo]:{...(Do[Lo]||{})[Eo],...No}}}))},vo=async()=>{if(!get_store_value(ro).canSaveSchema)return;const Eo=get_store_value(no),Lo=get_store_value(lo),No=get_store_value(uo),Do=get_store_value(co)||{};let Po={};Object.keys(Do).forEach(Mo=>{var Uo;if(Po[Mo]={...Do[Mo],...Lo[Mo]},No[Mo]){(Uo=Po[Mo]).columns??(Uo.columns={});for(const Vo of Object.keys(No[Mo])){const Wo=No[Mo][Vo];Po[Mo].columns[Vo]={...Po[Mo].columns[Vo],...Wo}}}}),await _o({...Eo,schema:Po}),$o()},$o=()=>{lo.set({}),uo.set({})};return{datasource:{...eo,actions:{refreshDefinition:mo,saveDefinition:_o,addRow:async Eo=>{var Lo;return await((Lo=po())==null?void 0:Lo.actions.addRow(Eo))},updateRow:async Eo=>{var Lo;return await((Lo=po())==null?void 0:Lo.actions.updateRow(Eo))},deleteRows:async Eo=>{var Lo;return await((Lo=po())==null?void 0:Lo.actions.deleteRows(Eo))},getRow:async Eo=>{var Lo;return await((Lo=po())==null?void 0:Lo.actions.getRow(Eo))},isDatasourceValid:Eo=>{var Lo;return(Lo=po())==null?void 0:Lo.actions.isDatasourceValid(Eo)},canUseColumn:Eo=>{var Lo;return(Lo=po())==null?void 0:Lo.actions.canUseColumn(Eo)},changePrimaryDisplay:ho,addSchemaMutation:go,addSubSchemaMutation:bo,saveSchemaMutations:vo,resetSchemaMutations:$o}}}},Datasource$1=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$4,createStores:createStores$1,deriveStores:deriveStores$1},Symbol.toStringTag,{value:"Module"})),SuppressErrors$1=!0,createActions$3=to=>{const{API:ue,datasource:eo,columns:no}=to,ro=async uo=>{await ue.saveTable(uo)},oo=async uo=>{var fo;uo={...uo,tableId:(fo=get_store_value(eo))==null?void 0:fo.tableId};const co=await ue.saveRow(uo,SuppressErrors$1);return{...co,_id:co._id}};return{table:{actions:{saveDefinition:ro,addRow:oo,updateRow:oo,deleteRows:async uo=>{await ue.deleteRows(get_store_value(eo).tableId,uo)},getRow:async uo=>{var po;const co=await ue.searchTable(get_store_value(eo).tableId,{limit:1,query:{equal:{_id:uo}},paginate:!1}),fo=(po=co==null?void 0:co.rows)==null?void 0:po[0];if(fo)return{...fo,_id:fo._id}},isDatasourceValid:uo=>(uo==null?void 0:uo.type)==="table"&&!!(uo!=null&&uo.tableId),canUseColumn:uo=>get_store_value(no).some(co=>co.name===uo)}}}},initialise$5=to=>{const{datasource:ue,fetch:eo,filter:no,inlineFilters:ro,allFilters:oo,sort:io,table:so,initialFilter:ao,initialSortColumn:lo,initialSortOrder:uo}=to;let co=[];ue.subscribe(fo=>{co==null||co.forEach(po=>po()),co=[],so.actions.isDatasourceValid(fo)&&(no.set(get_store_value(ao)??void 0),ro.set([]),io.set({column:get_store_value(lo),order:get_store_value(uo)||SortOrder.ASCENDING}),co.push(oo.subscribe(po=>{var _o,ho;const mo=get_store_value(eo);((ho=(_o=mo==null?void 0:mo.options)==null?void 0:_o.datasource)==null?void 0:ho.tableId)===fo.tableId&&mo.update({filter:po})})),co.push(io.subscribe(po=>{var _o,ho;const mo=get_store_value(eo);((ho=(_o=mo==null?void 0:mo.options)==null?void 0:_o.datasource)==null?void 0:ho.tableId)===fo.tableId&&mo.update({sortOrder:po.order||SortOrder.ASCENDING,sortColumn:po.column??void 0})})))})},Table$1=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$3,initialise:initialise$5},Symbol.toStringTag,{value:"Module"})),SuppressErrors=!0,createActions$2=to=>{const{API:ue,datasource:eo,columns:no}=to,ro=async uo=>{await ue.viewV2.update(uo)},oo=async uo=>{const co=get_store_value(eo);uo={...uo,tableId:co==null?void 0:co.tableId,_viewId:co==null?void 0:co.id};const fo=await ue.saveRow(uo,SuppressErrors);return{...fo,_id:fo._id,_viewId:uo._viewId}};return{viewV2:{actions:{saveDefinition:ro,addRow:oo,updateRow:oo,deleteRows:async uo=>{await ue.deleteRows(get_store_value(eo).id,uo)},getRow:async uo=>{var po;const co=await ue.viewV2.fetch(get_store_value(eo).id,{limit:1,query:{equal:{_id:uo}},paginate:!1}),fo=(po=co==null?void 0:co.rows)==null?void 0:po[0];if(fo)return{...fo,_id:fo._id}},isDatasourceValid:uo=>(uo==null?void 0:uo.type)==="viewV2"&&!!(uo!=null&&uo.id)&&!!(uo!=null&&uo.tableId),canUseColumn:uo=>get_store_value(no).some(co=>co.name===uo&&co.visible)}}}},initialise$4=to=>{const{definition:ue,datasource:eo,sort:no,rows:ro,filter:oo,inlineFilters:io,allFilters:so,subscribe:ao,viewV2:lo,initialFilter:uo,initialSortColumn:co,initialSortOrder:fo,config:po,fetch:mo}=to;let _o=[];eo.subscribe(ho=>{if(_o==null||_o.forEach(bo=>bo()),_o=[],!lo.actions.isDatasourceValid(ho))return;oo.set(get_store_value(uo)??void 0),io.set([]),no.set({column:get_store_value(co),order:get_store_value(fo)||SortOrder.ASCENDING}),_o.push(ue.subscribe(bo=>{var vo,$o;get_store_value(po).canSaveSchema&&(!bo||!("id"in bo)||(bo==null?void 0:bo.id)===ho.id&&(get_store_value(co)||no.set({column:(vo=bo.sort)==null?void 0:vo.field,order:(($o=bo.sort)==null?void 0:$o.order)||SortOrder.ASCENDING}),get_store_value(uo)||oo.set(bo.queryUI)))}));function go(bo,vo){const $o=bo.column??null,wo=(vo==null?void 0:vo.field)??null;if($o!==wo)return!0;if(!$o)return!1;const ko=bo.order??null,So=(vo==null?void 0:vo.order)??null;return ko!==So}_o.push(no.subscribe(async bo=>{var wo,ko;const vo=get_store_value(ue);if(!vo||!("id"in vo)||(vo==null?void 0:vo.id)!==ho.id||!go(bo,vo.sort))return;get_store_value(po).canSaveSchema&&await eo.actions.saveDefinition({...vo,sort:{field:bo.column,order:bo.order||SortOrder.ASCENDING}});const $o=get_store_value(mo);((ko=(wo=$o==null?void 0:$o.options)==null?void 0:wo.datasource)==null?void 0:ko.id)===ho.id&&$o.update({sortOrder:bo.order,sortColumn:bo.column??void 0})})),_o==null||_o.push(oo.subscribe(async bo=>{if(!get_store_value(po).canSaveSchema)return;const vo=get_store_value(ue);!vo||!("id"in vo)||(vo==null?void 0:vo.id)===ho.id&&JSON.stringify(bo)!==JSON.stringify(vo.queryUI)&&(await eo.actions.saveDefinition({...vo,queryUI:bo}),await ro.actions.refreshData())})),_o.push(io.subscribe(bo=>{var $o,wo;if(!get_store_value(po).canSaveSchema)return;const vo=get_store_value(mo);((wo=($o=vo==null?void 0:vo.options)==null?void 0:$o.datasource)==null?void 0:wo.id)===ho.id&&vo.update({filter:bo})})),_o.push(so.subscribe(bo=>{var $o,wo;if(get_store_value(po).canSaveSchema)return;const vo=get_store_value(mo);((wo=($o=vo==null?void 0:vo.options)==null?void 0:$o.datasource)==null?void 0:wo.id)===ho.id&&vo.update({filter:bo})})),_o.push(ao("show-column",async()=>{await ro.actions.refreshData()}))})},ViewV2=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$2,initialise:initialise$4},Symbol.toStringTag,{value:"Module"})),createActions$1=to=>{const{columns:ue,table:eo,viewV2:no}=to,ro=async()=>{throw"This datasource does not support updating the definition"},oo=async()=>{throw"This datasource does not support saving rows"};return{nonPlus:{actions:{saveDefinition:ro,addRow:oo,updateRow:oo,deleteRows:async()=>{throw"This datasource does not support deleting rows"},getRow:()=>{throw"This datasource does not support fetching individual rows"},isDatasourceValid:uo=>!eo.actions.isDatasourceValid(uo)&&!no.actions.isDatasourceValid(uo)&&(uo==null?void 0:uo.type)!=null,canUseColumn:uo=>get_store_value(ue).some(co=>co.name===uo)}}}},isSameDatasource=(to,ue)=>JSON.stringify(to)===JSON.stringify(ue),initialise$3=to=>{const{datasource:ue,sort:eo,filter:no,inlineFilters:ro,allFilters:oo,nonPlus:io,initialFilter:so,initialSortColumn:ao,initialSortOrder:lo,fetch:uo}=to;let co=[];ue.subscribe(fo=>{co==null||co.forEach(po=>po()),co=[],io.actions.isDatasourceValid(fo)&&(no.set(get_store_value(so)??void 0),ro.set([]),eo.set({column:get_store_value(ao),order:get_store_value(lo)||SortOrder.ASCENDING}),co.push(oo.subscribe(po=>{var _o;const mo=get_store_value(uo);isSameDatasource((_o=mo==null?void 0:mo.options)==null?void 0:_o.datasource,fo)&&(mo==null||mo.update({filter:po}))})),co.push(eo.subscribe(po=>{var _o;const mo=get_store_value(uo);isSameDatasource((_o=mo==null?void 0:mo.options)==null?void 0:_o.datasource,fo)&&(mo==null||mo.update({sortOrder:po.order||SortOrder.ASCENDING,sortColumn:po.column??void 0}))})))})},NonPlus=Object.freeze(Object.defineProperty({__proto__:null,createActions:createActions$1,initialise:initialise$3},Symbol.toStringTag,{value:"Module"})),createActions=to=>{const{API:ue}=to;let eo={};const no=()=>{eo={}},ro=async so=>(eo[so]||(eo[so]=ue.fetchTableDefinition(so)),await eo[so]);return{cache:{actions:{getPrimaryDisplayForTableId:async so=>{var uo,co;const ao=await ro(so);return(ao==null?void 0:ao.primaryDisplay)||((co=(uo=ao==null?void 0:ao.schema)==null?void 0:uo[0])==null?void 0:co.name)},getTable:async so=>await ro(so),resetCache:no}}}},initialise$2=to=>{const{datasource:ue,cache:eo}=to;ue.subscribe(eo.actions.resetCache)},Cache=Object.freeze(Object.defineProperty({__proto__:null,createActions,initialise:initialise$2},Symbol.toStringTag,{value:"Module"})),createStores=()=>({metadata:writable({})}),deriveStores=to=>{const{columns:ue}=to;return{conditions:derivedMemo(ue,no=>{let ro=[];for(let oo of no)for(let io of oo.conditions||[])ro.push({...io,column:oo.name,type:oo.schema.type});return ro})}},initialise$1=to=>{const{metadata:ue,conditions:eo,rows:no}=to;eo.subscribe(ro=>{let oo={};if(ro!=null&&ro.length)for(let io of get_store_value(no))oo[io._id]=evaluateConditions(io,ro);ue.set(oo)}),no.subscribe(ro=>{const oo=get_store_value(eo);if(!(oo!=null&&oo.length))return;const io=get_store_value(ue);let so={};for(let ao of ro){const lo=io[ao._id];!(!ao._rev||lo&&lo.version!==ao._rev||ao._rev===EXTERNAL_ROW_REV)&&lo||(io[ao._id]=evaluateConditions(ao,oo))}Object.keys(so).length&&ue.update(ao=>({...ao,...so}))})},TypeCoercionMap={[FieldType.NUMBER]:parseFloat,[FieldType.DATETIME]:to=>to?new Date(to).toISOString():null,[FieldType.BOOLEAN]:to=>`${to}`.toLowerCase().trim()==="true"?!0:`${to}`.toLowerCase().trim()==="false"?!1:null},evaluateConditions=(to,ue)=>{const eo={version:to._rev,row:{},cell:{}};for(let no of ue)try{let{column:ro,type:oo,referenceValue:io,operator:so,metadataKey:ao,metadataValue:lo,target:uo}=no,co=to[ro],fo=oo;oo===FieldType.FORMULA&&(co===!0||co===!1?fo=FieldType.BOOLEAN:typeof co=="number"&&(fo=FieldType.NUMBER));const po=TypeCoercionMap[fo];po&&(co=po(co),io=po(io));let _o=buildQuery$1([{operator:so,type:oo,field:"value",value:io}]);_o.onEmptyFilter=EmptyFilterOption.RETURN_NONE,runQuery$1([{value:co}],_o).length>0&&(uo==="row"?eo.row={...eo.row,[ao]:lo}:eo.cell[ro]={...eo.cell[ro],[ao]:lo})}catch{}return eo},Conditions=Object.freeze(Object.defineProperty({__proto__:null,createStores,deriveStores,initialise:initialise$1},Symbol.toStringTag,{value:"Module"})),DependencyOrderedStores=[Sort,Filter,Bounds,Table$1,ViewV2,NonPlus,Datasource$1,Columns,Config,Scroll,Validation,Rows,Conditions,UI,Resize,Viewport$2,Reorder,Users$2,Menu,Pagination,Clipboard,Notifications,Cache],attachStores=to=>{var ue,eo,no,ro;for(let oo of DependencyOrderedStores)"createStores"in oo&&(to={...to,...(ue=oo.createStores)==null?void 0:ue.call(oo,to)});for(let oo of DependencyOrderedStores)"deriveStores"in oo&&(to={...to,...(eo=oo.deriveStores)==null?void 0:eo.call(oo,to)});for(let oo of DependencyOrderedStores)"createActions"in oo&&(to={...to,...(no=oo.createActions)==null?void 0:no.call(oo,to)});for(let oo of DependencyOrderedStores)"initialise"in oo&&((ro=oo.initialise)==null||ro.call(oo,to));return to};function create_if_block_1$2V(to){let ue,eo;return ue=new ProgressBar({props:{size:"L",value:to[3],duration:duration$2,width:"100%"}}),{c(){create_component(ue.$$.fragment)},m(no,ro){mount_component(ue,no,ro),eo=!0},p(no,ro){const oo={};ro&8&&(oo.value=no[3]),ue.$set(oo)},i(no){eo||(transition_in(ue.$$.fragment,no),eo=!0)},o(no){transition_out(ue.$$.fragment,no),eo=!1},d(no){destroy_component(ue,no)}}}function create_default_slot_3$2q(to){let ue,eo,no,ro,oo,io=to[2]&&create_if_block_1$2V(to);return{c(){ue=text("Are you sure you want to delete "),eo=text(to[4]),no=text(` rows?
|
|
542
542
|
`),io&&io.c(),ro=empty$4()},m(so,ao){insert$1(so,ue,ao),insert$1(so,eo,ao),insert$1(so,no,ao),io&&io.m(so,ao),insert$1(so,ro,ao),oo=!0},p(so,ao){(!oo||ao&16)&&set_data(eo,so[4]),so[2]?io?(io.p(so,ao),ao&4&&transition_in(io,1)):(io=create_if_block_1$2V(so),io.c(),transition_in(io,1),io.m(ro.parentNode,ro)):io&&(group_outros(),transition_out(io,1,1,()=>{io=null}),check_outros())},i(so){oo||(transition_in(io),oo=!0)},o(so){transition_out(io),oo=!1},d(so){so&&(detach(ue),detach(eo),detach(no),detach(ro)),io&&io.d(so)}}}function create_default_slot_2$39(to){let ue,eo;return ue=new ModalContent({props:{title:"Delete rows",confirmText:"Continue",cancelText:"Cancel",onConfirm:to[12],size:"M",$$slots:{default:[create_default_slot_3$2q]},$$scope:{ctx:to}}}),{c(){create_component(ue.$$.fragment)},m(no,ro){mount_component(ue,no,ro),eo=!0},p(no,ro){const oo={};ro&268435484&&(oo.$$scope={dirty:ro,ctx:no}),ue.$set(oo)},i(no){eo||(transition_in(ue.$$.fragment,no),eo=!0)},o(no){transition_out(ue.$$.fragment,no),eo=!1},d(no){destroy_component(ue,no)}}}function create_if_block$57(to){let ue,eo;return ue=new ProgressBar({props:{size:"L",value:to[3],duration:duration$2,width:"100%"}}),{c(){create_component(ue.$$.fragment)},m(no,ro){mount_component(ue,no,ro),eo=!0},p(no,ro){const oo={};ro&8&&(oo.value=no[3]),ue.$set(oo)},i(no){eo||(transition_in(ue.$$.fragment,no),eo=!0)},o(no){transition_out(ue.$$.fragment,no),eo=!1},d(no){destroy_component(ue,no)}}}function create_default_slot_1$4q(to){let ue,eo,no,ro,oo,io=to[2]&&create_if_block$57(to);return{c(){ue=text("Are you sure you want to delete "),eo=text(to[4]),no=text(` cells?
|
|
543
543
|
`),io&&io.c(),ro=empty$4()},m(so,ao){insert$1(so,ue,ao),insert$1(so,eo,ao),insert$1(so,no,ao),io&&io.m(so,ao),insert$1(so,ro,ao),oo=!0},p(so,ao){(!oo||ao&16)&&set_data(eo,so[4]),so[2]?io?(io.p(so,ao),ao&4&&transition_in(io,1)):(io=create_if_block$57(so),io.c(),transition_in(io,1),io.m(ro.parentNode,ro)):io&&(group_outros(),transition_out(io,1,1,()=>{io=null}),check_outros())},i(so){oo||(transition_in(io),oo=!0)},o(so){transition_out(io),oo=!1},d(so){so&&(detach(ue),detach(eo),detach(no),detach(ro)),io&&io.d(so)}}}function create_default_slot$6E(to){let ue,eo;return ue=new ModalContent({props:{title:"Delete cells",confirmText:"Continue",cancelText:"Cancel",onConfirm:to[13],size:"M",$$slots:{default:[create_default_slot_1$4q]},$$scope:{ctx:to}}}),{c(){create_component(ue.$$.fragment)},m(no,ro){mount_component(ue,no,ro),eo=!0},p(no,ro){const oo={};ro&268435484&&(oo.$$scope={dirty:ro,ctx:no}),ue.$set(oo)},i(no){eo||(transition_in(ue.$$.fragment,no),eo=!0)},o(no){transition_out(ue.$$.fragment,no),eo=!1},d(no){destroy_component(ue,no)}}}function create_fragment$aI(to){let ue,eo,no,ro,oo={$$slots:{default:[create_default_slot_2$39]},$$scope:{ctx:to}};ue=new Modal({props:oo}),to[16](ue);let io={$$slots:{default:[create_default_slot$6E]},$$scope:{ctx:to}};return no=new Modal({props:io}),to[17](no),{c(){create_component(ue.$$.fragment),eo=space$1(),create_component(no.$$.fragment)},m(so,ao){mount_component(ue,so,ao),insert$1(so,eo,ao),mount_component(no,so,ao),ro=!0},p(so,[ao]){const lo={};ao&268435484&&(lo.$$scope={dirty:ao,ctx:so}),ue.$set(lo);const uo={};ao&268435484&&(uo.$$scope={dirty:ao,ctx:so}),no.$set(uo)},i(so){ro||(transition_in(ue.$$.fragment,so),transition_in(no.$$.fragment,so),ro=!0)},o(so){transition_out(ue.$$.fragment,so),transition_out(no.$$.fragment,so),ro=!1},d(so){so&&detach(eo),to[16](null),destroy_component(ue,so),to[17](null),destroy_component(no,so)}}}const duration$2=260;function instance$aL(to,ue,eo){let no,ro,oo,io,so,ao,lo,uo;const{selectedRows:co,rows:fo,subscribe:po,notifications:mo,menu:_o,selectedCellCount:ho,selectedRowCount:go,selectedCells:bo,rowLookupMap:vo,config:$o}=getContext$1("grid");component_subscribe(to,co,Po=>eo(15,uo=Po)),component_subscribe(to,mo,Po=>eo(20,oo=Po)),component_subscribe(to,ho,Po=>eo(21,io=Po)),component_subscribe(to,go,Po=>eo(23,ao=Po)),component_subscribe(to,bo,Po=>eo(19,ro=Po)),component_subscribe(to,vo,Po=>eo(14,lo=Po)),component_subscribe(to,$o,Po=>eo(22,so=Po));let wo,ko,So=!1,To=0,Io=0;const Ao=()=>{eo(3,To=0),_o.actions.close(),ao&&so.canDeleteRows?ao===1?Eo():(eo(4,Io=ao),wo==null||wo.show()):io&&so.canEditRows&&(eo(4,Io=io),ko==null||ko.show())},Eo=async()=>{eo(2,So=!0);const Po=no.length;await fo.actions.deleteRows(no),eo(3,To=100),await sleep$2(duration$2),oo.success(`Deleted ${Po} row${Po===1?"":"s"}`),eo(2,So=!1)},Lo=async()=>{eo(2,So=!0);let Po={};for(let Mo of ro)for(let Uo of Mo){const{rowId:Vo,field:Wo}=parseCellID(Uo);Po[Vo]||(Po[Vo]={}),Po[Vo][Wo]=null}await fo.actions.bulkUpdate(Po,Mo=>{eo(3,To=Mo*100)}),await sleep$2(duration$2),eo(2,So=!1)};onMount(()=>po("request-bulk-delete",Ao));function No(Po){binding_callbacks[Po?"unshift":"push"](()=>{wo=Po,eo(0,wo)})}function Do(Po){binding_callbacks[Po?"unshift":"push"](()=>{ko=Po,eo(1,ko)})}return to.$$.update=()=>{to.$$.dirty&49152&&(no=Object.keys(uo).map(Po=>lo[Po]).filter(Po=>Po!=null))},[wo,ko,So,To,Io,co,mo,ho,go,bo,vo,$o,Eo,Lo,lo,uo,No,Do]}class BulkDeleteHandler extends SvelteComponent{constructor(ue){super(),init$3(this,ue,instance$aL,create_fragment$aI,safe_not_equal,{})}}function create_if_block$56(to){let ue,eo;return ue=new ProgressBar({props:{size:"L",value:to[1],duration:duration$1,width:"100%"}}),{c(){create_component(ue.$$.fragment)},m(no,ro){mount_component(ue,no,ro),eo=!0},p(no,ro){const oo={};ro&2&&(oo.value=no[1]),ue.$set(oo)},i(no){eo||(transition_in(ue.$$.fragment,no),eo=!0)},o(no){transition_out(ue.$$.fragment,no),eo=!1},d(no){destroy_component(ue,no)}}}function create_default_slot_1$4p(to){let ue,eo,no,ro,oo,io=to[2]&&create_if_block$56(to);return{c(){ue=text("Are you sure you want to duplicate "),eo=text(to[3]),no=text(` rows?
|
|
544
544
|
`),io&&io.c(),ro=empty$4()},m(so,ao){insert$1(so,ue,ao),insert$1(so,eo,ao),insert$1(so,no,ao),io&&io.m(so,ao),insert$1(so,ro,ao),oo=!0},p(so,ao){(!oo||ao&8)&&set_data(eo,so[3]),so[2]?io?(io.p(so,ao),ao&4&&transition_in(io,1)):(io=create_if_block$56(so),io.c(),transition_in(io,1),io.m(ro.parentNode,ro)):io&&(group_outros(),transition_out(io,1,1,()=>{io=null}),check_outros())},i(so){oo||(transition_in(io),oo=!0)},o(so){transition_out(io),oo=!1},d(so){so&&(detach(ue),detach(eo),detach(no),detach(ro)),io&&io.d(so)}}}function create_default_slot$6D(to){let ue,eo;return ue=new ModalContent({props:{title:"Duplicate rows",confirmText:"Continue",cancelText:"Cancel",onConfirm:to[8],size:"M",$$slots:{default:[create_default_slot_1$4p]},$$scope:{ctx:to}}}),{c(){create_component(ue.$$.fragment)},m(no,ro){mount_component(ue,no,ro),eo=!0},p(no,ro){const oo={};ro&262158&&(oo.$$scope={dirty:ro,ctx:no}),ue.$set(oo)},i(no){eo||(transition_in(ue.$$.fragment,no),eo=!0)},o(no){transition_out(ue.$$.fragment,no),eo=!1},d(no){destroy_component(ue,no)}}}function create_fragment$aH(to){let ue,eo,no={$$slots:{default:[create_default_slot$6D]},$$scope:{ctx:to}};return ue=new Modal({props:no}),to[9](ue),{c(){create_component(ue.$$.fragment)},m(ro,oo){mount_component(ue,ro,oo),eo=!0},p(ro,[oo]){const io={};oo&262158&&(io.$$scope={dirty:oo,ctx:ro}),ue.$set(io)},i(ro){eo||(transition_in(ue.$$.fragment,ro),eo=!0)},o(ro){transition_out(ue.$$.fragment,ro),eo=!1},d(ro){to[9](null),destroy_component(ue,ro)}}}const duration$1=260;function instance$aK(to,ue,eo){let no,ro,oo,io;const{selectedRows:so,rows:ao,subscribe:lo,selectedRowCount:uo,visibleColumns:co,selectedCells:fo,rowLookupMap:po}=getContext$1("grid");component_subscribe(to,so,wo=>eo(13,io=wo)),component_subscribe(to,uo,wo=>eo(10,no=wo)),component_subscribe(to,co,wo=>eo(11,ro=wo)),component_subscribe(to,po,wo=>eo(12,oo=wo));let mo,_o=0,ho=!1,go=0;const bo=async()=>{eo(1,_o=0),eo(2,ho=!0);const wo=Object.keys(io).map(So=>oo[So]),ko=await ao.actions.bulkDuplicate(wo,So=>{eo(1,_o=So*100)});if(await sleep$2(duration$1),ko.length){const So=ko[0],To=ko[ko.length-1],Io=ro[0],Ao=ro[ro.length-1],Eo=getCellID(So._id,Io.name),Lo=getCellID(To._id,Ao.name);fo.actions.selectRange(Eo,Lo)}eo(2,ho=!1)},vo=()=>{eo(3,go=no),mo==null||mo.show()};onMount(()=>lo("request-bulk-duplicate",vo));function $o(wo){binding_callbacks[wo?"unshift":"push"](()=>{mo=wo,eo(0,mo)})}return[mo,_o,ho,go,so,uo,co,po,bo,$o]}class BulkDuplicationHandler extends SvelteComponent{constructor(ue){super(),init$3(this,ue,instance$aK,create_fragment$aH,safe_not_equal,{})}}function create_if_block$55(to){let ue,eo;return ue=new ProgressBar({props:{size:"L",value:to[1],duration,width:"100%"}}),{c(){create_component(ue.$$.fragment)},m(no,ro){mount_component(ue,no,ro),eo=!0},p(no,ro){const oo={};ro&2&&(oo.value=no[1]),ue.$set(oo)},i(no){eo||(transition_in(ue.$$.fragment,no),eo=!0)},o(no){transition_out(ue.$$.fragment,no),eo=!1},d(no){destroy_component(ue,no)}}}function create_default_slot_1$4o(to){let ue,eo,no,ro=to[2]&&create_if_block$55(to);return{c(){ue=text(`Are you sure you want to paste? This will update multiple values.
|
package/builder/index.html
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
<link href="/builder/fonts/inter/inter.css" rel="stylesheet" />
|
|
10
10
|
<link href="/builder/fonts/phosphor-icons/phosphor-icons.css" rel="stylesheet" />
|
|
11
11
|
<link href="/builder/fonts/remixicon.css" rel="stylesheet" />
|
|
12
|
-
<script type="module" crossorigin src="/builder/assets/index-
|
|
12
|
+
<script type="module" crossorigin src="/builder/assets/index-b0f56562.js"></script>
|
|
13
13
|
<link rel="stylesheet" href="/builder/assets/index-b6e7e172.css">
|
|
14
14
|
</head>
|
|
15
15
|
|