/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@indux/indux@0.5.14/src/scripts/indux.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
var Indux=function(exports){"use strict";var indux_components={},hasRequiredIndux_components;function requireIndux_components(){if(hasRequiredIndux_components)return indux_components;function e(){window.InduxComponentsRegistry&&window.InduxComponentsRegistry.initialize(),window.InduxComponentsLoader&&window.InduxComponentsLoader.initialize(),window.InduxComponentsProcessor&&window.InduxComponentsProcessor.initialize(),window.InduxComponentsSwapping&&window.InduxComponentsSwapping.initialize(),window.InduxComponentsMutation&&window.InduxComponentsMutation.initialize(),window.InduxComponentsUtils&&window.InduxComponentsUtils.initialize?.(),window.__induxComponentsInitialized=!0,window.dispatchEvent(new CustomEvent("indux:components-ready"))}return hasRequiredIndux_components=1,window.InduxComponentsRegistry={manifest:null,registered:new Set,preloaded:[],initialize(){try{const e=new XMLHttpRequest;if(e.open("GET","/manifest.json?t="+Date.now(),!1),e.setRequestHeader("Cache-Control","no-cache, no-store, must-revalidate"),e.setRequestHeader("Pragma","no-cache"),e.setRequestHeader("Expires","0"),e.send(null),200===e.status){this.manifest=JSON.parse(e.responseText);[...this.manifest?.preloadedComponents||[],...this.manifest?.components||[]].forEach((e=>{const t=e.split("/").pop().replace(".html","");this.registered.add(t)})),this.preloaded=(this.manifest?.preloadedComponents||[]).map((e=>e.split("/").pop().replace(".html","")))}else console.warn("[Indux] Failed to load manifest.json (HTTP",e.status+")")}catch(e){console.warn("[Indux] Failed to load manifest.json:",e.message)}}},window.InduxComponentsLoader={cache:{},initialize(){this.cache={};const e=window.InduxComponentsRegistry;e&&Array.isArray(e.preloaded)&&e.preloaded.forEach((e=>{this.loadComponent(e).then((()=>{}))}))},async loadComponent(e){if(this.cache[e])return this.cache[e];const t=window.InduxComponentsRegistry;if(!t||!t.manifest)return console.warn("[Indux] Manifest not loaded, cannot load component:",e),null;const i=(t.manifest.preloadedComponents||[]).concat(t.manifest.components||[]).find((t=>t.split("/").pop().replace(".html","")===e));if(!i)return console.warn("[Indux] Component",e,"not found in manifest."),null;try{const t=await fetch("/"+i);if(!t.ok)return console.warn("[Indux] HTML file not found for component",e,"at path:",i,"(HTTP",t.status+")"),null;const n=await t.text();return this.cache[e]=n,n}catch(t){return console.warn("[Indux] Failed to load component",e,"from",i+":",t.message),null}}},window.InduxComponentsProcessor={async processComponent(e,t){const i=e.tagName.toLowerCase().replace("x-",""),n=window.InduxComponentsRegistry,s=window.InduxComponentsLoader;if(!n||!s)return;if(!n.registered.has(i))return;if(e.hasAttribute("data-pre-rendered")||e.hasAttribute("data-processed"))return;const r=await s.loadComponent(i);if(!r)return void e.replaceWith(document.createComment(` Failed to load component: ${i} `));const o=document.createElement("div");o.innerHTML=r.trim();const a=Array.from(o.children);if(0===a.length)return void e.replaceWith(document.createComment(` Empty component: ${i} `));const c=[],l=e=>{"script"===e.tagName.toLowerCase()?(c.push({content:e.textContent,type:e.getAttribute("type")||"text/javascript",src:e.getAttribute("src"),async:e.hasAttribute("async"),defer:e.hasAttribute("defer")}),e.remove()):Array.from(e.children).forEach(l)};a.forEach(l);const u={};Array.from(e.attributes).forEach((e=>{if(e.name!==i&&"class"!==e.name&&!e.name.startsWith("data-")&&(u[e.name]=e.value,u[e.name.toLowerCase()]=e.value,e.name.startsWith(":"))){const t=e.name.substring(1);u[t]=e.value,u[t.toLowerCase()]=e.value}}));const d=e=>{Array.from(e.attributes).forEach((t=>{const i=t.value.trim();if(i.includes("$modify(")){const n=i.match(/\$modify\(['"]([^'"]+)['"]\)/);if(n){const s=n[1].toLowerCase(),r=u[s]||"";if("class"===t.name){const t=(e.getAttribute("class")||"").replace(new RegExp(`$modify(['"]${s}['"])`,"i"),r).split(" ").filter(Boolean).join(" ");e.setAttribute("class",t)}else if("x-icon"===t.name)e.setAttribute(t.name,r);else if("x-show"===t.name||"x-if"===t.name)if(i!==`$modify('${s}')`){const n=i.replace(/\$modify\(['"]([^'"]+)['"]\)/g,((e,t)=>u[t.toLowerCase()]||""?"true":"false"));e.setAttribute(t.name,n)}else{const i=r&&""!==r.trim()?"true":"false";e.setAttribute(t.name,i)}else if(t.name.startsWith("x-")||t.name.startsWith(":")||t.name.startsWith("@")||t.name.startsWith("x-bind:")||t.name.startsWith("x-on:"))if(i!==`$modify('${s}')`){const n=i.replace(/\$modify\(['"]([^'"]+)['"]\)/g,((e,n)=>{const s=u[n.toLowerCase()]||"";if(!s||""===s.trim()||/^[\r\n\t\s]+$/.test(s))return i.includes("||")?"null":"''";if(s.startsWith("$")){if(("x-for"===t.name||"x-if"===t.name||"x-show"===t.name)&&s.startsWith("$x")&&!s.includes("??")){let e=s.replace(/\./g,"?.");return"x-for"===t.name?`${e} ?? []`:`${e} ?? false`}return s}return"x-for"===t.name||"x-if"===t.name||"x-show"===t.name?s:`'${s.replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")}'`}));e.setAttribute(t.name,n)}else if(!r||""===r.trim()||/^[\r\n\t\s]+$/.test(r))e.removeAttribute(t.name);else if(r.startsWith("$"))e.setAttribute(t.name,r);else{const i=`'${r.replace(/'/g,"\\'").replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")}'`;e.setAttribute(t.name,i)}else e.setAttribute(t.name,r)}}})),Array.from(e.children).forEach(d)};if(a.forEach(d),a.forEach((n=>{Array.from(e.attributes).forEach((e=>{if("class"===e.name){const t=`${n.getAttribute("class")||""} ${e.value}`.trim();n.setAttribute("class",t)}else e.name.startsWith("x-")||e.name.startsWith(":")||e.name.startsWith("@")?n.setAttribute(e.name,e.value):(e.name===i||e.name.startsWith("data-"))&&"data-order"!==e.name&&"x-route"!==e.name&&"data-head"!==e.name||n.setAttribute(e.name,e.value)})),t&&n.setAttribute("data-component",t)})),a.length>0){const t=a[0];Array.from(e.attributes).forEach((e=>{if("class"===e.name)return;const n=["data-order","x-route","data-component","data-head","x-route-*","data-route-*","x-tabpanel"].some((t=>e.name===t||e.name.startsWith(t.replace("*",""))));if((!(e.name.startsWith("x-")||e.name.startsWith(":")||e.name.startsWith("@")||e.name!==i&&!e.name.startsWith("data-")||"data-order"===e.name||"x-route"===e.name||"data-head"===e.name)||n)&&!["data-original-placeholder","data-pre-rendered","data-processed"].includes(e.name))if(e.name.startsWith("x-")||e.name.startsWith(":")||e.name.startsWith("@"))if("x-data"===e.name&&t.hasAttribute("x-data")){const i=t.getAttribute("x-data");if(i.trim().startsWith("{")&&e.value.trim().startsWith("{")){const n=i.trim().slice(1,-1).trim(),s=e.value.trim().slice(1,-1).trim(),r=`{ ${n}${n&&s?", ":""}${s} }`;t.setAttribute("x-data",r)}else t.setAttribute(e.name,e.value)}else t.setAttribute(e.name,e.value);else t.setAttribute(e.name,e.value)}))}const h=e.parentElement;if(!h||!document.contains(e))return;const m=document.createDocumentFragment();a.forEach((e=>m.appendChild(e))),h.replaceChild(m,e),c.length>0&&setTimeout((()=>{c.forEach((e=>{if(e.src){const t=document.createElement("script");t.src=e.src,t.type=e.type,e.async&&(t.async=!0),e.defer&&(t.defer=!0),document.head.appendChild(t)}else if(e.content)try{new Function(e.content)()}catch(e){console.error(`[Indux] Error executing script in component ${i}:`,e)}}))}),0)},initialize(){}},function(){let e={};const t=new Set,i=new Map,n=new Map;function s(t){return e[t]?e[t]++:e[t]=1,`${t}-${e[t]}`}function r(e,t){e&&Array.from(e.children).map((e=>`${e.tagName}[data-component=${e.getAttribute("data-component")||""}]`)).join(", ")}window.InduxComponentsSwapping={async swapIn(e){if(e.hasAttribute("data-swapped"))return;const o=window.InduxComponentsProcessor;if(!o)return;const a=e.tagName.toLowerCase().replace("x-","");let c=e.getAttribute("data-component");if(c||(c=s(a),e.setAttribute("data-component",c)),!n.has(c)){const t=e.cloneNode(!0);t.setAttribute("data-original-placeholder",""),t.setAttribute("data-component",c),n.set(c,t)}r(e.parentNode),await o.processComponent(e,c),t.add(c);const l=e.getAttribute("x-route");i.set(c,l),r(e.parentNode||document.body)},revert(e){if(!t.has(e))return;const s=Array.from(document.querySelectorAll(`[data-component="${e}"]`));if(0===s.length)return;const o=s[0].parentNode,a=n.get(e);if(r(o),s.forEach((e=>{e.remove()})),a&&o&&!o.contains(a)){const e=parseInt(a.getAttribute("data-order"))||0;let t=!1;for(let i=0;i<o.children.length;i++){const n=o.children[i];if(e<(parseInt(n.getAttribute("data-order"))||0)){o.insertBefore(a,n),t=!0;break}}t||o.appendChild(a)}t.delete(e),i.delete(e),n.delete(e),r(o)},async processAll(){e={};if(!window.InduxComponentsRegistry)return;const n=window.InduxRouting,r=Array.from(document.querySelectorAll("*")).filter((e=>e.tagName.toLowerCase().startsWith("x-")&&!e.hasAttribute("data-pre-rendered")&&!e.hasAttribute("data-processed")));if(n){const e=window.location.pathname,n="/"===e?"/":e.replace(/^\/+|\/+$/g,"");for(const e of Array.from(t)){const t=i.get(e);!t||window.InduxRouting.matchesCondition(n,t)||this.revert(e)}}for(const e of r){const t=e.tagName.toLowerCase().replace("x-","");let i=e.getAttribute("data-component");i||(i=s(t),e.setAttribute("data-component",i));const r=e.getAttribute("x-route");if(n){const t=window.location.pathname,i="/"===t?"/":t.replace(/^\/+|\/+$/g,"");(!r||window.InduxRouting.matchesCondition(i,r))&&await this.swapIn(e)}else await this.swapIn(e)}},initialize(){this.processAll().then((()=>{window.dispatchEvent(new CustomEvent("indux:components-processed"))})),window.InduxRouting&&window.addEventListener("indux:route-change",(()=>{this.processAll().then((()=>{window.dispatchEvent(new CustomEvent("indux:components-processed"))}))}))}}}(),window.InduxComponentsMutation={async processAllPlaceholders(){const e=window.InduxComponentsProcessor,t=window.InduxRouting;if(!e)return;const i=Array.from(document.querySelectorAll("*")).filter((e=>e.tagName.toLowerCase().startsWith("x-")&&!e.hasAttribute("data-pre-rendered")&&!e.hasAttribute("data-processed")));for(const n of i){if(t){const e=n.getAttribute("x-route"),t=window.location.pathname,i="/"===t?"/":t.replace(/^\/+|\/+$/g,"");if(!(!e||window.InduxRouting.matchesCondition(i,e)))continue}await e.processComponent(n)}},initialize(){const e=window.InduxComponentsProcessor,t=window.InduxRouting;if(!e)return;this.processAllPlaceholders();const i=new MutationObserver((async i=>{for(const n of i)for(const i of n.addedNodes){if(1===i.nodeType&&i.tagName.toLowerCase().startsWith("x-")&&!i.hasAttribute("data-pre-rendered")&&!i.hasAttribute("data-processed")){if(t){const e=i.getAttribute("x-route"),t=window.location.pathname,n="/"===t?"/":t.replace(/^\/+|\/+$/g,"");if(!(!e||window.InduxRouting.matchesCondition(n,e)))continue}await e.processComponent(i)}if(1===i.nodeType){const n=Array.from(i.querySelectorAll("*")).filter((e=>e.tagName.toLowerCase().startsWith("x-")&&!e.hasAttribute("data-pre-rendered")&&!e.hasAttribute("data-processed")));for(const i of n){if(t){const e=i.getAttribute("x-route"),t=window.location.pathname,n="/"===t?"/":t.replace(/^\/+|\/+$/g,"");if(!(!e||window.InduxRouting.matchesCondition(n,e)))continue}await e.processComponent(i)}}}}));document.body?i.observe(document.body,{childList:!0,subtree:!0}):document.addEventListener("DOMContentLoaded",(()=>{i.observe(document.body,{childList:!0,subtree:!0})}))}},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e(),window.InduxComponents={initialize:e},indux_components}requireIndux_components();var indux_appwrite_auth={},hasRequiredIndux_appwrite_auth;function requireIndux_appwrite_auth(){if(hasRequiredIndux_appwrite_auth)return indux_appwrite_auth;async function e(){if(window.InduxComponentsRegistry?.manifest)return window.InduxComponentsRegistry.manifest;try{const e=await fetch("/manifest.json");return await e.json()}catch(e){return null}}async function t(){const t=await e();if(!t?.appwrite)return null;const i=t.appwrite,n=i.endpoint,s=i.projectId,r=i.devKey;if(!n||!s)return null;const o=i.auth?.methods||["magic","oauth"],a=o.includes("guest-auto"),c=o.includes("guest-manual"),l=a||c,u=o.includes("magic"),d=o.includes("oauth"),h=!!i.auth?.teams,m=i.auth?.teams?.permanent||null,p=i.auth?.teams?.template||null,f=i.auth?.teams?.pollInterval||null,g=i.auth?.roles?.permanent||null,w=i.auth?.roles?.template||null;return{endpoint:n,projectId:s,devKey:r,authMethods:o,guest:l,guestAuto:a,guestManual:c,anonymous:a,magic:u,oauth:d,teams:h,permanentTeams:m,templateTeams:p,teamsPollInterval:f,memberRoles:g||w?{...g||{},...w||{}}:i.auth?.memberRoles||null,permanentRoles:g,templateRoles:w,creatorRole:i.auth?.creatorRole||null}}hasRequiredIndux_appwrite_auth=1;let i=null,n=null,s=null,r=null;function o(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t="indux:auth:state";function i(e){try{const i={isAuthenticated:e.isAuthenticated,isAnonymous:e.isAnonymous,user:e.user,session:e.session,magicLinkSent:e.magicLinkSent,magicLinkExpired:e.magicLinkExpired,error:e.error};localStorage.setItem(t,JSON.stringify(i))}catch(e){}}window.addEventListener("storage",(e=>{if(e.key===t&&e.newValue)try{const t=JSON.parse(e.newValue),i=Alpine.store("auth");i&&(i.isAuthenticated=t.isAuthenticated,i.isAnonymous=t.isAnonymous,i.user=t.user,i.session=t.session,i.magicLinkSent=t.magicLinkSent||!1,i.magicLinkExpired=t.magicLinkExpired||!1,i.error=t.error)}catch(e){}}));const n={user:null,session:null,isAuthenticated:!1,isAnonymous:!1,inProgress:!1,error:null,magicLinkSent:!1,magicLinkExpired:!1,teams:[],currentTeam:null,_teamsPollInterval:null,_teamsRealtimeUnsubscribe:null,_teamsRealtimeSubscribing:!1,newTeamName:"",updateTeamNameInput:"",inviteEmail:"",inviteRoles:[],currentTeamMemberships:[],deletedTemplateTeams:[],deletedTemplateRoles:[],_teamImmutableCache:{},newRoleName:"",newRolePermissions:[],allAvailablePermissions:[],editingRole:null,editingMember:null,_initialized:!1,_initializing:!1,_appwrite:null,_guestAuto:!1,_guestManual:!1,guestManualEnabled:!1,_oauthProvider:null,_syncStateToStorage:i,_permissionCache:{},_userRoleCache:null,_allRolesCache:null,_allRolesCacheByTeam:{},_rolePermanentCache:{},_userGeneratedRolesCache:{},canInviteMembers(){return this._permissionCache&&this._permissionCache.inviteMembers||!1},canRemoveMembers(){return this._permissionCache&&this._permissionCache.removeMembers||!1},canRenameTeam(){return this._permissionCache&&this._permissionCache.renameTeam||!1},canAuthenticate(){return!(this.isAuthenticated&&!this.isAnonymous||this.inProgress)},canDeleteTeam(){return this._permissionCache&&this._permissionCache.deleteTeam||!1},currentUserRole(){return this._userRoleCache||null},allTeamRoles(e){return e&&e.$id?this._allRolesCacheByTeam[e.$id]||{}:this.currentTeam&&this.currentTeam.$id?this._allRolesCacheByTeam[this.currentTeam.$id]||this._allRolesCache||{}:this._allRolesCache||{}},isUserGeneratedRoleCached(e){return this._userGeneratedRolesCache&&this._userGeneratedRolesCache[e]||!1},async canManageRoles(){const e=window.InduxAppwriteAuthConfig;if(e)try{const t=await e.getAppwriteConfig(),i=t?.memberRoles;if(!i||0===Object.keys(i).length)return!!this.isCurrentTeamOwner&&await this.isCurrentTeamOwner();if(this.hasTeamPermission)return await this.hasTeamPermission("manageRoles")}catch(e){return!1}return!1},async canCreateRoles(){return await this.canManageRoles()},get personalTeam(){return null},getMethod(){if(!this.session)return null;const e=this.session.provider;return"anonymous"===e?"anonymous":"magic-url"===e?"magic":e&&"anonymous"!==e&&"magic-url"!==e?"oauth":null},getProvider(){if(!this.session)return null;const e=this.session.provider;if(e&&"anonymous"!==e&&"magic-url"!==e){let t=this._oauthProvider;if(!t)try{t=localStorage.getItem("indux:oauth:provider"),t||(t=sessionStorage.getItem("indux:oauth:provider")),t&&(this._oauthProvider=t)}catch(e){}!t&&this._appwrite&&this._appwrite.account&&!this._fetchingProvider&&(this._fetchingProvider=!0,this._appwrite.account.listIdentities().then((e=>{if(e&&e.identities&&e.identities.length>0){const t=e.identities.find((e=>e.provider&&"anonymous"!==e.provider&&"magic-url"!==e.provider&&"oauth2"!==e.provider));if(t&&t.provider){this._oauthProvider=t.provider;try{localStorage.setItem("indux:oauth:provider",t.provider);const e=Alpine.store("auth");e&&e._oauthProvider}catch(e){}}}this._fetchingProvider=!1})).catch((e=>{this._fetchingProvider=!1})));return t||e}return null},async init(){if(!this._initializing&&!this._initialized){this._initializing=!0,this.inProgress=!0,this.error=null;try{const t=await e.getAppwriteClient();if(!t)return this._initialized=!0,this._initializing=!1,void(this.inProgress=!1);this._appwrite=t;const n=await e.getAppwriteConfig();this._guestAuto=!0===n?.guestAuto,this._guestManual=!0===n?.guestManual,this.guestManualEnabled=!0===n?.guestManual;try{this.user=await t.account.get();const e=(await t.account.listSessions()).sessions||[],i=e.find((e=>!0===e.current))||e[0];if(i){if(this.session=i,this.isAuthenticated=!0,this.isAnonymous="anonymous"===i.provider,!this.isAnonymous&&"magic-url"!==i.provider)try{let e=localStorage.getItem("indux:oauth:provider");e||(e=sessionStorage.getItem("indux:oauth:provider")),e&&(this._oauthProvider=e)}catch(e){}if(this.isAnonymous&&!this._guestAuto&&!this._guestManual)try{await t.account.deleteSession(this.session.$id),this.isAuthenticated=!1,this.isAnonymous=!1,this.user=null,this.session=null}catch(e){}}else this.isAuthenticated=!0,this.isAnonymous=!1;if(this.isAuthenticated&&n?.teams&&this.listTeams)try{await this.listTeams(),(n.permanentTeams||n.templateTeams)&&window.InduxAppwriteAuthTeamsDefaults?.ensureDefaultTeams&&await window.InduxAppwriteAuthTeamsDefaults.ensureDefaultTeams(this)}catch(e){}}catch(e){this.isAuthenticated=!1,this.isAnonymous=!1,this.user=null,this.session=null}i(this)}catch(e){this.error=e.message,this.isAuthenticated=!1,this.isAnonymous=!1}finally{this.inProgress=!1,this._initialized=!0,this._initializing=!1,window.dispatchEvent(new CustomEvent("indux:auth:initialized",{detail:{isAuthenticated:this.isAuthenticated,isAnonymous:this.isAnonymous}}))}}},async createGuest(){if(!this._guestManual)return{success:!1,error:"Manual guest creation is not enabled"};if(this.isAuthenticated&&!this.isAnonymous)return{success:!1,error:"Already signed in. Please logout first."};if(this.isAnonymous)return{success:!0,user:this.user,message:"Already a guest"};if(this._createAnonymousSession)return await this._createAnonymousSession();if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};this.inProgress=!0;try{const e=await this._appwrite.account.createAnonymousSession();this.session=e,this.user=await this._appwrite.account.get(),this.isAuthenticated=!0,this.isAnonymous=!0,this._oauthProvider=null;try{localStorage.removeItem("indux:oauth:provider"),sessionStorage.removeItem("indux:oauth:provider")}catch(e){}return this.teams=[],this.currentTeam=null,i(this),window.dispatchEvent(new CustomEvent("indux:auth:anonymous",{detail:{user:this.user}})),{success:!0,user:this.user}}catch(e){return this.error=e.message,this.isAuthenticated=!1,this.isAnonymous=!1,{success:!1,error:e.message}}finally{this.inProgress=!1}},async requestGuest(){const e=await this.createGuest();return e.success?this.error=null:this.error=e.error,e},async logout(){if(!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!0};this.inProgress=!0;try{this.session&&await this._appwrite.account.deleteSession(this.session.$id),this._oauthProvider=null;try{localStorage.removeItem("indux:oauth:provider"),sessionStorage.removeItem("indux:oauth:provider")}catch(e){}return this.magicLinkSent=!1,this.magicLinkExpired=!1,this.stopTeamsRealtime&&this.stopTeamsRealtime(),this.stopTeamsPolling&&this.stopTeamsPolling(),this.teams=[],this.currentTeam=null,!this.isAnonymous&&this._guestAuto&&this._createAnonymousSession?await this._createAnonymousSession():(this.isAuthenticated=!1,this.isAnonymous=!1,this.user=null,this.session=null),i(this),window.dispatchEvent(new CustomEvent("indux:auth:logout")),{success:!0}}catch(e){if(this.error=e.message,!this.isAnonymous&&this._guestAuto&&this._createAnonymousSession)try{await this._createAnonymousSession()}catch(e){this.isAuthenticated=!1,this.isAnonymous=!1,this.user=null,this.session=null}else this.isAuthenticated=!1,this.isAnonymous=!1,this.user=null,this.session=null;return this.stopTeamsRealtime&&this.stopTeamsRealtime(),this.stopTeamsPolling&&this.stopTeamsPolling(),this.teams=[],this.currentTeam=null,{success:!1,error:e.message}}finally{this.inProgress=!1}},async clearSession(){if(!this._appwrite)return{success:!1,error:"Appwrite not configured"};this.inProgress=!0;try{this.session&&await this._appwrite.account.deleteSession(this.session.$id),this.isAuthenticated=!1,this.isAnonymous=!1,this.user=null,this.session=null,this.magicLinkSent=!1,this.magicLinkExpired=!1,this.error=null,this._oauthProvider=null,this.teams=[],this.currentTeam=null;try{localStorage.removeItem("indux:oauth:provider"),sessionStorage.removeItem("indux:oauth:provider")}catch(e){}return i(this),window.dispatchEvent(new CustomEvent("indux:auth:session-cleared")),{success:!0}}catch(e){return this.error=e.message,this.isAuthenticated=!1,this.isAnonymous=!1,this.user=null,this.session=null,this.magicLinkSent=!1,this.magicLinkExpired=!1,{success:!1,error:e.message}}finally{this.inProgress=!1}},async refresh(){if(!this._appwrite)throw new Error("Appwrite not configured");try{return this.user=await this._appwrite.account.get(),i(this),this.user}catch(e){throw this.isAuthenticated=!1,this.isAnonymous=!1,this.user=null,this.session=null,i(this),e}}};Alpine.store("auth",n)}window.InduxAppwriteAuthConfig={getAppwriteConfig:t,getAppwriteClient:async function(){if(!window.Appwrite||!window.Appwrite.Client||!window.Appwrite.Account)return null;if(!i){const e=await t();if(!e)return null;i=(new window.Appwrite.Client).setEndpoint(e.endpoint).setProject(e.projectId),e.devKey&&(i.headers["X-Appwrite-Dev-Key"]=e.devKey),n=new window.Appwrite.Account(i),s=new window.Appwrite.Teams(i),window.Appwrite.Users&&(r=new window.Appwrite.Users(i))}return{client:i,account:n,teams:s,users:r,realtime:window.Appwrite?.Realtime?new window.Appwrite.Realtime(i):null}},ensureManifest:e},document.addEventListener("alpine:init",(()=>{try{o()}catch(e){}})),window.InduxAppwriteAuthStore={initialize:o};let a=!1;async function c(){if(a)return;if(!window.InduxAppwriteAuthConfig)return;if("undefined"==typeof Alpine)return;a=!0;const e=()=>{const t=Alpine.store("auth");t?(t._initialized||t._initializing||t.init(),window.addEventListener("indux:auth:initialized",(async()=>{if(t.validateRoleConfig){const e=await t.validateRoleConfig();e.valid&&e.warnings&&e.warnings.length}if(window.InduxAppwriteAuthCallbacks){const e=window.InduxAppwriteAuthCallbacks.detect();(e.hasCallback||e.hasExpired)&&window.InduxAppwriteAuthCallbacks.process(e)}!t.isAuthenticated&&t._guestAuto&&t._createAnonymousSession&&t._createAnonymousSession()}),{once:!0}),a=!1):setTimeout(e,50)};setTimeout(e,150)}function l(){return"undefined"!=typeof Alpine&&(Alpine.magic("auth",(()=>{const e=Alpine.store("auth");return e?new Proxy({},{get(t,i){if(i!==Symbol.iterator&&"then"!==i&&"catch"!==i&&"finally"!==i){if(i in e){const t=e[i];return"function"==typeof t?t.bind(e):t}return"method"===i?e.getMethod():"provider"===i?e.getProvider():void 0}},set:(t,i,n)=>i in e?(e[i]=n,!0):(t[i]=n,!0)}):{}})),!0)}if("loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&c()})),document.addEventListener("alpine:init",c),window.InduxAppwriteAuth={initialize:c},"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&l()})),document.addEventListener("alpine:init",(()=>{try{l()}catch(e){}})),"undefined"!=typeof Alpine)try{l()}catch(e){}function u(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i.createTeam?(i.createTeam=async function(t,i,n=[]){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};const s=await e.getAppwriteConfig();if(s&&!s.teams)return{success:!1,error:"Teams are not enabled"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to create a team"};this.inProgress=!0,this.error=null;try{let e=t;e||(e=window.Appwrite&&window.Appwrite.ID&&window.Appwrite.ID.unique?window.Appwrite.ID.unique():"team_"+Date.now()+"_"+Math.random().toString(36).substr(2,9));let r=n;if(0===r.length){const e=s?.memberRoles,t=s?.creatorRole;if(e&&t&&e[t])r=[t];else if(e&&Object.keys(e).length>0){let t=null;for(const[i,n]of Object.entries(e))if(this.roleHasAllOwnerPermissions&&await this.roleHasAllOwnerPermissions(i)){t=i;break}r=[t||Object.keys(e)[0]]}else r=["owner"]}this.normalizeRolesForAppwrite&&(r=await this.normalizeRolesForAppwrite(r));const o=await this._appwrite.teams.create(e,i,r);return window.InduxAppwriteAuthTeamsRolesDefaults&&this.ensureDefaultRoles&&await this.ensureDefaultRoles(e),await this.listTeams(),{success:!0,team:o}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.listTeams=async function(t=[],i=""){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return console.warn("[Indux Appwrite Auth] listTeams: User not authenticated"),{success:!1,error:"You must be signed in to list teams"};try{const n={queries:t};i&&i.trim().length>0&&(n.search=i);const s=await this._appwrite.teams.list(n);if(this.teams=s.teams||[],this.currentTeam&&this.currentTeam.$id){const e=this.teams?.find((e=>e.$id===this.currentTeam.$id));e&&e.name!==this.currentTeam.name&&(this.currentTeam={...e})}if(window.InduxAppwriteAuthTeamsDefaults&&this.isTeamImmutable)for(const e of this.teams)this._teamImmutableCache[e.$id]||(this._teamImmutableCache[e.$id]=await this.isTeamImmutable(e.$id));if(window.InduxAppwriteAuthTeamsDefaults&&this.getDeletedTemplateTeams&&(this.deletedTemplateTeams=await this.getDeletedTemplateTeams()),window.InduxAppwriteAuthTeamsDefaults&&this.cleanupDuplicateDefaultTeams){const e=await this.cleanupDuplicateDefaultTeams();e.cleaned>0&&(e.errors&&e.errors.length>0&&console.warn("[Indux Appwrite Auth] Some duplicate teams could not be deleted:",e.errors),this.listTeams&&await this.listTeams())}if(this.currentTeam&&this.currentTeam.$id&&window.InduxAppwriteAuthTeamsRolesDefaults&&this.getDeletedTemplateRoles&&(this.deletedTemplateRoles=await this.getDeletedTemplateRoles(this.currentTeam.$id)),!this.currentTeam&&this.teams.length>0){const t=await e.getAppwriteConfig();if((t?.permanentTeams&&Array.isArray(t.permanentTeams)&&t.permanentTeams.length>0||t?.templateTeams&&Array.isArray(t.templateTeams)&&t.templateTeams.length>0)&&window.InduxAppwriteAuthTeamsDefaults&&this.getDefaultTeams){const e=await this.getDefaultTeams();e.length>0?this.currentTeam=e[0]:this.currentTeam=this.teams[0]}else this.currentTeam=this.teams[0]}if(this.currentTeam&&this.currentTeam.$id&&window.InduxAppwriteAuthTeamsMembers&&this.listMemberships)try{const e=await this.listMemberships(this.currentTeam.$id);e.success&&(this.currentTeamMemberships=e.memberships||[])}catch(e){this.currentTeamMemberships=[]}if(!this._teamsRealtimeUnsubscribe&&!this._teamsRealtimeSubscribing){const t=await e.getAppwriteConfig();this._appwrite?.realtime&&this.startTeamsRealtime?this.startTeamsRealtime():t?.teamsPollInterval&&"number"==typeof t.teamsPollInterval&&t.teamsPollInterval>0&&(console.warn("[Indux Appwrite Auth] Realtime not available, falling back to polling"),this.startTeamsPolling&&this.startTeamsPolling(t.teamsPollInterval))}return{success:!0,teams:s.teams||[],total:s.total||0}}catch(e){return this.error=e.message,{success:!1,error:e.message}}},i.getTeam=async function(t){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to get team details"};try{return{success:!0,team:await this._appwrite.teams.get({teamId:t})}}catch(e){return this.error=e.message,{success:!1,error:e.message}}},i.updateTeamName=async function(t,i){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to update team name"};if(!t)return{success:!1,error:"Team ID is required"};if(!i||!i.trim())return{success:!1,error:"Team name is required"};this.inProgress=!0,this.error=null;try{const e=await this._appwrite.teams.updateName(t,i.trim());if(await this.listTeams(),this.currentTeam&&this.currentTeam.$id===t){const i=this.teams?.find((e=>e.$id===t))||e;if(i){this.currentTeam={...i};const e=this.teams?.findIndex((e=>e.$id===t));void 0!==e&&e>=0&&this.teams&&(this.teams=[...this.teams.slice(0,e),{...i},...this.teams.slice(e+1)]),"undefined"!=typeof Alpine&&Alpine.nextTick&&Alpine.nextTick((()=>{this.currentTeam=i}))}}return{success:!0,team:e}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.deleteTeam=async function(t){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to delete a team"};if(this.isTeamImmutable){if(await this.isTeamImmutable(t))return{success:!1,error:"This team cannot be deleted"}}this.inProgress=!0,this.error=null;try{const e=this.teams?.find((e=>e.$id===t)),i=e?.name;if(await this._appwrite.teams.delete({teamId:t}),i&&window.InduxAppwriteAuthTeamsDefaults){const e=await window.InduxAppwriteAuthConfig.getAppwriteConfig();if(e?.templateTeams&&Array.isArray(e.templateTeams)){const t=window.InduxAppwriteAuthTeamsDefaults.resolvePersonalTeamName;for(const n of e.templateTeams){if(await t(n)===i){try{const e=this.user?.$id;if(e){const t=`indux:deleted-teams:${e}`,n=JSON.parse(localStorage.getItem(t)||"[]");n.includes(i)||(n.push(i),localStorage.setItem(t,JSON.stringify(n)))}}catch(e){console.warn("[Indux Appwrite Auth] Failed to track deleted team:",e)}break}}}}return this.currentTeam&&this.currentTeam.$id===t&&(this.currentTeam=null,this.currentTeamMemberships=[]),await this.listTeams(),{success:!0}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.getTeamPrefs=async function(t){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to get team preferences"};try{return{success:!0,prefs:await this._appwrite.teams.getPrefs({teamId:t})}}catch(e){return this.error=e.message,{success:!1,error:e.message}}},i.startTeamsRealtime=function(){if(!this._teamsRealtimeUnsubscribe&&this.isAuthenticated&&this._appwrite?.realtime)try{const e=this._appwrite.realtime.subscribe("teams",(e=>{if(!this._teamsRealtimeSubscribing&&e.events&&Array.isArray(e.events)){let t=!1;for(const i of e.events){const e=i.split(/[.\s]+/),n=e[0],s=e[1];"teams"===n&&("update"===s||"create"===s||"delete"===s||"*"===s||s&&s.length>10)&&(t=!0)}t&&!this._teamsRealtimeSubscribing&&(this._teamsRealtimeSubscribing=!0,this.listTeams?this.listTeams().finally((()=>{this._teamsRealtimeSubscribing=!1})):this._teamsRealtimeSubscribing=!1)}})),t=this._appwrite.realtime.subscribe("memberships",(e=>{if(!this._teamsRealtimeSubscribing&&e.events&&Array.isArray(e.events)){let t=!1,i=null;e.payload&&(e.payload.teamId?i=e.payload.teamId:e.payload.team&&e.payload.team.$id?i=e.payload.team.$id:e.payload.membership&&e.payload.membership.teamId&&(i=e.payload.membership.teamId));for(const n of e.events){const e=n.split(/[.\s]+/),s=e[0];if("memberships"===s){const n=e[1],s=e[1];if(s&&s.length>10&&/^[a-f0-9]+$/i.test(s)){i||(i=s);const n=e[2];"create"!==n&&"update"!==n&&"delete"!==n&&"*"!==n&&n||(t=!0)}else"create"!==n&&"update"!==n&&"delete"!==n&&"*"!==n||(t=!0)}else if("teams"===s&&e.length>=3&&"memberships"===e[2]){const n=e[1],s=(e[3],e[4]);n&&"*"!==n&&n.length>10&&/^[a-f0-9]+$/i.test(n)&&(i||(i=n)),"create"!==s&&"update"!==s&&"delete"!==s&&"*"!==s&&s||(t=!0)}}if(t){(!i||this.currentTeam&&this.currentTeam.$id===i)&&this.currentTeam&&this.currentTeam.$id&&this.listMemberships&&this.listMemberships(this.currentTeam.$id).then((e=>{this.currentTeamMemberships&&(this.currentTeamMemberships=[...this.currentTeamMemberships])})).catch((e=>{})),this._teamsRealtimeSubscribing||(this._teamsRealtimeSubscribing=!0,this.listTeams?this.listTeams().finally((()=>{this._teamsRealtimeSubscribing=!1})):this._teamsRealtimeSubscribing=!1)}}})),i=[e,t,this._appwrite.realtime.subscribe("account",(e=>{if(e.events&&Array.isArray(e.events)){let t=!1;for(const i of e.events){const e=i.split(/[.\s]+/),n=e[0],s=e[1];"account"===n&&("update"!==s&&"delete"!==s&&"*"!==s||(t=!0))}t&&this.getAccount&&this.getAccount()}}))],n=[];for(const e of i)"function"==typeof e?n.push(e):e&&"function"==typeof e.unsubscribe?n.push((()=>e.unsubscribe())):e&&n.push(e);n.length>1?this._teamsRealtimeUnsubscribe=n:1===n.length?this._teamsRealtimeUnsubscribe=n[0]:this._teamsRealtimeUnsubscribe=!0}catch(e){}},i.stopTeamsRealtime=function(){if(this._teamsRealtimeUnsubscribe)try{if(Array.isArray(this._teamsRealtimeUnsubscribe))for(const e of this._teamsRealtimeUnsubscribe)"function"==typeof e?e():e&&"function"==typeof e.unsubscribe&&e.unsubscribe();else"function"==typeof this._teamsRealtimeUnsubscribe?this._teamsRealtimeUnsubscribe():!0===this._teamsRealtimeUnsubscribe||"function"==typeof this._teamsRealtimeUnsubscribe.unsubscribe&&this._teamsRealtimeUnsubscribe.unsubscribe()}catch(e){console.warn("[Indux Appwrite Auth] Error stopping realtime subscriptions:",e)}finally{this._teamsRealtimeUnsubscribe=null}},i.startTeamsPolling=function(e){this._teamsPollInterval&&clearInterval(this._teamsPollInterval),this.isAuthenticated&&(this._teamsPollInterval=setInterval((async()=>{if(this.isAuthenticated&&this.listTeams)try{await this.listTeams()}catch(e){console.warn("[Indux Appwrite Auth] Teams polling error:",e)}else this.stopTeamsPolling&&this.stopTeamsPolling()}),e))},i.stopTeamsPolling=function(){this._teamsPollInterval&&(clearInterval(this._teamsPollInterval),this._teamsPollInterval=null)},i.updateTeamPrefs=async function(t,i){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to update team preferences"};this.inProgress=!0,this.error=null;try{return{success:!0,prefs:await this._appwrite.teams.updatePrefs({teamId:t,prefs:i})}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}}):i||setTimeout(t,50)};setTimeout(t,100)}if(window.InduxAppwriteAuthMagic={initialize:l},document.addEventListener("alpine:init",(()=>{try{u()}catch(e){}})),"undefined"!=typeof Alpine)try{u()}catch(e){}async function d(e){if(!e||"string"!=typeof e)return null;if(e.startsWith("$x."))try{const t=e.substring(3);if("undefined"!=typeof Alpine&&Alpine.magic&&Alpine.magic("x")){const e=Alpine.magic("x"),i=t.split(".");let n=e;for(const e of i){if(!n||"object"!=typeof n||!(e in n))return null;n=n[e],n&&"function"==typeof n.then&&(n=await n)}return n||null}{const e=Alpine.store("data");if(e){const i=t.split(".");let n=e;for(const e of i){if(!n||"object"!=typeof n||!(e in n))return null;n=n[e]}return n||null}}}catch(e){return null}return e}function h(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i.isTeamImmutable?(i.isTeamImmutable=async function(t){const i=this.teams?.find((e=>e.$id===t));if(!i)return!1;const n=await e.getAppwriteConfig();if(!n?.permanentTeams||!Array.isArray(n.permanentTeams))return!1;for(const e of n.permanentTeams){if(await d(e)===i.name)return!0}return!1},i.getDeletedTemplateTeams=async function(){const t=await e.getAppwriteConfig();if(!t?.templateTeams||!Array.isArray(t.templateTeams))return[];let i=[];try{const e=this.user?.$id;if(e){const t=`indux:deleted-teams:${e}`;i=JSON.parse(localStorage.getItem(t)||"[]")}}catch(e){return[]}const n=[];for(const e of t.templateTeams){const t=await d(e);t&&i.includes(t)&&n.push(t)}return n},i.trackDeletedTemplateTeam=async function(t){const i=await e.getAppwriteConfig();if(i?.templateTeams&&Array.isArray(i.templateTeams))for(const e of i.templateTeams){if(await d(e)===t){try{const e=this.user?.$id;if(e){const i=`indux:deleted-teams:${e}`,n=JSON.parse(localStorage.getItem(i)||"[]");n.includes(t)||(n.push(t),localStorage.setItem(i,JSON.stringify(n)))}}catch(e){console.warn("[Indux Appwrite Auth] Failed to track deleted team:",e)}break}}},i.getDefaultTeams=async function(){if(!this.teams||0===this.teams.length)return[];const t=await e.getAppwriteConfig(),i=[];if(t?.permanentTeams&&Array.isArray(t.permanentTeams))for(const e of t.permanentTeams){const t=await d(e);t&&i.push(t)}if(t?.templateTeams&&Array.isArray(t.templateTeams))for(const e of t.templateTeams){const t=await d(e);t&&i.push(t)}return this.teams.filter((e=>i.includes(e.name)))},i.cleanupDuplicateDefaultTeams=async function(){if(!this.teams||0===this.teams.length)return{success:!0,cleaned:0};const t=await e.getAppwriteConfig();if(!t)return{success:!1,error:"Appwrite config not available"};const i=[];if(t?.permanentTeams&&Array.isArray(t.permanentTeams))for(const e of t.permanentTeams){const t=await d(e);t&&i.push(t)}if(t?.templateTeams&&Array.isArray(t.templateTeams))for(const e of t.templateTeams){const t=await d(e);t&&i.push(t)}let n=0;const s=[];for(const t of i){const i=this.teams.filter((e=>e.name===t));if(i.length>1){const t=i.sort(((e,t)=>new Date(e.$createdAt||0)-new Date(t.$createdAt||0)));t[0];const r=t.slice(1);for(const t of r)try{this._appwrite||(this._appwrite=await e.getAppwriteClient()),this._appwrite&&this._appwrite.teams&&(await this._appwrite.teams.delete({teamId:t.$id}),n++)}catch(e){const i=`Error deleting duplicate team ${t.$id}: ${e.message}`;s.push(i)}}}return n>0&&this.listTeams&&await this.listTeams(),{success:0===s.length,cleaned:n,errors:s.length>0?s:void 0}},i.getPersonalTeam=async function(){const e=await this.getDefaultTeams();return e.length>0?e[0]:this.teams&&this.teams.length>0?this.teams[0]:null},i.reapplyTemplateTeam=async function(t){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to reapply a template team"};const i=await e.getAppwriteConfig();if(!i?.templateTeams||!Array.isArray(i.templateTeams))return{success:!1,error:"Template teams are not configured"};let n=!1;for(const e of i.templateTeams){if(await d(e)===t){n=!0;break}}if(!n)return{success:!1,error:"This is not a valid template team"};if(this.teams&&this.teams.some((e=>e.name===t)))return{success:!1,error:"This team already exists"};this.inProgress=!0,this.error=null;try{const e=await this.createTeam(null,t,[]);if(e.success){try{const e=this.user?.$id;if(e){const i=`indux:deleted-teams:${e}`,n=JSON.parse(localStorage.getItem(i)||"[]").filter((e=>e!==t));localStorage.setItem(i,JSON.stringify(n))}}catch(e){console.warn("[Indux Appwrite Auth] Failed to update deleted teams list:",e)}return this.listTeams&&await this.listTeams(),this.getDeletedTemplateTeams&&(this.deletedTemplateTeams=await this.getDeletedTemplateTeams()),{success:!0,team:e.team}}return{success:!1,error:e.error}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}}):i||setTimeout(t,50)};setTimeout(t,100)}if(window.InduxAppwriteAuthTeamsCore={initialize:u},document.addEventListener("alpine:init",(()=>{try{h()}catch(e){}})),"undefined"!=typeof Alpine)try{h()}catch(e){}function m(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i.isRolePermanent?(i._rolePermanentCache||(i._rolePermanentCache={}),i.isRolePermanent=async function(t,i){const n=await e.getAppwriteConfig();if(!n?.permanentRoles||"object"!=typeof n.permanentRoles)return!1;const s=i in n.permanentRoles;return this._rolePermanentCache[t]||(this._rolePermanentCache[t]={}),this._rolePermanentCache[t][i]=s,s},i.isRolePermanentSync=function(e,t){return!!(e&&t&&this._rolePermanentCache)&&!0===this._rolePermanentCache[e]?.[t]},i.isRoleTemplate=async function(t,i){const n=await e.getAppwriteConfig();return!(!n?.templateRoles||"object"!=typeof n.templateRoles)&&i in n.templateRoles},i.getDeletedTemplateRoles=async function(t){if(!t)return[];const i=await e.getAppwriteConfig();if(!i?.templateRoles||"object"!=typeof i.templateRoles)return[];let n=[];try{if(this._appwrite&&this._appwrite.teams){const e=await this._appwrite.teams.getPrefs({teamId:t});e&&e.deletedTemplateRoles&&Array.isArray(e.deletedTemplateRoles)&&(n=e.deletedTemplateRoles)}}catch(e){if(e.message&&e.message.includes("could not be found"))return[];try{const e=this.user?.$id;if(e){const i=`indux:deleted-roles:${e}:${t}`;n=JSON.parse(localStorage.getItem(i)||"[]")}}catch(e){}}const s=Object.keys(i.templateRoles);return n.filter((e=>s.includes(e)))},i.reapplyTemplateRole=async function(t,i){if(!t||!i)return{success:!1,error:"Team ID and role name are required"};const n=await e.getAppwriteConfig();if(!n?.templateRoles||"object"!=typeof n.templateRoles)return{success:!1,error:"Template roles are not configured"};const s=n.templateRoles[i];if(!s||!Array.isArray(s))return{success:!1,error:`Template role "${i}" does not exist`};try{const e=await this._appwrite.teams.getPrefs({teamId:t}),n=e?.roles?{...e.roles}:{};if(n[i])return{success:!1,error:"This role already exists"};const r={...n,[i]:s};let o=[];e&&e.deletedTemplateRoles&&Array.isArray(e.deletedTemplateRoles)&&(o=e.deletedTemplateRoles.filter((e=>e!==i)));const a={...e,roles:r,deletedTemplateRoles:o};await this._appwrite.teams.updatePrefs({teamId:t,prefs:a});try{const e=this.user?.$id;if(e){const n=`indux:deleted-roles:${e}:${t}`,s=JSON.parse(localStorage.getItem(n)||"[]").filter((e=>e!==i));localStorage.setItem(n,JSON.stringify(s))}}catch(e){}if(this.getAllRoles){const e=await this.getAllRoles(t),i=e?{...e}:{};this._allRolesCacheByTeam||(this._allRolesCacheByTeam={}),this._allRolesCacheByTeam[t]={...i},this._rolePermanentCache||(this._rolePermanentCache={}),this._rolePermanentCache[t]||(this._rolePermanentCache[t]={});for(const e of Object.keys(i))this.isRolePermanent&&await this.isRolePermanent(t,e)}return this.refreshPermissionCache&&await this.refreshPermissionCache(),{success:!0}}catch(e){return{success:!1,error:e.message}}},i.ensureDefaultRoles=async function(t){const i=await e.getAppwriteConfig();if(!i||!t)return{success:!1,error:"Invalid config or team ID"};const n=i.permanentRoles||{},s=i.templateRoles||{};let r=[];if(this.getDeletedTemplateRoles)try{r=await this.getDeletedTemplateRoles(t)}catch(e){}const o={...n};for(const[e,t]of Object.entries(s))r.includes(e)||(o[e]=t);if(0===Object.keys(o).length)return{success:!0,applied:!1};try{const e=await this._appwrite.teams.getPrefs({teamId:t}),i=e?.roles?{...e.roles}:{};let n=!1;const s={...i};for(const[e,t]of Object.entries(o))!s[e]&&Array.isArray(t)&&(s[e]=t,n=!0);if(n){const i={...e,roles:s};if(await this._appwrite.teams.updatePrefs({teamId:t,prefs:i}),this.getAllRoles){const e=await this.getAllRoles(t),i=e?{...e}:{};this._allRolesCacheByTeam||(this._allRolesCacheByTeam={}),this._allRolesCacheByTeam[t]=i,this._rolePermanentCache||(this._rolePermanentCache={}),this._rolePermanentCache[t]||(this._rolePermanentCache[t]={});for(const e of Object.keys(i))this.isRolePermanent&&await this.isRolePermanent(t,e)}return{success:!0,applied:!0}}return{success:!0,applied:!1}}catch(e){return{success:!1,error:e.message}}}):i||setTimeout(t,50)};setTimeout(t,100)}if(window.InduxAppwriteAuthTeamsDefaults={initialize:h,ensureDefaultTeams:async function(e){const t=await window.InduxAppwriteAuthConfig.getAppwriteConfig(),i=t?.permanentTeams&&Array.isArray(t.permanentTeams)&&t.permanentTeams.length>0,n=t?.templateTeams&&Array.isArray(t.templateTeams)&&t.templateTeams.length>0;if(!i&&!n||!t?.teams)return{success:!0,created:!1,teams:[]};e.teams&&0!==e.teams.length||e.listTeams&&await e.listTeams();const s=[],r=[];let o=[];try{const t=e.user?.$id;if(t){const e=`indux:deleted-teams:${t}`;o=JSON.parse(localStorage.getItem(e)||"[]")}}catch(e){console.warn("[Indux Appwrite Auth] Failed to load deleted teams list:",e)}if(i)for(const i of t.permanentTeams){const t=await d(i);if(!t)continue;const n=e.teams?.filter((e=>e.name===t))||[];if(n.length>0)n.length>1&&(console.warn(`[Indux Appwrite Auth] Found ${n.length} duplicate permanent teams with name "${t}". Using the first one.`),console.warn("[Indux Appwrite Auth] Duplicate team IDs:",n.map((e=>e.$id)))),r.push(n[0]);else try{const i=await e.createTeam(null,t,[]);i.success&&s.push(i.team)}catch(e){}}if(n)for(const i of t.templateTeams){const t=await d(i);if(!t)continue;if(o.includes(t))continue;const n=e.teams?.filter((e=>e.name===t))||[];if(n.length>0)n.length>1&&(console.warn(`[Indux Appwrite Auth] Found ${n.length} duplicate template teams with name "${t}". Using the first one.`),console.warn("[Indux Appwrite Auth] Duplicate team IDs:",n.map((e=>e.$id)))),r.push(n[0]);else try{const i=await e.createTeam(null,t,[]);i.success&&s.push(i.team)}catch(e){}}if(!e.currentTeam){const t=[...r,...s];t.length>0&&(e.currentTeam=t[0])}return{success:!0,created:s.length>0,teams:[...r,...s],createdCount:s.length}},resolvePersonalTeamName:d},document.addEventListener("alpine:init",(()=>{m()})),"undefined"!=typeof Alpine)try{m()}catch(e){}window.InduxAppwriteAuthTeamsRolesDefaults={initialize:m};const p=["inviteMembers","updateMembers","removeMembers","renameTeam","deleteTeam","manageRoles"];function f(){return[...p]}function g(e,t){const i=[],n=[];if(e&&"object"!=typeof e)return i.push("memberRoles must be an object"),{valid:!1,errors:i,warnings:n};if(!e||0===Object.keys(e).length)return{valid:!0,errors:[],warnings:[]};for(const[t,n]of Object.entries(e))if(Array.isArray(n))for(const e of n)"string"!=typeof e&&i.push(`Role "${t}" has invalid permission type. Permissions must be strings.`);else i.push(`Role "${t}" must have a permissions array`);return t&&("string"!=typeof t?i.push("creatorRole must be a string reference to a memberRoles key"):e&&e[t]||i.push(`creatorRole "${t}" does not exist in memberRoles`)),i.length>0?{valid:!1,errors:i,warnings:n}:{valid:!0,errors:[],warnings:n}}function w(e,t){if(!t||!t[e])return!1;return(t[e]||[]).some((e=>p.includes(e)))}function y(e,t){if(!t||!t[e])return!1;const i=t[e]||[];return p.every((e=>i.includes(e)))}async function b(e,t){if(!t||!t.teams)return null;try{const i=await t.teams.getPrefs({teamId:e});return i?.roles||null}catch(e){return e.message&&e.message.includes("could not be found"),null}}function v(e,t){if(!e&&!t)return null;const i=e?{...e}:{};return t&&"object"==typeof t&&Object.assign(i,t),i}function A(e,t,i=null){if(!Array.isArray(e))return e;const n=v(t,i);if(!n||0===Object.keys(n).length)return e;return e.some((e=>w(e,n)))&&!e.includes("owner")?[...e,"owner"]:e}function x(e,t,i=null){if(!Array.isArray(e))return e;const n=v(t,i);return n&&Object.keys(n).length>0?e.filter((e=>"owner"!==e)):e}function T(e,t,i=null){const n=x(e,t,i);return 0===n.length?null:n[0]}function C(e,t,i,n=null){if(!Array.isArray(e))return!1;const s=v(i,n);if(!s||0===Object.keys(s).length)return e.includes("owner");const r=e.filter((e=>"owner"!==e));if(0===r.length)return!0;for(const e of r){const i=s[e];if(i&&Array.isArray(i)&&i.includes(t))return!0}return!1}function I(e,t){if(t&&e&&e[t])return e[t];if(e){for(const[t,i]of Object.entries(e))if(y(t,e))return i;const t=Object.keys(e)[0];if(t)return e[t]}return[]}function S(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i._rolesInitialized?(i.getOwnerPermissions=function(){return f()},i.validateRoleConfig=async function(){const t=await e.getAppwriteConfig();return g(t?.memberRoles||null,t?.creatorRole||null)},i.roleRequiresOwner=async function(t){const i=await e.getAppwriteConfig();return w(t,i?.memberRoles||null)},i.roleHasAllOwnerPermissions=async function(t){const i=await e.getAppwriteConfig();return y(t,i?.memberRoles||null)},i.getUserGeneratedRoles=async function(e){return this._appwrite?await b(e,this._appwrite):null},i.getAllRoles=async function(t){if(t&&this.teams&&!this.teams.find((e=>e.$id===t))){const t=await e.getAppwriteConfig();return t?.memberRoles||null}const i=await e.getAppwriteConfig();let n=i?.memberRoles||null;if(n&&t&&window.InduxAppwriteAuthTeamsRolesDefaults&&this.getDeletedTemplateRoles){const e=await this.getDeletedTemplateRoles(t);if(e&&e.length>0){const t={...n};for(const i of e)delete t[i];n=t}}let s=null;return t&&this._appwrite&&(s=await this.getUserGeneratedRoles(t)),v(n,s)},i.normalizeRolesForAppwrite=async function(t,i=null){const n=await e.getAppwriteConfig(),s=n?.memberRoles||null;let r=null;return i&&this._appwrite&&(r=await this.getUserGeneratedRoles(i)),A(t,s,r)},i.normalizeRolesForDisplay=async function(t,i=null){const n=await e.getAppwriteConfig(),s=n?.memberRoles||null;let r=null;return i&&this._appwrite&&(r=await this.getUserGeneratedRoles(i)),x(t,s,r)},i.getPrimaryDisplayRole=async function(t,i=null){const n=await e.getAppwriteConfig(),s=n?.memberRoles||null;let r=null;return i&&this._appwrite&&(r=await this.getUserGeneratedRoles(i)),T(t,s,r)},i.hasPermission=async function(t,i,n=null){const s=await e.getAppwriteConfig(),r=s?.memberRoles||null;let o=null;return n&&this._appwrite&&(o=await this.getUserGeneratedRoles(n)),C(t,i,r,o)},i.getCreatorRolePermissions=async function(){const t=await e.getAppwriteConfig();return I(t?.memberRoles||null,t?.creatorRole||null)},i.hasCustomRoles=async function(){const t=await e.getAppwriteConfig(),i=t?.memberRoles||null;return i&&Object.keys(i).length>0},i.canManageRoles=async function(){return!!(this.currentTeam&&this.currentTeamMemberships&&this.user)&&await this.hasTeamPermission("manageRoles")},i.canCreateRoles=i.canManageRoles,i._rolesInitialized=!0):i||setTimeout(t,50)};setTimeout(t,100)}if(document.addEventListener("alpine:init",(()=>{try{S()}catch(e){}})),"undefined"!=typeof Alpine)try{S()}catch(e){}function E(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i.createUserRole?(i.createUserRole=async function(t,i,n){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to create roles"};if(!this.hasTeamPermission||!await this.hasTeamPermission("manageRoles"))return{success:!1,error:"You do not have permission to create roles"};if(!i||!i.trim())return{success:!1,error:"Role name is required"};if(!Array.isArray(n))return{success:!1,error:"Permissions must be an array"};this.inProgress=!0,this.error=null;try{const e=await this._appwrite.teams.getPrefs({teamId:t}),s=e?.roles?{...e.roles}:{};if(s[i])return{success:!1,error:`Role "${i}" already exists`};const r={...s,[i]:n},o={...e,roles:r};if(await this._appwrite.teams.updatePrefs({teamId:t,prefs:o}),this.refreshPermissionCache&&await this.refreshPermissionCache(),this.getAllRoles){const e=await this.getAllRoles(t),i=e?{...e}:{};this._allRolesCacheByTeam||(this._allRolesCacheByTeam={}),this._allRolesCacheByTeam[t]=i}return{success:!0,role:{name:i,permissions:n}}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.createRoleFromInputs=async function(e){if(!e)return{success:!1,error:"Team ID is required"};const t=String(this.newRoleName||"").trim(),i=Array.isArray(this.newRolePermissions)?this.newRolePermissions.filter((e=>e&&"string"==typeof e)):[];if(!t)return{success:!1,error:"Role name is required"};const n=await this.createUserRole(e,t,i);return n.success&&(this.newRoleName="",this.newRolePermissions=[]),n},i.updateUserRole=async function(t,i,n){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to update roles"};if(!this.hasTeamPermission||!await this.hasTeamPermission("manageRoles"))return{success:!1,error:"You do not have permission to update roles"};if(!i||!i.trim())return{success:!1,error:"Role name is required"};if(!Array.isArray(n))return{success:!1,error:"Permissions must be an array"};this.inProgress=!0,this.error=null;try{const e=await this._appwrite.teams.getPrefs({teamId:t}),s=e?.roles?{...e.roles}:{};if(!s[i])return{success:!1,error:`Role "${i}" does not exist`};const r={...s,[i]:n},o={...e,roles:r};if(await this._appwrite.teams.updatePrefs({teamId:t,prefs:o}),this.refreshPermissionCache&&await this.refreshPermissionCache(),this.getAllRoles){const e=await this.getAllRoles(t),i=e?{...e}:{};this._allRolesCacheByTeam||(this._allRolesCacheByTeam={}),this._allRolesCacheByTeam[t]={...i},this.currentTeam&&this.currentTeam.$id===t&&(this._allRolesCache={...i})}return{success:!0,role:{name:i,permissions:n}}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.renameUserRole=async function(t,i,n){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to rename roles"};if(!this.hasTeamPermission||!await this.hasTeamPermission("manageRoles"))return{success:!1,error:"You do not have permission to rename roles"};if(i=String(i||"").trim(),n=String(n||"").trim(),!i||!n)return{success:!1,error:"Both old and new role names are required"};if(i===n)return{success:!1,error:"New role name must be different from the current name"};if(this.isRolePermanent&&await this.isRolePermanent(t,i))return{success:!1,error:"Permanent roles cannot be renamed"};this.inProgress=!0,this.error=null;try{const e=await this._appwrite.teams.getPrefs({teamId:t}),s=e?.roles?{...e.roles}:{};if(!s[i])return{success:!1,error:`Role "${i}" does not exist`};if(s[n])return{success:!1,error:`Role "${n}" already exists`};const r=Array.isArray(s[i])?[...s[i]]:[],o={...s};delete o[i],o[n]=r;const a={...e,roles:o};await this._appwrite.teams.updatePrefs({teamId:t,prefs:a});try{if(this.listMemberships){const e=await this.listMemberships(t);if(e&&e.success&&e.memberships){const s=e.memberships;let r=0;for(const e of s)if(e.roles&&Array.isArray(e.roles)){if(e.roles.includes(i)){const s=e.roles.map((e=>e===i?n:e));this.updateMembership&&(await this.updateMembership(t,e.$id,s),r++)}}}}}catch(e){}if(this.refreshPermissionCache&&await this.refreshPermissionCache(),this.listMemberships&&this.currentTeam&&this.currentTeam.$id===t&&await this.listMemberships(t),this.getAllRoles){const e=await this.getAllRoles(t),i=e?{...e}:{};this._allRolesCacheByTeam||(this._allRolesCacheByTeam={}),this._allRolesCacheByTeam[t]={...i},this.currentTeam&&this.currentTeam.$id===t&&(this._allRolesCache={...i})}return{success:!0,role:{name:n,permissions:r}}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.deleteUserRole=async function(t,i){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to delete roles"};if(!this.hasTeamPermission||!await this.hasTeamPermission("manageRoles"))return{success:!1,error:"You do not have permission to delete roles"};if(!i||!i.trim())return{success:!1,error:"Role name is required"};if(this.isRolePermanent&&await this.isRolePermanent(t,i))return{success:!1,error:"This role cannot be deleted"};this.inProgress=!0,this.error=null;try{if(this.listMemberships){const e=await this.listMemberships(t);if(e.success){const t=e.memberships||[];if(t.some((e=>e.roles&&Array.isArray(e.roles)&&e.roles.includes(i))))return{success:!1,error:`Cannot delete role "${i}" - it is assigned to one or more team members. Please reassign members to other roles first.`}}}const e=await this._appwrite.teams.getPrefs({teamId:t}),n=e?.roles?{...e.roles}:{},s=!!n[i];let r=!1;if(!s&&window.InduxAppwriteAuthTeamsRolesDefaults&&this.isRoleTemplate&&(r=await this.isRoleTemplate(t,i)),!s&&!r)return{success:!1,error:`Role "${i}" does not exist`};if(!r&&window.InduxAppwriteAuthTeamsRolesDefaults&&this.isRoleTemplate&&(r=await this.isRoleTemplate(t,i)),r)try{const e=await this._appwrite.teams.getPrefs({teamId:t});let n=[];if(e&&e.deletedTemplateRoles&&Array.isArray(e.deletedTemplateRoles)&&(n=[...e.deletedTemplateRoles]),!n.includes(i)){n.push(i);const s={...e,deletedTemplateRoles:n};await this._appwrite.teams.updatePrefs({teamId:t,prefs:s})}}catch(e){try{const e=this.user?.$id;if(e){const n=`indux:deleted-roles:${e}:${t}`,s=JSON.parse(localStorage.getItem(n)||"[]");s.includes(i)||(s.push(i),localStorage.setItem(n,JSON.stringify(s)))}}catch(e){}}const o={...n};if(s&&delete o[i],s){const i={...e,roles:o};await this._appwrite.teams.updatePrefs({teamId:t,prefs:i})}if(this.getAllRoles){const e=await this.getAllRoles(t),n=e?{...e}:{};if(this._allRolesCacheByTeam||(this._allRolesCacheByTeam={}),this._allRolesCacheByTeam[t]={...n},this.currentTeam&&this.currentTeam.$id===t&&(this._allRolesCache={...n}),this._rolePermanentCache||(this._rolePermanentCache={}),this._rolePermanentCache[t]||(this._rolePermanentCache[t]={}),this.isRolePermanent){for(const e of Object.keys(n))await this.isRolePermanent(t,e);void 0!==this._rolePermanentCache[t][i]&&delete this._rolePermanentCache[t][i]}}return this.refreshPermissionCache&&await this.refreshPermissionCache(),{success:!0}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.isUserGeneratedRole=async function(e,t){if(!this._appwrite)return!1;try{const i=await this.getUserGeneratedRoles(e);return i&&void 0!==i[t]}catch(e){return!1}}):i||setTimeout(t,50)};setTimeout(t,100)}if(window.InduxAppwriteAuthTeamsRoles={initialize:S,getOwnerPermissions:f,validateRoleConfig:g,roleRequiresOwner:w,roleHasAllOwnerPermissions:y,getUserGeneratedRoles:b,mergeRoles:v,normalizeRolesForAppwrite:A,normalizeRolesForDisplay:x,getPrimaryDisplayRole:T,hasPermission:C,getCreatorRolePermissions:I},document.addEventListener("alpine:init",(()=>{try{E()}catch(e){}})),"undefined"!=typeof Alpine)try{E()}catch(e){}function $(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i.inviteMember?(i.inviteMember=async function(t,i,n=null,s=null,r=null,o=null,a=null){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to invite members"};if(!n&&!s&&!r)return{success:!1,error:"You must provide email, userId, or phone"};if(!o){const e=new URL(window.location.href);o=`${e.origin}${e.pathname}`}this.inProgress=!0,this.error=null;try{let e=Array.isArray(i)?i:i?[i]:[],c=e;this.normalizeRolesForAppwrite&&e.length>0&&(c=await this.normalizeRolesForAppwrite(e,t)),c&&0!==c.length||(c=["owner"]);const l={teamId:t,roles:c};n&&n.trim()?l.email=n.trim():s&&s.trim()?l.userId=s.trim():r&&r.trim()&&(l.phone=r.trim()),o&&o.trim()&&(l.url=o.trim()),a&&a.trim()&&(l.name=a.trim());return{success:!0,membership:await this._appwrite.teams.createMembership(l)}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.listMemberships=async function(t,i=[],n=""){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to list memberships"};try{const e={teamId:t,queries:i};n&&n.trim().length>0&&(e.search=n);const s=await this._appwrite.teams.listMemberships(e);let r=s.memberships||[];for(const e of r){const t=Object.keys(e),i={};if(t.forEach((t=>{const n=e[t];"string"==typeof n||"number"==typeof n||"boolean"==typeof n?i[t]=n:n&&"object"==typeof n&&(i[t]=Array.isArray(n)?`[Array(${n.length})]`:"[Object]")})),!e.email&&!e.userEmail)try{if(this.user&&this.user.$id===e.userId&&this.user.email)e.email=this.user.email,e.userEmail=this.user.email;else if(e.userId&&!0===e.confirm)try{if(this._appwrite&&this._appwrite.users&&"function"==typeof this._appwrite.users.get){const t=await this._appwrite.users.get({userId:e.userId});t&&t.email?(e.email=t.email,e.userEmail=t.email):console.warn("[Indux Appwrite Auth] User fetched but no email found")}else console.warn("[Indux Appwrite Auth] Users service not available on Appwrite client")}catch(e){console.warn("[Indux Appwrite Auth] Failed to fetch user:",e.message)}else if(!1===e.confirm){const t=["email","userEmail","inviteeEmail","invitedEmail","userName"];let i=null;for(const n of t){const t=e[n];if(t&&"string"==typeof t&&t.includes("@")){i=t;break}}if(i)e.email=i,e.userEmail=i;else if(e.userId)try{if(this._appwrite&&this._appwrite.users&&"function"==typeof this._appwrite.users.get){const t=await this._appwrite.users.get({userId:e.userId});t&&t.email&&(e.email=t.email,e.userEmail=t.email)}else console.warn("[Indux Appwrite Auth] Users service not available for pending invite lookup")}catch(e){console.warn("[Indux Appwrite Auth] Failed to fetch user for pending invite:",e.message)}else console.warn("[Indux Appwrite Auth] Pending invite has no email and no userId")}}catch(e){}e.email&&!e.userEmail&&(e.userEmail=e.email),e.userEmail&&!e.email&&(e.email=e.userEmail)}if(this.normalizeRolesForDisplay)for(const e of r)e.roles&&Array.isArray(e.roles)&&(e.displayRoles=await this.normalizeRolesForDisplay(e.roles,t));return this.currentTeam&&this.currentTeam.$id===t&&(this.currentTeamMemberships=[...r],this.refreshPermissionCache&&await this.refreshPermissionCache()),{success:!0,memberships:r,total:s.total||0}}catch(e){return e.message&&e.message.includes("could not be found")?(this.currentTeam&&this.currentTeam.$id===t&&(this.currentTeamMemberships=[]),{success:!0,memberships:[],total:0}):(this.error=e.message,{success:!1,error:e.message})}},i.getMembership=async function(t,i){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to get membership details"};try{return{success:!0,membership:await this._appwrite.teams.getMembership({teamId:t,membershipId:i})}}catch(e){return this.error=e.message,{success:!1,error:e.message}}},i.updateMembership=async function(t,i,n){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to update membership"};if(!(this.user&&this.currentTeamMemberships?.some((e=>e.$id===i&&e.userId===this.user.$id))||this.hasTeamPermission&&await this.hasTeamPermission("updateMembers")))return{success:!1,error:"You do not have permission to update member roles"};this.inProgress=!0,this.error=null;try{let e=n;this.normalizeRolesForAppwrite&&(e=await this.normalizeRolesForAppwrite(n,t));const s=await this._appwrite.teams.updateMembership({teamId:t,membershipId:i,roles:e}),r=this.user&&s.membership&&s.membership.userId===this.user.$id;return this.currentTeam&&this.currentTeam.$id===t&&this.listMemberships&&await this.listMemberships(t),r&&this.currentTeam&&this.currentTeam.$id===t&&this.refreshPermissionCache&&await this.refreshPermissionCache(),{success:!0,membership:s}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.acceptInvite=async function(t,i,n,s){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return console.warn("[Indux Appwrite Auth] acceptInvite: User not authenticated"),{success:!1,error:"You must be signed in to accept an invitation"};this.inProgress=!0,this.error=null;try{const e=await this._appwrite.teams.updateMembershipStatus({teamId:t,membershipId:i,userId:n,secret:s});return this.listTeams?await this.listTeams():console.warn("[Indux Appwrite Auth] acceptInvite: listTeams method not available"),this.currentTeam&&this.currentTeam.$id===t&&this.listMemberships&&await this.listMemberships(t),{success:!0,membership:e}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.deleteMembership=async function(t,i){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this.isAuthenticated)return{success:!1,error:"You must be signed in to delete membership"};if(!(this.user&&this.currentTeamMemberships?.some((e=>e.$id===i&&e.userId===this.user.$id))||this.hasTeamPermission&&await this.hasTeamPermission("removeMembers")))return{success:!1,error:"You do not have permission to remove members"};this.inProgress=!0,this.error=null;try{return await this._appwrite.teams.deleteMembership({teamId:t,membershipId:i}),this.currentTeam&&this.currentTeam.$id===t&&this.listMemberships&&await this.listMemberships(t),this.listTeams&&await this.listTeams(),{success:!0}}catch(e){return this.error=e.message,{success:!1,error:e.message}}finally{this.inProgress=!1}}):i||setTimeout(t,50)};setTimeout(t,100)}if(window.InduxAppwriteAuthTeamsUserRoles={initialize:E},document.addEventListener("alpine:init",(()=>{try{$()}catch(e){}})),"undefined"!=typeof Alpine)try{$()}catch(e){}function R(){window.addEventListener("indux:auth:callback:team",(async e=>{const t=Alpine.store("auth");if(!t)return;const i=e.detail;t.inProgress=!0,t.error=null;try{if(t.acceptInvite){const e=await t.acceptInvite(i.teamId,i.membershipId,i.userId,i.secret);e.success?window.dispatchEvent(new CustomEvent("indux:auth:team:invite-accepted",{detail:{membership:e.membership}})):t.error=e.error}}catch(e){t.error=e.message}finally{t.inProgress=!1}}))}if(window.InduxAppwriteAuthTeamsMembers={initialize:$},document.addEventListener("alpine:init",(()=>{try{R()}catch(e){}})),"undefined"!=typeof Alpine)try{R()}catch(e){}function _(){if("undefined"==typeof Alpine)return;if(!window.InduxAppwriteAuthConfig)return;const e=()=>{const t=Alpine.store("auth");if(t){t._permissionCache||(t._permissionCache={}),void 0===t._userRoleCache&&(t._userRoleCache=null),t._allRolesCache||(t._allRolesCache=null),t._allRolesCacheByTeam||(t._allRolesCacheByTeam={}),t._userGeneratedRolesCache||(t._userGeneratedRolesCache={});const e=async function(){if(!this.currentTeam||!this.currentTeamMemberships||!this.user)return this._permissionCache={},this._userRoleCache=null,this._allRolesCache=null,void(this._userGeneratedRolesCache={});const e=this.currentTeam.$id,t=["inviteMembers","updateMembers","removeMembers","renameTeam","deleteTeam","manageRoles"];for(const e of t)if(this.hasTeamPermission){const t=await this.hasTeamPermission(e);this._permissionCache[e]=t}else this._permissionCache[e]=!1;if(this.getUserRole?this._userRoleCache=await this.getUserRole():this._userRoleCache=null,this.getAllRoles){const t=await this.getAllRoles(e),i=t?{...t}:{};if(this._allRolesCache=i,this._allRolesCacheByTeam||(this._allRolesCacheByTeam={}),this._allRolesCacheByTeam[e]={...i},this._rolePermanentCache||(this._rolePermanentCache={}),this._rolePermanentCache[e]||(this._rolePermanentCache[e]={}),this.isRolePermanent)for(const t of Object.keys(i))await this.isRolePermanent(e,t);if(this._userGeneratedRolesCache={},this._allRolesCache&&this.isUserGeneratedRole)for(const t of Object.keys(this._allRolesCache))this._userGeneratedRolesCache[t]=await this.isUserGeneratedRole(e,t)}else this._allRolesCache={},this._allRolesCacheByTeam||(this._allRolesCacheByTeam={}),this._allRolesCacheByTeam[e]={}};if(t.refreshPermissionCache||(t.refreshPermissionCache=async function(){await e.call(this)}),t.createTeamFromName||(t.createTeamFromName=async function(){const e=String(this.newTeamName||"").trim();if(!e)return{success:!1,error:"Team name is required"};const t=await this.createTeam(null,e,[]);return t.success&&(this.newTeamName=""),t},t.updateCurrentTeamName=async function(){if(!this.currentTeam||!this.currentTeam.$id)return{success:!1,error:"No team selected"};const e=String(this.updateTeamNameInput||"").trim();if(!e)return{success:!1,error:"Team name is required"};const t=this.currentTeam.$id,i=await this.updateTeamName(t,e);return i.success&&(this.updateTeamNameInput=""),i},t.inviteToCurrentTeam=async function(){if(!this.currentTeam)return{success:!1,error:"No team selected"};const e=String(this.inviteEmail||"").trim();if(!e)return{success:!1,error:"Email is required"};const t=Array.isArray(this.inviteRoles)?this.inviteRoles.filter((e=>e&&"string"==typeof e)):[],i=await this.inviteMember(this.currentTeam.$id,t,e);return i.success&&(this.inviteEmail="",this.inviteRoles=[],this.listMemberships&&await this.listMemberships(this.currentTeam.$id)),i},t.toggleInviteRole=function(e){if(!e||"string"!=typeof e)return;this.inviteRoles||(this.inviteRoles=[]);const t=this.inviteRoles.indexOf(e);this.inviteRoles=-1===t?[...this.inviteRoles,e]:this.inviteRoles.filter((t=>t!==e))},t.isInviteRoleSelected=function(e){return!(!this.inviteRoles||!Array.isArray(this.inviteRoles))&&this.inviteRoles.includes(e)},t.addCustomInviteRoles=function(e){if(!e||"string"!=typeof e)return;this.inviteRoles||(this.inviteRoles=[]);const t=e.split(",").map((e=>e.trim())).filter((e=>e&&"string"==typeof e)),i=[...this.inviteRoles];for(const e of t)i.includes(e)||i.push(e);this.inviteRoles=i},t.clearInviteRoles=function(){this.inviteRoles=[]},t.startEditingMember=async function(e,t,i){e&&t&&(this.editingMember={teamId:e,membershipId:t,roles:Array.isArray(i)?[...i]:[]},this.inviteRoles=Array.isArray(i)?[...i]:[])},t.cancelEditingMember=function(){this.editingMember=null,this.inviteRoles=[]},t.saveEditingMember=async function(){if(!this.editingMember)return{success:!1,error:"No member being edited"};const{teamId:e,membershipId:t}=this.editingMember,i=Array.isArray(this.inviteRoles)?this.inviteRoles.filter((e=>e&&"string"==typeof e)):[],n=await this.updateMembership(e,t,i);return n.success&&this.cancelEditingMember(),n},t.deleteMember=async function(e,t){if(!e||!t)return{success:!1,error:"Team ID and membership ID are required"};if(!this.hasTeamPermissionSync||!this.hasTeamPermissionSync("removeMembers"))return{success:!1,error:"You do not have permission to remove members"};return await this.deleteMembership(e,t)},t.leaveTeam=async function(e,t){if(!e||!t)return{success:!1,error:"Team ID and membership ID are required"};if(!(this.user&&this.currentTeamMemberships?.some((e=>e.$id===t&&e.userId===this.user.$id))))return{success:!1,error:"You can only leave teams you are a member of"};const i=await this.deleteMembership(e,t);if(i.success&&this.currentTeam&&this.currentTeam.$id===e&&(this.currentTeam=null,this.currentTeamMemberships=[],this.teams&&this.teams.length>0)){const t=this.teams.find((t=>t.$id!==e));t&&(this.viewTeam?await this.viewTeam(t):this.currentTeam=t)}return i},t.viewTeam=async function(e){if(this.currentTeam=e,e&&e.name?this.updateTeamNameInput=e.name:this.updateTeamNameInput="",e&&e.$id&&this.listMemberships){const t=await this.listMemberships(e.$id);t.success&&(this.currentTeamMemberships=t.memberships||[])}return{success:!0}},t.isCurrentTeamOwner=function(){if(!this.currentTeam||!this.currentTeamMemberships||!this.user)return!1;const e=this.currentTeamMemberships.find((e=>e.userId===this.user.$id));return e&&e.roles&&e.roles.includes("owner")},t.isTeamDeletable=function(e){return!(!e||!e.$id)&&((!this._teamImmutableCache||!this._teamImmutableCache[e.$id])&&(!this.currentTeam||this.currentTeam.$id!==e.$id||(this._permissionCache&&this._permissionCache.deleteTeam||!1)))},t.isTeamRenamable=function(e){return!(!e||!e.$id)&&(!this.currentTeam||this.currentTeam.$id!==e.$id||(this._permissionCache&&this._permissionCache.renameTeam||!1))},t.isRoleDeletable=function(e,t){return!(!e||!t)&&(!this.isRolePermanentSync||!this.isRolePermanentSync(e,t))},t.isRoleBeingEdited=function(e,t){return!!(this.editingRole&&e&&t)&&(this.editingRole.teamId===e&&this.editingRole.oldRoleName===t)},t.canManageRolesSync=function(){return this.hasTeamPermissionSync&&this.hasTeamPermissionSync("manageRoles")},t.canManageRoles=t.canManageRolesSync,t.canInviteMembers=function(){return this.hasTeamPermissionSync&&this.hasTeamPermissionSync("inviteMembers")},t.canUpdateMembers=function(){return this.hasTeamPermissionSync&&this.hasTeamPermissionSync("updateMembers")},t.canRemoveMembers=function(){return this.hasTeamPermissionSync&&this.hasTeamPermissionSync("removeMembers")},t.canRenameTeam=function(){return this.hasTeamPermissionSync&&this.hasTeamPermissionSync("renameTeam")},t.canDeleteTeam=function(){return this.hasTeamPermissionSync&&this.hasTeamPermissionSync("deleteTeam")},t.isActionDisabled=function(e){return!!this.inProgress||!(!e||!this.hasTeamPermissionSync)&&!this.hasTeamPermissionSync(e)},t.getMemberDisplayName=function(e){return e?e.userId===this.user?.$id?this.user?.name||this.user?.email||"You":e.userName||e.email||e.userEmail||(!1===e.confirm?"Pending invitation":"Unknown user"):"Unknown user"},t.getMemberEmail=function(e){return e&&(e.email||e.userEmail||e.userId===this.user?.$id&&this.user?.email||"")||"No email"},t.getAllAvailablePermissions=async function(e){const t=new Set;if(["inviteMembers","removeMembers","renameTeam","deleteTeam","manageRoles"].forEach((e=>t.add(e))),e&&this.getAllRoles){const i=await this.getAllRoles(e);if(i&&"object"==typeof i)for(const e of Object.values(i))Array.isArray(e)&&e.forEach((e=>t.add(e)))}const i=window.InduxAppwriteAuthConfig;if(i){const e=await i.getAppwriteConfig(),n=e?.permanentRoles||{},s=e?.templateRoles||{};for(const e of Object.values(n))Array.isArray(e)&&e.forEach((e=>t.add(e)));for(const e of Object.values(s))Array.isArray(e)&&e.forEach((e=>t.add(e)))}return Array.from(t).sort()},t.togglePermission=function(e){if(!e||"string"!=typeof e)return;this.newRolePermissions||(this.newRolePermissions=[]);const t=this.newRolePermissions.indexOf(e);this.newRolePermissions=-1===t?[...this.newRolePermissions,e]:this.newRolePermissions.filter((t=>t!==e))},t.isPermissionSelected=function(e){return!(!this.newRolePermissions||!Array.isArray(this.newRolePermissions))&&this.newRolePermissions.includes(e)},t.addCustomPermissions=function(e){if(!e||"string"!=typeof e)return;this.newRolePermissions||(this.newRolePermissions=[]);const t=e.split(",").map((e=>e.trim())).filter((e=>e&&"string"==typeof e)),i=[...this.newRolePermissions];for(const e of t)i.includes(e)||i.push(e);this.newRolePermissions=i},t.removePermission=function(e){e&&this.newRolePermissions&&Array.isArray(this.newRolePermissions)&&(this.newRolePermissions=this.newRolePermissions.filter((t=>t!==e)))},t.clearPermissions=function(){this.newRolePermissions=[]},t.startEditingRole=async function(e,t){if(!e||!t)return;const i=this.allTeamRoles({$id:e}),n=i&&i[t]?[...i[t]]:[];this.allAvailablePermissions&&0!==this.allAvailablePermissions.length||this.getAllAvailablePermissions&&await this.getAllAvailablePermissions(e),this.editingRole={teamId:e,oldRoleName:t,newRoleName:t,permissions:n},this.newRolePermissions=[...n]},t.cancelEditingRole=function(){this.editingRole=null,this.newRolePermissions=[]},t.saveEditingRole=async function(){if(!this.editingRole)return{success:!1,error:"No role being edited"};const{teamId:e,oldRoleName:t,newRoleName:i}=this.editingRole,n=Array.isArray(this.newRolePermissions)?this.newRolePermissions.filter((e=>e&&"string"==typeof e)):[];let s;if(t!==i&&i.trim()&&(s=await this.renameUserRole(e,t,i.trim()),!s.success))return s;const r=i.trim()||t;return s=await this.updateUserRole(e,r,n),s.success&&this.cancelEditingRole(),s},t.formatTeamDate=function(e){if(!e)return"";try{const t=new Date(e);return isNaN(t.getTime())?e:t.toLocaleDateString()+" "+t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch(t){return e}},t.teamCreatedAt=function(e){return e?this.formatTeamDate(e.$createdAt||e.createdAt):""},t.teamUpdatedAt=function(e){return e?this.formatTeamDate(e.$updatedAt||e.updatedAt):""},t.getCurrentTeamRoles=function(){if(!this.currentTeam||!this.currentTeamMemberships||!this.user)return[];const e=this.currentTeamMemberships.find((e=>e.userId===this.user.$id));return e?.roles||[]},t.hasTeamPermission=async function(e){if(!this.currentTeam||!this.currentTeamMemberships||!this.user)return!1;const t=this.getCurrentTeamRoles(),i=this.currentTeam?.$id;return this.hasPermission?await this.hasPermission(t,e,i):t.includes("owner")},t.hasTeamPermissionSync=function(e){if(!this.currentTeam||!this.currentTeamMemberships||!this.user)return!1;if(this._permissionCache&&"boolean"==typeof this._permissionCache[e])return this._permissionCache[e];return 0===this.getCurrentTeamRoles().filter((e=>"owner"!==e)).length},t.hasRole=function(e){if(!this.currentTeam||!this.currentTeamMemberships||!this.user)return!1;return this.getCurrentTeamRoles().includes(e)},t.getUserRole=async function(){if(!this.currentTeam||!this.currentTeamMemberships||!this.user)return null;const e=this.getCurrentTeamRoles(),t=this.currentTeam?.$id;return this.getPrimaryDisplayRole?await this.getPrimaryDisplayRole(e,t):e[0]||null},t.getUserRoles=async function(){if(!this.currentTeam||!this.currentTeamMemberships||!this.user)return[];const e=this.getCurrentTeamRoles(),t=this.currentTeam?.$id;return this.normalizeRolesForDisplay?await this.normalizeRolesForDisplay(e,t):e}),t.viewTeam&&!t._viewTeamWrapped){const i=t.viewTeam;t.viewTeam=async function(t){const n=await i.call(this,t);return e&&await e.call(this),this.getAllAvailablePermissions&&t&&t.$id&&(this.allAvailablePermissions=await this.getAllAvailablePermissions(t.$id)),n},t._viewTeamWrapped=!0}}else t||setTimeout(e,50)};setTimeout(e,100)}if(window.InduxAppwriteAuthTeamsCallbacks={handleCallbacks:R},document.addEventListener("alpine:init",(()=>{try{_()}catch(e){}})),"undefined"!=typeof Alpine)try{_()}catch(e){}function P(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i._createAnonymousSession?i._createAnonymousSession=async function(){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(!this._guestAuto&&!this._guestManual)return{success:!1,error:"Guest sessions are not enabled"};try{const e=await this._appwrite.account.createAnonymousSession();return this.session=e,this.user=await this._appwrite.account.get(),this.isAuthenticated=!0,this.isAnonymous=!0,this._syncStateToStorage&&this._syncStateToStorage(this),window.dispatchEvent(new CustomEvent("indux:auth:anonymous",{detail:{user:this.user}})),{success:!0,user:this.user}}catch(e){return this.error=e.message,this.isAuthenticated=!1,this.isAnonymous=!1,{success:!1,error:e.message}}}:i||setTimeout(t,50)};setTimeout(t,100)}function L(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i.createMagicLink?(i.createMagicLink=async function(t,i=window.location.href){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};if(this.isAuthenticated&&!this.isAnonymous)return{success:!1,error:"Already signed in. Please logout first."};const n=await e.getAppwriteConfig();if(n&&!n.magic)return{success:!1,error:"Magic link authentication is not enabled"};const s=new URL(window.location.href),r=i===window.location.href?`${s.origin}${s.pathname}`:i;this.inProgress=!0,this.error=null,this.magicLinkExpired=!1;try{if(!this._appwrite||!this._appwrite.account)return{success:!1,error:"Account instance not available"};const e=this._appwrite.account;if("function"==typeof e.createMagicURLSession){const i=await e.createMagicURLSession("unique()",t,r);return this.magicLinkSent=!0,this.magicLinkExpired=!1,this.error=null,window.dispatchEvent(new CustomEvent("indux:auth:magic-link-sent",{detail:{email:t}})),{success:!0,message:"Magic link sent to email",token:i}}if("function"==typeof e.createMagicURLToken){const n=await e.createMagicURLToken("unique()",t,i);return this.magicLinkSent=!0,this.magicLinkExpired=!1,this.error=null,window.dispatchEvent(new CustomEvent("indux:auth:magic-link-sent",{detail:{email:t}})),{success:!0,message:"Magic link sent to email",token:n}}return{success:!1,error:"Magic link method not available. Please ensure you are using the latest Appwrite SDK."}}catch(e){return this.error=e.message,this.magicLinkSent=!1,this.magicLinkExpired=!1,{success:!1,error:e.message}}finally{this.inProgress=!1}},i.sendMagicLink=async function(e,t=window.location.href){let i=null,n=null,s=null;if(null==e){let e=null;if("undefined"!=typeof window&&window.event&&(e=window.event.target),e){const t=e.closest("form");if(t)n=t.querySelector('input[type="email"]'),n&&(i=n.value);else{const t=e.parentElement;t&&(n=t.querySelector('input[type="email"]'),n&&(i=n.value))}}n||(n=document.querySelector('input[type="email"]'),n&&(i=n.value))}else if("string"==typeof e)try{const t=document.querySelector(e);t&&"INPUT"===t.tagName&&"email"===t.type?(n=t,i=t.value):i=e}catch(t){i=e}else if(e&&"object"==typeof e)if("INPUT"===e.tagName||e.matches?.('input[type="email"]'))n=e,i=n.value;else{if(!("email"in e))return{success:!1,error:"Invalid email input. Provide an input element, selector, {email} object, email string, or nothing (auto-find)."};i=e.email,s=e}if(!i||!i.trim())return{success:!1,error:"Email is required"};const r=await this.createMagicLink(i.trim(),t);return r.success&&Promise.resolve().then((()=>{n?(n.value="",n.dispatchEvent(new Event("input",{bubbles:!0}))):s&&(s.email="")})),r},i.handleMagicLinkCallback=async function(t,i){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};this.inProgress=!0,this.error=null,this.magicLinkExpired=!1,this.magicLinkSent=!1;try{if(this.session&&this.isAnonymous)try{await this._appwrite.account.deleteSession(this.session.$id)}catch(e){}const n=await this._appwrite.account.createSession(t,i);this.session=n,this.user=await this._appwrite.account.get(),this.isAuthenticated=!0,this.isAnonymous=!1,this.magicLinkSent=!1,this.magicLinkExpired=!1,this.error=null;try{sessionStorage.removeItem("indux:magic-link:callback")}catch(e){}this._syncStateToStorage&&this._syncStateToStorage(this);const s=await e.getAppwriteConfig();if(s?.teams&&this.listTeams)try{await this.listTeams(),(s.permanentTeams||s.templateTeams)&&window.InduxAppwriteAuthTeamsDefaults?.ensureDefaultTeams&&await window.InduxAppwriteAuthTeamsDefaults.ensureDefaultTeams(this)}catch(e){console.warn("[Indux Appwrite Auth] Failed to load teams after magic link login:",e)}return window.dispatchEvent(new CustomEvent("indux:auth:login",{detail:{user:this.user}})),{success:!0,user:this.user}}catch(e){const n=e.message||"",s=e.code||e.statusCode||"",r=429===s||n.includes("Rate limit")||n.includes("429"),o=!r&&n&&(n.includes("expired")||n.includes("Invalid token")||n.includes("invalid")||n.includes("not found")||n.includes("404")||n.includes("prohibited")||404===s);if(r){try{sessionStorage.setItem("indux:magic-link:callback",JSON.stringify({userId:t,secret:i}))}catch(e){}this.error="Rate limit exceeded. Please wait a moment and refresh the page.",this.isAuthenticated=!1,this.isAnonymous=!1,this.magicLinkExpired=!1}else if(o){try{sessionStorage.removeItem("indux:magic-link:callback")}catch(e){}this.magicLinkExpired=!0,this.magicLinkSent=!1,this.error=null}else{try{sessionStorage.removeItem("indux:magic-link:callback")}catch(e){}this.error=e.message,this.magicLinkExpired=!1,this.magicLinkSent=!1}return this.isAuthenticated=!1,this.isAnonymous=!1,this._syncStateToStorage&&this._syncStateToStorage(this),{success:!1,error:e.message}}finally{this.inProgress=!1}}):i||setTimeout(t,50)};setTimeout(t,100)}function k(){window.addEventListener("indux:auth:callback:expired",(async e=>{const t=Alpine.store("auth");if(!t)return;e.detail;let i=!1;if(t.isAuthenticated&&t.user)i=!0;else if(t._appwrite)try{const e=await t._appwrite.account.get();if(e){i=!0,t.user=e,t.isAuthenticated=!0;try{const e=(await t._appwrite.account.listSessions()).sessions||[],i=e.find((e=>!0===e.current))||e[0];i&&(t.session=i,t.isAnonymous="anonymous"===i.provider)}catch(e){console.warn("[Indux Appwrite Auth] Could not get session info:",e)}}}catch(e){i=!1}t.magicLinkExpired=!0,t.magicLinkSent=!1,t.error=null,i||(t.isAuthenticated=!1,t.isAnonymous=!1,t.user=null,t.session=null),t.inProgress=!1,t._syncStateToStorage&&t._syncStateToStorage(t),requestAnimationFrame((()=>{const e=Alpine.store("auth");e&&(e.isAuthenticated,e.magicLinkExpired,e.user)}))})),window.addEventListener("indux:auth:callback:magic",(async e=>{const t=Alpine.store("auth");if(!t)return;const i=e.detail;try{sessionStorage.setItem("indux:magic-link:callback",JSON.stringify({userId:i.userId,secret:i.secret}))}catch(e){console.warn("[Indux Appwrite Auth] Could not store callback:",e)}await t.handleMagicLinkCallback(i.userId,i.secret)}))}function M(){if("undefined"==typeof Alpine)return;const e=window.InduxAppwriteAuthConfig;if(!e)return;const t=()=>{const i=Alpine.store("auth");i&&!i.loginOAuth?i.loginOAuth=async function(t,i=window.location.href,n=window.location.href){if(this._appwrite||(this._appwrite=await e.getAppwriteClient()),!this._appwrite)return{success:!1,error:"Appwrite not configured"};const s=await e.getAppwriteConfig();if(s&&!s.oauth)return{success:!1,error:"OAuth authentication is not enabled"};const r=new URL(window.location.href),o=`${r.origin}${r.pathname}`,a=`${r.origin}${r.pathname}`;if(this.isAnonymous&&this.session)try{await this._appwrite.account.deleteSession(this.session.$id),this.session=null,this.user=null,this.isAuthenticated=!1,this.isAnonymous=!1}catch(e){console.warn("[Indux Appwrite Auth] Failed to delete anonymous session before OAuth:",e)}sessionStorage.setItem("indux:oauth:redirect","true"),this._oauthProvider=t;try{localStorage.setItem("indux:oauth:provider",t)}catch(e){sessionStorage.setItem("indux:oauth:provider",t)}this.inProgress=!0,this.error=null;try{const e=await this._appwrite.account.createOAuth2Token(t,o,a,["email"]);let i=null;if("string"==typeof e)i=e;else if(e?.redirectUrl)i=e.redirectUrl;else if(e?.url)i=e.url;else if(e&&"object"==typeof e){const t=Object.values(e).find((e=>"string"==typeof e&&(e.startsWith("http://")||e.startsWith("https://"))));t&&(i=t)}return this.error=null,i?(requestAnimationFrame((()=>{window.location.href=i})),{success:!0,redirectUrl:i}):(console.warn("[Indux Appwrite Auth] Could not extract redirect URL from token:",e),this.inProgress=!1,{success:!1,error:"Could not extract redirect URL"})}catch(e){return e.message.includes("No redirect URL")||e.message.includes("redirect")?(console.warn("[Indux Appwrite Auth] OAuth redirect error (suppressed from UI):",e.message),this.error=null,this.inProgress=!1):(this.error=e.message,this.inProgress=!1),{success:!1,error:e.message}}}:i||setTimeout(t,50)};setTimeout(t,100)}function z(){window.addEventListener("indux:auth:callback:oauth",(async e=>{const t=Alpine.store("auth");if(!t)return;const i=e.detail;sessionStorage.removeItem("indux:oauth:redirect");let n=null;try{n=localStorage.getItem("indux:oauth:provider")}catch(e){n=sessionStorage.getItem("indux:oauth:provider")}if(n?t._oauthProvider=n:console.warn("[Indux Appwrite Auth] No OAuth provider found in storage"),t._appwrite||(t._appwrite=await window.InduxAppwriteAuthConfig.getAppwriteClient()),t._appwrite){t.inProgress=!0,t.error=null,t.magicLinkExpired=!1,t.magicLinkSent=!1;try{if(t.session&&t.isAnonymous)try{await t._appwrite.account.deleteSession(t.session.$id)}catch(e){}try{const e=await t._appwrite.account.createSession(i.userId,i.secret);t.session=e,t.user=await t._appwrite.account.get(),t.isAuthenticated=!0,t.isAnonymous=!1,t.magicLinkSent=!1,t.magicLinkExpired=!1,t.error=null}catch(e){const i=e.message?.includes("prohibited");if(!i)throw e;t.user=await t._appwrite.account.get();try{const e=(await t._appwrite.account.listSessions()).sessions||[],i=e.find((e=>"anonymous"!==e.provider&&"magic-url"!==e.provider))||e.find((e=>!0===e.current));i?t.session=i:e.length>0?t.session=e[0]:t.session=await t._appwrite.account.getSession("current")}catch(e){console.warn("[Indux Appwrite Auth] Could not get session info:",e)}t.isAuthenticated=!0,t.isAnonymous=!1,t.magicLinkSent=!1,t.magicLinkExpired=!1,t.error=null}t._syncStateToStorage&&t._syncStateToStorage(t);const e=await window.InduxAppwriteAuthConfig.getAppwriteConfig();if(e?.teams&&t.listTeams)try{await t.listTeams(),(e.permanentTeams||e.templateTeams)&&window.InduxAppwriteAuthTeamsDefaults?.ensureDefaultTeams&&await window.InduxAppwriteAuthTeamsDefaults.ensureDefaultTeams(t)}catch(e){console.warn("[Indux Appwrite Auth] Failed to load teams after OAuth login:",e)}window.dispatchEvent(new CustomEvent("indux:auth:login",{detail:{user:t.user}}))}catch(e){t.error=e.message,t.isAuthenticated=!1,t.isAnonymous=!1,t._syncStateToStorage&&t._syncStateToStorage(t)}finally{t.inProgress=!1}}else t.error="Appwrite not configured"}))}function j(){function e(){const e=new URL(window.location.href);["userId","secret","expire","project","teamId","membershipId"].forEach((t=>{for(;e.searchParams.has(t);)e.searchParams.delete(t)})),e.hash="",window.history.replaceState({},"",e.toString())}window.InduxAppwriteAuthConfig&&(window.InduxAppwriteAuthCallbacks={detect:function(){const e=new URLSearchParams(window.location.search),t=e.get("userId"),i=e.get("secret"),n=e.get("expire");let s=null;try{const e=sessionStorage.getItem("indux:magic-link:callback");e&&(s=JSON.parse(e))}catch(e){}const r="true"===sessionStorage.getItem("indux:oauth:redirect"),o=e.get("teamId"),a=e.get("membershipId"),c=!!(o&&a&&t&&i);return{userId:t||s?.userId,secret:i||s?.secret,expire:n,teamId:o,membershipId:a,isOAuth:r,isTeamInvite:c,hasCallback:!(!t&&!s?.userId||!i&&!s?.secret),hasExpired:!!n&&!t&&!i}},process:async function(t){const i=Alpine.store("auth");return i&&i._appwrite?(i._appwrite,e(),t.hasExpired?(window.dispatchEvent(new CustomEvent("indux:auth:callback:expired",{detail:t})),{handled:!0,type:"expired"}):t.hasCallback?t.isTeamInvite?(window.dispatchEvent(new CustomEvent("indux:auth:callback:team",{detail:t})),{handled:!0,type:"team"}):t.isOAuth?(window.dispatchEvent(new CustomEvent("indux:auth:callback:oauth",{detail:t})),{handled:!0,type:"oauth"}):(window.dispatchEvent(new CustomEvent("indux:auth:callback:magic",{detail:t})),{handled:!0,type:"magic"}):{handled:!1}):{handled:!1}},cleanupUrl:e})}return window.InduxAppwriteAuthTeamsConvenience={initialize:_},document.addEventListener("alpine:init",(()=>{try{P()}catch(e){}})),window.InduxAppwriteAuthAnonymous={initialize:P},document.addEventListener("alpine:init",(()=>{try{L(),k()}catch(e){}})),window.InduxAppwriteAuthMagicLinks={initialize:L,handleCallbacks:k},document.addEventListener("alpine:init",(()=>{try{M(),z()}catch(e){}})),window.InduxAppwriteAuthOAuth={initialize:M,handleCallbacks:z},window.InduxAppwriteAuthConfig?j():document.addEventListener("DOMContentLoaded",(()=>{window.InduxAppwriteAuthConfig&&j()})),indux_appwrite_auth}requireIndux_appwrite_auth();let jsyaml=null,yamlLoadingPromise=null;async function loadYamlLibrary(){return jsyaml||(yamlLoadingPromise||(yamlLoadingPromise=new Promise(((e,t)=>{const i=document.createElement("script");i.src="https://cdn.jsdelivr.net/npm/js-yaml/dist/js-yaml.min.js",i.onload=()=>{void 0!==window.jsyaml?(jsyaml=window.jsyaml,e(jsyaml)):(console.error("[Indux Data] js-yaml failed to load - jsyaml is undefined"),yamlLoadingPromise=null,t(new Error("js-yaml failed to load")))},i.onerror=e=>{console.error("[Indux Data] Script failed to load:",e),yamlLoadingPromise=null,t(e)},document.head.appendChild(i)})),yamlLoadingPromise))}async function initializeDataSourcesPlugin(){const e={all:[],_initialized:!1,_currentUrl:window.location.pathname};Alpine.store("data",e);const t=new Map,i=new Map;window.addEventListener("localechange",(async e=>{e.detail.locale;const n=Alpine.store("data");n&&Alpine.store("data",{...n,_localeChanging:!0});try{const e=await r();if(!e?.data)return;const n=[];Object.entries(e.data).forEach((([e,t])=>{if("object"==typeof t&&!t.url){Object.keys(t).some((e=>2===e.length&&"string"==typeof t[e]))&&n.push(e)}})),n.forEach((e=>{const n=[];for(const i of t.keys())i.startsWith(`${e}:`)&&n.push(i);n.forEach((e=>t.delete(e)));const s=[];for(const t of i.keys())t.startsWith(`${e}:`)&&s.push(t);s.forEach((e=>i.delete(e)))}));const s=Alpine.store("data");if(s&&s.all){const e=s.all.filter((e=>!n.includes(e.contentType))),t={...s,all:e};n.forEach((e=>{delete t[e]})),Alpine.store("data",{...t,_localeChanging:!1})}}catch(e){console.error("[Indux Data] Error handling locale change:",e),t.clear(),i.clear(),Alpine.store("data",{all:[],_initialized:!0,_localeChanging:!1})}}));let n=!1,s=!1;async function r(){if(window.InduxComponentsRegistry?.manifest)return window.InduxComponentsRegistry.manifest;try{const e=await fetch("/manifest.json");return await e.json()}catch(e){return console.error("[Indux Data] Failed to load manifest:",e),null}}function o(e){return"string"!=typeof e?e:e.replace(/\$\{([^}]+)\}/g,((e,t)=>"undefined"!=typeof process&&process.env&&process.env[t]?process.env[t]:"undefined"!=typeof window&&window.env&&window.env[t]?window.env[t]:e))}function a(e,t){if(null==t)return e;if(null==e)return t;if(Array.isArray(e)&&Array.isArray(t)){const i=Math.max(e.length,t.length),n=[];for(let s=0;s<i;s++){const i=e[s],r=t[s];void 0!==i&&void 0!==r?n.push(a(i,r)):void 0!==i?n.push(i):n.push(r)}return n}if("object"==typeof e&&"object"==typeof t&&!Array.isArray(e)&&!Array.isArray(t)){const i={...t};for(const n in e)n.startsWith("_")?i[n]=e[n]:void 0!==e[n]&&(i[n]=a(e[n],t[n]));return i}return void 0!==e?e:t}async function c(e){try{const i=new URL(o(e.url));e.params&&Object.entries(e.params).forEach((([e,t])=>{i.searchParams.set(e,o(t))}));const n={};e.headers&&Object.entries(e.headers).forEach((([e,t])=>{n[e]=o(t)}));const s=await fetch(i,{method:e.method||"GET",headers:n});if(!s.ok)throw new Error(`API request failed: ${s.status} ${s.statusText}`);let r=await s.json();return e.transform&&(t=r,r=e.transform.split(".").reduce(((e,t)=>e&&void 0!==e[t]?e[t]:void 0),t)),r}catch(t){return console.error("[Indux Data] Failed to load API dataSource:",t),Array.isArray(e.defaultValue)?e.defaultValue:e.defaultValue||[]}var t}async function l(e,s="en"){const o=`${e}:${s}`;if(t.has(o)){const i=t.get(o);return n||u(e,i),i}if(i.has(o))return i.get(o);const l=(async()=>{try{const i=await r();if(!i?.data)return console.warn("[Indux Data] No data sources defined in manifest.json"),null;const l=i.data[e];if(!l)return null;let d,h;if("string"==typeof l){const e=await fetch(l),t=e.headers.get("content-type");if(t?.includes("application/json")||l.endsWith(".json"))d=await e.json();else if(t?.includes("text/yaml")||l.endsWith(".yaml")||l.endsWith(".yml")){const t=await e.text();d=(await loadYamlLibrary()).load(t)}else try{const t=await e.text();d=JSON.parse(t)}catch(e){d=(await loadYamlLibrary()).load(text)}}else if(l.url)d=await c(l);else{if(!l[s])return console.warn(`[Indux Data] No valid source found for dataSource "${e}"`),null;{const t=l[s];let i=null;if("string"==typeof t){const e=await fetch(t),n=e.headers.get("content-type");if(n?.includes("application/json")||t.endsWith(".json"))i=await e.json();else if(n?.includes("text/yaml")||t.endsWith(".yaml")||t.endsWith(".yml")){const t=await e.text();i=(await loadYamlLibrary()).load(t)}else try{const t=await e.text();i=JSON.parse(t)}catch(e){i=(await loadYamlLibrary()).load(text)}}else{if(!t.url)return console.warn(`[Indux Data] No valid source found for dataSource "${e}" in locale "${s}"`),null;i=await c(t)}const n=function(e){if("object"!=typeof e||null===e)return null;const t=["url","headers","params","transform","defaultValue"];for(const i of Object.keys(e))if(!t.includes(i)&&"string"==typeof e[i]&&/^[a-zA-Z0-9_-]+$/.test(i))return i;return null}(l);if(n&&n!==s){const t=l[n];let s=null;try{if("string"==typeof t){const e=await fetch(t),i=e.headers.get("content-type");if(i?.includes("application/json")||t.endsWith(".json"))s=await e.json();else if(i?.includes("text/yaml")||t.endsWith(".yaml")||t.endsWith(".yml")){const t=await e.text();s=(await loadYamlLibrary()).load(t)}else try{const t=await e.text();s=JSON.parse(t)}catch(e){s=(await loadYamlLibrary()).load(text)}}else t?.url&&(s=await c(t));d=s?a(i,s):i}catch(t){console.warn(`[Indux Data] Failed to load fallback locale "${n}" for "${e}", using current locale only`),d=i}}else d=i}}const m="string"==typeof l?"local":"api",p="string"==typeof l?l:l.url;return Array.isArray(d)?h=d.map((t=>({...t,contentType:e,_loadedFrom:p,_sourceType:m,_locale:s}))):"object"==typeof d&&(h={...d,contentType:e,_loadedFrom:p,_sourceType:m,_locale:s}),t.set(o,h),n||u(e,h),h}catch(t){return console.error(`[Indux Data] Failed to load dataSource "${e}":`,t),null}finally{i.delete(o)}})();return i.set(o,l),l}function u(e,t){if(n)return;const i=Alpine.store("data"),s=i.all.filter((t=>t.contentType!==e));Array.isArray(t)?s.push(...t):s.push(t),Alpine.store("data",{...i,[e]:t,all:s,_initialized:!0})}let d=null;function h(){return d||(d=function(){const e=Object.create(null);return e[Symbol.toPrimitive]=function(e){return"number"===e?0:""},e.valueOf=function(){return""},e.toString=function(){return""},e.route=function(t){return e},Object.defineProperty(e,"length",{value:0,writable:!1,enumerable:!1,configurable:!1}),Object.defineProperty(e,Symbol.toPrimitive,{value:function(e){return"number"===e?0:""},writable:!1,enumerable:!1,configurable:!1}),new Proxy(e,{get(e,t){if(t!==Symbol.iterator&&"then"!==t&&"catch"!==t&&"finally"!==t&&t!==Symbol.toStringTag&&t!==Symbol.hasInstance&&"constructor"!==t&&"__proto__"!==t&&"prototype"!==t){if(t in e||t===Symbol.toPrimitive){const i=e[t];if(void 0!==i)return i}return e}},has:(e,t)=>"string"==typeof t||t in e||t===Symbol.toPrimitive})}()),d}function m(e){return new Proxy(e,{get(e,t){if(t!==Symbol.iterator&&"then"!==t&&"catch"!==t&&"finally"!==t)return t===Symbol.toPrimitive?function(){return e[t]||""}:e[t]}})}function p(e){return new Proxy(e,{get(e,t){if(t!==Symbol.iterator&&"then"!==t&&"catch"!==t&&"finally"!==t){if("route"===t)return function(t){return e&&"object"==typeof e?g(e,t,Array.isArray(e)&&e.length>0&&e[0]&&e[0].contentType?e[0].contentType:void 0):new Proxy({},{get(){}})};if("length"===t)return e.length;if("string"==typeof t&&!isNaN(Number(t))){const i=Number(t);return i>=0&&i<e.length?m(e[i]):h()}return"filter"===t||"map"===t||"find"===t||"findIndex"===t||"some"===t||"every"===t||"reduce"===t||"forEach"===t||"slice"===t?e[t].bind(e):h()}}})}function f(e){return new Proxy(e,{get(e,t){if(t===Symbol.iterator||"then"===t||"catch"===t||"finally"===t)return;if(t===Symbol.toPrimitive)return function(){return e[t]||""};const i=e[t];return Array.isArray(i)?p(i):"object"==typeof i&&null!==i?f(i):void 0===i?h():i}})}function g(e,t,i){let n=null;try{const i=Alpine.store("data");let s=(i?._currentUrl||window.location.pathname).split("/").filter((e=>e));const r=Alpine.store("locale");if(r&&r.available&&s.length>0){const e=s[0];r.available.includes(e)&&(s=s.slice(1))}e&&"object"==typeof e&&(n=v(e,t,s))}catch(e){}return new Proxy({},{get(t,i){try{if(!n)return"string"==typeof i?"":void 0;if(i in n)return n[i];if("group"===i){const t=A(e,n);return t?.group||""}return}catch(e){return}}})}let w=window.location.pathname;window.addEventListener("popstate",(()=>{if(window.location.pathname!==w){w=window.location.pathname;const e=Alpine.store("data");e&&e._initialized&&(e._currentUrl=window.location.pathname)}}));const y=history.pushState,b=history.replaceState;function v(e,t,i){if(!i||0===i.length)return null;if(Array.isArray(e)){for(const n of e)if("object"==typeof n&&null!==n){if(t in n){const e=n[t];if(i.some((t=>t===e)))return n}const e=v(n,t,i);if(e)return e}}else if("object"==typeof e&&null!==e)for(const n in e){const s=v(e[n],t,i);if(s)return s}return null}function A(e,t){if(Array.isArray(e)){for(const i of e)if("object"==typeof i&&null!==i){if(i.group&&Array.isArray(i.items)&&i.items.includes(t))return i;const e=A(i,t);if(e)return e}}else if("object"==typeof e&&null!==e)for(const i in e){const n=A(e[i],t);if(n)return n}return null}if(history.pushState=function(...e){if(y.apply(history,e),window.location.pathname!==w){w=window.location.pathname;const e=Alpine.store("data");e&&e._initialized&&(e._currentUrl=window.location.pathname)}},history.replaceState=function(...e){if(b.apply(history,e),window.location.pathname!==w){w=window.location.pathname;const e=Alpine.store("data");e&&e._initialized&&(e._currentUrl=window.location.pathname)}},Alpine.magic("x",(()=>{const e=new Map,t=Alpine.store("data"),i=new Map;return new Proxy({},{get(n,s){if(s===Symbol.iterator||"then"===s||"catch"===s||"finally"===s)return;if(i.has(s))return i.get(s);const r=t[s];if(document.documentElement.lang||Alpine.store("locale"),!r&&!e.has(s)){const t=new Promise((e=>{setTimeout((()=>{const t=document.documentElement.lang||Alpine.store("locale")?.current||"en";e(l(s,t))}),0)}));e.set(s,t);const n=h();return i.set(s,n),t.finally((()=>{i.delete(s),e.delete(s)})),n}return r?new Proxy(r,{get(e,t){if(t===Symbol.iterator||"then"===t||"catch"===t||"finally"===t)return;if("route"===t)return function(t){return e&&"object"==typeof e?g(e,t):new Proxy({},{get(){}})};if(t===Symbol.toPrimitive)return function(){return""};if(Array.isArray(e)){if("length"===t)return e.length;if("string"==typeof t&&!isNaN(Number(t))){const i=Number(t);return i>=0&&i<e.length?m(e[i]):h()}if("filter"===t||"map"===t||"find"===t||"findIndex"===t||"some"===t||"every"===t||"reduce"===t||"forEach"===t||"slice"===t)return e[t].bind(e)}const i=e[t];return i?Array.isArray(i)?p(i):"object"==typeof i&&null!==i?f(i):i:h()}}):h()}})})),!n&&!s){n=!0;try{Alpine.store("data",{all:[],_initialized:!0})}finally{n=!1,s=!0}}}function initializeDropdownPlugin(){var e,t;!function(){const e=document.body;e.hasAttribute("x-data")||e.setAttribute("x-data","{}")}(),e="dropdown",t=(e,{modifiers:t,expression:i},{effect:n,evaluateLater:s})=>{let r,o,a,c;n((()=>{setTimeout((()=>{if(!window.Alpine)return void console.warn("[Indux] Alpine not available for dropdown processing");const n=Math.random().toString(36).substr(2,9);let l;if(i?i.includes("${")||i.includes("`")?s(i)((e=>{l=e})):l=i:l=`dropdown-${n}`,l&&"TEMPLATE"===document.getElementById(l)?.tagName){const t=document.getElementById(l);r=t.content.cloneNode(!0).firstElementChild;const i=`dropdown-${n}`;r.setAttribute("id",i),document.body.appendChild(r),e.setAttribute("popovertarget",i),Alpine.initTree(r)}else{if(r=document.getElementById(l),!r){if(window.InduxComponentsRegistry&&window.InduxComponentsLoader){const t=l;if(window.InduxComponentsRegistry.registered.has(t)){const i=async()=>{const i=window.InduxComponentsLoader,n=await i.loadComponent(t);if(n){const i=document.createElement("div");i.innerHTML=n.trim();const s=i.querySelector(`#${l}`);s?(r=s.cloneNode(!0),r.setAttribute("id",l),document.body.appendChild(r),e.setAttribute("popovertarget",l),Alpine.initTree(r),u()):console.warn(`[Indux] Menu with id "${l}" not found in component "${t}"`)}else console.warn(`[Indux] Failed to load component "${t}" for dropdown`)};return void(window.__induxComponentsInitialized?i():window.addEventListener("indux:components-ready",i))}}return void console.warn(`[Indux] Dropdown menu with id "${l}" not found`)}e.setAttribute("popovertarget",l)}function u(){if(!r)return;r.setAttribute("popover","");const i=`--dropdown-${n}`;if(e.style.setProperty("anchor-name",i),r.style.setProperty("position-anchor",i),t.includes("hover")){const t=()=>{r&&!r.matches(":popover-open")&&(clearTimeout(o),clearTimeout(a),r.showPopover())};c=()=>{clearTimeout(a),a=setTimeout((()=>{if(r?.matches(":popover-open")){const t=e.matches(":hover"),i=r.matches(":hover");t||i||r.hidePopover()}}),300)},e.addEventListener("mouseenter",t),e.addEventListener("mouseleave",c)}if(r.addEventListener("keydown",(t=>{const i=r.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"]), li'),n=Array.from(i).indexOf(t.target);if("ArrowDown"===t.key){t.preventDefault();const e=i[(n+1)%i.length];"LI"===e.tagName&&e.setAttribute("tabindex","0"),e.focus()}else if("ArrowUp"===t.key){t.preventDefault();const e=i[(n-1+i.length)%i.length];"LI"===e.tagName&&e.setAttribute("tabindex","0"),e.focus()}else if("Tab"===t.key){const i=r.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');if(!t.shiftKey&&t.target===i[i.length-1]){t.preventDefault(),r.hidePopover();const i=document.querySelectorAll('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])'),n=i[Array.from(i).indexOf(e)+1];n&&n.focus()}t.shiftKey&&t.target===i[0]&&r.hidePopover()}else if("Escape"===t.key)r.hidePopover(),e.focus();else if(("Enter"===t.key||" "===t.key)&&"LI"===t.target.tagName){const e=t.target.querySelector("a");e&&(t.preventDefault(),e.click())}})),r.addEventListener("toggle",(e=>{"open"===e.newState&&r.querySelectorAll("li").forEach(((e,t)=>{e.hasAttribute("tabindex")||e.setAttribute("tabindex","-1"),0!==t||r.querySelector('button, [href], input, select, textarea, [tabindex="0"]')||(e.setAttribute("tabindex","0"),e.focus())}))})),t.includes("hover")){r.addEventListener("mouseenter",(()=>{clearTimeout(a),clearTimeout(o)})),r.addEventListener("mouseleave",(()=>{c&&c()}));const e=()=>{clearTimeout(a)};setTimeout((()=>{r.querySelectorAll('li, button, a, [role="menuitem"]').forEach((t=>{t.addEventListener("mouseenter",e)}))}),10)}}u()}))}))},Alpine.directive(e,t)}"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&initializeDataSourcesPlugin()})),document.addEventListener("alpine:init",initializeDataSourcesPlugin),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{window.Alpine?initializeDropdownPlugin():document.addEventListener("alpine:init",initializeDropdownPlugin)})):window.Alpine?initializeDropdownPlugin():document.addEventListener("alpine:init",initializeDropdownPlugin),document.addEventListener("alpine:init",initializeDropdownPlugin),document.addEventListener("click",(e=>{const t=e.target.closest("button[popovertarget]");if(!t)return;const i=t.getAttribute("popovertarget"),n=document.getElementById(i);if(n&&"DIALOG"===n.tagName&&n.hasAttribute("popover")){document.querySelectorAll("menu[popover]:popover-open").forEach((e=>{n.contains(e)||e.hidePopover()}))}}));var indux_icons={},hasRequiredIndux_icons;function requireIndux_icons(){return hasRequiredIndux_icons||(hasRequiredIndux_icons=1,function(e){var t=function(e){const t=Object.freeze({left:0,top:0,width:16,height:16}),i=Object.freeze({rotate:0,vFlip:!1,hFlip:!1}),n=Object.freeze({...t,...i}),s=Object.freeze({...n,body:"",hidden:!1});function r(e,t){const n=function(e,t){const i={};!e.hFlip!=!t.hFlip&&(i.hFlip=!0),!e.vFlip!=!t.vFlip&&(i.vFlip=!0);const n=((e.rotate||0)+(t.rotate||0))%4;return n&&(i.rotate=n),i}(e,t);for(const r in s)r in i?r in e&&!(r in n)&&(n[r]=i[r]):r in t?n[r]=t[r]:r in e&&(n[r]=e[r]);return n}function o(e,t,i){const n=e.icons,s=e.aliases||Object.create(null);let o={};function a(e){o=r(n[e]||s[e],o)}return a(t),i.forEach(a),r(e,o)}const a=/^[a-z0-9]+(-[a-z0-9]+)*$/,c=(e,t,i,n="")=>{const s=e.split(":");if("@"===e.slice(0,1)){if(s.length<2||s.length>3)return null;n=s.shift().slice(1)}if(s.length>3||!s.length)return null;if(s.length>1){const e=s.pop(),i=s.pop(),r={provider:s.length>0?s[0]:n,prefix:i,name:e};return t&&!l(r)?null:r}const r=s[0],o=r.split("-");if(o.length>1){const e={provider:n,prefix:o.shift(),name:o.join("-")};return t&&!l(e)?null:e}if(i&&""===n){const e={provider:n,prefix:"",name:r};return t&&!l(e,i)?null:e}return null},l=(e,t)=>!!e&&!(""!==e.provider&&!e.provider.match(a)||!(t&&""===e.prefix||e.prefix.match(a))||!e.name.match(a)),u={provider:"",aliases:{},not_found:{},...t};function d(e,t){for(const i in t)if(i in e&&typeof e[i]!=typeof t[i])return!1;return!0}const h=Object.create(null);function m(e,t){const i=h[e]||(h[e]=Object.create(null));return i[t]||(i[t]=function(e,t){return{provider:e,prefix:t,icons:Object.create(null),missing:new Set}}(e,t))}function p(e,t){return function(e){if("object"!=typeof e||null===e)return null;const t=e;if("string"!=typeof t.prefix||!e.icons||"object"!=typeof e.icons)return null;if(!d(e,u))return null;const i=t.icons;for(const e in i){const t=i[e];if(!e.match(a)||"string"!=typeof t.body||!d(t,s))return null}const n=t.aliases||Object.create(null);for(const e in n){const t=n[e],r=t.parent;if(!e.match(a)||"string"!=typeof r||!i[r]&&!n[r]||!d(t,s))return null}return t}(t)?function(e,t){const i=[];if("object"!=typeof e||"object"!=typeof e.icons)return i;e.not_found instanceof Array&&e.not_found.forEach((e=>{t(e,null),i.push(e)}));const n=function(e){const t=e.icons,i=e.aliases||Object.create(null),n=Object.create(null);return Object.keys(t).concat(Object.keys(i)).forEach((function e(s){if(t[s])return n[s]=[];if(!(s in n)){n[s]=null;const t=i[s]&&i[s].parent,r=t&&e(t);r&&(n[s]=[t].concat(r))}return n[s]})),n}(e);for(const s in n){const r=n[s];r&&(t(s,o(e,s,r)),i.push(s))}return i}(t,((t,i)=>{i?e.icons[t]=i:e.missing.add(t)})):[]}function f(e,t){let i=[];return("string"==typeof e?[e]:Object.keys(h)).forEach((e=>{("string"==typeof e&&"string"==typeof t?[t]:Object.keys(h[e]||{})).forEach((t=>{const n=m(e,t);i=i.concat(Object.keys(n.icons).map((i=>(""!==e?"@"+e+":":"")+t+":"+i)))}))})),i}let g=!1;function w(e){const t="string"==typeof e?c(e,!0,g):e;if(t){const e=m(t.provider,t.prefix),i=t.name;return e.icons[i]||(e.missing.has(i)?null:void 0)}}function y(e,t){const i=c(e,!0,g);return!!i&&function(e,t,i){try{if("string"==typeof i.body)return e.icons[t]={...i},!0}catch(e){}return!1}(m(i.provider,i.prefix),i.name,t)}function b(e,t){if("object"!=typeof e)return!1;"string"!=typeof t&&(t=e.provider||"");const i=e.prefix;return!!l({provider:t,prefix:i,name:"a"})&&!!p(m(t,i),e)}function v(e){return!!w(e)}function A(e){const t=w(e);return t?{...n,...t}:null}const x=Object.freeze({width:null,height:null}),T=Object.freeze({...x,...i}),C=/(-?[0-9.]*[0-9]+[0-9.]*)/g,I=/^-?[0-9.]*[0-9]+[0-9.]*$/g;function S(e,t,i){if(1===t)return e;if(i=i||100,"number"==typeof e)return Math.ceil(e*t*i)/i;if("string"!=typeof e)return e;const n=e.split(C);if(null===n||!n.length)return e;const s=[];let r=n.shift(),o=I.test(r);for(;;){if(o){const e=parseFloat(r);isNaN(e)?s.push(r):s.push(Math.ceil(e*t*i)/i)}else s.push(r);if(r=n.shift(),void 0===r)return s.join("");o=!o}}function E(e,t){const i={...n,...e},s={...T,...t},r={left:i.left,top:i.top,width:i.width,height:i.height};let o=i.body;[i,s].forEach((e=>{const t=[],i=e.hFlip,n=e.vFlip;let s,a=e.rotate;switch(i?n?a+=2:(t.push("translate("+(r.width+r.left).toString()+" "+(0-r.top).toString()+")"),t.push("scale(-1 1)"),r.top=r.left=0):n&&(t.push("translate("+(0-r.left).toString()+" "+(r.height+r.top).toString()+")"),t.push("scale(1 -1)"),r.top=r.left=0),a<0&&(a-=4*Math.floor(a/4)),a%=4,a){case 1:s=r.height/2+r.top,t.unshift("rotate(90 "+s.toString()+" "+s.toString()+")");break;case 2:t.unshift("rotate(180 "+(r.width/2+r.left).toString()+" "+(r.height/2+r.top).toString()+")");break;case 3:s=r.width/2+r.left,t.unshift("rotate(-90 "+s.toString()+" "+s.toString()+")")}a%2==1&&(r.left!==r.top&&(s=r.left,r.left=r.top,r.top=s),r.width!==r.height&&(s=r.width,r.width=r.height,r.height=s)),t.length&&(o='<g transform="'+t.join(" ")+'">'+o+"</g>")}));const a=s.width,c=s.height,l=r.width,u=r.height;let d,h;null===a?(h=null===c?"1em":"auto"===c?u:c,d=S(h,l/u)):(d="auto"===a?l:a,h=null===c?S(d,u/l):"auto"===c?u:c);const m={},p=(e,t)=>{(e=>"unset"===e||"undefined"===e||"none"===e)(t)||(m[e]=t.toString())};return p("width",d),p("height",h),m.viewBox=r.left.toString()+" "+r.top.toString()+" "+l.toString()+" "+u.toString(),{attributes:m,body:o}}const $=/\sid="(\S+)"/g,R="IconifyId"+Date.now().toString(16)+(16777216*Math.random()|0).toString(16);let _=0;function P(e,t=R){const i=[];let n;for(;n=$.exec(e);)i.push(n[1]);if(!i.length)return e;const s="suffix"+(16777216*Math.random()|Date.now()).toString(16);return i.forEach((i=>{const n="function"==typeof t?t(i):t+(_++).toString(),r=i.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");e=e.replace(new RegExp('([#;"])('+r+')([")]|\\.[a-z])',"g"),"$1"+n+s+"$3")})),e=e.replace(new RegExp(s,"g"),"")}const L={local:!0,session:!0},k={local:new Set,session:new Set};let M=!1;const z="iconify2",j="iconify",O=j+"-count",N=j+"-version",D=36e5;function U(e,t){try{return e.getItem(t)}catch(e){}}function q(e,t,i){try{return e.setItem(t,i),!0}catch(e){}}function F(e,t){try{e.removeItem(t)}catch(e){}}function W(e,t){return q(e,O,t.toString())}function B(e){return parseInt(U(e,O))||0}let H="undefined"==typeof window?{}:window;function V(e){const t=e+"Storage";try{if(H&&H[t]&&"number"==typeof H[t].length)return H[t]}catch(e){}L[e]=!1}function Y(e,t){const i=V(e);if(!i)return;const n=U(i,N);if(n!==z){if(n){const e=B(i);for(let t=0;t<e;t++)F(i,j+t.toString())}return q(i,N,z),void W(i,0)}const s=Math.floor(Date.now()/D)-168,r=e=>{const n=j+e.toString(),r=U(i,n);if("string"==typeof r){try{const i=JSON.parse(r);if("object"==typeof i&&"number"==typeof i.cached&&i.cached>s&&"string"==typeof i.provider&&"object"==typeof i.data&&"string"==typeof i.data.prefix&&t(i,e))return!0}catch(e){}F(i,n)}};let o=B(i);for(let t=o-1;t>=0;t--)r(t)||(t===o-1?(o--,W(i,o)):k[e].add(t))}function G(){if(!M){M=!0;for(const e in L)Y(e,(e=>{const t=e.data,i=m(e.provider,t.prefix);if(!p(i,t).length)return!1;const n=t.lastModified||-1;return i.lastModifiedCached=i.lastModifiedCached?Math.min(i.lastModifiedCached,n):n,!0}))}}function J(e,t){switch(e){case"local":case"session":L[e]=t;break;case"all":for(const e in L)L[e]=t}}const X=Object.create(null);function Z(e,t){X[e]=t}function K(e){return X[e]||X[""]}function Q(e){let t;if("string"==typeof e.resources)t=[e.resources];else if(t=e.resources,!(t instanceof Array&&t.length))return null;return{resources:t,path:e.path||"/",maxURL:e.maxURL||500,rotate:e.rotate||750,timeout:e.timeout||5e3,random:!0===e.random,index:e.index||0,dataAfterTimeout:!1!==e.dataAfterTimeout}}const ee=Object.create(null),te=["https://api.simplesvg.com","https://api.unisvg.com"],ie=[];for(;te.length>0;)1===te.length||Math.random()>.5?ie.push(te.shift()):ie.push(te.pop());function ne(e,t){const i=Q(t);return null!==i&&(ee[e]=i,!0)}function se(e){return ee[e]}ee[""]=Q({resources:["https://api.iconify.design"].concat(ie)});let re=(()=>{let e;try{if(e=fetch,"function"==typeof e)return e}catch(e){}})();const oe={prepare:(e,t,i)=>{const n=[],s=function(e,t){const i=se(e);if(!i)return 0;let n;if(i.maxURL){let e=0;i.resources.forEach((t=>{const i=t;e=Math.max(e,i.length)}));const s=t+".json?icons=";n=i.maxURL-e-i.path.length-s.length}else n=0;return n}(e,t),r="icons";let o={type:r,provider:e,prefix:t,icons:[]},a=0;return i.forEach(((i,c)=>{a+=i.length+1,a>=s&&c>0&&(n.push(o),o={type:r,provider:e,prefix:t,icons:[]},a=i.length),o.icons.push(i)})),n.push(o),n},send:(e,t,i)=>{if(!re)return void i("abort",424);let n=function(e){if("string"==typeof e){const t=se(e);if(t)return t.path}return"/"}(t.provider);switch(t.type){case"icons":{const e=t.prefix,i=t.icons.join(",");n+=e+".json?"+new URLSearchParams({icons:i}).toString();break}case"custom":{const e=t.uri;n+="/"===e.slice(0,1)?e.slice(1):e;break}default:return void i("abort",400)}let s=503;re(e+n).then((e=>{const t=e.status;if(200===t)return s=501,e.json();setTimeout((()=>{i(function(e){return 404===e}(t)?"abort":"next",t)}))})).then((e=>{"object"==typeof e&&null!==e?setTimeout((()=>{i("success",e)})):setTimeout((()=>{404===e?i("abort",e):i("next",s)}))})).catch((()=>{i("next",s)}))}};function ae(e,t){e.forEach((e=>{const i=e.loaderCallbacks;i&&(e.loaderCallbacks=i.filter((e=>e.id!==t)))}))}let ce=0;var le={resources:[],index:0,timeout:2e3,rotate:750,random:!1,dataAfterTimeout:!1};function ue(e){const t={...le,...e};let i=[];function n(){i=i.filter((e=>"pending"===e().status))}const s={query:function(e,s,r){const o=function(e,t,i,n){const s=e.resources.length,r=e.random?Math.floor(Math.random()*s):e.index;let o;if(e.random){let t=e.resources.slice(0);for(o=[];t.length>1;){const e=Math.floor(Math.random()*t.length);o.push(t[e]),t=t.slice(0,e).concat(t.slice(e+1))}o=o.concat(t)}else o=e.resources.slice(r).concat(e.resources.slice(0,r));const a=Date.now();let c,l="pending",u=0,d=null,h=[],m=[];function p(){d&&(clearTimeout(d),d=null)}function f(){"pending"===l&&(l="aborted"),p(),h.forEach((e=>{"pending"===e.status&&(e.status="aborted")})),h=[]}function g(e,t){t&&(m=[]),"function"==typeof e&&m.push(e)}function w(){l="failed",m.forEach((e=>{e(void 0,c)}))}function y(){h.forEach((e=>{"pending"===e.status&&(e.status="aborted")})),h=[]}return"function"==typeof n&&m.push(n),setTimeout((function n(){if("pending"!==l)return;p();const s=o.shift();if(void 0===s)return h.length?void(d=setTimeout((()=>{p(),"pending"===l&&(y(),w())}),e.timeout)):void w();const r={status:"pending",resource:s,callback:(t,i)=>{!function(t,i,s){const r="success"!==i;switch(h=h.filter((e=>e!==t)),l){case"pending":break;case"failed":if(r||!e.dataAfterTimeout)return;break;default:return}if("abort"===i)return c=s,void w();if(r)return c=s,void(h.length||(o.length?n():w()));if(p(),y(),!e.random){const i=e.resources.indexOf(t.resource);-1!==i&&i!==e.index&&(e.index=i)}l="completed",m.forEach((e=>{e(s)}))}(r,t,i)}};h.push(r),u++,d=setTimeout(n,e.rotate),i(s,t,r.callback)})),function(){return{startTime:a,payload:t,status:l,queriesSent:u,queriesPending:h.length,subscribe:g,abort:f}}}(t,e,s,((e,t)=>{n(),r&&r(e,t)}));return i.push(o),o},find:function(e){return i.find((t=>e(t)))||null},setIndex:e=>{t.index=e},getIndex:()=>t.index,cleanup:n};return s}function de(){}const he=Object.create(null);function me(e,t,i){let n,s;if("string"==typeof e){const t=K(e);if(!t)return i(void 0,424),de;s=t.send;const r=function(e){if(!he[e]){const t=se(e);if(!t)return;const i={config:t,redundancy:ue(t)};he[e]=i}return he[e]}(e);r&&(n=r.redundancy)}else{const t=Q(e);if(t){n=ue(t);const i=K(e.resources?e.resources[0]:"");i&&(s=i.send)}}return n&&s?n.query(t,s,i)().abort:(i(void 0,424),de)}function pe(){}const fe=(e,t)=>{const i=function(e){const t={loaded:[],missing:[],pending:[]},i=Object.create(null);e.sort(((e,t)=>e.provider!==t.provider?e.provider.localeCompare(t.provider):e.prefix!==t.prefix?e.prefix.localeCompare(t.prefix):e.name.localeCompare(t.name)));let n={provider:"",prefix:"",name:""};return e.forEach((e=>{if(n.name===e.name&&n.prefix===e.prefix&&n.provider===e.provider)return;n=e;const s=e.provider,r=e.prefix,o=e.name,a=i[s]||(i[s]=Object.create(null)),c=a[r]||(a[r]=m(s,r));let l;l=o in c.icons?t.loaded:""===r||c.missing.has(o)?t.missing:t.pending;const u={provider:s,prefix:r,name:o};l.push(u)})),t}(function(e,t=!0,i=!1){const n=[];return e.forEach((e=>{const s="string"==typeof e?c(e,t,i):e;s&&n.push(s)})),n}(e,!0,g));if(!i.pending.length){let e=!0;return t&&setTimeout((()=>{e&&t(i.loaded,i.missing,i.pending,pe)})),()=>{e=!1}}const n=Object.create(null),s=[];let r,o;return i.pending.forEach((e=>{const{provider:t,prefix:i}=e;if(i===o&&t===r)return;r=t,o=i,s.push(m(t,i));const a=n[t]||(n[t]=Object.create(null));a[i]||(a[i]=[])})),i.pending.forEach((e=>{const{provider:t,prefix:i,name:s}=e,r=m(t,i),o=r.pendingIcons||(r.pendingIcons=new Set);o.has(s)||(o.add(s),n[t][i].push(s))})),s.forEach((e=>{const{provider:t,prefix:i}=e;n[t][i].length&&function(e,t){e.iconsToLoad?e.iconsToLoad=e.iconsToLoad.concat(t).sort():e.iconsToLoad=t,e.iconsQueueFlag||(e.iconsQueueFlag=!0,setTimeout((()=>{e.iconsQueueFlag=!1;const{provider:t,prefix:i}=e,n=e.iconsToLoad;let s;delete e.iconsToLoad,n&&(s=K(t))&&s.prepare(t,i,n).forEach((i=>{me(t,i,(t=>{if("object"!=typeof t)i.icons.forEach((t=>{e.missing.add(t)}));else try{const i=p(e,t);if(!i.length)return;const n=e.pendingIcons;n&&i.forEach((e=>{n.delete(e)})),function(e,t){function i(i){let n;if(!L[i]||!(n=V(i)))return;const s=k[i];let r;if(s.size)s.delete(r=Array.from(s).shift());else if(r=B(n),!W(n,r+1))return;const o={cached:Math.floor(Date.now()/D),provider:e.provider,data:t};return q(n,j+r.toString(),JSON.stringify(o))}M||G(),t.lastModified&&!function(e,t){const i=e.lastModifiedCached;if(i&&i>=t)return i===t;if(e.lastModifiedCached=t,i)for(const i in L)Y(i,(i=>{const n=i.data;return i.provider!==e.provider||n.prefix!==e.prefix||n.lastModified===t}));return!0}(e,t.lastModified)||Object.keys(t.icons).length&&(t.not_found&&delete(t=Object.assign({},t)).not_found,i("local")||i("session"))}(e,t)}catch(e){console.error(e)}!function(e){e.iconsLoaderFlag||(e.iconsLoaderFlag=!0,setTimeout((()=>{e.iconsLoaderFlag=!1,function(e){e.pendingCallbacksFlag||(e.pendingCallbacksFlag=!0,setTimeout((()=>{e.pendingCallbacksFlag=!1;const t=e.loaderCallbacks?e.loaderCallbacks.slice(0):[];if(!t.length)return;let i=!1;const n=e.provider,s=e.prefix;t.forEach((t=>{const r=t.icons,o=r.pending.length;r.pending=r.pending.filter((t=>{if(t.prefix!==s)return!0;const o=t.name;if(e.icons[o])r.loaded.push({provider:n,prefix:s,name:o});else{if(!e.missing.has(o))return i=!0,!0;r.missing.push({provider:n,prefix:s,name:o})}return!1})),r.pending.length!==o&&(i||ae([e],t.id),t.callback(r.loaded.slice(0),r.missing.slice(0),r.pending.slice(0),t.abort))}))})))}(e)})))}(e)}))}))})))}(e,n[t][i])})),t?function(e,t,i){const n=ce++,s=ae.bind(null,i,n);if(!t.pending.length)return s;const r={id:n,icons:t,callback:e,abort:s};return i.forEach((e=>{(e.loaderCallbacks||(e.loaderCallbacks=[])).push(r)})),s}(t,i,s):pe},ge=e=>new Promise(((t,i)=>{const s="string"==typeof e?c(e,!0):e;s?fe([s||e],(r=>{if(r.length&&s){const e=w(s);if(e)return void t({...n,...e})}i(e)})):i(e)}));function we(e,t){const i={...e};for(const e in t){const n=t[e],s=typeof n;e in x?(null===n||n&&("string"===s||"number"===s))&&(i[e]=n):s===typeof i[e]&&(i[e]="rotate"===e?n%4:n)}return i}const ye={...T,inline:!1},be="iconify",ve="iconify-inline",Ae="iconifyData"+Date.now();let xe=[];function Te(e){for(let t=0;t<xe.length;t++){const i=xe[t];if(("function"==typeof i.node?i.node():i.node)===e)return i}}function Ce(e,t=!1){let i=Te(e);return i?(i.temporary&&(i.temporary=t),i):(i={node:e,temporary:t},xe.push(i),i)}function Ie(){return xe}let Se=null;const Ee={childList:!0,subtree:!0,attributes:!0};function $e(e){if(!e.observer)return;const t=e.observer;t.pendingScan||(t.pendingScan=setTimeout((()=>{delete t.pendingScan,Se&&Se(e)})))}function Re(e,t){if(!e.observer)return;const i=e.observer;if(!i.pendingScan)for(let n=0;n<t.length;n++){const s=t[n];if(s.addedNodes&&s.addedNodes.length>0||"attributes"===s.type&&void 0!==s.target[Ae])return void(i.paused||$e(e))}}function _e(e,t){e.observer.instance.observe(t,Ee)}function Pe(e){let t=e.observer;if(t&&t.instance)return;const i="function"==typeof e.node?e.node():e.node;i&&window&&(t||(t={paused:0},e.observer=t),t.instance=new window.MutationObserver(Re.bind(null,e)),_e(e,i),t.paused||$e(e))}function Le(){Ie().forEach(Pe)}function ke(e){if(!e.observer)return;const t=e.observer;t.pendingScan&&(clearTimeout(t.pendingScan),delete t.pendingScan),t.instance&&(t.instance.disconnect(),delete t.instance)}function Me(e){(e?[e]:Ie()).forEach((e=>{if(!e.observer)return void(e.observer={paused:1});const t=e.observer;t.paused++,t.paused>1||!t.instance||t.instance.disconnect()}))}function ze(e){if(e){const t=Te(e);t&&Me(t)}else Me()}function je(e){(e?[e]:Ie()).forEach((e=>{if(!e.observer)return void Pe(e);const t=e.observer;if(t.paused&&(t.paused--,!t.paused)){const i="function"==typeof e.node?e.node():e.node;if(!i)return;t.instance?_e(e,i):Pe(e)}}))}function Oe(e){if(e){const t=Te(e);t&&je(t)}else je()}function Ne(e,t=!1){const i=Ce(e,t);return Pe(i),i}function De(e){const t=Te(e);t&&(ke(t),function(e){xe=xe.filter((t=>e!==t&&e!==("function"==typeof t.node?t.node():t.node)))}(e))}const Ue=/[\s,]+/,qe=["width","height"],Fe=["inline","hFlip","vFlip"];const We="svg."+be+", i."+be+", span."+be+", i."+ve+", span."+ve;function Be(e,t){let i=-1===e.indexOf("xlink:")?"":' xmlns:xlink="http://www.w3.org/1999/xlink"';for(const e in t)i+=" "+e+'="'+t[e]+'"';return'<svg xmlns="http://www.w3.org/2000/svg"'+i+">"+e+"</svg>"}let He;function Ve(e){const t=new Set(["iconify"]);return["provider","prefix"].forEach((i=>{e[i]&&t.add("iconify--"+e[i])})),t}function Ye(e,t,i,n){const s=e.classList;if(n){const e=n.classList;Array.from(e).forEach((e=>{s.add(e)}))}const r=[];return t.forEach((e=>{s.contains(e)?i.has(e)&&r.push(e):(s.add(e),r.push(e))})),i.forEach((e=>{t.has(e)||s.remove(e)})),r}function Ge(e,t,i){const n=e.style;(i||[]).forEach((e=>{n.removeProperty(e)}));const s=[];for(const e in t)n.getPropertyValue(e)||(s.push(e),n.setProperty(e,t[e]));return s}function Je(e,t,i){let n;try{n=document.createElement("span")}catch(t){return e}const s=t.customisations,r=E(i,s),o=e[Ae],a=Be(P(r.body),{"aria-hidden":"true",role:"img",...r.attributes});n.innerHTML=function(e){return void 0===He&&function(){try{He=window.trustedTypes.createPolicy("iconify",{createHTML:e=>e})}catch(e){He=null}}(),He?He.createHTML(e):e}(a);const c=n.childNodes[0],l=e.attributes;for(let e=0;e<l.length;e++){const t=l.item(e),i=t.name;"class"===i||c.hasAttribute(i)||c.setAttribute(i,t.value)}const u=Ye(c,Ve(t.icon),new Set(o&&o.addedClasses),e),d=Ge(c,s.inline?{"vertical-align":"-0.125em"}:{},o&&o.addedStyles),h={...t,status:"loaded",addedClasses:u,addedStyles:d};return c[Ae]=h,e.parentNode&&e.parentNode.replaceChild(c,e),c}const Xe={display:"inline-block"},Ze={"background-color":"currentColor"},Ke={"background-color":"transparent"},Qe={image:"var(--svg)",repeat:"no-repeat",size:"100% 100%"},et={"-webkit-mask":Ze,mask:Ze,background:Ke};for(const e in et){const t=et[e];for(const i in Qe)t[e+"-"+i]=Qe[i]}function tt(e){return e+(e.match(/^[-0-9.]+$/)?"px":"")}let it=!1;function nt(){it||(it=!0,setTimeout((()=>{it&&(it=!1,st())})))}function st(e,t=!1){const i=Object.create(null);function s(e,t){const{provider:n,prefix:s,name:r}=e,o=m(n,s),a=o.icons[r];if(a)return{status:"loaded",icon:a};if(o.missing.has(r))return{status:"missing"};if(t&&!(e=>{const t=m(e.provider,e.prefix).pendingIcons;return!(!t||!t.has(e.name))})(e)){const e=i[n]||(i[n]=Object.create(null));(e[s]||(e[s]=new Set)).add(r)}return{status:"loading"}}(e?[e]:Ie()).forEach((e=>{const i="function"==typeof e.node?e.node():e.node;if(!i||!i.querySelectorAll)return;let r=!1,o=!1;function a(t,i,s){if(o||(o=!0,Me(e)),"SVG"!==t.tagName.toUpperCase()){const e=i.mode,r="mask"===e||"bg"!==e&&("style"===e?-1!==s.body.indexOf("currentColor"):null);if("boolean"==typeof r)return void function(e,t,i,n){const s=t.customisations,r=E(i,s),o=r.attributes,a=e[Ae],c=Be(r.body,{...o,width:i.width+"",height:i.height+""}),l=Ye(e,Ve(t.icon),new Set(a&&a.addedClasses)),u={"--svg":'url("'+(d=c,"data:image/svg+xml,"+function(e){return e.replace(/"/g,"'").replace(/%/g,"%25").replace(/#/g,"%23").replace(/</g,"%3C").replace(/>/g,"%3E").replace(/\s+/g," ")}(d)+'")'),width:tt(o.width),height:tt(o.height),...Xe,...n?Ze:Ke};var d;s.inline&&(u["vertical-align"]="-0.125em");const h=Ge(e,u,a&&a.addedStyles),m={...t,status:"loaded",addedClasses:l,addedStyles:h};e[Ae]=m}(t,i,{...n,...s},r)}Je(t,i,s)}(function(e){const t=[];return e.querySelectorAll(We).forEach((e=>{const i=e[Ae]||"svg"!==e.tagName.toLowerCase()?function(e){const t=e.getAttribute("data-icon"),i="string"==typeof t&&c(t,!0);if(!i)return null;const n={...ye,inline:e.classList&&e.classList.contains(ve)};qe.forEach((t=>{const i=e.getAttribute("data-"+t);i&&(n[t]=i)}));const s=e.getAttribute("data-rotate");"string"==typeof s&&(n.rotate=function(e,t=0){const i=e.replace(/^-?[0-9.]*/,"");function n(e){for(;e<0;)e+=4;return e%4}if(""===i){const t=parseInt(e);return isNaN(t)?0:n(t)}if(i!==e){let t=0;switch(i){case"%":t=25;break;case"deg":t=90}if(t){let s=parseFloat(e.slice(0,e.length-i.length));return isNaN(s)?0:(s/=t,s%1==0?n(s):0)}}return t}(s));const r=e.getAttribute("data-flip");"string"==typeof r&&function(e,t){t.split(Ue).forEach((t=>{switch(t.trim()){case"horizontal":e.hFlip=!0;break;case"vertical":e.vFlip=!0}}))}(n,r),Fe.forEach((t=>{const i="data-"+t,s=function(e,t){return e===t||"true"===e||""!==e&&"false"!==e&&null}(e.getAttribute(i),i);"boolean"==typeof s&&(n[t]=s)}));const o=e.getAttribute("data-mode");return{name:t,icon:i,customisations:n,mode:o}}(e):null;i&&t.push({node:e,props:i})})),t})(i).forEach((({node:e,props:t})=>{const i=e[Ae];if(!i){const{status:i,icon:n}=s(t.icon,!0);return n?void a(e,t,n):(r=r||"loading"===i,void(e[Ae]={...t,status:i}))}let n;if(function(e,t){if(e.name!==t.name||e.mode!==t.mode)return!0;const i=e.customisations,n=t.customisations;for(const e in ye)if(i[e]!==n[e])return!0;return!1}(i,t)){if(n=s(t.icon,i.name!==t.name),!n.icon)return r=r||"loading"===n.status,void Object.assign(i,{...t,status:n.status})}else{if("loading"!==i.status)return;if(n=s(t.icon,!1),!n.icon)return void(i.status=n.status)}a(e,t,n.icon)})),e.temporary&&!r?De(i):t&&r?Ne(i,!0):o&&e.observer&&je(e)}));for(const e in i){const t=i[e];for(const i in t){const n=t[i];fe(Array.from(n).map((t=>({provider:e,prefix:i,name:t}))),nt)}}}function rt(e,t,i=!1){const n=w(e);if(!n)return null;const s=c(e),r=we(ye,t||{}),o=Je(document.createElement("span"),{name:e,icon:s,customisations:r},n);return i?o.outerHTML:o}function ot(){return"3.1.1"}function at(e,t){return rt(e,t,!1)}function ct(e,t){return rt(e,t,!0)}function lt(e,t){const i=w(e);return i?E(i,we(ye,t||{})):null}function ut(e){e?function(e){const t=Te(e);t?st(t):st({node:e,temporary:!0},!0)}(e):st()}if("undefined"!=typeof document&&"undefined"!=typeof window){!function(){if(document.documentElement)return Ce(document.documentElement);xe.push({node:()=>document.documentElement})}();const e=window;if(void 0!==e.IconifyPreload){const t=e.IconifyPreload,i="Invalid IconifyPreload syntax.";"object"==typeof t&&null!==t&&(t instanceof Array?t:[t]).forEach((e=>{try{("object"!=typeof e||null===e||e instanceof Array||"object"!=typeof e.icons||"string"!=typeof e.prefix||!b(e))&&console.error(i)}catch(e){console.error(i)}}))}setTimeout((()=>{(function(e){const t=null!==Se;Se!==e&&(Se=e,t&&Ie().forEach(ke)),t?Le():function(e){const t=document;t.readyState&&"loading"!==t.readyState?e():t.addEventListener("DOMContentLoaded",e)}(Le)})(st),st()}))}function dt(e,t){J(e,!1!==t)}function ht(e){J(e,!0)}if(Z("",oe),"undefined"!=typeof document&&"undefined"!=typeof window){G();const t=window;if(void 0!==t.IconifyProviders){const i=t.IconifyProviders;if("object"==typeof i&&null!==i)for(const t in i){const n="IconifyProviders["+t+"] is invalid.";try{const e=i[t];if("object"!=typeof e||!e||void 0===e.resources)continue;ne(t,e)||console.error(n)}catch(e){console.error(n)}}}}const mt={getAPIConfig:se,setAPIModule:Z,sendAPIQuery:me,setFetch:function(e){re=e},getFetch:function(){return re},listAPIProviders:function(){return Object.keys(ee)}},pt={_api:mt,addAPIProvider:ne,loadIcons:fe,loadIcon:ge,iconExists:v,getIcon:A,listIcons:f,addIcon:y,addCollection:b,replaceIDs:P,calculateSize:S,buildIcon:E,getVersion:ot,renderSVG:at,renderHTML:ct,renderIcon:lt,scan:ut,observe:Ne,stopObserving:De,pauseObserver:ze,resumeObserver:Oe,enableCache:dt,disableCache:ht};return e._api=mt,e.addAPIProvider=ne,e.addCollection=b,e.addIcon=y,e.buildIcon=E,e.calculateSize=S,e.default=pt,e.disableCache=ht,e.enableCache=dt,e.getIcon=A,e.getVersion=ot,e.iconExists=v,e.listIcons=f,e.loadIcon=ge,e.loadIcons=fe,e.observe=Ne,e.pauseObserver=ze,e.renderHTML=ct,e.renderIcon=lt,e.renderSVG=at,e.replaceIDs=P,e.resumeObserver=Oe,e.scan=ut,e.stopObserving=De,Object.defineProperty(e,"__esModule",{value:!0}),e}({});try{for(var i in e.__esModule=!0,e.default=t,t)e[i]=t[i]}catch(e){}try{void 0===self.Iconify&&(self.Iconify=t)}catch(e){}function n(){Alpine.directive("icon",((e,{expression:t},{effect:i,evaluateLater:n})=>{const s=t;if(!s)return;const r=n(s.includes(":")&&!s.includes("'")&&!s.includes('"')&&!s.includes("$")&&!s.includes("?")&&!s.includes(".")&&!s.includes("(")&&!s.includes(")")?`'${s}'`:s);i((()=>{r((t=>{if(!t)return;if("li"===e.tagName.toLowerCase()){if(e.hasAttribute("data-icon-processed")){const i=e.querySelector(".iconify");return void(i&&(i.setAttribute("data-icon",t),window.Iconify&&window.Iconify.scan(i)))}{const i=e.textContent.trim();e.innerHTML="";const n=document.createElement("span");if(n.className="iconify",n.setAttribute("data-icon",t),e.appendChild(n),i){const t=document.createTextNode(i);e.appendChild(t)}return e.setAttribute("data-icon-processed","true"),window.Iconify.scan(n),void setTimeout((()=>{const i=e.querySelector("svg");if(i&&i.parentNode===e){const n=document.createElement("span");n.setAttribute("x-icon",t),e.insertBefore(n,i),n.appendChild(i)}}),50)}}let i=e.querySelector(".iconify");i||(i=document.createElement("span"),i.className="iconify",e.innerHTML="",e.appendChild(i)),i.setAttribute("data-icon",t),window.Iconify.scan(i)}))}))}))}"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&n()})),document.addEventListener("alpine:init",n)}(indux_icons)),indux_icons}function initializeLocalizationPlugin(){"localhost"===window.location.hostname||"127.0.0.1"===window.location.hostname||window.location.hostname.includes("dev")||window.location.search.includes("debug=true");const e=new Set(["ar","az-Arab","bal","ckb","fa","glk","ks","ku-Arab","lrc","mzn","pnb","ps","sd","ur","he","yi","jrb","jpr","lad-Hebr","dv","nqo","syr","aii","arc","sam","mid","uga","phn","xpr","peo","pal","avst","man"]);function t(t){return e.has(t)}function i(e){return"string"==typeof e&&0!==e.length&&/^[a-zA-Z0-9_-]+$/.test(e)}const n=e=>{try{return localStorage.getItem(e)}catch(e){return null}},s=(e,t)=>{try{return localStorage.setItem(e,t),!0}catch(e){return!1}};Alpine.store("locale",{current:"en",available:[],direction:"ltr",_initialized:!1});let r=null;async function o(){if(r)return r;try{const e=await fetch("/manifest.json");if(!e.ok)throw new Error(`HTTP ${e.status}: ${e.statusText}`);const t=await e.json();if(!t||"object"!=typeof t)throw new Error("Invalid manifest structure");const n=new Set;if(t.data&&"object"==typeof t.data&&Object.values(t.data).forEach((e=>{e&&"object"==typeof e&&Object.keys(e).forEach((e=>{i(e)&&"url"!==e&&"headers"!==e&&"params"!==e&&"transform"!==e&&"defaultValue"!==e&&n.add(e)}))})),0===n.size){const e=document.documentElement.lang,t=e&&i(e)?e:"en";n.add(t)}const s=Array.from(n);return r=s,s}catch(e){console.error("[Indux Localization] Error loading manifest:",e);const t=document.documentElement.lang;return[t&&i(t)?t:"en"]}}async function a(e,r=!1){if(!i(e))return console.error("[Indux Localization] Invalid language code:",e),!1;const a=Alpine.store("locale");if(a.available&&0!==a.available.length){if(!a.available.includes(e))return!1}else{if(!(await o()).includes(e))return!1}if(e===a.current)return!1;try{a.current=e,a.direction=t(e)?"rtl":"ltr",a._initialized=!0;try{document.documentElement.lang=e,document.documentElement.dir=a.direction}catch(e){console.error("[Indux Localization] DOM update error:",e)}s("lang",e);try{const t=new URL(window.location.href),i=t.pathname.split("/").filter(Boolean),n=i[0]&&a.available.includes(i[0]);(r||n)&&(n?i[0]!==e&&(i[0]=e,t.pathname="/"+i.join("/"),window.history.replaceState({},"",t)):r&&i.length>0&&(i.unshift(e),t.pathname="/"+i.join("/"),window.history.replaceState({},"",t)))}catch(e){console.error("[Indux Localization] URL update error:",e)}try{window.dispatchEvent(new CustomEvent("localechange",{detail:{locale:e}}))}catch(e){console.error("[Indux Localization] Event dispatch error:",e)}return!0}catch(e){console.error("[Indux Localization] Error setting locale:",e);const i=n("lang")||a.available[0]||"en";a.current=i,a.direction=t(i)?"rtl":"ltr";try{document.documentElement.lang=a.current,document.documentElement.dir=a.direction}catch(e){console.error("[Indux Localization] DOM restore error:",e)}return!1}}Alpine.magic("locale",(()=>{const e=Alpine.store("locale");return new Proxy({},{get:(t,i)=>"current"===i?e.current:"available"===i?e.available:"direction"===i?e.direction:"set"===i?a:"toggle"===i?()=>{const t=(e.available.indexOf(e.current)+1)%e.available.length;a(e.available[t],!1)}:void 0})}));let c=null;(async()=>{try{const e=await o();Alpine.store("locale").available=e;const t=function(e){const t=window.location.pathname.split("/").filter(Boolean);if(t[0]&&i(t[0])&&e.includes(t[0]))return t[0];const s=n("lang");if(s&&i(s)&&e.includes(s))return s;const r=document.documentElement.lang;if(r&&i(r)&&e.includes(r))return r;if(navigator.language){const t=navigator.language.split("-")[0];if(i(t)&&e.includes(t))return t}return e[0]||"en"}(e);await a(t,!0)}catch(e){console.error("[Indux Localization] Initialization error:",e)}})(),c=async e=>{try{const t=e.detail.to.split("/").filter(Boolean),n=Alpine.store("locale");if(t[0]&&i(t[0])&&n.available.includes(t[0])){const e=t[0];e!==n.current&&await a(e,!0)}}catch(e){console.error("[Indux Localization] Router navigation error:",e)}},window.addEventListener("indux:route-change",c);window.__induxLocalizationCleanup=()=>{c&&(window.removeEventListener("indux:route-change",c),c=null),r=null}}requireIndux_icons(),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&initializeLocalizationPlugin()})),document.addEventListener("alpine:init",initializeLocalizationPlugin);var indux_markdown={},hasRequiredIndux_markdown;function requireIndux_markdown(){if(hasRequiredIndux_markdown)return indux_markdown;hasRequiredIndux_markdown=1;let e=null;async function t(){return"undefined"!=typeof marked?marked:e||(e=new Promise(((t,i)=>{const n=document.createElement("script");n.src="https://cdn.jsdelivr.net/npm/marked/marked.min.js",n.onload=()=>{"undefined"!=typeof marked?t(marked):(console.error("[Indux Markdown] Marked.js failed to load - marked is undefined"),e=null,i(new Error("marked.js failed to load")))},n.onerror=t=>{console.error("[Indux Markdown] Script failed to load:",t),e=null,i(t)},document.head.appendChild(n)})),e)}function i(e){return e.replace(/<x-code-group[^>]*>([\s\S]*?)<\/x-code-group>/g,((e,t)=>`<x-code-group>${t.replace(/^(?!\s*\n)/,"\n")}</x-code-group>`))}function n(e){const t=document.createElement("div");t.innerHTML=e;return t.querySelectorAll('input[type="checkbox"]').forEach((e=>{e.removeAttribute("disabled")})),t.innerHTML}async function s(){try{const e=await t();await async function(e){e.use({renderer:{code(e){const t=e.lang||"",i=e.text||"";e.escaped;const n=function(e){if(!e||""===e.trim())return{title:null,language:null,numbers:!1,copy:!1};const t=e.split(/\s+/),i={title:null,language:null,numbers:!1,copy:!1};let n=0;for(;n<t.length;){const e=t[n];if("numbers"!==e)if("copy"!==e)if(e.startsWith('"')&&e.endsWith('"'))i.title=e.slice(1,-1),n++;else if(e.startsWith('"')){let s=e.slice(1);for(n++;n<t.length;){const e=t[n];if(e.endsWith('"')){s+=" "+e.slice(0,-1),i.title=s,n++;break}s+=" "+e,n++}}else i.language||(i.language=e),n++;else i.copy=!0,n++;else i.numbers=!0,n++}return i}(t);let s="";n.title&&(s+=` name="${n.title}"`),n.language&&(s+=` language="${n.language}"`),n.numbers&&(s+=" numbers"),n.copy&&(s+=" copy");let r=i,o="";return("html"===n.language||i.includes("<!DOCTYPE")||i.includes("<html")&&i.includes("<head")&&i.includes("<body"))&&(o=` data-original-content="${i.replace(/"/g,"&quot;")}"`),`<x-code${s}${o}>${r}</x-code>\n`}},breaks:!0,gfm:!0}),e.use({extensions:[{name:"callout",level:"block",start:e=>e.match(/^:::/)?.index,tokenizer(e){const t=e.match(/^:::(.*?)(?:\n|$)/);if(!t)return;const i=t[1].trim();let n="",s="";const r=i.match(/icon="([^"]+)"/);r&&(s=r[1]),n=i.replace(/\s*icon="[^"]+"\s*/,"").trim();const o=t[0].length,a=e.slice(o),c=a.match(/\n:::/);if(c){const e=a.slice(0,c.index);return{type:"callout",raw:t[0]+e+c[0],classes:n,iconValue:s,text:e.trim()}}},renderer(t){const i=t.classes||"",n=t.iconValue||"";let s;s=i.includes("frame")?t.text:e.parse(t.text);const r=n?`<span x-icon="${n}"></span>`:"",o=document.createElement("div");return o.innerHTML=s,`<aside${i?` class="${i}"`:""}>${r}${o.children.length>=2&&n?`<div>${s}</div>`:s}</aside>\n`}}]}),e.setOptions({headerIds:!1,mangle:!1})}(e),e.use({renderer:{heading(e){const t=e.text||"",i=e.depth||1;return`<h${i} id="${t.toLowerCase().replace(/[^\w]+/g,"-").replace(/^-+|-+$/g,"")}">${t}</h${i}>`}}});const s=document.querySelectorAll("[x-markdown]");Alpine.directive("markdown",((e,{expression:s,modifiers:r},{effect:o,evaluateLater:a})=>{if(!s)return;e.style.opacity="0",e.style.transition="opacity 0.15s ease-in-out";let c="",l=!1,u=!1;const d=e=>{const t=e.split("\n"),i=t.filter((e=>e.trim())).reduce(((e,t)=>{const i=t.match(/^\s*/)[0].length;return Math.min(e,i)}),1/0);return t.map((e=>e.slice(i))).join("\n").trim()},h=async(e,s=null)=>{if(!l){l=!0;try{if(null!==s&&""!==s.trim()&&(c=d(s)),!c||""===c.trim())return void(e.style.opacity="0");const r=await t(),o=i(c);let a=r.parse(o);if(a=n(a),e.innerHTML!==a&&""!==a.trim()){const t=document.createElement("div");for(t.innerHTML=a,e.innerHTML="";t.firstChild;)e.appendChild(t.firstChild);u=!0,e.style.opacity="1"}else u||(e.style.opacity="0")}finally{l=!1}}};if(!s||"inline"===s){c=d(e.textContent),h(e);return void new MutationObserver((t=>{let i=null;for(const n of t)if("childList"===n.type){const t=Array.from(e.childNodes).filter((e=>e.nodeType===Node.TEXT_NODE));if(t.length>0){i=t.map((e=>e.textContent)).join("");break}}else if("characterData"===n.type){i=n.target.textContent;break}i&&""!==i.trim()&&h(e,i)})).observe(e,{characterData:!0,childList:!0,subtree:!0,characterDataOldValue:!0})}let m=s;s.includes("+")||s.includes("`")||s.includes("${")||s.startsWith("$")||s.startsWith("'")||s.startsWith('"')||(m=`'${s.replace(/'/g,"\\'")}'`);const p=a(m);o((()=>{p((async i=>{if(!i||void 0===i||""===i)return e.style.opacity="0",void(u=!1);void 0===i&&(i=s);const o="string"==typeof i&&(i.includes(".md")||i.includes(".markdown")||i.startsWith("/")||i.includes("/"));let a=i;if(o)try{let e=i;i.startsWith("/")||(e="/"+i);const t=await fetch(e);t.ok?a=await t.text():(console.warn(`[Indux] Failed to fetch markdown file: ${e}`),a=`# Error Loading Content\n\nCould not load: ${e}`)}catch(e){console.error(`[Indux] Error fetching markdown file: ${i}`,e),a=`# Error Loading Content\n\nCould not load: ${i}\n\nError: ${e.message}`}if(!a||""===a.trim())return e.style.opacity="0",void(u=!1);let c=(await t()).parse(a);c=n(c);const l=document.createElement("div");for(l.innerHTML=c,e.innerHTML="";l.firstChild;)e.appendChild(l.firstChild);u=!0,e.style.opacity="1";const d=[];if(e.querySelectorAll("h1, h2, h3").forEach((e=>{d.push({id:e.id,text:e.textContent,level:parseInt(e.tagName.charAt(1))})})),r.includes("headings")){const t="markdown-"+Math.random().toString(36).substr(2,9);e.setAttribute("data-headings-section",t),window._induxHeadings||(window._induxHeadings={}),window._induxHeadings[t]=d}}))}))})),s.length>0&&s.forEach((e=>{const n=e.getAttribute("x-markdown");Alpine.$data(e);if(n.startsWith("'")&&n.endsWith("'")){const s=n.slice(1,-1);(async(e,n=null)=>{try{if(!n)return;const s=await t(),r=i(n);let o=s.parse(r);o=o.replace(/<input type="checkbox"([^>]*?)disabled([^>]*?)>/g,'<input type="checkbox"$1$2>');const a=document.createElement("div");for(a.innerHTML=o,e.innerHTML="";a.firstChild;)e.appendChild(a.firstChild)}catch(e){console.error("[Indux Markdown] Failed to process element:",e)}})(e,s)}else{const t=n;e.removeAttribute("x-markdown"),setTimeout((()=>{e.setAttribute("x-markdown",t)}),50)}}))}catch(e){console.error("[Indux] Failed to initialize markdown plugin:",e)}}return t().catch((()=>{})),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&s()})),document.addEventListener("alpine:init",(()=>{s()})),indux_markdown}function initializeResizablePlugin(){const e=new Map;let t=null;const i=(i,n)=>{if("px"===n)return i;const s=`${i}${n}`;if(e.has(s))return e.get(s);t||(t=document.createElement("div"),t.style.cssText="visibility:hidden;position:absolute;top:-9999px;left:-9999px;width:0;height:0;",document.body.appendChild(t)),t.style.width=`${i}${n}`;const r=t.getBoundingClientRect().width;return e.set(s,r),r},n=(t,i,n)=>{if("px"===i)return t;const s=`${t}${i}${n.tagName}`;if(e.has(s))return e.get(s);let r;switch(i){case"%":r=t/n.parentElement.getBoundingClientRect().width*100;break;case"rem":r=t/parseFloat(getComputedStyle(document.documentElement).fontSize);break;case"em":r=t/parseFloat(getComputedStyle(n).fontSize);break;default:r=t}return e.set(s,r),r};function s(e){const t=e.target,s=t._resizeConfig;if(s.initialized)return;s.initialized=!0;const r=e=>{if("number"==typeof e)return{value:e,unit:"px"};const t=String(e).match(/^([\d.]+)(.*)$/);return t?{value:parseFloat(t[1]),unit:t[2]||"px"}:{value:0,unit:"px"}};let o={};if(s.expression)try{o=s.evaluate(s.expression)}catch(e){console.error("Error parsing x-resize expression:",s.expression,e),o={}}const{snapDistance:a=0,snapPoints:c=[],snapCloseX:l=null,snapDistanceX:u=null,snapDistanceY:d=null,snapPointsX:h=[],snapPointsY:m=[],snapCloseY:p=null,toggle:f=null,handles:g=["top","bottom","left","right","top-left","top-right","bottom-left","bottom-right"],saveWidth:w=null,saveHeight:y=null}=o;s.handles=[];const b={closeX:l?r(l):null,closeY:p?r(p):null},v=c.map((e=>r(e))),A=h.map((e=>r(e))),x=m.map((e=>r(e))),T="rtl"===getComputedStyle(t).direction,C={top:{edge:"top",direction:"vertical"},bottom:{edge:"bottom",direction:"vertical"},left:{edge:"left",direction:"horizontal"},right:{edge:"right",direction:"horizontal"},"top-left":{edge:"top-left",direction:"both",edges:["top","left"]},"top-right":{edge:"top-right",direction:"both",edges:["top","right"]},"bottom-left":{edge:"bottom-left",direction:"both",edges:["bottom","left"]},"bottom-right":{edge:"bottom-right",direction:"both",edges:["bottom","right"]},start:{edge:T?"right":"left",direction:"horizontal",logical:!0},end:{edge:T?"left":"right",direction:"horizontal",logical:!0},"top-start":{edge:T?"top-right":"top-left",direction:"both",edges:T?["top","right"]:["top","left"],logical:!0},"top-end":{edge:T?"top-left":"top-right",direction:"both",edges:T?["top","left"]:["top","right"],logical:!0},"bottom-start":{edge:T?"bottom-right":"bottom-left",direction:"both",edges:T?["bottom","right"]:["bottom","left"],logical:!0},"bottom-end":{edge:T?"bottom-left":"bottom-right",direction:"both",edges:T?["bottom","left"]:["bottom","right"],logical:!0}};g.forEach((e=>{const r=C[e];if(!r)return;const o=document.createElement("span");let c,l,h,m;o.className=`resize-handle resize-handle-${e}`,o.setAttribute("data-handle",e);let p=null;const g=b.closeX?i(b.closeX.value,b.closeX.unit):null,T=b.closeY?i(b.closeY.value,b.closeY.unit):null,I=v.map((e=>({value:i(e.value,e.unit),unit:e.unit}))),S=A.map((e=>({value:i(e.value,e.unit),unit:e.unit}))),E=x.map((e=>({value:i(e.value,e.unit),unit:e.unit}))),$=i(a,"px"),R=u?i(u,"px"):$,_=d?i(d,"px"):$,P=e=>{const i=e.clientX-c,o=e.clientY-l;let a=h,u=m;if("horizontal"!==r.direction&&"both"!==r.direction||("left"===r.edge||"top-left"===r.edge||"bottom-left"===r.edge?a=h-i:"right"!==r.edge&&"top-right"!==r.edge&&"bottom-right"!==r.edge||(a=h+i)),"vertical"!==r.direction&&"both"!==r.direction||("top"===r.edge||"top-left"===r.edge||"top-right"===r.edge?u=m-o:"bottom"!==r.edge&&"bottom-left"!==r.edge&&"bottom-right"!==r.edge||(u=m+o)),null!==g&&a<=g)return t.classList.add("resizable-closing"),p="closing",void(f&&s.evaluate(`${f} = false`));if(null!==T&&u<=T)return t.classList.add("resizable-closing"),p="closing",void(f&&s.evaluate(`${f} = false`));const d=S.length>0?S:I,b=R;for(const e of d){if(Math.abs(a-e.value)<b){a=e.value,p=`${n(a,e.unit,t)}${e.unit}`;break}}const v=E.length>0?E:I,A=_;for(const e of v){if(Math.abs(u-e.value)<A){u=e.value,p=`${n(u,e.unit,t)}${e.unit}`;break}}t.style.width=`${a}px`,t.style.height=`${u}px`,t.classList.remove("resizable-closing","resizable-closed"),f&&s.evaluate(`${f} = true`),"closing"!==p&&(w&&localStorage.setItem(`resizable-${w}`,`${a}|px`),y&&localStorage.setItem(`resizable-${y}`,`${u}|px`)),t.dispatchEvent(new CustomEvent("resize",{detail:{width:a,height:u,unit:"px",snap:p,closing:"closing"===p}}))},L=()=>{document.removeEventListener("mousemove",P),document.removeEventListener("mouseup",L);const e=document.querySelector(".resize-overlay");e&&(e.style.display="none"),"closing"===p&&t.classList.add("resizable-closed")};o.addEventListener("mousedown",(e=>{e.preventDefault(),e.stopPropagation(),c=e.clientX,l=e.clientY,h=t.getBoundingClientRect().width,m=t.getBoundingClientRect().height;const i=document.querySelector(".resize-overlay")||function(){const e=document.createElement("div");return e.className="resize-overlay",e.style.display="none",e}();i.style.display="block",document.body.appendChild(i),document.addEventListener("mousemove",P),document.addEventListener("mouseup",L)})),t.appendChild(o),s.handles.push(o)}))}Alpine.directive("resize",((e,{modifiers:t,expression:i},{evaluate:n})=>{if(e._resizeConfig={expression:i,evaluate:n,handles:null,initialized:!1},i)try{const t=n(i);if(t){if(t.saveWidth){const i=localStorage.getItem(`resizable-${t.saveWidth}`);if(i){const[t,n]=i.split("|");e.style.width=`${t}${n||"px"}`}}if(t.saveHeight){const i=localStorage.getItem(`resizable-${t.saveHeight}`);if(i){const[t,n]=i.split("|");e.style.height=`${t}${n||"px"}`}}}}catch(e){}e.addEventListener("mouseenter",s,{once:!0})}))}function initializeRouting(){window.__induxRoutingInitialized=!0,window.dispatchEvent(new CustomEvent("indux:routing-ready"))}function captureBodyOrder(){if(!window.__induxBodyOrder)try{const e=new XMLHttpRequest;if(e.open("GET","/index.html",!1),e.send(null),200===e.status){let t=e.responseText;window.InduxComponents||(t=t.replace(/<x-([a-z0-9-]+)([^>]*)\s*\/?>/gi,((e,t,i)=>`<x-${t}${i}></x-${t}>`)));const i=(new DOMParser).parseFromString(t,"text/html"),n=Array.from(i.body.children);window.__induxBodyOrder=n.map(((e,t)=>({index:t,tag:e.tagName.toLowerCase().trim(),isComponent:e.tagName.toLowerCase().startsWith("x-"),attrs:Array.from(e.attributes).map((e=>[e.name,e.value])),key:e.getAttribute("data-component-id")||(e.tagName.toLowerCase().startsWith("x-")?e.tagName.toLowerCase().replace("x-","").trim():null),position:t,content:e.tagName.toLowerCase().startsWith("x-")?null:e.innerHTML})))}}catch(e){}}function assignDataPositions(){if(!document.body)return;Array.from(document.body.children).forEach(((e,t)=>{e.setAttribute("data-order",t.toString())}))}function initializePositionManagement(){captureBodyOrder(),assignDataPositions()}requireIndux_markdown(),"undefined"!=typeof Alpine?initializeResizablePlugin():document.addEventListener("alpine:init",(()=>{initializeResizablePlugin()})),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",initializeRouting):initializeRouting(),window.InduxRouting={initialize:initializeRouting,matchesCondition:(e,t)=>{const i="/"===e?"/":e.replace(/^\/+|\/+$/g,"")||"/",n=[];try{const e=window.InduxComponentsRegistry?.manifest||window.manifest;e&&e.data&&Object.values(e.data).forEach((e=>{"object"==typeof e&&null!==e&&Object.keys(e).forEach((e=>{e.match(/^[a-z]{2}(-[A-Z]{2})?$/)&&n.push(e)}))}))}catch(e){}let s=i;if(n.length>0){const e=i.split("/").filter((e=>e));e.length>0&&n.includes(e[0])&&(s=e.slice(1).join("/")||"/")}if(t.includes("*")){if("*"===t)return!0;const e=t.replace("*","").replace(/^\/+|\/+$/g,"");return s.startsWith(e+"/")}if(t.startsWith("=")){const e=t.slice(1);if("/"===e)return"/"===s||""===s;return s===e.replace(/^\/+|\/+$/g,"")}if(t.startsWith("/")){if("/"===t)return"/"===s||""===s;const e=t.replace(/^\//,"");return s===e||s.startsWith(e+"/")}return s.includes(t)}},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",initializePositionManagement):initializePositionManagement(),window.InduxRoutingPosition={initialize:initializePositionManagement,captureBodyOrder:captureBodyOrder,assignDataPositions:assignDataPositions};let currentRoute="/",isInternalNavigation=!1;async function handleRouteChange(){const e=window.location.pathname;e!==currentRoute&&(currentRoute=e,window.location.hash?setTimeout((()=>{}),50):setTimeout((()=>{window.scrollTo({top:0,behavior:"smooth"});document.querySelectorAll("div, main, section, article, aside, nav, header, footer, .prose").forEach((e=>{const t=window.getComputedStyle(e);("auto"===t.overflowY||"scroll"===t.overflowY||"auto"===t.overflow||"scroll"===t.overflow)&&e.scrollHeight>e.clientHeight&&(e.scrollTop=0)}))}),50),window.dispatchEvent(new CustomEvent("indux:route-change",{detail:{from:currentRoute,to:e,normalizedPath:"/"===e?"/":e.replace(/^\/|\/$/g,"")}})))}function interceptLinkClicks(){document.addEventListener("click",(e=>{const t=e.target.closest("a");if(!t)return;const i=t.getAttribute("href");if(!i||i.startsWith("mailto:")||i.startsWith("tel:"))return;if(i.startsWith("#"))return;let n=!1;try{new URL(i,window.location.origin).origin!==window.location.origin&&(n=!0)}catch(e){}if(!n){if(i.includes("#")){const[t,n]=i.split("#");return e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),isInternalNavigation=!0,history.pushState(null,"",i),handleRouteChange(),isInternalNavigation=!1,void setTimeout((()=>{const e=document.getElementById(n);e&&e.scrollIntoView({behavior:"smooth"})}),100)}e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation(),isInternalNavigation=!0,history.pushState(null,"",i),handleRouteChange(),isInternalNavigation=!1}}),!0)}function initializeNavigation(){currentRoute=window.location.pathname,interceptLinkClicks(),window.addEventListener("popstate",(()=>{isInternalNavigation||handleRouteChange()})),handleRouteChange()}function processRouteVisibility(e){const t=document.querySelectorAll("[x-route]"),i=[];t.forEach((e=>{const t=e.getAttribute("x-route");if(!t)return;t.split(",").map((e=>e.trim())).forEach((e=>{e.startsWith("!")||"!*"===e||i.push(e)}))}));const n=[];try{const e=window.InduxComponentsRegistry?.manifest||window.manifest;e&&e.data&&Object.values(e.data).forEach((e=>{"object"==typeof e&&null!==e&&Object.keys(e).forEach((e=>{e.match(/^[a-z]{2}(-[A-Z]{2})?$/)&&n.push(e)}))}))}catch(e){}let s=i.some((t=>window.InduxRouting.matchesCondition(e,t)));if(!s&&n.length>0){const t=e.split("/").filter((e=>e));if(t.length>0){const e=t[0];if(n.includes(e)){const e=t.slice(1).join("/");s=""===e?i.some((e=>window.InduxRouting.matchesCondition("/",e)||window.InduxRouting.matchesCondition("",e))):i.some((t=>window.InduxRouting.matchesCondition(e,t)))}}}t.forEach((t=>{const i=t.getAttribute("x-route");if(!i)return;const n=i.split(",").map((e=>e.trim())),r=n.filter((e=>!e.startsWith("!"))),o=n.filter((e=>e.startsWith("!"))).map((e=>e.slice(1)));if(n.includes("!*")){return void(!s?(t.removeAttribute("hidden"),t.style.display=""):(t.setAttribute("hidden",""),t.style.display="none"))}const a=o.some((t=>window.InduxRouting.matchesCondition(e,t)));(0===r.length||r.some((t=>window.InduxRouting.matchesCondition(e,t))))&&!a?(t.removeAttribute("hidden"),t.style.display=""):(t.setAttribute("hidden",""),t.style.display="none")}))}function addXCloakToRouteElements(){document.querySelectorAll("[x-route]:not([x-cloak])").forEach((e=>{e.setAttribute("x-cloak","")}))}function initializeVisibility(){addXCloakToRouteElements();const e=window.location.pathname;processRouteVisibility("/"===e?"/":e.replace(/^\/|\/$/g,"")),window.addEventListener("indux:route-change",(e=>{processRouteVisibility(e.detail.normalizedPath)})),window.addEventListener("indux:components-processed",(()=>{addXCloakToRouteElements();const e=window.location.pathname;processRouteVisibility("/"===e?"/":e.replace(/^\/|\/$/g,""))}))}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",initializeNavigation):initializeNavigation(),window.InduxRoutingNavigation={initialize:initializeNavigation,getCurrentRoute:()=>currentRoute},"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{addXCloakToRouteElements(),initializeVisibility()})):(addXCloakToRouteElements(),initializeVisibility()),window.InduxRoutingVisibility={initialize:initializeVisibility,processRouteVisibility:processRouteVisibility};const injectedHeadContent=new Set;function shouldElementBeVisible(e,t){if(e.hasAttribute("x-route")){const i=e.getAttribute("x-route");if(i){const e=i.split(",").map((e=>e.trim())),n=e.filter((e=>!e.startsWith("!"))),s=e.filter((e=>e.startsWith("!"))).map((e=>e.slice(1))).some((e=>window.InduxRouting.matchesCondition(t,e)));return(0===n.length||n.some((e=>window.InduxRouting.matchesCondition(t,e))))&&!s}}const i=e.closest("[x-route]");return!i||shouldElementBeVisible(i,t)}function generateHeadId(e){const t=e.getAttribute("data-order"),i=e.getAttribute("data-component-id"),n=e.tagName.toLowerCase();return t?`${n}-${t}`:i?`${n}-${i}`:`${n}-${Math.random().toString(36).substr(2,9)}`}function processElementHeadContent(e,t){let i=null;if(i="TEMPLATE"===e.tagName&&e.hasAttribute("data-head")?e:e.querySelector("template[data-head]"),!i)return;const n=generateHeadId(e);if(shouldElementBeVisible(e,t)){if(injectedHeadContent.has(n))return;Array.from(i.content.children).forEach((e=>{if("SCRIPT"===e.tagName){const t=document.createElement("script");t.textContent=e.textContent,t.setAttribute("data-route-head",n),document.head.appendChild(t)}else{const t=e.cloneNode(!0);t.setAttribute("data-route-head",n),document.head.appendChild(t)}})),injectedHeadContent.add(n)}else{document.head.querySelectorAll(`[data-route-head="${n}"]`).forEach((e=>{e.remove()})),injectedHeadContent.delete(n)}}function processAllHeadContent(e){const t=document.querySelectorAll("template[data-head]");document.querySelectorAll("template").forEach(((e,t)=>{e.hasAttribute("data-head")||e.getAttribute("x-route")})),document.querySelector('template[x-route="about"]'),t.forEach(((t,i)=>{let n=t,s=!0;if(t.hasAttribute("data-component")){t.getAttribute("data-component");const i=t.getAttribute("x-route");if(i){s=window.InduxRouting.matchesCondition(e,i)}else s=!1}else if(n=t.closest("[data-order], [data-component-id], [x-route]"),n&&n!==t||(n=t.hasAttribute("data-order")||t.hasAttribute("data-component")||t.hasAttribute("x-route")?t:t.parentElement),n){s=shouldElementBeVisible(n,e)}s&&(t.hasAttribute("data-component")?processElementHeadContent(t,e):processElementHeadContent(n,e))}))}function initializeHeadContent(){function e(){setTimeout((()=>{const e=window.location.pathname,t="/"===e?"/":e.replace(/^\/|\/$/g,"");document.querySelector('[data-component="about-1"]');document.querySelectorAll("x-about, x-home, x-ui").forEach(((e,t)=>{})),processAllHeadContent(t)}),200)}window.InduxComponents?window.__induxComponentsInitialized?document.querySelector("[data-component]")?e():window.addEventListener("indux:components-processed",e):window.addEventListener("indux:components-ready",(()=>{window.addEventListener("indux:components-processed",e)})):function(){const e=window.location.pathname;processAllHeadContent("/"===e?"/":e.replace(/^\/|\/$/g,""))}(),window.addEventListener("indux:route-change",(e=>{setTimeout((()=>{const e=window.location.pathname,t="/"===e?"/":e.replace(/^\/|\/$/g,"");document.querySelector('[data-component="about-1"]');document.querySelectorAll("x-about, x-home, x-ui").forEach(((e,t)=>{})),processAllHeadContent(t)}),100)}))}function initializeAnchors(){Alpine.directive("anchors",((el,{expression:expression,modifiers:modifiers},{effect:effect,evaluateLater:evaluateLater,Alpine:Alpine})=>{try{const parseExpression=e=>{if(!e||""===e.trim())return{scope:"",targets:"h1, h2, h3, h4, h5, h6"};if(e.includes("|")){const t=e.split("|").map((e=>e.trim()));return{scope:t[0]||"",targets:t[1]||"h1, h2, h3, h4, h5, h6"}}return{scope:"",targets:e}},extractAnchors=e=>{const t=parseExpression(e);let i=[];i=t.scope?Array.from(document.querySelectorAll(t.scope)):[document.body];let n=[];const s=t.targets.split(",").map((e=>e.trim()));return i.forEach((e=>{const t=[];s.forEach((i=>{const n=e.querySelectorAll(i);t.push(...Array.from(n))}));const i=[...new Set(t)];i.sort(((e,t)=>{const i=e.compareDocumentPosition(t);return i&Node.DOCUMENT_POSITION_FOLLOWING?-1:i&Node.DOCUMENT_POSITION_PRECEDING?1:0})),n.push(...i)})),n.map(((e,t)=>{let i=e.id;return i||(i=e.textContent.toLowerCase().replace(/[^a-z0-9]/g,"-").replace(/-+/g,"-"),i&&(e.id=i)),{id:i,text:e.textContent,link:`#${i}`,tag:e.tagName.toLowerCase(),class:e.className.split(" ")[0]||"",classes:Array.from(e.classList),index:t,element:e}}))};let renderedElements=[];const updateAnchors=anchors=>{if(renderedElements.forEach((e=>{e.parentElement&&e.remove()})),renderedElements=[],Alpine.store("anchors",{count:anchors.length}),anchors.length>0){const templateContent=el.content||el,containerTemplate=templateContent.querySelector("div")||el.querySelector("div");if(containerTemplate){const containerElement=containerTemplate.cloneNode(!1);containerElement.removeAttribute("x-show"),anchors.forEach((anchor=>{const anchorTemplate=templateContent.querySelector("a")||el.querySelector("a");if(anchorTemplate){const linkElement=anchorTemplate.cloneNode(!0);if(linkElement.removeAttribute("x-text"),linkElement.removeAttribute(":href"),linkElement.href=anchor.link,linkElement.textContent=anchor.text,linkElement.hasAttribute(":class")){const classBinding=linkElement.getAttribute(":class");linkElement.removeAttribute(":class");try{const evaluateClassBinding=(binding,anchor)=>{let evaluated=binding.replace(/anchor\.tag/g,`'${anchor.tag}'`).replace(/anchor\.selected/g,anchor.selected?"true":"false").replace(/anchor\.index/g,anchor.index).replace(/anchor\.id/g,`'${anchor.id}'`).replace(/anchor\.text/g,`'${anchor.text.replace(/'/g,"\\'")}'`).replace(/anchor\.link/g,`'${anchor.link}'`).replace(/anchor\.class/g,`'${anchor.class}'`);if(evaluated.includes("{")&&evaluated.includes("}")){const objectMatch=evaluated.match(/\{([^}]+)\}/);if(objectMatch){const objectContent=objectMatch[1],classPairs=objectContent.split(",").map((e=>e.trim()));classPairs.forEach((pair=>{const[className,condition]=pair.split(":").map((e=>e.trim()));condition&&eval(condition)&&linkElement.classList.add(className.replace(/['"]/g,""))}))}}};evaluateClassBinding(classBinding,anchor)}catch(e){console.warn("[Indux Anchors] Could not evaluate class binding:",classBinding,e)}}containerElement.appendChild(linkElement)}})),el.parentElement.insertBefore(containerElement,el),renderedElements.push(containerElement)}else anchors.forEach((anchor=>{const templateContent=el.content||el,anchorTemplate=templateContent.querySelector("a")||el.querySelector("a");if(anchorTemplate){const linkElement=anchorTemplate.cloneNode(!0);if(linkElement.removeAttribute("x-text"),linkElement.removeAttribute(":href"),linkElement.href=anchor.link,linkElement.textContent=anchor.text,linkElement.hasAttribute(":class")){const classBinding=linkElement.getAttribute(":class");linkElement.removeAttribute(":class");try{const evaluateClassBinding=(binding,anchor)=>{let evaluated=binding.replace(/anchor\.tag/g,`'${anchor.tag}'`).replace(/anchor\.selected/g,anchor.selected?"true":"false").replace(/anchor\.index/g,anchor.index).replace(/anchor\.id/g,`'${anchor.id}'`).replace(/anchor\.text/g,`'${anchor.text.replace(/'/g,"\\'")}'`).replace(/anchor\.link/g,`'${anchor.link}'`).replace(/anchor\.class/g,`'${anchor.class}'`);if(evaluated.includes("{")&&evaluated.includes("}")){const objectMatch=evaluated.match(/\{([^}]+)\}/);if(objectMatch){const objectContent=objectMatch[1],classPairs=objectContent.split(",").map((e=>e.trim()));classPairs.forEach((pair=>{const[className,condition]=pair.split(":").map((e=>e.trim()));condition&&eval(condition)&&linkElement.classList.add(className.replace(/['"]/g,""))}))}}};evaluateClassBinding(classBinding,anchor)}catch(e){console.warn("[Indux Anchors] Could not evaluate class binding:",classBinding,e)}}el.parentElement.insertBefore(linkElement,el),renderedElements.push(linkElement)}}));el.style.display="none"}else el.style.display=""},tryExtraction=()=>{const e=extractAnchors(expression);return updateAnchors(e),e},attemptExtraction=(e=1,t=10)=>{const i=extractAnchors(expression);return i.length>0?(updateAnchors(i),!0):(e<t?setTimeout((()=>{attemptExtraction(e+1,t)}),200*e):updateAnchors([]),!1)};el._x_anchorRefresh=()=>{attemptExtraction()},attemptExtraction()}catch(e){console.error("[Indux Anchors] Error in directive:",e)}}))}function initializeRouterMagic(){if("undefined"==typeof Alpine)return void console.error("[Indux Router Magic] Alpine is not available");const e=Alpine.reactive({current:window.location.pathname,segments:[],params:{},matches:null}),t=()=>{const t=window.InduxRoutingNavigation?.getCurrentRoute()||window.location.pathname;let i=t;const n=t.split("/").filter(Boolean);if(n.length>0){const e=n[0];if(/^[a-zA-Z0-9_-]{2,5}$/.test(e)){const t=Alpine.store("locale");t&&t.available&&t.available.includes(e)&&(i="/"+n.slice(1).join("/"),"/"===i&&(i="/"))}}const s="/"===i?"":i.replace(/^\/|\/$/g,""),r=s?s.split("/").filter((e=>e)):[];e.current=i,e.segments=r,e.params={}};window.addEventListener("indux:route-change",t),window.addEventListener("popstate",t),Alpine.magic("route",(()=>e.current))}if("loading"===document.readyState?document.addEventListener("DOMContentLoaded",initializeHeadContent):initializeHeadContent(),window.InduxRoutingHead={initialize:initializeHeadContent,processElementHeadContent:processElementHeadContent,processAllHeadContent:processAllHeadContent},document.addEventListener("alpine:init",(()=>{try{initializeAnchors()}catch(e){console.error("[Indux Anchors] Failed to initialize:",e)}})),window.addEventListener("indux:route-change",(()=>{Alpine.store("anchors",{count:0}),setTimeout((()=>{document.querySelectorAll("[x-anchors]").forEach((e=>{e.getAttribute("x-anchors")&&e._x_anchorRefresh&&e._x_anchorRefresh()}))}),200)})),window.addEventListener("hashchange",(()=>{document.querySelectorAll("[x-anchors]").forEach((e=>{e._x_anchorRefresh&&e._x_anchorRefresh()}))})),window.addEventListener("indux:components-processed",(()=>{setTimeout((()=>{document.querySelectorAll("[x-anchors]").forEach((e=>{e.getAttribute("x-anchors")&&e._x_anchorRefresh&&e._x_anchorRefresh()}))}),100)})),window.InduxRoutingAnchors={initialize:initializeAnchors},document.addEventListener("alpine:init",(()=>{const e=()=>{if(window.InduxRoutingNavigation&&window.InduxRouting)try{initializeRouterMagic()}catch(e){console.error("[Indux Router Magic] Failed to initialize:",e)}else setTimeout(e,50)};e()})),"undefined"!=typeof Alpine&&window.InduxRoutingNavigation&&window.InduxRouting)try{initializeRouterMagic()}catch(e){console.error("[Indux Router Magic] Failed to initialize immediately:",e)}function initializeCarouselPlugin(){Alpine.directive("carousel",((e,{value:t,modifiers:i,expression:n},{evaluate:s,effect:r})=>{const o={carousel:{autoplay:i.includes("autoplay"),interval:3e3,loop:i.includes("loop"),arrows:i.includes("arrows"),dots:i.includes("dots"),thumbnails:i.includes("thumbnails"),enableDrag:!i.includes("no-drag")},currentSlide:0,dragging:!1,startX:0,get totalSlides(){const t=e.querySelector(".carousel-slides");return t?Array.from(t.children).filter((e=>"TEMPLATE"!==e.tagName)).length:0},next(){const e=this.totalSlides;this.currentSlide>=e-1?this.carousel.loop&&(this.currentSlide=0):this.currentSlide++},prev(){const e=this.totalSlides;this.currentSlide<=0?this.carousel.loop&&(this.currentSlide=e-1):this.currentSlide--},goToSlide(e){const t=this.totalSlides;e>=0&&e<t&&(this.currentSlide=e)},startDrag(e){this.carousel.enableDrag&&(this.dragging=!0,this.startX="mousedown"===e.type?e.pageX:e.touches[0].pageX)},drag(e){if(!this.dragging)return;e.preventDefault();const t=("mousemove"===e.type?e.pageX:e.touches[0].pageX)-this.startX;Math.abs(t)>50&&(t>0?this.prev():this.next(),this.dragging=!1)},endDrag(){this.dragging=!1},get dots(){return Array.from({length:this.totalSlides},((e,t)=>({index:t,active:t===this.currentSlide})))}};Alpine.bind(e,{"x-data":()=>o,"x-init"(){setTimeout((()=>{if(e.querySelector(".carousel-slides")){if(this.carousel.autoplay){let t;const i=()=>{t=setInterval((()=>this.next()),this.carousel.interval)},n=()=>{clearInterval(t)};i(),e.addEventListener("mouseenter",n),e.addEventListener("mouseleave",i),e._x_cleanups=e._x_cleanups||[],e._x_cleanups.push((()=>{n(),e.removeEventListener("mouseenter",n),e.removeEventListener("mouseleave",i)}))}}else console.warn('[Indux] Carousel track element not found. Expected element with class "carousel-slides"')}),0)}})}))}function initializeTabsPlugin(){function e(){const e=document.querySelectorAll("[x-tab]"),t=document.querySelectorAll("[x-tabpanel]");if(0===e.length&&0===t.length)return;const i={};t.forEach((e=>{const t=e.getAttribute("x-tabpanel")||"",n=e.id||e.className.split(" ")[0];n&&(i[t]||(i[t]=[]),i[t].push({element:e,id:n}))})),Object.entries(i).forEach((([t,i])=>{const n=t?`tab_${t}`:"tab";let s=document.body;i.length>0&&(s=i[0].element.closest("[x-data]")||document.body),s.hasAttribute("x-data")||s.setAttribute("x-data","{}");const r=s.getAttribute("x-data")||"{}";let o=r;if(!new RegExp(`${n}\\s*:\\s*'[^']*'`,"g").test(o)){const e=i.length>0?i[0].id:"a",t=`${n}: '${e}'`;if("{}"===o)o=`{ ${t} }`;else{const e=o.lastIndexOf("}");if(e>0){const i=o.substring(0,e),n=o.substring(e),s=i.trim().endsWith(",")?"":", ";o=i+s+t+n}}o!==r&&s.setAttribute("x-data",o)}i.forEach((e=>{const t=`${n} === '${e.id}'`;e.element.setAttribute("x-show",t),e.element.removeAttribute("x-tabpanel")})),e.forEach((e=>{const t=e.getAttribute("x-tab");if(!t)return;if(!i.some((e=>e.id===t)))return;const s=`${n} = '${t}'`;e.setAttribute("x-on:click",s),e.removeAttribute("x-tab")}))}))}document.addEventListener("indux:components-ready",(()=>{setTimeout(e,100)})),document.addEventListener("indux:components-processed",(()=>{setTimeout(e,100)})),document.addEventListener("DOMContentLoaded",(()=>{setTimeout(e,100)})),setTimeout((()=>{e()}),2e3)}function initializeThemePlugin(){const e=Alpine.reactive({current:localStorage.getItem("theme")||"system"});i(e.current);function t(t){"toggle"===t&&(t="light"===e.current?"dark":"light"),e.current=t,localStorage.setItem("theme",t),i(t)}function i(e){const t="system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches:"dark"===e;document.documentElement.classList.remove("light","dark"),document.documentElement.classList.add(t?"dark":"light");const i=document.querySelector('meta[name="theme-color"]');i&&i.setAttribute("content",t?"#000000":"#FFFFFF")}window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",(()=>{"system"===e.current&&i("system")})),Alpine.directive("theme",((e,{expression:i},{evaluate:n,cleanup:s})=>{const r=()=>{t("toggle"===i?document.documentElement.classList.contains("dark")?"light":"dark":n(i))};e.addEventListener("click",r),s((()=>e.removeEventListener("click",r)))})),Alpine.magic("theme",(()=>({get current(){return e.current},set current(e){t(e)}})))}window.InduxRoutingMagic={initialize:initializeRouterMagic},"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&initializeCarouselPlugin()})),document.addEventListener("alpine:init",initializeCarouselPlugin),initializeTabsPlugin(),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&initializeThemePlugin()})),document.addEventListener("alpine:init",initializeThemePlugin);const TOAST_DURATION=3e3;function initializeToastPlugin(){const e=(e,{type:i="",duration:n=TOAST_DURATION,dismissible:s=!1,fixed:r=!1,icon:o=null}={})=>{const a=(()=>{let e=document.querySelector(".toast-container");return e||(e=document.createElement("div"),e.className="toast-container",document.body.appendChild(e)),e})(),c=document.createElement("div");c.setAttribute("role","alert"),c.setAttribute("class",i?`toast ${i}`:"toast");const l=`\n            ${o?'<span class="toast-icon"></span>':""}\n            <div class="toast-content">${e}</div>\n            ${s||r?'<button class="toast-dismiss-button" aria-label="Dismiss"></button>':""}\n        `;if(c.innerHTML=l,o){c.querySelector(".toast-icon").appendChild((e=>{const t=document.createElement("span");return t.className="iconify",t.setAttribute("data-icon",e),window.Iconify&&window.Iconify.scan(t),t})(o))}if(a.appendChild(c),requestAnimationFrame((()=>{requestAnimationFrame((()=>{c.classList.add("toast-entry")}))})),(s||r)&&c.querySelector(".toast-dismiss-button")?.addEventListener("click",(()=>{t(c)})),!r){const e=setTimeout((()=>{t(c)}),n);c.addEventListener("mouseenter",(()=>{clearTimeout(e)})),c.addEventListener("mouseleave",(()=>{setTimeout((()=>{t(c)}),n/2)}))}},t=e=>{e.classList.remove("toast-entry"),e.classList.add("toast-exit");let t=0;e.addEventListener("transitionend",(i=>{t++,t>=2&&(e.style.height=`${e.offsetHeight}px`,e.offsetHeight,e.style.height="0",e.style.margin="0",e.style.padding="0",e.addEventListener("transitionend",(()=>{e.remove()}),{once:!0}))}))};Alpine.directive("toast",((t,{modifiers:i,expression:n},{evaluate:s})=>{const r={type:i.includes("brand")?"brand":i.includes("positive")?"positive":i.includes("negative")?"negative":i.includes("accent")?"accent":"",dismissible:i.includes("dismiss"),fixed:i.includes("fixed")},o=i.find((e=>!isNaN(e)));let a;r.duration=o?Number(o):i.includes("long")?2*TOAST_DURATION:TOAST_DURATION;try{a=n.startsWith("$x.")||n.includes("+")||n.includes("`")||n.includes("${")?s(n):n}catch(e){a=n}t._toastOptions={message:a,options:r};const c=t.onclick;t.onclick=i=>{c&&c.call(t,i),e(a,r)}})),Alpine.magic("toast",(()=>{const t=(t,i={})=>{e(t,{...i,type:""})};return t.brand=(t,i={})=>{e(t,{...i,type:"brand"})},t.accent=(t,i={})=>{e(t,{...i,type:"accent"})},t.positive=(t,i={})=>{e(t,{...i,type:"positive"})},t.negative=(t,i={})=>{e(t,{...i,type:"negative"})},t.dismiss=(t,i={})=>{e(t,{...i,type:"",dismissible:!0})},t.brand.dismiss=(t,i={})=>{e(t,{...i,type:"brand",dismissible:!0})},t.accent.dismiss=(t,i={})=>{e(t,{...i,type:"accent",dismissible:!0})},t.positive.dismiss=(t,i={})=>{e(t,{...i,type:"positive",dismissible:!0})},t.negative.dismiss=(t,i={})=>{e(t,{...i,type:"negative",dismissible:!0})},t.fixed=(t,i={})=>{e(t,{...i,type:"",fixed:!0})},t.brand.fixed=(t,i={})=>{e(t,{...i,type:"brand",fixed:!0})},t.accent.fixed=(t,i={})=>{e(t,{...i,type:"accent",fixed:!0})},t.positive.fixed=(t,i={})=>{e(t,{...i,type:"positive",fixed:!0})},t.negative.fixed=(t,i={})=>{e(t,{...i,type:"negative",fixed:!0})},t}))}"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&initializeToastPlugin()})),document.addEventListener("alpine:init",initializeToastPlugin);var indux_tooltips={},hasRequiredIndux_tooltips;function requireIndux_tooltips(){if(hasRequiredIndux_tooltips)return indux_tooltips;function e(){Alpine.directive("tooltip",((e,{modifiers:t,expression:i},{effect:n,evaluateLater:s})=>{let r;if(i.startsWith("$x.")){const e=i.substring(3),[t,...o]=e.split(".");r=s(i),n((()=>{const e=Alpine.store("collections");e&&"function"==typeof e.loadCollection&&!e[t]&&e.loadCollection(t)}))}else if(i.includes("<")&&i.includes(">")){const e=i.replace(/'/g,"\\'");r=s(`'${e}'`)}else r=i.includes("+")||i.includes("`")||i.includes("${")?s(i):s(`'${i}'`);n((()=>{const i=Math.random().toString(36).substr(2,9),n=`tooltip-${i}`;let s=e.getAttribute("popovertarget");!s&&e.hasAttribute("x-dropdown")&&(s=e.getAttribute("x-dropdown"));const o=document.createElement("div");o.setAttribute("popover",""),o.setAttribute("id",n),o.setAttribute("class","tooltip"),e.style.getPropertyValue("anchor-name");const a=`--tooltip-${i}`;r((e=>{o.innerHTML=e||""}));const c=["top","bottom","start","end","center","corner"],l=t.filter((e=>c.includes(e)));if(l.length>0){const e=l.join("-");o.classList.add(e)}let u;document.body.appendChild(o);let d=!1;function h(){e._originalAnchorName?e.style.setProperty("anchor-name",e._originalAnchorName):e.style.removeProperty("anchor-name")}e.addEventListener("mouseenter",(()=>{if(!d){const t=function(e){let t=getComputedStyle(e),i=t.getPropertyValue("--tooltip-hover-delay").trim();if(i||(t=getComputedStyle(document.documentElement),i=t.getPropertyValue("--tooltip-hover-delay").trim()),!i)return 500;const n=parseFloat(i);return i.endsWith("s")?1e3*n:i.endsWith("ms")?n:i.endsWith("m")?60*n*1e3:i.endsWith("h")?60*n*60*1e3:i.endsWith("min")?60*n*1e3:i.endsWith("sec")||i.endsWith("second")?1e3*n:i.endsWith("minute")?60*n*1e3:i.endsWith("hour")?60*n*60*1e3:n}(e);u=setTimeout((()=>{const t=s&&document.getElementById(s)?.matches(":popover-open");if(!d&&!o.matches(":popover-open")&&!t){if(s){const t=e.style.getPropertyValue("anchor-name");t&&(e._originalAnchorName=t)}e.style.setProperty("anchor-name",a),o.style.setProperty("position-anchor",a),o.showPopover()}}),t)}})),e.addEventListener("mouseleave",(()=>{clearTimeout(u),o.matches(":popover-open")&&(o.hidePopover(),s&&h())})),e.addEventListener("mousedown",(()=>{d=!0,clearTimeout(u),o.matches(":popover-open")&&o.hidePopover(),s&&h()})),e.addEventListener("mouseup",(()=>{d=!1})),e.addEventListener("click",(e=>{clearTimeout(u),o.matches(":popover-open")&&o.hidePopover(),setTimeout((()=>{if(s){const e=document.getElementById(s),t=e?.matches(":popover-open");e&&t||h()}else h()}),100)}));const m=e=>{e.target!==o&&o.matches(":popover-open")&&(o.hidePopover(),s&&h())};e._tooltipPopoverListener||(document.addEventListener("toggle",m),e._tooltipPopoverListener=m);e._tooltipCleanup=()=>{e._tooltipPopoverListener&&(document.removeEventListener("toggle",e._tooltipPopoverListener),delete e._tooltipPopoverListener),o&&o.parentElement&&o.remove()}}))}))}return hasRequiredIndux_tooltips=1,"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&e()})),document.addEventListener("alpine:init",e),indux_tooltips}function initializeUrlParametersPlugin(){Alpine.store("urlParams",{current:{},_initialized:!1});const e=new Map,t=300;function i(e){const t=new URLSearchParams(e),i={};for(const[e,n]of t.entries())n.includes(",")?i[e]=n.split(",").filter(Boolean):i[e]=n;return i}function n(e){return Array.isArray(e)?e:null==e||""===e?[]:[e]}async function s(e,t="set"){const s=new URL(window.location.href),r=i(s.search);for(const[i,s]of Object.entries(e))switch(t){case"add":const e=n(r[i]),t=n(s);r[i]=[...new Set([...e,...t])];break;case"remove":const o=n(r[i]),a=n(s)[0];r[i]=o.filter((e=>e!==a)),0===r[i].length&&delete r[i];break;default:null==s||""===s?delete r[i]:r[i]=s}const o=function(e){const t=new URLSearchParams;for(const[i,n]of Object.entries(e))Array.isArray(n)?t.set(i,n.filter(Boolean).join(",")):null!=n&&""!==n&&t.set(i,n);return t.toString()}(r);return s.search=o?`?${o}`:"",console.debug("[Indux] New URL:",s.toString()),window.history.pushState({},"",s.toString()),Alpine.store("urlParams",{current:r,_initialized:!0}),document.dispatchEvent(new CustomEvent("url-updated",{detail:{updates:e,action:t}})),r}Alpine.magic("url",(()=>{const i=Alpine.store("urlParams");return new Proxy({},{get(n,r){if(r===Symbol.iterator||"then"===r||"catch"===r||"finally"===r)return;const o=i.current[r];return new Proxy({},{get:(i,n)=>"value"===n?Array.isArray(o)?o:"string"==typeof o&&o.includes(",")?o.split(",").filter(Boolean):o:"set"===n?i=>{clearTimeout(e.get(r));const n=setTimeout((()=>{s({[r]:i},"set")}),t);e.set(r,n)}:"add"===n?i=>{clearTimeout(e.get(r));const n=setTimeout((()=>{s({[r]:i},"add")}),t);e.set(r,n)}:"remove"===n?i=>{clearTimeout(e.get(r));const n=setTimeout((()=>{s({[r]:i},"remove")}),t);e.set(r,n)}:"clear"===n?()=>{clearTimeout(e.get(r));const i=setTimeout((()=>{s({[r]:null},"set")}),t);e.set(r,i)}:void 0,set(i,n,o){if("value"===n){clearTimeout(e.get(r));const i=setTimeout((()=>{s({[r]:o},"set")}),t);return e.set(r,i),!0}return!1}})}})}));const r=i(window.location.search);Alpine.store("urlParams",{current:r,_initialized:!0}),window.addEventListener("popstate",(()=>{const e=i(window.location.search);Alpine.store("urlParams",{current:e,_initialized:!0})}))}function createUtilityGenerators(){return{"color-":(e,t)=>{const i=[],n=(t,n,s)=>{i.push([`${t}-${e}`,`${n}: ${s}`])};return n("text","color",t),n("bg","background-color",t),n("border","border-color",t),n("outline","outline-color",t),n("ring","box-shadow",`0 0 0 1px ${t}`),n("fill","fill",t),n("stroke","stroke",t),n("decoration","text-decoration-color",t),n("accent","accent-color",t),n("caret","caret-color",t),i},"font-":(e,t)=>[[`font-${e}`,`font-family: ${t}`]],"text-":(e,t)=>[[`text-${e}`,`font-size: ${t}`]],"font-weight-":(e,t)=>[[`font-${e}`,`font-weight: ${t}`]],"tracking-":(e,t)=>[[`tracking-${e}`,`letter-spacing: ${t}`]],"leading-":(e,t)=>[[`leading-${e}`,`line-height: ${t}`]],"breakpoint-":(e,t)=>[[`@${e}`,`@media (min-width: ${t})`]],"container-":(e,t)=>[[`container-${e}`,`max-width: ${t}`],[`@container-${e}`,`@container (min-width: ${t})`]],"spacing-":(e,t)=>[[`gap-${e}`,`gap: ${t}`],[`p-${e}`,`padding: ${t}`],[`px-${e}`,`padding-left: ${t}; padding-right: ${t}`],[`py-${e}`,`padding-top: ${t}; padding-bottom: ${t}`],[`m-${e}`,`margin: ${t}`],[`mx-${e}`,`margin-left: ${t}; margin-right: ${t}`],[`my-${e}`,`margin-top: ${t}; margin-bottom: ${t}`],[`space-x-${e}`,`> * + * { margin-left: ${t}; }`],[`space-y-${e}`,`> * + * { margin-top: ${t}; }`],[`max-w-${e}`,`max-width: ${t}`],[`max-h-${e}`,`max-height: ${t}`],[`min-w-${e}`,`min-width: ${t}`],[`min-h-${e}`,`min-height: ${t}`],[`w-${e}`,`width: ${t}`],[`h-${e}`,`height: ${t}`]],"radius-":(e,t)=>[[`rounded-${e}`,`border-radius: ${t}`]],"shadow-":(e,t)=>[[`shadow-${e}`,`box-shadow: ${t}`]],"inset-shadow-":(e,t)=>[[`inset-shadow-${e}`,`box-shadow: inset ${t}`]],"drop-shadow-":(e,t)=>[[`drop-shadow-${e}`,`filter: drop-shadow(${t})`]],"blur-":(e,t)=>[[`blur-${e}`,`filter: blur(${t})`]],"perspective-":(e,t)=>[[`perspective-${e}`,`perspective: ${t}`]],"aspect-":(e,t)=>[[`aspect-${e}`,`aspect-ratio: ${t}`]],"ease-":(e,t)=>[[`ease-${e}`,`transition-timing-function: ${t}`]],"animate-":(e,t)=>[[`animate-${e}`,`animation: ${t}`]],"border-width-":(e,t)=>[[`border-${e}`,`border-width: ${t}`]],"border-style-":(e,t)=>[[`border-${e}`,`border-style: ${t}`]],"outline-":(e,t)=>[[`outline-${e}`,`outline-color: ${t}`]],"outline-width-":(e,t)=>[[`outline-${e}`,`outline-width: ${t}`]],"outline-style-":(e,t)=>[[`outline-${e}`,`outline-style: ${t}`]],"ring-":(e,t)=>[[`ring-${e}`,`box-shadow: 0 0 0 ${t} var(--color-ring)`]],"ring-offset-":(e,t)=>[[`ring-offset-${e}`,`--tw-ring-offset-width: ${t}`]],"divide-":(e,t)=>[[`divide-${e}`,`border-color: ${t}`]],"accent-":(e,t)=>[[`accent-${e}`,`accent-color: ${t}`]],"caret-":(e,t)=>[[`caret-${e}`,`caret-color: ${t}`]],"decoration-":(e,t)=>[[`decoration-${e}`,`text-decoration-color: ${t}`]],"placeholder-":(e,t)=>[[`placeholder-${e}`,`&::placeholder { color: ${t} }`]],"selection-":(e,t)=>[[`selection-${e}`,`&::selection { background-color: ${t} }`]],"scrollbar-":(e,t)=>[[`scrollbar-${e}`,`scrollbar-color: ${t}`]]}}function createVariants(){return{hover:":hover",focus:":focus","focus-visible":":focus-visible","focus-within":":focus-within",active:":active",visited:":visited",target:":target",first:":first-child",last:":last-child",only:":only-child",odd:":nth-child(odd)",even:":nth-child(even)","first-of-type":":first-of-type","last-of-type":":last-of-type","only-of-type":":only-of-type",empty:":empty",disabled:":disabled",enabled:":enabled",checked:":checked",indeterminate:":indeterminate",default:":default",required:":required",valid:":valid",invalid:":invalid","in-range":":in-range","out-of-range":":out-of-range","placeholder-shown":":placeholder-shown",autofill:":autofill","read-only":":read-only","read-write":":read-write",optional:":optional","user-valid":":user-valid","user-invalid":":user-invalid",inert:":inert",open:":is([open], :popover-open, :open) &",closed:":not(:is([open], :popover-open, :open)) &",paused:'[data-state="paused"] &',playing:'[data-state="playing"] &',muted:'[data-state="muted"] &',unmuted:'[data-state="unmuted"] &',collapsed:'[data-state="collapsed"] &',expanded:'[data-state="expanded"] &',unchecked:":not(:checked)",selected:'[data-state="selected"] &',unselected:'[data-state="unselected"] &',"details-content":"::details-content",nth:":nth-child","nth-last":":nth-last-child","nth-of-type":":nth-of-type","nth-last-of-type":":nth-last-of-type",has:":has",not:":not",before:"::before",after:"::after","first-letter":"::first-letter","first-line":"::first-line",marker:"::marker",selection:"::selection",file:"::file-selector-button",backdrop:"::backdrop",placeholder:"::placeholder","target-text":"::target-text","spelling-error":"::spelling-error","grammar-error":"::grammar-error",dark:".dark &",light:".light &",group:".group &","group-hover":".group:hover &","group-focus":".group:focus &","group-focus-within":".group:focus-within &","group-active":".group:active &","group-disabled":".group:disabled &","group-visited":".group:visited &","group-checked":".group:checked &","group-required":".group:required &","group-valid":".group:valid &","group-invalid":".group:invalid &","group-in-range":".group:in-range &","group-out-of-range":".group:out-of-range &","group-placeholder-shown":".group:placeholder-shown &","group-autofill":".group:autofill &","group-read-only":".group:read-only &","group-read-write":".group:read-write &","group-optional":".group:optional &","group-user-valid":".group:user-valid &","group-user-invalid":".group:user-invalid &",peer:".peer ~ &","peer-hover":".peer:hover ~ &","peer-focus":".peer:focus ~ &","peer-focus-within":".peer:focus-within ~ &","peer-active":".peer:active ~ &","peer-disabled":".peer:disabled ~ &","peer-visited":".peer:visited ~ &","peer-checked":".peer:checked ~ &","peer-required":".peer:required ~ &","peer-valid":".peer:valid ~ &","peer-invalid":".peer:invalid ~ &","peer-in-range":".peer:in-range ~ &","peer-out-of-range":".peer:out-of-range ~ &","peer-placeholder-shown":".peer:placeholder-shown ~ &","peer-autofill":".peer:autofill ~ &","peer-read-only":".peer:read-only ~ &","peer-read-write":".peer:read-write ~ &","peer-optional":".peer:optional ~ &","peer-user-valid":".peer:user-valid ~ &","peer-user-invalid":".peer:user-invalid &","motion-safe":"@media (prefers-reduced-motion: no-preference)","motion-reduce":"@media (prefers-reduced-motion: reduce)",print:"@media print",portrait:"@media (orientation: portrait)",landscape:"@media (orientation: landscape)","contrast-more":"@media (prefers-contrast: more)","contrast-less":"@media (prefers-contrast: less)","forced-colors":"@media (forced-colors: active)",rtl:'&:where(:dir(rtl), [dir="rtl"], [dir="rtl"] *)',ltr:'&:where(:dir(ltr), [dir="ltr"], [dir="ltr"] *)',"[dir=rtl]":'[dir="rtl"] &',"[dir=ltr]":'[dir="ltr"] &',"pointer-fine":"@media (pointer: fine)","pointer-coarse":"@media (pointer: coarse)","pointer-none":"@media (pointer: none)","any-pointer-fine":"@media (any-pointer: fine)","any-pointer-coarse":"@media (any-pointer: coarse)","any-pointer-none":"@media (any-pointer: none)","scripting-enabled":"@media (scripting: enabled)","can-hover":"@media (hover: hover)","can-not-hover":"@media (hover: none)","any-hover":"@media (any-hover: hover)","any-hover-none":"@media (any-hover: none)","any-pointer":"@media (any-pointer: fine)","any-pointer-coarse":"@media (any-pointer: coarse)","any-pointer-none":"@media (any-pointer: none)",color:"@media (color)","color-gamut":"@media (color-gamut: srgb)","color-gamut-p3":"@media (color-gamut: p3)","color-gamut-rec2020":"@media (color-gamut: rec2020)",monochrome:"@media (monochrome)","monochrome-color":"@media (monochrome: 0)","monochrome-grayscale":"@media (monochrome: 1)","inverted-colors":"@media (inverted-colors: inverted)","inverted-colors-none":"@media (inverted-colors: none)",update:"@media (update: fast)","update-slow":"@media (update: slow)","update-none":"@media (update: none)","overflow-block":"@media (overflow-block: scroll)","overflow-block-paged":"@media (overflow-block: paged)","overflow-inline":"@media (overflow-inline: scroll)","overflow-inline-auto":"@media (overflow-inline: auto)","prefers-color-scheme":"@media (prefers-color-scheme: dark)","prefers-color-scheme-light":"@media (prefers-color-scheme: light)","prefers-contrast":"@media (prefers-contrast: more)","prefers-contrast-less":"@media (prefers-contrast: less)","prefers-contrast-no-preference":"@media (prefers-contrast: no-preference)","prefers-reduced-motion":"@media (prefers-reduced-motion: reduce)","prefers-reduced-motion-no-preference":"@media (prefers-reduced-motion: no-preference)","prefers-reduced-transparency":"@media (prefers-reduced-transparency: reduce)","prefers-reduced-transparency-no-preference":"@media (prefers-reduced-transparency: no-preference)",resolution:"@media (resolution: 1dppx)","resolution-low":"@media (resolution: 1dppx)","resolution-high":"@media (resolution: 2dppx)",scan:"@media (scan: progressive)","scan-interlace":"@media (scan: interlace)",scripting:"@media (scripting: enabled)","scripting-none":"@media (scripting: none)","scripting-initial-only":"@media (scripting: initial-only)",container:"@container","container-name":"@container","!":"!important",sm:"@media (min-width: 640px)",md:"@media (min-width: 768px)",lg:"@media (min-width: 1024px)",xl:"@media (min-width: 1280px)","2xl":"@media (min-width: 1536px)",supports:"@supports",starting:"@starting-style","data-open":'[data-state="open"] &',"data-closed":'[data-state="closed"] &',"data-checked":'[data-state="checked"] &',"data-unchecked":'[data-state="unchecked"] &',"data-on":'[data-state="on"] &',"data-off":'[data-state="off"] &',"data-visible":'[data-state="visible"] &',"data-hidden":'[data-state="hidden"] &',"data-disabled":"[data-disabled] &","data-loading":"[data-loading] &","data-error":"[data-error] &","data-success":"[data-success] &","data-warning":"[data-warning] &","data-selected":"[data-selected] &","data-highlighted":"[data-highlighted] &","data-pressed":"[data-pressed] &","data-expanded":"[data-expanded] &","data-collapsed":"[data-collapsed] &","data-active":"[data-active] &","data-inactive":"[data-inactive] &","data-valid":"[data-valid] &","data-invalid":"[data-invalid] &","data-required":"[data-required] &","data-optional":"[data-optional] &","data-readonly":"[data-readonly] &","data-write":"[data-write] &","aria-expanded":'[aria-expanded="true"] &',"aria-collapsed":'[aria-expanded="false"] &',"aria-pressed":'[aria-pressed="true"] &',"aria-unpressed":'[aria-pressed="false"] &',"aria-checked":'[aria-checked="true"] &',"aria-unchecked":'[aria-checked="false"] &',"aria-selected":'[aria-selected="true"] &',"aria-unselected":'[aria-selected="false"] &',"aria-invalid":'[aria-invalid="true"] &',"aria-valid":'[aria-invalid="false"] &',"aria-required":'[aria-required="true"] &',"aria-optional":'[aria-required="false"] &',"aria-disabled":'[aria-disabled="true"] &',"aria-enabled":'[aria-disabled="false"] &',"aria-hidden":'[aria-hidden="true"] &',"aria-visible":'[aria-hidden="false"] &',"aria-busy":'[aria-busy="true"] &',"aria-available":'[aria-busy="false"] &',"aria-current":'[aria-current="true"] &',"aria-not-current":'[aria-current="false"] &',"aria-live":'[aria-live="polite"] &, [aria-live="assertive"] &',"aria-atomic":'[aria-atomic="true"] &',"aria-relevant":'[aria-relevant="additions"] &, [aria-relevant="removals"] &, [aria-relevant="text"] &, [aria-relevant="all"] &'}}function createVariantGroups(){return{state:["hover","focus","active","visited","target","open","closed","paused","playing","muted","unmuted","collapsed","expanded","unchecked","selected","unselected"],child:["first","last","only","odd","even"],form:["disabled","enabled","checked","indeterminate","required","valid","invalid"],pseudo:["before","after","first-letter","first-line","marker","selection","file","backdrop"],media:["dark","light","motion-safe","motion-reduce","print","portrait","landscape","rtl","ltr","can-hover","can-not-hover","any-hover","any-hover-none","color","monochrome","inverted-colors","inverted-colors-none","update","update-slow","update-none","overflow-block","overflow-block-paged","overflow-inline","overflow-inline-auto","prefers-color-scheme","prefers-color-scheme-light","prefers-contrast","prefers-contrast-less","prefers-contrast-no-preference","prefers-reduced-motion","prefers-reduced-motion-no-preference","prefers-reduced-transparency","prefers-reduced-transparency-no-preference","resolution","resolution-low","resolution-high","scan","scan-interlace","scripting","scripting-none","scripting-initial-only","forced-colors","contrast-more","contrast-less","pointer-fine","pointer-coarse","pointer-none","any-pointer-fine","any-pointer-coarse","any-pointer-none","scripting-enabled"],responsive:["sm","md","lg","xl","2xl"],group:["group","group-hover","group-focus","group-active","group-disabled","group-checked","group-required","group-valid","group-invalid"],peer:["peer","peer-hover","peer-focus","peer-active","peer-disabled","peer-checked","peer-required","peer-valid","peer-invalid"],data:["data-open","data-closed","data-checked","data-unchecked","data-visible","data-hidden","data-disabled","data-loading","data-error","data-success","data-warning","data-selected","data-highlighted","data-pressed","data-expanded","data-collapsed","data-active","data-inactive","data-valid","data-invalid","data-required","data-optional","data-readonly","data-write"],aria:["aria-expanded","aria-collapsed","aria-pressed","aria-unpressed","aria-checked","aria-unchecked","aria-selected","aria-unselected","aria-invalid","aria-valid","aria-required","aria-optional","aria-disabled","aria-enabled","aria-hidden","aria-visible","aria-busy","aria-available","aria-current","aria-not-current","aria-live","aria-atomic","aria-relevant"]}}requireIndux_tooltips(),"loading"===document.readyState&&document.addEventListener("DOMContentLoaded",(()=>{window.Alpine&&initializeUrlParametersPlugin()})),document.addEventListener("alpine:init",initializeUrlParametersPlugin);class TailwindCompiler{constructor(e={}){if(this.debug=!0===e.debug,this.startTime=performance.now(),this.debug&&(console.log(`[Indux Utilities] Constructor started at ${this.startTime.toFixed(2)}ms`),console.log(`[Indux Utilities] Document readyState: ${document.readyState}`),console.log(`[Indux Utilities] Head exists: ${!!document.head}`)),performance.now(),this.criticalStyleElement=document.createElement("style"),this.criticalStyleElement.id="utility-styles-critical",document.head)document.head.firstChild?document.head.insertBefore(this.criticalStyleElement,document.head.firstChild):document.head.appendChild(this.criticalStyleElement),this.debug&&console.log(`[Indux Utilities] Critical style element created and inserted at ${(performance.now()-this.startTime).toFixed(2)}ms`);else{this.debug&&console.warn("[Indux Utilities] Head doesn't exist yet, waiting...");const e=setInterval((()=>{document.head&&(clearInterval(e),document.head.firstChild?document.head.insertBefore(this.criticalStyleElement,document.head.firstChild):document.head.appendChild(this.criticalStyleElement),this.debug&&console.log(`[Indux Utilities] Critical style element inserted after wait at ${(performance.now()-this.startTime).toFixed(2)}ms`))}),1)}this.options={rootSelector:e.rootSelector||":root",themeSelector:e.themeSelector||"@theme",debounceTime:e.debounceTime||50,maxCacheAge:e.maxCacheAge||864e5,debug:!1!==e.debug,...e},this.regexPatterns={root:new RegExp(`${this.options.rootSelector}\\s*{([^}]*)}`,"g"),theme:new RegExp(`${this.options.themeSelector}\\s*{([^}]*)}`,"g"),variable:/--([\w-]+):\s*([^;]+);/g,tailwindPrefix:/^(color|font|text|font-weight|tracking|leading|breakpoint|container|spacing|radius|shadow|inset-shadow|drop-shadow|blur|perspective|aspect|ease|animate|border-width|border-style|outline|outline-width|outline-style|ring|ring-offset|divide|accent|caret|decoration|placeholder|selection|scrollbar)-/};const t=createUtilityGenerators();this.utilityGenerators={"color-":t["color-"],"font-":t["font-"],"text-":t["text-"],"font-weight-":t["font-weight-"],"tracking-":t["tracking-"],"leading-":t["leading-"],"spacing-":t["spacing-"],"radius-":t["radius-"],"shadow-":t["shadow-"],"blur-":t["blur-"]},Object.assign(this.utilityGenerators,t),this.variants=createVariants(),this.variantGroups=createVariantGroups(),this.classCache=new Map,this.addCriticalBlockingStylesSync(),this.styleElement=document.createElement("style"),this.styleElement.id="utility-styles",document.head.appendChild(this.styleElement),this.debug&&console.log(`[Indux Utilities] Main style element created at ${(performance.now()-this.startTime).toFixed(2)}ms`),this.tailwindLink=null,this.observer=null,this.isCompiling=!1,this.compileTimeout=null,this.cache=new Map,this.lastThemeHash=null,this.processedElements=new WeakSet,this.activeBreakpoints=new Set,this.activeModifiers=new Set,this.cssFiles=new Set,this.pendingStyles=new Map,this.currentThemeVars=new Map,this.hasInitialized=!1,this.lastCompileTime=0,this.minCompileInterval=100,this.cssContentCache=new Map,this.lastClassesHash="",this.staticClassCache=new Set,this.dynamicClassCache=new Set,this.hasScannedStatic=!1,this.staticScanPromise=null,this.ignoredClassPatterns=[/^hljs/,/^language-/,/^copy$/,/^copied$/,/^lines$/,/^selected$/],this.ignoredElementSelectors=["pre","code","x-code","x-code-group"],this.ignoredAttributes=["id","data-order","data-component-id","data-highlighted","data-processed","x-intersect","x-intersect:leave","x-show","x-hide","x-transition","aria-expanded","aria-selected","aria-current","aria-hidden","aria-label","tabindex","role","title","alt","data-state","data-value"],this.significantChangeSelectors=["[data-component]","[x-data]"],this.pseudoClasses=["hover","focus","active","disabled","dark"],this.customUtilities=new Map,this.loadAndApplyCache(),this.generateSynchronousUtilities(),this.setupComponentLoadListener(),this.waitForTailwind().then((()=>{this.startProcessing()}))}addIgnoredClassPattern(e){e instanceof RegExp?this.ignoredClassPatterns.push(e):"string"==typeof e&&this.ignoredClassPatterns.push(new RegExp(e))}addIgnoredElementSelector(e){"string"==typeof e&&this.ignoredElementSelectors.push(e)}addSignificantChangeSelector(e){"string"==typeof e&&this.significantChangeSelectors.push(e)}triggerRecompilation(e="manual"){this.compile()}debounce(e,t){let i;return function(...n){clearTimeout(i),i=setTimeout((()=>{clearTimeout(i),e(...n)}),t)}}async waitForTailwind(){return new Promise((e=>{if(this.isTailwindAvailable())return void e();const t=setInterval((()=>{this.isTailwindAvailable()&&(clearInterval(t),e())}),100);document.addEventListener("DOMContentLoaded",(()=>{this.isTailwindAvailable()&&(clearInterval(t),e())})),setTimeout((()=>{clearInterval(t),e()}),5e3)}))}isTailwindAvailable(){return Array.from(document.styleSheets).some((e=>e.href&&(e.href.includes("tailwind")||e.href.includes("tailwindcss")||e.href.includes("indux"))))||document.querySelector('[class*="tailwind"]')||window.tailwind||document.head.innerHTML.includes("tailwind")||document.head.innerHTML.includes("indux")}}TailwindCompiler.prototype.addCriticalBlockingStylesSync=function(){if(!this.criticalStyleElement)return;const e=performance.now();this.debug&&console.log(`[Indux Utilities] Starting synchronous utility generation at ${(e-this.startTime).toFixed(2)}ms`);try{const e=new Map,t=document.querySelectorAll("style:not(#utility-styles):not(#utility-styles-critical)");this.debug&&console.log(`[Indux Utilities] Found ${t.length} inline style elements`);for(const i of t)if(i.textContent){const t=this.extractThemeVariables(i.textContent);for(const[i,n]of t.entries())e.set(i,n)}this.debug&&e.size>0&&console.log(`[Indux Utilities] Extracted ${e.size} CSS variables from inline styles`);try{if(document.documentElement){const t=document.documentElement.outerHTML,i=/<style[^>]*>([\s\S]*?)<\/style>/gi;let n;for(;null!==(n=i.exec(t));){const t=n[1],i=this.extractThemeVariables(t);for(const[t,n]of i.entries())e.set(t,n)}}}catch(e){}try{const t=Array.from(document.styleSheets);this.debug&&console.log(`[Indux Utilities] Found ${t.length} stylesheets`);for(const i of t)try{const t=Array.from(i.cssRules||[]);for(const i of t){if(i.type===CSSRule.STYLE_RULE&&i.styleSheet)try{const t=Array.from(i.styleSheet.cssRules||[]);for(const i of t)if(i.type===CSSRule.STYLE_RULE){const t=i.cssText,n=this.extractThemeVariables(t);for(const[t,i]of n.entries())e.set(t,i)}}catch(e){}if(i.type===CSSRule.STYLE_RULE){const t=i.cssText,n=this.extractThemeVariables(t);for(const[t,i]of n.entries())e.set(t,i)}}}catch(e){this.debug&&i.href&&console.log(`[Indux Utilities] Cannot access stylesheet (CORS?): ${i.href}`)}this.debug&&e.size>0&&console.log(`[Indux Utilities] Extracted ${e.size} CSS variables from stylesheets`)}catch(e){this.debug&&console.warn("[Indux Utilities] Error reading stylesheets:",e)}try{if(document.documentElement&&"loading"!==document.readyState){const t=getComputedStyle(document.documentElement);let i=0;for(let n=0;n<t.length;n++){const s=t[n];if(s.startsWith("--")){const n=t.getPropertyValue(s);n&&n.trim()&&(e.set(s.substring(2),n.trim()),i++)}}this.debug&&i>0&&console.log(`[Indux Utilities] Extracted ${i} CSS variables from computed styles`)}}catch(e){}const i=new Set;try{if(document.documentElement){const e=document.documentElement.outerHTML,t=/class=["']([^"']+)["']/gi;let n;for(;null!==(n=t.exec(e));){const e=n[1].split(/\s+/).filter(Boolean);for(const t of e)/^(border|bg|text|ring|outline|decoration|caret|accent|fill|stroke)-[a-z0-9-]+(\/[0-9]+)?$/.test(t)&&i.add(t)}}if(document.body){const e=document.body.querySelectorAll("*");for(const t of e)if(t.className&&"string"==typeof t.className){const e=t.className.split(/\s+/).filter(Boolean);for(const t of e)/^(border|bg|text|ring|outline|decoration|caret|accent|fill|stroke)-[a-z0-9-]+(\/[0-9]+)?$/.test(t)&&i.add(t)}}this.debug&&(console.log(`[Indux Utilities] Found ${i.size} utility classes to generate`),i.size>0&&console.log(`[Indux Utilities] Sample classes: ${Array.from(i).slice(0,5).join(", ")}`))}catch(e){this.debug&&console.warn("[Indux Utilities] Error scanning for classes:",e)}if(this.debug&&console.log(`[Indux Utilities] CSS variables found: ${e.size}, Classes found: ${i.size}`),e.size>0){const t=performance.now(),n=`:root { ${Array.from(e.entries()).map((([e,t])=>`--${e}: ${t};`)).join("\n")} }`;let s=null;if(i.size>0)s={classes:Array.from(i),variableSuffixes:[]};else{const e=localStorage.getItem("tailwind-cache");let t=new Set;if(e)try{const i=JSON.parse(e),n=Object.values(i);for(const e of n){const e=n.sort(((e,t)=>(t.timestamp||0)-(e.timestamp||0)))[0];if(e&&e.css){const i=e.css.match(/\.([a-zA-Z0-9_-]+(?::[a-zA-Z0-9_-]+)*)\s*{/g);if(i)for(const e of i){const i=e.replace(/^\./,"").replace(/\s*{.*$/,"");/^(border|bg|text|ring|outline|decoration|caret|accent|fill|stroke)-[a-z0-9-]+(\/[0-9]+)?$/.test(i.split(":").pop())&&t.add(i)}}}}catch(e){}if(t.size>0)s={classes:Array.from(t),variableSuffixes:[]},this.debug&&console.log(`[Indux Utilities] Using ${t.size} classes from cache for synchronous generation`);else{try{const e=(document.documentElement.innerHTML||"").match(/class=["']([^"']+)["']/g);if(e)for(const i of e){const e=i.replace(/class=["']/,"").replace(/["']$/,"").split(/\s+/).filter(Boolean);for(const i of e)/^(border|bg|text|ring|outline|decoration|caret|accent|fill|stroke)-[a-z0-9-]+(\/[0-9]+)?$/.test(i)&&t.add(i)}}catch(e){}t.size>0&&(s={classes:Array.from(t),variableSuffixes:[]},this.debug&&console.log(`[Indux Utilities] Found ${t.size} classes from HTML source text`))}}if(!s||!s.classes||0===s.classes.length){this.debug&&console.log("[Indux Utilities] No classes found in DOM/cache, checking for color variables to generate utilities...");const t=Array.from(e.entries()).filter((([e])=>e.startsWith("color-")));if(this.debug&&console.log(`[Indux Utilities] Found ${t.length} color variables out of ${e.size} total variables`),!(t.length>0))return void(this.debug&&console.log("[Indux Utilities] No color variables found, skipping synchronous generation"));{const e=[];for(const[i]of t){const t=i.replace("color-","");e.push(`text-${t}`),e.push(`bg-${t}`),e.push(`border-${t}`)}s={classes:e,variableSuffixes:[]},this.debug&&console.log(`[Indux Utilities] Generating utilities for all ${t.length} color variables (${e.length} synthetic classes) to prevent flash`)}}const r=this.generateUtilitiesFromVars(n,s);if(r){const e=performance.now();this.criticalStyleElement.textContent=r,document.body?document.body.offsetHeight:document.documentElement.offsetHeight;const i=performance.now();if(this.debug){const n=s.classes.slice(0,5).join(", ");console.log(`[Indux Utilities] Generated ${r.split("{").length-1} utility rules in ${(e-t).toFixed(2)}ms`),console.log(`[Indux Utilities] Applied critical utilities to DOM at ${(i-this.startTime).toFixed(2)}ms`),console.log(`[Indux Utilities] Critical utilities length: ${r.length} chars`),console.log(`[Indux Utilities] Sample classes generated: ${n}${s.classes.length>5?"...":""}`)}}else this.debug&&console.warn(`[Indux Utilities] No utilities generated despite having ${e.size} variables`)}else this.debug&&console.warn("[Indux Utilities] Cannot generate utilities: no CSS variables found")}catch(e){this.debug&&console.error("[Indux Utilities] Error in synchronous generation:",e)}finally{this.debug&&console.log(`[Indux Utilities] Synchronous generation completed in ${(performance.now()-e).toFixed(2)}ms`)}},TailwindCompiler.prototype.generateSynchronousUtilities=function(){try{const e=this.styleElement.textContent&&this.styleElement.textContent.trim();let t=new Map;const i=new Set,n=document.querySelectorAll("style:not(#utility-styles)");for(const e of n)if(e.textContent){const i=this.extractThemeVariables(e.textContent);for(const[e,n]of i.entries())t.set(e,n)}try{const e=document.documentElement.outerHTML,i=/<style[^>]*>([\s\S]*?)<\/style>/gi;let n;for(;null!==(n=i.exec(e));){const e=n[1],i=this.extractThemeVariables(e);for(const[e,n]of i.entries())t.set(e,n)}}catch(e){}try{if("loading"!==document.readyState){const e=getComputedStyle(document.documentElement),i=e.length;for(let n=0;n<i;n++){const i=e[n];if(i.startsWith("--")){const n=e.getPropertyValue(i);n&&n.trim()&&t.set(i.substring(2),n.trim())}}}}catch(e){}try{const e=document.documentElement.outerHTML,t=/class=["']([^"']+)["']/gi;let n;for(;null!==(n=t.exec(e));){const e=n[1].split(/\s+/).filter(Boolean);for(const t of e)/^(border|bg|text|ring|outline|decoration|caret|accent|fill|stroke)-[a-z0-9-]+(\/[0-9]+)?$/.test(t)&&i.add(t)}}catch(e){const t=document.querySelectorAll("*");for(const e of t)if(e.className&&"string"==typeof e.className){const t=e.className.split(/\s+/);for(const e of t)/^(border|bg|text|ring|outline|decoration|caret|accent|fill|stroke)-[a-z0-9-]+(\/[0-9]+)?$/.test(e)&&i.add(e)}}if(t.size>0&&i.size>0){const n=`:root { ${Array.from(t.entries()).map((([e,t])=>`--${e}: ${t};`)).join("\n")} }`,s={classes:Array.from(i),variableSuffixes:[]},r=this.generateUtilitiesFromVars(n,s);if(r){const t=`@layer utilities {\n${r}\n}`;e?this.styleElement.textContent+="\n\n"+t:this.styleElement.textContent=t,this.criticalStyleElement&&r.trim()&&(this.criticalStyleElement.textContent="")}}}catch(e){}},TailwindCompiler.prototype.loadAndApplyCache=function(){const e=performance.now();this.debug&&console.log(`[Indux Utilities] Loading cache at ${(e-this.startTime).toFixed(2)}ms`);try{const e=localStorage.getItem("tailwind-cache");if(e){this.debug&&console.log(`[Indux Utilities] Cache found, size: ${e.length} chars`);const t=JSON.parse(e);this.cache=new Map(Object.entries(t));let i=new Set;try{if(document.documentElement){const e=document.documentElement.outerHTML,t=/class=["']([^"']+)["']/gi;let n;for(;null!==(n=t.exec(e));){n[1].split(/\s+/).filter(Boolean).forEach((e=>{e.startsWith("x-")||e.startsWith("$")||i.add(e)}))}}}catch(e){}let n=null,s=0;if(i.size>0)for(const[e,t]of this.cache.entries()){const r=e.lastIndexOf("-"),o=r>0?e.substring(0,r):e,a=o?o.split(","):[],c=new Set(a);let l=0;for(const e of i)c.has(e)&&l++;const u=l/i.size,d=(Date.now()-t.timestamp)/864e5,h=.7*u+.3*(1-Math.min(d,1));h>s&&(s=h,n=t)}const r=n||Array.from(this.cache.entries()).sort(((e,t)=>t[1].timestamp-e[1].timestamp))[0]?.[1];if(r&&r.css){const e=performance.now();if(this.styleElement.textContent=r.css,this.lastThemeHash=r.themeHash,this.criticalStyleElement&&!this.criticalStyleElement.textContent){let e=r.css;e=e.replace(/@layer\s+utilities\s*\{/g,"").replace(/\}\s*$/,"").trim(),e&&(this.criticalStyleElement.textContent=e,this.debug&&console.log(`[Indux Utilities] Applied cached CSS to critical style element (${e.length} chars) to prevent flash`))}if(this.debug&&(console.log(`[Indux Utilities] Applied cached CSS at ${(e-this.startTime).toFixed(2)}ms`),console.log(`[Indux Utilities] Cached CSS length: ${r.css.length} chars`),console.log(`[Indux Utilities] Cache age: ${((Date.now()-r.timestamp)/1e3).toFixed(2)}s`)),this.debug){const e=r.css.includes("border-")||r.css.includes("@layer utilities");console.log(`[Indux Utilities] Cache loaded - has utilities: ${e}`),console.log("[Indux Utilities] Keeping critical styles until full compilation verifies cache")}}else this.debug&&console.log("[Indux Utilities] No suitable cache entry found")}else this.debug&&console.log("[Indux Utilities] No cache in localStorage")}catch(e){console.warn("[Indux Utilities] Failed to load cached styles:",e)}finally{this.debug&&console.log(`[Indux Utilities] Cache loading completed in ${(performance.now()-e).toFixed(2)}ms`)}},TailwindCompiler.prototype.savePersistentCache=function(){try{const e=JSON.stringify(Object.fromEntries(this.cache));localStorage.setItem("tailwind-cache",e)}catch(e){console.warn("Failed to save cached styles:",e)}},TailwindCompiler.prototype.loadPersistentCache=function(){try{const e=localStorage.getItem("tailwind-cache");if(e){const t=JSON.parse(e);this.cache=new Map(Object.entries(t))}}catch(e){console.warn("Failed to load cached styles:",e)}},TailwindCompiler.prototype.generateThemeHash=function(e){return encodeURIComponent(e).slice(0,8)},TailwindCompiler.prototype.cleanupCache=function(){const e=Date.now(),t=this.options.maxCacheAge,i=[];for(const[n,s]of this.cache.entries())s.timestamp&&e-s.timestamp>t&&i.push(n);for(const e of i)this.cache.delete(e);i.length>0&&this.savePersistentCache()},TailwindCompiler.prototype.discoverCssFiles=function(){try{const e=Array.from(document.styleSheets);for(const t of e)try{t.href&&(t.href.startsWith(window.location.origin)||t.href.includes("@indux")||t.href.includes("jsdelivr")&&t.href.includes("@indux")||t.href.includes("unpkg")&&t.href.includes("@indux"))&&this.cssFiles.add(t.href);const e=Array.from(t.cssRules||[]);for(const t of e)t.type===CSSRule.IMPORT_RULE&&t.href&&(t.href.startsWith(window.location.origin)||t.href.includes("@indux")||t.href.includes("jsdelivr")&&t.href.includes("@indux")||t.href.includes("unpkg")&&t.href.includes("@indux"))&&this.cssFiles.add(t.href)}catch(e){}const t=document.querySelectorAll("style:not(#utility-styles)");for(const e of t)if(e.textContent&&e.textContent.trim()){const i=e.id||`inline-style-${Array.from(t).indexOf(e)}`;this.cssFiles.add("inline:"+i)}}catch(e){console.warn("Error discovering CSS files:",e)}},TailwindCompiler.prototype.scanStaticClasses=async function(){return this.staticScanPromise||(this.staticScanPromise=(async()=>{try{const e=new Set,t=document.documentElement.outerHTML;this.extractClassesFromHTML(t,e);const i=window.InduxComponentsRegistry,n=[];if(i&&i.manifest){const e=[...i.manifest.preloadedComponents||[],...i.manifest.components||[]];n.push(...e)}const s=n.map((async t=>{try{const i=await fetch("/"+t);if(i.ok){const t=await i.text();this.extractClassesFromHTML(t,e)}}catch(e){}}));await Promise.all(s);for(const t of e)this.staticClassCache.add(t);return this.hasScannedStatic=!0,e}catch(e){return console.warn("[TailwindCompiler] Error scanning static classes:",e),this.hasScannedStatic=!0,new Set}})()),this.staticScanPromise},TailwindCompiler.prototype.extractClassesFromHTML=function(e,t){const i=/class=["']([^"']+)["']/g;let n;for(;null!==(n=i.exec(e));){const e=n[1].split(/\s+/).filter(Boolean);for(const i of e)!i||i.startsWith("x-")||i.startsWith("$")||t.add(i)}const s=/x-(?:data|bind:class|class)=["']([^"']+)["']/g;for(;null!==(n=s.exec(e));){const e=n[1].match(/['"`]([^'"`\s]+)['"`]/g);if(e)for(const i of e){const e=i.replace(/['"`]/g,"");!e||e.startsWith("$")||e.includes("(")||t.add(e)}}},TailwindCompiler.prototype.getUsedClasses=function(){try{const e=new Set,t=new Set;for(const t of this.staticClassCache)e.add(t);const i=document.getElementsByTagName("*");for(const t of i){let i=[];"string"==typeof t.className?i=t.className.split(/\s+/).filter(Boolean):t.classList&&(i=Array.from(t.classList));for(const t of i){if(!t)continue;this.ignoredClassPatterns.some((e=>e.test(t)))||(e.add(t),this.staticClassCache.has(t)||this.dynamicClassCache.add(t))}}for(const i of e){const e=i.split(":"),n=e[e.length-1].split("-");if(n.length>1){let e=n.slice(1).join("-"),i=e;if(e.includes("/")){const n=e.split("/");i=n[0];n[1];t.add(i),t.add(e)}else t.add(e);if(n.length>2){const e=n.slice(1).join("-");e.includes("/")?t.add(e.split("/")[0]):t.add(e)}}}return{classes:Array.from(e),variableSuffixes:Array.from(t)}}catch(e){return console.error("Error getting used classes:",e),{classes:[],variableSuffixes:[]}}},TailwindCompiler.prototype.fetchThemeContent=async function(){const e=new Set,t=[];0===this.cssFiles.size&&this.discoverCssFiles();for(const i of this.cssFiles){const n=(async()=>{try{let t="",n=!0;if(i.startsWith("inline:")){const e=i.replace("inline:",""),s=e?document.getElementById(e):document.querySelector("style");s&&(t=s.textContent),n=!1}else{const e=i,s=this.cssContentCache.get(e),r=Date.now();let o;if(o=i.includes("@indux")||i.includes("jsdelivr")||i.includes("unpkg")?this.hasScannedStatic?6e4:3e5:this.hasScannedStatic?5e3:3e4,s&&r-s.timestamp<o&&(t=s.content,n=!1),n){const n=Math.floor(r/1e3),s=`${i}?t=${n}`,o=await fetch(s);if(!o.ok)return void console.warn("Failed to fetch stylesheet:",s);t=await o.text(),this.cssContentCache.set(e,{content:t,timestamp:r})}}t&&e.add(t)}catch(e){console.warn(`Error fetching CSS from ${i}:`,e)}})();t.push(n)}return await Promise.all(t),Array.from(e).join("\n")},TailwindCompiler.prototype.extractThemeVariables=function(e){const t=new Map,i=/--([\w-]+):\s*([^;]+);/g;let n;for(;null!==(n=i.exec(e));){const e=n[1],i=n[2].trim();t.set(e,i)}return t},TailwindCompiler.prototype.extractCustomUtilities=function(e){const t=new Map,i=e=>{if("string"==typeof e)return e.replace(/\[object Object\](;?\s*)/g,"").trim();if(e&&"object"==typeof e&&e.css)return i(e.css);const t=String(e);return"[object Object]"===t?"":t},n=/(?:@layer\s+utilities\s*{[^}]*}|^)(?:[^{}]*?)(?:^|\s)(\.!?[\w-]+)\s*{([^}]+)}/gm;let s;for(;null!==(s=n.exec(e));){const e=s[1].substring(1),n=s[2].trim(),r=e.startsWith("!")?e.slice(1):e;if(this.isTailwindGeneratedClass(r))continue;const o=/\s!important/.test(n);let a=n;e.startsWith("!")?o||(a=n.includes(";")?n.replace(/;/g," !important;"):n+" !important"):o&&(a=n.replace(/\s!important/g,""));const c=i(a);if(t.has(e)){const n=t.get(e),s=i(n);t.set(e,`${s}; ${c}`)}else t.set(e,c)}const r=(e=>{const t=[];let i=0;for(;i<e.length;){const n=e.indexOf(":where(",i);if(-1===n)break;let s=1,r=n+7;for(;r<e.length&&s>0;)"("===e[r]?s++:")"===e[r]&&s--,r++;if(s>0){i=n+1;continue}const o=e.slice(n+7,r-1);for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length||"{"!==e[r]){i=n+1;continue}let a=1,c=r+1;for(r++;r<e.length&&a>0;)"{"===e[r]?a++:"}"===e[r]&&a--,r++;if(a>0){i=n+1;continue}const l=e.slice(c,r-1).trim();t.push({selectorContent:o,cssRules:l,fullMatch:e.slice(n,r)}),i=r}return t})(e);for(const e of r){const n=e.selectorContent,s=e.cssRules,r=/\s!important/.test(s),o=n.match(/\.(!?[\w-]+)/g);if(o)for(const e of o){const o=e.substring(1),a=o.startsWith("!")?o.slice(1):o;if(this.isTailwindGeneratedClass(a))continue;let c=s;o.startsWith("!")?r||(c=s.includes(";")?s.replace(/;/g," !important;"):s+" !important"):r&&(c=s.replace(/\s!important/g,""));const l=o,u={selector:`:where(${n})`,css:i(c),fullBlock:!0};if(t.has(l)){const e=t.get(l);if("string"==typeof e){const n=i(e);t.set(l,[{selector:`.${o}`,css:n},u])}else if(Array.isArray(e)){const t=e.find((e=>e.selector===u.selector));if(t){const e=i(t.css),n=i(u.css);t.css=`${e}; ${n}`}else e.push(u)}else if(e&&e.selector)if(e.selector===u.selector){const n=i(e.css),s=i(u.css);e.css=`${n}; ${s}`,t.set(l,[e])}else t.set(l,[e,u])}else t.set(l,[u])}}try{let n=0;for(;n<e.length;){for(;n<e.length&&/\s/.test(e[n]);)n++;if(n>=e.length)break;if("@"===e[n]){for(;n<e.length&&"\n"!==e[n]&&"}"!==e[n];)n++;continue}let s=n;for(;n<e.length&&"{"!==e[n];)n++;if(n>=e.length)break;const r=e.slice(s,n).trim();n++;let o=1,a=n;for(;n<e.length&&o>0;)"{"===e[n]?o++:"}"===e[n]&&o--,n++;if(o>0)continue;const c=e.slice(a,n-1).trim();if(r.startsWith("@"))continue;const l=r.match(/\.!?[A-Za-z0-9_-]+/g);if(!l)continue;const u=/\s!important/.test(c);for(const e of l){const n=e.substring(1),s=n.startsWith("!")?n.slice(1):n;if(this.isTailwindGeneratedClass(s))continue;const r=n.startsWith("!");let o=c;r?u||(o=c.includes(";")?c.replace(/;/g," !important;"):c+" !important"):u&&(o=c.replace(/\s!important/g,""));const a=i(o);if(t.has(n)){const e=t.get(n);if(Array.isArray(e))t.set(n,[...e,{selector:`.${n}`,css:a,fullBlock:!0}]);else{const s=i(e);t.set(n,[{selector:`.${n}`,css:s},{selector:`.${n}`,css:a,fullBlock:!0}])}}else t.set(n,a)}}}catch(e){}try{const n=[],s=(e,t="",i=!0)=>{let r=0;for(;r<e.length;){for(;r<e.length&&/\s/.test(e[r]);)r++;if(r>=e.length)break;let o=r;for(;r<e.length&&"{"!==e[r];)r++;if(r>=e.length)break;const a=e.slice(o,r).trim();r++;let c=1,l=r;for(;r<e.length&&c>0;)"{"===e[r]?c++:"}"===e[r]&&c--,r++;const u=e.slice(l,r-1),d=t?a.replace(/&/g,t).trim():a.trim();if(i){const e=u.trim();e&&n.push({selector:d,css:e,fullBlock:!0})}s(u,d,!1)}};s(e,"");for(const e of n){let n=e.selector.replace(/\/\*[^]*?\*\//g,"").replace(/\s+/g," ").trim();const s=n.match(/\.!?[A-Za-z0-9_-]+/g);if(!s)continue;const r=/\s!important/.test(e.css);for(const o of s){const s=o.slice(1),a=s.startsWith("!")?s.slice(1):s;if(this.isTailwindGeneratedClass(a))continue;const c=s.startsWith("!");let l=e.css;c?r||(l=e.css.includes(";")?e.css.replace(/;/g," !important;"):e.css+" !important"):r&&(l=e.css.replace(/\s!important/g,""));const u={selector:n,css:i(l),fullBlock:e.fullBlock||!1};if(t.has(s)){const e=t.get(s);if("string"==typeof e){const n=i(e);t.set(s,[{selector:`.${s}`,css:n},u])}else if(Array.isArray(e)){const t=e.find((e=>e.selector===u.selector));if(t){const e=i(t.css),n=i(u.css);t.css=`${e}; ${n}`}else e.push(u)}else if(e&&e.selector)if(e.selector===u.selector){const n=i(e.css),r=i(u.css);e.css=`${n}; ${r}`,t.set(s,[e])}else t.set(s,[e,u])}else t.set(s,[u])}}}catch(e){}return t},TailwindCompiler.prototype.isTailwindGeneratedClass=function(e){return[/^[a-z]+-\d+$/,/^[a-z]+-\[/,/^(text|bg|border|ring|shadow|opacity|scale|rotate|translate|skew|origin|transform|transition|duration|delay|ease|animate|backdrop|blur|brightness|contrast|drop-shadow|grayscale|hue-rotate|invert|saturate|sepia|filter|backdrop-)/,/^(sm|md|lg|xl|2xl):/,/^(hover|focus|active|disabled|group-hover|group-focus|peer-hover|peer-focus):/,/^(dark|light):/,/^!/,/^\[/].some((t=>t.test(e)))},TailwindCompiler.prototype.parseClassName=function(e){if(this.classCache.has(e))return this.classCache.get(e);const t={important:e.startsWith("!"),variants:[],baseClass:e};t.important&&(e=e.slice(1));const i=[];let n="",s=0;for(let t=0;t<e.length;t++){const r=e[t];"["===r?s++:"]"===r&&s--,":"===r&&0===s?(i.push(n),n=""):n+=r}return i.push(n),t.baseClass=i.pop(),t.variants=i.map((e=>{const t=this.variants[e];if(t)return{name:e,selector:t,isArbitrary:!1};if(e.startsWith("[")&&e.endsWith("]")){const t=e.slice(1,-1);if(t.startsWith("&"))return{name:e,selector:t,isArbitrary:!0};if(t.startsWith("data-"))return{name:e,selector:`[${t}] &`,isArbitrary:!0}}const i=e.match(/^data-\[(.+)\]$/);if(i){const t=i[1];return{name:e,selector:`[data-${t.includes("=")?t.replace(/^([^=]+)=(.+)$/,'$1="$2"'):t}] &`,isArbitrary:!1}}const n=e.match(/^(nth|nth-last|nth-of-type|nth-last-of-type)-(\d+)$/);if(n){const t=n[1],i=n[2],s=this.variants[t];if(s)return{name:e,selector:`${s}(${i})`,isArbitrary:!1}}const s=e.match(/^has-\[(.+)\]$/);if(s){const t=s[1],i=this.variants.has;if(i)return{name:e,selector:`${i}(${t})`,isArbitrary:!1}}const r=e.match(/^not-\\\[(.+?)\\\]$/);if(r){const t=r[1],i=this.variants.not;if(i)return{name:e,selector:`${i}([${t}])`,isArbitrary:!1}}return console.warn(`Unknown variant: ${e}`),null})).filter(Boolean),this.classCache.set(e,t),t},TailwindCompiler.prototype.generateUtilitiesFromVars=function(e,t){try{const i=[],n=new Set,s=this.extractThemeVariables(e),{classes:r,variableSuffixes:o}=t;if(0===s.size)return"";const a=e=>e.replace(/[^a-zA-Z0-9-]/g,"\\$&"),c=(e,t)=>{const s=r.filter((t=>{const i=t.split(":"),n=i[i.length-1];return n===e||n.startsWith("!")&&n.slice(1)===e}));if(r.includes(e)){const s=`.${a(e)} { ${t} }`;n.has(s)||(i.push(s),n.add(s))}if(r.includes("!"+e)){const s=t.includes(";")?t.replace(/;/g," !important;"):t+" !important",r=`.${a("!"+e)} { ${s} }`;n.has(r)||(i.push(r),n.add(r))}for(const r of s){if(r===e)continue;const s=this.parseClassName(r),o=s.important,c="string"==typeof t?t:t&&"object"==typeof t&&t.css?t.css:String(t),l=o?c.includes(";")?c.replace(/;/g," !important;"):c+" !important":c;let u,d=`.${a(r)}`,h=!1,m="";for(const e of s.variants)if(e.isArbitrary){let t=e.selector;t.startsWith("&")?(t=t.replace(/_/g," ").replace(/&/g,d),d=t):(t=t.replace(/_/g," "),d={baseClass:d,arbitrarySelector:t})}else if(e.selector.includes("&")){d=e.selector.replace(/&/g,d)}else e.selector.startsWith(":")?d=`${d}${e.selector}`:e.selector.startsWith("@")&&(h=!0,m=e.selector);u="object"==typeof d&&d.arbitrarySelector?`${d.baseClass} {\n    ${d.arbitrarySelector} {\n        ${l}\n    }\n}`:`${d} { ${l} }`;const p=h?`${m} { ${u} }`:u;n.has(p)||(i.push(p),n.add(p))}};for(const[e,t]of s.entries()){if(!e.match(this.regexPatterns.tailwindPrefix))continue;const t=e.split("-").slice(1).join("-"),i=`var(--${e})`,n=e.split("-")[0]+"-",s=this.utilityGenerators[n];if(s){const e=s(t,i);for(const[t,n]of e){r.some((e=>{const i=this.parseClassName(e).baseClass;return i===t||i==="!"+t||i.startsWith("!")&&i.slice(1)===t}))&&c(t,n);const e=r.filter((e=>{const i=this.parseClassName(e).baseClass;if(i.includes("/")){if(i.split("/")[0]===t){const e=i.split("/")[1];return!isNaN(e)&&e>=0&&e<=100}}return!1}));for(const t of e){const e=`color-mix(in oklch, ${i} ${t.split("/")[1]}%, transparent)`;c(t,n.replace(i,e))}}}}return i.join("\n")}catch(e){return console.error("Error generating utilities:",e),""}},TailwindCompiler.prototype.generateCustomUtilities=function(e){try{const t=[],i=new Set,{classes:n}=e,s=e=>"string"!=typeof e?e:e.replace(/\[object Object\](;?\s*)/g,"").trim();if(0===this.customUtilities.size)return"";const r=e=>e.replace(/[^a-zA-Z0-9-]/g,"\\$&"),o=(e,t)=>{if(/&\s*[:\.\[{]/.test(e)||/&\s*\n\s*[:\.\[{]/.test(e)||/\]\s*&/.test(e)||/&\s*$/.test(e.split("\n").find((e=>e.trim().startsWith("&")))||""))return e;let i="",n=0,s=!1,r="",o=!1;for(;n<e.length;){const a=e[n],c=n+1<e.length?e[n+1]:"",l=n>0?e[n-1]:"";if('"'!==a&&"'"!==a||o)if(s)i+=a,n++;else if("/"!==a||"*"!==c)if(o){if("*"===a&&"/"===c){o=!1,i+=a,n++;continue}i+=a,n++}else{if("&"===a){const s=e.slice(n+1,Math.min(n+10,e.length));if(s.match(/^[:\.\[\+\>~,)]/)||s.match(/^\s+[:\.\[\+\>~,{]/)||""===s||"\n"===s[0]||"\n"===l&&(":"===s[0]||"."===s[0]||"["===s[0]||" "===s[0])){i+=t,n++;continue}}i+=a,n++}else o=!0,i+=a,n++;else s?a===r&&"\\"!==l&&(s=!1,r=""):(s=!0,r=a),i+=a,n++}return i},a=(e,s,a)=>{"string"!=typeof s&&(s="object"==typeof s&&s&&s.css?s.css:String(s));const c=n.filter((t=>{const i=t.split(":"),n=i[i.length-1];return n===e||n.startsWith("!")&&n.slice(1)===e}));if(n.includes("!"+e)){const n=/\s!important/.test(s)?s:s.includes(";")?s.replace(/;/g," !important;"):s+" !important";let o;if(a&&a.selector)if(a.selector.includes(":where("))o=`.${r("!"+e)} { ${n} }`;else{const t=`.${r("!"+e)}`;let i=a.selector.replace(new RegExp(`\\.${e}(?=[^a-zA-Z0-9_-]|$)`),t);i===a.selector&&(i=`${a.selector}${t}`),o=`${i} { ${n} }`}else o=`.${r("!"+e)} { ${n} }`;i.has(o)||(t.push(o),i.add(o))}for(const n of c){if(n===e)continue;const c=this.parseClassName(n),l=c.important,u="string"==typeof s?s:s&&"object"==typeof s&&s.css?s.css:String(s),d=l?u.includes(";")?u.replace(/;/g," !important;"):u+" !important":u;let h,m=`.${r(n)}`,p=!1,f="";for(const e of c.variants)if(e.isArbitrary){let t=e.selector;t.startsWith("&")?(t=t.replace(/_/g," ").replace(/&/g,m),m=t):(t=t.replace(/_/g," "),m={baseClass:m,arbitrarySelector:t})}else if(e.selector.includes("&")){m=e.selector.replace(/&/g,m)}else e.selector.startsWith(":")?m=`${m}${e.selector}`:e.selector.startsWith("@")&&(p=!0,f=e.selector);let g,w="string"==typeof d?d:String(d);if(w=w.replace(/\[object Object\](;?\s*)/g,"").trim(),"object"==typeof m&&m.arbitrarySelector)h=`${m.baseClass} {\n    ${m.arbitrarySelector} {\n        ${w}\n    }\n}`;else{const t=a&&void 0!==a.fullBlock?a.fullBlock:w.includes("@starting-style")||w.includes("@media")||w.includes("@supports")||w.includes("{")&&w.includes("}");if(a&&a.selector)if(a.selector.includes(":where("))if(t){h=`${m} {\n${o(w,m)}\n}`}else h=`${m} { ${w} }`;else{const i=new RegExp(`\\.${e}(?=[^a-zA-Z0-9_-]|$)`);let n=a.selector.replace(i,m);if(n===a.selector&&(n=`${a.selector}${m}`),t){h=`${n} {\n${o(w,n)}\n}`}else h=`${n} { ${w} }`}else if(t){h=`${m} {\n${o(w,m)}\n}`}else h=`${m} { ${w} }`}g=p?"string"==typeof h&&h.trim().startsWith("@media")?h:`${f} { ${h} }`:h,i.has(g)||(t.push(g),i.add(g))}};for(const[e,t]of this.customUtilities.entries()){const i=e.startsWith("!")?e.slice(1):e;if(n.some((t=>{const n=this.parseClassName(t).baseClass;return n===e||n===i||n==="!"+i||n.startsWith("!")&&n.slice(1)===i}))){let e=t;if("string"==typeof t)e=s(t);else if(Array.isArray(t));else if(t&&t.css){e=s("string"==typeof t.css?t.css:t.css&&"object"==typeof t.css&&t.css.css?t.css.css:String(t.css))}else e=s(String(t));if("string"==typeof t)a(i,e,null);else if(Array.isArray(t)){for(const e of t)if(e&&e.css&&e.selector){const t=s("string"==typeof e.css?e.css:e.css&&"object"==typeof e.css&&e.css.css?e.css.css:String(e.css));a(i,t,{selector:e.selector,fullBlock:e.fullBlock||!1})}}else if(t&&t.css&&t.selector){const e=s("string"==typeof t.css?t.css:t.css&&"object"==typeof t.css&&t.css.css?t.css.css:String(t.css));a(i,e,{selector:t.selector,fullBlock:t.fullBlock||!1})}}}return t.join("\n")}catch(e){return console.error("Error generating custom utilities:",e),""}},TailwindCompiler.prototype.compile=async function(){const e=performance.now();this.debug&&console.log(`[Indux Utilities] Compile started at ${(e-this.startTime).toFixed(2)}ms`);try{const e=Date.now();if(e-this.lastCompileTime<this.minCompileInterval)return;if(this.lastCompileTime=e,this.isCompiling)return;if(this.isCompiling=!0,!this.hasScannedStatic){await this.scanStaticClasses();const e=await this.fetchThemeContent();if(e){const t=this.extractCustomUtilities(e);for(const[e,i]of t.entries())this.customUtilities.set(e,i);const i=this.extractThemeVariables(e);for(const[e,t]of i.entries())this.currentThemeVars.set(e,t);const n={classes:Array.from(this.staticClassCache),variableSuffixes:[]};for(const e of this.staticClassCache){const t=e.split(":"),i=t[t.length-1].split("-");i.length>1&&n.variableSuffixes.push(i.slice(1).join("-"))}const s=this.generateUtilitiesFromVars(e,n),r=[s,this.generateCustomUtilities(n)].filter(Boolean).join("\n\n");if(r){const t=`@layer utilities {\n${r}\n}`,i=this.criticalStyleElement&&this.criticalStyleElement.textContent?`\n\n/* Critical utilities (non-layer, will be overridden by layer utilities) */\n${this.criticalStyleElement.textContent}`:"";this.styleElement.textContent=t+i,requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.criticalStyleElement&&this.criticalStyleElement.textContent&&(this.debug&&console.log("[Indux Utilities] Clearing critical styles after paint"),this.criticalStyleElement.textContent="")}))})),this.lastClassesHash=n.classes.sort().join(",");const s=this.generateThemeHash(e),o=`${this.lastClassesHash}-${s}`;this.cache.set(o,{css:t,timestamp:Date.now(),themeHash:s}),this.savePersistentCache()}}return this.hasInitialized=!0,void(this.isCompiling=!1)}const t=this.getUsedClasses(),i=Array.from(this.dynamicClassCache).sort().join(",");if(i!==this.lastClassesHash||!this.hasInitialized){const e=await this.fetchThemeContent();if(!e)return void(this.isCompiling=!1);const n=this.extractCustomUtilities(e);for(const[e,t]of n.entries())this.customUtilities.set(e,t);const s=this.extractThemeVariables(e);let r=!1;for(const[e,t]of s.entries()){this.currentThemeVars.get(e)!==t&&(r=!0,this.currentThemeVars.set(e,t))}if(r||i!==this.lastClassesHash){const n=this.generateUtilitiesFromVars(e,t),s=[n,this.generateCustomUtilities(t)].filter(Boolean).join("\n\n");if(s){const t=`@layer utilities {\n${s}\n}`,n=this.criticalStyleElement&&this.criticalStyleElement.textContent?`\n\n/* Critical utilities (non-layer, will be overridden by layer utilities) */\n${this.criticalStyleElement.textContent}`:"";this.styleElement.textContent=t+n,requestAnimationFrame((()=>{requestAnimationFrame((()=>{this.criticalStyleElement&&this.criticalStyleElement.textContent&&(this.debug&&console.log("[Indux Utilities] Clearing critical styles after paint"),this.criticalStyleElement.textContent="")}))})),this.lastClassesHash=i;const r=this.generateThemeHash(e),o=`${this.lastClassesHash}-${r}`;this.cache.set(o,{css:t,timestamp:Date.now(),themeHash:r}),this.savePersistentCache()}}}}catch(e){console.error("[Indux Utilities] Error compiling Tailwind CSS:",e)}finally{this.isCompiling=!1,this.debug&&console.log(`[Indux Utilities] Compile completed in ${(performance.now()-e).toFixed(2)}ms`)}},TailwindCompiler.prototype.setupComponentLoadListener=function(){const e=this.debounce((()=>{this.isCompiling||this.compile()}),this.options.debounceTime);document.addEventListener("indux:component-loaded",(t=>{e()})),document.addEventListener("indux:route-change",(t=>{this.hasScannedStatic&&setTimeout((()=>{const t=this.dynamicClassCache.size,i=this.lastClassesHash;this.getUsedClasses();const n=this.dynamicClassCache.size,s=Array.from(this.dynamicClassCache),r=s.sort().join(",");if(n>t&&r!==i){s.filter((e=>!(e.includes("hljs")||e.startsWith("language-")||e.includes("copy")||e.includes("lines")))).length>0&&e()}}),300)}));new MutationObserver((t=>{let i=!1;for(const e of t){if("attributes"===e.type){const t=e.attributeName;if(this.ignoredAttributes.includes(t))continue;if("class"!==t)continue;const n=e.target;if(n.nodeType===Node.ELEMENT_NODE){const e=Array.from(n.classList||[]).filter((e=>!this.ignoredClassPatterns.some((t=>t.test(e)))&&(!this.staticClassCache.has(e)&&!this.dynamicClassCache.has(e))));if(e.length>0){e.forEach((e=>this.dynamicClassCache.add(e))),i=!0;break}}}else if("childList"===e.type)for(const t of e.addedNodes)if(t.nodeType===Node.ELEMENT_NODE){if(this.ignoredElementSelectors.some((e=>t.tagName?.toLowerCase()===e.toLowerCase()||t.closest(e))))continue;if(this.significantChangeSelectors.some((e=>{try{return t.matches?.(e)||t.querySelector?.(e)}catch(e){return!1}}))){i=!0;break}}if(i)break}i&&e()})).observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]})},TailwindCompiler.prototype.startProcessing=async function(){try{const e=this.compile();this.observer=new MutationObserver((e=>{if(0===e.filter((e=>"attributes"===e.type&&"class"===e.attributeName||"childList"===e.type&&Array.from(e.addedNodes).some((e=>e.nodeType===Node.ELEMENT_NODE)))).length)return;0!==this.getUsedClasses().classes.length&&(this.compileTimeout&&clearTimeout(this.compileTimeout),this.compileTimeout=setTimeout((()=>{this.isCompiling||this.compile()}),this.options.debounceTime))})),this.observer.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),await e,this.hasInitialized=!0}catch(e){console.error("Error starting Tailwind compiler:",e)}};const compiler=new TailwindCompiler;if(window.InduxUtilities=compiler,"loading"===document.readyState?document.addEventListener("DOMContentLoaded",(()=>{compiler.debug&&console.log(`[Indux Utilities] DOMContentLoaded fired at ${(performance.now()-compiler.startTime).toFixed(2)}ms`)})):compiler.debug&&console.log("[Indux Utilities] DOM already loaded when script ran"),"PerformanceObserver"in window)try{const e=new PerformanceObserver((e=>{for(const t of e.getEntries())!compiler.debug||"first-paint"!==t.name&&"first-contentful-paint"!==t.name||console.log(`[Indux Utilities] ${t.name} at ${t.startTime.toFixed(2)}ms`)}));e.observe({entryTypes:["paint"]})}catch(e){}document.addEventListener("DOMContentLoaded",(()=>{compiler.isCompiling||compiler.compile()}));const TAILWIND_V4_FILE="tailwind.v4.1.js",ALPINE_FILE="alpine.v3.14.9.js";return exports.ALPINE_FILE=ALPINE_FILE,exports.TAILWIND_V4_FILE=TAILWIND_V4_FILE,exports}({});
//# sourceMappingURL=/sm/0484f0e8fdb888d210a9b21b2beaf006e47aab9781220bdd9502eddf5af5ae0c.map