From 61ce760e0fa3a03ca7a3ae00dd7f65ed5bb33fa5 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Sun, 19 Apr 2026 12:29:45 +0300 Subject: [PATCH] show collection name in the page title on initial load --- CHANGELOG.md | 5 ++++- ui/dist/assets/{index-BapiTLZm.js => index-D8i1aGFh.js} | 2 +- ui/dist/index.html | 2 +- ui/src/collections/pageCollections.js | 4 ++-- 4 files changed, 8 insertions(+), 5 deletions(-) rename ui/dist/assets/{index-BapiTLZm.js => index-D8i1aGFh.js} (99%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 013c9e7e..c100c224 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ ## v0.37.1 (WIP) -- Allow opening collections in new tab on middle click. +- Minor UI fixes: + - Allow opening collections in new tab on middle click. + - Show collection name in the page title on initial load. + ## v0.37.0 diff --git a/ui/dist/assets/index-BapiTLZm.js b/ui/dist/assets/index-D8i1aGFh.js similarity index 99% rename from ui/dist/assets/index-BapiTLZm.js rename to ui/dist/assets/index-D8i1aGFh.js index 6a48b092..3add2f93 100644 --- a/ui/dist/assets/index-BapiTLZm.js +++ b/ui/dist/assets/index-D8i1aGFh.js @@ -58,7 +58,7 @@ This field is disabled if "Except domains" is set.`)})),t.input({type:`text`,id: To target the newly submitted ones you can use @request.body.*.`)})],name:`updateRule`,autocomplete:i,disabled:()=>e.originalCollection?.system,value:()=>e.collection.updateRule,oninput:n=>e.collection.updateRule=n})),t.div({className:`col-12`,ariaDescription:r()},app.components.ruleField({label:`Delete rule`,name:`deleteRule`,autocomplete:i,disabled:()=>e.originalCollection?.system,value:()=>e.collection.deleteRule,oninput:n=>e.collection.deleteRule=n}))]}),()=>{if(e.collection.type==`auth`)return[t.hr({className:`m-t-base m-b-base`}),t.button({type:`button`,onmount:()=>{n.showAuthRules=e.collection.manageRule!==null||e.collection.authRule!==``},className:()=>`btn secondary sm ${n.showAuthRules?``:`transparent`}`,onclick:()=>{n.showAuthRules=!n.showAuthRules}},t.span({className:`txt`},`Additional auth collection rules`),t.i({ariaHidden:!0,className:()=>n.showAuthRules?`ri-arrow-drop-up-line`:`ri-arrow-drop-down-line`})),app.components.slide(()=>n.showAuthRules,t.div({className:`grid sm m-t-sm`},t.div({className:`col-12`,ariaDescription:r()},app.components.ruleField({label:`Authentication rule`,name:`authRule`,placeholder:``,autocomplete:i,disabled:()=>e.originalCollection?.system,value:()=>e.collection.authRule,oninput:n=>e.collection.authRule=n}),t.div({className:`field-help`},t.p(null,`This rule is executed every time `,t.strong(null,`before authentication`),` allowing you to restrict who can authenticate.`),t.p(null,`For example, to allow only verified users you can set it to `,t.code(null,`verified = true`),`.`),t.p(null,`Leave it empty to allow anyone with an account to authenticate.`),t.p(null,`To disable authentication entirely you can change it to "Set superusers only".`))),t.div({className:`col-12`,ariaDescription:r()},app.components.ruleField({label:`Manage rule`,name:`manageRule`,autocomplete:i,disabled:()=>e.originalCollection?.system,value:()=>e.collection.manageRule,oninput:n=>e.collection.manageRule=n}),t.div({className:`field-help`},t.p(null,`This rule is executed in addition to the `,t.strong(null,`create`),` and `,t.strong(null,`update`),` API rules.`),t.p(null,`It enables superuser-like permissions to allow fully managing the auth record(s), eg. changing the password without requiring to enter the old one, directly updating the verified state or email, etc.`)))))]})}var Jn=`test_view_query`;function Yn(e){let n=`query_`+app.utils.randomString(),r=[`SELECT`,`FROM`,`WHERE`,`LEFT JOIN`,`INNER JOIN`,`ON`,`GROUP BY`,`HAVING`,`ORDER BY`,`LIMIT`,`OFFSET`,`AS`,`WITH`,`NOT`,`IN`,`EXISTS`,`LIKE`,`CAST`],i=store({testRecords:[],testError:``,isTesting:!1});async function a(n){if(i.isTesting=!0,i.testRecords=[],(app.store.errors?.viewQuery||app.store.errors?.fields)&&(delete app.store.errors.viewQuery,delete app.store.errors.fields),!n){i.testError=``,i.isTesting=!1;return}try{let r=await app.pb.send(`/api/collections/meta/dry-run-view`,{method:`POST`,body:{query:n},requestKey:Jn});e.collection?.id?i.testRecords=r.sample.map(n=>(n.collectionId=e.collection?.id,n.collectionName=e.collection?.name,n)):i.testRecords=r.sample,i.testError=``,i.isTesting=!1}catch(e){e.isAbort||(i.testError=e.message||`Invalid query.`,i.isTesting=!1)}}let o,s=[watch(()=>e.collection?.viewQuery,e=>{clearTimeout(o),o=setTimeout(()=>a(e),200)})];return t.div({pbEvent:`collectionViewQueryTabContent`,className:`collection-tab-content collection-view-query-tab-content`,onunmount:()=>{clearTimeout(o),app.pb.cancelRequest(Jn),s.forEach(e=>e?.unwatch())}},t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`txt-right txt-sm m-b-10`},t.button({type:`button`,className:`txt-bold link-hint`,"html-popovertarget":n+`caveats_dropdown`},()=>`Query caveats`)),t.div({id:n+`caveats_dropdown`,className:`dropdown sm query-caveats-dropdown`,popover:`auto`},t.ul(null,t.li(null,`Wildcard columns (*) are not supported.`),t.li(null,`The query must have a unique `,t.code(null,`id`),` column.`,t.br(),`If your query doesn't have a suitable one, you can use the universal `,t.code(null,`(ROW_NUMBER() OVER()) as id`),`.`),t.li(null,`Expressions must be aliased with a valid formatted field name, e.g. `,t.code(null,`MAX(balance) as maxBalance`),`.`),t.li(null,`Combined/multi-spaced expressions must be wrapped in parenthesis, e.g. `,t.code(null,`(MAX(balance) + 1) as maxBalance`),`.`),t.li(null,`UNION expressions are supported but the entire query must be wrapped in parenthesis.`))),t.div({className:`field`},t.label({htmlFor:n+`.viewQuery`},t.span({className:`txt`},`Select query`),t.span({hidden:()=>!i.testError,className:`query-state`,ariaDescription:app.attrs.tooltip(`Invalid query`,`left`)},t.i({className:`ri-error-warning-fill txt-danger`,ariaHidden:!0})),t.span({hidden:()=>!!i.testError,className:`query-state`,ariaDescription:app.attrs.tooltip(`Valid query`,`left`)},t.i({className:`ri-checkbox-circle-fill txt-success`,ariaHidden:!0}))),app.components.codeEditor({id:n+`.viewQuery`,name:`viewQuery`,language:`sql`,required:!0,autocomplete:r,className:`inline-error`,value:()=>e.collection.viewQuery||``,oninput:n=>{e.collection.viewQuery=n}}))),t.div({className:`col-12`},t.p({className:`txt-sm txt-bold`},`Sample output:`),t.div({className:`view-query-sample-wrapper`},app.components.codeBlock({language:()=>i.testError?`plain`:`js`,className:()=>`view-query-sample ${i.testError?`txt-danger`:``}`,value:()=>i.testRecords?.length?JSON.stringify(i.testRecords,null,2):i.testError||`N/A`})))))}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openCollectionUpsert=function(e={},n={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null,onsave:null,ondelete:null,onduplicate:null,ontruncate:null}){app.store.errors=null;let r=Xn(e||{},n||{});document.body.appendChild(r),app.modals.open(r)},window.app.collectionTypes={base:{icon:`ri-folder-2-line`,tabs:{Fields:Q,"API rules":qn}},view:{icon:`ri-table-line`,tabs:{Query:Yn,"API rules":qn}},auth:{icon:`ri-group-line`,tabs:{Fields:Q,"API rules":qn,Options:Kn}}};function Xn(e,n){let r,i=`collection_upsert_`+app.utils.randomString(),a=store({isSaving:!1,originalCollection:{},collection:{},selectedTab:``,get activeTab(){return app.collectionTypes[a.collection.type]?.tabs&&(!a.selectedTab||!app.collectionTypes[a.collection.type].tabs?.[a.selectedTab])?Object.keys(app.collectionTypes[a.collection.type].tabs)?.[0]||``:a.selectedTab},get isNew(){return app.utils.isEmpty(a.originalCollection?.id)},get collectionTypeOptions(){return Object.keys(app.collectionTypes).map(e=>({value:e,label:app.utils.sentenize(e,!1)+` collection`}))},get collectionHash(){return Object.keys(a.collection).length,JSON.stringify(a.collection)},get originalCollectionHash(){return JSON.stringify(a.originalCollection)},get hasChanges(){return a.originalCollectionHash!=a.collectionHash},get canSave(){return!a.isSaving&&(a.isNew||a.hasChanges)}});async function o(e){app.utils.isEmpty(e)&&(e=JSON.parse(JSON.stringify(app.store.collectionScaffolds.base))||{type:`base`,fields:[]},e.fields.push({type:`autodate`,name:`created`,onCreate:!0}),e.fields.push({type:`autodate`,name:`updated`,onCreate:!0,onUpdate:!0})),a.originalCollection=JSON.parse(JSON.stringify(e)),a.collection=JSON.parse(JSON.stringify(e))}async function s(e=!0){a.canSave&&(a.isSaving=!0,app.modals.openCollectionChangesConfirmation(a.originalCollection,a.collection,()=>l(e),()=>{a.isSaving=!1}))}function c(){let e=JSON.parse(JSON.stringify(a.collection));e.fields=e.fields||[];for(let n=e.fields.length-1;n>=0;n--)if(e.fields[n][`@toDelete`]){e.fields.splice(n,1);continue}return e}async function l(e=!0){a.isSaving=!0;try{let i=c(),o=app.utils.isEmpty(a.originalCollection?.id),s;s=o?app.pb.collections.create(i):app.pb.collections.update(a.originalCollection.id,i);let l=JSON.stringify(await s);a.originalCollection=JSON.parse(l),a.collection=JSON.parse(l),app.store.addOrUpdateCollection(JSON.parse(l)),n?.onsave?.(JSON.parse(l),o),a.isSaving=!1,app.toasts.success(o?`Successfully created collection "${a.collection.name}".`:`Successfully updated collection "${a.collection.name}".`,{key:`collectionSave`}),app.store.errors=null,e&&app.modals.close(r,!0)}catch(e){e?.isAbort||(a.isSaving=!1,app.checkApiError(e,!1),app.toasts.error(e.message||`Failed to save collection.`,{key:`collectionSave`}))}}function u(){a.collection=JSON.parse(JSON.stringify(a.originalCollection))}async function d(){let e=a.originalCollection?JSON.parse(JSON.stringify(a.originalCollection)):{};return e.id=``,e.system=!1,e.name+=`_duplicate`,e.created=``,e.updated=``,e.indexes=e.indexes?.map(n=>app.utils.replaceIndexFields(n,n=>({indexName:n.indexName+app.utils.randomString(3),tableName:e.name})))||[],await n.onduplicate?.(e),o(e)}async function f(e){a.selectedTab=e,await new Promise(e=>setTimeout(e,0)),app.store.errors&&(app.store.errors=JSON.parse(JSON.stringify(app.store.errors)))}return r=t.div({pbEvent:`collectionUpsertModal`,"html-data-collectionId":()=>a.originalCollection?.id,"html-data-collectionName":()=>a.originalCollection?.name,className:`modal collection-upsert-modal`,inert:()=>a.isSaving,onkeydown:e=>{if((e.ctrlKey||e.metaKey)&&e.code==`KeyS`){e.preventDefault();let n=document.activeElement;n?.blur(),s(!1),n?.focus()}},onbeforeopen:()=>(o(e),n.onbeforeopen?.(el)),onafteropen:e=>{n.onafteropen?.(e)},onbeforeclose:(e,r)=>r?n.onbeforeclose?.(e):a.isSaving?!1:a.hasChanges?new Promise(r=>{app.modals.confirm(`You have unsaved changes. Do you really want to discard them?`,()=>r(n.onbeforeclose?.(e)),()=>r(!1))}):n.onbeforeclose?.(e),onafterclose:e=>{n.onafterclose?.(e),e?.remove()},onmount:e=>{e._watchers?.forEach(e=>e?.unwatch()),e._watchers=[watch(()=>a.collection.type,(e,n)=>{if(!n||e==n||!app.store.collectionScaffolds[e])return;app.utils.deleteByPath(app.store.errors,`fields`);let r=JSON.parse(JSON.stringify(app.store.collectionScaffolds[e]));a.collection=Object.assign(structuredClone(r),JSON.parse(JSON.stringify(a.collection))),a.originalCollection=r,Zn(a.collection)}),watch(()=>a.collection.name,(n,r)=>{n=app.utils.slugify(n),a.collection.name=n,!(r===void 0||!n||n==r)&&(clearTimeout(e.__collectionRenameTimeoutId),e.__collectionRenameTimeoutId=setTimeout(()=>{a.collection.indexes=a.collection.indexes?.map(e=>app.utils.replaceIndexFields(e,{tableName:a.collection.name}))},150))})]},onunmount:e=>{clearTimeout(e?.__collectionRenameTimeoutId),e?._watchers?.forEach(e=>e?.unwatch())}},t.header({className:`modal-header isolated`},t.div({className:`grid sm`},t.div({className:`col-12 flex`},t.h6({className:`modal-title`},t.span(null,()=>a.isNew?`Create `:`Edit `),t.strong({hidden:()=>a.isNew,className:`txt-ellipsis collection-name`},()=>a.originalCollection?.name),t.span(null,` collection`)),t.div({className:`flex-fill`}),()=>{if(!app.utils.isEmpty(a.originalCollection?.id))return[t.button({type:`button`,className:`btn sm circle transparent`,title:`More options`,"html-popovertarget":i+`modal-header-dropdown`},t.i({className:`ri-more-line`,ariaHidden:!0})),t.div({id:i+`modal-header-dropdown`,className:`dropdown nowrap modal-header-dropdown`,popover:`auto`},t.button({type:`button`,className:`dropdown-item`,onclick:e=>{e.target.closest(`.dropdown`).hidePopover(),app.utils.copyToClipboard(JSON.stringify(a.originalCollection,null,2)),app.toasts.success(`Collection copied to clipboard!`)}},t.i({className:`ri-braces-line`,ariaHidden:!0}),t.span({className:`txt`},`Copy JSON`)),t.button({type:`button`,className:`dropdown-item`,onclick:e=>{e.target.closest(`.dropdown`).hidePopover(),a.hasChanges?app.modals.confirm(`You have unsaved changes. Do you really want to discard them?`,d,null,{yesButton:`Yes, discard`}):d()}},t.i({className:`ri-file-copy-line`,ariaHidden:!0}),t.span({className:`txt`},`Duplicate`)),t.hr(),()=>{if(a.collection.type!=`view`)return Qn(a,n)},()=>{if(!a.collection.system)return $n(a,n)})]}),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:i+`col_name`,textContent:()=>`Name${a.collection?.system?` (system)`:``}`}),t.input({id:i+`col_name`,type:`text`,name:`name`,required:!0,spellcheck:!1,placeholder:`e.g. posts`,autofocus:()=>a.isNew,disabled:()=>!a.isNew&&a.collection?.system,value:()=>a.collection.name||``,onmount:e=>{e.addEventListener(`compositionend`,e=>{a.collection.name=e.target.value})},oninput:e=>{e.isComposing||(a.collection.name=e.target.value)}})),t.div({className:`field addon`},t.button({type:`button`,disabled:()=>!a.isNew,className:()=>`btn sm collection-type-select ${a.isNew?`outline`:`transparent`}`,"html-popovertarget":i+`col_type_dropdown`},t.span({className:`txt`},`Type: `,()=>app.utils.sentenize(a.collection.type,!1)||`N/A`),t.i({hidden:()=>!a.isNew,ariaHidden:!0,className:`ri-arrow-drop-down-line m-l-auto`})),t.div({id:i+`col_type_dropdown`,className:`dropdown nowrap collection-type-dropdown`,popover:`auto`},()=>{let e=[];for(let n of a.collectionTypeOptions)e.push(t.button({type:`button`,className:()=>`dropdown-item ${n.value==a.collection.type?`active`:``}`,onclick:e=>{e.target.closest(`.dropdown`).hidePopover(),a.collection.type=n.value}},t.i({ariaHidden:!0,className:app.collectionTypes[n.value]?.icon||app.utils.fallbackCollectionIcon}),t.span({className:`txt`},n.label||n.value)));return e})))),t.div({className:`col-12`},t.nav({className:`tabs-header equal-width`},()=>{let e=[],n=app.collectionTypes[a.collection.type]?.tabs||{};for(let r in n)e.push(t.button({type:`button`,disabled:()=>a.isSaving,className:()=>`tab-item ${a.activeTab==r?`active`:``}`,onclick:()=>f(r)},t.span({className:`txt`},r)));return e})))),t.div({className:`modal-content`},()=>app.collectionTypes[a.collection.type]?.tabs?.[a.activeTab]?.(a)),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,disabled:()=>a.isSaving,onclick:()=>app.modals.close(r)},t.span({className:`txt`},`Close`)),()=>{let e=JSON.stringify(app.store.errors);if(!(e==``||e==`null`||e==`{}`||e==`[]`))return t.i({className:`ri-alert-line txt-danger`,ariaDescription:app.attrs.tooltip(()=>`Raw error: `+e)})},t.div({className:`btns`},t.button({type:`button`,className:()=>`btn expanded-lg ${a.isSaving?`loading`:``}`,disabled:()=>!a.canSave,onclick:()=>s(!0)},t.span({className:`txt`},()=>a.isNew?`Create`:`Save changes`)),t.button({type:`button`,title:`Save options`,className:()=>`btn p-5`,disabled:()=>!a.canSave,"html-popovertarget":i+`save_options`},t.i({className:`ri-arrow-up-s-line`,ariaHidden:!0})),t.div({id:i+`save_options`,className:`dropdown nowrap`,popover:`auto`},t.button({type:`button`,className:`dropdown-item`,onclick:e=>{e.target.closest(`.dropdown`).hidePopover(),s(!1)}},t.span({className:`txt`},`Save and continue`),t.small({className:`txt-hint`},`(Ctrl+S)`)),t.hr(),t.button({type:`button`,className:`dropdown-item`,onclick:e=>{e.target.closest(`.dropdown`).hidePopover(),u()}},t.span({className:`txt`},`Reset form`)))))),r}function Zn(e){let n=JSON.parse(JSON.stringify(app.store.collectionScaffolds[e.type])),r=JSON.parse(JSON.stringify(e.fields))||[],i=r.filter(e=>!e.system);e.fields=n.fields||[];for(let n of r){if(!n.system)continue;let r=e.fields.find(e=>e.name==n.name);r&&Object.assign(r,n)}for(let n of i)e.fields.push(n);if(e.indexes=e.indexes||[],e.indexes.length){let r=n?.indexes||[];indexesLoop:for(let n=e.indexes.length-1;n>=0;n--){let i=app.utils.parseIndex(e.indexes[n]),a=i.indexName.toLowerCase();for(let i of r)if(a==app.utils.parseIndex(i).indexName.toLowerCase()){e.indexes.splice(n,1);continue indexesLoop}for(let r of i.columns)if(!e.fields.find(e=>e.name.toLowerCase()==r.name.toLowerCase())){e.indexes.splice(n,1);continue indexesLoop}}}app.utils.mergeUnique(e.indexes,n.indexes)}function Qn(e,n){let r=`truncate_`+app.utils.randomString(),i=store({isSubmitting:!1,nameConfirm:``});async function a(){if(i.isSubmitting||!e.originalCollection?.name||e.originalCollection.name!=i.nameConfirm)return!1;i.isSubmitting=!0;try{return await app.pb.collections.truncate(e.originalCollection.name),n.ontruncate?.(JSON.parse(JSON.stringify(e.originalCollection))),app.toasts.success(`Successfully truncated collection "${e.originalCollection.name}".`),i.isSubmitting=!1,!0}catch(e){i.isSubmitting=!1,app.checkApiError(e)}return!1}return t.button({type:`button`,className:`dropdown-item txt-danger`,disabled:()=>i.isSubmitting,onclick:n=>{n.target.closest(`.dropdown`).hidePopover(),app.modals.confirm(t.div(null,t.h6({className:`block txt-center`},`Do you really want to delete all records of the collection?`),t.div({className:`confirm-collection-label txt-bold m-t-sm m-b-sm`},`Type the collection name `,t.div({className:`label`},()=>e.originalCollection.name,app.components.copyButton(()=>e.originalCollection?.name)),` to confirm:`),t.div({className:`field`},t.label({htmlFor:r+`.confirm_name`},`Collection name`),t.input({id:r+`.confirm_name`,type:`text`,required:!0,pattern:()=>RegExp.escape(e.originalCollection.name),value:()=>i.nameConfirm,oninput:e=>i.nameConfirm=e.target.value}))),async()=>{if(document.getElementById(r+`.confirm_name`)?.reportValidity(),!await a())return!1;app.modals.close(n.target.closest(`.modal`))},()=>{i.nameConfirm=``})}},t.i({className:`ri-eraser-line`,ariaHidden:!0}),t.span({className:`txt`},`Truncate`))}function $n(e,n){let r=`delete_`+app.utils.randomString(),i=store({isSubmitting:!1,nameConfirm:``});async function a(){if(i.isSubmitting||!e.originalCollection?.name||e.originalCollection.name!=i.nameConfirm)return!1;i.isSubmitting=!0;try{return await app.pb.collections.delete(e.originalCollection.name),n.ondelete?.(JSON.parse(JSON.stringify(e.originalCollection))),app.utils.removeByKey(app.store.collections,`id`,e.originalCollection.id),app.toasts.success(`Successfully deleted collection "${e.originalCollection.name}".`),i.isSubmitting=!1,!0}catch(e){i.isSubmitting=!1,app.checkApiError(e)}return!1}return t.button({type:`button`,className:`dropdown-item txt-danger`,disabled:()=>i.isSubmitting,onclick:n=>{n.target.closest(`.dropdown`).hidePopover();let o=n.target.closest(`.modal`);app.modals.confirm(t.div({className:`block`},t.h6({className:`block txt-center`},()=>e.originalCollection.type==`view`?`Do you really want to delete the selected collection?`:`Do you really want to delete the selected collection and all its records`),t.div({className:`confirm-collection-label txt-bold m-t-sm m-b-sm`},`Type the collection name `,t.div({className:`label`},()=>e.originalCollection.name,app.components.copyButton(()=>e.originalCollection?.name)),` to confirm:`),t.div({className:`field`},t.label({htmlFor:r+`.confirm_name`},`Collection name`),t.input({id:r+`.confirm_name`,type:`text`,required:!0,pattern:()=>RegExp.escape(e.originalCollection.name),value:()=>i.nameConfirm,oninput:e=>i.nameConfirm=e.target.value}))),async()=>{if(document.getElementById(r+`.confirm_name`)?.reportValidity(),!await a())return!1;app.modals.close(o)},()=>{i.nameConfirm=``})}},t.i({className:`ri-delete-bin-7-line`,ariaHidden:!0}),t.span({className:`txt`},`Delete`))}window.app=window.app||{},window.app.components=window.app.components||{},window.app.components.addCollectionFieldButton=function(e){let n=`new_field_`+app.utils.randomString();function r(n){let r={id:``,name:i(n),type:n,system:!1,hidden:!1,presentable:!1,required:!1,__focus:!0};e.fields=e.fields||[];let a=e.fields.findLastIndex(e=>e.type!=`autodate`);r.type!=`autodate`&&a>=0?e.fields.splice(a+1,0,r):e.fields.push(r)}function i(e=``){let n=e,r=2,i=e.match(/\d+$/)?.[0]||``,o=i?e.substring(0,e.length-i.length):e;for(;a(n);)n=o+((i<<0)+r),r++;return n}function a(n){return!!e.fields?.find(e=>e.name.toLowerCase()===n.toLowerCase())}return t.div({className:`new-collection-field-btn-wrapper`},t.button({type:`button`,className:`btn block outline`,"html-popovertarget":n+`_dropdown`},t.i({className:`ri-add-line`,ariaHidden:!0}),t.span({className:`txt`},`New field`)),t.div({id:n+`_dropdown`,className:`dropdown field-types-dropdown`,popover:`auto`},()=>{let e=[];for(let n in app.fieldTypes){if(n==`password`)continue;let i=app.fieldTypes[n];i.settings&&e.push(t.button({type:`button`,className:`dropdown-item`,onclick:e=>{e.target.closest(`.dropdown`)?.hidePopover(),r(n)}},t.i({className:i.icon||app.utils.fallbackFieldIcon,ariaHidden:!0}),t.span({className:`txt`},i.label||n)))}return e}))},window.app=window.app||{},window.app.utils=window.app.utils||{};var er={maxKeys:30,requestKeys:!0,collectionJoinKeys:!0};window.app.utils.collectionAutocompleteKeys=function(e,n,r={}){if(!e||!n||!app.store.collections?.length)return[];r=Object.assign({},er,r);let i=nr(n,app.store.collections,e).sort(tr);if(r.requestKeys){let r=rr(n,app.store.collections,e).sort(tr);for(let e of r)i.push(e)}if(r.collectionJoinKeys){let e=ir(n,app.store.collections).sort(tr);for(let n of e)i.push(n)}return i.length>r.maxKeys?i.slice(0,r.maxKeys):i};function tr(e,n){return e.length-n.length}function nr(e,n,r,i=``,a=0){if(!e||a>=4||(typeof r==`string`&&(r=n.find(e=>e.name==r||e.id==r)),!r))return[];e=e.toLowerCase();let o=r.type==`auth`,s=app.utils.getAllCollectionIdentifiers(r,i).filter(n=>n.toLowerCase().includes(e)),c=r.fields||[];for(let r of c){if(r.type==`password`||o&&r.name==`tokenKey`)continue;let c=[];if(i==`@request.body.`&&(c.push(i+r.name+`:changed`),c.push(i+r.name+`:isset`)),typeof app.fieldTypes[r.type]?.filterModifiers==`function`){let e=app.fieldTypes[r.type]?.filterModifiers(r)||[];for(let n of e)c.push(i+r.name+`:`+n)}for(let n of c)n.toLowerCase().includes(e)&&s.push(n);if(r.type==`relation`&&r.collectionId){let o=nr(e,n,r.collectionId,i+r.name+`.`,a+1);for(let e of o)s.push(e)}}for(let o of n){let c=o.fields||[];for(let l of c){if(l.type!=`relation`||l.collectionId!=r.id)continue;let c=i+o.name+`_via_`+l.name,u=nr(e,n,o,c+`.`,a+2);for(let e of u)s.push(e)}}return s}function rr(e,n,r){if(!e)return[];e=e.toLowerCase();let i=[];for(let n of[`@request.context`,`@request.method`,`@request.query.`,`@request.body.`,`@request.headers.`,`@request.auth.collectionId`,`@request.auth.collectionName`])n.toLowerCase().includes(e)&&i.push(n);let a=n.filter(e=>e.type===`auth`);for(let r of a){if(r.system)continue;let a=nr(e,n,r,`@request.auth.`);for(let e of a)app.utils.pushUnique(i,e)}if(typeof r==`string`&&(r=n.find(e=>e.name==r||e.id==r)),!r)return i;let o=nr(e,n,r,`@request.body.`);for(let e of o)i.push(e);return i}function ir(e,n){let r=[],i=`@collection.`,a,o;if(12!e.exclude?.includes(r.name)&&(r.name+r.displayName).toLowerCase().replaceAll(` `,``).includes(n))}});function i(){r.searchTerm=``}return n=t.div({pbEvent:`providerPickerModal`,className:`modal provider-picker-modal`,onbeforeopen:n=>e.onbeforeopen?.(n),onafteropen:n=>{e.onafteropen?.(n)},onbeforeclose:n=>e.onbeforeclose?.(n),onafterclose:n=>{e.onafterclose?.(n),n?.remove()}},t.header({className:`modal-header`},t.h6({className:`modal-title`},t.span({className:`txt`},`Select OAuth2 provider`))),t.div({className:`modal-content`},t.div({className:`grid sm`},t.div({className:`col-12`},t.div({className:`fields searchbar`},t.div({className:`field`},t.input({placeholder:`Search...`,className:`p-l-20`,value:()=>r.searchTerm,oninput:e=>r.searchTerm=e.target.value})),()=>{if(r.searchTerm)return t.div({rid:`search-ctrls`,className:`field addon p-r-5`},t.button({type:`button`,className:`btn sm pill secondary transparent`,onclick:()=>i()},`Clear`))})),()=>{if(!(app.store.isLoadingOAuth2Providers||r.filteredProviders.length))return t.div({rid:`notfound`,className:`block txt-center txt-hint`},t.p(null,`No providers found.`),t.button({type:`button`,className:`btn sm secondary`,textContent:`Clear search`,onclick:()=>i()}))},()=>app.store.isLoadingOAuth2Providers?t.div({className:`col-12 txt-center`},t.span({className:`loader active`})):r.filteredProviders.map(r=>t.div({className:`col-sm-6`},t.button({type:`button`,className:`provider-card handle`,onclick:()=>{app.modals.close(n),e.onselect?.(r)}},t.figure({className:`provider-logo`},()=>r.logo?t.img({src:`data:image/svg+xml;base64,`+btoa(r.logo),alt:r.name+` logo`}):t.i({className:app.utils.fallbackProviderIcon,ariaHidden:!0})),t.div({className:`content`},t.span({className:`primadry-txt`},r.displayName||r.name),t.span({className:`secondary-txt`},r.name))))))),t.footer({className:`modal-footer gap-base`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(n)},t.span({className:`txt`},`Close`)))),n}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openProviderSettings=function(e={},n={namePrefix:``,onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null,onsubmit:null}){let r=or(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};function or(e,n){let r,i=`provider_`+app.utils.randomString();e||={};let a=!e.clientId,o=JSON.stringify(e),s=app.store.oauth2Providers?.find(n=>n.name==e.name);if(!s){console.warn(`missing provider for config`,e);return}let c=store({config:JSON.parse(o),get hasChanges(){return o!=JSON.stringify(c.config)},onsubmit:(e,n)=>{}});function l(){c.hasChanges&&(n.onsubmit?.(s,JSON.parse(JSON.stringify(c.config))),app.modals.close(r))}return r=t.div({pbEvent:`providerSettingsModal`,className:`modal provider-settings-modal`,onbeforeopen:e=>n.onbeforeopen?.(e),onafteropen:e=>{n.onafteropen?.(e),setTimeout(()=>{app.store.errors?.oauth2&&(app.store.errors.oauth2=JSON.parse(JSON.stringify(app.store.errors.oauth2)))},0)},onbeforeclose:e=>n.onbeforeclose?.(e),onafterclose:e=>{n.onafterclose?.(e),e?.remove()}},t.header({className:`modal-header`},t.figure({className:`provider-logo`},()=>s.logo?t.img({src:`data:image/svg+xml;base64,`+btoa(s.logo),alt:s.name+` logo`}):t.i({className:app.utils.fallbackProviderIcon,ariaHidden:!0})),t.h6({className:`modal-title`},e.displayName||s.displayName||s.name,t.small({className:`txt-hint`},` (`,e.name,`)`))),t.form({pbEvent:`providerSettingsForm`,id:i+`form`,className:`modal-content`,onsubmit:e=>{e.preventDefault(),l()}},t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.clientId`,textContent:`Client ID`}),t.input({type:`text`,required:!0,id:i+`.clientId`,autocomplete:`off`,name:()=>n.namePrefix+`.clientId`,value:()=>c.config.clientId||``,oninput:e=>c.config.clientId=e.target.value.trim()}))),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.clientSecret`,textContent:`Client secret`}),t.input({type:`password`,id:i+`.clientSecret`,autocomplete:`new-password`,required:()=>a||c.config.clientSecret!==void 0,name:()=>n.namePrefix+`.clientSecret`,value:()=>c.config.clientSecret||``,oninput:e=>c.config.clientSecret=e.target.value.trim(),onkeyup:e=>{e.key==`Backspace`&&c.config.clientSecret===void 0&&(c.config.clientSecret=``)},placeholder:()=>a||c.config.clientSecret!==void 0?``:`* * * * * *`}))),()=>{if(typeof app.oauth2?.[s.name]==`function`)return t.div({className:`col-12`},app.oauth2[s.name](s,n.namePrefix,c))})),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(r)},t.span({className:`txt`},`Close`)),t.button({"html-form":i+`form`,type:`submit`,className:`btn`,disabled:()=>!c.hasChanges},t.span({className:`txt`},`Set provider config`)))),r}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openCollectionChangesConfirmation=async function(e,n,r,i){let a=store({isLoadingConflictingOIDCProviders:!1,conflictingOIDCProviders:[],get isCollectionRenamed(){return e?.name!=n?.name},get isNewCollectionAuth(){return n?.type===`auth`},get isNewCollectionView(){return n?.type===`view`},get renamedFields(){return a.isNewCollectionView?[]:n?.fields?.filter?.(n=>{let r;return n.id&&!n[`@toDelete`]&&(r=e.fields?.find?.(e=>e.id==n.id)),r&&r.name!=n.name})||[]},get deletedFields(){return a.isNewCollectionView?[]:n?.fields?.filter?.(e=>e.id&&e[`@toDelete`])||[]},get multipleToSingleFields(){return a.isNewCollectionView?[]:n?.fields?.filter?.(n=>{let r=e?.fields?.find?.(e=>e.id==n.id);if(!r||r.maxSelect===void 0)return!1;let i=r.maxSelect||1,a=n.maxSelect||1;return i>1&&a==1})||[]},get changedRules(){if(window.location.protocol!=`https:`)return[];let r=[],i=[`listRule`,`viewRule`];a.isNewCollectionView||i.push(`createRule`,`updateRule`,`deleteRule`),a.isNewCollectionAuth&&i.push(`manageRule`,`authRule`);let o,s;for(let a of i)o=e?.[a],s=n?.[a],o!==s&&r.push({prop:a,oldRule:o,newRule:s});return r},get needConfirmation(){return!app.utils.isEmpty(e?.id)&&(a.isCollectionRenamed||a.renamedFields.length||a.deletedFields.length||a.multipleToSingleFields.length||a.changedRules.length||a.conflictingOIDCProviders.length)}}),o=[`oidc`,`oidc2`,`oidc3`];async function s(){if(!(app.utils.isEmpty(e?.id)||!a.isNewCollectionAuth)){a.isLoadingConflictingOIDCProviders=!0;try{a.conflictingOIDCProviders=[];for(let r of o){let i=e?.oauth2?.providers?.find?.(e=>e.name==r),o=n?.oauth2?.providers?.find?.(e=>e.name==r);if(!i||!o)continue;let s=new URL(i.authURL).host,c=new URL(o.authURL).host;s!=c&&await app.pb.collection(`_externalAuths`).getFirstListItem(app.pb.filter(`collectionRef={:collectionId} && provider={:provider}`,{collectionId:n?.id,provider:r}),{requestKey:null})&&a.conflictingOIDCProviders.push({name:r,oldHost:s,newHost:c})}a.isLoadingConflictingOIDCProviders=!1}catch(e){e.isAbort&&(a.isLoadingConflictingOIDCProviders=!1,app.checkApiError(e))}}}if(await s(),!a.needConfirmation)return r();app.modals.confirm(t.div({className:`dangerous-collection-changes-list`},t.h5({className:`block txt-center m-b-base`},`Do you really want to save the collection changes?`),()=>{if(!(!a.isCollectionRenamed&&!a.deletedFields.length&&!a.renamedFields.length))return t.div({className:`alert warning m-b-base`},t.p(null,`If the collection participate in another collection rule, filter or view query, you'll have to update it manually!`),()=>{if(a.deletedFields.length)return t.p(null,`All data associated with the removed fields will be permanently deleted!`)})},()=>{if(a.isCollectionRenamed)return t.ul({className:`collection-changes-list changes-renamed-collection`},t.li({className:`list-item`},`Renamed collection `,t.strong({className:`label warning`},e?.name),t.i({className:`ri-arrow-right-line txt-sm`,ariaHidden:!0}),t.strong({className:`label success`},n?.name||`N/A`)))},()=>{if(a.renamedFields.length)return t.ul({className:`collection-changes-list changes-renamed-fields`},()=>a.renamedFields.map(n=>{let r=e?.fields?.find?.(e=>e.id==n.id);return t.li({className:`list-item`},`Renamed field `,t.strong({className:`label warning`},r?.name),t.i({className:`ri-arrow-right-line txt-sm`,ariaHidden:!0}),t.strong({className:`label success`},n.name||`N/A`))}))},()=>{if(a.deletedFields.length)return t.ul({className:`collection-changes-list changes-deleted-fields`},()=>a.deletedFields.map(e=>t.li({className:`list-item`},`Deleted field `,t.strong({className:`label danger`},e.name||`N/A`))))},()=>{if(a.multipleToSingleFields.length)return t.ul({className:`collection-changes-list changes-multiple-to-single-fields`},()=>a.multipleToSingleFields.map(e=>t.li({className:`list-item`},`Multiple to single value conversion of field `,t.strong({className:`label warning`},e.name||e.id),t.em({className:`txt-sm`},` (will keep only the last array item)`))))},()=>{if(a.changedRules.length)return t.ul({className:`collection-changes-list changes-api-rules`},()=>a.changedRules.map(e=>t.li({className:`list-item`},t.div({className:`content`},t.span({className:`txt`},`Changed API rule for `),t.code(null,e.prop)),t.small({className:`txt-bold`},`Old:`),t.div({className:`rule-content old-rule`},e.oldRule===null?`null (superusers only)`:e.oldRule||`""`),t.small({className:`txt-bold`},`New:`),t.div({className:`rule-content new-rule`},e.newRule===null?`null (superusers only)`:e.newRule||`""`))))},()=>{if(a.conflictingOIDCProviders.length)return t.ul({className:`collection-changes-list changes-api-rules`},()=>a.conflictingOIDCProviders.map(e=>t.li({className:`list-item`},`Changed OIDC `,e.name,` host `,t.strong({className:`label warning`},e.oldHost),t.i({className:`ri-arrow-right-line txt-sm`,ariaHidden:!0}),t.strong({className:`label success`},e.newHost),t.br(),t.span({className:`txt-hint`},`If the old and new OIDC configuration is not for the same provider consider deleting`,` all old _externalAuths records associated to the current collection and provider,`,` otherwise it may result in account linking errors.`),` `,t.a({rel:`noopenener noreferrer`,target:`_blank`,href:()=>`#/collections?collection=_externalAuths&filter=collectionRef%3D%22${n?.id}%22+%26%26+provider%3D%22${e.name}%22`,textContent:`Review existing _externalAuths records`}))))}),r,i,{className:`collection-changes-confirm-modal`})},window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openCollectionsOverview=function(e={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null}){let n=sr(e);n&&(document.body.appendChild(n),app.modals.open(n))};function sr(e={}){let n=`overview_modal_`+app.utils.randomString(),r={"Fields and relations":cr,Rules:lr},i=store({showSystemCollections:!1,activeTab:Object.keys(r)[0],get collections(){return i.showSystemCollections?app.store.collections:app.store.collections.filter(e=>!e.system)}}),a=t.div({pbEvent:`collectionsOverviewModal`,className:`modal popup collections-overview-modal`,onbeforeopen:n=>e.onbeforeopen?.(n),onafteropen:n=>{e.onafteropen?.(n)},onbeforeclose:n=>e.onbeforeclose?.(n),onafterclose:n=>{e.onafterclose?.(n),n?.remove()}},t.header({className:`modal-header isolated`},t.div({className:`grid sm`},t.div({className:`col-12`},t.div({className:`flex`},t.h6({className:`modal-title`},`Collections overview`),t.div({className:`flex-fill`}),t.div({className:`field`},t.input({id:n+`.showSystemCollections`,type:`checkbox`,className:`sm switch`,checked:()=>i.showSystemCollections,onchange:e=>i.showSystemCollections=e.target.checked}),t.label({htmlFor:n+`.showSystemCollections`},`System collections`)),t.button({type:`button`,className:`btn sm secondary transparent circle modal-close-btn`,title:`Close`,onclick:()=>app.modals.close(a)},t.i({className:`ri-close-line`,ariaHidden:!0})))),t.div({className:`col-12`},t.div({className:`tabs-header equal-width`},()=>{let e=[];for(let n in r)e.push(t.button({type:`button`,className:()=>`tab-item ${i.activeTab==n?`active`:``}`,onclick:()=>i.activeTab=n,textContent:n}));return e})))),()=>r[i.activeTab]?.(i));return a}function cr(e){return t.div({className:`modal-content erd-tab`},app.components.erd({collections:()=>{let n,r;function i(e,i){return n=e.name.startsWith(`_`),r=i.name.startsWith(`_`),e.system&&!i.system||n&&!r?1:!e.system&&i.system||!n&&r?-1:0}return e.collections.slice().sort(i)}}))}function lr(e){let n=[{value:`listRule`,label:`List/Search rule`},{value:`viewRule`,label:`View rule`},{value:`createRule`,label:`Create rule`,filter:e=>e.type!=`view`},{value:`updateRule`,label:`Update rule`,filter:e=>e.type!=`view`},{value:`deleteRule`,label:`Delete rule`,filter:e=>e.type!=`view`},{value:`authRule`,label:`Auth rule`,filter:e=>e.type==`auth`},{value:`manageRule`,label:`Manage rule`,filter:e=>e.type==`auth`},{value:`mfaRule`,label:`MFA rule`,emptyLabel:t.span({className:`label info`},`Enabled for everyone`),rule:e=>e.mfa?.rule,filter:e=>e.mfa?.enabled&&e.type==`auth`}],r=store({activeRuleOption:n[0],get activeCollections(){return r.activeRuleOption.filter?e.collections.filter(e=>r.activeRuleOption.filter(e)):e.collections}});return t.div({className:`modal-content rules-tab`},t.table({className:`rules-table`},t.thead({className:`sticky`},t.tr(null,t.td({colSpan:99,className:`col-rule-btns`},t.div({className:`rule-btns`},()=>n.map(e=>t.button({type:`button`,className:()=>`btn sm ${r.activeRuleOption?.value==e.value?`outline`:`transparent secondary`}`,textContent:()=>e.label,onclick:()=>r.activeRuleOption=e})))))),t.tbody(null,()=>r.activeCollections.length?r.activeCollections.map(e=>t.tr(null,t.th({className:`min-width`},t.div({className:`inline-flex gap-10`},t.i({ariaHidden:!0,className:()=>app.collectionTypes[e.type]?.icon||app.utils.fallbackCollectionIcon}),t.span({className:`txt collection-name`,title:()=>e.name,textContent:()=>e.name}))),()=>{let n;return n=r.activeRuleOption.rule?r.activeRuleOption.rule(e):e[r.activeRuleOption.value],t.td({style:`vertical-align: top`},()=>n===null?r.activeRuleOption.nullLabel?r.activeRuleOption.nullLabel:t.span({className:`label success`},`Superusers only`):n===``?r.activeRuleOption.emptyLabel?r.activeRuleOption.emptyLabel:t.span({className:`label info`},`Public`):app.components.codeBlock({language:`pbrule`,value:n}))})):t.tr(null,t.td({colSpan:99,className:`txt-hint`},t.p(null,`No collections with the selected rule.`))))))}window.app=window.app||{},window.app.oauth2=window.app.oauth2||{},window.app.oauth2.microsoft=function(e,n,r){let i=`microsoft_`+app.utils.randomString();return t.div({pbEvent:`oauth2MicrosoftOptions`,className:`oauth2-microsoft-options`},t.p({className:`txt-bold`},`Azure AD endpoints`),t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.authURL`},`Auth URL`),t.input({id:i+`.authURL`,name:n+`.authURL`,type:`url`,required:!0,value:()=>r.config.authURL||``,oninput:e=>r.config.authURL=e.target.value})),t.div({className:`field-help`},`Ex. https://login.microsoftonline.com/YOUR_DIRECTORY_TENANT_ID/oauth2/v2.0/authorize`)),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.tokenURL`},`Token URL`),t.input({id:i+`.tokenURL`,name:n+`.tokenURL`,type:`url`,required:!0,value:()=>r.config.tokenURL||``,oninput:e=>r.config.tokenURL=e.target.value})),t.div({className:`field-help`},`Ex. https://login.microsoftonline.com/YOUR_DIRECTORY_TENANT_ID/oauth2/v2.0/token`))))},window.app=window.app||{},window.app.oauth2=window.app.oauth2||{},window.app.oauth2.lark=function(e,n,r){let i=`lark_`+app.utils.randomString(),a=[{label:`Feishu (China)`,value:`feishu.cn`},{label:`Lark (International)`,value:`larksuite.com`}],o=store({domain:r.config.authURL?.includes(a[1].value)?a[1].value:a[0].value}),s=[watch(()=>o.domain,e=>{e&&(r.config.authURL=`https://accounts.${e}/open-apis/authen/v1/authorize`,r.config.tokenURL=`https://open.${e}/open-apis/authen/v2/oauth/token`,r.config.userInfoURL=`https://open.${e}/open-apis/authen/v1/user_info`)})];return t.div({pbEvent:`oauth2LarkOptions`,className:`oauth2-lark-options`,onunmount:()=>{s.forEach(e=>e?.unwatch())}},t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.site`},`Site`),app.components.select({options:a,required:!0,value:()=>o.domain||``,onchange:e=>{o.domain=e?.[0]?.value}}))),t.div({className:`col-12`},t.div({className:`alert info`},`Note that the Lark user's `,t.strong(null,`Union ID`),` will be used for the association with the PocketBase user (see `,t.a({href:`https://open.feishu.cn/document/platform-overveiw/basic-concepts/user-identity-introduction/introduction#3f2d4b63`,target:`_blank`,rel:`noopener noreferrer`,textContent:`Different Types of Lark User IDs`}),`).`))))},window.app=window.app||{},window.app.components=window.app.components||{},window.app.components.oauth2EndpointFields=function(e,n,r,i={}){let a=`endpoints_`+app.utils.randomString(),o=store({required:!0,title:`Provider endpoints`}),s=app.utils.extendStore(o,i);return t.div({pbEvent:`oauth2Endpoints`,className:`oauth2-endpoints`,onunmount:()=>{s.forEach(e=>e?.unwatch())}},t.p({className:`txt-bold`},e=>(typeof o.title==`function`&&o.title(e),o.title)),t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:a+`.authURL`},`Auth URL`),t.input({id:a+`.authURL`,name:n+`.authURL`,type:`url`,required:()=>!!o.required,value:()=>r.config.authURL||``,oninput:e=>r.config.authURL=e.target.value}))),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:a+`.tokenURL`},`Token URL`),t.input({id:a+`.tokenURL`,name:n+`.tokenURL`,type:`url`,required:()=>!!o.required,value:()=>r.config.tokenURL||``,oninput:e=>r.config.tokenURL=e.target.value}))),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:a+`.userInfoURL`},`User info URL`),t.input({id:a+`.userInfoURL`,name:n+`.userInfoURL`,type:`url`,required:()=>!!o.required,value:()=>r.config.userInfoURL||``,oninput:e=>r.config.userInfoURL=e.target.value})))))},window.app.oauth2=window.app.oauth2||{},window.app.oauth2.gitlab=function(e,n,r){return app.components.oauth2EndpointFields(e,n,r,{required:!1,title:`Self-hosted endpoints (optional)`})},window.app.oauth2.gitea=function(e,n,r){return app.components.oauth2EndpointFields(e,n,r,{required:!1,title:`Self-hosted endpoints (optional)`})},window.app.oauth2.mailcow=function(e,n,r){return app.components.oauth2EndpointFields(e,n,r)},window.app=window.app||{},window.app.oauth2=window.app.oauth2||{},window.app.oauth2.oidc=function(e,n,r){let i=`oidc_`+app.utils.randomString(),a=[{label:`User info URL`,value:!0},{label:`ID Token`,value:!1}],o=store({useUserInfoUrl:!1}),s=[];return t.div({pbEvent:`oauth2OIDCOptions`,className:`oauth2-oidc-options`,onmount:e=>{r.config.displayName===void 0&&(r.config.displayName=`OIDC`),r.config.pkce===void 0&&(r.config.pkce=!0),(r.config.userInfoURL||!r.config.extra)&&(o.useUserInfoUrl=!0),s.push(watch(()=>o.useUserInfoUrl,(e,n)=>{e?r.config.extra=null:(r.config.userInfoURL=``,r.config.extra=r.config.extra||{})}))},onunmount:()=>{s.forEach(e=>e?.unwatch())}},t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.displayName`},`Display name`),t.input({id:i+`.displayName`,name:n+`.displayName`,type:`text`,required:!0,value:()=>r.config.displayName||``,oninput:e=>r.config.displayName=e.target.value}))),t.div({className:`col-12`},t.p({className:`txt-bold`},`Endpoints`),t.div({className:`field`},t.label({htmlFor:i+`.authURL`},`Auth URL`),t.input({id:i+`.authURL`,name:n+`.authURL`,type:`url`,required:!0,value:()=>r.config.authURL||``,oninput:e=>r.config.authURL=e.target.value}))),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.tokenURL`},`Token URL`),t.input({id:i+`.tokenURL`,name:n+`.tokenURL`,type:`url`,required:!0,value:()=>r.config.tokenURL||``,oninput:e=>r.config.tokenURL=e.target.value}))),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.userInfoSelect`},`Fetch user info from`),app.components.select({id:i+`.userInfoSelect`,required:!0,options:a,value:()=>o.useUserInfoUrl,onchange:e=>o.useUserInfoUrl=e?.[0]?.value})),t.div({className:`oidc-userinfo-options m-t-10`},()=>o.useUserInfoUrl?t.div({className:`field`},t.label({htmlFor:i+`.userInfoURL`},`User info URL`),t.input({id:i+`.userInfoURL`,name:n+`.userInfoURL`,type:`url`,required:!0,value:()=>r.config.userInfoURL||``,oninput:e=>r.config.userInfoURL=e.target.value})):t.div({className:`grid sm`},t.div({className:`col-12 txt-hint txt-sm`},t.em(null,`Both fields are considered optional because the parsed `,t.code(null,`id_token`),` is a direct result of the TLS code->token exchange server response.`)),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.extra.jwksURL`},t.span({className:`txt`},`JWKS verification URL`),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`URL to the public token verification keys.`)})),t.input({id:i+`.extra.jwksURL`,name:n+`.extra.jwksURL`,type:`url`,value:()=>r.config.extra?.jwksURL||``,oninput:e=>{r.config.extra=r.config.extra||{},r.config.extra.jwksURL=e.target.value}}))),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.extra.issuers`},t.span({className:`txt`},`Issuers`),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Comma separated list of accepted values for the iss token claim validation.`)})),t.input({id:i+`.extra.issuers`,name:n+`.extra.issuers`,type:`text`,value:()=>app.utils.joinNonEmpty(r.config.extra?.issuers),oninput:e=>{let n=app.utils.splitNonEmpty(e.target.value,`,`),i=app.utils.joinNonEmpty(n);app.utils.joinNonEmpty(r.config.extra?.issuers)!=i&&(r.config.extra=r.config.extra||{},r.config.extra.issuers=n)}})))))),t.div({className:`col-12`},t.div({className:`field`},t.input({id:i+`.pkce`,name:n+`.pkce`,type:`checkbox`,checked:()=>r.config.pkce||!1,onchange:e=>r.config.pkce=e.target.checked}),t.label({htmlFor:i+`.pkce`},t.span({className:`txt`,textContent:`Support PKCE`}),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Usually it should be safe to be always enabled as most providers will just ignore the extra query parameters if they don't support PKCE.`)}))))))},window.app=window.app||{},window.app.oauth2=window.app.oauth2||{},window.app.oauth2.apple=function(e,n,r){return``+app.utils.randomString(),t.div({pbEvent:`oauth2AppleOptions`,className:`oauth2-apple-options`},t.button({type:`button`,className:`btn sm secondary`,onclick:()=>{app.modals.openAppleSecretGenerator({ongenerate:e=>{r.config.clientSecret=e}})}},t.i({className:`ri-key-line`,ariaHidden:!0}),t.span({className:`txt`},`Generate secret`)))},window.app.modals=window.app.modals||{},window.app.modals.openAppleSecretGenerator=function(e={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null,ongenerate:null}){let n=ur(e);n&&(document.body.appendChild(n),app.modals.open(n))};function ur(e={}){let n,r=`secret_generator_`+app.utils.randomString(),i=15777e3,a=store({clientId:``,teamId:``,keyId:``,privateKey:``,duration:i,isSubmitting:!1});async function o(){a.isSubmitting=!0;try{let r=await app.pb.settings.generateAppleClientSecret(a.clientId,a.teamId,a.keyId,a.privateKey.trim(),a.duration);a.isSubmitting=!1,app.toasts.success(`Successfully generated client secret.`),e.ongenerate?.(r.secret),app.modals.close(n)}catch(e){e.isAbort||(app.checkApiError(e),a.isSubmitting=!1)}}return n=t.div({pbEvent:`appleSecretGeneratorModal`,className:`modal popup apple-secret-generator-modal`,onbeforeopen:n=>e.onbeforeopen?.(n),onafteropen:n=>{e.onafteropen?.(n)},onbeforeclose:n=>e.onbeforeclose?.(n),onafterclose:n=>{e.onafterclose?.(n),n?.remove()}},t.header({className:`modal-header`},t.h5({className:`m-auto`},`Generate Apple client secret`)),t.form({id:r+`_form`,className:`modal-content`,onsubmit:e=>{e.preventDefault(),o()}},t.div({className:`grid`},t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:r+`.clientId`},`Client ID`),t.input({id:r+`.clientId`,name:`clientId`,type:`text`,required:!0,value:()=>a.clientId||``,oninput:e=>a.clientId=e.target.value}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:r+`.teamId`},`Team ID`),t.input({id:r+`.teamId`,name:`teamId`,type:`text`,required:!0,value:()=>a.teamId||``,oninput:e=>a.teamId=e.target.value}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:r+`.keyId`},`Key ID`),t.input({id:r+`.keyId`,name:`keyId`,type:`text`,required:!0,value:()=>a.keyId||``,oninput:e=>a.keyId=e.target.value}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:r+`.duration`},`Duration (in seconds)`),t.input({id:r+`.duration`,name:`duration`,type:`number`,min:0,step:1,max:i,required:!0,value:()=>a.duration||0,oninput:e=>a.duration=parseInt(e.target.value,10)})),t.div({className:`field-help`},`Max ${i} seconds (~${i/(3600*24*30)<<0} months).`)),t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:r+`.privateKey`},`Private key`),t.textarea({id:r+`.privateKey`,name:`privateKey`,type:`text`,required:!0,rows:8,placeholder:`-----BEGIN PRIVATE KEY----- ... ------END PRIVATE KEY-----`,value:()=>a.privateKey||``,oninput:e=>a.privateKey=e.target.value})),t.div({className:`field-help`},`The key is not stored on the server and it is used only for generating the signed JWT.`)))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(n)},t.span({className:`txt`},`Close`)),t.button({"html-form":r+`_form`,type:`submit`,className:`btn expanded`},t.i({className:`ri-key-line`,ariaHidden:!0}),t.span({className:`txt`},`Generate secret`)))),n}function dr(){return t.div({className:`inline-flex gap-5`},t.span(null,`Default log levels:`),()=>{let e=[];for(let n in app.utils.logLevels)e.push(t.code(null,`${n}:${app.utils.logLevels[n].label}`));return e})}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openLogsSettings=function(e={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null,onsave:null}){let n=fr(e);n&&(document.body.appendChild(n),app.modals.open(n))};function fr(e){let n,r=store({isLoading:!1,isSaving:!1,formSettings:{},initFormSettingsHash:``,get hasChanges(){return r.initFormSettingsHash!=JSON.stringify(r.formSettings)}});function i(e={}){r.formSettings={logs:e?.logs||{}},r.initFormSettingsHash=JSON.stringify(r.formSettings)}async function a(){r.isLoading=!0;try{i(await app.pb.settings.getAll({requestKey:`logsSettings`})),r.isLoading=!1}catch(e){e.isAbort||(r.isLoading=!1,app.checkApiError(e))}}async function o(){if(r.hasChanges){r.isSaving=!0;try{let a=await app.pb.settings.update(app.utils.filterRedactedProps(r.formSettings));e.onsave?.(a),i(a),app.toasts.success(`Successfully saved logs settings.`),r.isSaving=!1,app.modals.close(n)}catch(e){e.isAbort||(r.isSaving=!1,app.checkApiError(e))}}}return n=t.div({pbEvent:`logsSettingsModal`,className:`modal popup sm logs-settings-modal`,onbeforeopen:n=>(a(),e.onbeforeopen?.(n)),onafteropen:n=>{e.onafteropen?.(n)},onbeforeclose:n=>e.onbeforeclose?.(n),onafterclose:n=>{e.onafterclose?.(n),n?.remove()}},t.header({className:`modal-header`},t.h5({className:`m-auto`},`Logs settings`)),()=>r.isLoading?t.div({className:`modal-content flex`,style:`min-height: 200px`},t.span({className:`loader m-auto`})):[t.form({pbEvent:`logsSettingsForm`,id:`logsSettingsForm`,className:`modal-content logs-settings-form`,onsubmit:e=>{e.preventDefault(),o()}},t.div({className:`grid`},t.div({className:`col-lg-12`},t.field({className:`field`},t.label({htmlFor:`logs.maxDays`},`Max days retention`),t.input({type:`number`,id:`logs.maxDays`,name:`logs.maxDays`,min:0,required:!0,value:()=>r.formSettings.logs.maxDays,oninput:e=>r.formSettings.logs.maxDays=e.target.value<<0})),t.div({className:`field-help`},`Set to `,t.code(null,0),` to disable logs persistence.`)),t.div({className:`col-lg-12`},t.field({className:`field`},t.label({htmlFor:`logs.minLevel`},`Min log level`),t.input({type:`number`,id:`logs.minLevel`,name:`logs.minLevel`,min:-100,max:100,required:!0,value:()=>r.formSettings.logs.minLevel,oninput:e=>r.formSettings.logs.minLevel=e.target.value<<0})),t.div({className:`field-help`},t.div(null,`Logs with level below the minimum will be ignored.`),dr())),t.div({className:`col-lg-12`},t.field({className:`field`},t.input({type:`checkbox`,id:`logs.logIP`,name:`logs.logIP`,className:`switch`,checked:()=>r.formSettings.logs.logIP,onchange:e=>r.formSettings.logs.logIP=e.target.checked}),t.label({htmlFor:`logs.logIP`},`Enable IP logging`))),t.div({className:`col-lg-12`},t.field({className:`field`},t.input({type:`checkbox`,id:`logs.logAuthId`,name:`logs.logAuthId`,className:`switch`,checked:()=>r.formSettings.logs.logAuthId,onchange:e=>r.formSettings.logs.logAuthId=e.target.checked}),t.label({htmlFor:`logs.logAuthId`},`Enable Auth Id logging`))))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(n),disabled:()=>r.isSaving},t.span({className:`txt`},`Close`)),t.button({type:`submit`,"html-form":`logsSettingsForm`,className:()=>`btn ${r.isSaving?`loading`:``}`,disabled:()=>!r.hasChanges||r.isSaving},t.span({className:`txt`},`Save changes`)))]),n}function pr(e){return t.div({className:()=>`label log-level-label level-${e.level}`},t.span({className:`txt`},()=>`${app.utils.logLevels[e.level]?.label||`UNKN`} (${e.level})`))}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openLogPreview=function(e,n={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null}){let r=_r(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};var mr=[`execTime`,`type`,`auth`,`authId`,`status`,`method`,`url`,`referer`,`remoteIP`,`userIP`,`userAgent`,`error`,`details`];function hr(e){app.utils.downloadJSON(e,`log_`+e.created.replaceAll(/[-:\. ]/gi,``)+`.json`)}function gr(e){app.utils.copyToClipboard(JSON.stringify(e,null,2)),app.toasts.success(`Log copied to clipboard!`)}function _r(e,n){let r,i=store({isLoading:!1,log:null,get isRequest(){return i.log?.data?.type==`request`},get orderedDataKeys(){let e=new Set;if(!i.log?.data)return e;for(let n of mr)i.log.data[n]!==void 0&&e.add(n);for(let n in i.log.data)e.add(n);return e}});async function a(){i.isLoading=!0;try{app.utils.isObject(e)?i.log=JSON.parse(JSON.stringify(e)):i.log=await app.pb.logs.getOne(e,{requestKey:`log_preview`}),i.isLoading=!1}catch(e){e.isAbort||(i.isLoading=!1,app.checkApiError(e))}}return r=t.div({pbEvent:`logPreviewModal`,className:`modal log-preview-modal`,onbeforeopen:e=>(a(),n.onbeforeopen?.(e)),onafteropen:e=>{n.onafteropen?.(e)},onbeforeclose:e=>n.onbeforeclose?.(e),onafterclose:e=>{n.onafterclose?.(e),e?.remove()}},t.header({className:`modal-header`},t.h5(null,`Log details`),t.button({className:`btn sm circle transparent m-l-auto`,title:`More options`,"html-popovertarget":`log-meta-dropdown`},t.i({className:`ri-more-line`,ariaHidden:!0})),t.div({id:`log-meta-dropdown`,className:`dropdown`,popover:`auto`},e=>t.button({className:`dropdown-item`,onclick:()=>{gr(i.log),e.hidePopover()}},t.i({className:`ri-braces-line`,ariaHidden:!0}),t.span({className:`txt`},`Copy JSON`)))),t.div({className:`modal-content`},()=>!i.log||i.isLoading?t.div({className:`block txt-center`},t.span({className:`loader`})):t.table({pbEvent:`logPreviewTable`,className:`log-view-table responsive-table`},t.tbody(null,t.tr(null,t.th({className:`col-field-name-id p-r-0`},`id`),t.td(null,()=>i.log.id),t.td({className:`col-copy min-width`},app.components.copyButton(i.log.id))),t.tr(null,t.th({className:`col-field-name-level p-r-0`},`level`),t.td(null,()=>pr(i.log)),t.td({className:`col-copy min-width`},app.components.copyButton(i.log.level))),t.tr(null,t.th({className:`col-field-name-created p-r-0`},`created`),t.td(null,app.components.formattedDate({value:()=>i.log.created,short:!1})),t.td({className:`col-copy min-width`},app.components.copyButton(i.log.created))),()=>{if(!i.isRequest)return t.tr(null,t.th({className:`col-field-name-message p-r-0`},`message`),t.td(null,()=>app.utils.truncate(i.log.message,1e3)),t.td({className:`col-copy min-width`},app.components.copyButton(i.log.message)))},()=>{let e=[];for(let n of i.orderedDataKeys){let r=i.log.data?.[n];app.utils.logDataFormatters[n]&&(r=app.utils.logDataFormatters[n](i.log));let a=app.utils.isEmpty(r),o=!a&&app.utils.isObject(r);o&&(r=JSON.stringify(r,null,2)),e.push(t.tr({rid:`log_data_`+i.log.id+`_`+n},t.th({className:`min-width p-r-0`},`data.`+n),t.td(null,()=>a?t.span({className:`txt txt-hint`,textContent:`N/A`}):n===`error`?t.span({className:`label danger log-error-label ${o?`txt-code`:``}`,textContent:r}):n==`details`?t.span({className:`label warning log-details-label ${o?`txt-code`:``}`,textContent:r}):o?app.components.codeBlock({value:r}):t.span({className:`txt`,textContent:app.utils.stringifyValue(r,`N/A`,1e3)})),t.td({className:`col-copy min-width`},app.components.copyButton(r))))}return e}))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(r)},t.span({className:`txt`},`Close`)),t.button({type:`button`,className:`btn`,onclick:()=>hr(i.log)},t.i({className:`ri-download-line`,ariaHidden:!0}),t.span({className:`txt`},`Download JSON`)))),r}function vr(e){app.store.title=`Superuser login`;let n=store({authMethods:{},identity:e.query.demoEmail?.[0]||``,password:e.query.demoPassword?.[0]||``,showPassword:!1,otpId:``,lastOTPId:``,otpEmail:``,otpPassword:``,mfaId:``,totalSteps:1,get currentStep(){return 1+!!n.mfaId+!!n.otpId},isAuthMethodsLoading:!0,isPasswordAuthSubmitting:!1,isOTPRequestSubmitting:!1,isOTPAuthSubmitting:!1});async function r(){n.isAuthMethodsLoading=!0;try{n.authMethods=await app.pb.collection(`_superusers`).listAuthMethods(),n.totalSteps=1,n.mfaId=``,n.otpId=``,n.authMethods.mfa?.enabled&&n.authMethods.otp?.enabled&&(n.totalSteps+=2)}catch(e){app.checkApiError(e)}n.isAuthMethodsLoading=!1}return r(),t.div({pbEvent:`pageSuperuserLogin`,className:`wrapper sm m-auto p-b-base`},t.header({className:`txt-center m-b-base`},t.img({className:`main-logo`,src:()=>app.store.mainLogo,ariaHidden:!0,alt:`App logo`}),t.h5({className:`m-t-10`},t.span(null,()=>app.store.title),()=>{if(n.totalSteps>1)return t.span(null,()=>` (${n.currentStep}/${n.totalSteps})`)})),()=>{if(n.isAuthMethodsLoading)return t.div({className:`block txt-center`},t.span({className:`loader lg`}));if(n.authMethods.password?.enabled&&!n.mfaId)return br(n);if(n.authMethods.otp?.enabled)return n.otpId?wr(n):Sr(n)})}async function yr(e){if(!e.isPasswordAuthSubmitting){e.isPasswordAuthSubmitting=!0;try{await app.pb.collection(`_superusers`).authWithPassword(e.identity,e.password),app.toasts.removeAll(),app.store.errors=null,app.utils.toRememberedPath()}catch(n){n.status==401?(e.mfaId=n.response.mfaId,e.authMethods?.password?.identityFields?.length==1&&e.authMethods.password.identityFields[0]==`email`?(e.otpEmail=e.identity,await xr(e)):/^[^@\s]+@[^@\s]+$/.test(e.identity)&&(e.otpEmail=e.identity)):n.status==400?app.toasts.error(`Invalid login credentials.`):app.checkApiError(n)}e.isPasswordAuthSubmitting=!1}}function br(e){return t.form({pbEvent:`authWithPasswordForm`,className:`grid auth-with-password-form`,onsubmit:n=>{n.preventDefault(),yr(e)}},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:`login_identity`},()=>app.utils.sentenize(e.authMethods.password.identityFields.join(` or `),!1)),t.input({id:`login_identity`,name:`identity`,type:()=>e.authMethods.password.identityFields.length==1&&e.authMethods.password.identityFields[0]==`email`?`email`:`text`,required:!0,autofocus:!0,value:()=>e.identity,oninput:n=>e.identity=n.target.value}))),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`login_pass`},`Password`),t.input({id:`login_pass`,name:`password`,required:!0,type:()=>e.showPassword?`text`:`password`,value:()=>e.password,oninput:n=>e.password=n.target.value})),t.div({className:`field addon`},t.button({type:`button`,tabIndex:-1,className:`btn sm transparent secondary circle tooltip-right`,ariaLabel:app.attrs.tooltip(()=>e.showPassword?`Hide password`:`Show password`),onclick:()=>e.showPassword=!e.showPassword},t.i({className:()=>e.showPassword?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0})))),t.a({href:`#/request-password-reset`,className:`link-hint m-t-5`,onclick:e=>e.stopPropagation()},t.small(null,`Forgotten password`))),t.div({className:`col-12`},t.button({className:()=>`btn lg block next ${e.isPasswordAuthSubmitting?`loading`:``}`,disabled:()=>e.isPasswordAuthSubmitting},t.span({className:`txt`},()=>e.totalSteps>1?`Next`:`Login`),t.i({className:`ri-arrow-right-line`,ariaHidden:!0}))))}async function xr(e){if(!e.isOTPRequestSubmitting){e.isOTPRequestSubmitting=!0;try{e.otpId=(await app.pb.collection(`_superusers`).requestOTP(e.otpEmail)).otpId,e.lastOTPId=e.otpId,app.toasts.removeAll(),app.store.errors=null}catch(n){n.status==429&&(e.otpId=e.lastOTPId),app.checkApiError(n)}e.isOTPRequestSubmitting=!1}}function Sr(e){return t.form({pbEvent:`requestOTPForm`,className:`grid request-otp-form`,onsubmit:n=>{n.preventDefault(),xr(e)}},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:`otp_email`},`Email`),t.input({id:`otp_email`,name:`email`,type:`email`,required:!0,autofocus:!0,value:()=>e.otpEmail,oninput:n=>e.otpEmail=n.target.value}))),t.div({className:`col-12`},t.button({className:()=>`btn lg block ${e.isOTPRequestSubmitting?`loading`:``}`,disabled:()=>e.isOTPRequestSubmitting},t.i({className:`ri-mail-send-line`,ariaHidden:!0}),t.span({className:`txt`},`Send OTP`))))}async function Cr(e){if(!e.isOTPAuthSubmitting){e.isOTPAuthSubmitting=!0;try{await app.pb.collection(`_superusers`).authWithOTP(e.otpId||e.lastOTPId,e.otpPassword,{mfaId:e.mfaId}),app.toasts.removeAll(),app.store.errors=null,app.utils.toRememberedPath()}catch(e){app.checkApiError(e)}e.isOTPAuthSubmitting=!1}}function wr(e){return t.form({pbEvent:`authWithOTPForm`,className:`grid auht-with-otp-form`,onsubmit:n=>{n.preventDefault(),Cr(e)}},()=>{if(e.otpEmail)return t.div({className:`col-12`},t.div({className:`content txt-center`},`Check your `,t.strong(null,e.otpEmail),` inbox and enter below the received One-time password (OTP).`))},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:`otp_id`},`Id`),t.input({id:`otp_id`,name:`otpId`,type:`text`,required:!0,placeholder:()=>e.lastOTPId,value:()=>e.otpId,onchange:n=>{e.otpId=n.target.value||e.lastOTPId,n.target.value=e.otpId}}))),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`otp_password`},`One-time password`),t.input({id:`otp_password`,name:`password`,required:!0,type:()=>e.showPassword?`text`:`password`,value:()=>e.otpPassword,oninput:n=>e.otpPassword=n.target.value})),t.div({className:`field addon`},t.button({type:`button`,tabIndex:-1,className:`btn sm transparent secondary circle tooltip-right`,ariaLabel:app.attrs.tooltip(()=>e.showPassword?`Hide password`:`Show password`),onclick:()=>e.showPassword=!e.showPassword},t.i({className:()=>e.showPassword?`ri-eye-off-line`:`ri-eye-line`}))))),t.div({className:`col-12`},t.button({className:()=>`btn lg block next ${e.isOTPAuthSubmitting?`loading`:``}`,disabled:()=>e.isOTPAuthSubmitting},t.span({className:`txt`},`Login`),t.i({className:`ri-arrow-right-line`,ariaHidden:!0})),t.div({className:`block m-t-sm txt-center`},t.button({type:`button`,className:`link-hint txt-sm`,disabled:()=>e.isOTPAuthSubmitting,onclick:()=>{e.otpId=``,e.otpPassword=``}},`Request another OTP`))))}var Tr=`pbPinnedCollections`,Er=12;function Dr(){let e=store({search:``,pinned:app.utils.getLocalHistory(Tr,[]),get filteredCollections(){if(!e.search.length)return app.store.collections;let n=e.search.replaceAll(` `,``).toLowerCase();return app.store.collections.filter(e=>(e.name+e.id+e.type).toLowerCase().includes(n))},get systemCollections(){return e.filteredCollections.filter(n=>n.system&&!e.pinned.includes(n.id))},get regularCollections(){return e.filteredCollections.filter(n=>!n.system&&!e.pinned.includes(n.id))},get pinnedCollections(){return e.pinned.length?e.filteredCollections.filter(n=>e.pinned.includes(n.id)):[]}});function n(){e.search=``}let r=[];return app.components.pageSidebar({className:()=>`collections-sidebar ${e.responsiveShow?`active`:``}`,onmount:n=>{r.push(watch(()=>{app.utils.saveLocalHistory(Tr,JSON.stringify(e.pinned))})),r.push(watch(()=>app.store.activeCollection?.id,async()=>{await new Promise(e=>setTimeout(e,0));let e=n?.querySelector(`.nav-item.active`),r=e?.closest(`details`);r&&(r.open=!0,e?.scrollIntoView({block:`nearest`}))}))},onunmount:()=>{r.forEach(e=>e?.unwatch())}},t.div({className:`sidebar-search`},t.div({className:`fields`},t.div({className:`field`},t.input({className:`p-r-5`,type:`text`,placeholder:`Search collections...`,value:()=>e.search,oninput:n=>e.search=n.target.value})),t.div({className:`field addon p-l-0 p-r-5 gap-0`},t.button({hidden:()=>!e.search.length,type:`button`,className:`btn sm circle transparent secondary`,ariaDescription:app.attrs.tooltip(`Clear`,`left`),onclick:n},t.i({className:`ri-close-line`,ariaHidden:!0})),t.button({type:`button`,disabled:()=>app.store.isLoadingCollections,className:()=>`btn sm circle transparent secondary link-faded ${app.store.isLoadingCollections?`loading`:``}`,ariaDescription:app.attrs.tooltip(`Collections overview`,`left`),onclick:()=>app.modals.openCollectionsOverview()},t.i({className:`ri-organization-chart`,ariaHidden:!0}))))),()=>{if(!(!e.search.length||e.filteredCollections.length||app.store.isLoadingCollections))return t.div({className:`block p-t-base txt-center txt-hint`},t.p(null,`No collections found.`),t.button({type:`button`,className:`btn sm secondary`,textContent:`Clear search`,onclick:()=>n()}))},()=>{if(app.store.isLoadingCollections&&!e.filteredCollections.length)return t.div({className:`sidebar-content txt-center`},t.span({className:`loader sm`}))},()=>[t.nav({className:()=>`sidebar-content collections-list scrollable ${e.regularCollections.length+e.pinnedCollections>=Er?`compact`:``}`},t.details({hidden:()=>!e.pinnedCollections.length,className:()=>`nav-group nav-group-pinned-collections`,open:!0},t.summary({tabIndex:-1,onfocusout:()=>!1,onclick:()=>!1,onkeyup:()=>!1},`Pinned`),()=>e.pinnedCollections.map(n=>Or(n,e))),t.details({hidden:()=>!e.regularCollections.length,className:`nav-group nav-group-regular-collections`,open:!0},t.summary({tabIndex:-1,onfocusout:()=>!1,onclick:()=>!1,onkeyup:()=>!1},()=>e.pinnedCollections.length?`Others`:`Collections`),()=>e.regularCollections.map(n=>Or(n,e))),t.details({hidden:()=>!e.systemCollections.length,className:`nav-group nav-group-system-collections`,open:()=>e.search.length},t.summary(null,`System`),()=>e.systemCollections.map(n=>Or(n,e)))),t.div({hidden:()=>e.search.length&&!e.filteredCollections.length,className:`sidebar-content new-collection`},t.button({type:`button`,className:`btn outline block`,onclick:()=>{app.modals.openCollectionUpsert({},{onsave:e=>{app.store.activeCollection=e.id}})}},t.i({className:`ri-add-line`,ariaHidden:!0}),t.span({textContent:`New collection`})))])}function Or(e,n){return t.button({"html-data-collection-id":()=>e.id,type:`button`,className:()=>`nav-item responsive-close ${e.id==app.store.activeCollection?.id?`active`:``}`,title:()=>e.name,onauxclick:n=>{n.preventDefault(),window.open(`#/collections?collection=${e.name}`,`_blank`,`noreferrer,noopener`)},onclick:n=>{n.preventDefault(),app.store.activeCollection=e.name}},t.i({className:()=>app.collectionTypes[e.type]?.icon||app.utils.fallbackCollectionIcon,ariaHidden:!0}),t.span({className:`txt`},()=>e.name),()=>{if(!(e.type!=`auth`||!e.oauth2?.enabled||e.oauth2?.providers?.length>0))return t.i({ariaHidden:!0,className:`ri-alert-line txt-hint txt-sm`,ariaDescription:app.attrs.tooltip(`OAuth2 auth is enabled but the collection doesn't have any registered providers`)})},()=>{let r=n.pinned.indexOf(e.id);return t.span({tabIndex:-1,role:`button`,className:`pin`,title:()=>r>=0?`Unpin`:`Pin`,onclick:i=>{i.preventDefault(),i.stopPropagation(),r>=0?n.pinned.splice(r,1):n.pinned.push(e.id)}},t.i({ariaHidden:!1,className:()=>r>=0?`ri-unpin-line`:`ri-pushpin-line`}))})}var kr=`sort`,$=`filter`,Ar=`collection`,jr=`record`,Mr=`pbLastActiveCollection`,Nr=`recordsTotalCountRequest`;function Pr(e){app.store.activeCollection=e.query[Ar]?.[0]||window.localStorage.getItem(Mr);let n=store({reset:null,activeRecordIdOrModel:e.query[jr]?.[0]||``,sort:e.query[kr]?.[0]||``,filter:e.query[$]?.[0]||``,totalCount:0,isTotalCountLoading:!1});async function r(){if(app.store.activeCollection?.id){n.isTotalCountLoading=!0;try{let e=app.utils.normalizeSearchFilter(n.filter,app.store.activeCollection.fields.filter(e=>!e.hidden).map(e=>e.name));n.totalCount=(await app.pb.collection(app.store.activeCollection.name).getList(1,1,{requestKey:Nr,filter:e,fields:`id`})).totalItems}catch(e){e.isAbort||(n.totalCount=0,console.warn(`failed to load total count:`,e))}n.isTotalCountLoading=!1}}function i(){n.reset=Date.now()}let a=[watch(()=>(app.store.activeCollection?.name||``)+(app.store.activeCollection?.updated||``),(e,r)=>{r&&(r!=e&&(n.filter=``,n.sort=``),app.store.title=app.store.activeCollection?.name||`Collections`,app.utils.replaceHashQueryParams({[Ar]:app.store.activeCollection?.name,[$]:n.filter||null,[kr]:n.sort||null},e==r?null:!0),app.store.activeCollection?.id?window.localStorage.setItem(Mr,app.store.activeCollection.id):window.localStorage.removeItem(Mr))}),watch(()=>[n.filter,n.sort],(e,r)=>{r&&app.utils.replaceHashQueryParams({[$]:n.filter||null,[kr]:n.sort||null})}),watch(()=>(n.activeRecordIdOrModel||``)+(app.store.activeCollection?.id||``),(e,r)=>{if(!n.activeRecordIdOrModel){app.utils.replaceHashQueryParams({[jr]:null});return}if(e==r||!app.store.activeCollection?.id)return;let i=typeof n.activeRecordIdOrModel==`string`?{id:n.activeRecordIdOrModel,collectionId:app.store.activeCollection?.id,collectionName:app.store.activeCollection?.name}:n.activeRecordIdOrModel;app.utils.replaceHashQueryParams({[jr]:i.id||null}),app.modals.close(null,!0),app.store.activeCollection?.type==`view`?app.modals.openRecordPreview(i,{onafterclose:()=>{n.activeRecordIdOrModel=``}}):app.modals.openRecordUpsert(app.store.activeCollection,i,{onafterclose:()=>{n.activeRecordIdOrModel=``}})}),watch(()=>[app.store.activeCollection?.id,n.filter,n.reset],()=>r())],o={"record:save":e=>{e.detail.collectionId==app.store.activeCollection?.id&&n.totalCount++},"record:delete":e=>{e.detail.collectionId!=app.store.activeCollection?.id&&e.detail.collectionName!=app.store.activeCollection?.name||n.totalCount--}};return t.div({pbEvent:`pageCollections`,className:`page`,onmount:()=>{app.store.isLoadingCollections||app.store.silentlyReloadCollections();for(let e in o)document.addEventListener(e,o[e])},onunmount:()=>{app.pb.cancelRequest(Nr),a.forEach(e=>e?.unwatch());for(let e in o)document.removeEventListener(e,o[e])}},()=>Dr(),t.div({className:`page-content full-height`},t.header({className:`page-header compact flex-nowrap`},t.nav({className:`breadcrumbs`},t.div(null,`Collections`),()=>{if(app.store.activeCollection?.name)return t.div({title:app.store.activeCollection.name,textContent:app.store.activeCollection.name})}),t.div({hidden:()=>!app.store.activeCollection?.id,pbEvent:`pageHeaderSecondaryBtns`,className:`page-header-secondary-btns`},t.button({type:`button`,className:`btn circle transparent secondary tooltip-bottom btn-collection-settings`,ariaLabel:app.attrs.tooltip(`Collection settings`),onclick:()=>{app.modals.openCollectionUpsert(app.store.activeCollection,{ontruncate:()=>i(),onsave:(e,n)=>{n?app.store.activeCollection=e.id:i()}})}},t.i({className:`ri-settings-3-line`,ariaHidden:!0})),app.components.refreshButton({onclick:()=>i()})),t.div({hidden:()=>!app.store.activeCollection?.id,pbEvent:`pageHeaderPrimaryBtns`,className:`page-header-primary-btns`},t.button({type:`button`,className:`btn outline api-preview-btn`,onclick:()=>app.modals.openApiPreview(app.store.activeCollection)},t.i({className:`ri-code-s-slash-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`API preview`})),()=>{if(app.store.activeCollection?.type!=`view`)return t.button({type:`button`,className:`btn new-record-btn`,onclick:()=>app.modals.openRecordUpsert(app.store.activeCollection)},t.i({className:`ri-add-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`New Record`}))})),t.div({hidden:()=>!app.store.isLoadingCollections||app.store.activeCollection?.id,className:`block txt-center p-base`},t.span({className:`loader lg`})),t.div({hidden:()=>app.store.isLoadingCollections||app.store.activeCollection?.id,className:`block txt-center p-base`},t.h6({className:`txt`},()=>app.store.collections?.length?`Select collection from the sidebar.`:`No collections found.`)),app.components.recordsSearchbar({hidden:()=>!app.store.activeCollection?.id,collection:()=>app.store.activeCollection,value:()=>n.filter,onsubmit:e=>n.filter=e}),app.components.recordsList({className:`m-t-sm`,reset:()=>n.reset,hidden:()=>!app.store.activeCollection?.id,collection:()=>app.store.activeCollection,filter:()=>n.filter,sort:()=>n.sort,onselect:e=>{n.activeRecordIdOrModel=e},onchange:(e,r)=>{n.filter=e,n.sort=r}}),t.footer({className:`page-footer`},t.span({className:()=>`total-count ${n.isTotalCountLoading?`faded`:``}`},`Total: `,()=>n.totalCount),app.components.credits())))}function Fr(){return document.body.clientWidth>600&&document.body.clientHeight>=720?150:100}function Ir(e){let n=store({stats:[]});async function r(r){if(r){e.isChartLoading=!0;try{let i=(e.presets||[]).concat(app.utils.normalizeSearchFilter(e.filter,[`level`,`message`,`data`])),a=await app.pb.logs.getStats({filter:i.filter(Boolean).map(e=>`(`+e+`)`).join(`&&`)}),o=a.length,s=[],c=[];e.totalFound=0;for(let n=0;n3600&&(s.push(r+3600),c.push(0)):n+1==o&&(s.push(r+3600),c.push(0))}n.stats=a,e.isChartLoading=!1,Rr(r,[s,c],e)}catch(n){n?.isAbort||(e.isChartLoading=!1,console.warn(`failed to load logs chart:`,n))}}}let i=[];return t.div({pbEvent:`logsChart`,className:()=>[`logs-chart`,e.isChartLoading?`loading`:null,e.zoom?.min&&e.zoom?.max?`zoomed`:``,!n.stats.length||!e.isFirstLoadReady?`nodata`:null].filter(Boolean).join(` `),onmount:n=>{i.push(watch(()=>[e.reset,e.filter,e.presets?.length],()=>r(n))),n._resizeChartFunc=()=>{clearTimeout(n._resizeTimeoutId),n._resizeTimeoutId=setTimeout(()=>{n?._uplot&&n._uplot.setSize({width:n.clientWidth,height:Fr()})},100)},window.addEventListener(`resize`,n._resizeChartFunc)},onunmount:e=>{i.forEach(e=>e?.unwatch()),e._uplot?.destroy(),e._resizeChartFunc&&(clearTimeout(e._resizeTimeoutId),window.removeEventListener(`resize`,e._resizeChartFunc),e._resizeChartFunc=null,e._resizeTimeoutId=null)}},t.button({type:`button`,className:()=>`logs-reset-zoom-ctrl ${e.zoom?.min&&e.zoom?.max?``:`hidden`}`,onclick(){e.zoom={}}},t.div({className:`content-primary`},`Reset zoom`),t.div({className:`content-secondary`},`(drag the timeline to pan)`)),t.span({hidden:()=>!e.isChartLoading,className:()=>`loader logs-chart-loader`}))}function Lr(e){let n=e?.data?.[0];n&&e.setScale(`x`,{min:n[0],max:n[n.length-1]})}function Rr(e,n,r){let i=window.getComputedStyle(e),a=i.getPropertyValue(`--surfaceTxtHintColor`),o=i.getPropertyValue(`--surfaceAlt1Color`),s=i.getPropertyValue(`--surfaceAlt4Color`),c=i.getPropertyValue(`--surfaceAlt2Color`),l={width:e.clientWidth,height:Fr(),legend:{show:!1},cursor:{x:!1,y:!1},scales:{x:{range:(e,r,i)=>rn[0][n[0].length-1]?[e.scales.x.min,e.scales.x.max]:[r,i]},y:{range:{min:{pad:.2,soft:0,mode:1},max:{pad:.2,soft:0,mode:2}}}},series:[{},{paths:uPlot.paths.stepped({align:1}),points:{show:!1,size:1},width:2,fill:c,stroke:s}],axes:[{show:!0,size:35,lineGap:1,space:60,stroke:a,incrs:[300,600,900,1800,3600,3600*2,3600*3,3600*4,3600*6,3600*12,86400,86400*2],values:[[3600,`{h}{aa}`,` +-----END PRIVATE KEY-----`,value:()=>a.privateKey||``,oninput:e=>a.privateKey=e.target.value})),t.div({className:`field-help`},`The key is not stored on the server and it is used only for generating the signed JWT.`)))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(n)},t.span({className:`txt`},`Close`)),t.button({"html-form":r+`_form`,type:`submit`,className:`btn expanded`},t.i({className:`ri-key-line`,ariaHidden:!0}),t.span({className:`txt`},`Generate secret`)))),n}function dr(){return t.div({className:`inline-flex gap-5`},t.span(null,`Default log levels:`),()=>{let e=[];for(let n in app.utils.logLevels)e.push(t.code(null,`${n}:${app.utils.logLevels[n].label}`));return e})}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openLogsSettings=function(e={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null,onsave:null}){let n=fr(e);n&&(document.body.appendChild(n),app.modals.open(n))};function fr(e){let n,r=store({isLoading:!1,isSaving:!1,formSettings:{},initFormSettingsHash:``,get hasChanges(){return r.initFormSettingsHash!=JSON.stringify(r.formSettings)}});function i(e={}){r.formSettings={logs:e?.logs||{}},r.initFormSettingsHash=JSON.stringify(r.formSettings)}async function a(){r.isLoading=!0;try{i(await app.pb.settings.getAll({requestKey:`logsSettings`})),r.isLoading=!1}catch(e){e.isAbort||(r.isLoading=!1,app.checkApiError(e))}}async function o(){if(r.hasChanges){r.isSaving=!0;try{let a=await app.pb.settings.update(app.utils.filterRedactedProps(r.formSettings));e.onsave?.(a),i(a),app.toasts.success(`Successfully saved logs settings.`),r.isSaving=!1,app.modals.close(n)}catch(e){e.isAbort||(r.isSaving=!1,app.checkApiError(e))}}}return n=t.div({pbEvent:`logsSettingsModal`,className:`modal popup sm logs-settings-modal`,onbeforeopen:n=>(a(),e.onbeforeopen?.(n)),onafteropen:n=>{e.onafteropen?.(n)},onbeforeclose:n=>e.onbeforeclose?.(n),onafterclose:n=>{e.onafterclose?.(n),n?.remove()}},t.header({className:`modal-header`},t.h5({className:`m-auto`},`Logs settings`)),()=>r.isLoading?t.div({className:`modal-content flex`,style:`min-height: 200px`},t.span({className:`loader m-auto`})):[t.form({pbEvent:`logsSettingsForm`,id:`logsSettingsForm`,className:`modal-content logs-settings-form`,onsubmit:e=>{e.preventDefault(),o()}},t.div({className:`grid`},t.div({className:`col-lg-12`},t.field({className:`field`},t.label({htmlFor:`logs.maxDays`},`Max days retention`),t.input({type:`number`,id:`logs.maxDays`,name:`logs.maxDays`,min:0,required:!0,value:()=>r.formSettings.logs.maxDays,oninput:e=>r.formSettings.logs.maxDays=e.target.value<<0})),t.div({className:`field-help`},`Set to `,t.code(null,0),` to disable logs persistence.`)),t.div({className:`col-lg-12`},t.field({className:`field`},t.label({htmlFor:`logs.minLevel`},`Min log level`),t.input({type:`number`,id:`logs.minLevel`,name:`logs.minLevel`,min:-100,max:100,required:!0,value:()=>r.formSettings.logs.minLevel,oninput:e=>r.formSettings.logs.minLevel=e.target.value<<0})),t.div({className:`field-help`},t.div(null,`Logs with level below the minimum will be ignored.`),dr())),t.div({className:`col-lg-12`},t.field({className:`field`},t.input({type:`checkbox`,id:`logs.logIP`,name:`logs.logIP`,className:`switch`,checked:()=>r.formSettings.logs.logIP,onchange:e=>r.formSettings.logs.logIP=e.target.checked}),t.label({htmlFor:`logs.logIP`},`Enable IP logging`))),t.div({className:`col-lg-12`},t.field({className:`field`},t.input({type:`checkbox`,id:`logs.logAuthId`,name:`logs.logAuthId`,className:`switch`,checked:()=>r.formSettings.logs.logAuthId,onchange:e=>r.formSettings.logs.logAuthId=e.target.checked}),t.label({htmlFor:`logs.logAuthId`},`Enable Auth Id logging`))))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(n),disabled:()=>r.isSaving},t.span({className:`txt`},`Close`)),t.button({type:`submit`,"html-form":`logsSettingsForm`,className:()=>`btn ${r.isSaving?`loading`:``}`,disabled:()=>!r.hasChanges||r.isSaving},t.span({className:`txt`},`Save changes`)))]),n}function pr(e){return t.div({className:()=>`label log-level-label level-${e.level}`},t.span({className:`txt`},()=>`${app.utils.logLevels[e.level]?.label||`UNKN`} (${e.level})`))}window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openLogPreview=function(e,n={onbeforeopen:null,onafteropen:null,onbeforeclose:null,onafterclose:null}){let r=_r(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};var mr=[`execTime`,`type`,`auth`,`authId`,`status`,`method`,`url`,`referer`,`remoteIP`,`userIP`,`userAgent`,`error`,`details`];function hr(e){app.utils.downloadJSON(e,`log_`+e.created.replaceAll(/[-:\. ]/gi,``)+`.json`)}function gr(e){app.utils.copyToClipboard(JSON.stringify(e,null,2)),app.toasts.success(`Log copied to clipboard!`)}function _r(e,n){let r,i=store({isLoading:!1,log:null,get isRequest(){return i.log?.data?.type==`request`},get orderedDataKeys(){let e=new Set;if(!i.log?.data)return e;for(let n of mr)i.log.data[n]!==void 0&&e.add(n);for(let n in i.log.data)e.add(n);return e}});async function a(){i.isLoading=!0;try{app.utils.isObject(e)?i.log=JSON.parse(JSON.stringify(e)):i.log=await app.pb.logs.getOne(e,{requestKey:`log_preview`}),i.isLoading=!1}catch(e){e.isAbort||(i.isLoading=!1,app.checkApiError(e))}}return r=t.div({pbEvent:`logPreviewModal`,className:`modal log-preview-modal`,onbeforeopen:e=>(a(),n.onbeforeopen?.(e)),onafteropen:e=>{n.onafteropen?.(e)},onbeforeclose:e=>n.onbeforeclose?.(e),onafterclose:e=>{n.onafterclose?.(e),e?.remove()}},t.header({className:`modal-header`},t.h5(null,`Log details`),t.button({className:`btn sm circle transparent m-l-auto`,title:`More options`,"html-popovertarget":`log-meta-dropdown`},t.i({className:`ri-more-line`,ariaHidden:!0})),t.div({id:`log-meta-dropdown`,className:`dropdown`,popover:`auto`},e=>t.button({className:`dropdown-item`,onclick:()=>{gr(i.log),e.hidePopover()}},t.i({className:`ri-braces-line`,ariaHidden:!0}),t.span({className:`txt`},`Copy JSON`)))),t.div({className:`modal-content`},()=>!i.log||i.isLoading?t.div({className:`block txt-center`},t.span({className:`loader`})):t.table({pbEvent:`logPreviewTable`,className:`log-view-table responsive-table`},t.tbody(null,t.tr(null,t.th({className:`col-field-name-id p-r-0`},`id`),t.td(null,()=>i.log.id),t.td({className:`col-copy min-width`},app.components.copyButton(i.log.id))),t.tr(null,t.th({className:`col-field-name-level p-r-0`},`level`),t.td(null,()=>pr(i.log)),t.td({className:`col-copy min-width`},app.components.copyButton(i.log.level))),t.tr(null,t.th({className:`col-field-name-created p-r-0`},`created`),t.td(null,app.components.formattedDate({value:()=>i.log.created,short:!1})),t.td({className:`col-copy min-width`},app.components.copyButton(i.log.created))),()=>{if(!i.isRequest)return t.tr(null,t.th({className:`col-field-name-message p-r-0`},`message`),t.td(null,()=>app.utils.truncate(i.log.message,1e3)),t.td({className:`col-copy min-width`},app.components.copyButton(i.log.message)))},()=>{let e=[];for(let n of i.orderedDataKeys){let r=i.log.data?.[n];app.utils.logDataFormatters[n]&&(r=app.utils.logDataFormatters[n](i.log));let a=app.utils.isEmpty(r),o=!a&&app.utils.isObject(r);o&&(r=JSON.stringify(r,null,2)),e.push(t.tr({rid:`log_data_`+i.log.id+`_`+n},t.th({className:`min-width p-r-0`},`data.`+n),t.td(null,()=>a?t.span({className:`txt txt-hint`,textContent:`N/A`}):n===`error`?t.span({className:`label danger log-error-label ${o?`txt-code`:``}`,textContent:r}):n==`details`?t.span({className:`label warning log-details-label ${o?`txt-code`:``}`,textContent:r}):o?app.components.codeBlock({value:r}):t.span({className:`txt`,textContent:app.utils.stringifyValue(r,`N/A`,1e3)})),t.td({className:`col-copy min-width`},app.components.copyButton(r))))}return e}))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(r)},t.span({className:`txt`},`Close`)),t.button({type:`button`,className:`btn`,onclick:()=>hr(i.log)},t.i({className:`ri-download-line`,ariaHidden:!0}),t.span({className:`txt`},`Download JSON`)))),r}function vr(e){app.store.title=`Superuser login`;let n=store({authMethods:{},identity:e.query.demoEmail?.[0]||``,password:e.query.demoPassword?.[0]||``,showPassword:!1,otpId:``,lastOTPId:``,otpEmail:``,otpPassword:``,mfaId:``,totalSteps:1,get currentStep(){return 1+!!n.mfaId+!!n.otpId},isAuthMethodsLoading:!0,isPasswordAuthSubmitting:!1,isOTPRequestSubmitting:!1,isOTPAuthSubmitting:!1});async function r(){n.isAuthMethodsLoading=!0;try{n.authMethods=await app.pb.collection(`_superusers`).listAuthMethods(),n.totalSteps=1,n.mfaId=``,n.otpId=``,n.authMethods.mfa?.enabled&&n.authMethods.otp?.enabled&&(n.totalSteps+=2)}catch(e){app.checkApiError(e)}n.isAuthMethodsLoading=!1}return r(),t.div({pbEvent:`pageSuperuserLogin`,className:`wrapper sm m-auto p-b-base`},t.header({className:`txt-center m-b-base`},t.img({className:`main-logo`,src:()=>app.store.mainLogo,ariaHidden:!0,alt:`App logo`}),t.h5({className:`m-t-10`},t.span(null,()=>app.store.title),()=>{if(n.totalSteps>1)return t.span(null,()=>` (${n.currentStep}/${n.totalSteps})`)})),()=>{if(n.isAuthMethodsLoading)return t.div({className:`block txt-center`},t.span({className:`loader lg`}));if(n.authMethods.password?.enabled&&!n.mfaId)return br(n);if(n.authMethods.otp?.enabled)return n.otpId?wr(n):Sr(n)})}async function yr(e){if(!e.isPasswordAuthSubmitting){e.isPasswordAuthSubmitting=!0;try{await app.pb.collection(`_superusers`).authWithPassword(e.identity,e.password),app.toasts.removeAll(),app.store.errors=null,app.utils.toRememberedPath()}catch(n){n.status==401?(e.mfaId=n.response.mfaId,e.authMethods?.password?.identityFields?.length==1&&e.authMethods.password.identityFields[0]==`email`?(e.otpEmail=e.identity,await xr(e)):/^[^@\s]+@[^@\s]+$/.test(e.identity)&&(e.otpEmail=e.identity)):n.status==400?app.toasts.error(`Invalid login credentials.`):app.checkApiError(n)}e.isPasswordAuthSubmitting=!1}}function br(e){return t.form({pbEvent:`authWithPasswordForm`,className:`grid auth-with-password-form`,onsubmit:n=>{n.preventDefault(),yr(e)}},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:`login_identity`},()=>app.utils.sentenize(e.authMethods.password.identityFields.join(` or `),!1)),t.input({id:`login_identity`,name:`identity`,type:()=>e.authMethods.password.identityFields.length==1&&e.authMethods.password.identityFields[0]==`email`?`email`:`text`,required:!0,autofocus:!0,value:()=>e.identity,oninput:n=>e.identity=n.target.value}))),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`login_pass`},`Password`),t.input({id:`login_pass`,name:`password`,required:!0,type:()=>e.showPassword?`text`:`password`,value:()=>e.password,oninput:n=>e.password=n.target.value})),t.div({className:`field addon`},t.button({type:`button`,tabIndex:-1,className:`btn sm transparent secondary circle tooltip-right`,ariaLabel:app.attrs.tooltip(()=>e.showPassword?`Hide password`:`Show password`),onclick:()=>e.showPassword=!e.showPassword},t.i({className:()=>e.showPassword?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0})))),t.a({href:`#/request-password-reset`,className:`link-hint m-t-5`,onclick:e=>e.stopPropagation()},t.small(null,`Forgotten password`))),t.div({className:`col-12`},t.button({className:()=>`btn lg block next ${e.isPasswordAuthSubmitting?`loading`:``}`,disabled:()=>e.isPasswordAuthSubmitting},t.span({className:`txt`},()=>e.totalSteps>1?`Next`:`Login`),t.i({className:`ri-arrow-right-line`,ariaHidden:!0}))))}async function xr(e){if(!e.isOTPRequestSubmitting){e.isOTPRequestSubmitting=!0;try{e.otpId=(await app.pb.collection(`_superusers`).requestOTP(e.otpEmail)).otpId,e.lastOTPId=e.otpId,app.toasts.removeAll(),app.store.errors=null}catch(n){n.status==429&&(e.otpId=e.lastOTPId),app.checkApiError(n)}e.isOTPRequestSubmitting=!1}}function Sr(e){return t.form({pbEvent:`requestOTPForm`,className:`grid request-otp-form`,onsubmit:n=>{n.preventDefault(),xr(e)}},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:`otp_email`},`Email`),t.input({id:`otp_email`,name:`email`,type:`email`,required:!0,autofocus:!0,value:()=>e.otpEmail,oninput:n=>e.otpEmail=n.target.value}))),t.div({className:`col-12`},t.button({className:()=>`btn lg block ${e.isOTPRequestSubmitting?`loading`:``}`,disabled:()=>e.isOTPRequestSubmitting},t.i({className:`ri-mail-send-line`,ariaHidden:!0}),t.span({className:`txt`},`Send OTP`))))}async function Cr(e){if(!e.isOTPAuthSubmitting){e.isOTPAuthSubmitting=!0;try{await app.pb.collection(`_superusers`).authWithOTP(e.otpId||e.lastOTPId,e.otpPassword,{mfaId:e.mfaId}),app.toasts.removeAll(),app.store.errors=null,app.utils.toRememberedPath()}catch(e){app.checkApiError(e)}e.isOTPAuthSubmitting=!1}}function wr(e){return t.form({pbEvent:`authWithOTPForm`,className:`grid auht-with-otp-form`,onsubmit:n=>{n.preventDefault(),Cr(e)}},()=>{if(e.otpEmail)return t.div({className:`col-12`},t.div({className:`content txt-center`},`Check your `,t.strong(null,e.otpEmail),` inbox and enter below the received One-time password (OTP).`))},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:`otp_id`},`Id`),t.input({id:`otp_id`,name:`otpId`,type:`text`,required:!0,placeholder:()=>e.lastOTPId,value:()=>e.otpId,onchange:n=>{e.otpId=n.target.value||e.lastOTPId,n.target.value=e.otpId}}))),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`otp_password`},`One-time password`),t.input({id:`otp_password`,name:`password`,required:!0,type:()=>e.showPassword?`text`:`password`,value:()=>e.otpPassword,oninput:n=>e.otpPassword=n.target.value})),t.div({className:`field addon`},t.button({type:`button`,tabIndex:-1,className:`btn sm transparent secondary circle tooltip-right`,ariaLabel:app.attrs.tooltip(()=>e.showPassword?`Hide password`:`Show password`),onclick:()=>e.showPassword=!e.showPassword},t.i({className:()=>e.showPassword?`ri-eye-off-line`:`ri-eye-line`}))))),t.div({className:`col-12`},t.button({className:()=>`btn lg block next ${e.isOTPAuthSubmitting?`loading`:``}`,disabled:()=>e.isOTPAuthSubmitting},t.span({className:`txt`},`Login`),t.i({className:`ri-arrow-right-line`,ariaHidden:!0})),t.div({className:`block m-t-sm txt-center`},t.button({type:`button`,className:`link-hint txt-sm`,disabled:()=>e.isOTPAuthSubmitting,onclick:()=>{e.otpId=``,e.otpPassword=``}},`Request another OTP`))))}var Tr=`pbPinnedCollections`,Er=12;function Dr(){let e=store({search:``,pinned:app.utils.getLocalHistory(Tr,[]),get filteredCollections(){if(!e.search.length)return app.store.collections;let n=e.search.replaceAll(` `,``).toLowerCase();return app.store.collections.filter(e=>(e.name+e.id+e.type).toLowerCase().includes(n))},get systemCollections(){return e.filteredCollections.filter(n=>n.system&&!e.pinned.includes(n.id))},get regularCollections(){return e.filteredCollections.filter(n=>!n.system&&!e.pinned.includes(n.id))},get pinnedCollections(){return e.pinned.length?e.filteredCollections.filter(n=>e.pinned.includes(n.id)):[]}});function n(){e.search=``}let r=[];return app.components.pageSidebar({className:()=>`collections-sidebar ${e.responsiveShow?`active`:``}`,onmount:n=>{r.push(watch(()=>{app.utils.saveLocalHistory(Tr,JSON.stringify(e.pinned))})),r.push(watch(()=>app.store.activeCollection?.id,async()=>{await new Promise(e=>setTimeout(e,0));let e=n?.querySelector(`.nav-item.active`),r=e?.closest(`details`);r&&(r.open=!0,e?.scrollIntoView({block:`nearest`}))}))},onunmount:()=>{r.forEach(e=>e?.unwatch())}},t.div({className:`sidebar-search`},t.div({className:`fields`},t.div({className:`field`},t.input({className:`p-r-5`,type:`text`,placeholder:`Search collections...`,value:()=>e.search,oninput:n=>e.search=n.target.value})),t.div({className:`field addon p-l-0 p-r-5 gap-0`},t.button({hidden:()=>!e.search.length,type:`button`,className:`btn sm circle transparent secondary`,ariaDescription:app.attrs.tooltip(`Clear`,`left`),onclick:n},t.i({className:`ri-close-line`,ariaHidden:!0})),t.button({type:`button`,disabled:()=>app.store.isLoadingCollections,className:()=>`btn sm circle transparent secondary link-faded ${app.store.isLoadingCollections?`loading`:``}`,ariaDescription:app.attrs.tooltip(`Collections overview`,`left`),onclick:()=>app.modals.openCollectionsOverview()},t.i({className:`ri-organization-chart`,ariaHidden:!0}))))),()=>{if(!(!e.search.length||e.filteredCollections.length||app.store.isLoadingCollections))return t.div({className:`block p-t-base txt-center txt-hint`},t.p(null,`No collections found.`),t.button({type:`button`,className:`btn sm secondary`,textContent:`Clear search`,onclick:()=>n()}))},()=>{if(app.store.isLoadingCollections&&!e.filteredCollections.length)return t.div({className:`sidebar-content txt-center`},t.span({className:`loader sm`}))},()=>[t.nav({className:()=>`sidebar-content collections-list scrollable ${e.regularCollections.length+e.pinnedCollections>=Er?`compact`:``}`},t.details({hidden:()=>!e.pinnedCollections.length,className:()=>`nav-group nav-group-pinned-collections`,open:!0},t.summary({tabIndex:-1,onfocusout:()=>!1,onclick:()=>!1,onkeyup:()=>!1},`Pinned`),()=>e.pinnedCollections.map(n=>Or(n,e))),t.details({hidden:()=>!e.regularCollections.length,className:`nav-group nav-group-regular-collections`,open:!0},t.summary({tabIndex:-1,onfocusout:()=>!1,onclick:()=>!1,onkeyup:()=>!1},()=>e.pinnedCollections.length?`Others`:`Collections`),()=>e.regularCollections.map(n=>Or(n,e))),t.details({hidden:()=>!e.systemCollections.length,className:`nav-group nav-group-system-collections`,open:()=>e.search.length},t.summary(null,`System`),()=>e.systemCollections.map(n=>Or(n,e)))),t.div({hidden:()=>e.search.length&&!e.filteredCollections.length,className:`sidebar-content new-collection`},t.button({type:`button`,className:`btn outline block`,onclick:()=>{app.modals.openCollectionUpsert({},{onsave:e=>{app.store.activeCollection=e.id}})}},t.i({className:`ri-add-line`,ariaHidden:!0}),t.span({textContent:`New collection`})))])}function Or(e,n){return t.button({"html-data-collection-id":()=>e.id,type:`button`,className:()=>`nav-item responsive-close ${e.id==app.store.activeCollection?.id?`active`:``}`,title:()=>e.name,onauxclick:n=>{n.preventDefault(),window.open(`#/collections?collection=${e.name}`,`_blank`,`noreferrer,noopener`)},onclick:n=>{n.preventDefault(),app.store.activeCollection=e.name}},t.i({className:()=>app.collectionTypes[e.type]?.icon||app.utils.fallbackCollectionIcon,ariaHidden:!0}),t.span({className:`txt`},()=>e.name),()=>{if(!(e.type!=`auth`||!e.oauth2?.enabled||e.oauth2?.providers?.length>0))return t.i({ariaHidden:!0,className:`ri-alert-line txt-hint txt-sm`,ariaDescription:app.attrs.tooltip(`OAuth2 auth is enabled but the collection doesn't have any registered providers`)})},()=>{let r=n.pinned.indexOf(e.id);return t.span({tabIndex:-1,role:`button`,className:`pin`,title:()=>r>=0?`Unpin`:`Pin`,onclick:i=>{i.preventDefault(),i.stopPropagation(),r>=0?n.pinned.splice(r,1):n.pinned.push(e.id)}},t.i({ariaHidden:!1,className:()=>r>=0?`ri-unpin-line`:`ri-pushpin-line`}))})}var kr=`sort`,$=`filter`,Ar=`collection`,jr=`record`,Mr=`pbLastActiveCollection`,Nr=`recordsTotalCountRequest`;function Pr(e){app.store.activeCollection=e.query[Ar]?.[0]||window.localStorage.getItem(Mr);let n=store({reset:null,activeRecordIdOrModel:e.query[jr]?.[0]||``,sort:e.query[kr]?.[0]||``,filter:e.query[$]?.[0]||``,totalCount:0,isTotalCountLoading:!1});async function r(){if(app.store.activeCollection?.id){n.isTotalCountLoading=!0;try{let e=app.utils.normalizeSearchFilter(n.filter,app.store.activeCollection.fields.filter(e=>!e.hidden).map(e=>e.name));n.totalCount=(await app.pb.collection(app.store.activeCollection.name).getList(1,1,{requestKey:Nr,filter:e,fields:`id`})).totalItems}catch(e){e.isAbort||(n.totalCount=0,console.warn(`failed to load total count:`,e))}n.isTotalCountLoading=!1}}function i(){n.reset=Date.now()}let a=[watch(()=>(app.store.activeCollection?.name||``)+(app.store.activeCollection?.updated||``),(e,r)=>{app.store.title=app.store.activeCollection?.name||`Collections`,r&&(r!=e&&(n.filter=``,n.sort=``),app.utils.replaceHashQueryParams({[Ar]:app.store.activeCollection?.name,[$]:n.filter||null,[kr]:n.sort||null},e==r?null:!0),app.store.activeCollection?.id?window.localStorage.setItem(Mr,app.store.activeCollection.id):window.localStorage.removeItem(Mr))}),watch(()=>[n.filter,n.sort],(e,r)=>{r&&app.utils.replaceHashQueryParams({[$]:n.filter||null,[kr]:n.sort||null})}),watch(()=>(n.activeRecordIdOrModel||``)+(app.store.activeCollection?.id||``),(e,r)=>{if(!n.activeRecordIdOrModel){app.utils.replaceHashQueryParams({[jr]:null});return}if(e==r||!app.store.activeCollection?.id)return;let i=typeof n.activeRecordIdOrModel==`string`?{id:n.activeRecordIdOrModel,collectionId:app.store.activeCollection?.id,collectionName:app.store.activeCollection?.name}:n.activeRecordIdOrModel;app.utils.replaceHashQueryParams({[jr]:i.id||null}),app.modals.close(null,!0),app.store.activeCollection?.type==`view`?app.modals.openRecordPreview(i,{onafterclose:()=>{n.activeRecordIdOrModel=``}}):app.modals.openRecordUpsert(app.store.activeCollection,i,{onafterclose:()=>{n.activeRecordIdOrModel=``}})}),watch(()=>[app.store.activeCollection?.id,n.filter,n.reset],()=>r())],o={"record:save":e=>{e.detail.collectionId==app.store.activeCollection?.id&&n.totalCount++},"record:delete":e=>{e.detail.collectionId!=app.store.activeCollection?.id&&e.detail.collectionName!=app.store.activeCollection?.name||n.totalCount--}};return t.div({pbEvent:`pageCollections`,className:`page`,onmount:()=>{app.store.isLoadingCollections||app.store.silentlyReloadCollections();for(let e in o)document.addEventListener(e,o[e])},onunmount:()=>{app.pb.cancelRequest(Nr),a.forEach(e=>e?.unwatch());for(let e in o)document.removeEventListener(e,o[e])}},()=>Dr(),t.div({className:`page-content full-height`},t.header({className:`page-header compact flex-nowrap`},t.nav({className:`breadcrumbs`},t.div(null,`Collections`),()=>{if(app.store.activeCollection?.name)return t.div({title:app.store.activeCollection.name,textContent:app.store.activeCollection.name})}),t.div({hidden:()=>!app.store.activeCollection?.id,pbEvent:`pageHeaderSecondaryBtns`,className:`page-header-secondary-btns`},t.button({type:`button`,className:`btn circle transparent secondary tooltip-bottom btn-collection-settings`,ariaLabel:app.attrs.tooltip(`Collection settings`),onclick:()=>{app.modals.openCollectionUpsert(app.store.activeCollection,{ontruncate:()=>i(),onsave:(e,n)=>{n?app.store.activeCollection=e.id:i()}})}},t.i({className:`ri-settings-3-line`,ariaHidden:!0})),app.components.refreshButton({onclick:()=>i()})),t.div({hidden:()=>!app.store.activeCollection?.id,pbEvent:`pageHeaderPrimaryBtns`,className:`page-header-primary-btns`},t.button({type:`button`,className:`btn outline api-preview-btn`,onclick:()=>app.modals.openApiPreview(app.store.activeCollection)},t.i({className:`ri-code-s-slash-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`API preview`})),()=>{if(app.store.activeCollection?.type!=`view`)return t.button({type:`button`,className:`btn new-record-btn`,onclick:()=>app.modals.openRecordUpsert(app.store.activeCollection)},t.i({className:`ri-add-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`New Record`}))})),t.div({hidden:()=>!app.store.isLoadingCollections||app.store.activeCollection?.id,className:`block txt-center p-base`},t.span({className:`loader lg`})),t.div({hidden:()=>app.store.isLoadingCollections||app.store.activeCollection?.id,className:`block txt-center p-base`},t.h6({className:`txt`},()=>app.store.collections?.length?`Select collection from the sidebar.`:`No collections found.`)),app.components.recordsSearchbar({hidden:()=>!app.store.activeCollection?.id,collection:()=>app.store.activeCollection,value:()=>n.filter,onsubmit:e=>n.filter=e}),app.components.recordsList({className:`m-t-sm`,reset:()=>n.reset,hidden:()=>!app.store.activeCollection?.id,collection:()=>app.store.activeCollection,filter:()=>n.filter,sort:()=>n.sort,onselect:e=>{n.activeRecordIdOrModel=e},onchange:(e,r)=>{n.filter=e,n.sort=r}}),t.footer({className:`page-footer`},t.span({className:()=>`total-count ${n.isTotalCountLoading?`faded`:``}`},`Total: `,()=>n.totalCount),app.components.credits())))}function Fr(){return document.body.clientWidth>600&&document.body.clientHeight>=720?150:100}function Ir(e){let n=store({stats:[]});async function r(r){if(r){e.isChartLoading=!0;try{let i=(e.presets||[]).concat(app.utils.normalizeSearchFilter(e.filter,[`level`,`message`,`data`])),a=await app.pb.logs.getStats({filter:i.filter(Boolean).map(e=>`(`+e+`)`).join(`&&`)}),o=a.length,s=[],c=[];e.totalFound=0;for(let n=0;n3600&&(s.push(r+3600),c.push(0)):n+1==o&&(s.push(r+3600),c.push(0))}n.stats=a,e.isChartLoading=!1,Rr(r,[s,c],e)}catch(n){n?.isAbort||(e.isChartLoading=!1,console.warn(`failed to load logs chart:`,n))}}}let i=[];return t.div({pbEvent:`logsChart`,className:()=>[`logs-chart`,e.isChartLoading?`loading`:null,e.zoom?.min&&e.zoom?.max?`zoomed`:``,!n.stats.length||!e.isFirstLoadReady?`nodata`:null].filter(Boolean).join(` `),onmount:n=>{i.push(watch(()=>[e.reset,e.filter,e.presets?.length],()=>r(n))),n._resizeChartFunc=()=>{clearTimeout(n._resizeTimeoutId),n._resizeTimeoutId=setTimeout(()=>{n?._uplot&&n._uplot.setSize({width:n.clientWidth,height:Fr()})},100)},window.addEventListener(`resize`,n._resizeChartFunc)},onunmount:e=>{i.forEach(e=>e?.unwatch()),e._uplot?.destroy(),e._resizeChartFunc&&(clearTimeout(e._resizeTimeoutId),window.removeEventListener(`resize`,e._resizeChartFunc),e._resizeChartFunc=null,e._resizeTimeoutId=null)}},t.button({type:`button`,className:()=>`logs-reset-zoom-ctrl ${e.zoom?.min&&e.zoom?.max?``:`hidden`}`,onclick(){e.zoom={}}},t.div({className:`content-primary`},`Reset zoom`),t.div({className:`content-secondary`},`(drag the timeline to pan)`)),t.span({hidden:()=>!e.isChartLoading,className:()=>`loader logs-chart-loader`}))}function Lr(e){let n=e?.data?.[0];n&&e.setScale(`x`,{min:n[0],max:n[n.length-1]})}function Rr(e,n,r){let i=window.getComputedStyle(e),a=i.getPropertyValue(`--surfaceTxtHintColor`),o=i.getPropertyValue(`--surfaceAlt1Color`),s=i.getPropertyValue(`--surfaceAlt4Color`),c=i.getPropertyValue(`--surfaceAlt2Color`),l={width:e.clientWidth,height:Fr(),legend:{show:!1},cursor:{x:!1,y:!1},scales:{x:{range:(e,r,i)=>rn[0][n[0].length-1]?[e.scales.x.min,e.scales.x.max]:[r,i]},y:{range:{min:{pad:.2,soft:0,mode:1},max:{pad:.2,soft:0,mode:2}}}},series:[{},{paths:uPlot.paths.stepped({align:1}),points:{show:!1,size:1},width:2,fill:c,stroke:s}],axes:[{show:!0,size:35,lineGap:1,space:60,stroke:a,incrs:[300,600,900,1800,3600,3600*2,3600*3,3600*4,3600*6,3600*12,86400,86400*2],values:[[3600,`{h}{aa}`,` {MMM} {DD}`,null,` {MMM} {DD}`,null,null,null,1],[60,`{h}:{mm}{aa}`,` {MMM} {DD}`,null,` diff --git a/ui/dist/index.html b/ui/dist/index.html index e725942b..21412413 100644 --- a/ui/dist/index.html +++ b/ui/dist/index.html @@ -13,7 +13,7 @@ - + diff --git a/ui/src/collections/pageCollections.js b/ui/src/collections/pageCollections.js index 245ffff8..987ebae1 100644 --- a/ui/src/collections/pageCollections.js +++ b/ui/src/collections/pageCollections.js @@ -58,6 +58,8 @@ export function pageCollections(route) { watch( () => (app.store.activeCollection?.name || "") + (app.store.activeCollection?.updated || ""), (newVal, oldVal) => { + app.store.title = app.store.activeCollection?.name || "Collections"; + // skip unnecessery initial params replacement if (!oldVal) { return; @@ -69,8 +71,6 @@ export function pageCollections(route) { pageData.sort = ""; } - app.store.title = app.store.activeCollection?.name || "Collections"; - app.utils.replaceHashQueryParams({ [COLLECTION_QUERY_KEY]: app.store.activeCollection?.name, [FILTER_QUERY_KEY]: pageData.filter || null,