From 1034dc98423e5833a8bcbd9b1a923e596c7ea032 Mon Sep 17 00:00:00 2001 From: Gani Georgiev Date: Mon, 25 May 2026 07:19:34 +0300 Subject: [PATCH] registered missing oidc2/oidc3 option fields --- CHANGELOG.md | 2 +- ui/dist/assets/{index-CkzYXztf.js => index-C6Hdzfsf.js} | 4 ++-- ...lChange-DE_eWn0l.js => pageConfirmEmailChange-v6oufhPX.js} | 2 +- ...Reset-pcaeA4wC.js => pageConfirmPasswordReset-DfIjsaaC.js} | 2 +- ...cation-Ov2sOAhE.js => pageConfirmVerification-BpdljkZV.js} | 2 +- .../{pageInstaller-CDIahrVC.js => pageInstaller-DKuaYpPL.js} | 2 +- ui/dist/index.html | 2 +- ui/src/collections/oauth2/oidcOptions.js | 3 +++ 8 files changed, 11 insertions(+), 8 deletions(-) rename ui/dist/assets/{index-CkzYXztf.js => index-C6Hdzfsf.js} (99%) rename ui/dist/assets/{pageConfirmEmailChange-DE_eWn0l.js => pageConfirmEmailChange-v6oufhPX.js} (94%) rename ui/dist/assets/{pageConfirmPasswordReset-pcaeA4wC.js => pageConfirmPasswordReset-DfIjsaaC.js} (96%) rename ui/dist/assets/{pageConfirmVerification-Ov2sOAhE.js => pageConfirmVerification-BpdljkZV.js} (95%) rename ui/dist/assets/{pageInstaller-CDIahrVC.js => pageInstaller-DKuaYpPL.js} (97%) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9fd8edb..2a4a653b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ - Fixed logs bulk selection export error. -- Other Minor UI improvements (optimized logs and records list rendering, word breaking in labels, text contrast improvements, etc.). +- Other Minor UI improvements (optimized logs and records list rendering, word breaking in labels, text contrast improvements, registered missing `oidc2` and `oidc3` option fields, etc.). ## v0.38.2 diff --git a/ui/dist/assets/index-CkzYXztf.js b/ui/dist/assets/index-C6Hdzfsf.js similarity index 99% rename from ui/dist/assets/index-CkzYXztf.js rename to ui/dist/assets/index-C6Hdzfsf.js index c85f803b..ce96a421 100644 --- a/ui/dist/assets/index-CkzYXztf.js +++ b/ui/dist/assets/index-C6Hdzfsf.js @@ -58,7 +58,7 @@ This field is disabled if "Except domains" is set.`)})),t.input({type:`text`,id: `);e.field.values=r,app.utils.deleteByPath(app.store.errors,`fields.${e.fieldIndex}.values`)},onchange:n=>{let r=new Set,i=n.target.value.split(` `);for(let e of i)e!=``&&r.add(e);e.field.values=Array.from(r)},onblur:e=>{(!e.relatedTarget||!i.contains(e.relatedTarget))&&i.hidePopover()}}))),a=[watch(()=>{e.field.values?.length&&e.field.maxSelect>e.field.values.length&&(e.field.maxSelect=e.field.values.length)})];return app.components.fieldSettings(e,{header:[t.div({className:`field header-select field-select-choices-input`,onunmount:()=>{a.forEach(e=>e?.unwatch())}},t.input({type:`text`,placeholder:`Add choices*`,className:`txt-left inline-error`,value:()=>e.field.values?.join(` • `)||``,name:()=>`fields.${e.fieldIndex}.values`,onfocus:e=>(i?.showPopover({source:e.target}),i.querySelector(`textarea`)?.focus(),!1)}),i),t.div({className:`field header-select single-multiple-select`},app.components.select({required:!0,options:r,value:()=>e.field.maxSelect>1,onchange:n=>{n?.[0]?.value?e.field.maxSelect=e.field.values.length||2:e.field.maxSelect=1}}))],content:()=>t.div({className:`grid sm`},()=>{if(e.field.maxSelect>1)return t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:n+`.maxSelect`},`Max select`),t.input({type:`number`,id:n+`.maxSelect`,placeholder:`Default to single`,step:1,min:2,max:()=>e.field.values?.length||2,name:()=>`fields.${e.fieldIndex}.maxSelect`,value:()=>e.field.maxSelect||``,onchange:n=>{let r=parseInt(n.target.value,10);r>1?e.field.maxSelect=r:e.field.maxSelect=1}})))},t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:n+`.help`},`Help text`),t.input({type:`text`,id:n+`.help`,name:()=>`fields.${e.fieldIndex}.help`,value:()=>e.field.help||``,oninput:n=>e.field.help=n.target.value})))),footer:()=>[t.div({className:`field`},t.input({className:`sm`,type:`checkbox`,id:n+`.required`,name:()=>`fields.${e.fieldIndex}.required`,checked:()=>!!e.field.required,onchange:n=>e.field.required=n.target.checked}),t.label({htmlFor:n+`.required`},t.span({className:`txt`},`Required`),t.small({className:`txt-hint`,textContent:()=>e.field.maxSelect>1?`(!=[])`:`(!='')`}),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(()=>`Requires the field value to be nonempty ${e.field.maxSelect>1?`array`:`string`}.`)})))]})}function ir(e){return t.div({className:`record-field-view field-type-select`},t.div({className:`inline-flex gap-5`},()=>{let n=app.utils.toArray(e.record[e.field.name],!1);return n.length?n.map(e=>t.span({className:`label`,title:e,textContent:app.utils.truncate(e,100)})):t.span({className:`missing-value`})}))}window.app=window.app||{},window.app.fieldTypes=window.app.fieldTypes||{},window.app.fieldTypes.select={icon:`ri-list-check`,label:`Select`,settings:rr,input:nr,view:ir,filterModifiers:e=>e.maxSelect>1?[`each`,`length`]:[],dummyData:(e,n=!1)=>e.maxSelect>1?e.values?.slice(0,2)||[]:e.values?.[0]||``};function ar(e){let n=`json_`+app.utils.randomString(),r=store({value:``}),i=[watch(()=>e.record[e.field.name],(n,i)=>{if(!(n!==``&&n===r.value)){if(typeof n==`string`&&!n.startsWith(`"`)&&!n.endsWith(`"`)){r.value=JSON.stringify(n===void 0?null:n),e.record[e.field.name]=r.value;return}typeof n==`string`&&n.startsWith(`"`)&&n.endsWith(`"`)?r.value=n:n===null?r.value=`null`:r.value=JSON.stringify(n===void 0?null:n,null,2)}})];function a(){let n=r.value.trim();if(n===``){e.record[e.field.name]=null;return}try{let r=JSON.parse(n);typeof r==`string`?e.record[e.field.name]=JSON.stringify(r):e.record[e.field.name]=r}catch{e.record[e.field.name]=n}}return t.div({className:`record-field-input field-type-json`},t.div({className:`field`,onunmount:()=>{clearTimeout(void 0),i.forEach(e=>e?.unwatch())}},t.label({htmlFor:n},t.i({className:app.fieldTypes.json.icon,ariaHidden:!0}),t.span({className:`txt`},()=>e.field.name),t.span({hidden:()=>or(r.value.trim()),className:`json-state`,ariaDescription:app.attrs.tooltip(`Invalid JSON`,`left`)},t.i({className:`ri-error-warning-fill txt-danger`,ariaHidden:!0})),t.span({hidden:()=>!or(r.value.trim()),className:`json-state`,ariaDescription:app.attrs.tooltip(`Valid JSON`,`left`)},t.i({className:`ri-checkbox-circle-fill txt-success`,ariaHidden:!0}))),app.components.codeEditor({language:`js`,id:n,name:()=>e.field.name,required:()=>e.field.required,value:()=>r.value,oninput:e=>r.value=e,onblur:()=>a()})),()=>{if(e.field.help)return t.div({className:`field-help`},e.field.help)})}function or(e){if(e===``)return!0;try{return JSON.parse(e),!0}catch{return!1}}function sr(e){try{let n=e.record[e.field.name];typeof n==`string`&&JSON.parse(n)}catch(n){throw new y({status:400,response:{message:`Invalid JSON data`,data:{[e.field.name]:{code:`invalid_json`,message:n.toString()}}}})}}function cr(e){let n=`f_`+app.utils.randomString(),r=store({showInfo:!1});return app.components.fieldSettings(e,{content:()=>t.div({className:`grid sm`},t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:n+`.maxSize`},t.span(null,`Max size `),t.small(null,`(bytes)`)),t.input({type:`number`,id:n+`.maxSize`,name:()=>`fields.${e.fieldIndex}.maxSize`,min:0,step:1,max:2**53-1,placeholder:`Default to max ~1MB`,value:()=>e.field.maxSize||``,oninput:n=>{e.field.maxSize=parseInt(n.target.value,10)}}))),t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:n+`.help`},`Help text`),t.input({type:`text`,id:n+`.help`,name:()=>`fields.${e.fieldIndex}.help`,value:()=>e.field.help||``,oninput:n=>e.field.help=n.target.value}))),t.div({className:`col-sm-12`},t.button({type:`button`,className:()=>`btn sm secondary ${r.showInfo?``:`transparent`}`,onclick:()=>r.showInfo=!r.showInfo},t.span({className:`txt`},`String value normalizations`),t.i({className:()=>r.showInfo?`ri-arrow-up-s-line`:`ri-arrow-down-s-line`,ariaHidden:!0})),app.components.slide(()=>r.showInfo,t.div({className:`alert m-t-10 info`},t.div({className:`content`},`In order to support seamlessly both `,t.code(null,`application/json`),` and `,t.code(null,`multipart/form-data`),`requests, the following normalization rules are applied if the `,t.code(null,`json`),` field is a plain string:`,t.ul(null,t.li(null,`"true" is converted to the json `,t.code(null,`true`)),t.li(null,`"false" is converted to the json `,t.code(null,`false`)),t.li(null,`"null" is converted to the json `,t.code(null,`null`)),t.li(null,`"[1,2,3]" is converted to the json `,t.code(null,`[1,2,3]`)),t.li(null,`'{"a":1,"b":2}' is converted to the json `,t.code(null,`{"a":1,"b":2}`)),t.li(null,`numeric strings are converted to json number`),t.li(null,`double quoted strings are left as they are (aka. without normalizations)`),t.li(null,`any other string (empty string too) is double quoted`)),`Alternatively, if you want to avoid the string value normalizations, you can wrap your data inside an object, eg. `,t.code(null,`{"data": anything}`),`.`))))),footer:()=>[t.div({className:`field`},t.input({className:`sm`,type:`checkbox`,id:n+`.required`,name:()=>`fields.${e.fieldIndex}.required`,checked:()=>!!e.field.required,onchange:n=>e.field.required=n.target.checked}),t.label({htmlFor:n+`.required`},t.span({className:`txt`},`Required`),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Requires the field value NOT to be null, '', [], {}`)})))]})}function lr(e){return t.div({className:`record-field-view field-type-json`},()=>{let n=e.record[e.field.name];return e.short?t.span({className:`txt-code txt-ellipsis`,textContent:app.utils.truncate(app.utils.trimQuotedValue(JSON.stringify(n))||``)}):app.components.codeBlock({value:()=>JSON.stringify(n,null,2)})})}window.app=window.app||{},window.app.fieldTypes=window.app.fieldTypes||{},window.app.fieldTypes.json={icon:`ri-braces-line`,label:`JSON`,settings:cr,input:ar,view:lr,onrecordsave:sr,dummyData:(e,n=!1)=>({example:123})};function ur(e){let n=`geo_`+app.utils.randomString(),r=store({showMap:!1});return t.div({className:`record-field-input field-type-geoPoint`},t.div({className:()=>`field-list ${e.field.required?`required`:``}`},t.label({htmlFor:n},t.i({className:app.fieldTypes.geoPoint.icon,ariaHidden:!0}),t.span({className:`txt`},()=>e.field.name)),t.div({className:`field-list-content`},t.div({className:`field-list-item p-0`},t.div({className:`fields`},t.div({className:`field addon`},t.label({htmlFor:n+`.lon`},`Longitude:`)),t.div({className:`field`},t.input({id:n+`.lon`,type:`number`,step:`any`,min:-180,max:180,placeholder:0,name:()=>e.field.name,required:()=>e.field.required,value:()=>e.record[e.field.name]?.lon||``,onchange:n=>{e.record[e.field.name]=e.record[e.field.name]||{},e.record[e.field.name].lon=Number(n.target.value)}})),t.span({className:`delimiter`}),t.div({className:`field addon`},t.label({htmlFor:n+`.lat`},`Latitude:`)),t.div({className:`field`},t.input({id:n+`.lat`,type:`number`,step:`any`,min:-90,max:90,placeholder:0,name:()=>e.field.name,required:()=>e.field.required,value:()=>e.record[e.field.name]?.lat||``,onchange:n=>{e.record[e.field.name]=e.record[e.field.name]||{},e.record[e.field.name].lat=Number(n.target.value)}})),t.span({className:`delimiter`}),t.div({className:`field addon p-5`},t.button({type:`button`,className:()=>`btn sm circle secondary ${r.showMap?``:`transparent`}`,onclick:()=>r.showMap=!r.showMap},t.i({className:`ri-map-2-line`}))))),()=>{if(r.showMap)return t.div({className:`field-list-item p-0`,style:`height: 250px`},app.components.leaflet({point:()=>e.record[e.field.name]||{lat:0,lon:0},onchange:n=>{e.record[e.field.name]=structuredClone(n)}}))})),()=>{if(e.field.help)return t.div({className:`field-help`},e.field.help)})}function dr(e){let n=`f_`+app.utils.randomString();return app.components.fieldSettings(e,{content:()=>t.div({className:`grid sm`},t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:n+`.help`},`Help text`),t.input({type:`text`,id:n+`.help`,name:()=>`fields.${e.fieldIndex}.help`,value:()=>e.field.help||``,oninput:n=>e.field.help=n.target.value})))),footer:()=>[t.div({className:`field`},t.input({className:`sm`,type:`checkbox`,id:n+`.required`,name:()=>`fields.${e.fieldIndex}.required`,checked:()=>!!e.field.required,onchange:n=>e.field.required=n.target.checked}),t.label({htmlFor:n+`.required`},t.span({className:`txt`},`Required`),t.small({className:`txt-hint`},`(=true)`),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Requires the field value to be true.`)})))]})}function fr(e){return t.div({className:`record-field-view field-type-geoPoint`},t.span({className:`label`},()=>{let n=e.record[e.field.name];return`${n?.lon||0}, ${n?.lat||0}`}))}window.app=window.app||{},window.app.fieldTypes=window.app.fieldTypes||{},window.app.fieldTypes.geoPoint={icon:`ri-map-pin-2-line`,label:`Geo Point`,settings:dr,input:ur,view:fr,identifierExtractor:function(e,n=``){return[n+e.name+`.lon`,n+e.name+`.lat`]},dummyData:(e,n=!1)=>({lon:0,lat:0})};function pr(e){let n=`f_`+app.utils.randomString();return app.components.fieldSettings(e,{showHidden:!1,showPresentable:!1,showDuplicate:!1,content:t.div({className:`grid sm`},t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.min`},t.span({className:`txt`},`Min length`),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Clear the field or set it to 0 for no limit.`)})),t.input({type:`number`,id:n+`.min`,name:()=>`fields.${e.fieldIndex}.min`,step:1,min:0,max:71,placeholder:`No min limit`,value:()=>e.field.min||``,oninput:n=>{e.field.min=parseInt(n.target.value,10)}}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.max`},t.span({className:`txt`},`Max length`),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Clear the field or set it to 0 to fallback to the default limit (71).`)})),t.input({type:`number`,id:n+`.max`,name:()=>`fields.${e.fieldIndex}.max`,step:1,min:()=>e.field.min||0,max:71,placeholder:`Up to 71 chars`,value:()=>e.field.max||``,oninput:n=>{e.field.max=parseInt(n.target.value,10)}}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.max`},t.span({className:`txt`},`Bcrypt cost`),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Clear the field or set it to 0 to fallback to the default (10).`)})),t.input({type:`number`,id:n+`.cost`,name:()=>`fields.${e.fieldIndex}.cost`,step:1,min:4,max:31,placeholder:`Default to 10`,value:()=>e.field.cost||``,oninput:n=>{e.field.cost=parseInt(n.target.value,10)}}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.pattern`},t.span({className:`txt`},`Validation pattern`)),t.input({type:`text`,id:n+`.pattern`,placeholder:`ex. ^\\w+$`,name:()=>`fields.${e.fieldIndex}.pattern`,value:()=>e.field.pattern||``,oninput:n=>e.field.pattern=n.target.value}))),t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:n+`.help`},`Help text`),t.input({type:`text`,id:n+`.help`,name:()=>`fields.${e.fieldIndex}.help`,value:()=>e.field.help||``,oninput:n=>e.field.help=n.target.value})))),footer:()=>{if(!(e.collection?.type==`auth`&&e.field.name==`password`))return[t.div({className:`field`},t.input({className:`sm`,type:`checkbox`,id:n+`.required`,name:()=>`fields.${e.fieldIndex}.required`,checked:()=>!!e.field.required,onchange:n=>e.field.required=n.target.checked}),t.label({htmlFor:n+`.required`},t.span({className:`txt`},`Required`),t.small({className:`txt-hint`},`(!='')`),t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Requires the field value to be nonempty string`)})))]}})}window.app=window.app||{},window.app.fieldTypes=window.app.fieldTypes||{},window.app.fieldTypes.password={icon:`ri-lock-password-line`,label:`Password`,settings:pr},window.app=window.app||{},window.app.modals=window.app.modals||{},window.app.modals.openIndexUpsert=function(e,n=``,r={onsave:()=>{},ondelete:()=>{}}){let i=mr(e,n,r);i&&(document.body.appendChild(i),app.modals.open(i))};function mr(e,n=``,r={}){if(!e){console.warn(`[indexUpsertModal] missing required collection argument`);return}let i,a=app.utils.randomString(),o=store({originalIndex:``,index:``,get isNew(){return o.originalIndex==``},get indexParts(){return app.utils.parseIndex(o.index)},get lowerCasedIndexColumnNames(){return o.indexParts.columns.map(e=>e.name.toLowerCase())},get canSave(){return o.lowerCasedIndexColumnNames.length>0}}),s=e?.fields?.filter(e=>!e[`@toDelete`]&&e.name!=`id`)?.map(e=>e.name)||[];function c(n){if(o.originalIndex=n||``,!n){let r=app.utils.parseIndex(``);r.tableName=e?.name||``,n=app.utils.buildIndex(r)}o.index=n}function l(){if(!e||!o.canSave){console.warn(`[saveIndex] no collection or invalid save state:`,e,o.canSave);return}e.indexes=e.indexes||[];let n=e.indexes.findIndex(e=>e==o.originalIndex);n>=0?(e.indexes[n]=o.index,app.utils.deleteByPath(app.store.errors,`indexes.`+n)):e.indexes.push(o.index),typeof r?.onsave==`function`&&r.onsave({collection:e,index:o.index,oldIndex:o.originalIndex}),f(),app.modals.close(i)}function u(){if(!e||!o.originalIndex){console.warn(`[deleteIndex] no collection or index:`,e,o.originalIndex);return}let n=e.indexes?.findIndex(e=>e==o.originalIndex);if(n==-1){console.warn(`[deleteIndex] missing index:`,o.originalIndex);return}e.indexes.splice(n,1),app.utils.deleteByPath(app.store.errors,`indexes.`+n),typeof r?.ondelete==`function`&&r.ondelete({collection:e,position:n,index:o.originalIndex}),f(),app.modals.close(i)}function d(n){let r=JSON.parse(JSON.stringify(o.indexParts));r.tableName=e?.name||``;let i=n.toLowerCase(),a=r.columns.findIndex(e=>e.name.toLowerCase()==i);a>=0?r.columns.splice(a,1):app.utils.pushUnique(r.columns,{name:n}),o.index=app.utils.buildIndex(r),f()}function f(){if(app.store.errors?.indexes){let n=e.indexes.findIndex(e=>e==o.originalIndex);app.utils.deleteByPath(app.store.errors,`indexes.`+n)}}return i=t.div({className:`modal popup index-upsert-modal`,onbeforeopen:()=>{c(n)},onafteropen:()=>{app.store.errors?.indexes&&(app.store.errors.indexes=JSON.parse(JSON.stringify(app.store.errors.indexes)))},onafterclose:e=>{e?.remove()}},t.header({className:`modal-header`},t.h6({className:`modal-title`},t.span({className:`txt`},()=>o.isNew?`Create index`:`Update index`))),t.div({className:`modal-content`},t.form({id:a+`form`,className:`grid sm index-upsert-form`,onsubmit:e=>{e.preventDefault(),l()}},t.div({className:`col-12`},t.div({className:`field`},t.input({type:`checkbox`,className:`switch`,id:a+`checkbox_unique`,checked:()=>o.indexParts.unique,onchange:n=>{let r=JSON.parse(JSON.stringify(o.indexParts));r.unique=n.target.checked,r.tableName=r.tableName||e?.name||``,o.index=app.utils.buildIndex(r)}}),t.label({htmlFor:a+`checkbox_unique`},`Unique`))),t.div({className:`col-12`},t.div({className:`field`},app.components.codeEditor({required:!0,className:`collection-index-input pre-wrap`,name:()=>`indexes.`+e.indexes?.findIndex(e=>e==o.originalIndex),placeholder:()=>`e.g. CREATE INDEX idx_test on ${e?.name||`X`} (created)`,value:()=>o.index,oninput:e=>o.index=e})),t.div({hidden:()=>!s.length,className:`field-help m-t-sm`},t.div({className:`flex flex-wrap gap-5`},t.span({className:`txt`,textContent:`Presets:`}),()=>s?.map(e=>{let n=o.lowerCasedIndexColumnNames.includes(e.toLowerCase());return t.button({type:`button`,textContent:e,className:()=>`label handle ${n?`success`:``}`,onclick:()=>d(e)})})))))),t.footer({className:`modal-footer gap-base`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(i)},t.span({className:`txt`},`Close`)),t.button({hidden:()=>o.isNew,type:`button`,className:()=>`btn sm circle transparent secondary`,ariaLabel:app.attrs.tooltip(`Delete index`,`left`),onclick:()=>{app.modals.confirm(`Do you really want to remove the selected index from the collection?`,u)}},t.i({className:`ri-delete-bin-7-line`,ariaHidden:!0})),t.button({type:`submit`,"html-form":a+`form`,disabled:()=>!o.canSave,className:()=>`btn expanded`},t.span({className:`txt`},`Set index`)))),i}function hr(e,n,r={}){let i=`emailTemplate`+app.utils.randomString(),a=store({title:`Email template`,placeholders:[]}),o=app.utils.extendStore(a,r),s=store({get config(){let r=app.utils.getByPath(e,n);return r||(r={subject:``,body:``},app.utils.setByPath(e,n,r)),r},get tokensList(){return[]}}),c=()=>{if(a.placeholders?.length)return t.div({className:`field-help`},t.div({className:`flex flex-wrap gap-5`},t.span({className:`txt`},`Placeholders:`),()=>a.placeholders.map(e=>t.span({className:`label sm`},app.components.copyButton(e,e)))))};return t.details({pbEvent:`emailTemplateAccordion`,className:`accordion email-template-accordion`,name:`email-template`,onunmount:()=>{o.forEach(e=>e?.unwatch())}},t.summary(null,t.i({className:`ri-draft-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:()=>a.title}),()=>{if(app.utils.getByPath(app.store.errors,n))return t.i({ariaHidden:!0,className:`ri-error-warning-fill txt-danger m-l-auto`,ariaDescription:app.attrs.tooltip(`Has errors`,`left`)})}),t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.subject`,textContent:`Subject`}),app.components.codeEditor({id:i+`.subject`,name:n+`.subject`,required:!0,singleLine:!0,language:`text`,autocomplete:a.placeholders,value:()=>s.config.subject||``,oninput:e=>s.config.subject=e})),c),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:i+`.body`,textContent:`Body (HTML)`}),app.components.codeEditor({id:i+`.body`,name:n+`.body`,required:!0,language:`html`,className:`pre-wrap`,autocomplete:a.placeholders,value:()=>s.config.body||``,oninput:e=>s.config.body=e})),c)))}function gr(e){let n=`mfa_`+app.utils.randomString(),r=store({get config(){return e.mfa||={enabled:!1,duration:600,rule:``},e.mfa},get isSuperusers(){return e.system&&e.name==`_superusers`}});return t.details({pbEvent:`mfaAccordion`,name:`auth-methods`,className:`accordion mfa-accordion`},t.summary(null,t.i({className:`ri-shield-check-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`Multi-factor authentication (MFA)`}),t.span({className:()=>`label m-l-auto ${r.config.enabled?`success`:``}`,textContent:()=>r.config.enabled?`Enabled`:`Disabled`}),()=>{if(app.store.errors?.mfa)return t.i({className:`ri-error-warning-fill txt-danger`,ariaDescription:app.attrs.tooltip(`Has errors`,`left`)})}),t.div({className:`grid sm`},t.div({className:`col-sm-12`},t.div({className:`alert info`},t.div({className:`content`},t.p(null,`Multi-factor authentication (MFA) requires the user to authenticate with any 2 different auth methods (otp, identity/password, oauth2) before issuing an auth token. `,t.a({href:`https://pocketbase.io/docs/authentication#multi-factor-authentication`,className:`link-hint`,target:`_blank`,rel:`noopener noreferrer`,textContent:`Learn more.`}))))),t.div({className:`col-sm-12`},t.div({className:`field`},t.input({type:`checkbox`,id:n+`.enabled`,name:`mfa.enabled`,className:`switch`,checked:()=>r.config.enabled,onchange:n=>{r.config.enabled=n.target.checked,r.isSuperusers&&(e.otp.enabled=n.target.checked)}}),t.label({htmlFor:n+`.enabled`,textContent:`Enable`}))),t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:n+`.duration`,textContent:`Max duration between 2 authentications (in seconds)`}),t.input({type:`number`,id:n+`.duration`,name:`mfa.duration`,min:1,step:1,required:!0,value:()=>r.config.duration||``,oninput:e=>r.config.duration=parseInt(e.target.value,10)}))),t.div({className:`col-sm-12`},app.components.ruleField({label:`MFA rule`,id:n+`.rule`,name:`mfa.rule`,nullable:!1,placeholder:`Leave empty to require MFA for everyone`,autocomplete:n=>app.utils.collectionAutocompleteKeys(e,n),value:()=>r.config.rule||``,oninput:e=>r.config.rule=e}),t.div({className:`field-help`},t.p(null,`This optional rule could be used to enable/disable MFA per account basis.`),t.p(null,`For example, to require MFA only for accounts with non-empty email you can set it to `,t.code(null,`email != ''`),`.`),t.p(null,`Leave the rule empty to require MFA for everyone.`)))))}var _r=[`id`,`email`,`emailVisibility`,`verified`,`tokenKey`,`password`],vr=[`text`,`editor`,`url`,`email`,`json`];function yr(e){let n=`oauth2_`+app.utils.randomString(),r=store({get config(){return e.oauth2||={enabled:!1,mappedFields:{},providers:[]},e.oauth2},get regularFieldOptions(){return e.fields?.filter(e=>vr.includes(e.type)&&!_r.includes(e.name)).map(e=>({value:e.name}))},get regularAndFileFieldOptions(){return e.fields?.filter(e=>(e.type==`file`||vr.includes(e.type))&&!_r.includes(e.name)).map(e=>({value:e.name}))},showMapping:!1});function i(e){app.utils.deleteByPath(app.store.errors,`oauth2.providers.`+e)}return t.details({pbEvent:`oauth2Accordion`,name:`auth-methods`,className:`accordion oauth2-accordion`},t.summary(null,t.i({className:`ri-profile-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`OAuth2`}),t.span({className:()=>`label m-l-auto ${r.config.enabled?`success`:``}`,textContent:()=>r.config.enabled?`Enabled`:`Disabled`}),()=>{if(!app.utils.isEmpty(app.store.errors?.oauth2))return t.i({className:`ri-error-warning-fill txt-danger`,ariaDescription:app.attrs.tooltip(`Has errors`,`left`)})}),t.div({className:`grid sm`},t.div({className:`col-sm-12`},t.div({className:`field`},t.input({type:`checkbox`,id:n+`.enabled`,name:`oauth2.enabled`,className:`switch`,checked:()=>r.config.enabled,onchange:e=>r.config.enabled=e.target.checked}),t.label({htmlFor:n+`.enabled`,textContent:`Enable`}))),()=>r.config.providers.map((e,a)=>{let o=n+e.name,s=app.store.oauth2Providers?.find(n=>n.name==e.name)||{};return t.div({className:`col-sm-6`},t.div({className:()=>{let e=`provider-card`;return app.utils.isEmpty(app.store.errors?.oauth2?.providers?.[a])||(e+=` error`),e}},t.figure({className:`provider-logo`},()=>s.logo?t.img({src:`data:image/svg+xml;base64,`+btoa(s.logo),alt:e.name+` logo`}):t.i({className:app.utils.fallbackProviderIcon,ariaHidden:!0})),t.div({className:`content`},t.span({className:`primary-txt`},()=>e.displayName||s.displayName||s.name),t.span({className:`secondary-txt`},()=>e.name||s.name)),t.div({className:`actions`},t.button({type:`button`,title:`Options`,className:`btn secondary transparent sm circle`,"html-popovertarget":o+`dropdown`},t.i({className:`ri-more-2-line`,ariaHidden:!0})),t.div({id:o+`dropdown`,className:`dropdown sm`,popover:`auto`},t.button({type:`button`,className:`dropdown-item`,onclick:n=>{n.target.closest(`.dropdown`).hidePopover(),app.modals.openProviderSettings(e,{namePrefix:`oauth2.providers.`+a,onsubmit:(e,n)=>{r.config.providers[a]=n,i(a)}})}},t.span({className:`txt`},`Settings`)),t.hr(),t.button({type:`button`,className:`dropdown-item`,onclick:n=>{n.target.closest(`.dropdown`).hidePopover(),app.modals.confirm(`Do you really want to remove provider "${e.displayName||s.displayName||s.name}"?`,()=>{i(a),r.config.providers.splice(a,1),r.config.providers.length==0&&(r.config.enabled=!1)})}},t.span({className:`txt`},`Remove`))))))}),t.div({className:`col-sm-6`},t.button({type:`button`,className:`btn lg block secondary add-provider-btn`,onclick:()=>{app.modals.openProviderPicker({exclude:r.config.providers.map(e=>e.name),onselect:e=>{app.modals.openProviderSettings({name:e.name},{onsubmit:(e,n)=>{r.config.providers.length==0&&(r.config.enabled=!0),r.config.providers.push(n)}})}})}},t.i({className:`ri-add-line`,ariaHidden:!0}),t.span({className:`txt `},`Add provider`))),t.div({className:`col-sm-12`},t.button({type:`button`,className:()=>`btn secondary sm ${r.showMapping?``:`transparent`}`,onclick:()=>r.showMapping=!r.showMapping},t.span({className:`txt`},`Optional users create fields mapping`),t.i({className:()=>r.showMapping?`ri-arrow-drop-up-line`:`ri-arrow-drop-down-line`,ariaHidden:!0})),app.components.slide(()=>r.showMapping,t.div({className:`grid sm m-t-sm`},t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.mappedFields.name`},`OAuth2 full name`),app.components.select({id:n+`.mappedFields.name`,name:`oauth2.mappedFields.name`,placeholder:`Select field`,options:()=>r.regularFieldOptions,value:()=>e.oauth2.mappedFields.name,onchange:n=>{e.oauth2.mappedFields.name=n?.[0]?.value||``}}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.mappedFields.avatarURL`},`OAuth2 avatar`),app.components.select({id:n+`.mappedFields.avatarURL`,name:`oauth2.mappedFields.avatarURL`,placeholder:`Select field`,options:()=>r.regularAndFileFieldOptions,value:()=>e.oauth2.mappedFields.avatarURL,onchange:n=>{e.oauth2.mappedFields.avatarURL=n?.[0]?.value||``}}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.mappedFields.id`},`OAuth2 id`),app.components.select({id:n+`.mappedFields.id`,name:`oauth2.mappedFields.id`,placeholder:`Select field`,options:()=>r.regularFieldOptions,value:()=>e.oauth2.mappedFields.id,onchange:n=>{e.oauth2.mappedFields.id=n?.[0]?.value||``}}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.mappedFields.username`},`OAuth2 username`),app.components.select({id:n+`.mappedFields.username`,name:`oauth2.mappedFields.username`,placeholder:`Select field`,options:()=>r.regularFieldOptions,value:()=>e.oauth2.mappedFields.username,onchange:n=>{e.oauth2.mappedFields.username=n?.[0]?.value||``}}))))))))}function br(e){let n=`otp_`+app.utils.randomString(),r=store({get config(){return e.otp||={enabled:!1,duration:300,length:8},e.otp},get isSuperusers(){return e.system&&e.name==`_superusers`}});return t.details({pbEvent:`otpAccordion`,name:`auth-methods`,className:`accordion otp-accordion`},t.summary(null,t.i({className:`ri-time-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`One-time password (OTP)`}),t.span({className:()=>`label m-l-auto ${r.config.enabled?`success`:``}`,textContent:()=>r.config.enabled?`Enabled`:`Disabled`}),()=>{if(app.store.errors?.otp)return t.i({className:`ri-error-warning-fill txt-danger`,ariaDescription:app.attrs.tooltip(`Has errors`,`left`)})}),t.div({className:`grid sm`},t.div({className:`col-sm-12`},t.div({className:`field`},t.input({type:`checkbox`,id:n+`.enabled`,name:`otp.enabled`,className:`switch`,checked:()=>r.config.enabled,onchange:n=>{r.config.enabled=n.target.checked,r.isSuperusers&&(e.mfa.enabled=n.target.checked)}}),t.label({htmlFor:n+`.enabled`,textContent:`Enable`}),()=>{if(r.isSuperusers)return t.i({className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`Superusers can have OTP only as part of Two-factor authentication.`)})})),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.duration`,textContent:`Duration (in seconds)`}),t.input({type:`number`,id:n+`.duration`,name:`otp.duration`,min:1,step:1,required:!0,value:()=>r.config.duration||``,oninput:e=>r.config.duration=parseInt(e.target.value,10)}))),t.div({className:`col-sm-6`},t.div({className:`field`},t.label({htmlFor:n+`.length`,textContent:`Generated password length`}),t.input({type:`number`,id:n+`.length`,name:`otp.length`,min:1,step:1,required:!0,value:()=>r.config.length||``,oninput:e=>r.config.length=parseInt(e.target.value,10)})))))}function xr(e){let n=`passwordAuth_`+app.utils.randomString(),r=store({get config(){return e.passwordAuth||={enabled:!0,identityFields:[`email`]},e.passwordAuth},get identityFieldOptions(){let n=[{value:`email`}],r=e?.fields||[],i=e?.indexes||[];for(let e of i){let i=app.utils.parseIndex(e);if(!i.unique||i.columns.length!=1||i.columns[0].name==`email`)continue;let a=r.find(e=>!e.hidden&&e.name.toLowerCase()==i.columns[0].name.toLowerCase());a&&n.push({value:a.name})}return n}});return t.details({pbEvent:`passwordAuthAccordion`,name:`auth-methods`,className:`accordion password-auth-accordion`},t.summary(null,t.i({className:`ri-lock-password-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`Identity/Password`}),t.span({className:()=>`label m-l-auto ${r.config.enabled?`success`:``}`,textContent:()=>r.config.enabled?`Enabled`:`Disabled`}),()=>{if(app.store.errors?.passwordAuth)return t.i({className:`ri-error-warning-fill txt-danger`,ariaDescription:app.attrs.tooltip(`Has errors`,`left`)})}),t.div({className:`grid sm`},t.div({className:`col-sm-12`},t.div({className:`field`},t.input({type:`checkbox`,id:n+`.enabled`,name:`passwordAuth.enabled`,className:`switch`,checked:()=>r.config.enabled,onchange:e=>r.config.enabled=e.target.checked}),t.label({htmlFor:n+`.enabled`,textContent:`Enable`}))),t.div({className:`col-sm-12`},t.div({className:`field`},t.label({htmlFor:n+`.identityFields`,textContent:`Identity fields`}),app.components.select({id:n+`.identityFields`,name:`passwordAuth.identityFields`,max:99,required:!0,options:()=>r.identityFieldOptions,value:()=>r.config.identityFields,onchange:e=>{r.config.identityFields=e.map(e=>e.value)}})),t.div({className:`field-help`},`Only non-hidden fields with UNIQUE index constraint can be selected.`))))}function Sr(e){let n=`token_`+app.utils.randomString(),r=store({get tokensList(){return e?.name===`_superusers`?[{key:`authToken`,label:`Auth`},{key:`passwordResetToken`,label:`Password reset`},{key:`fileToken`,label:`Protected file`}]:[{key:`authToken`,label:`Auth`},{key:`verificationToken`,label:`Email verification`},{key:`passwordResetToken`,label:`Password reset`},{key:`emailChangeToken`,label:`Email change`},{key:`fileToken`,label:`Protected file`}]}});return t.details({pbEvent:`tokenOptionsAccordion`,name:`other`,className:`accordion token-options-accordion`},t.summary(null,t.i({className:`ri-key-2-line`,ariaHidden:!0}),t.span({className:`txt`,textContent:`Token options (invalidate, duration)`})),t.div({className:`grid sm`},()=>r.tokensList.map(r=>{let i=n+r.key;return t.div({className:`col-sm-6`},t.div({className:`field token-field`},t.label({htmlFor:i,textContent:()=>r.label+` duration (in seconds)`}),t.input({id:i,type:`number`,min:1,step:1,required:!0,name:()=>r.key+`.duration`,value:()=>e[r.key].duration,oninput:n=>e[r.key].duration=parseInt(n.target.value,10)})),t.div({className:`field-help m-b-10`},t.button({type:`button`,className:()=>`link-hint ${e[r.key].secret?`txt-success`:``}`,textContent:`Invalidate all previously issued tokens`,onclick:()=>{e[r.key].secret?delete e[r.key].secret:e[r.key].secret=app.utils.randomSecret(50)}})))})))}function Cr(e){let n=`options_`+app.utils.randomString();return t.div({className:`collection-tab-content collection-options-tab-content`},t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`section-heading`},t.strong(null,`Auth methods`),t.div({className:`flex-fill`}),t.div({className:`field`},t.input({id:n+`.authAlert`,name:`authAlert.enabled`,type:`checkbox`,className:`switch sm`,checked:()=>!!e.collection.authAlert?.enabled,onchange:n=>{e.collection.authAlert=e.collection.authAlert||{},e.collection.authAlert.enabled=n.target.checked}}),t.label({htmlFor:n+`.authAlert`},`Send email alert for new logins`))),xr(e.collection),()=>{if(e.originalCollection?.name!=`_superusers`)return yr(e.collection)},br(e.collection),gr(e.collection)),t.div({className:`col-12`},t.div({className:`section-heading`},t.strong(null,`Mail templates`),t.button({tabIndex:-1,type:`buttton`,className:`m-l-auto label handle txt-bold`,textContent:`Send test email`,onclick:()=>app.modals.openMailTest(e.collection?.name)})),hr(e.collection,`verificationTemplate`,{title:`Default Verification email template`,placeholders:[`{APP_NAME}`,`{APP_URL}`,`{RECORD:*}`,`{TOKEN}`]}),hr(e.collection,`resetPasswordTemplate`,{title:`Default Password reset email template`,placeholders:[`{APP_NAME}`,`{APP_URL}`,`{RECORD:*}`,`{TOKEN}`]}),hr(e.collection,`confirmEmailChangeTemplate`,{title:`Default Confirm email change email template`,placeholders:[`{APP_NAME}`,`{APP_URL}`,`{RECORD:*}`,`{TOKEN}`]}),hr(e.collection,`otp.emailTemplate`,{title:`Default OTP email template`,placeholders:[`{APP_NAME}`,`{APP_URL}`,`{RECORD:*}`,`{OTP}`,`{OTP_ID}`]}),hr(e.collection,`authAlert.emailTemplate`,{title:`Default Login alert email template`,placeholders:[`{APP_NAME}`,`{APP_URL}`,`{RECORD:*}`,`{ALERT_INFO}`]})),t.div({className:`col-12`},t.div({className:`section-heading`},t.strong(null,`Other`)),Sr(e.collection))))}function wr(e){return t.div({className:`collection-tab-content collection-fields-tab-content`},t.div({className:`collection-fields-list`},app.components.sortable({handle:`.sort-handle`,data:()=>(e.collection?.fields||[])?.filter(e=>!!app.fieldTypes[e.type]?.settings),dataItem:(n,r)=>app.fieldTypes[n.type].settings({field:n,get originalCollection(){return e.originalCollection},get collection(){return e.collection},get originalField(){return e.originalCollection?.fields?.find(e=>n.id&&e.id==n.id)},get fieldIndex(){return e.collection.fields?.findIndex(e=>n.id?e.id==n.id:e==n)}}),onchange:(n,r,i)=>{e.collection.fields=n}})),()=>app.components.addCollectionFieldButton(e.collection),t.hr(),t.p({className:`txt-bold`},`Unique constraints and indexes (`,()=>e.collection.indexes?.length,`)`),app.components.sortable({className:`indexes-list`,data:()=>e.collection.indexes||[],onchange:function(n){e.collection.indexes=n},dataItem:(n,r)=>{let i=app.utils.parseIndex(n);return t.button({type:`button`,className:()=>`label handle ${app.store.errors?.indexes?.[r]?.message?`danger error`:`success`}`,ariaDescription:app.attrs.tooltip(()=>app.store.errors?.indexes?.[r]?.message||``),onclick:()=>app.modals.openIndexUpsert(e.collection,n)},()=>{if(i.unique)return t.strong(null,`Unique:`)},t.span({className:`txt`},()=>i.columns?.map(e=>e.name).join(`, `)))},after:()=>t.button({type:`button`,className:`label handle`,onclick:()=>app.modals.openIndexUpsert(e.collection)},t.i({className:`ri-add-line`,ariaHidden:!0}),t.span({className:`txt`},`New index`))}))}function Tr(e){let n=store({showRulesInfo:!1,showAuthRules:!1}),r=()=>app.attrs.tooltip(e.originalCollection?.system?`System collection rule cannot be changed.`:null,`top-left`);function i(n){return app.utils.collectionAutocompleteKeys(e.collection,n)}return t.div({className:`collection-tab-content collection-rules-tab-content`},t.div({className:`grid`},t.div({className:`col-12`},t.div({className:`flex txt-hint txt-sm`},t.span({className:`txt`},`All rules follow the `,t.a({target:`_blank`,rel:`noopener noreferrer`,href:`https://pocketbase.io/docs/api-rules-and-filters`,textContent:`PocketBase filter syntax and operators`}),`.`),t.strong({tabIndex:-1,className:`m-l-auto link-hint`,textContent:()=>n.showRulesInfo?`Hide available fields`:`Show available fields`,onclick:()=>n.showRulesInfo=!n.showRulesInfo})),app.components.slide(()=>n.showRulesInfo,t.div({className:`alert warning m-t-sm`},t.div({className:`content`},t.p(null,`The following record fields are available:`),t.div({className:`flex flex-wrap gap-5`},()=>app.utils.getAllCollectionIdentifiers(e.collection).map(e=>t.code(null,e))),t.hr({className:`m-t-10 m-b-10`}),t.p(null,`The request fields could be accessed with the special `,t.strong(null,`@request`),` fields:`),t.div({className:`flex flex-wrap gap-5`},t.code(null,`@request.headers.*`),t.code(null,`@request.query.*`),t.code(null,`@request.body.*`),t.code(null,`@request.auth.*`)),t.hr({className:`m-t-10 m-b-10`}),t.p(null,`You could also add constraints and query other collections using the `,t.strong(null,`@collection`),` field:`),t.div({className:`flex flex-wrap gap-5`},t.code(null,`@collection.ANY_COLLECTION_NAME.*`)),t.hr({className:`m-t-10 m-b-10`}),t.p(null,`Example rule:`),()=>{let n=e.collection.fields?.find(e=>e.type==`date`||e.type==`autodate`);return n?t.code(null,`@request.auth.id != "" && ${n.name} > "2022-01-01 00:00:00.000Z"`):t.code(null,`@request.auth.id != ""`)})))),t.div({className:`col-12`,ariaDescription:r()},app.components.ruleField({label:`List/Search rule`,name:`listRule`,autocomplete:i,disabled:()=>e.originalCollection?.system,value:()=>e.collection.listRule,oninput:n=>e.collection.listRule=n})),t.div({className:`col-12`,ariaDescription:r()},app.components.ruleField({label:`View rule`,name:`viewRule`,autocomplete:i,disabled:()=>e.originalCollection?.system,value:()=>e.collection.viewRule,oninput:n=>e.collection.viewRule=n})),()=>{if(e.collection.type!=`view`)return[t.div({className:`col-12`,ariaDescription:r()},app.components.ruleField({label:[t.span({className:`txt`,textContent:`Create rule`}),t.i({hidden:()=>e.collection.createRule==null,className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`The main record fields hold the values that are going to be inserted in the database.`)})],name:`createRule`,autocomplete:i,disabled:()=>e.originalCollection?.system,value:()=>e.collection.createRule,oninput:n=>e.collection.createRule=n})),t.div({className:`col-12`,ariaDescription:r()},app.components.ruleField({label:[t.span({className:`txt`,textContent:`Update rule`}),t.i({hidden:()=>e.collection.updateRule==null,className:`ri-information-line link-hint`,ariaDescription:app.attrs.tooltip(`The main record fields hold the old/existing record field values. 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 Er=`test_view_query`;function Dr(e){let n=`query_`+app.utils.randomString(),r=`SELECT.FROM.WHERE.LEFT JOIN.INNER JOIN.ON.AS.GROUP BY.HAVING.ORDER BY.ASC.DESC.LIMIT.OFFSET.WITH.NOT.IN.AND.OR.EXISTS.LIKE.CAST.REAL.DECIMAL.NUMERIC.INT.TEXT.BOOL`.split(`.`),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.collections.dryRunViewQuery(n,{requestKey:Er});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(Er),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`},t.span({hidden:()=>!i.isTesting,className:`loader sm`}),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=Or(e||{},n||{});document.body.appendChild(r),app.modals.open(r)},window.app.collectionTypes={base:{icon:`ri-folder-2-line`,tabs:{Fields:wr,"API rules":Tr}},view:{icon:`ri-table-line`,tabs:{Query:Dr,"API rules":Tr}},auth:{icon:`ri-group-line`,tabs:{Fields:wr,"API rules":Tr,Options:Cr}}};function Or(e,n){let r,i=`collection_upsert_`+app.utils.randomString(),a=store({isSaving:!1,originalCollection:{},collection:{},selectedTab:``,errorTabs:{},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);app.store.collectionScaffolds=await app.pb.collections.getScaffolds({requestKey:`save.reloadScaffolds`}),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)),app.store.errors=null}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,kr(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))}),watch(()=>JSON.stringify(app.store.errors),async e=>{if(!e){a.errorTabs={};return}await new Promise(e=>setTimeout(e,0)),a.errorTabs={};let n=r?.querySelectorAll(`.modal-content [data-tab] .error`);for(let e of n){let n=e.closest(`[data-tab]`)?.dataset?.tab;n&&(a.errorTabs[n]=!0)}})]},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 Ar(a,n)},()=>{if(!a.collection.system)return jr(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`,"html-data-tab":r,disabled:()=>a.isSaving,className:()=>`tab-item ${a.activeTab==r?`active`:``}`,onclick:()=>f(r)},t.span({className:`txt`},r),()=>{if(a.errorTabs[r])return t.i({className:`ri-error-warning-fill txt-danger txt-base`,ariaDescription:app.attrs.tooltip(`Has errors`)})}));return e})))),t.div({className:`modal-content`},()=>{let e=[],n=app.collectionTypes[a.collection.type]?.tabs||{};for(let r in n)e.push(t.div({"html-data-tab":r,hidden:()=>a.activeTab!=r,className:`tab-content-wrapper block`},()=>app.collectionTypes[a.collection.type]?.tabs?.[r]?.(a)));return e}),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,null,2);if(!(e==``||e==`null`||e==`{}`||e==`[]`))return t.i({className:`ri-error-warning-line txt-danger`,ariaDescription:app.attrs.tooltip(()=>`Raw errors: -`+e,`top`,`code`)})},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 kr(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),e.indexes=e.indexes?.map(n=>app.utils.replaceIndexFields(n,{tableName:e.name||``}))}function Ar(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 jr(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 Mr={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({},Mr,r);let i=Pr(n,app.store.collections,e).sort(Nr);if(r.requestKeys){let r=Fr(n,app.store.collections,e).sort(Nr);for(let e of r)i.push(e)}if(r.collectionJoinKeys){let e=Ir(n,app.store.collections).sort(Nr);for(let n of e)i.push(n)}return i.length>r.maxKeys?i.slice(0,r.maxKeys):i};function Nr(e,n){return e.length-n.length}function Pr(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=Pr(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=Pr(e,n,o,c+`.`,a+2);for(let e of u)s.push(e)}}return s}function Fr(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=Pr(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=Pr(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=Rr(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};function Rr(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`,yesButton:`Yes, save changes`})},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=zr(e);n&&(document.body.appendChild(n),app.modals.open(n))};function zr(e={}){let n=`overview_modal_`+app.utils.randomString(),r={"Fields and relations":Br,Rules:Vr},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 Br(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 Vr(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=Hr(e);n&&(document.body.appendChild(n),app.modals.open(n))};function Hr(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----- +`+e,`top`,`code`)})},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 kr(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),e.indexes=e.indexes?.map(n=>app.utils.replaceIndexFields(n,{tableName:e.name||``}))}function Ar(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 jr(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 Mr={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({},Mr,r);let i=Pr(n,app.store.collections,e).sort(Nr);if(r.requestKeys){let r=Fr(n,app.store.collections,e).sort(Nr);for(let e of r)i.push(e)}if(r.collectionJoinKeys){let e=Ir(n,app.store.collections).sort(Nr);for(let n of e)i.push(n)}return i.length>r.maxKeys?i.slice(0,r.maxKeys):i};function Nr(e,n){return e.length-n.length}function Pr(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=Pr(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=Pr(e,n,o,c+`.`,a+2);for(let e of u)s.push(e)}}return s}function Fr(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=Pr(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=Pr(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=Rr(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};function Rr(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`,yesButton:`Yes, save changes`})},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=zr(e);n&&(document.body.appendChild(n),app.modals.open(n))};function zr(e={}){let n=`overview_modal_`+app.utils.randomString(),r={"Fields and relations":Br,Rules:Vr},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 Br(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 Vr(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.oauth2.oidc2=window.app.oauth2.oidc,window.app.oauth2.oidc3=window.app.oauth2.oidc,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=Hr(e);n&&(document.body.appendChild(n),app.modals.open(n))};function Hr(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 Ur(){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=Wr(e);n&&(document.body.appendChild(n),app.modals.open(n))};function Wr(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.`),Ur())),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 Gr(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=Yr(e,n);r&&(document.body.appendChild(r),app.modals.open(r))};var Kr=[`execTime`,`type`,`auth`,`authId`,`status`,`method`,`url`,`referer`,`remoteIP`,`userIP`,`userAgent`,`error`,`details`];function qr(e){app.utils.downloadJSON(e,`log_`+e.created.replaceAll(/[-:\. ]/gi,``)+`.json`)}function Jr(e){app.utils.copyToClipboard(JSON.stringify(e,null,2)),app.toasts.success(`Log copied to clipboard!`)}function Yr(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 Kr)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:()=>{Jr(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,()=>Gr(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.displayValue(r,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:()=>qr(i.log)},t.i({className:`ri-download-line`,ariaHidden:!0}),t.span({className:`txt`},`Download JSON`)))),r}function Xr(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 Qr(n);if(n.authMethods.otp?.enabled)return n.otpId?ni(n):ei(n)})}async function Zr(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 $r(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 Qr(e){return t.form({pbEvent:`authWithPasswordForm`,className:`grid auth-with-password-form`,onsubmit:n=>{n.preventDefault(),Zr(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 $r(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 ei(e){return t.form({pbEvent:`requestOTPForm`,className:`grid request-otp-form`,onsubmit:n=>{n.preventDefault(),$r(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 ti(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 ni(e){return t.form({pbEvent:`authWithOTPForm`,className:`grid auht-with-otp-form`,onsubmit:n=>{n.preventDefault(),ti(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 ri=`pbPinnedCollections`,ii=12;function ai(){let e=store({search:``,pinned:app.utils.getLocalHistory(ri,[]),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(ri,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>=ii?`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=>oi(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=>oi(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=>oi(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 oi(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 si=`sort`,ci=`filter`,li=`collection`,ui=`record`,di=`pbLastActiveCollection`;function fi(e){let n=`page_collections_`+app.utils.randomString();app.store.activeCollection=e.query[li]?.[0]||window.localStorage.getItem(di);let r=store({reset:null,suggestReset:!1,activeRecordIdOrModel:e.query[ui]?.[0]||``,sort:e.query[si]?.[0]||``,filter:e.query[ci]?.[0]||``,totalCount:0,isTotalCountLoading:!1});async function i(){if(app.store.activeCollection?.id){r.isTotalCountLoading=!0;try{let e=app.utils.normalizeSearchFilter(r.filter,app.store.activeCollection.fields.filter(e=>!e.hidden).map(e=>e.name));r.totalCount=(await app.pb.collection(app.store.activeCollection.name).getList(1,1,{requestKey:n,filter:e,fields:`id`})).totalItems}catch(e){e.isAbort||(r.totalCount=0,console.warn(`failed to load total count:`,e))}r.isTotalCountLoading=!1}}function a(){r.reset=Date.now()}let o=[watch(()=>(app.store.activeCollection?.name||``)+(app.store.activeCollection?.updated||``),(e,n)=>{app.store.title=app.store.activeCollection?.name||`Collections`;let i=n&&n!=e;i&&(r.filter=``,r.sort=``),app.utils.replaceHashQueryParams({[li]:app.store.activeCollection?.name,[ci]:r.filter||null,[si]:r.sort||null},i?!0:null),app.store.activeCollection?.id?window.localStorage.setItem(di,app.store.activeCollection.id):window.localStorage.removeItem(di)}),watch(()=>[r.filter,r.sort],(e,n)=>{n&&app.utils.replaceHashQueryParams({[ci]:r.filter||null,[si]:r.sort||null})}),watch(()=>(r.activeRecordIdOrModel||``)+(app.store.activeCollection?.id||``),(e,n)=>{if(!r.activeRecordIdOrModel){app.utils.replaceHashQueryParams({[ui]:null});return}if(e==n||!app.store.activeCollection?.id)return;let i=typeof r.activeRecordIdOrModel==`string`?{id:r.activeRecordIdOrModel,collectionId:app.store.activeCollection?.id,collectionName:app.store.activeCollection?.name}:r.activeRecordIdOrModel;app.utils.replaceHashQueryParams({[ui]:i.id||null}),app.modals.close(null,!0),app.store.activeCollection?.type==`view`?app.modals.openRecordPreview(i,{onafterclose:()=>{r.activeRecordIdOrModel=``}}):app.modals.openRecordUpsert(app.store.activeCollection,i,{onafterclose:()=>{r.activeRecordIdOrModel=``}})}),watch(()=>[app.store.activeCollection?.id,r.filter,r.reset],()=>i())],s={"record:create":e=>{e.detail.collectionId==app.store.activeCollection?.id&&r.totalCount++},"record:delete":e=>{e.detail.collectionId!=app.store.activeCollection?.id&&e.detail.collectionName!=app.store.activeCollection?.name||r.totalCount--}};return t.div({pbEvent:`pageCollections`,className:`page`,onmount:()=>{app.store.isLoadingCollections||app.store.silentlyReloadCollections();for(let e in s)document.addEventListener(e,s[e])},onunmount:()=>{app.pb.cancelRequest(n),o.forEach(e=>e?.unwatch());for(let e in s)document.removeEventListener(e,s[e])}},()=>ai(),t.div({className:`page-content full-height`},t.header({className:`page-header 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:()=>a(),onsave:(e,n)=>{n?app.store.activeCollection=e.id:a()}})}},t.i({className:`ri-settings-3-line`,ariaHidden:!0})),app.components.refreshButton({onclick:()=>a(),className:()=>`btn transparent circle rotate-btn ${r.suggestReset?`warning`:`secondary`}`,tooltip:()=>`Refresh${r.suggestReset?` (list changed)`:``}`})),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:()=>r.filter,onsubmit:e=>r.filter=e}),()=>{if(app.store.activeCollection?.id)return app.components.recordsList({className:`m-t-sm`,reset:()=>r.reset,collection:()=>app.store.activeCollection,filter:()=>r.filter,sort:()=>r.sort,onselect:e=>{r.activeRecordIdOrModel=e},onchange:(e,n)=>{r.filter=e,r.sort=n},suggestReset:()=>r.suggestReset,onSuggestResetChange:e=>{r.suggestReset=!!e}})},t.footer({className:`page-footer`},t.span({className:()=>`total-count ${r.isTotalCountLoading?`faded`:``}`},`Total: `,()=>r.totalCount),app.components.credits())))}function pi(){return document.body.clientWidth>600&&document.body.clientHeight>=720?150:100}function mi(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,gi(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:pi()})},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 hi(e){let n=e?.data?.[0];n&&e.setScale(`x`,{min:n[0],max:n[n.length-1]})}function gi(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:pi(),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}`,` @@ -81,4 +81,4 @@ Records update will also require an extra unlock step before save.`)})))),t.div( @weekly @daily @midnight -@hourly`)},`macros`),`.`,t.br(),`By default the timezone is in UTC.`)),t.div({className:`col-lg-6`},t.div({className:`field`},t.label({htmlFor:`backups.cronMaxKeep`},`Max @auto backups to keep`),t.input({id:`backups.cronMaxKeep`,name:`backups.cronMaxKeep`,type:`number`,required:()=>a.enableAutoBackups,min:1,value:()=>a.formSettings.backups.cronMaxKeep,oninput:e=>{a.formSettings.backups.cronMaxKeep=parseInt(e.target.value,10)}})))))),t.div({className:`col-lg-12`},app.components.s3ConfigFields({toggleLabel:`Store backups in S3 storage`,testFilesystem:`backups`,config:()=>a.formSettings.backups.s3})),t.div({className:`col-lg-12`},t.hr()),t.div({className:`col-lg-12`},t.div({className:`flex`},t.div({className:`m-r-auto`}),t.button({hidden:()=>!a.hasChanges,type:`button`,className:`btn transparent secondary`,onclick:l},t.span({className:`txt`},`Cancel`)),t.button({className:()=>`btn expanded-lg ${a.isSaving?`loading`:``}`,disabled:()=>!a.hasChanges||a.isSaving},t.span({className:`txt`},`Save changes`))))])))}function Ii(e={oncreated:null}){let n=Li(e);n&&(document.body.appendChild(n),app.modals.open(n))}function Li(e){let n,r=`backup_create_`+app.utils.randomString(),i=store({name:``,isSubmitting:!1}),a;async function o(){if(!i.isSubmitting){i.isSubmitting=!0,clearTimeout(a),a=setTimeout(()=>{app.modals.close(n)},1500);try{await app.pb.backups.create(i.name,{requestKey:r}),i.isSubmitting=!1,e.oncreated&&e.oncreated(i.name),app.toasts.success(`Successfully generated new backup.`),app.modals.close(n)}catch(e){e.isAbort||(clearTimeout(a),i.isSubmitting=!1,app.checkApiError(e))}}}return n=t.div({pbEvent:`backupCreateModal`,className:`modal popup backup-create-modal`,onbeforeclose:()=>{i.isSubmitting&&app.toasts.info(`The backup was started but may take a while to complete. You can come back later.`)},onafterclose:e=>{clearTimeout(a),e?.remove()}},t.header({className:`modal-header`},t.h5({className:`m-auto txt-center`},`Initialize new backup`)),t.form({id:r,className:`modal-content backup-restore-form`,autocomplete:`off`,onsubmit:e=>{e.preventDefault(),o()}},t.div({className:`grid`},t.div({className:`col-lg-12`},t.div({className:`alert warning`},t.div({className:`content`},t.p(null,`Please note that during the backup other concurrent write requests may fail since the database will be temporary "locked" (this usually happens only during the ZIP generation).`),t.p({className:`txt-bold`},`If you are using S3 storage for the collections file upload, you'll have to backup them separately since they are not locally stored and they will not be included in the generated backup!`)))),t.div({className:`col-lg-12`},t.div({className:`field`},t.label({htmlFor:r+`_name`},`Backup name`),t.input({id:r+`_name`,name:`name`,type:`text`,pattern:`^[a-z0-9_-]+.zip$`,placeholder:`Leave empty to autogenerate`,value:()=>i.name,oninput:e=>i.name=e.target.value})),t.div({className:`field-help`},`Must be in the format [a-z0-9_-].zip`)))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,disabled:()=>i.isSubmitting,onclick:()=>app.modals.close(n)},t.span({className:`txt`},`Cancel`)),t.button({"html-form":r,type:`submit`,className:()=>`btn ${i.isSubmitting?`loading`:``}`,disabled:()=>i.isSubmitting},t.span({className:`txt`},`Start backup`)))),n}function Ri(e){let n=zi(e);document.body.appendChild(n),app.modals.open(n)}function zi(e){let n=`backup_restore_`+app.utils.randomString(),r=store({key:e,keyConfirm:``,isSubmitting:!1,get canSubmit(){return r.key&&r.key==r.keyConfirm}}),i;async function a(){if(!(r.isSubmitting||!r.canSubmit)){clearTimeout(i),r.isSubmitting=!0;try{await app.pb.backups.restore(r.keyConfirm),i=setTimeout(()=>{window.location.reload(),r.isSubmitting=!1},2e3)}catch(e){clearTimeout(i),e?.isAbort||(r.isSubmitting=!1,app.checkApiError(e))}}}return t.div({pbEvent:`backupRestoreModal`,className:`modal popup backup-restore-modal`,onbeforeclose:()=>!r.isSubmitting,onafterclose:e=>{e?.remove()},onunmount:()=>{clearTimeout(i)}},t.header({className:`modal-header`},t.h5({className:`m-auto txt-center`},`Restore `,t.strong(null,()=>r.key))),t.form({id:n,className:`modal-content backup-restore-form`,autocomplete:`off`,onsubmit:e=>{e.preventDefault(),a()}},t.div({className:`grid`},t.div({className:`col-lg-12`},t.div({className:`alert danger`},t.div({className:`content`},t.p({className:`txt-bold`},`Please proceed with extreme caution and use it only with trusted backups!`),t.p(null,`Backup restore currently works only on UNIX based systems.`),t.p(null,`The restore operation will attempt to replace your existing `,t.code(null,`pb_data`),` with the one from the backup and will restart the application process.`),t.p(null,`This means that on success all of your data (including app settings, users, superusers, etc.) will be replaced with the ones from the backup.`),t.p(null,`The operation will be reverted if the backup is invalid (ex. missing `,t.code(null,`data.db`),` file).`),t.p(null,`Below is an oversimplified version of the restore flow:`),t.ol(null,t.li(null,`Replaces the current `,t.code(null,`pb_data`),` with the content from the backup.`),t.li(null,`Triggers app restart.`),t.li(null,`Applies all migrations that are missing in the restored `,t.code(null,`pb_data`),`.`),t.li(null,`Initializes the app server as usual.`))))),t.div({className:`col-lg-12`},t.div({className:`confirm-key-label m-b-sm`},`Type the backup name `,t.div({className:`label`},()=>r.key,app.components.copyButton(()=>r.key)),` to confirm:`),t.div({className:`field`},t.label({htmlFor:n+`_key`},`Backup name`),t.input({id:n+`_key`,name:`key`,type:`text`,required:!0,value:()=>r.keyConfirm,oninput:e=>r.keyConfirm=e.target.value}))))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(),disabled:()=>r.isSubmitting},t.span({className:`txt`},`Cancel`)),t.button({"html-form":n,type:`submit`,className:()=>`btn ${r.isSubmitting?`loading`:``}`,disabled:()=>r.isSubmitting||!r.canSubmit},t.span({className:`txt`},`Restore backup`))))}function Bi(e={}){let n=store({reset:null}),r=app.utils.extendStore(n,e),i=store({canBackup:!0,isLoading:!1,isDownloading:{},isDeleting:{},backups:[]});async function a(){i.isLoading=!0;try{i.backups=await app.pb.backups.getFullList(),i.backups.sort((e,n)=>e.modifiedn.modified?-1:0),i.isLoading=!1}catch(e){e.isAbort||(app.checkApiError(e),i.isLoading=!1)}}async function o(e){app.modals.confirm(`Do you really want to delete ${e}?`,()=>s(e))}async function s(e){if(!i.isDeleting[e]){i.isDeleting[e]=!0;try{await app.pb.backups.delete(e),a(),app.toasts.success(`Successfully deleted ${e}.`)}catch(e){app.checkApiError(e)}delete i.isDeleting[e]}}async function c(){try{let e=await app.pb.health.check({requestKey:null}),n=i.canBackup;i.canBackup=e?.data?.canBackup||!1,i.canBackup&&n!=i.canBackup&&a()}catch(e){console.warn(`failed to load canBackup checks`,e)}}async function l(e){if(!i.isDownloading[e]){i.isDownloading[e]=!0;try{let n=await app.pb.files.getToken({requestKey:null});app.utils.download(app.pb.backups.getDownloadURL(n,e))}catch(e){app.checkApiError(e)}delete i.isDownloading[e]}}return t.div({pbEvent:`backupsList`,className:`list backups-list`,onmount:e=>{r.push(watch(()=>n.reset,()=>{a()})),e._canBackupIntervalId=setInterval(()=>{c()},3500)},onunmount:e=>{clearInterval(e._canBackupIntervalId),r.forEach(e=>e?.unwatch())}},t.div({className:`list-content`},t.div({hidden:()=>!i.isLoading||i.backups.length,className:`list-item`},t.div({className:`skeleton-loader`})),t.div({hidden:()=>i.isLoading||i.backups.length,className:()=>`list-item`},t.div({className:`content block txt-hint`},`No backups found.`)),()=>i.backups.map(e=>t.div({className:()=>`list-item ${i.isLoading?`faded`:``}`},t.i({className:`ri-folder-zip-line`,ariaHidden:!0}),t.div({className:`content`},t.span({className:`backup-name txt-ellipsis`,title:()=>e.key,textContent:()=>e.key}),t.small({className:`backup-size txt-hint txt-nowrap`},`(`,()=>app.utils.formattedFileSize(e.size),`)`)),t.nav({hidden:()=>i.isLoading,className:`actions autohide`},t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Download`),className:()=>`btn sm circle secondary transparent ${i.isDownloading[e.key]?`loading`:``}`,disabled:()=>i.isDeleting[e.key]||i.isDownloading[e.key],onclick:()=>l(e.key)},t.i({className:`ri-download-line`,ariaHidden:!0})),t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Restore`),className:()=>`btn sm circle secondary transparent`,disabled:()=>i.isDeleting[e.key]||i.isDownloading[e.key],onclick:()=>Ri(e.key)},t.i({className:`ri-restart-line`,ariaHidden:!0})),t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Delete`),className:()=>`btn sm circle secondary transparent ${i.isDeleting[e.key]?`loading`:``}`,disabled:()=>i.isDeleting[e.key]||i.isDownloading[e.key],onclick:()=>o(e.key)},t.i({className:`ri-delete-bin-7-line`,ariaHidden:!0})))))),t.div({className:`list-item`},t.button({type:`button`,className:()=>`btn secondary block ${i.isLoading?`loading`:``}`,disabled:()=>!i.canBackup||i.isLoading,onclick:()=>{Ii({oncreated:()=>a()})}},()=>i.canBackup?[t.i({className:`ri-play-circle-line`,ariaHidden:!0}),t.span({className:`txt`},`Initialize new backup`)]:[t.span({className:`loader sm`}),t.span({className:`txt`},`Backup/restore operation is in process`)])))}function Vi(e=null){let n=`backup_upload_`+app.utils.randomString(),r=store({isUploading:!1});function i(e){e&&app.modals.confirm(`Note that we don't perform validations for the uploaded backup files. Proceed with extreme caution and only if you trust the source.\n\nDo you really want to upload "${e.name}"?`,()=>{a(e)},()=>{o()})}async function a(i){if(!(!i||r.isUploading)){r.isUploading=!0;try{let a=new FormData;a.set(`file`,i),await app.pb.backups.upload(a,{requestKey:n}),r.isUploading=!1,e(i),app.toasts.success(`Successfully uploaded a new backup.`)}catch(e){e.isAbort||(r.isUploading=!1,e.response?.formData?.file?.message?app.toasts.error(e.response.formData.file.message):app.checkApiError(e))}o()}}function o(){s&&(s.value=``)}let s=t.input({type:`file`,accept:`application/zip`,className:`hidden`,onchange:e=>{i(e.target?.files?.[0])}});return t.div(null,t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Upload backup`),className:()=>`btn sm transparent secondary circle ${r.isUploading?`loading`:``}`,disabled:()=>r.isUploading,onclick:()=>s?.click(),onunmount:()=>{app.pb.cancelRequest(n)}},t.i({className:`ri-upload-cloud-line`,ariaHidden:!0})),s)}function Hi(e){app.store.title=`Backups`;let n=store({resetList:null});function r(){n.resetList=Date.now()}return t.div({pbEvent:`pageBackupsSettings`,className:`page page-backups-settings`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},t.div({className:`grid`},t.div({className:`col-lg-12`},t.div({className:`flex gap-10 m-b-sm`},t.div({className:`txt-lg`},`Backup and restore your PocketBase data`),app.components.refreshButton({className:`btn sm transparent secondary circle tooltip-bottom`,onclick:r}),Vi(r)),Bi({reset:()=>n.resetList})),t.div({className:`col-lg-12`},Fi({onsave:()=>r()})))),t.footer({className:`page-footer`},app.components.credits())))}function Ui(e={}){let n=store({reset:null}),r=app.utils.extendStore(n,e),i=store({isLoading:!1,isRunning:{},crons:[]});async function a(){i.isLoading=!0;try{i.crons=await app.pb.crons.getFullList(),i.isLoading=!1}catch(e){e.isAbort||(app.checkApiError(e),i.isLoading=!1)}}async function o(e){if(!(!e||i.isRunning[e])){i.isRunning[e]=!0;try{await app.pb.crons.run(e),app.toasts.success(`Successfully triggered "${e}".`),i.isRunning[e]=!1}catch(n){n.isAbort||(ApiClient.error(n),i.isRunning[e]=!1)}}}return t.div({pbEvent:`cronsList`,className:`list`,onmount:()=>{r.push(watch(()=>n.reset,()=>{a()}))},onunmount:()=>{r.forEach(e=>e?.unwatch())}},()=>{if(!i.isLoading||i.crons.length)return;let e=[];for(let n=0;n<4;n++)e.push(t.div({rid:`skeleton_`+n,className:`list-item`},t.div({className:`skeleton-loader`})));return e},t.div({hidden:()=>i.isLoading||i.crons.length,className:`list-item`},t.div({className:`content block txt-hint`},`No registered crons found.`)),()=>i.crons.map(e=>t.div({className:()=>`list-item ${i.isLoading?`faded`:``}`},t.div({className:`content`},t.span({className:`cron-id txt-code txt-ellipsis`,title:()=>e.id,textContent:()=>e.id})),t.small({className:`cron-expression txt-hint txt-nowrap txt-code`},()=>e.expression),t.nav({hidden:()=>i.isLoading,className:`actions`},t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Run`),className:()=>`btn sm circle secondary transparent ${i.isRunning[e.id]?`loading`:``}`,disabled:()=>i.isRunning[e.id],onclick:()=>o(e.id)},t.i({className:`ri-play-large-line`,ariaHidden:!0}))))))}function Wi(e){app.store.title=`Crons`;let n=store({resetList:null});function r(){n.resetList=Date.now()}return t.div({pbEvent:`pageCronsSettings`,className:`page`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},t.div({className:`flex gap-10 m-b-sm`},t.div({className:`txt-lg`},`Registered app cron jobs`),app.components.refreshButton({className:`btn sm transparent secondary circle`,onclick:r})),Ui({reset:()=>n.resetList}),t.div({className:`txt-sm txt-hint m-t-sm`},`App cron jobs can be registered only programmatically with `,t.a({href:`https://pocketbase.io/docs/go-jobs-scheduling/`,target:`_blank`,rel:`noopener noreferrer`,textContent:`Go`}),` or `,t.a({href:`https://pocketbase.io/docs/js-jobs-scheduling/`,target:`_blank`,rel:`noopener noreferrer`,textContent:`JavaScript`}),`.`)),t.footer({className:`page-footer`},app.components.credits())))}function Gi(e){app.store.title=`Mail settings`;let n=[{label:`Auto (StartTLS)`,value:!1},{label:`Always`,value:!0}],r=[{label:`PLAIN (default)`,value:`PLAIN`},{label:`LOGIN`,value:`LOGIN`}],i=store({isLoading:!1,isSaving:!1,formSettings:null,initSerialized:`null`,showMoreOptions:!1,get hasChanges(){return i.initSerialized!=JSON.stringify(i.formSettings)}});a();async function a(){i.isLoading=!0;try{s(await app.pb.settings.getAll()),i.isLoading=!1}catch(e){e.isAbort||app.checkApiError(e)}}async function o(){if(!(i.isSaving||!i.hasChanges)){i.isSaving=!0;try{let e=app.utils.filterRedactedProps(i.formSettings);s(await app.pb.settings.update(e)),app.toasts.success(`Successfully saved mail settings.`)}catch(e){app.checkApiError(e)}i.isSaving=!1}}function s(e={}){app.store.settings=JSON.parse(JSON.stringify(e)),i.formSettings={meta:e?.meta||{},smtp:e?.smtp||{}},i.formSettings.smtp.authMethod||(i.formSettings.smtp.authMethod=r[0].value),i.initSerialized=JSON.stringify(i.formSettings)}function c(){i.formSettings=JSON.parse(i.initSerialized)}return t.div({pbEvent:`pageMailSettings`,className:`page page-mail-settings`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},()=>i.isLoading?t.div({className:`block txt-center`},t.span({className:`loader lg`})):t.form({pbEvent:`mailSettingsForm`,className:`grid mail-settings-form`,inert:()=>i.isSaving,onsubmit:e=>{e.preventDefault(),o()}},t.div({className:`col-lg-12 txt-lg`},t.p(null,`Configure common settings for sending emails.`)),t.div({className:`col-lg-6`},t.div({className:`field`},t.label({htmlFor:`meta.senderName`},`Sender name`),t.input({id:`meta.senderName`,name:`meta.senderName`,type:`text`,required:!0,value:()=>i.formSettings.meta.senderName||``,oninput:e=>i.formSettings.meta.senderName=e.target.value}))),t.div({className:`col-lg-6`},t.div({className:`field`},t.label({htmlFor:`meta.senderAddress`},`Sender address`),t.input({id:`meta.senderAddress`,name:`meta.senderAddress`,type:`email`,required:!0,value:()=>i.formSettings.meta.senderAddress||``,oninput:e=>i.formSettings.meta.senderAddress=e.target.value}))),t.div({className:`col-lg-12`},t.div({className:`field`},t.input({id:`smtp.enabled`,name:`smtp.enabled`,type:`checkbox`,className:`switch`,checked:()=>!!i.formSettings.smtp.enabled,onchange:e=>i.formSettings.smtp.enabled=e.target.checked}),t.label({htmlFor:`smtp.enabled`},t.span({className:`txt`},`Use SMTP mail server `,t.strong(null,`(recommended)`)),t.i({className:`ri-information-line link-faded`,ariaDescription:app.attrs.tooltip(`By default PocketBase uses the unix "sendmail" command for sending emails. For better emails deliverability it is recommended to use a SMTP mail server.`)}))),app.components.slide(()=>i.formSettings.smtp.enabled,t.div({className:`grid m-t-sm`},t.div({className:`col-lg-4`},t.div({className:`field`},t.label({htmlFor:`smtp.host`},`SMTP server host`),t.input({id:`smtp.host`,name:`smtp.host`,type:`text`,required:()=>i.formSettings.smtp.enabled,value:()=>i.formSettings.smtp.host||``,oninput:e=>i.formSettings.smtp.host=e.target.value}))),t.div({className:`col-lg-2`},t.div({className:`field`},t.label({htmlFor:`smtp.port`},`Port`),t.input({id:`smtp.port`,name:`smtp.port`,type:`number`,min:0,step:1,required:()=>i.formSettings.smtp.enabled,value:()=>i.formSettings.smtp.port||``,oninput:e=>i.formSettings.smtp.port=parseInt(e.target.value,10)}))),t.div({className:`col-lg-3`},t.div({className:`field`},t.label({htmlFor:`smtp.username`},`Username`),t.input({id:`smtp.username`,name:`smtp.username`,type:`text`,autocomplete:`off`,value:()=>i.formSettings.smtp.username||``,oninput:e=>i.formSettings.smtp.username=e.target.value}))),t.div({className:`col-lg-3`},t.div({className:`field`},t.label({htmlFor:`smtp.password`},`Password`),t.input({id:`smtp.password`,name:`smtp.password`,type:`password`,autocomplete:`new-password`,value:()=>i.formSettings.smtp.password||``,oninput:e=>i.formSettings.smtp.password=e.target.value,onkeyup:e=>{e.key==`Backspace`&&i.formSettings.smtp.password===void 0&&(i.formSettings.smtp.password=``)},placeholder:()=>i.formSettings.smtp.password===void 0?`* * * * * *`:``})))),t.button({type:`button`,className:`btn secondary sm m-t-sm`,onclick:()=>i.showMoreOptions=!i.showMoreOptions},t.span({className:`txt`},()=>i.showMoreOptions?`Hide more options`:`Show more options`),t.i({className:()=>i.showMoreOptions?`ri-arrow-drop-up-line`:`ri-arrow-drop-down-line`})),app.components.slide(()=>i.showMoreOptions,t.div({className:`grid m-t-sm`},t.div({className:`col-lg-3`},t.div({className:`field`},t.label({htmlFor:`smtp.tls`},`TLS encryption`),app.components.select({id:`smtp.tls`,name:`smtp.tls`,required:!0,options:n,value:()=>i.formSettings.smtp.tls||!1,onchange:e=>{i.formSettings.smtp.tls=e?.[0]?.value}}))),t.div({className:`col-lg-3`},t.div({className:`field`},t.label({htmlFor:`smtp.authMethod`},`AUTH method`),app.components.select({id:`smtp.authMethod`,name:`smtp.authMethod`,required:!0,options:r,value:()=>i.formSettings.smtp.authMethod||r[0].value,onchange:e=>{i.formSettings.smtp.authMethod=e?.[0]?.value}}))),t.div({className:`col-lg-6`},t.div({className:`field`},t.label({htmlFor:`smtp.localName`},t.span({className:`txt`},`EHLO/HELO domain`),t.i({className:`ri-information-line link-hint tooltip-top`,ariaDescription:app.attrs.tooltip(`Some SMTP servers, such as the Gmail SMTP-relay, requires a proper domain name in the inital EHLO/HELO exchange and will reject attempts to use localhost.`)})),t.input({id:`smtp.localName`,name:`smtp.localName`,type:`text`,placeholder:`Default to localhost`,value:()=>i.formSettings.smtp.localName||``,oninput:e=>i.formSettings.smtp.localName=e.target.value}))))))),t.div({className:`col-lg-12`},t.hr()),t.div({className:`col-lg-12`},t.div({className:`flex`},t.div({className:`m-r-auto`}),()=>i.hasChanges?[t.button({type:`button`,className:`btn transparent secondary`,onclick:c},t.span({className:`txt`},`Cancel`)),t.button({className:()=>`btn expanded-lg ${i.isSaving?`loading`:``}`,disabled:()=>!i.hasChanges||i.isSaving},t.span({className:`txt`},`Save changes`))]:t.button({type:`button`,className:()=>`btn expanded-lg outline`,onclick:()=>app.modals.openMailTest()},t.i({className:`ri-mail-check-line`,ariaHidden:!0}),t.span({className:`txt`},`Send test email`)))))),t.footer({className:`page-footer`},app.components.credits())))}var Ki=`pbSQLConsoleHistory`;function qi(e){app.store.title=`SQL console`;let n=`sql_console_`+app.utils.randomString(),r=n+`editor`,i=n+`executeSQL`,a=store({askedForConfirmationAtLeastOnce:!1,isExecuting:!1,maxRows:250,query:``,result:{},sort:{},errorMsg:``,executedHistory:app.utils.getLocalHistory(Ki,[]),get sortedResultRows(){if(a.sort?.index===void 0){let e=a.result?.rows||[];return a.maxRows>=e.length?e:e.slice(0,a.maxRows)}let e=!!a.sort?.asc,n=a.result?.rows?.toSorted((n,r)=>{let i=n[a.sort.index],o=r[a.sort.index];return e||(i=r[a.sort.index],o=n[a.sort.index]),i==o?0:i==null?-1:o==null?1:i.localeCompare(o)})||[];return a.maxRows>=n.length?n:n.slice(0,a.maxRows)},get totalRemainingRows(){return(a.result?.rows?.length<<0)-a.sortedResultRows.length}});function o(e){return e?.trim()?!a.askedForConfirmationAtLeastOnce&&app.store.settings?.meta?.hideControls?!0:(e=e?.replace(/[\s\;]/gm,` `).toUpperCase()+` `,!![`INSERT `,`CREATE `,`UPDATE `,`DELETE `,`DROP `,`DETACH `,`PRAGMA `].find(n=>e.includes(n))):!1}async function s(){return o(a.query)?(a.askedForConfirmationAtLeastOnce=!0,app.modals.confirm(t.div({className:`txt-center`},t.h6(null,`Be careful and continue only if you really know what you are doing because, depending on the query, the operation could break your application and may not be reversible.`)),()=>c(),null,{yesButton:`Execute`,noButton:`Cancel`})):c()}async function c(){a.isExecuting=!0,a.maxRows=250,a.result={},a.sort={},a.errorMsg=``;let e=a.query.trim();if(!e){app.pb.cancelRequest(i),a.isExecuting=!1;return}try{a.result=await app.pb.sql.run(e,{requestKey:i}),u(e),a.isExecuting=!1}catch(e){e?.isAbort||(a.isExecuting=!1,a.errorMsg=e?.response?.message||e?.message||`Failed to execute query.`)}}function l(e){function n(e){return e.replace(/[\s\;]/gm,``).toUpperCase()}let r=n(e);for(let i=a.executedHistory.length-1;i>=0;i--)(a.executedHistory[i]==e||n(a.executedHistory[i])==r)&&a.executedHistory.splice(i,1)}function u(e){l(e),a.executedHistory.unshift(a.query),a.executedHistory.length>10&&a.executedHistory.splice(10)}function d(){if(!a.sortedResultRows.length)return;let e=[a.result.columns.map(e=>e.name)].concat(a.sortedResultRows),n=`export_`+app.utils.toLocalDatetime(new Date).replace(/[\-\:\. ]/g,`_`)+`.csv`;app.utils.downloadCSV(e,n)}function f(e){a.sort?.index==e?a.sort={index:e,asc:!a.sort.asc}:a.sort={index:e,asc:!0}}let p=[watch(()=>JSON.stringify(a.executedHistory),(e,n)=>{n!==void 0&&window.localStorage.setItem(Ki,e)})];return t.div({pbEvent:`pageSQLConsole`,className:`page`,onunmount:()=>{app.pb.cancelRequest(i),p.forEach(e=>e?.unwatch())}},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title)),t.div({className:`page-header-secondary-btns`},t.button({type:`button`,className:`btn circle transparent secondary`,ariaDescription:app.attrs.tooltip(`Recently executed queries`,`right`),"html-popovertarget":`sql-console-history-dropdown`},t.i({className:`ri-history-line`,ariaHidden:!0})),t.div({id:`sql-console-history-dropdown`,className:()=>`dropdown left sql-console-history-dropdown ${a.executedHistory.length?``:`no-items`}`,popover:`auto`},()=>a.executedHistory.length?a.executedHistory.map(e=>t.button({role:`button`,className:`dropdown-item`,onclick:n=>{n.target.closest(`.dropdown`).hidePopover(),a.query=e,document.getElementById(r)?.click()}},t.span({className:`query`},()=>app.utils.truncate(e,500)),t.small({role:`button`,className:`remove-btn link-hint m-l-auto p-l-5 p-r-5`,title:`Clear`,onauxclick:e=>(e.stopPropagation(),!1),onclick:n=>(n.stopPropagation(),l(e),!1)},t.i({className:`ri-close-line`,ariaHidden:!0})))):t.span({className:`txt txt-hint p-5`},`No recently executed queries.`))),t.div({className:`page-header-primary-btns`},t.button({type:`button`,className:()=>`btn expanded-lg ${a.isExecuting?`loading`:``}`,disabled:()=>a.isExecuting,onclick:()=>s()},t.i({className:`ri-play-large-line`,ariaHidden:!0}),t.span({className:`txt`},`Execute`)))),t.div({className:`field sql-console-field`},app.components.codeEditor({id:r,language:`sql`,required:!0,name:`query`,placeholder:`e.g. EXPLAIN QUERY PLAN SELECT * from users WHERE verified=true`,value:()=>a.query,oninput:e=>a.query=e,onblur:e=>a.query=e.trim()})),t.div({className:`flex field-help m-b-sm`},t.button({type:`button`,className:`link-hint m-l-auto`,"html-popovertarget":n+`caveats_dropdown`},()=>`SQL console caveats`),t.div({id:n+`caveats_dropdown`,className:`dropdown sm query-caveats-dropdown`,popover:`auto`},t.ul(null,t.li(null,`The returned rows are limited up to 1000.`),t.li(null,`The executed queries have a max timeout of 3 minutes.`),t.li(null,`The data is returned as byte strings without any additional formatting.`),t.li(null,`Multiple queries are supported but only the result of the last one is returned.`)))),t.div({hidden:()=>a.isExecuting||!a.errorMsg,className:`alert danger m-b-sm`},t.pre(null,()=>a.errorMsg)),t.div({hidden:()=>a.isExecuting||a.errorMsg||a.result?.columns?.length||app.utils.isEmpty(a.result),className:`alert success m-b-sm`},t.p({className:`txt-bold`},`Query executed successfully!`),t.p(null,`Affected rows: `,()=>a.result?.affectedRows||0)),t.div({hidden:()=>a.isExecuting||!a.result?.columns?.length,className:`page-table-wrapper`},t.table({className:`sql-console-table responsive-table optimize`},t.thead({className:`sticky`},t.tr(null,()=>a.result?.columns?.map((e,n)=>t.th({textContent:e.name,className:()=>{let e=`sort-handle`;return a.sort?.index==n&&(e+=a.sort.asc?` asc`:` desc`),e},onclick:()=>f(n)})))),t.tbody(null,()=>a.sortedResultRows.length?a.sortedResultRows.map(e=>t.tr(null,()=>a.result?.columns?.map((n,r)=>{let i=e[r];return t.td({"html-data-name":n.name},i==null?`NULL`:app.utils.truncate(i,2e3))}))):t.tr(null,t.td({colSpan:a.result?.columns?.length||1,className:`txt-center`},t.span({className:`txt-hint`},`No rows found.`))),t.tr({hidden:()=>a.isExecuting||!a.result?.rows?.length||a.result.rows.length<=a.sortedResultRows.length},t.td({colSpan:99},t.button({type:`button`,className:`btn lg secondary load-more-btn`,onclick:()=>{a.maxRows=a.result?.rows?.length||250}},t.span({className:`txt`,textContent:()=>`Load remaining (${a.totalRemainingRows})`}))))))),t.footer({className:`page-footer`},t.span({className:()=>`exec-time ${a.isExecuting?`faded`:``}`},`Time: `,()=>(a.result?.execTime||0)+`ms`),t.span({hidden:()=>!a.result?.columns?.length,className:()=>`total-count ${a.isExecuting?`faded`:``}`},`Rows: `,()=>a.result?.rows?.length||0,()=>{if(a.result?.rows?.length)return[` (`,t.span({role:`button`,className:`link-hint`,textContent:`Export as CSV`,onclick:d}),`)`]}),app.components.credits())))}function Ji(){app.store.title=`File storage`;let e=store({isLoading:!1,isSaving:!1,formSettings:null,initSerialized:`null`,originalFormSettings:null,get hasChanges(){return e.initSerialized!=JSON.stringify(e.formSettings)}});n();async function n(){e.isLoading=!0;try{i(await app.pb.settings.getAll()),e.isLoading=!1}catch(e){e.isAbort||app.checkApiError(e)}}async function r(){if(!(e.isSaving||!e.hasChanges)){e.isSaving=!0;try{let n=app.utils.filterRedactedProps(e.formSettings);i(await app.pb.settings.update(n)),app.toasts.success(`Successfully saved storage settings.`)}catch(e){app.checkApiError(e)}e.isSaving=!1}}function i(n={}){app.store.settings=JSON.parse(JSON.stringify(n)),e.formSettings={s3:n?.s3||{}},e.initSerialized=JSON.stringify(e.formSettings),e.originalFormSettings=JSON.parse(e.initSerialized)}function a(){e.formSettings=JSON.parse(e.initSerialized)}return t.div({pbEvent:`pageStorageSettings`,className:`page page-storage-settings`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},()=>e.isLoading?t.div({className:`block txt-center`},t.span({className:`loader lg`})):t.form({pbEvent:`storageSettingsForm`,className:`grid storage-settings-form`,inert:()=>e.isSaving,onsubmit:e=>{e.preventDefault(),r()}},t.div({className:`col-lg-12 txt-lg`},t.p(null,`By default PocketBase uses and recommends the local file system to store uploaded files because it is more performant, easier to manage and backup.`),t.p(null,`Alternatively, if you have limited disk space available, you could opt to an S3 compatible external storage.`)),t.div({className:`col-lg-12`},app.components.s3ConfigFields({config:()=>e.formSettings.s3,before:()=>{let n=e.originalFormSettings.s3?.enabled;if(n!=e.formSettings.s3?.enabled)return t.div({className:`alert info m-t-sm`},`If you have existing uploaded files, you'll have to migrate them manually from the `,t.strong(null,n?`S3 storage`:`local file system`),` to the `,t.strong(null,e.formSettings.s3?.enabled?`S3 storage`:`local file system`),`.`,t.br(),`There are several command line tools that can help you, such as: `,t.a({href:`https://github.com/rclone/rclone`,target:`_blank`,rel:`noopener noreferrer`,className:`txt-bold`,textContent:`rclone`}),`, `,t.a({href:`https://github.com/peak/s5cmd`,target:`_blank`,rel:`noopener noreferrer`,className:`txt-bold`,textContent:`s5cmd`}),`, etc.`)}})),t.div({className:`col-lg-12`},t.hr()),t.div({className:`col-lg-12`},t.div({className:`flex`},t.div({className:`m-r-auto`}),t.button({hidden:()=>!e.hasChanges,type:`button`,className:`btn transparent secondary`,onclick:a},t.span({className:`txt`},`Cancel`)),t.button({className:()=>`btn expanded-lg ${e.isSaving?`loading`:``}`,disabled:()=>!e.hasChanges||e.isSaving},t.span({className:`txt`},`Save changes`)))))),t.footer({className:`page-footer`},app.components.credits())))}function Yi(e){app.store.title=`Export collections`;let n=`export_`+app.utils.randomString(),r=store({isLoading:!1,collections:[],bulkSelected:{},get bulkSelectStr(){return JSON.stringify(app.utils.sortedCollectionsByType(Object.values(r.bulkSelected)),null,2)},get totalSelected(){return Object.keys(r.bulkSelected).length},get areAllSelected(){return r.collections.length&&r.collections.length==r.totalSelected}});i();async function i(){r.isLoading=!0;try{let e=await app.pb.collections.getFullList({requestKey:n});for(let n of e)delete n.created,delete n.updated,delete n.oauth2?.providers;r.collections=app.utils.sortedCollectionsByType(e),c(),r.isLoading=!1}catch(e){e.isAbort||(app.checkApiError(e),r.isLoading=!1)}}function a(){let e=app.utils.sortedCollectionsByType(Object.values(r.bulkSelected));app.utils.downloadJSON(e,`pb_schema`)}function o(){r.areAllSelected?s():c()}function s(){r.bulkSelected={}}function c(){r.bulkSelected={};for(let e of r.collections)r.bulkSelected[e.id]=e}function l(e){let n=JSON.parse(JSON.stringify(r.bulkSelected));r.bulkSelected[e.id]?delete n[e.id]:n[e.id]=e,r.bulkSelected=n}return t.div({pbEvent:`pageExportCollections`,className:`page page-export-collections`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},()=>r.isLoading?t.div({className:`txt-center`},t.span({className:`loader lg`})):t.div({className:`grid`},t.div({className:`col-lg-12`},t.div({className:`txt-lg`},`Below you'll find your current collections configuration that you could import in another PocketBase environment.`)),t.div({className:`col-lg-12`},t.div({className:`export-panel`},t.aside({className:`export-list`},t.div({className:`list-item`},t.div({className:`field`},t.input({id:n+`.select_all`,type:`checkbox`,checked:()=>r.areAllSelected,onchange:()=>o()}),t.label({htmlFor:n+`.select_all`},`Select all`))),()=>r.collections.map(e=>{let i=n+`_c_`+e.id;return t.div({className:`list-item`},t.div({className:`field`},t.input({id:i,type:`checkbox`,checked:()=>!!r.bulkSelected[e.id],onchange:()=>{l(e)}}),t.label({htmlFor:i},e.name)))})),t.output({className:`export-preview`},app.components.codeBlock({value:()=>r.bulkSelectStr,language:`plain`}),t.nav({className:`ctrls`},app.components.copyButton(()=>r.bulkSelectStr))))),t.div({className:`col-lg-12 txt-right`},t.button({className:`btn`,onclick:a},t.i({className:`ri-download-line`,ariaHidden:!0}),t.span({className:`txt`},`Download as JSON`))))),t.footer({className:`page-footer`},app.components.credits())))}function Xi(e){app.store.title=`Import collections`;let n=`import_`+app.utils.randomString(),r=[],i=store({rawNewCollections:``,oldCollections:[],newCollections:[],collectionsToUpdate:[],deleteMissing:!0,isLoadingFile:!1,isLoadingOldCollections:!1,mergeWithOldCollections:!1,get isRawValid(){return!!i.rawNewCollections&&i.newCollections?.length>0&&i.newCollections.length==i.newCollections.filter(e=>!!e.id&&!!e.name).length},get collectionsToDelete(){return i.oldCollections.filter(e=>i.isRawValid&&!i.mergeWithOldCollections&&i.deleteMissing&&!i.newCollections.find(n=>n.id==e.id))},get collectionsToAdd(){return i.newCollections.filter(e=>i.isRawValid&&!i.oldCollections.find(n=>n.id==e.id))},get idReplacableCollections(){return i.newCollections.filter(e=>{let n=i.oldCollections.find(n=>n.name==e.name||n.id==e.id);if(!n)return!1;if(n.id!=e.id)return!0;let r=Array.isArray(n.fields)?n.fields:[],a=Array.isArray(e.fields)?e.fields:[];for(let e of a){if(r.find(n=>n.id==e.id))continue;let n=r.find(n=>n.name==e.name);if(n&&e.id!=n.id)return!0}return!1})},get hasChanges(){return!!i.rawNewCollections&&!!(i.collectionsToDelete.length||i.collectionsToAdd.length||i.collectionsToUpdate.length)},get canReview(){return!i.isLoadingOldCollections&&i.isRawValid&&i.hasChanges}}),a=t.input({id:n+`_load_json`,type:`file`,className:`hidden`,accept:`.json`,onchange:()=>{d(a.files?.[0])}});o();async function o(){i.isLoadingOldCollections=!0;try{let e=await app.pb.collections.getFullList();for(let n of e)delete n.created,delete n.updated,delete n.oauth2?.providers;i.oldCollections=e,i.isLoadingOldCollections=!1}catch(e){e.isAbort||(app.checkApiError(e),i.isLoadingOldCollections=!1)}}r.push(watch(()=>i.rawNewCollections,()=>{s()}));function s(){let e=[];try{e=JSON.parse(i.rawNewCollections),e=Array.isArray(e)?app.utils.filterDuplicatesByKey(e):[];for(let n of e)delete n.created,delete n.updated,n.fields&&=app.utils.filterDuplicatesByKey(n.fields)}catch{}i.newCollections=e}r.push(watch(()=>[i.newCollections,i.deleteMissing],()=>{c()}));function c(){if(i.collectionsToUpdate=[],i.isRawValid)for(let e of i.newCollections){let n=i.oldCollections.find(n=>n.id==e.id);!n?.id||!app.utils.hasCollectionChanges(n,e,i.deleteMissing)||i.collectionsToUpdate.push({new:e,old:n})}}function l(){for(let e of i.newCollections){let n=i.oldCollections.find(n=>n.name==e.name||n.id==e.id);if(!n)continue;let r=e.id,a=n.id;e.id=a;let o=Array.isArray(n.fields)?n.fields:[],s=Array.isArray(e.fields)?e.fields:[];for(let e of s){let n=o.find(n=>n.name==e.name);n&&n.id&&(e.id=n.id)}for(let e of i.newCollections)if(Array.isArray(e.fields))for(let n of e.fields)n.collectionId&&n.collectionId===r&&(n.collectionId=a);for(let n=0;ne.replace(r,a))}i.rawNewCollections=JSON.stringify(i.newCollections,null,2)}function u(){i.rawNewCollections=``,a.value=``,app.store.errors=null}function d(e){i.isLoadingFile=!0;let n=new FileReader;n.onload=async e=>{i.isLoadingFile=!1,a.value=``,i.rawNewCollections=e.target.result,await new Promise(e=>setTimeout(e,0)),i.newCollections.length||(app.toasts.error(`Invalid collections configuration.`),u())},n.onerror=e=>{app.toasts.error(`Failed to load the imported JSON.`),console.warn(e),i.isLoadingFile=!1,a.value=``},n.readAsText(e)}function f(){let e=i.mergeWithOldCollections?app.utils.filterDuplicatesByKey(i.oldCollections.concat(i.newCollections)):i.newCollections;app.modals.openImportCollectionsReview(i.oldCollections,e,{deleteMissing:i.deleteMissing,onsubmit:()=>{u(),o()}})}return t.div({pbEvent:`pageImportCollections`,className:`page page-import-collections`,onunmount:()=>{r.forEach(e=>e?.unwatch())}},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},()=>i.isLoadingOldCollections?t.div({className:`block txt-center`},t.span({className:`loader lg`})):t.div({className:`grid`},t.div({className:`col-lg-12`},t.span({className:`txt-lg m-r-5`},`Paste below the collections configuration you want to import or`),t.label({htmlFor:a.id,className:()=>`btn sm outline ${i.isLoadingFile?`loading`:``}`},t.span({className:`txt`},`Load from JSON file`)),a,t.p({className:`txt-hint`},t.em(null,`You can use the `,t.a({href:`https://pocketbase.io/docs/go-migrations/`,target:`_blank`,rel:`noopener noreferrer`,textContent:`Go`}),` or `,t.a({href:`https://pocketbase.io/docs/js-migrations/`,target:`_blank`,rel:`noopener noreferrer`,textContent:`JS`}),` migrations to manage your collections programmatically in more granular and version controlled manner.`))),t.div({className:`col-lg-12`},t.div({className:`field`},t.label({htmlFor:n+`_collections_field`},`Collections`),t.textarea({id:n+`_collections_field`,name:`collections`,rows:12,className:`txt-code`,spellcheck:!1,autocorrect:!1,autocomplete:`off`,autocapitalize:`off`,value:()=>i.rawNewCollections,oninput:e=>i.rawNewCollections=e.target.value})),t.div({className:()=>`field-help error ${i.rawNewCollections&&!i.isRawValid?``:`hidden`}`},`Invalid collections configuration.`)),t.div({className:()=>`col-lg-12 ${i.isRawValid?``:`hidden`}`},t.div({className:`field`},t.input({id:n+`_merge_checkbox`,type:`checkbox`,className:`switch`,checked:()=>i.mergeWithOldCollections,onchange:e=>i.mergeWithOldCollections=e.target.checked}),t.label({htmlFor:n+`_merge_checkbox`},`Merge with the existing collections`))),t.div({className:()=>`col-lg-12 ${i.isRawValid&&!i.hasChanges?``:`hidden`}`},t.div({className:`alert info`},t.div({className:`content`},t.p(null,`Your collections configuration is already up-to-date!`)))),t.div({className:()=>`col-lg-12 ${i.isRawValid&&i.hasChanges?``:`hidden`}`},t.p({className:`txt-hint txt-bold`},`Detected changes`),t.div({className:`list`},()=>i.collectionsToDelete.map(e=>t.div({className:`list-item`},t.span({className:`label import-change-label danger`,textContent:`Deleted`}),t.div({className:`inline-flex gap-5`},t.strong({textContent:()=>e.name}),t.small({className:()=>`txt-hint ${e.id?``:`hidden`}`,textContent:()=>e.id})))),()=>i.collectionsToUpdate.map(e=>t.div({className:`list-item`},t.span({className:`label import-change-label warning`,textContent:`Changed`}),t.div({className:`inline-flex gap-5`},()=>{if(e.old.name!=e.new.name)return[t.span({className:`txt-strikethrough txt-hint`,textContent:e.old.name}),t.i({className:`ri-arrow-right-line txt-sm`,ariaHidden:!0})]},t.strong({textContent:()=>e.new.name}),t.small({className:()=>`txt-hint ${e.new.id?``:`hidden`}`,textContent:()=>e.new.id})))),()=>i.collectionsToAdd.map(e=>t.div({className:`list-item`},t.span({className:`label import-change-label success`,textContent:`Added`}),t.div({className:`inline-flex gap-5`},t.strong({textContent:()=>e.name}),t.small({className:()=>`txt-hint ${e.id?``:`hidden`}`,textContent:()=>e.id})))))),t.div({className:()=>`col-lg-12 ${i.idReplacableCollections?.length?``:`hidden`}`},t.div({className:`alert warning`},t.div({className:`content`},t.p(null,`Some of the imported collections share the same name and/or fields but are imported with different IDs.`),t.p(null,`You can replace them in the import if you want to:`,t.button({type:`button`,className:`btn warning sm m-l-10`,textContent:`Replace with original IDs`,onclick:l}))))),t.div({className:`col-lg-12`},t.div({className:`flex`},t.button({type:`button`,className:()=>`btn secondary ${i.rawNewCollections?``:`hidden`}`,onclick:u},t.span({className:`txt`},`Clear`)),t.button({type:`button`,className:`btn expanded-lg m-l-auto`,disabled:()=>!i.canReview,onclick:f},t.span({className:`txt`},`Review`)))))),t.footer({className:`page-footer`},app.components.credits())))}window.app=window.app||{},window.app.routes=window.app.routes||{},window.app.routes.fallbackPath=`#/collections`,app.routes.guestOnly=function(e,n){if(app.store._ready)throw Error(`the router is already initialized`);Zi[e]=async e=>{if(app.pb.authStore.isValid&&app.pb.authStore.record?.id){window.location.hash=`#/`;return}app.store.showHeader=!1,app.store.page=await n(e)}},app.routes.superuserOnly=function(e,n){if(app.store._ready)throw Error(`the router is already initialized`);Zi[e]=async e=>{if(!app.pb.authStore.isValid||!app.pb.authStore.record?.id){window.location.hash=`#/login`;return}app.store.showHeader=!0,app.store.page=await n(e)}},app.routes.blank=function(e,n){if(app.store._ready)throw Error(`the router is already initialized`);Zi[e]=async e=>{app.store.showHeader=!1,app.store.page=await n(e)}};var Zi={},Qi;function $i(){Qi&&Qi(),Qi=router(Zi,{fallbackPath:app.routes.fallbackPath})}app.routes.guestOnly(`#/pbinstall/{token}`,async e=>{let{pageInstaller:n}=await H(async()=>{let{pageInstaller:e}=await import(`./pageInstaller-CDIahrVC.js`);return{pageInstaller:e}},[],import.meta.url);return n(e)}),app.routes.guestOnly(`#/login`,e=>Xr(e)),app.routes.guestOnly(`#/request-password-reset`,async e=>{let{pageRequestSuperuserPasswordReset:n}=await H(async()=>{let{pageRequestSuperuserPasswordReset:e}=await import(`./pageRequestSuperuserPasswordReset-C39AMhGf.js`);return{pageRequestSuperuserPasswordReset:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/confirm-password-reset/{token}`,async e=>{let{pageConfirmPasswordReset:n}=await H(async()=>{let{pageConfirmPasswordReset:e}=await import(`./pageConfirmPasswordReset-pcaeA4wC.js`);return{pageConfirmPasswordReset:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/confirm-verification/{token}`,async e=>{let{pageConfirmVerification:n}=await H(async()=>{let{pageConfirmVerification:e}=await import(`./pageConfirmVerification-Ov2sOAhE.js`);return{pageConfirmVerification:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/confirm-email-change/{token}`,async e=>{let{pageConfirmEmailChange:n}=await H(async()=>{let{pageConfirmEmailChange:e}=await import(`./pageConfirmEmailChange-DE_eWn0l.js`);return{pageConfirmEmailChange:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/oauth2-redirect-success`,async e=>{let{pageOAuth2RedirectSuccess:n}=await H(async()=>{let{pageOAuth2RedirectSuccess:e}=await import(`./pageOAuth2RedirectSuccess-DmZV1eyz.js`);return{pageOAuth2RedirectSuccess:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/oauth2-redirect-failure`,async e=>{let{pageOAuth2RedirectFailure:n}=await H(async()=>{let{pageOAuth2RedirectFailure:e}=await import(`./pageOAuth2RedirectFailure-CRvz4PXa.js`);return{pageOAuth2RedirectFailure:e}},[],import.meta.url);return n(e)}),app.routes.superuserOnly(`#/collections`,fi),app.routes.superuserOnly(`#/logs`,Ci),app.routes.superuserOnly(`#/settings`,Ni),app.routes.superuserOnly(`#/settings/mail`,Gi),app.routes.superuserOnly(`#/settings/storage`,Ji),app.routes.superuserOnly(`#/settings/backups`,Hi),app.routes.superuserOnly(`#/settings/crons`,Wi),app.routes.superuserOnly(`#/settings/export-collections`,Yi),app.routes.superuserOnly(`#/settings/import-collections`,Xi),app.routes.superuserOnly(`#/settings/sql`,qi);var ea=t;t=new Proxy({},{get(e,n){return function(){let e=arguments?.[0];if(e&&e.pbEvent){let n=e.onmount;e.onmount=r=>{n?.(r),r.dataset.pb=e.pbEvent,document.dispatchEvent(new CustomEvent(`mount:`+e.pbEvent,{detail:r}))};let r=e.onunmount;e.onunmount=n=>{document.dispatchEvent(new CustomEvent(`unmount:`+e.pbEvent,{detail:n})),r?.(n)}}return ea[n](...arguments)}}}),document.body.prepend(t.main({"html-class":`app`,className:()=>`app ${app.store.settings?.meta?.hideControls?`hide-controls`:``}`},Re(),e=>(typeof app.store.page==`function`&&app.store.page(e),app.store.page))),watch(()=>app.store._ready,e=>{e&&$i()}),document.body.appendChild(t.script({type:`module`,src:app.pb.buildURL(`/_/extensions.js`),onload:()=>{app.store._ready=!0},onerror:e=>{console.warn(`Failed to load extensions:`,e),app.store._ready=!0}}));export{ce as n,S as r,ke as t}; \ No newline at end of file +@hourly`)},`macros`),`.`,t.br(),`By default the timezone is in UTC.`)),t.div({className:`col-lg-6`},t.div({className:`field`},t.label({htmlFor:`backups.cronMaxKeep`},`Max @auto backups to keep`),t.input({id:`backups.cronMaxKeep`,name:`backups.cronMaxKeep`,type:`number`,required:()=>a.enableAutoBackups,min:1,value:()=>a.formSettings.backups.cronMaxKeep,oninput:e=>{a.formSettings.backups.cronMaxKeep=parseInt(e.target.value,10)}})))))),t.div({className:`col-lg-12`},app.components.s3ConfigFields({toggleLabel:`Store backups in S3 storage`,testFilesystem:`backups`,config:()=>a.formSettings.backups.s3})),t.div({className:`col-lg-12`},t.hr()),t.div({className:`col-lg-12`},t.div({className:`flex`},t.div({className:`m-r-auto`}),t.button({hidden:()=>!a.hasChanges,type:`button`,className:`btn transparent secondary`,onclick:l},t.span({className:`txt`},`Cancel`)),t.button({className:()=>`btn expanded-lg ${a.isSaving?`loading`:``}`,disabled:()=>!a.hasChanges||a.isSaving},t.span({className:`txt`},`Save changes`))))])))}function Ii(e={oncreated:null}){let n=Li(e);n&&(document.body.appendChild(n),app.modals.open(n))}function Li(e){let n,r=`backup_create_`+app.utils.randomString(),i=store({name:``,isSubmitting:!1}),a;async function o(){if(!i.isSubmitting){i.isSubmitting=!0,clearTimeout(a),a=setTimeout(()=>{app.modals.close(n)},1500);try{await app.pb.backups.create(i.name,{requestKey:r}),i.isSubmitting=!1,e.oncreated&&e.oncreated(i.name),app.toasts.success(`Successfully generated new backup.`),app.modals.close(n)}catch(e){e.isAbort||(clearTimeout(a),i.isSubmitting=!1,app.checkApiError(e))}}}return n=t.div({pbEvent:`backupCreateModal`,className:`modal popup backup-create-modal`,onbeforeclose:()=>{i.isSubmitting&&app.toasts.info(`The backup was started but may take a while to complete. You can come back later.`)},onafterclose:e=>{clearTimeout(a),e?.remove()}},t.header({className:`modal-header`},t.h5({className:`m-auto txt-center`},`Initialize new backup`)),t.form({id:r,className:`modal-content backup-restore-form`,autocomplete:`off`,onsubmit:e=>{e.preventDefault(),o()}},t.div({className:`grid`},t.div({className:`col-lg-12`},t.div({className:`alert warning`},t.div({className:`content`},t.p(null,`Please note that during the backup other concurrent write requests may fail since the database will be temporary "locked" (this usually happens only during the ZIP generation).`),t.p({className:`txt-bold`},`If you are using S3 storage for the collections file upload, you'll have to backup them separately since they are not locally stored and they will not be included in the generated backup!`)))),t.div({className:`col-lg-12`},t.div({className:`field`},t.label({htmlFor:r+`_name`},`Backup name`),t.input({id:r+`_name`,name:`name`,type:`text`,pattern:`^[a-z0-9_-]+.zip$`,placeholder:`Leave empty to autogenerate`,value:()=>i.name,oninput:e=>i.name=e.target.value})),t.div({className:`field-help`},`Must be in the format [a-z0-9_-].zip`)))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,disabled:()=>i.isSubmitting,onclick:()=>app.modals.close(n)},t.span({className:`txt`},`Cancel`)),t.button({"html-form":r,type:`submit`,className:()=>`btn ${i.isSubmitting?`loading`:``}`,disabled:()=>i.isSubmitting},t.span({className:`txt`},`Start backup`)))),n}function Ri(e){let n=zi(e);document.body.appendChild(n),app.modals.open(n)}function zi(e){let n=`backup_restore_`+app.utils.randomString(),r=store({key:e,keyConfirm:``,isSubmitting:!1,get canSubmit(){return r.key&&r.key==r.keyConfirm}}),i;async function a(){if(!(r.isSubmitting||!r.canSubmit)){clearTimeout(i),r.isSubmitting=!0;try{await app.pb.backups.restore(r.keyConfirm),i=setTimeout(()=>{window.location.reload(),r.isSubmitting=!1},2e3)}catch(e){clearTimeout(i),e?.isAbort||(r.isSubmitting=!1,app.checkApiError(e))}}}return t.div({pbEvent:`backupRestoreModal`,className:`modal popup backup-restore-modal`,onbeforeclose:()=>!r.isSubmitting,onafterclose:e=>{e?.remove()},onunmount:()=>{clearTimeout(i)}},t.header({className:`modal-header`},t.h5({className:`m-auto txt-center`},`Restore `,t.strong(null,()=>r.key))),t.form({id:n,className:`modal-content backup-restore-form`,autocomplete:`off`,onsubmit:e=>{e.preventDefault(),a()}},t.div({className:`grid`},t.div({className:`col-lg-12`},t.div({className:`alert danger`},t.div({className:`content`},t.p({className:`txt-bold`},`Please proceed with extreme caution and use it only with trusted backups!`),t.p(null,`Backup restore currently works only on UNIX based systems.`),t.p(null,`The restore operation will attempt to replace your existing `,t.code(null,`pb_data`),` with the one from the backup and will restart the application process.`),t.p(null,`This means that on success all of your data (including app settings, users, superusers, etc.) will be replaced with the ones from the backup.`),t.p(null,`The operation will be reverted if the backup is invalid (ex. missing `,t.code(null,`data.db`),` file).`),t.p(null,`Below is an oversimplified version of the restore flow:`),t.ol(null,t.li(null,`Replaces the current `,t.code(null,`pb_data`),` with the content from the backup.`),t.li(null,`Triggers app restart.`),t.li(null,`Applies all migrations that are missing in the restored `,t.code(null,`pb_data`),`.`),t.li(null,`Initializes the app server as usual.`))))),t.div({className:`col-lg-12`},t.div({className:`confirm-key-label m-b-sm`},`Type the backup name `,t.div({className:`label`},()=>r.key,app.components.copyButton(()=>r.key)),` to confirm:`),t.div({className:`field`},t.label({htmlFor:n+`_key`},`Backup name`),t.input({id:n+`_key`,name:`key`,type:`text`,required:!0,value:()=>r.keyConfirm,oninput:e=>r.keyConfirm=e.target.value}))))),t.footer({className:`modal-footer`},t.button({type:`button`,className:`btn transparent m-r-auto`,onclick:()=>app.modals.close(),disabled:()=>r.isSubmitting},t.span({className:`txt`},`Cancel`)),t.button({"html-form":n,type:`submit`,className:()=>`btn ${r.isSubmitting?`loading`:``}`,disabled:()=>r.isSubmitting||!r.canSubmit},t.span({className:`txt`},`Restore backup`))))}function Bi(e={}){let n=store({reset:null}),r=app.utils.extendStore(n,e),i=store({canBackup:!0,isLoading:!1,isDownloading:{},isDeleting:{},backups:[]});async function a(){i.isLoading=!0;try{i.backups=await app.pb.backups.getFullList(),i.backups.sort((e,n)=>e.modifiedn.modified?-1:0),i.isLoading=!1}catch(e){e.isAbort||(app.checkApiError(e),i.isLoading=!1)}}async function o(e){app.modals.confirm(`Do you really want to delete ${e}?`,()=>s(e))}async function s(e){if(!i.isDeleting[e]){i.isDeleting[e]=!0;try{await app.pb.backups.delete(e),a(),app.toasts.success(`Successfully deleted ${e}.`)}catch(e){app.checkApiError(e)}delete i.isDeleting[e]}}async function c(){try{let e=await app.pb.health.check({requestKey:null}),n=i.canBackup;i.canBackup=e?.data?.canBackup||!1,i.canBackup&&n!=i.canBackup&&a()}catch(e){console.warn(`failed to load canBackup checks`,e)}}async function l(e){if(!i.isDownloading[e]){i.isDownloading[e]=!0;try{let n=await app.pb.files.getToken({requestKey:null});app.utils.download(app.pb.backups.getDownloadURL(n,e))}catch(e){app.checkApiError(e)}delete i.isDownloading[e]}}return t.div({pbEvent:`backupsList`,className:`list backups-list`,onmount:e=>{r.push(watch(()=>n.reset,()=>{a()})),e._canBackupIntervalId=setInterval(()=>{c()},3500)},onunmount:e=>{clearInterval(e._canBackupIntervalId),r.forEach(e=>e?.unwatch())}},t.div({className:`list-content`},t.div({hidden:()=>!i.isLoading||i.backups.length,className:`list-item`},t.div({className:`skeleton-loader`})),t.div({hidden:()=>i.isLoading||i.backups.length,className:()=>`list-item`},t.div({className:`content block txt-hint`},`No backups found.`)),()=>i.backups.map(e=>t.div({className:()=>`list-item ${i.isLoading?`faded`:``}`},t.i({className:`ri-folder-zip-line`,ariaHidden:!0}),t.div({className:`content`},t.span({className:`backup-name txt-ellipsis`,title:()=>e.key,textContent:()=>e.key}),t.small({className:`backup-size txt-hint txt-nowrap`},`(`,()=>app.utils.formattedFileSize(e.size),`)`)),t.nav({hidden:()=>i.isLoading,className:`actions autohide`},t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Download`),className:()=>`btn sm circle secondary transparent ${i.isDownloading[e.key]?`loading`:``}`,disabled:()=>i.isDeleting[e.key]||i.isDownloading[e.key],onclick:()=>l(e.key)},t.i({className:`ri-download-line`,ariaHidden:!0})),t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Restore`),className:()=>`btn sm circle secondary transparent`,disabled:()=>i.isDeleting[e.key]||i.isDownloading[e.key],onclick:()=>Ri(e.key)},t.i({className:`ri-restart-line`,ariaHidden:!0})),t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Delete`),className:()=>`btn sm circle secondary transparent ${i.isDeleting[e.key]?`loading`:``}`,disabled:()=>i.isDeleting[e.key]||i.isDownloading[e.key],onclick:()=>o(e.key)},t.i({className:`ri-delete-bin-7-line`,ariaHidden:!0})))))),t.div({className:`list-item`},t.button({type:`button`,className:()=>`btn secondary block ${i.isLoading?`loading`:``}`,disabled:()=>!i.canBackup||i.isLoading,onclick:()=>{Ii({oncreated:()=>a()})}},()=>i.canBackup?[t.i({className:`ri-play-circle-line`,ariaHidden:!0}),t.span({className:`txt`},`Initialize new backup`)]:[t.span({className:`loader sm`}),t.span({className:`txt`},`Backup/restore operation is in process`)])))}function Vi(e=null){let n=`backup_upload_`+app.utils.randomString(),r=store({isUploading:!1});function i(e){e&&app.modals.confirm(`Note that we don't perform validations for the uploaded backup files. Proceed with extreme caution and only if you trust the source.\n\nDo you really want to upload "${e.name}"?`,()=>{a(e)},()=>{o()})}async function a(i){if(!(!i||r.isUploading)){r.isUploading=!0;try{let a=new FormData;a.set(`file`,i),await app.pb.backups.upload(a,{requestKey:n}),r.isUploading=!1,e(i),app.toasts.success(`Successfully uploaded a new backup.`)}catch(e){e.isAbort||(r.isUploading=!1,e.response?.formData?.file?.message?app.toasts.error(e.response.formData.file.message):app.checkApiError(e))}o()}}function o(){s&&(s.value=``)}let s=t.input({type:`file`,accept:`application/zip`,className:`hidden`,onchange:e=>{i(e.target?.files?.[0])}});return t.div(null,t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Upload backup`),className:()=>`btn sm transparent secondary circle ${r.isUploading?`loading`:``}`,disabled:()=>r.isUploading,onclick:()=>s?.click(),onunmount:()=>{app.pb.cancelRequest(n)}},t.i({className:`ri-upload-cloud-line`,ariaHidden:!0})),s)}function Hi(e){app.store.title=`Backups`;let n=store({resetList:null});function r(){n.resetList=Date.now()}return t.div({pbEvent:`pageBackupsSettings`,className:`page page-backups-settings`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},t.div({className:`grid`},t.div({className:`col-lg-12`},t.div({className:`flex gap-10 m-b-sm`},t.div({className:`txt-lg`},`Backup and restore your PocketBase data`),app.components.refreshButton({className:`btn sm transparent secondary circle tooltip-bottom`,onclick:r}),Vi(r)),Bi({reset:()=>n.resetList})),t.div({className:`col-lg-12`},Fi({onsave:()=>r()})))),t.footer({className:`page-footer`},app.components.credits())))}function Ui(e={}){let n=store({reset:null}),r=app.utils.extendStore(n,e),i=store({isLoading:!1,isRunning:{},crons:[]});async function a(){i.isLoading=!0;try{i.crons=await app.pb.crons.getFullList(),i.isLoading=!1}catch(e){e.isAbort||(app.checkApiError(e),i.isLoading=!1)}}async function o(e){if(!(!e||i.isRunning[e])){i.isRunning[e]=!0;try{await app.pb.crons.run(e),app.toasts.success(`Successfully triggered "${e}".`),i.isRunning[e]=!1}catch(n){n.isAbort||(ApiClient.error(n),i.isRunning[e]=!1)}}}return t.div({pbEvent:`cronsList`,className:`list`,onmount:()=>{r.push(watch(()=>n.reset,()=>{a()}))},onunmount:()=>{r.forEach(e=>e?.unwatch())}},()=>{if(!i.isLoading||i.crons.length)return;let e=[];for(let n=0;n<4;n++)e.push(t.div({rid:`skeleton_`+n,className:`list-item`},t.div({className:`skeleton-loader`})));return e},t.div({hidden:()=>i.isLoading||i.crons.length,className:`list-item`},t.div({className:`content block txt-hint`},`No registered crons found.`)),()=>i.crons.map(e=>t.div({className:()=>`list-item ${i.isLoading?`faded`:``}`},t.div({className:`content`},t.span({className:`cron-id txt-code txt-ellipsis`,title:()=>e.id,textContent:()=>e.id})),t.small({className:`cron-expression txt-hint txt-nowrap txt-code`},()=>e.expression),t.nav({hidden:()=>i.isLoading,className:`actions`},t.button({type:`button`,ariaLabel:app.attrs.tooltip(`Run`),className:()=>`btn sm circle secondary transparent ${i.isRunning[e.id]?`loading`:``}`,disabled:()=>i.isRunning[e.id],onclick:()=>o(e.id)},t.i({className:`ri-play-large-line`,ariaHidden:!0}))))))}function Wi(e){app.store.title=`Crons`;let n=store({resetList:null});function r(){n.resetList=Date.now()}return t.div({pbEvent:`pageCronsSettings`,className:`page`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},t.div({className:`flex gap-10 m-b-sm`},t.div({className:`txt-lg`},`Registered app cron jobs`),app.components.refreshButton({className:`btn sm transparent secondary circle`,onclick:r})),Ui({reset:()=>n.resetList}),t.div({className:`txt-sm txt-hint m-t-sm`},`App cron jobs can be registered only programmatically with `,t.a({href:`https://pocketbase.io/docs/go-jobs-scheduling/`,target:`_blank`,rel:`noopener noreferrer`,textContent:`Go`}),` or `,t.a({href:`https://pocketbase.io/docs/js-jobs-scheduling/`,target:`_blank`,rel:`noopener noreferrer`,textContent:`JavaScript`}),`.`)),t.footer({className:`page-footer`},app.components.credits())))}function Gi(e){app.store.title=`Mail settings`;let n=[{label:`Auto (StartTLS)`,value:!1},{label:`Always`,value:!0}],r=[{label:`PLAIN (default)`,value:`PLAIN`},{label:`LOGIN`,value:`LOGIN`}],i=store({isLoading:!1,isSaving:!1,formSettings:null,initSerialized:`null`,showMoreOptions:!1,get hasChanges(){return i.initSerialized!=JSON.stringify(i.formSettings)}});a();async function a(){i.isLoading=!0;try{s(await app.pb.settings.getAll()),i.isLoading=!1}catch(e){e.isAbort||app.checkApiError(e)}}async function o(){if(!(i.isSaving||!i.hasChanges)){i.isSaving=!0;try{let e=app.utils.filterRedactedProps(i.formSettings);s(await app.pb.settings.update(e)),app.toasts.success(`Successfully saved mail settings.`)}catch(e){app.checkApiError(e)}i.isSaving=!1}}function s(e={}){app.store.settings=JSON.parse(JSON.stringify(e)),i.formSettings={meta:e?.meta||{},smtp:e?.smtp||{}},i.formSettings.smtp.authMethod||(i.formSettings.smtp.authMethod=r[0].value),i.initSerialized=JSON.stringify(i.formSettings)}function c(){i.formSettings=JSON.parse(i.initSerialized)}return t.div({pbEvent:`pageMailSettings`,className:`page page-mail-settings`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},()=>i.isLoading?t.div({className:`block txt-center`},t.span({className:`loader lg`})):t.form({pbEvent:`mailSettingsForm`,className:`grid mail-settings-form`,inert:()=>i.isSaving,onsubmit:e=>{e.preventDefault(),o()}},t.div({className:`col-lg-12 txt-lg`},t.p(null,`Configure common settings for sending emails.`)),t.div({className:`col-lg-6`},t.div({className:`field`},t.label({htmlFor:`meta.senderName`},`Sender name`),t.input({id:`meta.senderName`,name:`meta.senderName`,type:`text`,required:!0,value:()=>i.formSettings.meta.senderName||``,oninput:e=>i.formSettings.meta.senderName=e.target.value}))),t.div({className:`col-lg-6`},t.div({className:`field`},t.label({htmlFor:`meta.senderAddress`},`Sender address`),t.input({id:`meta.senderAddress`,name:`meta.senderAddress`,type:`email`,required:!0,value:()=>i.formSettings.meta.senderAddress||``,oninput:e=>i.formSettings.meta.senderAddress=e.target.value}))),t.div({className:`col-lg-12`},t.div({className:`field`},t.input({id:`smtp.enabled`,name:`smtp.enabled`,type:`checkbox`,className:`switch`,checked:()=>!!i.formSettings.smtp.enabled,onchange:e=>i.formSettings.smtp.enabled=e.target.checked}),t.label({htmlFor:`smtp.enabled`},t.span({className:`txt`},`Use SMTP mail server `,t.strong(null,`(recommended)`)),t.i({className:`ri-information-line link-faded`,ariaDescription:app.attrs.tooltip(`By default PocketBase uses the unix "sendmail" command for sending emails. For better emails deliverability it is recommended to use a SMTP mail server.`)}))),app.components.slide(()=>i.formSettings.smtp.enabled,t.div({className:`grid m-t-sm`},t.div({className:`col-lg-4`},t.div({className:`field`},t.label({htmlFor:`smtp.host`},`SMTP server host`),t.input({id:`smtp.host`,name:`smtp.host`,type:`text`,required:()=>i.formSettings.smtp.enabled,value:()=>i.formSettings.smtp.host||``,oninput:e=>i.formSettings.smtp.host=e.target.value}))),t.div({className:`col-lg-2`},t.div({className:`field`},t.label({htmlFor:`smtp.port`},`Port`),t.input({id:`smtp.port`,name:`smtp.port`,type:`number`,min:0,step:1,required:()=>i.formSettings.smtp.enabled,value:()=>i.formSettings.smtp.port||``,oninput:e=>i.formSettings.smtp.port=parseInt(e.target.value,10)}))),t.div({className:`col-lg-3`},t.div({className:`field`},t.label({htmlFor:`smtp.username`},`Username`),t.input({id:`smtp.username`,name:`smtp.username`,type:`text`,autocomplete:`off`,value:()=>i.formSettings.smtp.username||``,oninput:e=>i.formSettings.smtp.username=e.target.value}))),t.div({className:`col-lg-3`},t.div({className:`field`},t.label({htmlFor:`smtp.password`},`Password`),t.input({id:`smtp.password`,name:`smtp.password`,type:`password`,autocomplete:`new-password`,value:()=>i.formSettings.smtp.password||``,oninput:e=>i.formSettings.smtp.password=e.target.value,onkeyup:e=>{e.key==`Backspace`&&i.formSettings.smtp.password===void 0&&(i.formSettings.smtp.password=``)},placeholder:()=>i.formSettings.smtp.password===void 0?`* * * * * *`:``})))),t.button({type:`button`,className:`btn secondary sm m-t-sm`,onclick:()=>i.showMoreOptions=!i.showMoreOptions},t.span({className:`txt`},()=>i.showMoreOptions?`Hide more options`:`Show more options`),t.i({className:()=>i.showMoreOptions?`ri-arrow-drop-up-line`:`ri-arrow-drop-down-line`})),app.components.slide(()=>i.showMoreOptions,t.div({className:`grid m-t-sm`},t.div({className:`col-lg-3`},t.div({className:`field`},t.label({htmlFor:`smtp.tls`},`TLS encryption`),app.components.select({id:`smtp.tls`,name:`smtp.tls`,required:!0,options:n,value:()=>i.formSettings.smtp.tls||!1,onchange:e=>{i.formSettings.smtp.tls=e?.[0]?.value}}))),t.div({className:`col-lg-3`},t.div({className:`field`},t.label({htmlFor:`smtp.authMethod`},`AUTH method`),app.components.select({id:`smtp.authMethod`,name:`smtp.authMethod`,required:!0,options:r,value:()=>i.formSettings.smtp.authMethod||r[0].value,onchange:e=>{i.formSettings.smtp.authMethod=e?.[0]?.value}}))),t.div({className:`col-lg-6`},t.div({className:`field`},t.label({htmlFor:`smtp.localName`},t.span({className:`txt`},`EHLO/HELO domain`),t.i({className:`ri-information-line link-hint tooltip-top`,ariaDescription:app.attrs.tooltip(`Some SMTP servers, such as the Gmail SMTP-relay, requires a proper domain name in the inital EHLO/HELO exchange and will reject attempts to use localhost.`)})),t.input({id:`smtp.localName`,name:`smtp.localName`,type:`text`,placeholder:`Default to localhost`,value:()=>i.formSettings.smtp.localName||``,oninput:e=>i.formSettings.smtp.localName=e.target.value}))))))),t.div({className:`col-lg-12`},t.hr()),t.div({className:`col-lg-12`},t.div({className:`flex`},t.div({className:`m-r-auto`}),()=>i.hasChanges?[t.button({type:`button`,className:`btn transparent secondary`,onclick:c},t.span({className:`txt`},`Cancel`)),t.button({className:()=>`btn expanded-lg ${i.isSaving?`loading`:``}`,disabled:()=>!i.hasChanges||i.isSaving},t.span({className:`txt`},`Save changes`))]:t.button({type:`button`,className:()=>`btn expanded-lg outline`,onclick:()=>app.modals.openMailTest()},t.i({className:`ri-mail-check-line`,ariaHidden:!0}),t.span({className:`txt`},`Send test email`)))))),t.footer({className:`page-footer`},app.components.credits())))}var Ki=`pbSQLConsoleHistory`;function qi(e){app.store.title=`SQL console`;let n=`sql_console_`+app.utils.randomString(),r=n+`editor`,i=n+`executeSQL`,a=store({askedForConfirmationAtLeastOnce:!1,isExecuting:!1,maxRows:250,query:``,result:{},sort:{},errorMsg:``,executedHistory:app.utils.getLocalHistory(Ki,[]),get sortedResultRows(){if(a.sort?.index===void 0){let e=a.result?.rows||[];return a.maxRows>=e.length?e:e.slice(0,a.maxRows)}let e=!!a.sort?.asc,n=a.result?.rows?.toSorted((n,r)=>{let i=n[a.sort.index],o=r[a.sort.index];return e||(i=r[a.sort.index],o=n[a.sort.index]),i==o?0:i==null?-1:o==null?1:i.localeCompare(o)})||[];return a.maxRows>=n.length?n:n.slice(0,a.maxRows)},get totalRemainingRows(){return(a.result?.rows?.length<<0)-a.sortedResultRows.length}});function o(e){return e?.trim()?!a.askedForConfirmationAtLeastOnce&&app.store.settings?.meta?.hideControls?!0:(e=e?.replace(/[\s\;]/gm,` `).toUpperCase()+` `,!![`INSERT `,`CREATE `,`UPDATE `,`DELETE `,`DROP `,`DETACH `,`PRAGMA `].find(n=>e.includes(n))):!1}async function s(){return o(a.query)?(a.askedForConfirmationAtLeastOnce=!0,app.modals.confirm(t.div({className:`txt-center`},t.h6(null,`Be careful and continue only if you really know what you are doing because, depending on the query, the operation could break your application and may not be reversible.`)),()=>c(),null,{yesButton:`Execute`,noButton:`Cancel`})):c()}async function c(){a.isExecuting=!0,a.maxRows=250,a.result={},a.sort={},a.errorMsg=``;let e=a.query.trim();if(!e){app.pb.cancelRequest(i),a.isExecuting=!1;return}try{a.result=await app.pb.sql.run(e,{requestKey:i}),u(e),a.isExecuting=!1}catch(e){e?.isAbort||(a.isExecuting=!1,a.errorMsg=e?.response?.message||e?.message||`Failed to execute query.`)}}function l(e){function n(e){return e.replace(/[\s\;]/gm,``).toUpperCase()}let r=n(e);for(let i=a.executedHistory.length-1;i>=0;i--)(a.executedHistory[i]==e||n(a.executedHistory[i])==r)&&a.executedHistory.splice(i,1)}function u(e){l(e),a.executedHistory.unshift(a.query),a.executedHistory.length>10&&a.executedHistory.splice(10)}function d(){if(!a.sortedResultRows.length)return;let e=[a.result.columns.map(e=>e.name)].concat(a.sortedResultRows),n=`export_`+app.utils.toLocalDatetime(new Date).replace(/[\-\:\. ]/g,`_`)+`.csv`;app.utils.downloadCSV(e,n)}function f(e){a.sort?.index==e?a.sort={index:e,asc:!a.sort.asc}:a.sort={index:e,asc:!0}}let p=[watch(()=>JSON.stringify(a.executedHistory),(e,n)=>{n!==void 0&&window.localStorage.setItem(Ki,e)})];return t.div({pbEvent:`pageSQLConsole`,className:`page`,onunmount:()=>{app.pb.cancelRequest(i),p.forEach(e=>e?.unwatch())}},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title)),t.div({className:`page-header-secondary-btns`},t.button({type:`button`,className:`btn circle transparent secondary`,ariaDescription:app.attrs.tooltip(`Recently executed queries`,`right`),"html-popovertarget":`sql-console-history-dropdown`},t.i({className:`ri-history-line`,ariaHidden:!0})),t.div({id:`sql-console-history-dropdown`,className:()=>`dropdown left sql-console-history-dropdown ${a.executedHistory.length?``:`no-items`}`,popover:`auto`},()=>a.executedHistory.length?a.executedHistory.map(e=>t.button({role:`button`,className:`dropdown-item`,onclick:n=>{n.target.closest(`.dropdown`).hidePopover(),a.query=e,document.getElementById(r)?.click()}},t.span({className:`query`},()=>app.utils.truncate(e,500)),t.small({role:`button`,className:`remove-btn link-hint m-l-auto p-l-5 p-r-5`,title:`Clear`,onauxclick:e=>(e.stopPropagation(),!1),onclick:n=>(n.stopPropagation(),l(e),!1)},t.i({className:`ri-close-line`,ariaHidden:!0})))):t.span({className:`txt txt-hint p-5`},`No recently executed queries.`))),t.div({className:`page-header-primary-btns`},t.button({type:`button`,className:()=>`btn expanded-lg ${a.isExecuting?`loading`:``}`,disabled:()=>a.isExecuting,onclick:()=>s()},t.i({className:`ri-play-large-line`,ariaHidden:!0}),t.span({className:`txt`},`Execute`)))),t.div({className:`field sql-console-field`},app.components.codeEditor({id:r,language:`sql`,required:!0,name:`query`,placeholder:`e.g. EXPLAIN QUERY PLAN SELECT * from users WHERE verified=true`,value:()=>a.query,oninput:e=>a.query=e,onblur:e=>a.query=e.trim()})),t.div({className:`flex field-help m-b-sm`},t.button({type:`button`,className:`link-hint m-l-auto`,"html-popovertarget":n+`caveats_dropdown`},()=>`SQL console caveats`),t.div({id:n+`caveats_dropdown`,className:`dropdown sm query-caveats-dropdown`,popover:`auto`},t.ul(null,t.li(null,`The returned rows are limited up to 1000.`),t.li(null,`The executed queries have a max timeout of 3 minutes.`),t.li(null,`The data is returned as byte strings without any additional formatting.`),t.li(null,`Multiple queries are supported but only the result of the last one is returned.`)))),t.div({hidden:()=>a.isExecuting||!a.errorMsg,className:`alert danger m-b-sm`},t.pre(null,()=>a.errorMsg)),t.div({hidden:()=>a.isExecuting||a.errorMsg||a.result?.columns?.length||app.utils.isEmpty(a.result),className:`alert success m-b-sm`},t.p({className:`txt-bold`},`Query executed successfully!`),t.p(null,`Affected rows: `,()=>a.result?.affectedRows||0)),t.div({hidden:()=>a.isExecuting||!a.result?.columns?.length,className:`page-table-wrapper`},t.table({className:`sql-console-table responsive-table optimize`},t.thead({className:`sticky`},t.tr(null,()=>a.result?.columns?.map((e,n)=>t.th({textContent:e.name,className:()=>{let e=`sort-handle`;return a.sort?.index==n&&(e+=a.sort.asc?` asc`:` desc`),e},onclick:()=>f(n)})))),t.tbody(null,()=>a.sortedResultRows.length?a.sortedResultRows.map(e=>t.tr(null,()=>a.result?.columns?.map((n,r)=>{let i=e[r];return t.td({"html-data-name":n.name},i==null?`NULL`:app.utils.truncate(i,2e3))}))):t.tr(null,t.td({colSpan:a.result?.columns?.length||1,className:`txt-center`},t.span({className:`txt-hint`},`No rows found.`))),t.tr({hidden:()=>a.isExecuting||!a.result?.rows?.length||a.result.rows.length<=a.sortedResultRows.length},t.td({colSpan:99},t.button({type:`button`,className:`btn lg secondary load-more-btn`,onclick:()=>{a.maxRows=a.result?.rows?.length||250}},t.span({className:`txt`,textContent:()=>`Load remaining (${a.totalRemainingRows})`}))))))),t.footer({className:`page-footer`},t.span({className:()=>`exec-time ${a.isExecuting?`faded`:``}`},`Time: `,()=>(a.result?.execTime||0)+`ms`),t.span({hidden:()=>!a.result?.columns?.length,className:()=>`total-count ${a.isExecuting?`faded`:``}`},`Rows: `,()=>a.result?.rows?.length||0,()=>{if(a.result?.rows?.length)return[` (`,t.span({role:`button`,className:`link-hint`,textContent:`Export as CSV`,onclick:d}),`)`]}),app.components.credits())))}function Ji(){app.store.title=`File storage`;let e=store({isLoading:!1,isSaving:!1,formSettings:null,initSerialized:`null`,originalFormSettings:null,get hasChanges(){return e.initSerialized!=JSON.stringify(e.formSettings)}});n();async function n(){e.isLoading=!0;try{i(await app.pb.settings.getAll()),e.isLoading=!1}catch(e){e.isAbort||app.checkApiError(e)}}async function r(){if(!(e.isSaving||!e.hasChanges)){e.isSaving=!0;try{let n=app.utils.filterRedactedProps(e.formSettings);i(await app.pb.settings.update(n)),app.toasts.success(`Successfully saved storage settings.`)}catch(e){app.checkApiError(e)}e.isSaving=!1}}function i(n={}){app.store.settings=JSON.parse(JSON.stringify(n)),e.formSettings={s3:n?.s3||{}},e.initSerialized=JSON.stringify(e.formSettings),e.originalFormSettings=JSON.parse(e.initSerialized)}function a(){e.formSettings=JSON.parse(e.initSerialized)}return t.div({pbEvent:`pageStorageSettings`,className:`page page-storage-settings`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},()=>e.isLoading?t.div({className:`block txt-center`},t.span({className:`loader lg`})):t.form({pbEvent:`storageSettingsForm`,className:`grid storage-settings-form`,inert:()=>e.isSaving,onsubmit:e=>{e.preventDefault(),r()}},t.div({className:`col-lg-12 txt-lg`},t.p(null,`By default PocketBase uses and recommends the local file system to store uploaded files because it is more performant, easier to manage and backup.`),t.p(null,`Alternatively, if you have limited disk space available, you could opt to an S3 compatible external storage.`)),t.div({className:`col-lg-12`},app.components.s3ConfigFields({config:()=>e.formSettings.s3,before:()=>{let n=e.originalFormSettings.s3?.enabled;if(n!=e.formSettings.s3?.enabled)return t.div({className:`alert info m-t-sm`},`If you have existing uploaded files, you'll have to migrate them manually from the `,t.strong(null,n?`S3 storage`:`local file system`),` to the `,t.strong(null,e.formSettings.s3?.enabled?`S3 storage`:`local file system`),`.`,t.br(),`There are several command line tools that can help you, such as: `,t.a({href:`https://github.com/rclone/rclone`,target:`_blank`,rel:`noopener noreferrer`,className:`txt-bold`,textContent:`rclone`}),`, `,t.a({href:`https://github.com/peak/s5cmd`,target:`_blank`,rel:`noopener noreferrer`,className:`txt-bold`,textContent:`s5cmd`}),`, etc.`)}})),t.div({className:`col-lg-12`},t.hr()),t.div({className:`col-lg-12`},t.div({className:`flex`},t.div({className:`m-r-auto`}),t.button({hidden:()=>!e.hasChanges,type:`button`,className:`btn transparent secondary`,onclick:a},t.span({className:`txt`},`Cancel`)),t.button({className:()=>`btn expanded-lg ${e.isSaving?`loading`:``}`,disabled:()=>!e.hasChanges||e.isSaving},t.span({className:`txt`},`Save changes`)))))),t.footer({className:`page-footer`},app.components.credits())))}function Yi(e){app.store.title=`Export collections`;let n=`export_`+app.utils.randomString(),r=store({isLoading:!1,collections:[],bulkSelected:{},get bulkSelectStr(){return JSON.stringify(app.utils.sortedCollectionsByType(Object.values(r.bulkSelected)),null,2)},get totalSelected(){return Object.keys(r.bulkSelected).length},get areAllSelected(){return r.collections.length&&r.collections.length==r.totalSelected}});i();async function i(){r.isLoading=!0;try{let e=await app.pb.collections.getFullList({requestKey:n});for(let n of e)delete n.created,delete n.updated,delete n.oauth2?.providers;r.collections=app.utils.sortedCollectionsByType(e),c(),r.isLoading=!1}catch(e){e.isAbort||(app.checkApiError(e),r.isLoading=!1)}}function a(){let e=app.utils.sortedCollectionsByType(Object.values(r.bulkSelected));app.utils.downloadJSON(e,`pb_schema`)}function o(){r.areAllSelected?s():c()}function s(){r.bulkSelected={}}function c(){r.bulkSelected={};for(let e of r.collections)r.bulkSelected[e.id]=e}function l(e){let n=JSON.parse(JSON.stringify(r.bulkSelected));r.bulkSelected[e.id]?delete n[e.id]:n[e.id]=e,r.bulkSelected=n}return t.div({pbEvent:`pageExportCollections`,className:`page page-export-collections`},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},()=>r.isLoading?t.div({className:`txt-center`},t.span({className:`loader lg`})):t.div({className:`grid`},t.div({className:`col-lg-12`},t.div({className:`txt-lg`},`Below you'll find your current collections configuration that you could import in another PocketBase environment.`)),t.div({className:`col-lg-12`},t.div({className:`export-panel`},t.aside({className:`export-list`},t.div({className:`list-item`},t.div({className:`field`},t.input({id:n+`.select_all`,type:`checkbox`,checked:()=>r.areAllSelected,onchange:()=>o()}),t.label({htmlFor:n+`.select_all`},`Select all`))),()=>r.collections.map(e=>{let i=n+`_c_`+e.id;return t.div({className:`list-item`},t.div({className:`field`},t.input({id:i,type:`checkbox`,checked:()=>!!r.bulkSelected[e.id],onchange:()=>{l(e)}}),t.label({htmlFor:i},e.name)))})),t.output({className:`export-preview`},app.components.codeBlock({value:()=>r.bulkSelectStr,language:`plain`}),t.nav({className:`ctrls`},app.components.copyButton(()=>r.bulkSelectStr))))),t.div({className:`col-lg-12 txt-right`},t.button({className:`btn`,onclick:a},t.i({className:`ri-download-line`,ariaHidden:!0}),t.span({className:`txt`},`Download as JSON`))))),t.footer({className:`page-footer`},app.components.credits())))}function Xi(e){app.store.title=`Import collections`;let n=`import_`+app.utils.randomString(),r=[],i=store({rawNewCollections:``,oldCollections:[],newCollections:[],collectionsToUpdate:[],deleteMissing:!0,isLoadingFile:!1,isLoadingOldCollections:!1,mergeWithOldCollections:!1,get isRawValid(){return!!i.rawNewCollections&&i.newCollections?.length>0&&i.newCollections.length==i.newCollections.filter(e=>!!e.id&&!!e.name).length},get collectionsToDelete(){return i.oldCollections.filter(e=>i.isRawValid&&!i.mergeWithOldCollections&&i.deleteMissing&&!i.newCollections.find(n=>n.id==e.id))},get collectionsToAdd(){return i.newCollections.filter(e=>i.isRawValid&&!i.oldCollections.find(n=>n.id==e.id))},get idReplacableCollections(){return i.newCollections.filter(e=>{let n=i.oldCollections.find(n=>n.name==e.name||n.id==e.id);if(!n)return!1;if(n.id!=e.id)return!0;let r=Array.isArray(n.fields)?n.fields:[],a=Array.isArray(e.fields)?e.fields:[];for(let e of a){if(r.find(n=>n.id==e.id))continue;let n=r.find(n=>n.name==e.name);if(n&&e.id!=n.id)return!0}return!1})},get hasChanges(){return!!i.rawNewCollections&&!!(i.collectionsToDelete.length||i.collectionsToAdd.length||i.collectionsToUpdate.length)},get canReview(){return!i.isLoadingOldCollections&&i.isRawValid&&i.hasChanges}}),a=t.input({id:n+`_load_json`,type:`file`,className:`hidden`,accept:`.json`,onchange:()=>{d(a.files?.[0])}});o();async function o(){i.isLoadingOldCollections=!0;try{let e=await app.pb.collections.getFullList();for(let n of e)delete n.created,delete n.updated,delete n.oauth2?.providers;i.oldCollections=e,i.isLoadingOldCollections=!1}catch(e){e.isAbort||(app.checkApiError(e),i.isLoadingOldCollections=!1)}}r.push(watch(()=>i.rawNewCollections,()=>{s()}));function s(){let e=[];try{e=JSON.parse(i.rawNewCollections),e=Array.isArray(e)?app.utils.filterDuplicatesByKey(e):[];for(let n of e)delete n.created,delete n.updated,n.fields&&=app.utils.filterDuplicatesByKey(n.fields)}catch{}i.newCollections=e}r.push(watch(()=>[i.newCollections,i.deleteMissing],()=>{c()}));function c(){if(i.collectionsToUpdate=[],i.isRawValid)for(let e of i.newCollections){let n=i.oldCollections.find(n=>n.id==e.id);!n?.id||!app.utils.hasCollectionChanges(n,e,i.deleteMissing)||i.collectionsToUpdate.push({new:e,old:n})}}function l(){for(let e of i.newCollections){let n=i.oldCollections.find(n=>n.name==e.name||n.id==e.id);if(!n)continue;let r=e.id,a=n.id;e.id=a;let o=Array.isArray(n.fields)?n.fields:[],s=Array.isArray(e.fields)?e.fields:[];for(let e of s){let n=o.find(n=>n.name==e.name);n&&n.id&&(e.id=n.id)}for(let e of i.newCollections)if(Array.isArray(e.fields))for(let n of e.fields)n.collectionId&&n.collectionId===r&&(n.collectionId=a);for(let n=0;ne.replace(r,a))}i.rawNewCollections=JSON.stringify(i.newCollections,null,2)}function u(){i.rawNewCollections=``,a.value=``,app.store.errors=null}function d(e){i.isLoadingFile=!0;let n=new FileReader;n.onload=async e=>{i.isLoadingFile=!1,a.value=``,i.rawNewCollections=e.target.result,await new Promise(e=>setTimeout(e,0)),i.newCollections.length||(app.toasts.error(`Invalid collections configuration.`),u())},n.onerror=e=>{app.toasts.error(`Failed to load the imported JSON.`),console.warn(e),i.isLoadingFile=!1,a.value=``},n.readAsText(e)}function f(){let e=i.mergeWithOldCollections?app.utils.filterDuplicatesByKey(i.oldCollections.concat(i.newCollections)):i.newCollections;app.modals.openImportCollectionsReview(i.oldCollections,e,{deleteMissing:i.deleteMissing,onsubmit:()=>{u(),o()}})}return t.div({pbEvent:`pageImportCollections`,className:`page page-import-collections`,onunmount:()=>{r.forEach(e=>e?.unwatch())}},wi(),t.div({className:`page-content full-height`},t.header({className:`page-header`},t.nav({className:`breadcrumbs`},t.div({className:`breadcrumb-item`},`Settings`),t.div({className:`breadcrumb-item`},()=>app.store.title))),t.div({className:`wrapper m-b-base`},()=>i.isLoadingOldCollections?t.div({className:`block txt-center`},t.span({className:`loader lg`})):t.div({className:`grid`},t.div({className:`col-lg-12`},t.span({className:`txt-lg m-r-5`},`Paste below the collections configuration you want to import or`),t.label({htmlFor:a.id,className:()=>`btn sm outline ${i.isLoadingFile?`loading`:``}`},t.span({className:`txt`},`Load from JSON file`)),a,t.p({className:`txt-hint`},t.em(null,`You can use the `,t.a({href:`https://pocketbase.io/docs/go-migrations/`,target:`_blank`,rel:`noopener noreferrer`,textContent:`Go`}),` or `,t.a({href:`https://pocketbase.io/docs/js-migrations/`,target:`_blank`,rel:`noopener noreferrer`,textContent:`JS`}),` migrations to manage your collections programmatically in more granular and version controlled manner.`))),t.div({className:`col-lg-12`},t.div({className:`field`},t.label({htmlFor:n+`_collections_field`},`Collections`),t.textarea({id:n+`_collections_field`,name:`collections`,rows:12,className:`txt-code`,spellcheck:!1,autocorrect:!1,autocomplete:`off`,autocapitalize:`off`,value:()=>i.rawNewCollections,oninput:e=>i.rawNewCollections=e.target.value})),t.div({className:()=>`field-help error ${i.rawNewCollections&&!i.isRawValid?``:`hidden`}`},`Invalid collections configuration.`)),t.div({className:()=>`col-lg-12 ${i.isRawValid?``:`hidden`}`},t.div({className:`field`},t.input({id:n+`_merge_checkbox`,type:`checkbox`,className:`switch`,checked:()=>i.mergeWithOldCollections,onchange:e=>i.mergeWithOldCollections=e.target.checked}),t.label({htmlFor:n+`_merge_checkbox`},`Merge with the existing collections`))),t.div({className:()=>`col-lg-12 ${i.isRawValid&&!i.hasChanges?``:`hidden`}`},t.div({className:`alert info`},t.div({className:`content`},t.p(null,`Your collections configuration is already up-to-date!`)))),t.div({className:()=>`col-lg-12 ${i.isRawValid&&i.hasChanges?``:`hidden`}`},t.p({className:`txt-hint txt-bold`},`Detected changes`),t.div({className:`list`},()=>i.collectionsToDelete.map(e=>t.div({className:`list-item`},t.span({className:`label import-change-label danger`,textContent:`Deleted`}),t.div({className:`inline-flex gap-5`},t.strong({textContent:()=>e.name}),t.small({className:()=>`txt-hint ${e.id?``:`hidden`}`,textContent:()=>e.id})))),()=>i.collectionsToUpdate.map(e=>t.div({className:`list-item`},t.span({className:`label import-change-label warning`,textContent:`Changed`}),t.div({className:`inline-flex gap-5`},()=>{if(e.old.name!=e.new.name)return[t.span({className:`txt-strikethrough txt-hint`,textContent:e.old.name}),t.i({className:`ri-arrow-right-line txt-sm`,ariaHidden:!0})]},t.strong({textContent:()=>e.new.name}),t.small({className:()=>`txt-hint ${e.new.id?``:`hidden`}`,textContent:()=>e.new.id})))),()=>i.collectionsToAdd.map(e=>t.div({className:`list-item`},t.span({className:`label import-change-label success`,textContent:`Added`}),t.div({className:`inline-flex gap-5`},t.strong({textContent:()=>e.name}),t.small({className:()=>`txt-hint ${e.id?``:`hidden`}`,textContent:()=>e.id})))))),t.div({className:()=>`col-lg-12 ${i.idReplacableCollections?.length?``:`hidden`}`},t.div({className:`alert warning`},t.div({className:`content`},t.p(null,`Some of the imported collections share the same name and/or fields but are imported with different IDs.`),t.p(null,`You can replace them in the import if you want to:`,t.button({type:`button`,className:`btn warning sm m-l-10`,textContent:`Replace with original IDs`,onclick:l}))))),t.div({className:`col-lg-12`},t.div({className:`flex`},t.button({type:`button`,className:()=>`btn secondary ${i.rawNewCollections?``:`hidden`}`,onclick:u},t.span({className:`txt`},`Clear`)),t.button({type:`button`,className:`btn expanded-lg m-l-auto`,disabled:()=>!i.canReview,onclick:f},t.span({className:`txt`},`Review`)))))),t.footer({className:`page-footer`},app.components.credits())))}window.app=window.app||{},window.app.routes=window.app.routes||{},window.app.routes.fallbackPath=`#/collections`,app.routes.guestOnly=function(e,n){if(app.store._ready)throw Error(`the router is already initialized`);Zi[e]=async e=>{if(app.pb.authStore.isValid&&app.pb.authStore.record?.id){window.location.hash=`#/`;return}app.store.showHeader=!1,app.store.page=await n(e)}},app.routes.superuserOnly=function(e,n){if(app.store._ready)throw Error(`the router is already initialized`);Zi[e]=async e=>{if(!app.pb.authStore.isValid||!app.pb.authStore.record?.id){window.location.hash=`#/login`;return}app.store.showHeader=!0,app.store.page=await n(e)}},app.routes.blank=function(e,n){if(app.store._ready)throw Error(`the router is already initialized`);Zi[e]=async e=>{app.store.showHeader=!1,app.store.page=await n(e)}};var Zi={},Qi;function $i(){Qi&&Qi(),Qi=router(Zi,{fallbackPath:app.routes.fallbackPath})}app.routes.guestOnly(`#/pbinstall/{token}`,async e=>{let{pageInstaller:n}=await H(async()=>{let{pageInstaller:e}=await import(`./pageInstaller-DKuaYpPL.js`);return{pageInstaller:e}},[],import.meta.url);return n(e)}),app.routes.guestOnly(`#/login`,e=>Xr(e)),app.routes.guestOnly(`#/request-password-reset`,async e=>{let{pageRequestSuperuserPasswordReset:n}=await H(async()=>{let{pageRequestSuperuserPasswordReset:e}=await import(`./pageRequestSuperuserPasswordReset-C39AMhGf.js`);return{pageRequestSuperuserPasswordReset:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/confirm-password-reset/{token}`,async e=>{let{pageConfirmPasswordReset:n}=await H(async()=>{let{pageConfirmPasswordReset:e}=await import(`./pageConfirmPasswordReset-DfIjsaaC.js`);return{pageConfirmPasswordReset:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/confirm-verification/{token}`,async e=>{let{pageConfirmVerification:n}=await H(async()=>{let{pageConfirmVerification:e}=await import(`./pageConfirmVerification-BpdljkZV.js`);return{pageConfirmVerification:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/confirm-email-change/{token}`,async e=>{let{pageConfirmEmailChange:n}=await H(async()=>{let{pageConfirmEmailChange:e}=await import(`./pageConfirmEmailChange-v6oufhPX.js`);return{pageConfirmEmailChange:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/oauth2-redirect-success`,async e=>{let{pageOAuth2RedirectSuccess:n}=await H(async()=>{let{pageOAuth2RedirectSuccess:e}=await import(`./pageOAuth2RedirectSuccess-DmZV1eyz.js`);return{pageOAuth2RedirectSuccess:e}},[],import.meta.url);return n(e)}),app.routes.blank(`#/auth/oauth2-redirect-failure`,async e=>{let{pageOAuth2RedirectFailure:n}=await H(async()=>{let{pageOAuth2RedirectFailure:e}=await import(`./pageOAuth2RedirectFailure-CRvz4PXa.js`);return{pageOAuth2RedirectFailure:e}},[],import.meta.url);return n(e)}),app.routes.superuserOnly(`#/collections`,fi),app.routes.superuserOnly(`#/logs`,Ci),app.routes.superuserOnly(`#/settings`,Ni),app.routes.superuserOnly(`#/settings/mail`,Gi),app.routes.superuserOnly(`#/settings/storage`,Ji),app.routes.superuserOnly(`#/settings/backups`,Hi),app.routes.superuserOnly(`#/settings/crons`,Wi),app.routes.superuserOnly(`#/settings/export-collections`,Yi),app.routes.superuserOnly(`#/settings/import-collections`,Xi),app.routes.superuserOnly(`#/settings/sql`,qi);var ea=t;t=new Proxy({},{get(e,n){return function(){let e=arguments?.[0];if(e&&e.pbEvent){let n=e.onmount;e.onmount=r=>{n?.(r),r.dataset.pb=e.pbEvent,document.dispatchEvent(new CustomEvent(`mount:`+e.pbEvent,{detail:r}))};let r=e.onunmount;e.onunmount=n=>{document.dispatchEvent(new CustomEvent(`unmount:`+e.pbEvent,{detail:n})),r?.(n)}}return ea[n](...arguments)}}}),document.body.prepend(t.main({"html-class":`app`,className:()=>`app ${app.store.settings?.meta?.hideControls?`hide-controls`:``}`},Re(),e=>(typeof app.store.page==`function`&&app.store.page(e),app.store.page))),watch(()=>app.store._ready,e=>{e&&$i()}),document.body.appendChild(t.script({type:`module`,src:app.pb.buildURL(`/_/extensions.js`),onload:()=>{app.store._ready=!0},onerror:e=>{console.warn(`Failed to load extensions:`,e),app.store._ready=!0}}));export{ce as n,S as r,ke as t}; \ No newline at end of file diff --git a/ui/dist/assets/pageConfirmEmailChange-DE_eWn0l.js b/ui/dist/assets/pageConfirmEmailChange-v6oufhPX.js similarity index 94% rename from ui/dist/assets/pageConfirmEmailChange-DE_eWn0l.js rename to ui/dist/assets/pageConfirmEmailChange-v6oufhPX.js index c0b6a153..2e7078fa 100644 --- a/ui/dist/assets/pageConfirmEmailChange-DE_eWn0l.js +++ b/ui/dist/assets/pageConfirmEmailChange-v6oufhPX.js @@ -1 +1 @@ -import{n as e,t as n}from"./index-CkzYXztf.js";function r(r){let i=r.params?.token||``,a=e(i);if(!a.newEmail||!a.collectionId){app.toasts.error(`Invalid or expired email change token.`),window.location.hash=`#/`;return}app.store.title=`Confirm email change`;let o=store({password:``,isSubmitting:!1,isSuccess:!1,showPassword:!1});async function s(){if(o.isSubmitting)return;o.isSubmitting=!0;let e=new n(app.pb.baseURL);try{await e.collection(a.collectionId).confirmEmailChange(i,o.password),o.isSuccess=!0}catch(e){app.checkApiError(e),o.isSuccess=!1}o.isSubmitting=!1}return t.div({pbEvent:`pageConfirmEmailChange`,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`},()=>app.store.title)),()=>o.isSuccess?t.div({pbEvent:`confirmEmailChangeAlert`,className:`alert success txt-center`},t.p(null,`The email was successfully changed.`),t.p(null,`You can go back and sign in with your new email address.`)):t.form({pbEvent:`confirmEmailChangeForm`,className:`grid confirm-email-change-form`,onsubmit:e=>{e.preventDefault(),s()}},t.div({className:`col-12`},t.div({className:`content txt-center m-b-sm`},`Type your password to confirm changing your email address to `,t.strong(null,a.newEmail),`:`),t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`password_confirm`},`Password`),t.input({id:`password_confirm`,name:`password`,required:!0,autofocus:!0,type:()=>o.showPassword?`text`:`password`,value:()=>o.password,oninput:e=>o.password=e.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(()=>o.showPassword?`Hide password`:`Show password`),onclick:()=>o.showPassword=!o.showPassword},t.i({className:()=>o.showPassword?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0}))))),t.div({className:`col-12`},t.button({className:()=>`btn lg block ${o.isSubmitting?`loading`:``}`,disabled:()=>o.isSubmitting},t.span({className:`txt`},`Confirm new email`)))))}export{r as pageConfirmEmailChange}; \ No newline at end of file +import{n as e,t as n}from"./index-C6Hdzfsf.js";function r(r){let i=r.params?.token||``,a=e(i);if(!a.newEmail||!a.collectionId){app.toasts.error(`Invalid or expired email change token.`),window.location.hash=`#/`;return}app.store.title=`Confirm email change`;let o=store({password:``,isSubmitting:!1,isSuccess:!1,showPassword:!1});async function s(){if(o.isSubmitting)return;o.isSubmitting=!0;let e=new n(app.pb.baseURL);try{await e.collection(a.collectionId).confirmEmailChange(i,o.password),o.isSuccess=!0}catch(e){app.checkApiError(e),o.isSuccess=!1}o.isSubmitting=!1}return t.div({pbEvent:`pageConfirmEmailChange`,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`},()=>app.store.title)),()=>o.isSuccess?t.div({pbEvent:`confirmEmailChangeAlert`,className:`alert success txt-center`},t.p(null,`The email was successfully changed.`),t.p(null,`You can go back and sign in with your new email address.`)):t.form({pbEvent:`confirmEmailChangeForm`,className:`grid confirm-email-change-form`,onsubmit:e=>{e.preventDefault(),s()}},t.div({className:`col-12`},t.div({className:`content txt-center m-b-sm`},`Type your password to confirm changing your email address to `,t.strong(null,a.newEmail),`:`),t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`password_confirm`},`Password`),t.input({id:`password_confirm`,name:`password`,required:!0,autofocus:!0,type:()=>o.showPassword?`text`:`password`,value:()=>o.password,oninput:e=>o.password=e.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(()=>o.showPassword?`Hide password`:`Show password`),onclick:()=>o.showPassword=!o.showPassword},t.i({className:()=>o.showPassword?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0}))))),t.div({className:`col-12`},t.button({className:()=>`btn lg block ${o.isSubmitting?`loading`:``}`,disabled:()=>o.isSubmitting},t.span({className:`txt`},`Confirm new email`)))))}export{r as pageConfirmEmailChange}; \ No newline at end of file diff --git a/ui/dist/assets/pageConfirmPasswordReset-pcaeA4wC.js b/ui/dist/assets/pageConfirmPasswordReset-DfIjsaaC.js similarity index 96% rename from ui/dist/assets/pageConfirmPasswordReset-pcaeA4wC.js rename to ui/dist/assets/pageConfirmPasswordReset-DfIjsaaC.js index 5c2b9bfd..9b30070b 100644 --- a/ui/dist/assets/pageConfirmPasswordReset-pcaeA4wC.js +++ b/ui/dist/assets/pageConfirmPasswordReset-DfIjsaaC.js @@ -1 +1 @@ -import{n as e,t as n}from"./index-CkzYXztf.js";function r(r){let i=r.params?.token||``,a=e(i);if(!a.email||!a.collectionId){app.toasts.error(`Invalid or expired password reset token.`),window.location.hash=`#/`;return}app.store.title=`Confirm password reset`;let o=store({newPassword:``,newPasswordConfirm:``,showNewPassword:!1,showNewPasswordConfirm:!1,isSubmitting:!1,isSuccess:!1});async function s(){if(o.isSubmitting)return;o.isSubmitting=!0;let e=new n(app.pb.baseURL);try{await e.collection(a.collectionId).confirmPasswordReset(i,o.newPassword,o.newPasswordConfirm),o.isSuccess=!0}catch(e){app.checkApiError(e)}o.isSubmitting=!1}return t.div({pbEvent:`pageConfirmPasswordReset`,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`},()=>app.store.title)),()=>o.isSuccess?t.div({pbEvent:`confirmPasswordResetAlert`,className:`alert success txt-center`},t.p(null,`The password was successfully changed.`),t.p(null,`You can go back to sign in with your new password.`)):t.form({pbEvent:`confirmPasswordResetForm`,className:`grid confirm-password-reset-form`,onsubmit:e=>{e.preventDefault(),s()}},t.div({className:`col-12`},t.div({className:`content txt-center m-b-sm`},`Type your new password for `,t.strong(null,a.email),`:`),t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`newPassword`},`New password`),t.input({id:`newPassword`,name:`password`,required:!0,autofocus:!0,autocomplete:`new-password`,type:()=>o.showNewPassword?`text`:`password`,value:()=>o.newPassword,oninput:e=>o.newPassword=e.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(()=>o.showNewPassword?`Hide password`:`Show password`),onclick:()=>o.showNewPassword=!o.showNewPassword},t.i({className:()=>o.showNewPassword?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0}))))),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`newPasswordConfirm`},`New password confirm`),t.input({id:`newPasswordConfirm`,name:`passwordConfirm`,required:!0,autocomplete:`new-password`,type:()=>o.showNewPasswordConfirm?`text`:`password`,value:()=>o.newPasswordConfirm,oninput:e=>o.newPasswordConfirm=e.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(()=>o.showNewPasswordConfirm?`Hide password`:`Show password`),onclick:()=>o.showNewPasswordConfirm=!o.showNewPasswordConfirm},t.i({className:()=>o.showNewPasswordConfirm?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0}))))),t.div({className:`col-12`},t.button({className:()=>`btn lg block ${o.isSubmitting?`loading`:``}`,disabled:()=>o.isSubmitting},t.span({className:`txt`},`Set new password`)))))}export{r as pageConfirmPasswordReset}; \ No newline at end of file +import{n as e,t as n}from"./index-C6Hdzfsf.js";function r(r){let i=r.params?.token||``,a=e(i);if(!a.email||!a.collectionId){app.toasts.error(`Invalid or expired password reset token.`),window.location.hash=`#/`;return}app.store.title=`Confirm password reset`;let o=store({newPassword:``,newPasswordConfirm:``,showNewPassword:!1,showNewPasswordConfirm:!1,isSubmitting:!1,isSuccess:!1});async function s(){if(o.isSubmitting)return;o.isSubmitting=!0;let e=new n(app.pb.baseURL);try{await e.collection(a.collectionId).confirmPasswordReset(i,o.newPassword,o.newPasswordConfirm),o.isSuccess=!0}catch(e){app.checkApiError(e)}o.isSubmitting=!1}return t.div({pbEvent:`pageConfirmPasswordReset`,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`},()=>app.store.title)),()=>o.isSuccess?t.div({pbEvent:`confirmPasswordResetAlert`,className:`alert success txt-center`},t.p(null,`The password was successfully changed.`),t.p(null,`You can go back to sign in with your new password.`)):t.form({pbEvent:`confirmPasswordResetForm`,className:`grid confirm-password-reset-form`,onsubmit:e=>{e.preventDefault(),s()}},t.div({className:`col-12`},t.div({className:`content txt-center m-b-sm`},`Type your new password for `,t.strong(null,a.email),`:`),t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`newPassword`},`New password`),t.input({id:`newPassword`,name:`password`,required:!0,autofocus:!0,autocomplete:`new-password`,type:()=>o.showNewPassword?`text`:`password`,value:()=>o.newPassword,oninput:e=>o.newPassword=e.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(()=>o.showNewPassword?`Hide password`:`Show password`),onclick:()=>o.showNewPassword=!o.showNewPassword},t.i({className:()=>o.showNewPassword?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0}))))),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`newPasswordConfirm`},`New password confirm`),t.input({id:`newPasswordConfirm`,name:`passwordConfirm`,required:!0,autocomplete:`new-password`,type:()=>o.showNewPasswordConfirm?`text`:`password`,value:()=>o.newPasswordConfirm,oninput:e=>o.newPasswordConfirm=e.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(()=>o.showNewPasswordConfirm?`Hide password`:`Show password`),onclick:()=>o.showNewPasswordConfirm=!o.showNewPasswordConfirm},t.i({className:()=>o.showNewPasswordConfirm?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0}))))),t.div({className:`col-12`},t.button({className:()=>`btn lg block ${o.isSubmitting?`loading`:``}`,disabled:()=>o.isSubmitting},t.span({className:`txt`},`Set new password`)))))}export{r as pageConfirmPasswordReset}; \ No newline at end of file diff --git a/ui/dist/assets/pageConfirmVerification-Ov2sOAhE.js b/ui/dist/assets/pageConfirmVerification-BpdljkZV.js similarity index 95% rename from ui/dist/assets/pageConfirmVerification-Ov2sOAhE.js rename to ui/dist/assets/pageConfirmVerification-BpdljkZV.js index 7480a946..7314ba34 100644 --- a/ui/dist/assets/pageConfirmVerification-Ov2sOAhE.js +++ b/ui/dist/assets/pageConfirmVerification-BpdljkZV.js @@ -1 +1 @@ -import{n as e,t as n}from"./index-CkzYXztf.js";function r(r){let i=r.params?.token||``,a=e(i);if(!a.email||!a.collectionId){app.toasts.error(`Invalid or expired verification token.`),window.location.hash=`#/`;return}app.store.title=`Confirm verification`;let o=store({isConfirming:!1,isConfirmSuccess:!1,isResending:!1,isResendSuccess:!1});s();async function s(){if(o.isConfirming)return;o.isConfirming=!0;let e=new n(app.pb.baseURL);try{await e.collection(a.collectionId).confirmVerification(i),o.isConfirmSuccess=!0}catch{o.isConfirmSuccess=!1}o.isConfirming=!1}async function c(){if(o.isResending)return;o.isResending=!0;let e=new n(`../`);try{await e.collection(a.collectionId).requestVerification(a.email),o.isResendSuccess=!0}catch(e){app.checkApiError(e),o.isResendSuccess=!1}o.isResending=!1}return t.div({pbEvent:`pageConfirmVerification`,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`},()=>app.store.title)),()=>o.isConfirming?t.div({className:`block txt-center`},t.span({className:`loader`},`Please wait...`)):o.isConfirmSuccess?t.div({pbEvent:`confirmVerificationSuccessAlert`,className:`alert success txt-center`},t.p(null,`Successfully verified `,t.strong(null,a.email),`.`)):o.isResendSuccess?t.div({pbEvent:`confirmVerificationResendAlert`,className:`alert success txt-center`},t.p(null,`Please check your email for the new verification link.`)):[t.div({pbEvent:`confirmVerificationErrorAlert`,className:`alert danger txt-center m-b-base`},t.p(null,`Invalid or expired verification token.`)),t.button({type:`button`,className:()=>`btn transparent lg block ${o.isResending?`loading`:``}`,disabled:()=>o.isResending,onclick:()=>c()},t.span({className:`txt`},`Resend`))])}export{r as pageConfirmVerification}; \ No newline at end of file +import{n as e,t as n}from"./index-C6Hdzfsf.js";function r(r){let i=r.params?.token||``,a=e(i);if(!a.email||!a.collectionId){app.toasts.error(`Invalid or expired verification token.`),window.location.hash=`#/`;return}app.store.title=`Confirm verification`;let o=store({isConfirming:!1,isConfirmSuccess:!1,isResending:!1,isResendSuccess:!1});s();async function s(){if(o.isConfirming)return;o.isConfirming=!0;let e=new n(app.pb.baseURL);try{await e.collection(a.collectionId).confirmVerification(i),o.isConfirmSuccess=!0}catch{o.isConfirmSuccess=!1}o.isConfirming=!1}async function c(){if(o.isResending)return;o.isResending=!0;let e=new n(`../`);try{await e.collection(a.collectionId).requestVerification(a.email),o.isResendSuccess=!0}catch(e){app.checkApiError(e),o.isResendSuccess=!1}o.isResending=!1}return t.div({pbEvent:`pageConfirmVerification`,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`},()=>app.store.title)),()=>o.isConfirming?t.div({className:`block txt-center`},t.span({className:`loader`},`Please wait...`)):o.isConfirmSuccess?t.div({pbEvent:`confirmVerificationSuccessAlert`,className:`alert success txt-center`},t.p(null,`Successfully verified `,t.strong(null,a.email),`.`)):o.isResendSuccess?t.div({pbEvent:`confirmVerificationResendAlert`,className:`alert success txt-center`},t.p(null,`Please check your email for the new verification link.`)):[t.div({pbEvent:`confirmVerificationErrorAlert`,className:`alert danger txt-center m-b-base`},t.p(null,`Invalid or expired verification token.`)),t.button({type:`button`,className:()=>`btn transparent lg block ${o.isResending?`loading`:``}`,disabled:()=>o.isResending,onclick:()=>c()},t.span({className:`txt`},`Resend`))])}export{r as pageConfirmVerification}; \ No newline at end of file diff --git a/ui/dist/assets/pageInstaller-CDIahrVC.js b/ui/dist/assets/pageInstaller-DKuaYpPL.js similarity index 97% rename from ui/dist/assets/pageInstaller-CDIahrVC.js rename to ui/dist/assets/pageInstaller-DKuaYpPL.js index bd82e20e..20307bcd 100644 --- a/ui/dist/assets/pageInstaller-CDIahrVC.js +++ b/ui/dist/assets/pageInstaller-DKuaYpPL.js @@ -1 +1 @@ -import{n as e,r as n}from"./index-CkzYXztf.js";function r(r){let i=r.params?.token||``;if(e(i).type!=`auth`||n(i)){app.toasts.error(`The installer token is invalid or has expired.`),window.location.hash=`#/`;return}app.store.title=`Setup your PocketBase instance`;let a=store({email:``,password:``,passwordConfirm:``,showPassword:!1,showPasswordConfirm:!1,isSubmitting:!1,isUploading:!1,get isBusy(){return a.isSubmitting||a.isUploading}});async function o(){if(!a.isBusy){a.isSubmitting=!0;try{await app.pb.collection(`_superusers`).create({email:a.email,password:a.password,passwordConfirm:a.passwordConfirm},{headers:{Authorization:i}}),await app.pb.collection(`_superusers`).authWithPassword(a.email,a.password),window.location.hash=`#/`}catch(e){app.checkApiError(e)}a.isSubmitting=!1}}let s=`backupFileInput`;function c(){let e=document.getElementById(s);e&&(e.value=``)}function l(e){e&&app.modals.confirm(t.h6(null,`Note that we don't perform validations for the uploaded backup files. Proceed with caution and only if you trust the file source.\n\nDo you really want to upload and initialize "${e.name}"?`),()=>{u(e)},()=>{c()})}async function u(e){if(!(!e||a.isBusy)){a.isUploading=!0;try{await app.pb.backups.upload({file:e},{headers:{Authorization:i}}),await app.pb.backups.restore(e.name,{headers:{Authorization:i}}),app.toasts.info(`Please wait while extracting the uploaded archive!`),await new Promise(e=>setTimeout(e,3e3)),window.location.href=`#/`}catch(e){app.checkApiError(e)}c(),a.isUploading=!1}}return t.div({pbEvent:`pageInstaller`,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`},()=>app.store.title)),t.form({pbEvent:`installerForm`,className:`grid installer-form`,onsubmit:e=>{e.preventDefault(),o(a)}},t.div({className:`col-12 txt-center`},`Create your first superuser account in order to continue:`),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:`superuser_email`},`Email`),t.input({id:`superuser_email`,name:`email`,type:`email`,required:!0,autofocus:!0,autocomplete:`off`,disabled:()=>a.isBusy,value:()=>a.email,oninput:e=>a.email=e.target.value}))),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`superuser_password`},`Password`),t.input({id:`superuser_password`,name:`password`,min:10,required:!0,disabled:()=>a.isBusy,type:()=>a.showPassword?`text`:`password`,value:()=>a.password,oninput:e=>a.password=e.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(()=>a.showPassword?`Hide password`:`Show password`),onclick:()=>a.showPassword=!a.showPassword},t.i({className:()=>a.showPassword?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0})))),t.div({className:`field-help`},`Recommended at least 10 characters.`)),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`superuser_password_confirm`},`Password confirm`),t.input({id:`superuser_password_confirm`,name:`passwordConfirm`,required:!0,disabled:()=>a.isBusy,type:()=>a.showPasswordConfirm?`text`:`password`,value:()=>a.passwordConfirm,oninput:e=>a.passwordConfirm=e.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(()=>a.showPasswordConfirm?`Hide password`:`Show password`),onclick:()=>a.showPasswordConfirm=!a.showPasswordConfirm},t.i({className:()=>a.showPasswordConfirm?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0}))))),t.div({className:`col-12`},t.button({className:()=>`btn lg next block ${a.isSubmitting?`loading`:``}`,disabled:()=>a.isBusy},t.span({className:`txt`},`Create superuser and login`),t.i({className:`ri-arrow-right-line`,ariaHidden:!0})))),t.hr(),t.label({htmlFor:s,className:()=>`btn secondary transparent lg block ${a.isBusy?`disabled`:``} ${a.isUploading?`loading`:``}`},t.i({className:`ri-upload-cloud-line`,ariaHidden:!0}),t.span({className:`txt`},`Or initialize from backup`)),t.input({id:s,type:`file`,className:`hidden`,accept:`.zip`,onchange:e=>{l(e.target?.files?.[0])}}))}export{r as pageInstaller}; \ No newline at end of file +import{n as e,r as n}from"./index-C6Hdzfsf.js";function r(r){let i=r.params?.token||``;if(e(i).type!=`auth`||n(i)){app.toasts.error(`The installer token is invalid or has expired.`),window.location.hash=`#/`;return}app.store.title=`Setup your PocketBase instance`;let a=store({email:``,password:``,passwordConfirm:``,showPassword:!1,showPasswordConfirm:!1,isSubmitting:!1,isUploading:!1,get isBusy(){return a.isSubmitting||a.isUploading}});async function o(){if(!a.isBusy){a.isSubmitting=!0;try{await app.pb.collection(`_superusers`).create({email:a.email,password:a.password,passwordConfirm:a.passwordConfirm},{headers:{Authorization:i}}),await app.pb.collection(`_superusers`).authWithPassword(a.email,a.password),window.location.hash=`#/`}catch(e){app.checkApiError(e)}a.isSubmitting=!1}}let s=`backupFileInput`;function c(){let e=document.getElementById(s);e&&(e.value=``)}function l(e){e&&app.modals.confirm(t.h6(null,`Note that we don't perform validations for the uploaded backup files. Proceed with caution and only if you trust the file source.\n\nDo you really want to upload and initialize "${e.name}"?`),()=>{u(e)},()=>{c()})}async function u(e){if(!(!e||a.isBusy)){a.isUploading=!0;try{await app.pb.backups.upload({file:e},{headers:{Authorization:i}}),await app.pb.backups.restore(e.name,{headers:{Authorization:i}}),app.toasts.info(`Please wait while extracting the uploaded archive!`),await new Promise(e=>setTimeout(e,3e3)),window.location.href=`#/`}catch(e){app.checkApiError(e)}c(),a.isUploading=!1}}return t.div({pbEvent:`pageInstaller`,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`},()=>app.store.title)),t.form({pbEvent:`installerForm`,className:`grid installer-form`,onsubmit:e=>{e.preventDefault(),o(a)}},t.div({className:`col-12 txt-center`},`Create your first superuser account in order to continue:`),t.div({className:`col-12`},t.div({className:`field`},t.label({htmlFor:`superuser_email`},`Email`),t.input({id:`superuser_email`,name:`email`,type:`email`,required:!0,autofocus:!0,autocomplete:`off`,disabled:()=>a.isBusy,value:()=>a.email,oninput:e=>a.email=e.target.value}))),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`superuser_password`},`Password`),t.input({id:`superuser_password`,name:`password`,min:10,required:!0,disabled:()=>a.isBusy,type:()=>a.showPassword?`text`:`password`,value:()=>a.password,oninput:e=>a.password=e.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(()=>a.showPassword?`Hide password`:`Show password`),onclick:()=>a.showPassword=!a.showPassword},t.i({className:()=>a.showPassword?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0})))),t.div({className:`field-help`},`Recommended at least 10 characters.`)),t.div({className:`col-12`},t.div({className:`fields`},t.div({className:`field`},t.label({htmlFor:`superuser_password_confirm`},`Password confirm`),t.input({id:`superuser_password_confirm`,name:`passwordConfirm`,required:!0,disabled:()=>a.isBusy,type:()=>a.showPasswordConfirm?`text`:`password`,value:()=>a.passwordConfirm,oninput:e=>a.passwordConfirm=e.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(()=>a.showPasswordConfirm?`Hide password`:`Show password`),onclick:()=>a.showPasswordConfirm=!a.showPasswordConfirm},t.i({className:()=>a.showPasswordConfirm?`ri-eye-off-line`:`ri-eye-line`,ariaHidden:!0}))))),t.div({className:`col-12`},t.button({className:()=>`btn lg next block ${a.isSubmitting?`loading`:``}`,disabled:()=>a.isBusy},t.span({className:`txt`},`Create superuser and login`),t.i({className:`ri-arrow-right-line`,ariaHidden:!0})))),t.hr(),t.label({htmlFor:s,className:()=>`btn secondary transparent lg block ${a.isBusy?`disabled`:``} ${a.isUploading?`loading`:``}`},t.i({className:`ri-upload-cloud-line`,ariaHidden:!0}),t.span({className:`txt`},`Or initialize from backup`)),t.input({id:s,type:`file`,className:`hidden`,accept:`.zip`,onchange:e=>{l(e.target?.files?.[0])}}))}export{r as pageInstaller}; \ No newline at end of file diff --git a/ui/dist/index.html b/ui/dist/index.html index ecb1b2fd..e2ffcd54 100644 --- a/ui/dist/index.html +++ b/ui/dist/index.html @@ -13,7 +13,7 @@ - + diff --git a/ui/src/collections/oauth2/oidcOptions.js b/ui/src/collections/oauth2/oidcOptions.js index d831a5c8..964f6986 100644 --- a/ui/src/collections/oauth2/oidcOptions.js +++ b/ui/src/collections/oauth2/oidcOptions.js @@ -229,3 +229,6 @@ window.app.oauth2.oidc = function(providerInfo, namePrefix, data) { ), ); }; + +window.app.oauth2.oidc2 = window.app.oauth2.oidc; +window.app.oauth2.oidc3 = window.app.oauth2.oidc;