PageSourceSearch

https://storyverse.fi/assets/vendor-storyverse-dashboard-CVlIC7DF.js

js storyverse.fi collected 2026-10-06 13:38:26 UTC 1,009,607 bytes, 125 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/dist-D8Mv159s.js","assets/rolldown-runtime-B0Z9INg1.js","assets/vendor-react-BUbDLm_B.js","assets/vendor-storyverse-auto-fields-BFlr9mim.js","assets/vendor-rxjs-C9v0ebUh.js","assets/vendor-storyverse-core-BjXRyxT9.js","assets/vendor-three-C3rQHxFg.js","assets/vendor-ui-utils-DOVy8AX-.js"])))=>i.map(i=>d[i]);
2import{a as e,r as t,t as n}from"./rolldown-runtime-B0Z9INg1.js";import{C as r,D as i,E as a,S as o,T as s,b as c,c as l,f as u,g as d,h as f,l as p,m,n as h,p as g,r as _,s as v,u as y,v as b,w as x,x as S,y as C}from"./vendor-react-BUbDLm_B.js";import{C as w,E as T,d as E,i as D,m as O}from"./vendor-rxjs-C9v0ebUh.js";import{Ct as k,Et as A,H as j,Ot as M,St as N,X as P,_t as F,b as I,d as L,gt as ee,h as te,ht as ne,xt as re}from"./vendor-storyverse-core-BjXRyxT9.js";import{c as R,l as ie,n as ae,r as oe,u as z}from"./vendor-storyverse-space-D0310Q2Z.js";import{a as se,d as ce,i as le,n as ue,o as de,p as fe,r as pe,s as B,t as me,u as V}from"./vendor-tanstack-C7fzTc_4.js";import{_ as he,p as ge,s as _e}from"./vendor-storyverse-common-CuofzQl-.js";import{$n as ve,A as ye,Ar as be,B as xe,Br as H,C as Se,Cr as Ce,Ct as we,D as Te,Dr as Ee,E as De,Er as Oe,Et as ke,F as Ae,Fr as je,G as Me,Gt as Ne,H as Pe,Hr as Fe,I as Ie,Ir as Le,It as Re,J as ze,Jt as Be,K as Ve,Kt as He,L as Ue,Lr as We,Lt as Ge,M as Ke,Mn as qe,Mr as Je,N as Ye,Nr as Xe,Nt as Ze,O as Qe,On as $e,Or as et,Ot as tt,P as nt,Pr as rt,Pt as it,Q as at,Qt as ot,R as st,Rn as ct,Rr as lt,S as ut,St as dt,T as ft,Tr as pt,U as mt,Ur as ht,V as gt,Vr as _t,W as vt,Wt as yt,X as bt,Xt as xt,Y as St,Yt as Ct,Z as wt,Zt as Tt,_r as Et,_t as Dt,a as Ot,at as kt,b as At,br as jt,bt as Mt,c as Nt,ct as Pt,dr as Ft,dt as U,er as It,fn as Lt,fr as Rt,ft as zt,g as Bt,gt as Vt,h as Ht,hn as Ut,ht as W,i as Wt,it as Gt,j as Kt,jr as qt,kn as Jt,kr as Yt,l as Xt,lt as Zt,mn as Qt,mt as $t,n as en,nr as tn,nt as G,o as nn,pt as rn,q as an,qt as on,r as sn,rr as cn,rt as ln,s as un,sr as dn,st as K,t as fn,tt as pn,u as mn,ur as hn,ut as gn,v as _n,vr as vn,vt as yn,w as bn,wr as xn,wt as Sn,x as Cn,xr as wn,xt as q,y as Tn,yr as En,yt as Dn,z as On,zr as kn}from"./vendor-storyverse-auto-fields-BFlr9mim.js";import{$ as An,A as jn,B as Mn,C as Nn,D as Pn,E as Fn,F as In,G as Ln,H as Rn,I as zn,J as Bn,K as Vn,L as Hn,M as Un,N as Wn,O as Gn,P as Kn,Q as qn,R as Jn,S as Yn,T as Xn,U as Zn,V as Qn,W as $n,X as er,Y as tr,_ as nr,at as rr,b as ir,et as ar,f as or,g as sr,h as cr,it as lr,j as ur,k as dr,m as fr,nt as pr,ot as mr,p as hr,q as gr,rt as _r,st as vr,tt as yr,v as br,w as xr,x as Sr,y as Cr,z as wr}from"./vendor-storyverse-event-DLsXZFKA.js";import{$ as Tr,$n as Er,$t as Dr,A as Or,An as kr,At as Ar,B as jr,Bn as Mr,Bt as Nr,C as Pr,Cn as Fr,Ct as Ir,D as Lr,Dn as Rr,Dt as zr,E as Br,En as Vr,Et as Hr,F as Ur,Fn as Wr,Gn as Gr,Gt as Kr,H as qr,Hn as Jr,Ht as Yr,I as Xr,In as Zr,J as Qr,Jn as $r,Jt as ei,K as ti,Kn as ni,Kt as ri,L as J,Ln as ii,M as ai,N as oi,Nt as si,O as ci,On as li,P as ui,Pt as di,Q as fi,Rn as pi,S as mi,Sn as hi,St as gi,T as _i,Un as vi,Ut as yi,Vn as bi,Vt as xi,W as Si,Wn as Ci,X as wi,Xn as Ti,Xt as Ei,Y as Di,Yn as Oi,Yt as ki,Z as Ai,Zn as ji,Zt as Mi,_ as Ni,_n as Pi,_r as Fi,_t as Ii,a as Li,an as Ri,ar as zi,at as Bi,b as Vi,bn as Hi,c as Ui,cn as Wi,cr as Gi,d as Ki,dn as qi,dr as Ji,dt as Yi,en as Xi,er as Zi,et as Qi,f as $i,fr as ea,ft as ta,g as na,gn as ra,gr as ia,h as aa,hn as oa,hr as sa,ht as ca,i as la,in as ua,ir as da,it as fa,j as pa,jn as ma,jt as ha,k as ga,kn as _a,kt as va,l as ya,lr as ba,m as xa,mn as Sa,mr as Ca,mt as wa,nn as Ta,nr as Ea,nt as Da,o as Oa,on as ka,or as Aa,ot as ja,p as Ma,pn as Na,pr as Pa,pt as Fa,q as Ia,r as La,rn as Ra,rr as za,rt as Ba,s as Va,sn as Ha,sr as Ua,st as Wa,tn as Ga,tr as Ka,tt as qa,u as Ja,un as Ya,ur as Xa,ut as Za,v as Qa,vn as $a,vt as eo,w as to,x as no,xn as ro,xt as io,y as ao,yn as oo,z as so,zn as co,zt as lo}from"./vendor-ui-utils-DOVy8AX-.js";import{a as uo,i as fo,n as po,o as mo,r as ho}from"./vendor-storyverse-viewer-BnJsZC1v.js";import{n as go,t as _o}from"./vendor-storyverse-space-editor-CVyaV0zW.js";var Y=e(i(),1),X=a(),vo=Ee.object({name:Ee.string(),nativeName:Ee.string(),isDefault:Ee.boolean().default(!1),region:Ee.string().optional(),languageCode:Ee.string(),fallbackLanguageCode:Ee.string().optional(),aiStyleDescription:Ee.string().optional(),order:Ee.number().default(0)}),yo=`selectedLanguage`;function bo(){try{return localStorage.getItem(yo)}catch{return null}}function xo(e){try{e?localStorage.setItem(yo,e):localStorage.removeItem(yo)}catch{}}function So(){let e=L.getInstance().resources,t=e.getValue(te.LANGUAGE_RESOURCE);if(t)return t;let n=bo();return n&&e.setValue(te.LANGUAGE_RESOURCE,n),n}function Co(e){L.getInstance().resources.setValue(te.LANGUAGE_RESOURCE,e??void 0),xo(e)}function wo(){let[e,t]=(0,Y.useState)(()=>So()??void 0);(0,Y.useEffect)(()=>{let e=L.getInstance().resources.getValue$(te.LANGUAGE_RESOURCE).subscribe(t);return()=>e.unsubscribe()},[]);let n=(0,Y.useCallback)(e=>{Co(e)},[]);return[e??null,n]}var To={"common.error":`Error`,"common.sign.in":`Sign in`,"common.email":`Email`,"common.password":`Password`,"common.forgot.password":`Forgot password?`,"common.sign.up":`Sign up`,"common.home":`Home`,"common.create.event":`Create Event`,"common.create.space":`Create Space`,"common.settings":`Settings`,"common.events":`Events`,"common.account":`Account`,"common.spaces":`Spaces`,"common.members":`Members`,"common.organization":`Organization`,"common.invited.members":`Invited Members`,"common.invite.members":`Invite Members`,"common.hide":`Hide`,"common.profile":`Profile`,"common.theme":`Theme`,"common.light":`Light`,"common.dark":`Dark`,"common.system":`System`,"common.open.menu":`Open menu`,"common.edit.event":`Edit Event`,"common.actions":`Actions`,"common.join.event":`Join Event`,"common.copy.link":`Copy Link`,"common.loading":`Loading...`,"common.next":`Next`,"common.signing.in":`Signing in...`,"common.confirm.password":`Confirm Password`,"common.worlds":`Worlds`,"common.emails":`Emails`,"common.files":`Files`,"common.api.keys":`API Keys`,"common.organizations":`Organizations`,"common.terms.and.conditions":`Terms and Conditions`,"common.based.on.finnish.law.and.gdpr.compliance":`Based on Finnish law and GDPR compliance`,"common.1.service.description":`1. Service Description`,"common.2.personal.data.processing":`2. Personal Data Processing`,"common.personal.data.processing.is.based.on.the.eu":`Personal data processing is based on the EU General Data Protection Regulation (GDPR) and the Finnish Data Protection Act. We process the following personal data:`,"common.email.address":`Email address`,"common.username.display.name":`Username/display name`,"common.usage.statistics.and.analytics":`Usage statistics and analytics`,"common.technical.log.data":`Technical log data`,"common.personal.data.processing.is.based.on.the.following":`Personal data processing is based on the following legal grounds:`,"common.service.provision.and.contract.fulfillment":`Service provision and contract fulfillment`,"common.legitimate.interest.service.development.and.security":`Legitimate interest - service development and security`,"common.consent.where.applicable":`Consent - where applicable`,"common.right.to.erasure":`Right to erasure`,"common.right.to.restrict.processing":`Right to restrict processing`,"common.right.to.data.portability":`Right to data portability`,"common.right.to.object":`Right to object`,"common.5.service.usage":`5. Service Usage`,"common.when.using.the.service.you.commit.to":`When using the service, you commit to:`,"common.using.the.service.only.for.lawful.purposes":`Using the service only for lawful purposes`,"common.respecting.other.users.rights":`Respecting other users' rights`,"common.not.spreading.harmful.content":`Not spreading harmful content`,"common.following.the.service.s.technical.limitations":`Following the service's technical limitations`,"common.6.limitation.of.liability":`6. Limitation of Liability`,"common.7.contact.
2information":`7. Contact Information`,"common.for.questions.regarding.personal.data.contact":`For questions regarding personal data, contact:`,"common.8.changes":`8. Changes`,"common.we.reserve.the.right.to.change.these.terms":`We reserve the right to change these terms. Changes will be notified in the service and via email.`,"common.9.applicable.law":`9. Applicable Law`,"common.these.terms.are.subject.to.finnish.law.any":`These terms are subject to Finnish law. Any disputes will be resolved in the Helsinki District Court.`,"common.10.consent":`10. Consent`,"common.error.2":`Error:`,"common.no.spaces.found":`No spaces found`,"common.name":`Name`,"common.description":`Description`,"common.created.at":`Created At`,"common.updated.at":`Updated At`,"common.edit.space":`Edit Space`,"common.save":`Save`,"common.delete.account":`Delete Account`,"common.cancel":`Cancel`,"common.change.email":`Change Email`,"common.svg.png.jpg.or.gif":`SVG, PNG, JPG or GIF`,"common.change.password":`Change Password`,"common.current.password":`Current Password`,"common.new.password":`New Password`,"common.confirm.new.password":`Confirm New Password`,"common.change.name":`Change Name`,"common.upload.organization.logo":`Upload Organization Logo`,"common.change.organization.name":`Change Organization Name`,"common.organization.name":`Organization Name`,"common.go.to.dashboard":`Go to Dashboard`,"common.invalid.json":`Invalid JSON`,"common.error.loading.worlds":`Error loading worlds`,"common.no.worlds.found":`No worlds found`,"common.edit.world":`Edit World`,"common.create.world":`Create World`,"common.world.name":`World Name`,"common.world.description":`World Description`,"common.world.address.slug":`World Address (Slug)`,"common.world.created.successfully":`World created successfully`,"common.add.participants":`Add Participants`,"common.select.the.spaces.for.your.world":`Select the spaces for your world.`,"common.size":`Size`,"common.status":`Status`,"common.select":`Select`,"common.details":`Details`,"common.or":`or`,"common.content":`Content`,"common.thumbnail":`Thumbnail`,"common.space.updated.successfully":`Space updated successfully`,"common.space.name":`Space Name`,"common.space.description":`Space Description`,"common.save.changes":`Save changes`,"common.saving":`Saving…`,"common.prefix":`Prefix`,"common.delete.api.key":`Delete API Key`,"common.never":`Never`,"common.done":`Done`,"common.delete":`Delete`,"common.create.organization":`Create Organization`,"common.event.type":`Event Type`,"common.select.the.chat.type.for.the.event":`Select the chat type for the event.`,"common.chat.type":`Chat Type`,"common.accept.invitation":`Accept Invitation`,"common.collections":`Collections`,"common.system.keys":`System keys`,"common.locales":`Locales`,"common.key":`Key`,"common.value":`Value`,"common.default":`Default`,"common.create":`Create`,"common.close":`Close`,"common.world.details":`World Details`,"common.back":`Back`,"common.guide":`Guide`,"auth.authencatedroute.yourarenotsignedin":`You are not signed in.`,"auth.authencatedroute.pleasesignin":`Please sign in`,"auth.authencatedroute.redirectingin":`Redirecting in `,"auth.signin.subtitle":`Sign in to your account`,"dashboard.access-denied.title":`Access denied`,"dashboard.access-denied.body":`You don't have permission to view this page.`,"dashboard.access-denied.go-home":`Go to home`,"dashboard.select-organization.title":`Select an organization`,"dashboard.select-organization.body":`Choose an organization to continue to your dashboard.`,"dashboard.no-organization.title":`No organization yet`,"dashboard.no-organization.body":`You don't belong to any organization yet. Ask an administrator to invite you to get started.`,"dashboard.no-organization.contact-admin":`Ask an administrator to invite you to an organization.`,"dashboard.layout.create.deck":`Create Deck`,"dashboard.layout.create.user":`Create User`,"dashboard.layout.list.events":`My Events`,"dashboard.layout.list.decks":`My Decks`,"dashboard.layout.list.spaces":`My Spaces`,"dashboard.layout.decks":`Decks`,"dashboard.layout.settings.billing":`Billing`,"components.create.event.name":`Event Name`,"components.create.event.description":`Event Description`,"components.create.event.startAt":`Start At`,"components.create.event.endAt":`End At`,"components.create.event.event.calendar.startAt":`Event Will Start On`,"components.create.event.event.calendar.endAt":`Event Will End On`,"components.create.event.event.calendar.to":`To`,"components.create.event.event.calendar.selectDate":`Select Date`,"components.table.column.toggle.visibility":`Toggle Columns`,"components.table.column.toggle.visibility.view":`View`,"components.table.data.table.column.header.asc":`Asc`,"components.table.data.table.column.header.desc":`Desc`,"components.table.data.table.pagination.rows.selected":`row(s) selected`,"components.table.data.table.pagination.rows.per.page":`Rows per page`,"components.table.data.table.pagination.page":`Page`,"components.table.data.table.pagination.of":`of`,"components.table.data.table.pagination.go.to.first.page":`Go to first page`,"components.table.data.table.pagination.go.to.previous.page":`Go to previous page`,"components.table.data.table.pagination.go.to.next.page":`Go to next page`,"components.table.data.table.pagination.go.to.last.page":`Go to last page`,"components.table.data.table.no.results":`No results`,"components.table.data.table.search.placeholder":`Search all columns...`,"components.table.data.table.search.placeholder.fields":`Search in {{fields}} columns...`,"components.table.data.table.search.fields.label":`Search in`,"components.table.data.table.search.fields.all":`Search in field(s)`,"components.table.data.table.search.fields.count":`{{count}} fields`,"components.table.data.table.search.fields.filter":`Find a field...`,"components.table.data.table.search.fields.empty":`No fields foun
2d`,"components.table.data.table.search.fields.reset":`Reset`,"components.top.bar.user.my.account":`My Account`,"components.top.bar.user.sign.out":`Sign out`,"routes.events.columns.delete.event":`Delete Event`,"routes.events.columns.view.event.description":`Create a link to join the event`,"routes.events.columns.view.event.copied":`Copied to clipboard`,"routes.events.create.event":`New Event`,"routes.events.error":`Error loading events`,"routes.events.no.events.found":`No events found`,"routes.home.events.created":`Events Created`,"routes.home.events.created.description":`Latest created events`,"routes.home.events.created.helper":`Trending up this month`,"routes.home.spaces.created":`Spaces Created`,"routes.home.spaces.created.description":`Active spaces for events`,"routes.home.spaces.created.helper":`Engagement exceeds targets`,"routes.home.users.created":`Users Created`,"routes.home.users.created.description":`Registered user accounts`,"routes.home.users.created.helper":`Acquisition needs attention`,"routes.home.growth.rate.description":`Steady performance increase`,"routes.home.growth.rate.helper":`Meets growth projections`,"routes.home.upcoming.events":`Upcoming Events`,"routes.home.day":`Day`,"routes.home.week":`Week`,"routes.home.month":`Month`,"routes.home.year":`Year`,"routes.home.previous":`Previous`,"routes.home.today":`Today`,"routes.signin.error":`Invalid credentials`,"routes.signin.authheader.title":`Hello again`,"routes.signin.autheader.subtitle":`Sign in to your Storyverse account`,"routes.signin.email.input.placeholder":`[email protected]`,"routes.signin.signup.text":`Don't have an account?`,"routes.signup.password.error":`Password must contain at least 8 characters, one uppercase letter, one lowercase letter and one number`,"routes.signup.password.error.match":`Passwords do not match`,"routes.signup.signin.with.apple":`Apple`,"routes.signup.signin.with.google":`Sign in with Google`,"routes.signup.signin.with.meta":`Sign in with Meta`,"routes.signup.continue.with":`Or continue with`,"routes.signup.authheader.title":`Sign Up To Storyverse`,"routes.signup.autheader.subtitle":`Sign up to Storyverse to get started`,"routes.signup.signup.text":`Already have an account?`,"routes.signup.password.must.contain":`Password must contain`,"routes.signup.password.must.contain.at.least.8.characters":`At least 8 characters`,"routes.signup.password.must.contain.one.uppercase.letter":`One uppercase letter`,"routes.signup.password.must.contain.one.lowercase.letter":`One lowercase letter`,"routes.signup.password.must.contain.one.number":`One number`,"routes.signup.password.for.confirmation":`Password for confirmation`,"routes.signup.error":`Sign up failed`,"components.terms.by.clicking.continue":`By clicking continue, you agree to our`,"components.terms.terms.of.service":`Terms of Service`,"components.terms.privacy.policy":`Privacy Policy`,"components.terms.by.clicking.join":`By clicking Join, you agree to our Terms and acknowledge our Privacy Policy on data collection and processing.`,"components.terms.and.conditions.title":`Terms of Service and Privacy Policy`,"components.terms.and.conditions.1.description":`Storyverse is a virtual event and meeting platform that provides 3D environments for its users. The service is provided by Movya Oy (Business ID: 2271073-2), address: Kympinkatu 7 40320 Jyväskylä, Finland.`,"components.terms.and.conditions.3.title":`3. Data Storage`,"components.terms.and.conditions.3.description":`Data is stored in the European Union (EU) and the United States (US).`,"components.terms.and.conditions.4.title":`4. Legal Basis for Processing`,"components.terms.and.conditions.6.description":`Movya Oy is not liable for indirect damages or losses. The service is provided "as is" without warranties.`,"components.terms.and.conditions.7.list.1":`Movya Oy`,"components.terms.and.conditions.7.list.2":`Email: [email protected]`,"components.terms.and.conditions.7.list.3":`Phone: +358 40 744 2595`,"components.terms.and.conditions.10.description":`By using the service, you consent to the processing of your personal data as described 
2in this privacy policy.`,"routes.spaces.error":`Error loading spaces`,"routes.spaces.columns.template":`Template`,"routes.spaces.columns.delete.space":`Delete Space`,"routes.spaces.columns.delete.template.description":`This space is a template. Deleting it cannot be undone and can affect spaces created from it.`,"routes.spaces.columns.view.space":`View Space`,"components.account.avatar.title":`Upload New Avatar`,"components.account.title":`Your Account`,"components.account.subtitle":`Manage your profile, security settings, and account preferences`,"components.account.section.profile.description":`Manage your personal information and how others see you`,"components.account.section.security":`Security`,"components.account.section.security.description":`Manage your password, linked accounts, and active sessions`,"components.account.section.danger":`Danger Zone`,"components.account.section.danger.description":`Irreversible actions that affect your account`,"components.account.delete.account.description":`Permanently remove your account and all contents. We will email you a confirmation link to complete deletion. This action is not reversible.`,"components.account.delete.account.alert.title":`Request account deletion`,"components.account.delete.account.alert.description":`We will send a confirmation link to your email. Your account will only be deleted after you click that link. This action is not reversible.`,"components.account.delete.account.alert.delete":`Send confirmation email`,"components.account.delete.account.alert.placeholder":`Enter 'delete' to confirm`,"components.account.delete.account.alert.verification.label":`Type 'delete' to confirm`,"components.account.delete.account.alert.success":`Confirmation email sent. Click the link in your inbox to finish deleting your account.`,"components.account.delete.account.alert.error":`Failed to send confirmation email. Please try again.`,"components.account.email.change.placeholder":`[email protected]`,"components.account.file.upload.description.1":`Click to upload`,"components.account.file.upload.description.2":`or drag and drop`,"components.account.sessions.title":`Sessions`,"components.account.sessions.current.session":`Current Session`,"components.account.sessions.sign.out":`Sign Out`,"components.account.providers.title":`Providers`,"components.account.providers.link":`Link`,"components.account.sessions.ip.address":`IP Address`,"components.account.sessions.browser":`Browser`,"components.account.sessions.os":`OS`,"components.account.sessions.device":`Device`,"components.account.sessions.revoke":`Revoke`,"components.account.sessions.success":`Success`,"components.account.sessions.revoke.success":`Session revoked successfully`,"components.account.sessions.revoke.error":`Error revoking session`,"routes.signup.success":`You have Signed up successfully`,"routes.settings.members.error":`Error loading members`,"routes.settings.members.no.members.found":`No members found`,"routes.settings.members.columns.edit.member":`Edit Member`,"routes.settings.members.columns.delete.member":`Delete Member`,"routes.settings.organization.subtitle":`Manage your organization profile, branding, and settings.`,"routes.settings.organization.logo.label":`Organization Logo`,"routes.settings.members.member.title":`User Details`,"routes.settings.members.member.access_denied":`You don't have permission to manage users.`,"components.space.top.bar.command.import":`Import Space`,"components.space.top.bar.command.import.description":`from a JSON file`,"components.space.top.bar.command.import.title":`Import Space From JSON File`,"components.space.top.bar.command.export":`Export Space`,"components.space.top.bar.name.edit":`Edit Space Details`,"components.space.top.bar.command.import.json.description":`Import JSON`,"components.space.top.bar.command.import.json.placeholder":`from a Your File`,"components.space.top.bar.command.import.json.label":`JSON`,"components.space.top.bar.command.import.name.placeholder":`Optional name`,"dashboard.space-import.success":`Space imported`,"dashboard.space-import.failed":`Failed to import space`,"dashboard.space-import.completed-with-errors":`Import completed with errors`,"dashboard.space-import.failure-summary":`Failed: {failed}.`,"dashboard.space-import.summary":`Created: {created}. Updated: {updated}.`,"dashboard.space-import.invalid":`The import definition is invali
2d.`,"dashboard.space-import.missing-key":`Every imported object must have a key. Exports without keys are not supported.`,"dashboard.space-import.duplicate-key":`The same key identifies multiple objects.`,"dashboard.space-import.type-conflict":`An existing object with this key has a different type.`,"dashboard.space-import.cyclic-extends":`Imported inheritance contains a cycle.`,"dashboard.space-import.space-unavailable":`The target space could not be loaded.`,"dashboard.space-import.missing-references":`Some reference targets could not be found`,"dashboard.space-import.references-kept":`These references were kept unchanged. Import the missing objects later or edit the references.`,"routes.worlds.columns.slug":`Slug`,"routes.worlds.columns.delete.world":`Delete World`,"routes.worlds.columns.view.world":`View World`,"components.create.event.add.initial.space.button":`Add Initial Space`,"components.create.event.add.lobby.space.button":`Add Lobby Space`,"routes.participants.columns.delete.participant":`Delete Participant`,"components.create.event.add.participants.import.csv":`Import Participants from CSV`,"components.create.event.add.participants.import.csv.description":`Upload a CSV file that has emails in the first column`,"components.form.world.form.create.description":`Create a new world for your events and experiences.`,"components.form.world.form.slug.tooltip":`Only A-Z and numbers are allowed no spaces or special characters.`,"components.form.world.form.edit.success":`World updated successfully`,"components.form.event.create.success":`Event created successfully`,"components.form.event.edit.success":`Event updated successfully`,"routes.upload.file.title":`Upload Files`,"routes.files.error":`Error loading files`,"routes.files.no.files.found":`No files found`,"routes.files.upload.file":`Upload File`,"routes.files.columns.filename":`Filename`,"routes.files.columns.visibility":`Visibility`,"routes.files.columns.mimetype":`Mimetype`,"routes.files.columns.view.file":`View File`,"routes.files.columns.edit.file":`Edit File`,"routes.files.columns.delete.file":`Delete File`,"components.form.file.upload.description":`files you want to upload.`,"components.create.event.initialSpaceLabel":`Select Initial Space`,"components.create.event.initialSpacePlaceholder":`Select an initial space`,"components.create.event.initialSpace.description":`The initial space will be the space that the participants will be in when they join the event.`,"components.create.event.lobby-space.label":`Select Lobby Space`,"components.create.event.lobby-space.placeholder":`Select a lobby space`,"components.create.event.lobby-space.description":`The lobby space is the space that will be used as the lobby for the event. It is the space that will be used to welcome the participants and to give them the instructions for the event.`,"components.form.event.select.world.select.placeholder":`Select a world`,"components.form.event.select.world.description":`Select the world that will be used for the event.`,"components.form.event.select.world.label":`Select World`,"components.create.event.event.auth.type.description":`Select the authencation type for the event.`,"components.create.event.event.auth.type.label":`Authencation Type for the Event`,"components.create.event.add.participants.list.invitedAt":`Invited At`,"components.create.event.add.participants.list.respondedAt":`Responded At`,"components.create.event.participant.transform.limit":`Participant Transform Limit`,"routes.spaces.columns.is.default":`Default Space`,"components.form.api-key.add.button":`Add Api Key`,"components.form.members.role.label":`Role`,"components.form.members.add.button":`Add Member`,"components.form.members.add.description":`Invite members to your organization`,"components.form.members.email.placeholder":`[email protected]`,"components.form.members.emails.min":`Add at least one invitation to the list.`,"components.form.members.addtolist":`Add`,"components.form.members.queue.label":`Invitations`,"components.form.members.queue.empty":`No invitations yet. Fill in email and role above.`,"components.form.members.duplicate":`That address is already in the list.`,"components.form.members.invalid.email":`Enter a valid email address.`,"components.form.members.remove":`Remove invitation`,"components.form.members.add.submit":`Send invitations`,"components.form.members.role.placeholder":`Select a role`,"components.form.members.role.member":`Member`,"components.form.members.role.admin":`Admin`,"components.form.members.role.owner":`Owner`,"components.form.members.role.user":`User`,"components.form.members.role.event_user":`Event User`,"components.form.members.role.content_user":`Content User`,"components.form.members.role.insta_user":`Insta User`,"components.form.members.role.info.button":`About roles`,"components.form.members.role.info.title":`What each role can do`,"components.form.members.role.info.description":`Pick the role that best matches what this person needs to do day-to-day. You can change it later.`,"components.form.members.role.desc.owner":`Runs the organization. Can manage people, set permissions, and create or change anything: events, worlds, spaces, content, files, emails, and translations.`,"components.form.members.role.desc.admin":`System administrator. Has every permission across the organization, including system-level settings on top of everything an Owner can do.`,"components.form.members.role.desc.user":`A full team member. Can create and change events, worlds, spaces, content, files, emails, and translations, and can invite or manage teammates.`,"components.form.members.role.desc.event_user":`Focused on events. Full control over events. Can view worlds, spaces, and content to use inside events, but can't add or change them.`,"components.form.members.role.desc.content_user":`Focused on content. Can create and edit CMS entries and translations only — no access to events, worlds, spaces, or teammates.`,"components.form.members.role.desc.insta_user":`Insta user`,"components.form.members.role.desc.member":`View-only. Can see the events list and event details, but can't join, create, or change anything.`,"components.form.members.email.description":`Enter an email and role, then use Add to list for each person.`,"components.form.members.role.description":`Role applies to the invitation you add next.`,"components.form.members.add.error":`Member has been already invited or is already a member of the organization`,"components.form.members.add.success":`Member invited successfully`,"components.form.members.add.success_plural"
2:`Successfully invited {{count}} members`,"components.form.members.add.partial":`Could not invite: `,"components.form.api-key.permissions.label":`Api Key Permissions`,"components.table.row.delete.confirm.label":`Type {{text}} to confirm`,"routes.emails.error":`Error loading emails`,"routes.emails.no.emails.found":`No emails found`,"routes.emails.columns.to":`To`,"routes.emails.columns.sent.at":`Sent At`,"routes.emails.columns.delete.email":`Delete Email`,"routes.emails.update.success":`Email updated successfully`,"routes.emails.update.error":`Error updating email`,"routes.emails.missing.id":`Email ID is missing`,"routes.emails.not.found":`Email not found`,"routes.emails.edit.title":`Edit email: {subject}`,"routes.emails.edit.details":`Email details`,"routes.emails.edit.metadata":`Metadata`,"components.space.form.create.success":`Space created successfully`,"views.content-manager.columns.slug":`Slug`,"routes.api-keys.error":`Error loading API keys`,"routes.api-keys.no.api-keys.found":`No API keys found`,"routes.api-keys.columns.enabled":`Enabled`,"routes.api-keys.columns.request-count":`Requests`,"routes.api-keys.columns.remaining":`Remaining`,"routes.api-keys.columns.expires-at":`Expires At`,"routes.api-keys.columns.last-request":`Last Request`,"routes.api-keys.columns.enabled.true":`Active`,"routes.api-keys.columns.enabled.false":`Disabled`,"routes.api-keys.columns.no-expiry":`No expiry`,"components.form.api-key.add.title":`Add API Key`,"components.form.api-key.add.description":`Add a new API key to your organization`,"components.form.api-key.prefix.placeholder":`Optional prefix (e.g., sk_live)`,"components.form.api-key.expires-in":`Expires In`,"components.form.api-key.expires-in.placeholder":`Select expiration`,"components.form.api-key.expires-in.7-days":`7 days`,"components.form.api-key.expires-in.30-days":`3
20 days`,"components.form.api-key.expires-in.90-days":`90 days`,"components.form.api-key.expires-in.1-year":`1 year`,"components.form.api-key.rate-limit":`Rate Limit`,"components.form.api-key.rate-limit.enabled":`Enable rate limiting`,"components.form.api-key.rate-limit.max":`Max requests`,"components.form.api-key.rate-limit.window":`Time window`,"components.form.api-key.rate-limit.window.unit":`Time unit`,"components.form.api-key.rate-limit.window.unit.seconds":`Seconds`,"components.form.api-key.rate-limit.window.unit.minutes":`Minutes`,"components.form.api-key.rate-limit.window.unit.hours":`Hours`,"components.form.api-key.rate-limit.window.unit.days":`Days`,"components.form.api-key.info.toggle":`What does this do?`,"components.form.api-key.suggestions":`Suggestions`,"components.form.api-key.rate-limit.window.suggestion.1-minute":`1 minute`,"components.form.api-key.rate-limit.window.suggestion.15-minutes":`15 minutes`,"components.form.api-key.rate-limit.window.suggestion.1-hour":`1 hour`,"components.form.api-key.rate-limit.window.suggestion.1-day":`1 day`,"components.form.api-key.rate-limit.info":`Limits how many requests this key can make within a time window. Requests over the limit are rejected until the window resets.`,"components.form.api-key.rate-limit.max.info":`The maximum number of requests allowed within one time window. If left empty, the server default is used.`,"components.form.api-key.rate-limit.window.info":`How long one time window lasts. When the window ends, the request count resets.`,"components.form.api-key.refill":`Refill Settings`,"components.form.api-key.refill.amount":`Refill amount`,"components.form.api-key.refill.interval":`Refill interval (ms)`,"components.form.api-key.remaining":`Remaining requests`,"components.form.api-key.created.title":`API Key Created`,"components.form.api-key.created.description":`Make sure to copy your API key now. You won't be able to see it again!`,"components.form.api-key.created.copy":`Copy to clipboard`,"components.form.api-key.created.copied":`Copied!`,"components.form.api-key.name.placeholder":`My API Key`,"components.form.api-key.permissions.description":`Choose what this key can do. A key without permissions cannot access anything.`,"components.form.api-key.create.error":`Failed to create API key`,"components.form.api-key.add.creating":`Creating API key…`,"components.form.api-key.resource.translate-ui":`UI translations`,"components.form.api-key.resource.translate-entry":`Content translations`,"components.form.api-key.resource.translate-label":`Label translations`,"components.form.api-key.resource.translate-system":`System translations`,"components.form.api-key.action.list":`List`,"components.form.api-key.action.get":`Read`,"components.form.api-key.action.update":`Update`,"components.form.api-key.action.join":`Join`,"components.form.api-key.delete.description":`Are you sure you want to delete this API key? This action cannot be undone.`,"routes.organizations.error":`Error loading organizations`,"routes.organizations.no.organizations.found":`No organizations found`,"routes.organizations.columns.logo":`Logo`,"routes.organizations.columns.view.organization":`View Organization`,"routes.organizations.columns.edit.organization":`Edit Organization`,"routes.organizations.columns.delete.organization":`Delete Organization`,"components.create.event.event.type.description":`Select the type of the event.`,"components.space.form.create.description":`Create a new space`,"components.space.form.edit.description":`Update space details`,"routes.events.columns.join.in.new.window":`Join Event in New Window`,"components.form.world.form.create.error":`Error creating world`,"components.space.form.update.error":`Error updating space`,"components.space.form.duplicate.success":`Space duplicated successfully`,"components.space.form.duplicate.error":`Error duplicating space`,"routes.files.columns.copy.url":`Copy URL`,"components.form.event.form.slug":`Event Address (Slug)`,"components.form.event.form.slug.tooltip":`Only A-Z and numbers are allowed no spaces or special characters.`,"routes.accept-invitation.autheader.subtitle":`Set up your account to join the organization`,"routes.accept-invitation.first.name":`First Name`,"routes.accept-invitation.missing":`Invitation not found or has expired`,"routes.accept-invitation.success":`Invitation accepted successfully`,"routes.accept-invitation.error":`Failed to accept invitation`,"routes.accept-invitation.password.must.contain.one.special.character":`One special character`,"routes.accept-invitation.invited.title":`You've been invited`,"routes.accept-invitation.invited.subtitle":`Accept the invitation to join`,"routes.accept-invitation.login.title":`Almost there`,"routes.accept-invitation.login.subtitle":`Please log in to join`,"routes.accept-invitation.login.button":`Log in to continue`,"routes.accept-invitation.wrong-account.title":`Wrong account`,"routes.accept-invitation.wrong-account.subtitle":`This invitation was sent to a different email. Log in with the correct account to continue.`,"routes.accept-invitation.wrong-account.button":`Log in with a different account`,"routes.settings.members.columns.cancel.invitation":`Cancel Invitation`,"views.cms.mode.labels":`Labels`,"views.cms.mode.localization":`Localization`,"views.cms.top-bar.back-to-dashboard":`Back to dashboard`,"views.cms.top-bar.open-navigation":`Open content navigation`,"views.cms.delete.entry.title":`Delete this entry?`,"views.cms.delete.entry.description":`This permanently deletes "{{name}}". This cannot be undone.`,"views.cms.delete.entries.title":`Delete {{count}} entries?`,"views.cms.delete.entries.description":`This permanently deletes the {{count}} selected entries. This cannot be undone.`,"views.cms.delete.field.title":`Delete this field?`,"views.cms.delete.field.description":`The field "{{name}}" is removed from this collection when you save your changes.`,"views.cms.delete.locale.title":`Delete this locale?`,"views.cms.delete.locale.de
2scription":`This removes "{{name}}" and permanently deletes its content translations in this organization. This cannot be undone.`,"views.cms.navigation.labels":`Label collections`,"views.cms.navigation.labels.description":`Choose a label collection to manage.`,"views.cms.navigation.default.description":`Choose what to manage in the content manager.`,"views.system-keys.loading":`Loading system keys...`,"views.system-keys.error":`Unable to load system keys.`,"views.system-keys.empty":`No system translations exist yet.`,"views.system-keys.description":`Platform-wide translation strings, shared by every organization. Published worlds pick up edits on their next publish.`,"views.system-keys.admin-only":`Only administrators can make changes.`,"views.system-keys.english":`English`,"views.system-keys.not-translated":`Not translated`,"views.system-keys.add-key":`Add New System Key`,"views.system-keys.create.title":`Add new system key`,"views.system-keys.create.description":`Create the key and its initial values for every system language.`,"views.system-keys.create.key.placeholder":`components.example.title`,"views.system-keys.create.error":`Unable to create system key`,"views.system-keys.create.success":`System key created`,"views.system-keys.delete.label":`Delete system key`,"views.system-keys.delete.title":`Delete system key?`,"views.system-keys.delete.description":`This permanently deletes every translation for this system key.`,"views.system-keys.delete.error":`Unable to delete system key`,"views.system-keys.delete.success":`System key deleted`,"views.system-keys.update.error":`Unable to update system translation`,"views.system-keys.editor.title":`Edit system key`,"views.system-keys.editor.context":`Context`,"views.system-keys.editor.translations":`Translations`,"views.system-keys.editor.value":`translation value`,"features.language-selector.content-language":`Content language`,"features.language-selector.select-language":`Select language`,"auth.organization-selector.aria-label":`Select organization`,"auth.organization-selector.search":`Search organization...`,"auth.organization-selector.no-organization":`No organization found.`,"auth.organization-selector.settings":`Organization Settings`,"auth.organization-selector.dialog.title":`Create organization`,"auth.organization-selector.dialog.description":`Add a new organization to your account.`,"auth.organization-selector.dialog.name.label":`Organization name`,"auth.organization-selector.dialog.name.placeholder":`Acme Inc.`,"auth.organization-selector.dialog.slug.label":`Organization slug`,"auth.organization-selector.dialog.slug.placeholder":`acme`,"auth.organization-selector.create.error":`Failed to create organization`,"auth.organization-selector.create.error.retry":`Please try again`,"auth.organization-selector.create.warning":`Organization created without a default language`,"auth.organization-selector.create.warning.description":`Add one from the organization settings.`,"auth.organization-selector.create.success":`Organization created successfully`,"dashboard.layout.group.manage":`Manage`,"views.world-view.error.title":`World Not Available`,"views.world-view.error.description":`Could not load published world data. Try again later.`,"views.world-view.not-found.title":`World Not Found`,"views.world-view.select-space":`Select Space`,"views.space-view.loading":`Loading space…`,"features.content-viewer.default-label":`Content details`,"views.locale-settings.title":`Locale Settings`,"views.locale-settings.description":`Select and configure languages for your application`,"views.locale-settings.languages":`Languages`,"views.locale-settings.no-languages":`No languages added yet. Click + to add one.`,"views.locale-settings.add-language":`Add Language`,"views.locale-settings.add-language.description":`Select a language to add to your application`,"views.locale-settings.search":`Search languages...`,"views.locale-settings.no-results":`No languages found matching your search`,"views.locale-settings.all-added":`All languages have been added`,"views.locale-settings.edit-language":`Edit Language`,"views.locale-settings.edit-language.description":`Configure language settings and behavior`,"views.locale-settings.language-code":`L
2anguage Code`,"views.locale-settings.language-code.placeholder":`en or en-GB`,"views.locale-settings.language-code.hint":`Format: language code (lowercase) or language-REGION (e.g., en, en-GB, fr-FR)`,"views.locale-settings.region":`Region (Optional)`,"views.locale-settings.region.placeholder":`US, GB, etc.`,"views.locale-settings.display-name":`Display Name`,"views.locale-settings.native-name":`Native Name`,"views.locale-settings.fallback":`Fallback Language (Optional)`,"views.locale-settings.is-default-suffix":` (Default)`,"views.locale-settings.ai-style":`AI Translation Style (Optional)`,"views.locale-settings.ai-style.placeholder":`Translate content with a cheerful tone, intended for an audience of designers...`,"views.locale-settings.set-as-default":`Set as Default Language`,"views.locale-settings.set-as-default.description":`This language will be used as the primary language`,"views.localization.collection.no-items":`No items yet`,"views.localization.collection.no-entries":`No entries in this collection`,"views.localization.collection.empty-badge":`Empty`,"views.localization.labels.no-labels":`No labels in this collection`,"views.localization.labels.no-source-value":`No source value`,"views.data-transfer.choose-files":`Choose export files`,"views.data-transfer.accepted-files":`Choose a ZIP archive or one or more JSON export files`,"views.data-transfer.import-everything.description":`Restore collections, entries, labels and every translation from a Storyverse export. Select a ZIP archive or one or more JSON files. Existing records are matched by slug and updated rather than duplicated.`,"views.data-transfer.reading":`Reading…`,"views.data-transfer.reading-data":`Reading current data…`,"views.data-transfer.download-report":`Download report`,"views.data-transfer.importing":`Importing…`,"views.data-transfer.report-downloaded":`Report downloaded`,"views.world-edit.publish.status.published":`Published`,"views.world-edit.publish.status.draft":`Draft`,"views.world-edit.publish.not-accessible":`This world is not publicly accessible yet.`,"views.world-edit.publish.unpublish":`Unpublish`,"views.world-edit.publish.update":`Publish update`,"views.world-edit.publish.publish":`Publish`,"views.world-edit.publish.snapshot-history":`Snapshot history`,"views.world-edit.publish.show":`Show`,"views.world-edit.publish.live":`Live`,"views.world-properties.tab.details.description":`Edit the name, description, and address of this world.`,"views.world-properties.tab.thumbnail":`Thumbnail`,"views.world-properties.tab.thumbnail.description":`Choose how this world appears in lists and previews.`,"views.world-properties.tab.collections.description":`Select the collections and label collections used by this world.`,"views.world-properties.section.title":`World settings`,"views.world-properties.thumbnail.alt":`World Thumbnail`,"views.world-properties.thumbnail.select":`Select Thumbnail`,"views.world-properties.thumbnail.select-hub":`Select World Thumbnail`,"views.world-properties.save-changes":`Save Changes`,"components.space.details.section.title":`Space settings`,"components.space.details.name.required":`Name is required`,"components.space.details.tab.details.description":`Edit the name, description, and behavior of this space.`,"components.space.details.tab.thumbnail.description":`Choose how this space appears in lists and previews.`,"components.space.details.tab.collections.description":`Select the collections and label collections used by this space.`,"components.space.details.template.label":`Template`,"components.space.details.template.description":`Mark this space as a reusable template`,"components.space.details.thumbnail.select":`Select or Upload Thumbnail`,"components.space.details.thumbnail.select-hub":`Select Space Thumbnail`,"components.space.details.thumbnail.alt":`Space Thumbnail`,"components.space.details.thumbnail.remove":`Remove thumbnail`,"components.space.details.thumbnail.capture":`Capture Space`,"components.space.details.thumbnail.uploading":`Uploading…`,"components.space.details.thumbnail.capturing":`Capturing…`,"views.field-schema.update.success":`Fields updated successfully`,"views.field-schema.update.error":`Failed to update fields`,"views.field-schema.duplicate-variable":`Variable name must be unique`,"features.content-selection.dialog.create-new.tab":`Create new`,"features.content-selection.dialog.select-collection":`Select a collection`,"features.content-selection.dialog.no-description":`No description`,"features.content-selection.dialog.search-spaces":`Search spaces`,"features.content-selection.dialog.selected":`Selected`,"features.label-selection.dialog.title":`Select text`,"features.label-selection.dialog.description":`Choose a label from a collection linked to this space.`,"features.label-selection.dialog.no-space":`No space is selected. Open a space before selecting text.`,"features.label-selection.dialog.no-collections":`This space has no linked label collections.`,"features.label-selection.dialog.collection":`Label collection`,"features.label-selection.dialog.no-labels":`This label collection has no labels.`,"features.label-selection.dialog.error":`Label collections could not be loaded.`,"views.goodbye.loading":`Loading`,"views.goodbye.title":`Goodbye`,"views.goodbye.body":`We’re sad to 
2see you go. Your account and data have been permanently deleted.`,"views.goodbye.thanks":`Thanks for spending time with us. You’re always welcome back.`,"features.quick-help.end-tour":`End tour`,"features.quick-help.finish":`Finish`,"features.quick-help.close":`Close guide`,"features.quick-help.help":`Help`,"features.quick-help.home.title":`Get started on Home`,"features.quick-help.home.description":`See your worlds and events, and find the fastest way to get started.`,"features.quick-help.home.welcome.title":`Welcome to Home`,"features.quick-help.home.welcome.content":`Home gathers the worlds and events you use most, so you can pick up where you left off or start something new.`,"features.quick-help.home.create-event.title":`Start a new event`,"features.quick-help.home.create-event.content":`Select Create event, then pick Meeting, Webinar, or Solo experience. Fill in the short form that opens. If you need invitations, access rules, or other details, select Advanced settings instead.`,"features.quick-help.home.open-world.title":`Open a world`,"features.quick-help.home.open-world.content":`World cards are the quickest way into your published environments. Select a card to open it, or use its menu to edit the world or create an event for it.`,"features.quick-help.home.calendar.title":`See what is coming up`,"features.quick-help.home.calendar.content":`Switch between list, day, week, month, and year views. Select an event to see its details, or select a free slot to start scheduling a new one.`,"features.quick-help.home.navigation.title":`Navigation in Storyverse Dashboard`,"features.quick-help.home.navigation.content":`The dashboard is where you create and edit your events, worlds, and content. Use the main navigation to move between those areas, along with spaces, files, and organization settings. You only see the areas your permissions allow.`,"features.quick-help.worlds.title":`Create and manage worlds`,"features.quick-help.worlds.description":`Create a world, open its editor, and find your way around the world list.`,"features.quick-help.worlds.overview.title":`Your worlds`,"features.quick-help.worlds.overview.content":`A world is a virtual environment built from one or more spaces. Everything your organization can open is listed here.`,"features.quick-help.worlds.create.title":`Create a world`,"features.quick-help.worlds.create.content":`Start here. Give your world a clear name and description, check its web address, and pick a thumbnail people will recognize.`,"features.quick-help.worlds.manage.title":`Open and manage a world`,"features.quick-help.worlds.manage.content":`Select a world to open it in the editor. The menu at the end of each row lets you edit, view, or delete a world, depending on what your role allows.`,"features.quick-help.worlds.editor.title":`Continue in the World Editor`,"features.quick-help.worlds.editor.content":`Once a world is open, select Help again. The next guide covers spaces, properties, interactive spots, preview, and publishing.`,"features.quick-help.events.title":`Create and manage events`,"features.quick-help.events.description":`Schedule an event and pick the format that suits your audience.`,"features.quick-help.events.overview.title":`Your events`,"features.quick-help.events.overview.content":`An event lets people into a world at a set time. Select any event to check or change its details.`,"features.quick-help.events.create.title":`Schedule a new event`,"features.quick-help.events.create.content":`Pick a meeting for two-way audio and video, a webinar led by a presenter, or a solo experience people explore on their own. Which types you see depends on your organization.`,"features.quick-help.events.manage.title":`Update or remove an event`,"features.quick-help.events.manage.content":`From the list you can open an event, change its invitations, or delete one you no longer need. Select Help on the create page for a walkthrough of the form.`,"features.quick-help.create-event.title":`Fill in the event form`,"features.quick-help.create-event.description":`Set the time, choose the world, and decide who can join.`,"features.quick-help.create-event.type.title":`Pick the type of event`,"features.quick-help.create-event.type.content":`Meeting gives everyone audio and video, Webinar is led by a presenter, and Solo experience is explored alone. Pick the one that fits your audience.`,"features.quick-help.create-event.details.title":`Add the event details`,"features.quick-help.create-event.details.content":`Give the event a clear name and description, check its web address, set the start and end time, and choose the world people will enter.`,"features.quick-help.create-event.access.title":`Control who can join`,"features.quick-help.create-event.access.content":`Pick an access level, then add people. You can type email addresses one by one, paste a whole list, or invite everyone at a company with *@company.com.`,"features.quick-help.create-event.actions.title":`Create the event`,"features.quick-help.create-event.actions.content":`Check the form, then select Create event. Leave Send invitations turned on and Storyverse emails everyone on your list for you.`,"features.quick-help.world-editor.title":`Use the World Editor`,"features.quick-help.world-editor.description":`Arrange space
2s, add spots, preview changes, and publish.`,"features.quick-help.world-editor.spaces.title":`Build the world from spaces`,"features.quick-help.world-editor.spaces.content":`Select a thumbnail to open that space. You can add spaces from templates, drag thumbnails to reorder them, and use a card’s menu to edit, duplicate, or delete a space.`,"features.quick-help.world-editor.canvas.title":`See your changes live`,"features.quick-help.world-editor.canvas.content":`This is the space you have selected. Anything you change in the panels around it shows up here right away, so you can judge the experience as you build it.`,"features.quick-help.world-editor.side-panel.title":`Edit properties and spots`,"features.quick-help.world-editor.side-panel.content":`Properties holds the settings for this space template. Spots is where you add interactive points, change how they look and what they do, and link them to your content.`,"features.quick-help.world-editor.spots-tab.title":`Open the Spots tab`,"features.quick-help.world-editor.spots-tab.content":`Select Spots to see every interactive point in this space. Leave the tab open and select Next to carry on.`,"features.quick-help.world-editor.add-spot.title":`Add a spot`,"features.quick-help.world-editor.add-spot.content":`Select Add. A new spot appears in the scene and in the list, ready for you to edit its settings below.`,"features.quick-help.world-editor.spot-properties.title":`Set up your spot`,"features.quick-help.world-editor.spot-properties.content":`The guide has selected a spot for you, adding one if the space had none, so you can see its settings. Give it a clear name, then choose how it looks, where it sits, and what happens when someone selects it. To open content, pick a collection and item under its content link settings.`,"features.quick-help.world-editor.preview.title":`Test before publishing`,"features.quick-help.world-editor.preview.content":`Turn on Preview to walk through the space the way a visitor will. Try the spots and the navigation, then switch back to editing to fix anything that feels off.`,"features.quick-help.world-editor.details.title":`Update world details`,"features.quick-help.world-editor.details.content":`Change the name, description, web address, thumbnail, and linked collections. These are what help people recognize and find your world.`,"features.quick-help.world-editor.publish.title":`Publish and share`,"features.quick-help.world-editor.publish.content":`Your changes stay private until you publish. Publish the latest version, then use Share for a public link or Embed to put the world on a website.`,"features.quick-help.content-collections.title":`Collections and content items`,"features.quick-help.content-collections.description":`Create collections, decide what each item holds, and add content you can reuse.`,"features.quick-help.content-collections.overview.title":`Build reusable content`,"features.quick-help.content-collections.overview.content":`The Content tab keeps reusable items in collections. Every collection sets out the fields its items share, such as a title, description, image, or video.`,"features.quick-help.content-collections.add-collection.title":`Add a collection`,"features.quick-help.content-collections.add-collection.content":`Select the plus button next to Collections. A new collection appears and is selected for you, so just type a clear name while it is highlighted.`,"features.quick-help.content-collections.fields.title":`Decide what each item holds`,"features.quick-help.content-collections.fields.content":`Open the collection’s menu and choose Edit Fields. The dialog that opens has its own Guide button, which walks you through adding, setting up, ordering, and saving fields.`,"features.quick-help.content-collections.fields-dialog.title":`Get help inside the fields dialog`,"features.quick-help.content-collections.fields-dialog.content":`Once Edit Fields is open, select the blue question-mark button next to the X to start the guide for that dialog.`,"features.quick-help.content-collections.create-item.title":`Create an item`,"features.quick-help.content-collections.create-item.content":`Pick a collection, then select Create Item. Name it, check its web address and status, fill in the collection’s fields, and select Create Item to save.`,"features.quick-help.content-collections.item-editor.title":`Use the item editor guide`,"features.quick-help.content-collections.item-editor.content":`When the item editor opens, select Guide at the top for a short tour of naming, status, fields, preview, and saving.`,"features.quick-help.content-collections.workspace.title":`Find and edit your items`,"features.quick-help.content-collections.workspace.content":`Everything in the collection is listed here. Select a row to edit it, use Preview where it is offered, and use the table buttons to refresh, import, export, or delete content.`,"features.quick-help.content-labels.title":`Label collections and labels`,"features.quick-help.content-labels.description":`Create label collections and keep the original wording of your reusable text.`,"features.quick-help.content-labels.overview.title":`Write your text once`,"features.quick-help.content-labels.overview.content":`Labels are short pieces of text you reuse across the interface. Write them in your original language here, then translate them on the Localization tab.`,"features.quick-help.content-labels.add-collection.title":`Add a label collection`,"features.quick-help.content-labels.add-collection.content":`Select the plus button next to Label collections. The new collection opens straight away, ready to name and set up.`,"features.quick-help.content-labels.details.title":`Name the collection`,"features.quick-help.content-labels.details.content":`Give it a name you will recognize, check the web address, and add a de
2scription if it helps. Select Save once you have changed anything here.`,"features.quick-help.content-labels.add-label.title":`Add a label`,"features.quick-help.content-labels.add-label.content":`Select Add label to start a new row. Swap the generated key for your own dot-separated one, then type the text people will see and a description if it helps.`,"features.quick-help.content-labels.source-values.title":`Edit labels in the table`,"features.quick-help.content-labels.source-values.content":`Change keys, text, and descriptions straight in the table. Your edit saves as soon as you leave a field, and a green outline confirms it.`,"features.quick-help.content-localization.title":`Languages and translations`,"features.quick-help.content-localization.description":`Add the languages you need and translate your content and labels.`,"features.quick-help.content-localization.overview.title":`Translate Storyverse content`,"features.quick-help.content-localization.overview.content":`Localization shows your collection content and labels side by side for the language you pick. The original text stays visible next to every translation box.`,"features.quick-help.content-localization.add-language.title":`Add a language`,"features.quick-help.content-localization.add-language.content":`Select the plus button next to Locales. When the dialog opens, select its Guide button for a short walkthrough of choosing, setting up, and saving a language.`,"features.quick-help.content-localization.language-dialog.title":`Get help inside the language dialog`,"features.quick-help.content-localization.language-dialog.content":`Once the language dialog is open, select the blue question-mark button next to the X. That guide covers the language picker, the settings, reordering, and Save.`,"features.quick-help.content-localization.select-language.title":`Pick a language to work on`,"features.quick-help.content-localization.select-language.content":`Choose any language other than your default. Each one shows how many values are translated and how far along you are, so you can spot what still needs work.`,"features.quick-help.content-localization.content-translations.title":`Translate collection content`,"features.quick-help.content-localization.content-translations.content":`Under Collections, open a collection and then an item. Type each translation next to the original. Leaving a box saves it and moves your progress along.`,"features.quick-help.content-localization.label-translations.title":`Translate labels`,"features.quick-help.content-localization.label-translations.content":`Under Labels, open a label collection. Use the original as your reference, type the translation, and leave the box to save it.`,"features.quick-help.content-localization.tools.title":`Search, import, and export`,"features.quick-help.content-localization.tools.content":`Search narrows down collections, items, and labels. Import and Export move translations in bulk, which helps when you work with outside translators.`,"features.quick-help.content-fields-dialog.title":`Set up collection fields`,"features.quick-help.content-fields-dialog.description":`Add, set up, reorder, and save the fields in the open collection.`,"features.quick-help.content-fields-dialog.overview.title":`Decide what every item holds`,"features.quick-help.content-fields-dialog.overview.content":`Every item in this collection uses the fields you set up here. Changing or removing a field can affect items that already exist.`,"features.quick-help.content-fields-dialog.add-field.title":`Add a field`,"features.quick-help.content-fields-dialog.add-field.content":`Select the plus button to add a field. It appears in the list on the left and opens for you to set up on the right.`,"features.quick-help.content-fields-dialog.order.title":`Select and order fields`,"features.quick-help.content-fields-dialog.order.content":`Select a field to edit it. Drag fields into the order you want people to see when they create or edit an item.`,"features.quick-help.content-fields-dialog.settings.title":`Set up the field`,"features.quick-help.content-fields-dialog.settings.content":`Choose the display name, a unique property name, a description, whether it is required, and the field type. Options for that type appear underneath. Leave Localization on for any text you want translated.`,"features.quick-help.content-fields-dialog.save.title":`Save the schema`,"features.quick-help.content-fields-dialog.save.content":`Check the list, then select Save Schema. Cancel closes the dialog and drops your changes; Delete Field removes the field you have selected.`,"features.quick-help.content-item-editor.title":`Create a collection item`,"features.quick-help.content-item-editor.description":`Fill in and save an item using the fields from its collection.`,"features.quick-help.content-item-editor.overview.title":`Create the item`,"features.quick-help.content-item-editor.overview.content":`This editor follows the fields set up for the collection you picked. Anything marked required has to be filled 
2in before you can save.`,"features.quick-help.content-item-editor.details.title":`Name it and set its status`,"features.quick-help.content-item-editor.details.content":`Give the item a clear name, check the web address that is generated for it, and choose Draft, Published, or Archived. Draft is handy while you are still working on it.`,"features.quick-help.content-item-editor.fields.title":`Fill in the fields`,"features.quick-help.content-item-editor.fields.content":`Fill in the fields that belong to this collection. Their descriptions, whether they are required, and the controls you get all come from the collection’s field setup.`,"features.quick-help.content-item-editor.save.title":`Save the item`,"features.quick-help.content-item-editor.save.content":`Select Create Item for a new item, or Save Changes when you are editing one. If the collection offers a visual preview, take a look before you save.`,"features.quick-help.content-language-dialog.title":`Add and set up a language`,"features.quick-help.content-language-dialog.description":`Pick a language, choose how it behaves, and save your list.`,"features.quick-help.content-language-dialog.overview.title":`Choose your organization languages`,"features.quick-help.content-language-dialog.overview.content":`This is where you decide which languages are available for translating content and labels. One language always stays as your default source language.`,"features.quick-help.content-language-dialog.picker.title":`Choose a language`,"features.quick-help.content-language-dialog.picker.content":`Search by language name or code and select a result. The language joins your list and its settings open automatically.`,"features.quick-help.content-language-dialog.settings.title":`Set up the language`,"features.quick-help.content-language-dialog.settings.content":`Check the language code, display name, and native name. You can also pick a fallback language, describe the translation style you prefer, or make this your default source language.`,"features.quick-help.content-language-dialog.locales.title":`Reorder or remove languages`,"features.quick-help.content-language-dialog.locales.content":`Select a language to edit it, drag to change the order, or use the remove button when you no longer need one.`,"features.quick-help.content-language-dialog.save.title":`Save the languages`,"features.quick-help.content-language-dialog.save.content":`Select Save to apply the list to your organization. After that, pick any non-default language in Localization to start translating your collections and labels.`,"features.quick-help.world-settings-dialog.title":`Edit world settings`,"features.quick-help.world-settings-dialog.description":`Update your world’s details, pick a thumbnail, and link the collections it uses.`,"features.quick-help.world-settings-dialog.overview.content":`Everything that describes the world itself lives here. Use the sections on the left to move between the details, the thumbnail, and the collections your world can use.`,"features.quick-help.world-settings-dialog.details.title":`Edit the world details`,"features.quick-help.world-settings-dialog.details.content":`Give the world a clear name and description, then check the web address visitors will use. Each field saves as you leave it, and a green outline confirms the change.`,"features.quick-help.world-settings-dialog.thumbnail.title":`Choose a thumbnail`,"features.quick-help.world-settings-dialog.thumbnail.content":`The thumbnail stands in for your world in lists, cards, and previews. Select the image area to choose or upload a picture, and use the file row below it to remove the current one.`,"features.quick-help.world-settings-dialog.capture.title":`Take a picture of a space`,"features.quick-help.world-settings-dialog.capture.content":`Rather than uploading a picture, you can photograph one of the spaces in this world. Pick a space to load it in the editor behind this panel, then select Capture space to use that view. The image saves right away, and the space you were editing comes back when you close settings.`,"features.quick-help.world-settings-dialog.cms-collections.title":`Link content collections`,"features.quick-help.world-settings-dialog.cms-collections.content":`Open Collections and tick every content collection this world should reach. Spots and components can then open items from whatever you tick here.`,"features.quick-help.world-settings-dialog.label-collections.title":`Link label collections`,"features.quick-help.world-settings-dialog.label-collections.content":`Open Labels and tick the label collections whose translated text this world should use. Use the filter box if your organization has a lot of them.`,"features.quick-help.world-settings-dialog.done.title":`Close the settings`,"features.quick-help.world-settings-dialog.done.content":`The details and thumbnail save as you go, so select Done to close this and get back to the editor.`};function Z(e){return To[e]}function Eo(e){return[...e].sort((e,t)=>
2e.order-t.order||Do(e).localeCompare(Do(t)))}function Do(e){return e.nativeName||e.name||e.languageCode}function Oo(e){let t=vo.array().safeParse(e&&typeof e==`object`&&`locales`in e?e.locales:void 0);return t.success?Eo(t.data):[]}function ko(){let{activeOrganization:e}=z(),t=e?.metadata;return(0,Y.useMemo)(()=>Oo(t),[t])}var Ao=Z(`features.language-selector.select-language`);function jo({value:e,onValueChange:t,locales:n,label:r=Ao,placeholder:i=Ao,disabled:a=!1,hidden:o=!1,className:s,id:c,variant:l=`overlay`}){let u=ko(),d=n??u;if(o)return null;let f=d.find(t=>t.languageCode===e)??null;return d.length===0?null:(0,X.jsxs)(Vt,{value:f?.languageCode??null,onValueChange:e=>{e&&t(e)},disabled:a||d.length===1,children:[(0,X.jsx)(Dn,{id:c,"aria-label":r,className:q(l===`overlay`?`h-10 w-auto min-w-0 rounded-lg bg-transparent px-2 text-sm text-white shadow-none hover:bg-white/10 [&>svg]:hidden`:`bg-background text-foreground hover:bg-accent [&_svg]:text-muted-foreground`,s),children:(0,X.jsx)(Mt,{children:()=>f?f.languageCode.toUpperCase():(0,X.jsx)(`span`,{className:q(l===`overlay`?`text-white/70`:`text-muted-foreground`),children:i})})}),(0,X.jsx)(Dt,{align:`start`,sideOffset:8,className:q(l===`overlay`&&`min-w-48 rounded-2xl bg-white/15 p-3 text-white shadow-2xl ring-1 ring-white/10 backdrop-blur-xl`),children:d.map(e=>(0,X.jsx)(Mo,{locale:e,variant:l},e.languageCode))})]})}jo.displayName=`LanguageSelector`;function Mo({locale:e,variant:t}){let n=Do(e),r=!!e.name&&e.name!==n;return(0,X.jsxs)(yn,{value:e.languageCode,hideIndicator:t===`overlay`,className:q(t===`overlay`&&`min-h-14 rounded-2xl px-4 text-base text-white focus:bg-white/15 focus:text-white`),children:[(0,X.jsx)(`span`,{className:`flex-1 truncate`,children:n}),r&&(0,X.jsx)(`span`,{className:q(`truncate`,t===`overlay`?`text-white/65`:`text-muted-foreground`),children:e.name}),e.isDefault&&(0,X.jsx)(`span`,{className:q(`rounded px-1.5 py-0.5 text-xs`,t===`overlay`?`bg-white/15 text-white`:`bg-muted text-muted-foreground`),children:Z(`common.default`)}),(0,X.jsx)(`span`,{className:q(`text-xs uppercase`,t===`overlay`?`text-white/65`:`text-muted-foreground`),children:e.languageCode})]})}Mo.displayName=`LanguageSelectorItem`;function No(){let[e,t]=wo(),n=ko(),r=e!=null&&n.some(t=>t.languageCode===e),i=n.find(e=>e.isDefault)?.languageCode??n[0]?.languageCode;return(0,Y.useEffect)(function(){!r&&i&&t(i)},[r,i,t]),r?e:n.length===0?e??`en`:i??`en`}function Po(){let e=ko(),[,t]=wo(),n=No();return(0,X.jsx)(jo,{hidden:!0,className:`h-9 w-auto min-w-24 rounded-md px-3 text-sm`,label:Z(`features.language-selector.content-language`),locales:e,onValueChange:t,value:n,variant:`dashboard`})}function Fo({className:e,size:t=`default`,...n}){return(0,X.jsx)(`div`,{"data-slot":`card`,"data-size":t,className:q(`group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-[min(var(--radius-4xl),24px)] bg-card py-(--card-spacing) text-sm text-card-foreground shadow-sm ring-1 ring-foreground/5 [--card-spacing:--spacing(5)] has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(4)] dark:ring-foreground/10 *:[img:first-child]:rounded-t-[min(var(--radius-4xl),24px)] *:[img:last-child]:rounded-b-[min(var(--radius-4xl),24px)]`,e),...n})}function Io({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`card-header`,className:q(`group/card-header @container/card-header grid auto-rows-min items-start gap-1.5 rounded-t-[min(var(--radius-4xl),24px)] px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)`,e),...t})}function Lo({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`card-title`,className:q(`text-base font-medium`,e),...t})}function Ro({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`card-description`,className:q(`text-sm text-muted-foreground`,e),...t})}function zo({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`card-content`,className:q(`px-(--card-spacing)`,e),...t})}function Bo({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`card-footer`,className:q(`flex items-center rounded-b-[min(var(--radius-4xl),24px)] px-(--card-spacing) [.border-t]:pt-(--card-spacing)`,e),...t})}function Vo({error:e,className:t,...n}){return e?(0,X.jsx)(`div`,{className:q(`rounded-md bg-destructive/15 px-4 py-3 text-sm text-destructive`,t),...n,children:e}):null}var Ho=Y.createContext({legendId:void 0,setLegendId:()=>{},disabled:void 0});function Uo(e=!1){let t=Y.useContext(Ho);if(!t&&!e)throw Error(Et(86));return t}var Wo=Y.createContext({disabled:!1});function Go(){return Y.useContext(Wo)}var Ko=Y.createContext(void 0);function qo(e=!0){let t=Y.useContext(Ko);if(t===void 0&&!e)throw Error(Et(3));return t}var Jo=Y.createContext(void 0);function Yo(){let e=Y.useContext(Jo);if(e===void 0)throw Error(Et(13));return e}var Xo={imageLoadingStatus:()=>null},Zo=Y.forwardRef(function(e,t){let{className:n,render:r,...i}=e,[a,o]=Y.useState(`idle`),s={imageLoadingStatus:a},c=Y.useMemo(()=>({imageLoadingStatus:a,setImageLoadingStatus:o}),[a,o]),l=$e(`span`,e,{state:s,ref:t,props:i,stateAttributesMapping:Xo});return(0,X.jsx)(Jo.Provider,{value:c,children:l})});function Qo(e,{referrerPolicy:t,crossOrigin:n}){let[r,i]=Y.useState(`idle`);return jt(()=>{if(!e)return i(`error`),Rt;let r=!0,a=new window.Image,o=e=>()=>{r&&i(e)};return i(`loading`),a.onload=o(`loaded`),a.onerror=o(`error`),t&&(a.referrerPolicy=t),a.crossOrigin=n??null,a.src=e,()=>{r=!1}},[e,n,t]),r}var $o={...Xo,...Qt},es=Y.forwardRef(function(e,t){let{className:n,render:r,onLoadingStatusChange:i,referrerPolicy:a,crossOrigin:o,...s}=e,c=Yo(),l=Qo(e.src,{referrerPolicy:a,crossOrigin:o}),u=l===`loading`||l===`loaded`,{mounted:d,transitionStatus:f,setMounted:p}=Ut(u),m=Y.useRef(null),h=En(e=>{i?.(e),c.setImageLoadingStatus(e)});jt(()=>{l!==`idle`&&h(l)},[l,h]);let g={imageLoadingStatus:l,transitionStatus:l===`loading`?`starting`:f};Lt({open:u,ref:m,onComplete(){u||p(!1)}});let _=$e(`img`,e,{state:g,ref:[t,m],props:s,stateAttributesMapping:$o,enabled:d});return d?_:null}),ts={...Xo,...Qt},ns=Y.forwardRef(function(e,t){let{className:n,render:r,delay:i,...a}=e,{imageLoadingStatus:o}=Yo(),[s,c]=Y.useState(i===void 0),l=dn(),u=o!==`loaded`&&s,{mounted:d,transitionStatus:f,setMounted:p}=Ut(u),m=Y.useRef(null);Y.useEffect(()=>(i!==void 0&&l.start(i,()=>c(!0)),l.clear),[l,i]);let h={imageLoadingStatus:o,transitionStatus:f};Lt({open:u,ref:m,onComplete(){u||p(!1)}});let g=$e(`span`,e,{state:h,ref:[t,m],props:a,stateAttributesMapping:ts,enabled:d});return d?g:null});function rs({className:e,size:t=`default`,...n}){return(0,X.jsx)(Zo,{"data-slot":`avatar`,"data-size":t,className:q(`group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten`,e),...n})}function is({className:e,...t}){return(0,X.jsx)(es,{"data-slot":`avatar-image`,className:q(`aspect-square size-full rounded-full object-cover`,e),...t})}function as({className:e,...t}){return(0,X.jsx)(ns,{"data-slot":`avatar-fallback`,className:q(`flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs`,e),...t})}var os=()=>{let{session:e,switchOrganization:t}=z(),n=c(),r=e?.user.organizations??[],i=async e=>{await t(e.id),n(`/${e.slug}/dashboard`)};return(0,X.jsx)(ar,{open:!0,children:(0,X.jsxs)(pr,{showCloseButton:!1,className:`sm:max-w-md`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:Z(`dashboard.select-organization.title`)}),(0,X.jsx)(_r,{children:Z(`dashboard.select-organization.body`)})]}),(0,X.jsx)(`ul`,{className:`flex flex-col gap-2`,children:r.map(e=>{let t=e.logo;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e),className:`flex w-full items-center gap-3 rounded-lg border border-border p-3 text-left transition-colors hover:bg-foreground
2/5 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,children:[(0,X.jsxs)(rs,{className:`size-9 rounded-lg bg-background after:rounded-lg`,children:[(0,X.jsx)(is,{src:t||``,alt:e.name,className:`rounded-lg object-contain p-1`}),(0,X.jsx)(as,{className:`rounded-lg text-xs`,children:e.name.substring(0,2).toUpperCase()})]}),(0,X.jsx)(`span`,{className:`flex-1 truncate text-sm font-medium`,children:e.name}),(0,X.jsx)(Er,{className:`size-4 shrink-0 text-muted-foreground`})]})},e.id)})})]})})};os.displayName=`OrganizationSelectScreen`;var ss=()=>(0,X.jsxs)(`div`,{className:`flex h-svh w-svw flex-col items-center justify-center gap-6 p-8 text-center`,children:[(0,X.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-full bg-muted`,children:(0,X.jsx)(Aa,{className:`h-9 w-9 text-muted-foreground`})}),(0,X.jsxs)(`div`,{className:`max-w-md space-y-2`,children:[(0,X.jsx)(`h1`,{className:`text-2xl font-bold`,children:Z(`dashboard.no-organization.title`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`dashboard.no-organization.body`)})]}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`dashboard.no-organization.contact-admin`)})]});ss.displayName=`NoOrganizationScreen`;var cs=lt({email:H().email(`Please enter a valid email address`)});function ls(){return new URL(`/reset-password`,window.location.origin).href}function us({className:e,onResetPassword:t,...n}){let{client:r}=z(),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)(0),m=(0,Y.useRef)(null),{theme:g,setTheme:_}=qn();(0,Y.useEffect)(()=>{if(!(f<=0))return m.current=setInterval(()=>{p(e=>e<=1?(clearInterval(m.current),0):e-1)},1e3),()=>clearInterval(m.current)},[f>0]);let v=l({resolver:pn(cs),defaultValues:{email:``}}),y=async e=>{a(!0),d(null);try{let t=await r.requestPasswordReset({email:e.email,redirectTo:ls()});t.data?.status?(s(!0),p(60)):d(t.error?.message??`Failed to send reset email. Please try again.`)}catch(e){d(e instanceof Error?e.message:`Failed to send reset email. Please try again.`)}finally{a(!1)}},b=g===`dark`||g===`system`&&typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches,x=(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`fixed top-4 right-4 z-50 text-muted-foreground hover:text-foreground`,onClick:()=>_(b?`light`:`dark`),"aria-label":b?`Switch to light mode`:`Switch to dark mode`,children:b?(0,X.jsx)(fa,{className:`size-4`}):(0,X.jsx)(si,{className:`size-4`})});return o?(0,X.jsxs)(`div`,{className:q(`w-full max-w-[428px]`,e),...n,children:[x,(0,X.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-8 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-primary/10`,children:(0,X.jsx)(yi,{className:`h-7 w-7 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`h1`,{className:`text-[1.75rem] font-normal tracking-tight text-foreground`,children:`Check your email`}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:`We've sent a password reset link to your email address.`})]})]}),(0,X.jsxs)(`div`,{className:`mb-6 flex items-center gap-2 rounded-lg border border-amber-500/40 bg-amber-500/10 px-4 py-3 text-sm text-amber-700 dark:text-amber-400`,children:[(0,X.jsx)(ua,{className:`size-4 shrink-0`}),(0,X.jsx)(`span`,{children:`If you don't see the email, check your spam folder or try again.`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)(U,{className:`h-12 w-full rounded-full text-base font-medium`,size:`lg`,render:e=>(0,X.jsxs)(u,{to:`/signin`,...e,children:[(0,X.jsx)(Ca,{className:`mr-2 h-4 w-4`}),`Back to Sign In`]})}),(0,X.jsx)(U,{variant:`outline`,className:`h-12 w-full rounded-full`,disabled:f>0||i,onClick:()=>v.handleSubmit(y)(),children:f>0?`Resend in ${f}s`:`Resend email`})]})]})]}):(0,X.jsxs)(`div`,{className:q(`w-full max-w-[428px]`,e),...n,children:[x,(0,X.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-8 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-primary/10`,children:(0,X.jsx)(Ra,{className:`h-7 w-7 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`h1`,{className:`text-[1.75rem] font-normal tracking-tight text-foreground`,children:`Forgot your password?`}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:`Enter your email and we'll send you a link to reset your password.`})]})]}),(0,X.jsxs)(`form`,{onSubmit:v.handleSubmit(y),className:`space-y-5`,children:[(0,X.jsx)(Vo,{error:c}),(0,X.jsx)(h,{control:v.control,name:`email`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":!!t.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:`Email`}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,id:`email`,type:`email`,autoComplete:`email`,placeholder:`[email protected]`,disabled:i,className:`h-12 rounded-lg border-input bg-background px-4 focus-visible:ring-2 focus-visible:ring-primary/30`})}),(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(U,{type:`submit`,className:`h-12 w-full rounded-full text-base font-medium`,size:`lg`,disabled:i,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(An,{className:`mr-2 h-4 w-4`}),`Sending reset link...`]}):`Send reset link`}),(0,X.jsxs)(`div`,{className:`text-center text-sm text-muted-foreground`,children:[`Remember your password?`,` `,(0,X.jsx)(u,{to:`/signin`,className:`text-primary underline underline-offset-4`,children:`Back to Sign In`})]})]})]})]})}us.displayName=`ForgotPasswordForm`;function ds(){let[e,t]=(0,Y.useState)(!1);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`py-4 text-center text-xs text-balance text-muted-foreground *:[a]:underline *:[a]:underline-offset-4 *:[a]:hover:text-primary`,children:[Z(`components.terms.by.clicking.continue`),` `,(0,X.jsx)(`span`,{onClick:()=>
2t(!0),className:`cursor-pointer underline`,children:Z(`components.terms.terms.of.service`)}),` `,`and`,` `,(0,X.jsx)(`span`,{onClick:()=>t(!0),className:`cursor-pointer underline`,children:Z(`components.terms.privacy.policy`)})]}),(0,X.jsx)(Ln,{open:e,onOpenChange:t,children:(0,X.jsxs)(Vn,{children:[(0,X.jsxs)(tr,{className:``,children:[(0,X.jsx)(er,{children:Z(`components.terms.and.conditions.title`)}),(0,X.jsx)(gr,{children:Z(`common.based.on.finnish.law.and.gdpr.compliance`)})]}),(0,X.jsxs)(`div`,{className:`mx-auto max-w-4xl space-y-6 overflow-y-auto p-6 text-sm leading-relaxed text-foreground`,children:[(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`common.1.service.description`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`components.terms.and.conditions.1.description`)})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`common.2.personal.data.processing`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`common.personal.data.processing.is.based.on.the.eu`)}),(0,X.jsxs)(`ul`,{className:`mb-2 list-disc space-y-1 pl-6`,children:[(0,X.jsx)(`li`,{children:Z(`common.email.address`)}),(0,X.jsx)(`li`,{children:Z(`common.username.display.name`)}),(0,X.jsx)(`li`,{children:Z(`common.usage.statistics.and.analytics`)}),(0,X.jsx)(`li`,{children:Z(`common.technical.log.data`)})]})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`components.terms.and.conditions.3.title`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`components.terms.and.conditions.3.description`)}),(0,X.jsxs)(`ul`,{className:`mb-2 list-disc space-y-1 pl-6`,children:[(0,X.jsx)(`li`,{children:Z(`common.email.address`)}),(0,X.jsx)(`li`,{children:Z(`common.username.display.name`)}),(0,X.jsx)(`li`,{children:Z(`common.usage.statistics.and.analytics`)})]})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`components.terms.and.conditions.4.title`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`common.personal.data.processing.is.based.on.the.following`)}),(0,X.jsxs)(`ul`,{className:`mb-2 list-disc space-y-1 pl-6`,children:[(0,X.jsx)(`li`,{children:Z(`common.service.provision.and.contract.fulfillment`)}),(0,X.jsx)(`li`,{children:Z(`common.legitimate.interest.service.development.and.security`)}),(0,X.jsx)(`li`,{children:Z(`common.consent.where.applicable`)}),(0,X.jsx)(`li`,{children:Z(`common.right.to.erasure`)}),(0,X.jsx)(`li`,{children:Z(`common.right.to.restrict.processing`)}),(0,X.jsx)(`li`,{children:Z(`common.right.to.data.portability`)}),(0,X.jsx)(`li`,{children:Z(`common.right.to.object`)})]})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`common.5.service.usage`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`common.when.using.the.service.you.commit.to`)}),(0,X.jsxs)(`ul`,{className:`mb-2 list-disc space-y-1 pl-6`,children:[(0,X.jsx)(`li`,{children:Z(`common.using.the.service.only.for.lawful.purposes`)}),(0,X.jsx)(`li`,{children:Z(`common.respecting.other.users.rights`)}),(0,X.jsx)(`li`,{children:Z(`common.not.spreading.harmful.content`)}),(0,X.jsx)(`li`,{children:Z(`common.following.the.service.s.technical.limitations`)})]})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`common.6.limitation.of.liability`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`components.terms.and.conditions.6.description`)})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`common.7.contact.information`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`common.for.questions.regarding.personal.data.contact`)}),(0,X.jsxs)(`p`,{className:`font-medium`,children:[Z(`components.terms.and.conditions.7.list.1`),(0,X.jsx)(`br`,{}),Z(`components.terms.and.conditions.7.list.2`),(0,X.jsx)(`br`,{}),Z(`components.terms.and.conditions.7.list.3`)]})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`common.8.changes`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`common.we.reserve.the.right.to.change.these.terms`)})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`common.9.applicable.law`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`common.these.terms.are.subject.to.finnish.law.any`)})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h3`,{className:`mb-3 text-lg font-semibold`,children:Z(`common.10.consent`)}),(0,X.jsx)(`p`,{className:`mb-2`,children:Z(`components.terms.and.conditions.10.description`)})]})]})]})})]})}var fs=lt({password:H().min(8,`Password must be at least 8 characters`),confirmPassword:H().min(8,`Password must be at least 8 characters`)}
2).refine(e=>e.password===e.confirmPassword,{message:`Passwords do not match`,path:[`confirmPassword`]});function ps({className:e,token:t,onResetPassword:n,...r}){let[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,d]=(0,Y.useState)(null),{theme:f,setTheme:p}=qn(),m=l({resolver:pn(fs),defaultValues:{password:``,confirmPassword:``}}),g=async e=>{if(!t){d(`Invalid reset token. Please request a new password reset.`);return}a(!0),d(null);try{n&&await n(e.password,t),s(!0)}catch(e){d(e instanceof Error?e.message:`Failed to reset password. Please try again.`)}finally{a(!1)}},_=f===`dark`||f===`system`&&typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches,v=(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`fixed top-4 right-4 z-50 text-muted-foreground hover:text-foreground`,onClick:()=>p(_?`light`:`dark`),"aria-label":_?`Switch to light mode`:`Switch to dark mode`,children:_?(0,X.jsx)(fa,{className:`size-4`}):(0,X.jsx)(si,{className:`size-4`})});return o?(0,X.jsxs)(`div`,{className:q(`w-full max-w-[428px]`,e),...r,children:[v,(0,X.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-8 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-green-500/10`,children:(0,X.jsx)(ni,{className:`h-7 w-7 text-green-500`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`h1`,{className:`text-[1.75rem] font-normal tracking-tight text-foreground`,children:`Password updated`}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:`Your password has been reset successfully. You can now sign in with your new password.`})]})]}),(0,X.jsx)(U,{className:`h-12 w-full rounded-full text-base font-medium`,size:`lg`,render:e=>(0,X.jsxs)(u,{to:`/signin`,...e,children:[(0,X.jsx)(Kr,{className:`mr-2 h-4 w-4`}),`Sign In`]})})]}),(0,X.jsx)(ds,{})]}):(0,X.jsxs)(`div`,{className:q(`w-full max-w-[428px]`,e),...r,children:[v,(0,X.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-8 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-primary/10`,children:(0,X.jsx)(Ra,{className:`h-7 w-7 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`h1`,{className:`text-[1.75rem] font-normal tracking-tight text-foreground`,children:`Reset your password`}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:`Choose a strong password to secure your account`})]})]}),(0,X.jsxs)(`form`,{onSubmit:m.handleSubmit(g),className:`space-y-5`,children:[(0,X.jsx)(Vo,{error:c}),(0,X.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg border border-blue-200 bg-blue-50 p-3 dark:border-blue-900/50 dark:bg-blue-950/20`,children:[(0,X.jsx)(ta,{className:`mt-0.5 size-4 shrink-0 text-blue-600 dark:text-blue-400`}),(0,X.jsx)(`p`,{className:`text-xs text-blue-700 dark:text-blue-300`,children:`Use at least 8 characters. A mix of letters, numbers, and symbols makes your password stronger.`})]}),(0,X.jsx)(h,{control:m.control,name:`password`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":!!t.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:`New Password`}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,id:`password`,type:`password`,autoComplete:`new-password`,placeholder:`Enter your new password`,disabled:i,className:`h-12 rounded-lg border-input bg-background px-4 focus-visible:ring-2 focus-visible:ring-primary/30`})}),(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:m.control,name:`confirmPassword`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":!!t.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:`Confirm New Password`}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,id:`confirmPassword`,type:`password`,autoComplete:`new-password`,placeholder:`Confirm your new password`,disabled:i,className:`h-12 rounded-lg border-input bg-background px-4 focus-visible:ring-2 focus-visible:ring-primary/30`})}),(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(U,{type:`submit`,className:`mt-2 h-12 w-full rounded-full text-base font-medium`,size:`lg`,disabled:i,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(An,{className:`mr-2 h-4 w-4`}),`Resetting password...`]}):`Reset password`}),(0,X.jsxs)(`div`,{className:`text-center text-sm text-muted-foreground`,children:[`Remember your password?`,` `,(0,X.jsx)(u,{to:`/signin`,className:`text-primary underline underline-offset-4`,children:`Back to Sign In`})]})]})]}),(0,X.jsx)(ds,{})]})}ps.displayName=`ResetPasswordForm`;var ms=()=>{let e=c(),{organizationSlug:t}=S();return(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col items-center justify-center gap-6 p-8 text-center`,children:[(0,X.jsx)(`div`,{className:`flex h-16 w-16 items-center justify-center rounded-full bg-muted`,children:(0,X.jsx)(Yi,{className:`h-10 w-10 text-muted-foreground`})}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h2`,{className:`text-2xl font-bold`,children:Z(`dashboard.access-denied.title`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`dashboard.access-denied.body`)})]}),(0,X.jsx)(`div`,{className:`flex w-full max-w-62.5 flex-col gap-2`,children:(0,X.jsx)(U,{onClick:()=>e(`/${t}/dashboard/home`),children:Z(`dashboard.access-denied.go-home`)})})]})};ms.displayName=`AccessDenied`;var hs=({children:e,anyOf:t,type:n,action:r})=>{let{hasPermissions:i,activeOrganization:a,isLoadingSession:o}=z();return o||!a?(0,X.jsx)(`div`,{className:`flex h-svh w-svw items-center justify-center`,role:`status`,"aria-label":`Loading`,children:(0,X.jsx)(An,{className:`size-10`})}):t?.length?t.some(e=>i(a.id,e.type,e.action))?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(ms,{}):n?i(a.id,n,r??`list-view`)?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(ms,{}):(0,X.jsx)(X.Fragment,{children:e})};hs.displayName=`RequiresPermission`;var gs=({children:e})=>{let{activeOrganization:t,isLoadingSession:n,session:r}=z();return n||!t?(0,X.jsx)(`div`,{className:`flex h-svh w-svw items-center justify-center`,role:`status`,"aria-label":`Loading`,children:(0,X.jsx)(An,{className:`size-10`})}):r?.user?.role===`admin`?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(ms,{})};gs.displayName=`RequiresPlatformAdmin`;var _s=()=>(0,X.jsx)(`div`,{className:`flex h-svh w-svw items-center justify-center`,role:`status`,"aria-label":`Loading`,children:(0,X.jsx)(An,{className:`size-10`})}),vs=({children:e})=>{let{session:t,activeOrganization:n,isLoadingSession:r}=z();return r?(0,X.jsx)(_s,{}):n?.id?(0,X.jsx)(X.Fragment,{children:e}):(t?.user.organizations??[]).length>0?(0,X.jsx)(os,{}):(0,X.jsx)(ss,{})};vs.displayName=`ActiveOrganizationGuard`;var ys=()=>(0,X.jsx)(`div`,{className:`flex h-svh w-svw items-center justify-center`,role:`status`,"aria-label":`Loading`,children:(0,X.jsx)(An,{className:`size-10`})}),bs=({redirectPath:e=`/signin`,children:t})=>{let{session:n,isLoadingSession:r,activeOrganization:i,switchOrganization:a}=z(),o=C(),{organizationSlug:s}=S();if(r)return(0,X.jsx)(ys,{});if(!n)return(0,X.jsx)(m,{to:e,replace:!0,state:{from:o}});
2let c=(0,X.jsx)(vs,{children:t?(0,X.jsx)(X.Fragment,{children:t}):(0,X.jsx)(f,{})});if(s){let e=(n.user.organizations??[]).find(e=>e.slug===s);return(0,X.jsx)(xs,{matchedOrg:e,activeOrganization:i,switchOrganization:a,children:c})}return c},xs=({matchedOrg:e,activeOrganization:t,switchOrganization:n,children:r})=>{let i=e?.id,a=t?.id,o=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{i&&i!==a&&o.current!==i&&(o.current=i,n(i))},[i,a,n]),e?e.id===t?.id?(0,X.jsx)(X.Fragment,{children:r}):(0,X.jsx)(ys,{}):t?.slug?(0,X.jsx)(m,{to:`/${t.slug}/dashboard/home`,replace:!0}):(0,X.jsx)(X.Fragment,{children:r})};bs.displayName=`ProtectedRoute`;var Ss=({children:e})=>{let{session:t,isLoadingSession:n,activeOrganization:r}=z(),i=C();if(n)return(0,X.jsx)(`div`,{className:`flex h-svh w-svw items-center justify-center`,role:`status`,"aria-label":`Loading`,children:(0,X.jsx)(An,{className:`size-10`})});if(t){let e=i.state?.from;if(e)return(0,X.jsx)(m,{to:e.pathname+(e.search??``),replace:!0});if(r?.slug)return(0,X.jsx)(m,{to:`/${r.slug}/dashboard`,replace:!0})}return e?(0,X.jsx)(X.Fragment,{children:e}):(0,X.jsx)(f,{})};Ss.displayName=`PublicOnlyRoute`;var Cs=1,ws=.9,Ts=.8,Es=.17,Ds=.1,Os=.999,ks=.9999,As=.99,js=/[\\\/_+.#"@\[\(\{&]/,Ms=/[\\\/_+.#"@\[\(\{&]/g,Ns=/[\s-]/,Ps=/[\s-]/g;function Fs(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?Cs:As;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=Fs(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=Cs:js.test(e.charAt(l-1))?(d*=Ts,p=e.slice(i,l-1).match(Ms),p&&i>0&&(d*=Os**+p.length)):Ns.test(e.charAt(l-1))?(d*=ws,m=e.slice(i,l-1).match(Ps),m&&i>0&&(d*=Os**+m.length)):(d*=Es,i>0&&(d*=Os**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=ks)),(d<Ds&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=Fs(e,t,n,r,l+1,a+2,o),f*Ds>d&&(d=f*Ds)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function Is(e){return e.toLowerCase().replace(Ps,` `)}function Ls(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,Fs(e,t,Is(e),Is(t),0,0,{})}var Rs=e(r(),1),zs=[`a`,`button`,`div`,`form`,`h2`,`h3`,`img`,`input`,`label`,`li`,`nav`,`ol`,`p`,`select`,`span`,`svg`,`ul`].reduce((e,t)=>{let n=at(`Primitive.${t}`),r=Y.forwardRef((e,r)=>{let{asChild:i,...a}=e,o=i?n:t;return typeof window<`u`&&(window[Symbol.for(`radix-ui`)]=!0),(0,X.jsx)(o,{...a,ref:r})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function Bs(e,t){if(typeof e==`function`)return e(t);e!=null&&(e.current=t)}function Vs(...e){return t=>{let n=!1,r=e.map(e=>{let r=Bs(e,t);return!n&&typeof r==`function`&&(n=!0),r});if(n)return()=>{for(let t=0;t<r.length;t++){let n=r[t];typeof n==`function`?n():Bs(e[t],null)}}}}var Hs=`[cmdk-group=""]`,Us=`[cmdk-group-items=""]`,Ws=`[cmdk-group-heading=""]`,Gs=`[cmdk-item=""]`,Ks=`${Gs}:not([aria-disabled="true"])`,qs=`cmdk-item-select`,Js=`data-value`,Ys=(e,t,n)=>Ls(e,t,n),Xs=Y.createContext(void 0),Zs=()=>Y.useContext(Xs),Qs=Y.createContext(void 0),$s=()=>Y.useContext(Qs),ec=Y.createContext(void 0),tc=Y.forwardRef((e,t)=>{let n=hc(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=hc(()=>new Set),i=hc(()=>new Map),a=hc(()=>new Map),o=hc(()=>new Set),s=pc(e),{label:c,children:l,value:u,onValueChange:d,filter:f,shouldFilter:p,loop:m,disablePointerSelection:h=!1,vimBindings:g=!0,..._}=e,v=Zn(),y=Zn(),b=Zn(),x=Y.useRef(null),S=vc();mc(()=>{if(u!==void 0){let e=u.trim();n.current.value=e,C.emit()}},[u]),mc(()=>{S(6,k)},[]);let C=Y.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)O(),E(),S(1,D);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(b);e?e.focus():(i=document.getElementById(v))==null||i.focus()}if(S(7,()=>{n.current.selectedItemId=A()?.id,C.emit()}),r||S(5,k),s.current?.value!==void 0){let e=t??``;(o=(a=s.current).onValueChange)==null||o.call(a,e);return}}
vendor: 8,387 bytes, line 2
2C.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),w=Y.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,T(t,r)),S(2,()=>{E(),C.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),S(3,()=>{O(),E(),n.current.value||D(),C.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=A();S(4,()=>{O(),t?.getAttribute(`id`)===e&&D(),C.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>s.current.shouldFilter,label:c||e[`aria-label`],getDisablePointerSelection:()=>s.current.disablePointerSelection,listId:v,inputId:b,labelId:y,listInnerRef:x}),[]);function T(e,t){let r=s.current?.filter??Ys;return e?r(e,n.current.search,t):0}function E(){if(!n.current.search||s.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=x.current;j().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(Us);t?t.appendChild(e.parentElement===t?e:e.closest(`${Us} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${Us} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=x.current?.querySelector(`${Hs}[${Js}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function D(){let e=j().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(Js);C.setState(`value`,e||void 0)}function O(){if(!n.current.search||s.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=T(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function k(){var e;let t=A();t&&(t.parentElement?.firstChild===t&&((e=t.closest(Hs)?.querySelector(Ws))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function A(){return x.current?.querySelector(`${Gs}[aria-selected="true"]`)}function j(){return Array.from(x.current?.querySelectorAll(Ks)||[])}function M(e){let t=j()[e];t&&C.setState(`value`,t.getAttribute(Js))}function N(e){var t;let n=A(),r=j(),i=r.findIndex(e=>e===n),a=r[i+e];(t=s.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&C.setState(`value`,a.getAttribute(Js))}function P(e){let t=A()?.closest(Hs),n;for(;t&&!n;)t=e>0?dc(t,Hs):fc(t,Hs),n=t?.querySelector(Ks);n?C.setState(`value`,n.getAttribute(Js)):N(e)}let F=()=>M(j().length-1),I=e=>{e.preventDefault(),e.metaKey?F():e.altKey?P(1):N(1)},L=e=>{e.preventDefault(),e.metaKey?M(0):e.altKey?P(-1):N(-1)};return Y.createElement(zs.div,{ref:t,tabIndex:-1,..._,"cmdk-root":``,onKeyDown:e=>{var t;(t=_.onKeyDown)==null||t.call(_,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:g&&e.ctrlKey&&I(e);break;case`ArrowDown`:I(e);break;case`p`:case`k`:g&&e.ctrlKey&&L(e);break;case`ArrowUp`:L(e);break;case`Home`:e.preventDefault(),M(0);break;case`End`:e.preventDefault(),F();break;case`Enter`:{e.preventDefault();let t=A();if(t){let e=new Event(qs);t.dispatchEvent(e)}}}}},Y.createElement(`label`,{"cmdk-label":``,htmlFor:w.inputId,id:w.labelId,style:xc},c),bc(e,e=>Y.createElement(Qs.Provider,{value:C},Y.createElement(Xs.Provider,{value:w},e))))}),nc=Y.forwardRef((e,t)=>{let n=Zn(),r=Y.useRef(null),i=Y.useContext(ec),a=Zs(),o=pc(e),s=o.current?.forceMount??i?.forceMount;mc(()=>{if(!s)return a.item(n,i?.id)},[s]);let c=_c(n,r,[e.value,e.children,r],e.keywords),l=$s(),u=gc(e=>e.value&&e.value===c.current),d=gc(e=>s||a.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);Y.useEffect(()=>{let t=r.current;if(t&&!e.disabled)return t.addEventListener(qs,f),()=>t.removeEventListener(qs,f)},[d,e.onSelect,e.disabled]);function f(){var e,t;p(),(t=(e=o.current).onSelect)==null||t.call(e,c.current)}function p(){l.setState(`value`,c.current,!0)}if(!d)return null;let{disabled:m,value:h,onSelect:g,forceMount:_,keywords:v,...y}=e;return Y.createElement(zs.div,{ref:Vs(r,t),...y,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!m,"aria-selected":!!u,"data-disabled":!!m,"data-selected":!!u,onPointerMove:m||a.getDisablePointerSelection()?void 0:p,onClick:m?void 0:f},e.children)}),rc=Y.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:i,...a}=e,o=Zn(),s=Y.useRef(null),c=Y.useRef(null),l=Zn(),u=Zs(),d=gc(e=>i||u.filter()===!1?!0:!e.search||e.filtered.groups.has(o));mc(()=>u.group(o),[]),_c(o,s,[e.value,e.heading,c]);let f=Y.useMemo(()=>({id:o,forceMount:i}),[i]);return Y.createElement(zs.div,{ref:Vs(s,t),...a,"cmdk-group":``,role:`presentation`,hidden:!d||void 0},n&&Y.createElement(`div`,{ref:c,"cmdk-group-heading":``,"aria-hidden":!0,id:l},n),bc(e,e=>Y.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?l:void 0},Y.createElement(ec.Provider,{value:f},e))))}),ic=Y.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,i=Y.useRef(null),a=gc(e=>!e.search);return!n&&!a?null:Y.createElement(zs.div,{ref:Vs(i,t),...r,"cmdk-separator":``,role:`separator`})}),ac=Y.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=$s(),o=gc(e=>e.search),s=gc(e=>e.selectedItemId),c=Zs();return Y.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),Y.createElement(zs.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":c.listId,"aria-labelledby":c.labelId,"aria-activedescendant":s,id:c.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),oc=Y.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...i}=e,a=Y.useRef(null),o=Y.useRef(null),s=gc(e=>e.selectedItemId),c=Zs();return Y.useEffect(()=>{if(o.current&&a.current){let e=o.current,t=a.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),Y.createElement(zs.div,{ref:Vs(a,t),...i,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":s,"aria-label":r,id:c.listId},bc(e,e=>Y.createElement(`div`,{ref:Vs(o,c.listInnerRef),"cmdk-list-sizer":``},e)))}),sc=Y.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return Y.createElement(Rn,{open:n,onOpenChange:r},Y.createElement(Qn,{container:o},Y.createElement(Mn,{"cmdk-overlay":``,className:i}),Y.createElement(wr,{"aria-label":e.label,"cmdk-dialog":``,className:a},Y.createElement(tc,{ref:t,...s}))))}),cc=Y.forwardRef((e,t)=>gc(e=>e.filtered.count===0)?Y.createElement(zs.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),lc=Y.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return Y.createElement(zs.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},bc(e,e=>Y.createElement(`div`,{"aria-hidden":!0},e)))}),uc=Object.assign(tc,{List:oc,Item:nc,Input:ac,Group:rc,Separator:ic,Dialog:sc,Empty:cc,Loading:lc});function dc(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function fc(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function pc(e){let t=Y.useRef(e);return mc(()=>{t.current=e}),t}var mc=typeof window>`u`?Y.useEffect:Y.useLayoutEffect;function hc(e){let t=Y.useRef();return t.current===void 0&&(t.current=e()),t}function gc(e){let t=$s(),n=()=>e(t.snapshot());return Y.useSyncExternalStore(t.subscribe,n,n)}function _c(e,t,n,r=[]){let i=Y.useRef(),a=Zs();return mc(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(Js,s),i.current=s}),i}var vc=()=>{let[e,t]=Y.useState(),n=hc(()=>new Map);return mc(()=>
2{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function yc(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function bc({asChild:e,children:t},n){return e&&Y.isValidElement(t)?Y.cloneElement(yc(t),{ref:t.ref},n(t.props.children)):n(t)}var xc={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`};function Sc({className:e,...t}){return(0,X.jsx)(uc,{"data-slot":`command`,className:q(`flex size-full flex-col overflow-hidden rounded-3xl bg-popover p-1 text-popover-foreground`,e),...t})}function Cc({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`command-input-wrapper`,className:`p-1 pb-0`,children:(0,X.jsxs)(Me,{className:`h-8! bg-input/50`,children:[(0,X.jsx)(uc.Input,{"data-slot":`command-input`,className:q(`w-full text-sm outline-hidden disabled:cursor-not-allowed disabled:opacity-50`,e),...t}),(0,X.jsx)(Ve,{children:(0,X.jsx)(eo,{className:`size-4 shrink-0 opacity-50`})})]})})}function wc({className:e,...t}){return(0,X.jsx)(uc.List,{"data-slot":`command-list`,className:q(`no-scrollbar max-h-72 scroll-py-1 overflow-x-hidden overflow-y-auto outline-none`,e),...t})}function Tc({className:e,...t}){return(0,X.jsx)(uc.Empty,{"data-slot":`command-empty`,className:q(`py-6 text-center text-sm`,e),...t})}function Ec({className:e,...t}){return(0,X.jsx)(uc.Group,{"data-slot":`command-group`,className:q(`overflow-hidden p-1 text-foreground **:[[cmdk-group-heading]]:px-2 **:[[cmdk-group-heading]]:py-1.5 **:[[cmdk-group-heading]]:text-xs **:[[cmdk-group-heading]]:font-medium **:[[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function Dc({className:e,...t}){return(0,X.jsx)(uc.Separator,{"data-slot":`command-separator`,className:q(`my-1 h-px bg-border/50`,e),...t})}function Oc({className:e,children:t,...n}){return(0,X.jsxs)(uc.Item,{"data-slot":`command-item`,className:q(`group/command-item relative flex min-h-7 cursor-default items-center gap-2 rounded-xl px-2 py-1.5 text-sm outline-hidden select-none in-data-[slot=dialog-content]:rounded-2xl data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-selected:bg-muted data-selected:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 data-selected:*:[svg]:text-foreground`,e),...n,children:[t,(0,X.jsx)(Ea,{className:`ml-auto opacity-0 group-has-data-[slot=command-shortcut]/command-item:hidden group-data-[checked=true]/command-item:opacity-100`})]})}var kc=`selectedOrganization`;function Ac(e){try{localStorage.setItem(kc,e)}catch{}}var jc={languageCode:`en`,name:`English`,nativeName:`English`,isDefault:!0,order:1};function Mc(){let{session:e,client:t,switchOrganization:n,activeOrganization:r,hasPermissions:i}=z(),a=c(),{data:o}=t.useListOrganizations(),s=o?.find(e=>e.id===r?.id)?.logo??r?.logo??``,[l,u]=Y.useState(!1),[d,f]=Y.useState(!1),p=i(r?.id??``,`organization`,`create`),m=i(r?.id??``,`organization`,`update`),h=p||m,g=e=>{Ac(e),n(e);let t=o?.find(t=>t.id===e);t?.slug&&a(`/${t.slug}/dashboard`)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(jn,{open:l,onOpenChange:u,children:[(0,X.jsx)(Kn,{render:e=>(0,X.jsxs)(U,{variant:`ghost`,role:`combobox`,"aria-expanded":l,"aria-label":Z(`auth.organization-selector.aria-label`),className:`h-9 w-full justify-start rounded-lg px-2 hover:bg-foreground
2/5 md:justify-center lg:justify-start`,...e,children:[(0,X.jsx)(`div`,{className:`flex shrink-0 items-center`,children:(0,X.jsxs)(rs,{className:`size-6 rounded-md bg-background after:rounded-md`,children:[(0,X.jsx)(is,{src:s,className:`rounded-md object-contain p-0.5`,alt:r?.name}),(0,X.jsx)(as,{className:`rounded-md text-[10px]`,children:r?.name.substring(0,2).toUpperCase()})]})}),(0,X.jsx)(`span`,{className:`ml-2 truncate text-[13px] font-medium md:hidden lg:inline`,children:r?.name}),(0,X.jsx)(Oi,{className:`ml-auto size-3.5 shrink-0 opacity-40 md:hidden lg:block`})]})}),(0,X.jsx)(ur,{className:`w-60 p-0`,children:(0,X.jsxs)(Sc,{children:[(0,X.jsx)(Cc,{placeholder:Z(`auth.organization-selector.search`)}),(0,X.jsxs)(wc,{children:[(0,X.jsx)(Tc,{children:Z(`auth.organization-selector.no-organization`)}),(0,X.jsx)(Ec,{heading:Z(`common.organizations`),children:e?.user.organizations&&e?.user.organizations.map(e=>{let t=o?.find(t=>t.id===e.id);return(0,X.jsxs)(Oc,{onSelect:()=>g(e.id),className:q(`text-sm transition-all duration-200 ease-in-out`,r?.id===e.id?`bg-accent`:`hover:bg-accent/50`),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 truncate`,children:[(0,X.jsxs)(rs,{className:`size-6 rounded-md bg-background after:rounded-md`,children:[(0,X.jsx)(is,{src:t?.logo||``,className:`rounded-md object-contain p-0.5`,alt:t?.name||e.name}),(0,X.jsx)(as,{className:`rounded-md text-xs`,children:e.name.substring(0,2).toUpperCase()})]}),(0,X.jsx)(`span`,{className:`truncate`,children:t?.name||e.name})]}),(0,X.jsx)(Ea,{className:q(`ml-auto h-4 w-4 transition-opacity duration-200`,r?.id===e.id?`opacity-100`:`opacity-0`)})]},e.id)})}),h&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Dc,{}),(0,X.jsxs)(Ec,{children:[p&&(0,X.jsxs)(Oc,{className:q(`cursor-pointer`),onSelect:()=>{u(!1),f(!0)},children:[(0,X.jsx)(Ci,{className:`mr-2 h-4 w-4`}),Z(`common.create.organization`)]}),m&&(0,X.jsxs)(Oc,{onSelect:()=>{a(`/${r?.slug}/dashboard/settings/organization`)},children:[(0,X.jsx)(wa,{className:`mr-2 h-4 w-4`}),Z(`auth.organization-selector.settings`)]})]})]})]})]})})]}),(0,X.jsx)(Pc,{showNewOrgDialog:d,setShowNewOrgDialog:f})]})}var Nc=lt({name:H().min(1),slug:H().min(1)}),Pc=({showNewOrgDialog:e,setShowNewOrgDialog:t})=>{let n=l({resolver:pn(Nc),defaultValues:{name:``,slug:``}}),{client:r,session:i,refetchSession:a}=z(),{refetch:o}=r.useListOrganizations(),s=c(),u=async e=>{let{data:c,error:l}=await r.organization.create({name:e.name,slug:e.slug,userId:i?.user.id||``});if(l||!c){J.error(Z(`auth.organization-selector.create.error`),{description:l?.message??Z(`auth.organization-selector.create.error.retry`)});return}let{error:u}=await r.organization.update({organizationId:c.id,data:{metadata:{locales:[jc]}}});u?J.warning(Z(`auth.organization-selector.create.warning`),{description:Z(`auth.organization-selector.create.warning.description`)}):J.success(Z(`auth.organization-selector.create.success`)),await a(),o(),t(!1),n.reset(),s(`/${c.slug}/dashboard`)};return(0,X.jsx)(ar,{open:e,onOpenChange:t,children:(0,X.jsxs)(pr,{className:`sm:max-w-106.25`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:Z(`auth.organization-selector.dialog.title`)}),(0,X.jsx)(_r,{children:Z(`auth.organization-selector.dialog.description`)})]}),(0,X.jsx)(_,{...n,children:(0,X.jsxs)(`form`,{onSubmit:n.handleSubmit(u),className:`flex w-full flex-col gap-4`,children:[(0,X.jsx)(h,{control:n.control,name:`name`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:Z(`auth.organization-selector.dialog.name.label`)}),(0,X.jsx)(W,{id:`name`,placeholder:Z(`auth.organization-selector.dialog.name.placeholder`),...e}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:n.control,name:`slug`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:Z(`auth.organization-selector.dialog.slug.label`)}),(0,X.jsx)(W,{id:`slug`,placeholder:Z(`auth.organization-selector.dialog.slug.placeholder`),...e}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsxs)(lr,{children:[(0,X.jsx)(U,{type:`button`,variant:`outline`,disabled:n.formState.isSubmitting,onClick:()=>t(!1),children:Z(`common.cancel`)}),(0,X.jsx)(U,{type:`submit`,disabled:n.formState.isSubmitting,children:Z(`common.create`)})]})]})})]})})};function Fc(e){return e.permissionAnyOf?.length?{anyOf:e.permissionAnyOf}:e.permissionType?{type:e.permissionType,action:e.permissionAction??`list-view`}:null}var Ic=({children:e,className:t,...n})=>(0,X.jsx)(`div`,{className:q(`hidden h-full shrink-0 overflow-hidden pt-3 transition-all duration-200 ease-linear md:block md:w-13 md:px-1 lg:w-65 lg:px-3`,t),...n,children:e}),Lc=({children:e,className:t,...n})=>(0,X.jsx)(`div`,{className:q(`h-full`,t),...n,children:e}),Rc=({children:e,className:t,icon:n,expanded:r,...i})=>r?(0,X.jsxs)(`span`,{...i,className:q(`flex h-9 w-full cursor-pointer items-center justify-start gap-3 rounded-full px-3 text-foreground transition-colors hover:bg-foreground
2/5`,t),children:[n&&(0,X.jsx)(`span`,{className:`flex shrink-0 items-center justify-center`,children:Y.cloneElement(n,{className:`size-5 lg:size-4.5`})}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] tracking-normal`,children:e})]}):(0,X.jsxs)(Pn,{children:[(0,X.jsx)(dr,{render:r=>(0,X.jsxs)(`span`,{...r,...i,className:q(`flex h-9 w-full cursor-pointer items-center rounded-full px-3 text-foreground transition-colors hover:bg-foreground/5`,`md:justify-center md:px-0 lg:justify-start lg:gap-3 lg:px-3`,t,r.className),children:[n&&(0,X.jsx)(`span`,{className:`flex shrink-0 items-center justify-center`,children:Y.cloneElement(n,{className:`size-5 lg:size-4.5`})}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] tracking-normal md:hidden lg:block`,children:e})]})}),(0,X.jsx)(Gn,{side:`right`,sideOffset:8,className:`lg:hidden`,children:e})]});Rc.displayName=`SidebarLink`;var zc=`sidebar_state`,Bc=604800,Vc=`b`,Hc=(0,Y.createContext)(null);function Uc(){let e=(0,Y.useContext)(Hc);if(!e)throw Error(`useSidebar must be used within a SidebarProvider.`);return e}var Wc=(0,Y.forwardRef)(({defaultOpen:e=!0,open:t,onOpenChange:n,className:r,style:i,children:a,...o},s)=>{let c=Fn(),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(e),p=t??d,m=(0,Y.useCallback)(e=>{let t=typeof e==`function`?e(p):e;n?n(t):f(t),document.cookie=`${zc}=${t}; path=/; max-age=${Bc}`},[n,p]),h=(0,Y.useCallback)(()=>c?u(e=>!e):m(e=>!e),[c,m,u]);(0,Y.useEffect)(function(){let e=e=>{e.key===Vc&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),h())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[h]);let g=p?`expanded`:`collapsed`,_=(0,Y.useMemo)(()=>({state:g,open:p,setOpen:m,isMobile:c,openMobile:l,setOpenMobile:u,toggleSidebar:h}),[g,p,m,c,l,u,h]);return(0,X.jsx)(Hc.Provider,{value:_,children:(0,X.jsx)(`div`,{"data-state":g,className:q(`h-full w-full`,r),ref:s,style:i,...o,children:a})})});Wc.displayName=`SidebarProvider`;function Gc(e){return(0,X.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,xmlnsXlink:`http://www.w3.org/1999/xlink`,viewBox:`0 0 395 62`,...e,children:[(0,X.jsx)(`path`,{fill:`#F1B04F`,d:`M119.8,37.7c0-0.4-0.1-0.9-0.1-1.1c0-0.3-0.1-0.7-0.1-1c0-0.3-0.1-0.7-0.2-1c-0.1-0.3-0.1-0.7-0.2-0.9
3        c-0.1-0.2-0.2-0.6-0.2-0.9c-0.1-0.2-0.2-0.7-0.3-1c-0.1-0.3-0.2-0.7-0.3-0.9c-0.1-0.2-0.2-0.5-0.3-0.7c-0.1-0.2-0.3-0.7-0.5-1
4        c-0.2-0.3-0.4-0.8-0.5-1c-0.1-0.2-0.3-0.6-0.5-0.8c-0.1-0.2-0.4-0.6-0.6-0.9c-0.2-0.3-0.5-0.7-0.7-1c-0.2-0.3-0.5-0.7-0.7-0.9
5        c-0.2-0.2-0.5-0.6-0.7-0.8c-0.2-0.3-0.7-0.7-1-1c-0.3-0.3-0.8-0.8-1-1c-0.3-0.2-0.7-0.6-0.9-0.8c-0.2-0.2-0.6-0.5-0.9-0.7
6        c-0.2-0.2-0.6-0.4-0.7-0.6c-0.2-0.1-0.6-0.4-0.8-0.6c-0.3-0.2-1-0.7-1.6-1c-0.6-0.4-1.4-0.9-1.8-1.2c-0.4-0.3-1.1-0.7-1.4-1
7        c-0.3-0.3-0.8-0.6-1.1-0.8c-0.3-0.2-0.7-0.6-1-0.9c-0.3-0.3-0.7-0.7-0.9-0.9c-0.2-0.2-0.4-0.5-0.6-0.7c-0.1-0.2-0.4-0.5-0.5-0.6
8        c-0.1-0.2-0.2-0.4-0.3-0.5c-0.1-0.1-0.2-0.3-0.2-0.5c-0.1-0.1-0.2-0.4-0.2-0.5c-0.1-0.1-0.2-0.4-0.2-0.6c-0.1-0.2-0.1-0.4-0.2-0.6
9        c0-0.1-0.1-0.4-0.1-0.5c0-0.1-0.1-0.4-0.1-0.7c0-0.3,0-0.5,0-0.8c0-0.2,0-0.6,0.1-0.7c0-0.2,0.1-0.4,0.1-0.6c0-0.2,0.2-0.7,0.3-1.1
10        c0.1-0.4,0.6-1.8,0.9-3c0.4-1.3,0.7-2.3,0.7-2.3s0,0,0,0c0,0-1,0.5-2.2,1.2c-1.2,0.6-2.4,1.3-2.7,1.4S95.2,2.5,95,2.6
11        S94.4,3,94.2,3.2c-0.2,0.2-0.5,0.4-0.7,0.5C93.3,3.8,93,4,92.8,4.2c-0.3,0.2-0.6,0.5-0.9,0.7c-0.2,0.2-0.6,0.6-0.9,0.8
12        c-0.3,0.3-0.6,0.7-0.8,0.9c-0.2,0.2-0.5,0.6-0.7,0.8C89.4,7.6,89,8,88.9,8.2c-0.2,0.2-0.4,0.6-0.6,0.8c-0.1,0.2-0.4,0.6-0.5,0.8
13        c-0.2,0.3-0.4,0.6-0.5,0.8c-0.1,0.2-0.3,0.6-0.5,0.9c-0.2,0.3-0.4,0.8-0.5,1c-0.1,0.2-0.3,0.6-0.4,0.9c-0.1,0.3-0.3,0.8-0.4,1.1
14        c-0.1,0.3-0.3,0.8-0.4,1.1c-0.1,0.3-0.2,0.8-0.3,1.1c-0.1,0.3-0.2,0.9-0.3,1.2c-0.1,0.4-0.2,0.9-0.2,1.3c0,0.3-0.1,0.8-0.2,1.2
15        c0,0.3-0.1,0.9-0.1,1.1c0,0.3-0.1,0.8-0.1,1c0,0.3,0,0.9,0,1.5c0,0.6,0,1.4,0,1.9c0,0.5,0.1,1.2,0.1,1.6c0,0.3,0.1,0.9,0.1,1.3
16        c0,0.3,0.1,0.8,0.1,1.1c0,0.3,0.1,0.5,0.1,0.6c0,0-0.1-0.1-0.3-0.3c-0.1-0.2-0.4-0.4-0.5-0.6c-0.1-0.2-0.3-0.4-0.4-0.6
17        c-0.1-0.2-0.3-0.5-0.4-0.7c-0.1-0.2-0.3-0.6-0.4-0.8c-0.1-0.2-0.3-0.6-0.3-0.8c-0.1-0.2-0.2-0.6-0.3-0.8c-0.1-0.2-0.2-0.6-0.2-0.8
18        c-0.1-0.3-0.1-0.6-0.2-0.9c0-0.2-0.1-0.6-0.1-0.8c0-0.2-0.1-0.7-0.1-1c0-0.4,0-1,0-2.7c0-1.2,0-2.4,0.1-2.7l0-0.5l-2.3,2.3
19        c-1.3,1.3-2.5,2.5-2.6,2.7c-0.2,0.2-0.4,0.4-0.5,0.6c-0.1,0.1-0.3,0.3-0.4,0.5c-0.1,0.2-0.4,0.5-0.5,0.7c-0.2,0.2-0.5,0.6-0.6,0.9
20        c-0.2,0.3-0.5,0.7-0.6,1c-0.1,0.3-0.4,0.6-0.5,0.9c-0.1,0.2-0.3,0.6-0.4,0.9c-0.1,0.3-0.3,0.7-0.4,0.9c-0.1,0.3-0.3,0.7-0.4,0.9
21        c-0.1,0.3-0.3,0.7-0.3,1c-0.1,0.3-0.2,0.6-0.2,0.8c-0.1,0.2-0.1,0.5-0.2,0.8c-0.1,0.3-0.
211,0.7-0.2,0.9c-0.1,0.3-0.1,0.7-0.2,1.1
22        c-0.1,0.3-0.1,0.8-0.2,1.1c0,0.3-0.1,0.7-0.1,0.9c0,0.2-0.1,0.6-0.1,0.9c0,0.2,0,0.8-0.1,1.3c0,0.6,0,1.3,0,1.9c0,0.5,0,1.2,0.1,1.5
23        c0,0.3,0.1,0.7,0.1,0.9s0.1,0.6,0.1,0.8c0,0.2,0.1,0.6,0.2,0.9c0.1,0.2,0.1,0.6,0.2,0.8c0.1,0.2,0.2,0.6,0.2,0.8
24        c0.1,0.2,0.2,0.6,0.3,0.9c0.1,0.3,0.3,0.7,0.4,1c0.1,0.3,0.3,0.7,0.4,0.9c0.1,0.2,0.3,0.6,0.5,0.9c0.2,0.3,0.4,0.8,0.5,1
25        c0.1,0.2,0.4,0.7,0.6,1c0.2,0.3,0.5,0.8,0.7,1c0.2,0.3,0.5,0.6,0.6,0.8c0.1,0.2,0.4,0.5,0.6,0.7c0.2,0.2,0.5,0.5,0.7,0.8
26        c0.2,0.2,0.6,0.6,0.8,0.8c0.2,0.2,0.6,0.5,0.8,0.7c0.2,0.2,0.6,0.5,0.8,0.7c0.2,0.2,0.6,0.4,0.8,0.6c0.2,0.1,0.5,0.4,0.8,0.5
27        c0.2,0.2,0.6,0.4,0.8,0.5c0.2,0.1,0.5,0.3,0.7,0.4c0.2,0.1,0.6,0.3,0.9,0.5c0.3,0.1,0.7,0.4,1,0.5c0.3,0.1,0.7,0.3,1,0.4
28        c0.3,0.1,0.7,0.3,1,0.4c0.3,0.1,0.7,0.3,1,0.4c0.3,0.1,0.8,0.3,1.2,0.4c0.3,0.1,0.9,0.2,1.1,0.3c0.3,0.1,0.7,0.2,1,0.2
29        c0.2,0.1,0.6,0.1,0.8,0.2c0.2,0,0.5,0.1,0.7,0.1c0.2,0,0.6,0.1,0.8,0.1c0.2,0,0.6,0.1,0.9,0.1c0.2,0,0.7,0.1,1,0.1
30        c0.3,0,0.8,0,1.2,0s0.9,0,1.2,0c0.3,0,0.7-0.1,1-0.1c0.2,0,0.6-0.1,0.9-0.1c0.3,0,0.7-0.1,0.9-0.1c0.3,0,0.7-0.1,0.9-0.2
31        c0.2-0.1,0.7-0.2,1.1-0.3c0.4-0.1,0.9-0.2,1.1-0.3c0.3-0.1,0.7-0.2,1-0.3c0.3-0.1,0.8-0.3,1.1-0.4c0.3-0.1,0.8-0.3,1-0.4
32        c0.3-0.1,0.7-0.3,0.9-0.4c0.3-0.1,0.7-0.3,0.9-0.5c0.2-0.1,0.6-0.3,0.8-0.5c0.2-0.1,0.6-0.3,0.8-0.5c0.2-0.1,0.6-0.4,0.8-0.6
33        c0.2-0.2,0.6-0.4,0.7-0.5c0.2-0.1,0.4-0.3,0.6-0.5c0.2-0.1,0.5-0.4,0.7-0.6c0.2-0.2,0.6-0.5,0.8-0.8c0.3-0.3,0.7-0.7,0.9-0.9
34        s0.6-0.6,0.7-0.8c0.2-0.2,0.5-0.6,0.7-0.8s0.5-0.6,0.6-0.8c0.1-0.2,0.4-0.5,0.5-0.8c0.2-0.3,0.4-0.6,0.5-0.8
35        c0.1-0.2,0.3-0.6,0.5-0.8c0.1-0.3,0.3-0.7,0.5-0.9c0.1-0.2,0.3-0.6,0.4-0.8c0.1-0.2,0.2-0.6,0.3-0.8c0.1-0.2,0.2-0.6,0.3-0.8
36        c0.1-0.3,0.2-0.7,0.3-1c0.1-0.3,0.2-0.7,0.3-1c0.1-0.3,0.2-0.7,0.2-0.9c0-0.2,0.1-0.7,0.2-0.9c0-0.3,0.1-0.7,0.1-1
37        c0-0.3,0.1-0.7,0.1-0.9c0-0.2,0-0.7,0-1C119.8,38.6,119.8,38,119.8,37.7z M114.4,44.1c-0.1,0.2-0.2,0.5-0.3,0.7
38        c-0.1,0.3-0.3,0.6-0.4,0.9c-0.1,0.2-0.3,0.6-0.5,0.9c-0.1,0.3-0.3,0.6-0.4,0.8c-0.1,0.2-0.3,0.4-0.4,0.6c-0.1,0.2-0.4,0.5-0.5,0.8
39        l-0.2,0.2c-0.2,0.2-0.3,0.4-0.4,0.6c-0.1,0.2-0.4,0.4-0.6,0.6c-0.2,0.2-0.5,0.6-0.8,0.8c-0.3,0.3-0.7,0.6-0.9,0.8
40        c-0.2,0.2-0.6,0.5-0.7,0.6l-0.3,0.2c-0.2,0.1-0.3,0.3-0.5,0.3c-0.2,0.1-0.5,0.4-0.8,0.5c-0.2,0.1-0.6,0.4-0.8,0.5
41        c-0.2,0.1-0.6,0.3-0.8,0.4l-0.2,0.1c-0.2,0.1-0.4,0.2-0.5,0.3c-0.2,0.1-0.5,0.3-0.8,0.4c-0.3,0.1-0.7,0.3-0.9,0.4l-0.2,0.1
42        c-0.3,0.1-0.6,0.2-0.8,0.3c-0.3,0.1-0.8,0.2-1,0.3c-0.3,0.1-0.6,0.2-0.9,0.2l-1.1,0.2c-0.2,0-0.4,0.1-0.6,0.1c-0.2,0-0.7,0.1-1,0.1
43        c-0.3,0-0.9,0.1-1.2,0.1c-0.5,0-0.9,0-1.4,0c-0.4,0-0.8-0.1-1.1-0.1c-0.2,0-0.5-0.1-0.8-0.1l-0.1,0c-0.3,0-0.7-0.1-1-0.2
44        c-0.3-0.1-0.7-0.1-1-0.2c-0.2,0-0.7-0.1-0.9-0.2S89,56.1,88.7,56c-0.3-0.1-0.8-0.2-1.1-0.3c-0.3-0.1-0.7-0.2-0.9-0.3
45        c-0.3-0.1-0.7-0.3-0.9-0.4c-0.3-0.1-0.7-0.3-0.9-0.4c-0.2-0.1-0.5-0.3-0.7-0.4c-0.2-0.1-0.5-0.3-0.7-0.4c-0.2-0.1-0.6-0.3-0.8-0.5
46        l-0.8-0.6c-0.2-0.1-0.5-0.4-0.7-0.5c-0.2-0.1-0.4-0.4-0.6-0.5c-0.2-0.1-0.6-0.5-0.9-0.8c-0.3-0.3-0.7-0.8-0.9-1
47        c-0.2-0.2-0.5-0.6-0.7-0.8c-0.2-0.2-0.4-0.6-0.6-0.9c-0.1-0.2-0.3-0.5-0.4-0.7c-0.1-0.2-0.3-0.5-0.4-0.7c-0.1-0.2-0.3-0.6-0.4-0.8
48        c-0.1-0.2-0.2-0.4-0.3-0.6l-0.2-0.6c-0.1-0.2-0.1-0.4-0.2-0.5c-0.1-0.3-0.2-0.7-0.3-0.9c-0.1-0.3-0.2-0.6-0.2-0.8
49        c-0.1-0.2-0.1-0.5-0.2-0.8c0-0.2-0.1-0.6-0.1-0.8c0-0.2,0-0.4-0.1-0.6l0-0.2c0-0.1,0-0.4,0-0.8l0-0.7c0-0.7,0-1.3,0-1.8
50        c0-0.4,0.1-1,0.1-1.3l0-0.2c0-0.3,0.1-0.6,0.1-0.8c0-0.2,0.1-0.6,0.1-0.9c0.1-0.3,0.1-0.7,0.2-0.9c0.1-0.2,0.1-0.6,0.2-0.8
51        c0.1-0.2,0.2-0.6,0.3-0.9c0.1-0.3,0.2-0.7,0.3-0.9l0.3-0.8c0.1-0.2,0.3-0.6,0.4-0.9c0.2-0.3,0.4-0.8,0.5-1c0.1-0.1,0.2-0.4,0.3-0.6
52        l0.2,0.7c0.1,0.3,0.3,0.8,0.4,1.1c0.1,0.3,0.4,0.8,0.5,1.2c0.2,0.4,0.5,0.9,0.6,1.1c0.1,0.2,0.3,0.5,0.5,0.8
53        c0.1,0.2,0.4,0.5,0.6,0.8c0.2,0.2,0.6,0.7,0.9,0.9c0.3,0.3,0.7,0.7,0.9,0.8c0.2,0.1,0.4,0.3,0.7,0.5l0.1,0.1c0.3,0.2,0.7,0.4,1,0.6
54        c0,0,0.1,0,0.1,0c1.6,1,4.5,1.7,6,2c-0.4-1.8-0.8-4.6-1-5.8c0-0.1,0-0.2,0-0.2c0-0.3-0.1-0.4-0.1-0.4l-0.1-0.8
55        c0-0.3-0.1-0.8-0.1-1.1l0-0.1c0-0.3-0.1-0.7-0.1-0.9l0-0.1c0-0.3-0.1-0.7-0.1-1.1c0-0.4-0.1-1.2-0.1-1.9c0-0.8,0-1.5,0-2
56        c0-0.4,0.1-1,0.1-1.4c0-0.4,0.1-0.9,0.1-1.2c0-0.3,0.1-0.7,0.1-1c0-0.2,0.1-0.6,0.2-0.9c0.1-0.3,0.2-0.7,0.2-1
57        c0.1-0.3,0.2-0.8,0.3-1c0.1-0.3,0.2-0.7,0.3-0.9l0.3-0.8c0-0.1,0.1-0.3,0.2-0.4l0.1-0.3c0.1-0.2,0.3-0.6,0.4-0.8
58        c0.1-0.2,0.2-0.4,0.3-0.6l0.2-0.3c0.1-0.2,0.3-0.4,0.4-0.6c0.1-0.2,0.3-0.5,0.5-0.7c0.1-0.2,0.4-0.6,0.6-0.8
59        c0.2-0.2,0.5-0.5,0.6-0.7c0.1-0.2,0.5-0.5,0.7-0.8l0.2-0.2c0,0.1,0,0.3,0,0.4c0,0.2,0.1,0.5,0.1,0.7c0,0.1,0.1,0.2,0.1,0.4l0.1,0.3
60        c0,0.2,0.1,0.5,0.2,0.7c0.1,0.2,0.2,0.4,0.2,0.7l0.1,0.2c0.
601,0.3,0.3,0.7,0.5,1c0.1,0.3,0.4,0.8,0.5,1c0.1,0.2,0.4,0.6,0.5,0.8
61        c0.1,0.2,0.4,0.5,0.6,0.8l0.2,0.2c0.2,0.2,0.4,0.4,0.5,0.6c0.2,0.2,0.6,0.7,1,1c0.3,0.3,0.8,0.8,1,1l0.9,0.7
62        c0.3,0.2,0.7,0.6,1.1,0.8c0.3,0.2,0.9,0.6,1.2,0.9c0.2,0.1,0.5,0.3,0.8,0.5l2.3,1.5c0.2,0.1,0.5,0.3,0.7,0.5l0.8,0.6
63        c0.2,0.1,0.5,0.4,0.8,0.6l0.9,0.8c0.3,0.2,0.7,0.6,0.9,0.9c0.2,0.3,0.6,0.6,0.7,0.8c0.2,0.2,0.4,0.4,0.6,0.7
64        c0.2,0.2,0.4,0.6,0.6,0.8c0.1,0.2,0.4,0.6,0.6,0.8c0.2,0.3,0.4,0.7,0.6,1c0.1,0.3,0.4,0.6,0.5,0.9c0.1,0.3,0.3,0.6,0.4,0.8
65        c0.1,0.2,0.2,0.5,0.3,0.8c0.1,0.2,0.2,0.6,0.3,0.9c0.1,0.3,0.2,0.7,0.3,1c0.1,0.3,0.2,0.7,0.2,0.9c0.1,0.3,0.1,0.7,0.1,0.9
66        c0,0.1,0.1,0.3,0.1,0.5l0,0.3c0,0.3,0.1,0.7,0.1,1.5c0,0.7,0,1.2,0,1.4l0,0.4c0,0.2,0,0.4-0.1,0.5c0,0.3-0.1,0.8-0.2,1.1
67        c-0.1,0.3-0.2,0.9-0.3,1.2c-0.1,0.3-0.2,0.8-0.3,1L114.4,44.1z`}),(0,X.jsx)(`path`,{className:`fill-foreground`,d:`M22.4,55.8c-2.9,0-5.8-0.6-8.6-1.8c-2.8-1.2-5.2-2.8-7.1-4.7l-1.4-1.4L9,44.2l1.4,1.5c1.4,1.5,3.2,2.7,5.3,3.6
68        c2.2,0.9,4.4,1.3,6.6,1.3c3.5,0,6.3-0.7,8.3-2.1c1.8-1.3,2.7-2.9,2.7-5.1c0-1.7-0.4-3-1.2-4c-0.9-1.2-2-2-3.3-2.6
69        c-1.5-0.7-3.6-1.5-6.3-2.3c-2.9-0.9-5.3-1.8-7-2.5c-2-0.9-3.7-2.3-5-4c-1.4-1.8-2.2-4.2-2.2-7.1c0-3.5,1.6-6.4,4.5-8.4
70        c2.7-1.9,6.4-2.9,10.8-2.9c2.1,0,4.3,0.3,6.4,0.9c2.2,0.6,4.1,1.4,5.7,2.5l1.7,1.1l-2.7,4.3l-1.7-1.1c-1.2-0.8-2.6-1.3-4.3-1.8
71        c-1.7-0.5-3.4-0.7-5.1-0.7c-3.2,0-5.8,0.6-7.7,1.9c-1.6,1.1-2.4,2.5-2.4,4.3c0,1.7,0.4,3,1.2,3.9c0.9,1.1,2,1.9,3.2,2.5
72        c1.4,0.6,3.5,1.3,6.2,2.2c3,0.9,5.3,1.8,7.1,2.6c2,0.9,3.7,2.2,5,4c1.5,1.8,2.2,4.3,2.2,7.2c0,2.5-0.7,4.7-2.1,6.7
73        c-1.4,1.9-3.3,3.3-5.8,4.3C28.2,55.3,25.5,55.8,22.4,55.8z`}),(0,X.jsx)(`polygon`,{className:`fill-foreground`,points:`58.9,55.6 53.7,55.6 53.7,15.1 39.4,15.1 39.4,9.9 73.2,9.9 73.2,15.1 58.9,15.1`}),(0,X.jsx)(`path`,{className:`fill-foreground`,d:`M159.7,55.6h-2.5l-10.6-14.5c-1.1,0.1-2.1,0.1-2.9,0.1h-11v14.3h-5.2V9.9h16.1c5.5,0,9.9,1.4,13.1,4.1
74        c3.2,2.7,4.9,6.6,4.9,11.5c0,4-1.1,7.4-3.3,10.1c-1.6,1.9-3.7,3.4-6.3,4.4l9.1,12.5L159.7,55.6z M132.8,36.1h11
75        c4.2,0,7.4-0.9,9.6-2.8c2.1-1.8,3.2-4.4,3.2-7.9c0-3.3-1-5.8-3.2-7.6c-2.2-1.8-5.4-2.8-9.6-2.8h-11V36.1z`}),(0,X.jsx)(`polygon`,{className:`fill-foreground`,points:`239.4,9.9 220.3,55.6 216.3,55.6 199.6,15.5 184.8,38.2 184.8,55.6 179.6,55.6 179.6,38.2 162.9,13
76        164.6,9.9 167.1,9.9 182.2,32.8 197.1,9.9 202.9,9.9 218.3,47.1 233.7,9.9`}),(0,X.jsx)(`polygon`,{className:`fill-foreground`,points:`273.1,55.6 242.2,55.6 242.2,9.9 272.3,9.9 272.3,15.1 247.4,15.1 247.4,29.6 269.6,29.6 269.6,34.7
77        247.4,34.7 247.4,50.4 273.1,50.4`}),(0,X.jsx)(`path`,{className:`fill-foreground`,d:`M312.3,55.6h-2.5l-10.6-14.5c-1.1,0.1-2.1,0.1-2.9,0.1h-11v14.3h-5.2V9.9h16.1c5.5,0,9.9,1.4,13.1,4.1
78        c3.2,2.7,4.9,6.6,4.9,11.5c0,4-1.1,7.4-3.3,10.1c-1.6,1.9-3.7,3.4-6.3,4.4l9.1,12.5L312.3,55.6z M285.4,36.1h11
79        c4.2,0,7.4-0.9,9.6-2.8c2.1-1.8,3.2-4.4,3.2-7.9c0-3.3-1-5.8-3.2-7.6c-2.2-1.8-5.4-2.8-9.6-2.8h-11V36.1z`}),(0,X.jsx)(`path`,{className:`fill-foreground`,d:`M333.9,55.8c-2.9,0-5.8-0.6-8.6-1.8c-2.8-1.2-5.2-2.8-7.1-4.7l-1.4-1.4l3.7-3.7l1.4,1.5
80        c1.4,1.5,3.2,2.7,5.3,3.6c2.2,0.9,4.4,1.3,6.6,1.3c3.5,0,6.3-0.7,8.3-2.1c1.8-1.3,2.7-2.9,2.7-5.1c0-1.7-0.4-3-1.2-4
81        c-0.9-1.2-2-2-3.3-2.6c-1.5-0.7-3.6-1.5-6.3-2.3c-2.9-0.9-5.3-1.7-7-2.5c-2-1-3.7-2.3-5-4c-1.4-1.8-2.2-4.2-2.2-7.1
82        c0-3.5,1.6-6.4,4.5-8.4c2.7-1.9,6.4-2.9,10.8-2.9c2.1,0,4.3,0.3,6.4,0.9c2.2,0.6,4.1,1.4,5.7,2.5l1.7,1.1l-2.7,4.3l-1.7-1.1
83        c-1.2-0.8-2.6-1.3-4.3-1.8c-1.7-0.5-3.4-0.7-5.1-0.7c-3.2,0-5.8,0.6-7.7,1.9c-1.6,1.1-2.4,2.5-2.4,4.3c0,1.7,0.4,3,1.2,3.9
84        c0.9,1.1,1.9,1.9,3.2,2.5c1.5,0.6,3.6,1.4,6.2,2.2c3,0.9,5.3,1.8,7.1,2.6c2,0.9,3.7,2.2,5,4c1.5,1.8,2.2,4.3,2.2,7.2
85        c0,2.5-0.7,4.7-2.1,6.7c-1.4,1.9-3.3,3.3-5.8,4.3C339.8,55.3,337,55.8,333.9,55.8z`}),(0,X.jsx)(`polygon`,{className:`fill-foreground`,points:`388.6,55.6 357.3,55.6 357.3,9.9 387.8,9.9 387.8,15.1 362.6,15.1 362.6,29.6 385,29.6 385,34.7
86        362.6,34.7 362.6,50.4 388.6,50.4`})]})}var Kc=({children:e,className:t,...n})=>{let{toggleSidebar:r}=Uc();return(0,X.jsxs)(`div`,{className:q(`grid h-13 w-full items-center justify-between transition-all duration-200 ease-linear`,`grid-cols-[auto_1fr] lg:grid-cols-[260px_1fr]`,t),...n,children:[(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-row items-center gap-2 overflow-visible px-3 md:justify-start md:px-3 lg:pr-2 lg:pl-6`,children:[(0,X.jsx)(`button`,{type:`button`,className:`flex size-11 shrink-0 items-center justify-center rounded-md text-foreground hover:bg-accent hover:text-accent-foreground md:hidden`,onClick:r,"aria-label":`Open navigation`,children:(0,X.jsx)(lo,{className:`size-5`})}),(0,X.jsx)(Gc,{className:`h-5.5 w-auto max-w-full transition-all duration-200 ease-linear md:max-w-none`,"aria-label":`Storyverse`})]}),e]})};Kc.displayName=`TopBar`;function qc(){let{session:e,signOut:t,activeOrganization:n}=z(),r=c(),{theme:i,setTheme:a}=qn();return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{nativeButton:!1,render:t=>(0,X.jsx)(`div`,{className:`flex flex-row items-center pr-4 hover:cursor-pointer`,...t,children:(0,X.jsxs)(rs,{className:`size-8`,children:[(0,X.jsx)(is,{src:e?.user.image||``}),(0,X.jsx)(as,{children:e?.user.name.charAt(0)})]})})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{className:`w-56`,align:`start`,children:[(0,X.jsx)(On,{children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`span`,{className:`font-semibold`,children:e?.user.name}),(0,X.jsx)(`span`,{className:`text-xs font-normal text-muted-foreground`,children:e?.user.email})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(st,{onClick:()=>r(`/${n?.slug}/dashboard/account`),children:[Z(`common.profile`),(0,X.jsx)(gt,{children:`⇧⌘P`})]})}),(0,X.jsx)(xe,{}),(0,X.jsx)(On,{children:Z(`common.theme`)}),(0,X.jsxs)(Ue,{children:[(0,X.jsxs)(st,{closeOnClick:!1,onClick:()=>a(`light`),children:[(0,X.jsx)(fa,{className:`size-4`}),Z(`common.light`),i===`light`&&(0,X.jsx)(Ea,{className:`ml-auto size-4`})]}),(0,X.jsxs)(st,{closeOnClick:!1,onClick:()=>a(`dark`),children:[(0,X.jsx)(si,{className:`size-4`}),Z(`common.dark`),i===`dark`&&(0,X.jsx)(Ea,{className:`ml-auto size-4`})]}),(0,X.jsxs)(st,{closeOnClick:!1,onClick:()=>a(`system`),children:[(0,X.jsx)(di,{className:`size-4`}),Z(`common.system`),i===`system`&&(0,X.jsx)(Ea,{className:`ml-auto size-4`})]})]}),(0,X.jsx)(xe,{}),(0,X.jsxs)(st,{onClick:async()=>{await t(),r(`/signin`)},children:[Z(`components.top.bar.user.sign.out`),(0,X.jsx)(gt,{children:`⇧⌘Q`})]})]})})]})}var Jc=(e,t)=>`/${e}/dashboard/${t}`,Yc=e=>(t,n=``)=>t.endsWith(`/dashboard/content`)?(new URLSearchParams(n).get(`tab`)??`content`)===e:!1,Xc=e=>e.getClientRects().length>0,Zc=(...e)=>{for(let t of e){let e=Array.from(document.querySelectorAll(t)).find(Xc);if(e)return e}return null},Qc=(...e)=>()=>Zc(...e),$c=()=>new Promise(e=>{window.requestAnimationFrame(()=>{window.requestAnimationFrame(()=>e())})});async function el(){if(document.querySelector(`[data-quick-help="world-spots-tab"]`)?.click(),await $c(),document.querySelector(`[data-quick-help="world-spot-properties"]`))return;let e=document.querySelector(`[data-quick-help="world-spot-select"]`);e?e.click():document.querySelector(`[data-quick-help="world-add-spot"]`)?.click(),await $c()}async function tl(){Zc(`[data-quick-help="field-schema-save"]`)||(Zc(`[data-quick-help="field-schema-add"]`)?.click(),await $c())}var nl=e=>async()=>{Zc(`[data-quick-help="world-settings-tab-${e}"]`)?.click(),await $c()};function rl(e){return[{id:`home`,title:Z(`features.quick-help.home.title`),description:Z(`features.quick-help.home.description`),path:Jc(e,`home`),matches:e=>e.endsWith(`/dashboard/home`),steps:[{target:`[data-quick-help="page-header"]`,title:Z(`features.quick-help.home.welcome.title`),content:Z(`features.quick-help.home.welcome.content`),placement:`bottom-start`},{target:`[data-quick-help="home-create-event"]`,title:Z(`features.quick-help.home.create-event.title`),content:Z(`features.quick-help.home.create-event.content`),placement:`bottom-end`},{target:Qc(`[data-quick-help="home-worlds"]`,`[data-quick-help="page-content"]`),title:Z(`features.quick-help.home.open-world.title`),content:Z(`features.quick-help.home.open-world.content`),placement:`top-start`},{target:Qc(`[data-quick-help="home-events"]`,`[data-quick-help="page-content"]`),title:Z(`features.quick-help.home.calendar.title`),content:Z(`features.quick-help.home.calendar.content`),placement:`top-start`},{target:`[data-quick-help="dashboard-navigation"]`,title:Z(`features.quick-help.home.navigation.title`),content:Z(`features.quick-help.home.navigation.content`),placement:`right-start`}]},{id:`worlds`,title:Z(`features.quick-help.worlds.title`),description:Z(`features.quick-help.worlds.description`),path:Jc(e,`worlds`),matches:e=>e.endsWith(`/dashboard/worlds`),steps:[{target:`[data-quick-help="page-header"]`,title:Z(`features.quick-help.worlds.overview.title`),content:Z(`features.quick-help.worlds.overview.content`),placement:`bottom-start`},{target:Qc(`[data-quick-help="create-world"]`,`[data-quick-help="page-header"]`),title:Z(`features.quick-help.worlds.create.title`),content:Z(`features.quick-help.worlds.create.content`),placement:`bottom-end`},{target:`[data-quick-help="page-content"]`,title:Z(`features.quick-help.worlds.manage.title`),content:Z(`features.quick-help.worlds.manage.content`),placement:`top`},{target:`[data-quick-help="help-button"]`,title:Z(`features.quick-help.worlds.editor.title`),content:Z(`features.quick-help.worlds.editor.content`),placement:`bottom-end`}]},{id:`events`,title:Z(`features.quick-help.events.title`),description:Z(`features.quick-help.events.description`),path:Jc(e,`events`),matches:e=>e.endsWith(`/dashboard/events`),steps:[{target:`[data-quick-help="page-header"]`,title:Z(`features.quick-help.events.overview.title`),content:Z(`features.quick-help.events.overview.content`),placement:`bottom-start`},{target:Qc(`[data-quick-help="create-event"]`,`[data-quick-help="page-header"]`),title:Z(`features.quick-help.events.create.title`),content:Z(`features.quick-help.events.create.content`),placement:`bottom-end`},{target:`[data-quick-help="page-content"]`,title:Z(`features.quick-help.events.manage.title`),content:Z(`features.quick-help.events.manage.content`),placement:`top`}]},{id:`create-event`,title:Z(`features.quick-help.create-event.title`),description:Z(`features.quick-help.create-event.description`),path:Jc(e,`events/create`),matches:e=>e.endsWith(`/dashboard/events/create`),steps:[{target:`[data-quick-help="event-type"]`,title:Z(`features.quick-help.create-event.type.title`),content:Z(`features.quick-help.create-event.type.content`),placement:`bottom-start`},{target:`[data-quick-help="event-details"]`,title:Z(`features.quick-help.create-event.details.title`),content:Z(`features.quick-help.create-event.details.content`),placement:`right-start`},{target:`[data-quick-help="event-access"]`,title:Z(`features.quick-help.create-event.access.title`),content:Z(`features.quick-help.create-event.access.content`),placement:`left-start`},{target:`[data-quick-help="event-actions"]`,title:Z(`features.quick-help.create-event.actions.title`),content:Z(`features.quick-help.create-event.actions.content`),placement:`bottom-end`}]},{id:`world-editor`,title:Z(`features.quick-help.world-editor.title`),description:Z(`features.quick-help.world-editor.description`),matches:e=>/\/dashboard\/worlds\/[^/]+\/edit$/.test(e),steps:[{target:`[data-quick-help="world-spaces"]`,title:Z(`features.quick-help.world-editor.spaces.title`),content:Z(`features.quick-help.world-editor.spaces.content`),placement:`right-start`},{target:`[data-quick-help="world-canvas"]`,title:Z(`features.quick-help.world-editor.canvas.title`),content:Z(`features.quick-help.world-editor.canvas.content`),placement:`top`},{target:`[data-quick-help="world-side-panel"]`,title:Z(`features.quick-help.world-editor.side-panel.title`),content:Z(`features.quick-help.world-editor.side-panel.content`),placement:`left-start`},{target:`[data-quick-help="world-spots-tab"]`,title:Z(`features.quick-help.world-editor.spots-tab.title`),content:Z(`features.quick-help.world-editor.spots-tab.content`),placement:`left-start`},{target:Qc(`[data-quick-help="world-add-spot"]`,`[data-quick-help="world-spots-tab"]`),title:Z(`features.quick-help.world-editor.add-spot.title`),content:Z(`features.quick-help.world-editor.add-spot.content`),placement:`left-start`},{target:Qc(`[data-quick-help="world-spot-properties"]`,`[data-quick-help="world-spots-panel"]`,`[data-quick-help="world-spots-tab"]`),title:Z(`features.quick-help.world-editor.spot-properties.title`),content:Z(`features.quick-help.world-editor.spot-properties.content`),placement:`left-start`,before:el},{target:`[data-quick-help="world-preview"]`,title:Z(`features.quick-help.world-editor.preview.title`),content:Z(`features.quick-help.world-editor.preview.content`),placement:`bottom-end`}
86,{target:`[data-quick-help="world-details"]`,title:Z(`features.quick-help.world-editor.details.title`),content:Z(`features.quick-help.world-editor.details.content`),placement:`bottom-end`},{target:`[data-quick-help="world-publish"]`,title:Z(`features.quick-help.world-editor.publish.title`),content:Z(`features.quick-help.world-editor.publish.content`),placement:`bottom-end`}]},{id:`content-collections`,title:Z(`features.quick-help.content-collections.title`),description:Z(`features.quick-help.content-collections.description`),path:`${Jc(e,`content`)}?tab=content`,matches:Yc(`content`),steps:[{target:`[data-quick-help="cms-tab-content"]`,title:Z(`features.quick-help.content-collections.overview.title`),content:Z(`features.quick-help.content-collections.overview.content`),placement:`bottom`},{target:Qc(`[data-quick-help="content-add-collection"]`,`[data-quick-help="content-collections-navigation"]`),title:Z(`features.quick-help.content-collections.add-collection.title`),content:Z(`features.quick-help.content-collections.add-collection.content`),placement:`right-start`},{target:Qc(`[data-quick-help="content-collection"]`,`[data-quick-help="content-collections-navigation"]`),title:Z(`features.quick-help.content-collections.fields.title`),content:Z(`features.quick-help.content-collections.fields.content`),placement:`right-start`},{target:Qc(`[data-quick-help="content-fields-dialog-button"]`,`[data-quick-help="content-collection"]`,`[data-quick-help="content-collections-navigation"]`),title:Z(`features.quick-help.content-collections.fields-dialog.title`),content:Z(`features.quick-help.content-collections.fields-dialog.content`),placement:`right-start`},{target:Qc(`[data-quick-help="content-create-item"]`,`[data-quick-help="content-workspace"]`),title:Z(`features.quick-help.content-collections.create-item.title`),content:Z(`features.quick-help.content-collections.create-item.content`),placement:`bottom-end`},{target:Qc(`[data-quick-help="content-item-editor-button"]`,`[data-quick-help="content-create-item"]`,`[data-quick-help="content-workspace"]`),title:Z(`features.quick-help.content-collections.item-editor.title`),content:Z(`features.quick-help.content-collections.item-editor.content`),placement:`left-start`},{target:`[data-quick-help="content-workspace"]`,title:Z(`features.quick-help.content-collections.workspace.title`),content:Z(`features.quick-help.content-collections.workspace.content`),placement:`left-start`}]},{id:`content-labels`,title:Z(`features.quick-help.content-labels.title`),description:Z(`features.quick-help.content-labels.description`),path:`${Jc(e,`content`)}?tab=labels`,matches:Yc(`labels`),steps:[{target:`[data-quick-help="cms-tab-labels"]`,title:Z(`features.quick-help.content-labels.overview.title`),content:Z(`features.quick-help.content-labels.overview.content`),placement:`bottom`},{target:Qc(`[data-quick-help="labels-add-collection"]`,`[data-quick-help="labels-navigation"]`),title:Z(`features.quick-help.content-labels.add-collection.title`),content:Z(`features.quick-help.content-labels.add-collection.content`),placement:`right-start`},{target:Qc(`[data-quick-help="labels-collection-details"]`,`[data-quick-help="content-workspace"]`),title:Z(`features.quick-help.content-labels.details.title`),content:Z(`features.quick-help.content-labels.details.content`),placement:`left-start`},{target:Qc(`[data-quick-help="labels-add-item"]`,`[data-quick-help="labels-source-items"]`,`[data-quick-help="content-workspace"]`),title:Z(`features.quick-help.content-labels.add-label.title`),content:Z(`features.quick-help.content-labels.add-label.content`),placement:`bottom-end`},{target:Qc(`[data-quick-help="labels-source-items"]`,`[data-quick-help="content-workspace"]`),title:Z(`features.quick-help.content-labels.source-values.title`),content:Z(`features.quick-help.content-labels.source-values.content`),placement:`top-start`}]},{id:`content-localization`,title:Z(`features.quick-help.content-localization.title`),description:Z(`features.quick-help.content-localization.description`),path:`${Jc(e,`content`)}?tab=localization`,matches:Yc(`localization`),steps:[{target:`[data-quick-help="cms-tab-localization"]`,title:Z(`features.quick-help.content-localization.overview.title`),content:Z(`features.quick-help.content-localization.overview.content`),placement:`bottom`},{target:Qc(`[data-quick-help="localization-add-language"]`,`[data-quick-help="localization-locales"]`),title:Z(`features.quick-help.content-localization.add-language.title`),content:Z(`features.quick-help.content-localization.add-language.content`),placement:`right-start`},{target:Qc(`[data-quick-help="content-language-dialog-button"]`,`[data-quick-help="localization-add-language"]`),title:Z(`features.quick-help.content-localization.language-dialog.title`),content:Z(`features.quick-help.content-localization.language-dialog.content`),placement:`top-end`},{target:Qc(`[data-quick-help="localization-locales"]`),title:Z(`features.quick-help.content-localization.select-language.title`),content:Z(`features.quick-help.content-localization.select-language.content`),placement:`right-start`},{target:Qc(`[data-quick-help="localization-content-translations"]`,`[data-quick-help="content-workspace"]`),title:Z(`features.quick-help.content-localization.content-translations.title`),content:Z(`features.quick-help.content-localization.content-translations.content`),placement:`left-start`},{target:Qc(`[data-quick-help="localization-label-translations"]`,`[data-quick-help="content-workspace"]`),title:Z(`features.quick-help.content-localization.label-translations.title`),content:Z(`features.quick-help.content-localization.label-translations.content`),placement:`left-start`},{target:`[data-quick-help="localization-tools"]`,title:Z(`features.quick-help.content-localization.tools.title`),content:Z(`features.quick-help.content-localization.tools.content`),placement:`bottom-end`}]},{id:`content-fields-dialog`,title:Z(`features.quick-help.content-fields-dialog.title`),description:Z(`features.quick-help.content-fields-dialog.description`),contextualOnly:!0,matches:()=>!1,steps:[{target:`[data-quick-help="field-schema-dialog"]`,title:Z(`features.quick-help.content-fields-dialog.overview.title`),content:Z(`features.quick-help.content-fields-dialog.overview.content`),placement:`center`},{target:`[data-quick-help="field-schema-add"]`,title:Z(`features.quick-help.content-fields-dialog.add-field.title`),content:Z(`features.quick-help.content-fields-dialog.add-field.content`),placement:`right-start`},{before:tl,target:Qc(`[data-quick-help="field-schema-list"]`,`[data-quick-help="field-schema-dialog"]`),title:Z(`features.quick-help.content-fields-dialog.order.title`),content:Z(`features.quick-help.content-fields-dialog.order.content`),placement:`right-start`},{target:Qc(`[data-quick-help="field-schema-settings"]`,`[data-quick-help="field-schema-dialog"]`),title:Z(`features.quick-help.content-fields-dialog.settings.title`),content:Z(`features.quick-help.content-fields-dialog.settings.content`),placement:`left-start`},{target:Qc(`[data-quick-help="field-schema-save"]`,`[data-quick-help="field-schema-dialog"]`),title:Z(`features.quick-help.content-fields-dialog.save.title`),content:Z(`features.quick-help.content-fields-dialog.save.content`),placement:`top-end`}]},{id:`content-item-editor`,title:Z(`features.quick-help.content-item-editor.title`),description:Z(`features.quick-help.content-item-editor.description`),contextualOnly:!0,matches:()=>!1,steps:[{target:Qc(`[data-quick-help="content-item-editor"]`),title:Z(`features.quick-help.content-item-editor.overview.title`),content:Z(`features.quick-help.content-item-editor.overview.content`),placement:`left-start`},{target:Qc(`[data-quick-help="content-item-details"]`),title:Z(`features.quick-help.content-item-editor.details.title`),content:Z(`features.quick-help.content-item-editor.details.content`),placement:`left-start`},{target:Qc(`[data-quick-help="content-item-fields"]`,`[data-quick-help="content-item-editor"]`),title:Z(`features.quick-help.content-item-editor.fields.title`),content:Z(`features.quick-help.content-item-editor.fields.content`),placement:`left-start`},{target:Qc(`[data-quick-help="content-item-save"]`),title:Z(`features.quick-help.content-item-editor.save.title`),content:Z(`features.quick-help.content-item-editor.save.content`),placement:`top-end`}]},{id:`content-language-dialog`,title:Z(`features.quick-help.content-language-dialog.title`),description:Z(`features.quick-help.content-language-dialog.description`),contextualOnly:!0,matches:()=>!1,steps:[{target:`[data-quick-help="language-dialog"]`,title:Z(`features.quick-help.content-language-dialog.overview.title`),content:Z(`features.quick-help.content-language-dialog.overview.content`),placement:`center`},{target:Qc(`[data-quick-help="language-picker"]`,`[data-quick-help="language-dialog"]`),title:Z(`features.quick-help.content-language-dialog.picker.title`),content:Z(`features.quick-help.content-language-dialog.picker.content`),placement:`left-start`},{target:Qc(`[data-quick-help="language-settings"]`,`[data-quick-help="language-dialog"]`),title:Z(`features.quick-help.content-language-dialog.settings.title`),content:Z(`features.quick-help.content-language-dialog.settings.content`),placement:`left-start`},{target:`[data-quick-help="language-dialog-locales"]`,title:Z(`features.quick-help.content-language-dialog.locales.title`),content:Z(`features.quick-help.content-language-dialog.locales.content`),placement:`right-start`},{target:`[data-quick-help="language-dialog-save"]`,title:Z(`features.quick-help.content-language-dialog.save.title`),content:Z(`features.quick-help.content-language-dialog.save.content`),placement:`top-end`}]},{id:`world-settings-dialog`,title:Z(`features.quick-help.world-settings-dialog.title`),description:Z(`features.quick-help.world-settings-dialog.description`),contextualOnly:!0,matches:()=>!1,steps:[{target:`[data-quick-help="world-settings-dialog"]`,title:Z(`views.world-properties.section.title`),content:Z(`features.quick-help.world-settings-dialog.overview.content`),placement:`center`},{before:nl(`details`),target:Qc(`[data-quick-help="world-settings-details"]`,`[data-quick-help="world-settings-dialog"]`),title:Z(`features.quick-help.world-settings-dialog.details.title`),content:Z(`features.quick-help.world-settings-dialog.details.content`),placement:`left-start`},{before:nl(`thumbnail`),target:Qc(`[data-quick-help="world-settings-thumbn
86ail"]`,`[data-quick-help="world-settings-dialog"]`),title:Z(`features.quick-help.world-settings-dialog.thumbnail.title`),content:Z(`features.quick-help.world-settings-dialog.thumbnail.content`),placement:`left-start`},{before:nl(`thumbnail`),target:Qc(`[data-quick-help="world-settings-capture-space"]`,`[data-quick-help="world-settings-thumbnail"]`,`[data-quick-help="world-settings-dialog"]`),title:Z(`features.quick-help.world-settings-dialog.capture.title`),content:Z(`features.quick-help.world-settings-dialog.capture.content`),placement:`left-start`},{before:nl(`collections`),target:Qc(`[data-quick-help="world-settings-cms-collections"]`,`[data-quick-help="world-settings-collections"]`,`[data-quick-help="world-settings-dialog"]`),title:Z(`features.quick-help.world-settings-dialog.cms-collections.title`),content:Z(`features.quick-help.world-settings-dialog.cms-collections.content`),placement:`left-start`},{before:nl(`collections`),target:Qc(`[data-quick-help="world-settings-label-collections"]`,`[data-quick-help="world-settings-collections"]`,`[data-quick-help="world-settings-dialog"]`),title:Z(`features.quick-help.world-settings-dialog.label-collections.title`),content:Z(`features.quick-help.world-settings-dialog.label-collections.content`),placement:`left-start`},{target:Qc(`[data-quick-help="world-settings-done"]`,`[data-quick-help="world-settings-dialog"]`),title:Z(`features.quick-help.world-settings-dialog.done.title`),content:Z(`features.quick-help.world-settings-dialog.done.content`),placement:`top-end`}]}]}function il(e,t,n=``){return e.find(e=>e.matches(t,n))}var al=Y.createContext(void 0);function ol(){let e=Y.useContext(al);if(e===void 0)throw Error(Et(53));return e}var sl=function(e){return e.scrollAreaCornerHeight=`--scroll-area-corner-height`,e.scrollAreaCornerWidth=`--scroll-area-corner-width`,e}({});function cl(e,t,n){if(!e)return 0;let r=getComputedStyle(e),i=n===`x`?`Inline`:`Block`;return n===`x`&&t===`margin`?parseFloat(r[`${t}InlineStart`])*2:parseFloat(r[`${t}${i}Start`])+parseFloat(r[`${t}${i}End`])}var ll=function(e){return e.orientation=`data-orientation`,e.hovering=`data-hovering`,e.scrolling=`data-scrolling`,e.hasOverflowX=`data-has-overflow-x`,e.hasOverflowY=`data-has-overflow-y`,e.overflowXStart=`data-overflow-x-start`,e.overflowXEnd=`data-overflow-x-end`,e.overflowYStart=`data-overflow-y-start`,e.overflowYEnd=`data-overflow-y-end`,e}({}),ul=function(e){return e.scrolling=`data-scrolling`,e.hasOverflowX=`data-has-overflow-x`,e.hasOverflowY=`data-has-overflow-y`,e.overflowXStart=`data-overflow-x-start`,e.overflowXEnd=`data-overflow-x-end`,e.overflowYStart=`data-overflow-y-start`,e.overflowYEnd=`data-overflow-y-end`,e}({}),dl={hasOverflowX:e=>e?{[ul.hasOverflowX]:``}:null,hasOverflowY:e=>e?{[ul.hasOverflowY]:``}:null,overflowXStart:e=>e?{[ul.overflowXStart]:``}:null,overflowXEnd:e=>e?{[ul.overflowXEnd]:``}:null,overflowYStart:e=>e?{[ul.overflowYStart]:``}:null,overflowYEnd:e=>e?{[ul.overflowYEnd]:``}:null,cornerHidden:()=>null},fl={x:0,y:0},pl={width:0,height:0},ml={xStart:!1,xEnd:!1,yStart:!1,yEnd:!1},hl={x:!1,y:!1,corner:!1},gl=Y.forwardRef(function(e,t){let{render:n,className:r,overflowEdgeThreshold:i,...a}=e,o=_l(i),s=xt(),c=dn(),l=dn(),{nonce:u,disableStyleElements:d}=we(),[f,p]=Y.useState(!1),[m,h]=Y.useState(!1),[g,_]=Y.useState(!1),[v,y]=Y.useState(!1),[b,x]=Y.useState(pl),[S,C]=Y.useState(pl),[w,T]=Y.useState(ml),[E,D]=Y.useState(hl),O=Y.useRef(null),k=Y.useRef(null),A=Y.useRef(null),j=Y.useRef(null),M=Y.useRef(null),N=Y.useRef(null),P=Y.useRef(null),F=Y.useRef(!1),I=Y.useRef(0),L=Y.useRef(0),ee=Y.useRef(0),te=Y.useRef(0),ne=Y.useRef(`vertical`),re=Y.useRef(fl),R=En(e=>{let t=e.x-re.current.x,n=e.y-re.current.y;re.current=e,n!==0&&(_(!0),c.start(500,()=>{_(!1)})),t!==0&&(h(!0),l.start(500,()=>{h(!1)}))}),ie=En(e=>{e.button===0&&(F.current=!0,I.current=e.clientY,L.current=e.clientX,ne.current=e.currentTarget.getAttribute(ll.orientation),k.current&&(ee.current=k.current.scrollTop,te.current=k.current.scrollLeft),M.current&&ne.current===`vertical`&&M.current.setPointerCapture(e.pointerId),N.current&&ne.current===`horizontal`&&N.current.setPointerCapture(e.pointerId))}),ae=En(e=>{if(!F.current)return;let t=e.clientY-I.current,n=e.clientX-L.current;if(k.current){let r=k.current.scrollHeight,i=k.current.clientHeight,a=k.current.scrollWidth,o=k.current.clientWidth;if(M.current&&A.current&&ne.current===`vertical`){let n=cl(A.current,`padding`,`y`),a=cl(M.current,`margin`,`y`),o=M.current.offsetHeight,s=t/(A.current.offsetHeight-o-n-a);k.current.scrollTop=ee.current+s*(r-i),e.preventDefault(),_(!0),c.start(500,()=>{_(!1)})}if(N.current&&j.current&&ne.current===`horizontal`){let t=cl(j.current,`padding`,`x`),r=cl(N.current,`margin`,`x`),i=N.current.offsetWidth,s=n/(j.current.offsetWidth-i-t-r);k.current.scrollLeft=te.current+s*(a-o),e.preventDefault(),h(!0),l.start(500,()=>{h(!1)})}}}),oe=En(e=>{F.current=!1,M.current&&ne.current===`vertical`&&M.current.releasePointerCapture(e.pointerId),N.current&&ne.current===`horizontal`&&N.current.releasePointerCapture(e.pointerId)});function z(e){y(e.pointerType===`touch`)}function se(e){if(z(e),e.pointerType!==`touch`){let t=It(O.current,e.target);p(t)}}let ce=Y.useMemo(()=>({scrolling:m||g,hasOverflowX:!E.x,hasOverflowY:!E.y,overflowXStart:w.xStart,overflowXEnd:w.xEnd,overflowYStart:w.yStart,overflowYEnd:w.yEnd,cornerHidden:E.corner}),[m,g,E.x,E.y,E.corner,w]),le={role:`presentation`,onPointerEnter:se,onPointerMove:se,onPointerDown:z,onPointerLeave(){p(!1)},style:{position:`relative`,[sl.scrollAreaCornerHeight]:`${b.height}px`,[sl.scrollAreaCornerWidth]:`${b.width}px`}},ue=$e(`div`,e,{state:ce,ref:[t,O],props:[le,a],stateAttributesMapping:dl}),de=Y.useMemo(()=>({handlePointerDown:ie,handlePointerMove:ae,handlePointerUp:oe,handleScroll:R,cornerSize:b,setCornerSize:x,thumbSize:S,setThumbSize:C,touchModality:v,cornerRef:P,scrollingX:m,setScrollingX:h,scrollingY:g,setScrollingY:_,hovering:f,setHovering:p,viewportRef:k,rootRef:O,scrollbarYRef:A,scrollbarXRef:j,thumbYRef:M,thumbXRef:N,rootId:s,hiddenState:E,setHiddenState:D,overflowEdges:w,setOverflowEdges:T,viewportState:ce,overflowEdgeThreshold:o}),[ie,ae,oe,R,b,S,v,m,h,g,_,f,p,s,E,w,ce,o]);return(0,X.jsxs)(al.Provider,{value:de,children:[!d&&tt.getElement(u),ue]})});function _l(e){if(typeof e==`number`){let t=Math.max(0,e);return{xStart:t,xEnd:t,yStart:t,yEnd:t}}return{xStart:Math.max(0,e?.xStart||0),xEnd:Math.max(0,e?.xEnd||0),yStart:Math.max(0,e?.yStart||0),yEnd:Math.max(0,e?.yEnd||0)}}var vl=Y.createContext(void 0);function yl(e,t){if(typeof IntersectionObserver>`u`)return()=>{};let n=new IntersectionObserver(e=>
86{e.forEach(e=>{e.intersectionRatio>0&&(t(),n.disconnect())})});return n.observe(e),()=>{n.disconnect()}}var bl=function(e){return e.scrollAreaOverflowXStart=`--scroll-area-overflow-x-start`,e.scrollAreaOverflowXEnd=`--scroll-area-overflow-x-end`,e.scrollAreaOverflowYStart=`--scroll-area-overflow-y-start`,e.scrollAreaOverflowYEnd=`--scroll-area-overflow-y-end`,e}({});function xl(e,t){if(t<=0)return 0;let n=Sn(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}var Sl=!1;function Cl(){Sl||tn||(typeof CSS<`u`&&`registerProperty`in CSS&&[bl.scrollAreaOverflowXStart,bl.scrollAreaOverflowXEnd,bl.scrollAreaOverflowYStart,bl.scrollAreaOverflowYEnd].forEach(e=>{try{CSS.registerProperty({name:e,syntax:`<length>`,inherits:!1,initialValue:`0px`})}catch{}}),Sl=!0)}var wl=Y.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{viewportRef:a,scrollbarYRef:o,scrollbarXRef:s,thumbYRef:c,thumbXRef:l,cornerRef:u,cornerSize:d,setCornerSize:f,setThumbSize:p,rootId:m,setHiddenState:h,hiddenState:g,handleScroll:_,setHovering:v,setOverflowEdges:y,overflowEdges:b,overflowEdgeThreshold:x,scrollingX:S,scrollingY:C}=ol(),w=Ze(),T=Y.useRef(!0),E=dn(),D=dn(),O=En(()=>{let e=a.current,t=o.current,n=s.current,r=c.current,i=l.current,m=u.current;if(!e)return;let g=e.scrollHeight,_=e.scrollWidth,v=e.clientHeight,b=e.clientWidth,S=e.scrollTop,C=e.scrollLeft;if(g===0||_===0)return;let T=v>=g,E=b>=_,D=b/_,O=v/g,k=Math.max(0,_-b),A=Math.max(0,g-v),j=0,M=0;if(!E){let e=0;e=Sn(w===`rtl`?-C:C,0,k),j=xl(e,k),M=k-j}let N=T?0:Sn(S,0,A),P=T?0:xl(N,A),F=T?0:A-P,I=E?0:b,L=T?0:v,ee=0,te=0;!E&&!T&&(ee=t?.offsetWidth||0,te=n?.offsetHeight||0);let ne=d.width===0&&d.height===0,re=ne?ee:0,R=ne?te:0,ie=cl(n,`padding`,`x`),ae=cl(t,`padding`,`y`),oe=cl(i,`margin`,`x`),z=cl(r,`margin`,`y`),se=I-ie-oe,ce=L-ae-z,le=n?Math.min(n.offsetWidth-re,se):se,ue=t?Math.min(t.offsetHeight-R,ce):ce,de=Math.max(16,le*D),fe=Math.max(16,ue*O);if(p(e=>e.height===fe&&e.width===de?e:{width:de,height:fe}),t&&r){let e=t.offsetHeight-fe-ae-z,n=g-v,i=n===0?0:S/n,a=Math.min(e,Math.max(0,i*e));r.style.transform=`translate3d(0,${a}px,0)`}if(n&&i){let e=n.offsetWidth-de-ie-oe,t=_-b,r=t===0?0:C/t,a=w===`rtl`?Sn(r*e,-e,0):Sn(r*e,0,e);i.style.transform=`translate3d(${a}px,0,0)`}let pe=[[bl.scrollAreaOverflowXStart,j],[bl.scrollAreaOverflowXEnd,M],[bl.scrollAreaOverflowYStart,P],[bl.scrollAreaOverflowYEnd,F]];for(let[t,n]of pe)e.style.setProperty(t,`${n}px`);m&&(E||T?f({width:0,height:0}):!E&&!T&&f({width:ee,height:te})),h(e=>{let t=T||E;return e.y===T&&e.x===E&&e.corner===t?e:{y:T,x:E,corner:t}});let B={xStart:!E&&j>x.xStart,xEnd:!E&&M>x.xEnd,yStart:!T&&P>x.yStart,yEnd:!T&&F>x.yEnd};y(e=>e.xStart===B.xStart&&e.xEnd===B.xEnd&&e.yStart===B.yStart&&e.yEnd===B.yEnd?e:B)});jt(()=>{if(!a.current)return;Cl();let e=!1;return yl(a.current,()=>{if(!e){e=!0;return}O()})},[O,a]),jt(()=>{queueMicrotask(O)},[O,g,w]),jt(()=>{a.current?.matches(`:hover`)&&v(!0)},[a,v]),Y.useEffect(()=>{let e=a.current;if(typeof ResizeObserver>`u`||!e)return;let t=!1,n=new ResizeObserver(()=>{if(!t){t=!0;return}O()});return n.observe(e),D.start(0,()=>{let t=e.getAnimations({subtree:!0});t.length!==0&&Promise.allSettled(t.map(e=>e.finished)).then(O).catch(()=>{})}),()=>{n.disconnect(),D.clear()}},[O,a,D]);function k(){T.current=!1}let A={role:`presentation`,...m&&{"data-id":`${m}-viewport`},...(!g.x||!g.y)&&{tabIndex:0},className:tt.className,style:{overflow:`scroll`},onScroll(){a.current&&(O(),T.current||_({x:a.current.scrollLeft,y:a.current.scrollTop}),E.start(100,()=>{T.current=!0}))},onWheel:k,onTouchMove:k,onPointerMove:k,onPointerEnter:k,onKeyDown:k},j=Y.useMemo(()=>({scrolling:S||C,hasOverflowX:!g.x,hasOverflowY:!g.y,overflowXStart:b.xStart,overflowXEnd:b.xEnd,overflowYStart:b.yStart,overflowYEnd:b.yEnd,cornerHidden:g.corner}),[S,C,g.x,g.y,g.corner,b]),M=$e(`div`,e,{ref:[t,a],state:j,props:[A,i],stateAttributesMapping:dl}),N=Y.useMemo(()=>({computeThumbPosition:O}),[O]);return(0,X.jsx)(vl.Provider,{value:N,children:M})}),Tl=Y.createContext(void 0);function El(){let e=Y.useContext(Tl);if(e===void 0)throw Error(Et(54));return e}var Dl=function(e){return e.scrollAreaThumbHeight=`--scroll-area-thumb-height`,e.scrollAreaThumbWidth=`--scroll-area-thumb-width`,e}({}),Ol=Y.forwardRef(function(e,t){let{render:n,className:r,orientation:i=`vertical`,keepMounted:a=!1,...o}=e,{hovering:s,scrollingX:c,scrollingY:l,hiddenState:u,overflowEdges:d,scrollbarYRef:f,scrollbarXRef:p,viewportRef:m,thumbYRef:h,thumbXRef:g,handlePointerDown:_,handlePointerUp:v,rootId:y,thumbSize:b}=ol(),x={hovering:s,scrolling:{horizontal:c,vertical:l}[i],orientation:i,hasOverflowX:!u.x,hasOverflowY:!u.y,overflowXStart:d.xStart,overflowXEnd:d.xEnd,overflowYStart:d.yStart,overflowYEnd:d.yEnd,cornerHidden:u.corner},S=Ze();Y.useEffect(()=>{let e=m.current,t=i===`vertical`?f.current:p.current;if(!t)return;
86function n(n){if(e&&t&&!n.ctrlKey){if(n.preventDefault(),i===`vertical`){if(e.scrollTop===0&&n.deltaY<0)return}else if(e.scrollLeft===0&&n.deltaX<0)return;if(i===`vertical`){if(e.scrollTop===e.scrollHeight-e.clientHeight&&n.deltaY>0)return}else if(e.scrollLeft===e.scrollWidth-e.clientWidth&&n.deltaX>0)return;i===`vertical`?e.scrollTop+=n.deltaY:e.scrollLeft+=n.deltaX}}return t.addEventListener(`wheel`,n,{passive:!1}),()=>{t.removeEventListener(`wheel`,n)}},[i,p,f,m]);let C={...y&&{"data-id":`${y}-scrollbar`},onPointerDown(e){if(e.button===0&&e.currentTarget===e.target&&m.current){if(h.current&&f.current&&i===`vertical`){let t=cl(h.current,`margin`,`y`),n=cl(f.current,`padding`,`y`),r=h.current.offsetHeight,i=f.current.getBoundingClientRect(),a=e.clientY-i.top-r/2-n+t/2,o=m.current.scrollHeight,s=m.current.clientHeight,c=a/(f.current.offsetHeight-r-n-t)*(o-s);m.current.scrollTop=c}if(g.current&&p.current&&i===`horizontal`){let t=cl(g.current,`margin`,`x`),n=cl(p.current,`padding`,`x`),r=g.current.offsetWidth,i=p.current.getBoundingClientRect(),a=e.clientX-i.left-r/2-n+t/2,o=m.current.scrollWidth,s=m.current.clientWidth,c=a/(p.current.offsetWidth-r-n-t),l;S===`rtl`?(l=(1-c)*(o-s),m.current.scrollLeft<=0&&(l=-l)):l=c*(o-s),m.current.scrollLeft=l}_(e)}},onPointerUp:v,style:{position:`absolute`,touchAction:`none`,WebkitUserSelect:`none`,userSelect:`none`,...i===`vertical`&&{top:0,bottom:`var(${sl.scrollAreaCornerHeight})`,insetInlineEnd:0,[Dl.scrollAreaThumbHeight]:`${b.height}px`},...i===`horizontal`&&{insetInlineStart:0,insetInlineEnd:`var(${sl.scrollAreaCornerWidth})`,bottom:0,[Dl.scrollAreaThumbWidth]:`${b.width}px`}}},w=$e(`div`,e,{ref:[t,i===`vertical`?f:p],state:x,props:[C,o],stateAttributesMapping:dl}),T=Y.useMemo(()=>({orientation:i}),[i]),E=i===`vertical`?u.y:u.x;return!a&&E?null:(0,X.jsx)(Tl.Provider,{value:T,children:w})}),kl=Y.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{thumbYRef:a,thumbXRef:o,handlePointerDown:s,handlePointerMove:c,handlePointerUp:l,setScrollingX:u,setScrollingY:d}=ol(),{orientation:f}=El();return $e(`div`,e,{ref:[t,f===`vertical`?a:o],state:{orientation:f},props:[{onPointerDown:s,onPointerMove:c,onPointerUp(e){f===`vertical`&&d(!1),f===`horizontal`&&u(!1),l(e)},style:{...f===`vertical`&&{height:`var(${Dl.scrollAreaThumbHeight})`},...f===`horizontal`&&{width:`var(${Dl.scrollAreaThumbWidth})`}}},i]})}),Al=Y.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{cornerRef:a,cornerSize:o,hiddenState:s}=ol(),c=$e(`div`,e,{ref:[t,a],props:[{style:{position:`absolute`,bottom:0,insetInlineEnd:0,width:o.width,height:o.height}},i]});return s.corner?null:c});function jl({className:e,children:t,...n}){return(0,X.jsxs)(gl,{"data-slot":`scroll-area`,className:q(`relative`,e),...n,children:[(0,X.jsx)(wl,{"data-slot":`scroll-area-viewport`,className:`size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1`,children:t}),(0,X.jsx)(Ml,{}),(0,X.jsx)(Al,{})]})}function Ml({className:e,orientation:t=`vertical`,...n}){return(0,X.jsx)(Ol,{"data-slot":`scroll-area-scrollbar`,"data-orientation":t,orientation:t,className:q(`flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent`,e),...n,children:(0,X.jsx)(kl,{"data-slot":`scroll-area-thumb`,className:`relative flex-1 rounded-full bg-border`})})}var Nl=(e,t)=>!e.contextualOnly&&(e.id!==`world-editor`||t===`world-editor`);function Pl({className:e}){return(0,X.jsx)(`span`,{"aria-hidden":`true`,className:q(`flex size-6.5 shrink-0 items-center justify-center rounded-lg bg-sky-500 text-white`,e),children:(0,X.jsx)(zr,{className:`size-3 fill-current`})})}function Fl({currentGuide:e,guides:t,onClose:n,onStartGuide:r}){let[i,a]=(0,Y.useState)(``),o=(0,Y.useMemo)(()=>t.filter(t=>Nl(t,e?.id)),[e?.id,t]),s=(0,Y.useMemo)(()=>{let e=i.trim().toLowerCase();return e?o.filter(t=>t.title.toLowerCase().includes(e)||t.description.toLowerCase().includes(e)):o},[o,i]);return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(Wn,{className:`text-[11px] font-semibold tracking-wide text-muted-foreground uppercase`,children:`Quick guide`}),(0,X.jsxs)(U,{type:`button`,variant:`ghost`,size:`icon-xs`,className:`text-muted-foreground`,onClick:n,children:[(0,X.jsx)(so,{}),(0,X.jsx)(`span`,{className:`sr-only`,children:`Close quick guide`})]})]}),(0,X.jsx)(W,{type:`search`,value:i,onChange:e=>a(e.target.value),placeholder:`Find a guide...`,"aria-label":`Find a guide`}),e&&(0,X.jsxs)(`div`,{className:`rounded-xl border border-border p-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,X.jsx)(Pl,{}),(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:`Guide this page`})]}),(0,X.jsx)(Un,{className:`mt-2 text-xs leading-5`,children:e.description}),(0,X.jsxs)(U,{type:`button`,variant:`ghost`,size:`xs`,className:`mt-1 -ml-2.5 text-sky-500 hover:bg-transparent hover:text-sky-600`,onClick:()=>r(e.id),children:[`Start tour`,(0,X.jsx)(Pa,{"data-icon":`inline-end`})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`p`,{className:`px-1 text-[11px] font-semibold tracking-wide text-muted-foreground
86/70 uppercase`,children:`All guides`}),(0,X.jsxs)(jl,{className:`-mx-1 px-1 **:data-[slot=scroll-area-viewport]:max-h-88 **:data-[slot=scroll-area-viewport]:overscroll-contain`,children:[s.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r(e.id),className:`group flex w-full items-center gap-3 rounded-lg p-2 text-left transition-colors outline-none hover:bg-muted focus-visible:ring-3 focus-visible:ring-ring/30 dark:hover:bg-muted/50`,children:[(0,X.jsx)(Pl,{className:`hidden group-hover:flex group-focus-visible:flex`}),(0,X.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:e.title}),(0,X.jsx)(`span`,{className:`mt-0.5 block text-xs leading-4 text-muted-foreground`,children:e.description})]}),(0,X.jsx)(Er,{className:`size-4 shrink-0 text-muted-foreground/50`})]},e.id)),s.length===0&&(0,X.jsxs)(`p`,{className:`px-2 py-6 text-center text-xs text-muted-foreground`,children:[`No guides match “`,i.trim(),`”`]})]})]})]})}Fl.displayName=`QuickHelpPopover`,s();var Il=(0,Y.lazy)(()=>x(()=>import(`./dist-D8Mv159s.js`).then(e=>({default:e.Joyride})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),Ll=(0,Y.createContext)(null);function Rl({backProps:e,closeProps:t,index:n,isLastStep:r,primaryProps:i,size:a,skipProps:o,step:s,tooltipProps:c}){return(0,X.jsxs)(`div`,{...c,className:`max-h-[calc(100dvh-2rem)] w-[min(23rem,calc(100vw-2rem))] overflow-y-auto overscroll-contain rounded-2xl border border-border bg-popover p-4 text-popover-foreground shadow-xl`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[s.title&&(0,X.jsx)(`h2`,{className:`text-base font-semibold`,children:s.title}),(0,X.jsx)(`p`,{className:`mt-1 text-sm leading-6 text-muted-foreground`,children:s.content})]}),(0,X.jsxs)(U,{...t,type:`button`,variant:`ghost`,size:`icon-xs`,className:`shrink-0`,children:[(0,X.jsx)(so,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`features.quick-help.close`)})]})]}),(0,X.jsxs)(`div`,{className:`mt-4 flex items-center justify-between gap-3 border-t border-border pt-3`,children:[(0,X.jsx)(U,{...o,type:`button`,variant:`ghost`,size:`sm`,className:`text-muted-foreground`,children:Z(`features.quick-help.end-tour`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[n>0&&(0,X.jsx)(U,{...e,type:`button`,variant:`outline`,size:`sm`,children:Z(`common.back`)}),(0,X.jsxs)(U,{...i,type:`button`,size:`sm`,children:[Z(r?`features.quick-help.finish`:`common.next`),(0,X.jsxs)(`span`,{className:`text-[11px] opacity-70`,children:[n+1,`/`,a]})]})]})]})]})}function zl(){let e=(0,Y.useContext)(Ll);if(!e)throw Error(`useQuickHelp must be used within QuickHelpProvider`);return e}function Bl({children:e}){let{activeOrganization:t,hasPermissions:n}=z(),r=C(),i=c(),[a,o]=(0,Y.useState)(null),[s,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(0),m=t?.id,h=t?.slug,g=(0,Y.useMemo)(()=>{let e=rl(h??``);return m?e.filter(e=>{switch(e.id){case`worlds`:return n(m,`world`,`list-view`);case`world-editor`:case`world-settings-dialog`:return n(m,`world`,`update`);case`events`:return n(m,`event`,`list-view`);case`create-event`:return n(m,`event`,`create`);case`content-collections`:return n(m,`cms`,`list-view`);case`content-labels`:return n(m,`translateLabel`,`list-view`);case`content-localization`:case`content-language-dialog`:return n(m,`translateEntry`,`list-view`);case`content-fields-dialog`:return n(m,`cms`,`update`);case`content-item-editor`:return n(m,`cms`,`create`)||n(m,`cms`,`update`);default:return!0}}):e.slice(0,1)},[m,h,n]),_=(0,Y.useMemo)(()=>il(g,r.pathname,r.search),[g,r.pathname,r.search]),v=g.find(e=>e.id===a),y=(0,Y.useCallback)(e=>{d(!1),o(e),p(e=>e+1),window.requestAnimationFrame(()=>d(!0))},[]),b=(0,Y.useCallback)(e=>{let t=g.find(t=>t.id===e);if(t){if(t.path&&!t.matches(r.pathname,r.search)){d(!1),l(e),i(t.path);return}y(e)}},[g,r.pathname,r.search,i,y]);(0,Y.useEffect)(()=>{if(!s||!g.find(e=>e.id===s)?.matches(r.pathname,r.search))return;let e=window.setTimeout(()=>{l(null),y(s)},250);return()=>window.clearTimeout(e)},[g,r.pathname,r.search,s,y]);let x=(0,Y.useCallback)(e=>{e.type===`tour:end`&&(d(!1),o(null))},[]),S=v?{continuous:!0,floatingOptions:{flipOptions:{crossAxis:!0,padding:20,rootBoundary:`viewport`},shiftOptions:{crossAxis:!0,padding:{top:16,right:16,bottom:16,left:16},rootBoundary:`viewport`,...typeof document>`u`?{}:{boundary:document.documentElement}},strategy:`fixed`},onEvent:x,options:{arrowColor:`var(--popover)`,backgroundColor:`var(--popover)`,buttons:[`back`,`close`,`primary`,`skip`],closeButtonAction:`skip`,dismissKeyAction:`close`,overlayClickAction:!1,overlayColor:`rgba(17, 17, 16, 0.58)`,primaryColor:`var(--foreground)`,showProgress:!0,skipBeacon:!0,spotlightPadding:8,spotlightRadius:12,targetWaitTimeout:5e3,textColor:`var(--popover-foreground)`,width:368,zIndex:1e3},run:u,scrollToFirstStep:!0,steps:v.steps,tooltipComponent:Rl}:null;return(0,X.jsxs)(Ll.Provider,{value:{currentGuide:_,guides:g,startGuide:b},children:[e,S&&(0,X.jsx)(Y.Suspense,{fallback:null,children:(0,X.jsx)(Il,{...S},f)})]})}function Vl({className:e}){let{currentGuide:t,guides:n,startGuide:r}=zl(),[i,a]=(0,Y.useState)(!1);return(0,X.jsxs)(jn,{open:i,onOpenChange:a,children:[(0,X.jsx)(Kn,{render:t=>(0,X.jsxs)(U,{...t,type:`button`,variant:`ghost`,size:`sm`,className:e,"data-quick-help":`help-button`,children:[(0,X.jsx)(Ul,{}),Z(`features.quick-help.help`)]})}),(0,X.jsx)(ur,{align:`end`,className:`w-85 gap-3 p-3`,children:(0,X.jsx)(Fl,{currentGuide:t,guides:n,onClose:()=>a(!1),onStartGuide:e=>{a(!1),r(e)}})})]})}function Hl({guideId:e,className:t,iconOnly:n=!1}){let{guides:r,startGuide:i}=zl(),a=r.find(t=>
86t.id===e);return a?(0,X.jsxs)(U,{type:`button`,variant:`ghost`,size:n?`icon-sm`:`sm`,className:t,onClick:()=>i(e),"data-quick-help":`${e}-button`,children:[(0,X.jsx)(Ul,{}),n?(0,X.jsxs)(`span`,{className:`sr-only`,children:[`Guide: `,a.title]}):Z(`common.guide`)]}):null}function Ul(){return(0,X.jsx)(vi,{"aria-hidden":`true`,className:`size-4 text-sky-500`})}var Wl=(e,...t)=>`/${e}/dashboard${t.length?`/`+t.join(`/`):``}`,Gl=e=>[{items:[{title:`common.home`,url:Wl(e,`home`),icon:ka}]},{label:Z(`common.create`),items:[{title:`common.events`,url:Wl(e,`events`),icon:da,permissionType:`event`},{title:`common.worlds`,url:Wl(e,`worlds`),icon:Na,permissionType:`world`},{title:`common.spaces`,url:Wl(e,`spaces`),icon:Gi,permissionType:`space`}]},{label:Z(`dashboard.layout.group.manage`),items:[{title:`common.content`,url:Wl(e,`content`),icon:ba,permissionType:`cms`},{title:`common.files`,url:Wl(e,`files`),icon:oa,permissionType:`user`,permissionAction:`list`},{title:`common.emails`,url:Wl(e,`emails`),icon:Yr,permissionType:`user`,permissionAction:`list`}]},{label:Z(`common.settings`),items:[{title:`common.account`,url:Wl(e,`account`),icon:Ia},{title:`common.api.keys`,url:Wl(e,`settings`,`api-keys`),icon:Ta,permissionType:`user`,permissionAction:`list`},{title:`common.members`,url:Wl(e,`settings`,`members`),icon:Ia,permissionAnyOf:[{type:`organization`,action:`list`},{type:`organization`,action:`update`}]},{title:`common.organization`,url:Wl(e,`settings`,`organization`),icon:Na,permissionType:`organization`,permissionAction:`update`},{title:`common.organizations`,url:Wl(e,`settings`,`organizations`),icon:Aa,permissionType:`organization`,permissionAction:`list`}]}];function Kl({children:e}){return(0,X.jsx)(Bl,{children:e})}function ql({groups:e,onNavigate:t,expanded:n}){let{hasPermissions:r,activeOrganization:i}=z();return(0,X.jsx)(X.Fragment,{children:e.map((e,a)=>{let o=e.items.filter(e=>{let t=Fc(e);return t?i?.id?t.anyOf?.length?t.anyOf.some(e=>r(i.id,e.type,e.action)):r(i.id,t.type,t.action??`list-view`):!1:!0});return o.length===0?null:(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[e.label&&(n?(0,X.jsx)(`div`,{className:`px-3 pt-4 pb-0.5 text-[11px] font-medium text-muted-foreground select-none`,children:e.label}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`hidden px-3 pt-4 pb-0.5 text-[11px] font-medium text-muted-foreground select-none lg:block`,children:e.label}),(0,X.jsx)(`div`,{className:`mx-2 mt-3 mb-1 border-t border-border lg:hidden`})]})),o.map(e=>(0,X.jsx)(Xl,{item:e,onNavigate:t,expanded:n},e.title))]},e.label??a)})})}function Jl({children:e}){let{activeOrganization:t}=z(),{openMobile:n,setOpenMobile:r}=Uc(),i=Gl(t?.slug??``);return(0,X.jsxs)(`div`,{className:`grid h-svh w-full grid-rows-[52px_1fr] overflow-hidden bg-muted`,children:[(0,X.jsx)(Kc,{className:``,children:(0,X.jsxs)(`div`,{className:`flex w-full flex-row items-center justify-end gap-1 px-3`,children:[(0,X.jsx)(Po,{}),(0,X.jsx)(Vl,{}),(0,X.jsx)(qc,{})]})}),(0,X.jsxs)(`div`,{className:`grid h-full min-h-0 grid-cols-1 md:grid-cols-[52px_1fr] lg:grid-cols-[260px_1fr]`,children:[(0,X.jsx)(Ic,{className:`pb-2 text-foreground`,"data-quick-help":`dashboard-navigation`,children:(0,X.jsxs)(Lc,{className:q(`flex h-full flex-col overflow-y-auto`,$n({style:`base`})),children:[(0,X.jsx)(ql,{groups:i}),(0,X.jsx)(`div`,{className:`mt-auto pt-2`,"data-quick-help":`organization`,children:(0,X.jsx)(Mc,{})})]})}),(0,X.jsx)(Ln,{open:n,onOpenChange:r,children:(0,X.jsxs)(Vn,{side:`left`,className:`w-65 p-0 pt-0`,children:[(0,X.jsx)(`div`,{className:`flex h-13 shrink-0 items-center border-b border-border pr-2 pl-5`,children:(0,X.jsx)(`img`,{src:`/assets/sidebar-logo.png`,alt:`logo`,className:`h-4.5 w-auto max-w-full rounded-md object-contain`})}),(0,X.jsxs)(`div`,{className:q(`flex min-h-0 flex-1 flex-col overflow-y-auto px-2 pt-3 pb-4`,$n({style:`base`})),children:[(0,X.jsx)(ql,{groups:i,onNavigate:()=>r(!1),expanded:!0}),(0,X.jsx)(`div`,{className:`mt-auto pt-2`,children:(0,X.jsx)(Mc,{})})]})]})}),(0,X.jsx)(`div`,{className:`min-w-0 overflow-hidden pr-2 pb-2 pl-2`,children:(0,X.jsx)(`div`,{className:`flex h-full flex-col overflow-hidden rounded-xl bg-background`,children:e})})]})]})}function Yl({children:e}){return(0,X.jsx)(Wc,{children:(0,X.jsx)(Jl,{children:e})})}var Xl=({item:e,onNavigate:t,expanded:n})=>{let r=e.icon;return(0,X.jsx)(g,{to:e.url,className:`block w-full`,onClick:()=>t?.(),children:({isActive:t})=>
86(0,X.jsx)(Rc,{className:q(t&&`bg-foreground/10 hover:bg-foreground/10`),icon:(0,X.jsx)(r,{}),expanded:n,children:Z(e.title)})})},Zl=lt({name:H().min(1,`Organization name is required`),slug:H().min(1,`Organization slug is required`),logo:H().optional()}),Ql=()=>{let{id:e}=S(),t=c(),n=R(),{client:r,hasPermissions:i,activeOrganization:a,refetchSession:o}=z(),s=fe(),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(null),{data:m,isPending:g,error:v}=V(n.organization.get.queryOptions([e],{enabled:!!e})),y=l({resolver:pn(Zl),defaultValues:{name:``,slug:``,logo:``}});(0,Y.useEffect)(function(){if(m&&m[0]){let e=m[0],t=e.logo;y.reset({name:e.name,slug:e.slug,logo:t||``})}},[m,y]);let b=B({mutationFn:async t=>{if(!e)throw Error(`Organization ID is required`);return r.organization.update({organizationId:e,data:{name:t.name,slug:t.slug,logo:t.logo}})},onSuccess:()=>{s.invalidateQueries({queryKey:n.organization.get.queryKey([e])}),s.invalidateQueries({queryKey:[`better-auth.listOrganizations`]}),J.success(`Success!`,{description:`Organization updated successfully`}),d(!1)},onError:e=>{console.error(`Error updating organization:`,e),J.error(`Failed to update organization`,{description:`Please try again`}),d(!1)}}),x=async e=>{d(!0),b.mutate(e)};(0,Y.useEffect)(function(){if(!f)return;let t=P.get$(`file.response`).pipe(O(e=>e.source===f)).subscribe(async t=>{if(t.payload&&`files`in t.payload){let i=t.payload.files[0];if(i?.url&&e)try{await r.organization.update({organizationId:e,data:{logo:i.url}}),o(),s.invalidateQueries({queryKey:n.organization.get.queryKey([e])}),J.success(`Organization logo updated successfully`)}catch(e){console.error(`Failed to update logo:`,e),J.error(`Failed to update logo`)}p(null)}});return()=>{t.unsubscribe()}},[f,r,e,o,s,n]);let C=()=>{let e=xr();p(e),P.publish({type:`file.request`,id:e,payload:{fileType:`image`,multiple:!1,title:`Select Organization Logo`,uploadOnly:!1}})},w=async()=>{if(e)try{await r.organization.update({organizationId:e,data:{logo:``}}),o(),s.invalidateQueries({queryKey:n.organization.get.queryKey([e])}),J.success(`Logo removed`)}catch(e){console.error(`Failed to remove logo:`,e),J.error(`Failed to remove logo`)}},T=()=>{t(`/${a?.slug}/dashboard/settings/organizations`)};if(!e)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{children:`Organization ID not found`})});if(!a?.id||!i(a?.id,`organization`,`update`))return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{children:`You don't have permission to edit this organization`})});if(g)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{children:`Loading organization...`})});if(v)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{children:`Error loading organization`})});if(!m||!m[0])return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{children:`Organization not found`})});let E=m[0],D=E.logo;return(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col gap-6 p-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-4`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`icon`,onClick:T,"aria-label":`Go back`,children:(0,X.jsx)(Ca,{className:`h-5 w-5`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`text-2xl font-bold`,children:`Edit Organization`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Update your organization details`})]})]}),(0,X.jsx)(_,{...y,children:(0,X.jsxs)(`form`,{onSubmit:y.handleSubmit(x),className:`flex flex-col gap-6`,children:[(0,X.jsxs)(Fo,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(Io,{children:`Organization Logo`}),(0,X.jsxs)(zo,{className:`flex flex-row items-center gap-4`,children:[(0,X.jsx)(`div`,{className:`cursor-pointer transition-opacity hover:opacity-80`,onClick:C,children:(0,X.jsxs)(rs,{className:`size-32 rounded-xl bg-background after:rounded-xl`,children:[(0,X.jsx)(is,{src:D||``,className:`rounded-xl object-contain p-3`,alt:E.name}),(0,X.jsx)(as,{className:`rounded-xl`,children:D?E.name.charAt(0).toUpperCase():(0,X.jsx)(oo,{className:`h-8 w-8 text-muted-foreground`})})]})}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Click logo to change`}),D&&(0,X.jsxs)(`button`,{type:`button`,className:`flex items-center gap-1 text-xs text-red-500 hover:text-red-600`,onClick:w,children:[(0,X.jsx)(Tr,{className:`size-3`}),`Remove`]})]})]})]}),(0,X.jsxs)(Fo,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(Io,{
86children:`Organization Details`}),(0,X.jsxs)(zo,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(h,{control:y.control,name:`name`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:`Organization Name`}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,placeholder:`Acme Inc.`})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:y.control,name:`slug`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:`Organization Slug`}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,placeholder:`acme`})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})})]}),(0,X.jsxs)(Bo,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(U,{type:`button`,variant:`outline`,onClick:T,disabled:u,children:`Cancel`}),(0,X.jsx)(U,{type:`submit`,disabled:u||!y.formState.isDirty,children:u?`Saving...`:`Save Changes`})]})]})]})})]})};Ql.displayName=`EditOrganization`;var $l=Y.createContext(void 0);function eu(){let e=Y.useContext($l);if(e===void 0)throw Error(Et(64));return e}var tu=function(e){return e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e}({}),nu={tabActivationDirection:e=>({[tu.activationDirection]:e})},ru=Y.forwardRef(function(e,t){let{className:n,defaultValue:r=0,onValueChange:i,orientation:a=`horizontal`,render:o,value:s,...c}=e,l=Ze(),u=Object.hasOwn(e,`defaultValue`),d=Y.useRef([]),[f,p]=Y.useState(()=>new Map),[m,h]=wn({controlled:s,default:r,name:`Tabs`,state:`value`}),g=s!==void 0,[_,v]=Y.useState(()=>new Map),[y,b]=Y.useState(`none`),x=En((e,t)=>
86{i?.(e,t),!t.isCanceled&&(h(e),b(t.activationDirection))}),S=En((e,t)=>{p(n=>{if(n.get(e)===t)return n;let r=new Map(n);return r.set(e,t),r})}),C=En((e,t)=>{p(n=>{if(!n.has(e)||n.get(e)!==t)return n;let r=new Map(n);return r.delete(e),r})}),w=Y.useCallback(e=>f.get(e),[f]),T=Y.useCallback(e=>{for(let t of _.values())if(e===t?.value)return t?.id},[_]),E=Y.useCallback(e=>{if(e===void 0)return null;for(let[t,n]of _.entries())if(n!=null&&e===(n.value??n.index))return t;return null},[_]),D=Y.useMemo(()=>({direction:l,getTabElementBySelectedValue:E,getTabIdByPanelValue:T,getTabPanelIdByValue:w,onValueChange:x,orientation:a,registerMountedTabPanel:S,setTabMap:v,unregisterMountedTabPanel:C,tabActivationDirection:y,value:m}),[l,E,T,w,x,a,S,v,C,y,m]),O=Y.useMemo(()=>{for(let e of _.values())if(e!=null&&e.value===m)return e},[_,m]),k=Y.useMemo(()=>{for(let e of _.values())if(e!=null&&!e.disabled)return e.value},[_]);jt(()=>{if(g||_.size===0)return;let e=O?.disabled;if(u&&e&&m===r||!e&&(O!=null||m===null))return;let t=k??null;m!==t&&(h(t),b(`none`))},[r,k,u,g,O,b,h,_,m]);let A=$e(`div`,e,{state:{orientation:a,tabActivationDirection:y},ref:t,props:c,stateAttributesMapping:nu});return(0,X.jsx)($l.Provider,{value:D,children:(0,X.jsx)(it,{elementsRef:d,children:A})})}),iu=Y.createContext(void 0);function au(){let e=Y.useContext(iu);if(e===void 0)throw Error(Et(65));return e}var ou=Y.forwardRef(function(e,t){let{className:n,disabled:r=!1,render:i,value:a,id:o,nativeButton:s=!0,...c}=e,{value:l,getTabPanelIdByValue:u,orientation:d}=eu(),{activateOnFocus:f,highlightedTabIndex:p,onTabActivation:m,setHighlightedTabIndex:h,tabsListElement:g}=au(),_=xt(o),v=Y.useMemo(()=>({disabled:r,id:_,value:a}),[r,_,a]),{compositeProps:y,compositeRef:b,index:x}=vt({metadata:v}),S=a===l,C=Y.useRef(!1);jt(()=>{if(C.current){C.current=!1;return}if(!(S&&x>-1&&p!==x))return;let e=g;if(e!=null){let t=ve(cn(e));if(t&&It(e,t))return}r||h(x)},[S,x,p,h,r,g]);let{getButtonProps:w,buttonRef:T}=Ge({disabled:r,native:s,focusableWhenDisabled:!0}),E=u(a),D=Y.useRef(!1),O=Y.useRef(!1);function k(e){S||r||m(a,qe(ct,e.nativeEvent,void 0,{activationDirection:`none`}))}function A(e){S||(x>-1&&!r&&h(x),!r&&f&&(!D.current||D.current&&O.current)&&m(a,qe(ct,e.nativeEvent,void 0,{activationDirection:`none`})))}function j(e){if(S||r)return;D.current=!0;function t(){D.current=!1,O.current=!1}(!e.button||e.button===0)&&(O.current=!0,cn(e.currentTarget).addEventListener(`pointerup`,t,{once:!0}))}return $e(`button`,e,{state:{disabled:r,active:S,orientation:d},ref:[t,T,b],props:[y,{role:`tab`,"aria-controls":E,"aria-selected":S,id:_,onClick:k,onFocus:A,onPointerDown:j,[Ye]:S?``:void 0,onKeyDownCapture(){C.current=!0}},c,w]})}),su=function(e){return e.index=`data-index`,e.activationDirection=`data-activation-direction`,e.orientation=`data-orientation`,e.hidden=`data-hidden`,e}({}),cu={...nu,...Qt},lu=Y.forwardRef(function(e,t){let{className:n,value:r,render:i,keepMounted:a=!1,...o}=e,{value:s,getTabIdByPanelValue:c,orientation:l,tabActivationDirection:u,registerMountedTabPanel:d,unregisterMountedTabPanel:f}=eu(),p=xt(),m=Y.useMemo(()=>({id:p,value:r}),[p,r]),{ref:h,index:g}=dt({metadata:m}),_=r===s,{mounted:v,transitionStatus:y,setMounted:b}=Ut(_),x=!v,S=c(r),C={hidden:x,orientation:l,tabActivationDirection:u,transitionStatus:y},w=Y.useRef(null),T=$e(`div`,e,{state:C,ref:[t,h,w],props:[{"aria-labelledby":S,hidden:x,id:p,role:`tabpanel`,tabIndex:_?0:-1,inert:Re(!_),[su.index]:g},o],stateAttributesMapping:cu});return Lt({open:_,ref:w,onComplete(){_||b(!1)}}),jt(()=>{if((!x||a)&&p!=null)return d(r,p),()=>{f(r,p)}},[x,a,r,p,d,f]),a||v?T:null}),uu=Y.forwardRef(function(e,t){let{activateOnFocus:n=!1,className:r,loopFocus:i=!0,render:a,...o}=e,{getTabElementBySelectedValue:s,onValueChange:c,orientation:l,value:u,setTabMap:d,tabActivationDirection:f}=eu(),[p,m]=Y.useState(0),[h,g]=Y.useState(null),_=fu(u,l,h,s),v=En((e,t)=>{e!==u&&(t.activationDirection=_(e),c(e,t))}),y={orientation:l,tabActivationDirection:f},b={"aria-orientation":l===`vertical`?`vertical`:void 0,role:`tablist`},x=Y.useMemo(()=>({activateOnFocus:n,highlightedTabIndex:p,onTabActivation:v,setHighlightedTabIndex:m,tabsListElement:h,value:u}),[n,p,v,m,h,u]);return(0,X.jsx)(iu.Provider,{value:x,children:(0,X.jsx)(Ke,{render:a,className:r,state:y,refs:[t,g],props:[b,o],stateAttributesMapping:nu,highlightedIndex:p,enableHomeAndEndKeys:!0,loopFocus:i,orientation:l,onHighlightedIndexChange:m,onMapChange:d,disabledIndices:hn})})});function du(e,t){let{left:n,top:r}=e.getBoundingClientRect(),{left:i,top:a}=t.getBoundingClientRect();return{left:n-i,top:r-a}}function fu(e,t,n,r){let[i,a]=Y.useState(null);return jt(()=>{if(e==null||n==null){a(null);return}let i=r(e);
86if(i==null){a(null);return}let{left:o,top:s}=du(i,n);a(t===`horizontal`?o:s)},[t,r,n,e]),Y.useCallback(o=>{if(o===e)return`none`;if(o==null)return a(null),`none`;if(o!=null&&n!=null){let e=r(o);if(e!=null){let{left:r,top:o}=du(e,n);if(i==null)return a(t===`horizontal`?r:o),`none`;if(t===`horizontal`){if(r<i)return a(r),`left`;if(r>i)return a(r),`right`}else if(o<i)return a(o),`up`;else if(o>i)return a(o),`down`}}return`none`},[r,t,i,n,e])}function pu({className:e,orientation:t=`horizontal`,...n}){return(0,X.jsx)(ru,{"data-slot":`tabs`,"data-orientation":t,className:q(`group/tabs flex gap-2 data-horizontal:flex-col`,e),...n})}var mu=rn(`group/tabs-list inline-flex w-fit items-center justify-center rounded-2xl p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col group-data-vertical/tabs:p-1 data-[variant=line]:rounded-none`,{variants:{variant:{default:`bg-muted`,line:`gap-1 bg-transparent`}},defaultVariants:{variant:`default`}});function hu({className:e,variant:t=`default`,...n}){return(0,X.jsx)(uu,{"data-slot":`tabs-list`,"data-variant":t,className:q(mu({variant:t}),e),...n})}function gu({className:e,...t}){return(0,X.jsx)(ou,{"data-slot":`tabs-trigger`,className:q(`relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-2xl border border-transparent! px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start group-data-vertical/tabs:px-3 group-data-vertical/tabs:py-0.5 hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,`group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent`,`data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground`,`after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100`,e),...t})}function _u({className:e,...t}){return(0,X.jsx)(lu,{"data-slot":`tabs-content`,className:q(`flex-1 text-sm outline-none`,e),...t})}function vu({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,X.jsx)(`table`,{"data-slot":`table`,className:q(`w-full caption-bottom text-sm`,e),...t})})}function yu({className:e,...t}){return(0,X.jsx)(`thead`,{"data-slot":`table-header`,className:q(`[&_tr]:border-b`,e),...t})}function bu({className:e,...t}){return(0,X.jsx)(`tbody`,{"data-slot":`table-body`,className:q(`[&_tr:last-child]:border-0`,e),...t})}function xu({className:e,...t}){return(0,X.jsx)(`tr`,{"data-slot":`table-row`,className:q(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function Su({className:e,...t}){return(0,X.jsx)(`th`,{"data-slot":`table-head`,className:q(`h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0`,e),...t})}function Cu({className:e,...t}){return(0,X.jsx)(`td`,{"data-slot":`table-cell`,className:q(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}function wu({table:e,className:t}){return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,className:q(`hidden h-8 items-center gap-2 text-[13px] lg:flex`,t),...e,children:[(0,X.jsx)(ca,{}),Z(`components.table.column.toggle.visibility.view`)]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-37.5`,children:[(0,X.jsx)(On,{children:Z(`components.table.column.toggle.visibility`)}),(0,X.jsx)(xe,{}),e.getAllColumns().filter(e=>e.accessorFn!==void 0&&e.getCanHide()).map(e=>(0,X.jsx)(Ae,{className:`capitalize`,checked:e.getIsVisible(),onCheckedChange:t=>e.toggleVisibility(!!t),children:e.id},e.id))]})})]})}function Tu({table:e}){return(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-t border-border px-0 py-3 text-[13px]`,children:[(0,X.jsxs)(`div`,{className:`flex-1 text-[13px] text-muted-foreground`,children:[e.getFilteredSelectedRowModel().rows.length,` of`,` `,e.getFilteredRowModel().rows.length,` `,Z(`components.table.data.table.pagination.rows.selected`)]}),(0,X.jsxs)(`div`,{className:`flex items-center space-x-6 lg:space-x-8`,children:[(0,X.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,X.jsx)(`p`,{className:`text-[13px] font-medium`,children:Z(`components.table.data.table.pagination.rows.per.page`)}),(0,X.jsxs)(Vt,{value:`${e.getState().pagination.pageSize}`,onValueChange:t=>{e.setPageSize(Number(t))},children:[(0,X.jsx)(Dn,{className:`h-8 w-17.5`,children:(0,X.jsx)(Mt,{render:t=>(0,X.jsx)(`span`,{...t,children:e.getState().pagination.pageSize})})}),(0,X.jsx)(Dt,{side:`top`,children:[10,20,25,30,40,50].map(e=>(0,X.jsx)(yn,{value:`${e}`,children:e},e))})]})]}),(0,X.jsxs)(`div`,{className:`flex w-25 items-center justify-center text-[13px] font-medium`,children:[Z(`components.table.data.table.pagination.page`),` `,e.getState().pagination.pageIndex+1,` `,Z(`components.table.data.table.pagination.of`),` `,e.getPageCount()]}),(0,X.jsxs)(`div`,{className:`flex items-center space-x-2`,children:[(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`icon`,className:`hidden size-8 lg:flex`,onClick:()=>e.setPageIndex(0),disabled:!e.getCanPreviousPage(),children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`components.table.data.table.pagination.go.to.first.page`)}),(0,X.jsx)(ji,{})]}),(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`icon`,className:`size-8`,onClick:()=>e.previousPage(),disabled:!e.getCanPreviousPage(),children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`components.table.data.table.pagination.go.to.previous.page`)}),(0,X.jsx)(Zi,{})]}),(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`icon`,className:`size-8`,onClick:()=>e.nextPage(),disabled:!e.getCanNextPage(),children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`components.table.data.table.pagination.go.to.next.page`)}),(0,X.jsx)(Er,{})]}),(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`icon`,className:`hidden size-8 lg:flex`,onClick:()=>e.setPageIndex(e.getPageCount()-1),disabled:!e.getCanNextPage(),children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`components.table.data.table.pagination.go.to.last.page`)}),(0,X.jsx)(Ti,{})]})]})]})]})}var Eu=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.indeterminate=`data-indeterminate`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invali
86d=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({});function Du(e){return Y.useMemo(()=>({checked(t){return e.indeterminate?{}:t?{[Eu.checked]:``}:{[Eu.unchecked]:``}},...ot}),[e.indeterminate])}var Ou=Y.createContext(void 0);function ku(){let e=Y.useContext(Ou);if(e===void 0)throw Error(Et(14));return e}var Au=`data-parent`,ju=Y.forwardRef(function(e,t){let{checked:n,className:r,defaultChecked:i=!1,disabled:a=!1,id:o,indeterminate:s=!1,inputRef:c,name:l,onCheckedChange:u,parent:d=!1,readOnly:f=!1,render:p,required:m=!1,uncheckedValue:h,value:g,nativeButton:_=!1,...v}=e,{clearErrors:y}=He(),{disabled:b,name:x,setDirty:S,setFilled:C,setFocused:w,setTouched:T,state:E,validationMode:D,validityData:O,shouldValidateOnChange:k,validation:A}=Tt(),j=Go(),{labelId:M,controlId:N,registerControlId:P,getDescriptionProps:F}=Ct(),I=qo(),L=I?.parent,ee=L&&I.allValues,te=b||j.disabled||I?.disabled||a,ne=x??l,re=g??ne,R=xt(),ie=xt(),ae=N;ee?ae=d?ie:`${L.id}-${re}`:o&&(ae=o);let oe={};ee&&(d?oe=I.parent.getParentProps():re&&(oe=I.parent.getChildProps(re)));let z=En(u),{checked:se=n,indeterminate:ce=s,onCheckedChange:le,...ue}=oe,de=I?.value,fe=I?.setValue,pe=I?.defaultValue,B=Y.useRef(null),me=xn(()=>Symbol(`checkbox-control`)),V=Y.useRef(!1),{getButtonProps:he,buttonRef:ge}=Ge({disabled:te,native:_}),_e=I?.validation??A,[ve,ye]=wn({controlled:re&&de&&!d?de.includes(re):se,default:re&&pe&&!d?pe.includes(re):i,name:`Checkbox`,state:`checked`});jt(()=>{P!==Rt&&(V.current=!0,P(me.current,ae))},[ae,I,P,d,me]),Y.useEffect(()=>{let e=me.current;return()=>{V.current&&P!==Rt&&(V.current=!1,P(e,void 0))}},[P,me]),Ne({enabled:!I,id:R,commit:_e.commit,value:ve,controlRef:B,name:ne,getValue:()=>ve});let be=Y.useRef(null),xe=Ce(c,be,_e.inputRef);jt(()=>{be.current&&(be.current.indeterminate=ce,ve&&C(!0))},[ve,ce,C]),yt(ve,()=>{(!I||d)&&(y(ne),C(ve),S(ve!==O.initialValue),k()?_e.commit(ve):_e.commit(ve,!0))});let H=Jt({checked:ve,disabled:te,name:d?void 0:ne,id:_?void 0:ae??void 0,required:m,ref:xe,style:ne?Oe:pt,tabIndex:-1,type:`checkbox`,"aria-hidden":!0,onChange(e){if(e.nativeEvent.defaultPrevented)return;let t=e.target.checked,n=qe(ct,e.nativeEvent);if(le?.(t,n),z(t,n),!n.isCanceled&&(ye(t),re&&de&&fe&&!d)){let e=t?[...de,re]:de.filter(e=>e!==re);fe(e,n)}},onFocus(){B.current?.focus()}},g===void 0?Ft:{value:(I?ve&&g:g)||``},F,I?_e.getValidationProps:_e.getInputValidationProps),Se=ee?!!se:ve,we=ee&&ce||s;Y.useEffect(()=>{if(!L||!re)return;let e=L.disabledStatesRef.current;return e.set(re,te),()=>{e.delete(re)}},[L,te,re]);let Te=Y.useMemo(()=>({...E,checked:Se,disabled:te,readOnly:f,required:m,indeterminate:we}),[E,Se,te,f,m,we]),Ee=Du(Te),De=$e(`span`,e,{state:Te,ref:[ge,B,t,I?.registerControlRef],props:[{id:_?ae??void 0:R,role:`checkbox`,"aria-checked":ce?`mixed`:ve,"aria-readonly":f||void 0,"aria-required":m||void 0,"aria-labelledby":M,[Au]:d?``:void 0,onFocus(){w(!0)},onBlur(){let e=be.current;e&&(T(!0),w(!1),D===`onBlur`&&_e.commit(I?de:e.checked))},onClick(e){f||te||(e.preventDefault(),be.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))}},F,_e.getValidationProps,v,ue,he],stateAttributesMapping:Ee});return(0,X.jsxs)(Ou.Provider,{value:Te,children:[De,!ve&&!I&&ne&&!d&&h!==void 0&&(0,X.jsx)(`input`,{type:`hidden`,name:ne,value:h}),(0,X.jsx)(`input`,{...H})]})}),Mu=Y.forwardRef(function(e,t){let{render:n,className:r,keepMounted:i=!1,...a}=e,o=ku(),s=o.checked||o.indeterminate,{mounted:c,transitionStatus:l,setMounted:u}=Ut(s),d=Y.useRef(null),f={...o,transitionStatus:l};Lt({open:s,ref:d,onComplete(){s||u(!1)}});let p=Du(o),m=Y.useMemo(()=>({...p,...Qt,...ot}),[p]),h=i||c,g=$e(`span`,e,{ref:[t,d],state:f,stateAttributesMapping:m,props:a});return h?g:null}),Nu=Y.createContext(void 0);function Pu(){let e=Y.useContext(Nu);if(e===void 0)throw Error(Et(51));return e}var Fu=function(e){return e.complete=`data-complete`,e.indeterminate=`data-indeterminate`,e.progressing=`data-progressing`,e}({}),Iu={status(e){return e===`progressing`?{[Fu.progressing]:``}:e===`complete`?{[Fu.complete]:``}:e===`indeterminate`?{[Fu.indeterminate]:``}:null}};function Lu(e,t){return t==null?`indeterminate progress`:e||`${t}%`}var Ru=Y.forwardRef(function(e,t){let{format:n,getAriaValueText:r=Lu,locale:i,max:a=100,min:o=0,value:s,render:c,className:l,...u}=e,[d,f]=Y.useState(),p=vn(n),m=`indeterminate`;Number.isFinite(s)&&(m=s===a?`complete`:`progressing`);let h=Kt(s,i,p.current),g=Y.useMemo(()=>({status:m}),[m]),_={"aria-labelledby":d,"aria-valuemax":a,"aria-valuemin":o,"aria-valuenow":s??void 0,"aria-valuetext":r(h,s),role:`progressbar`},v=Y.useMemo(()=>({formattedValue:h,max:a,min:o,setLabelId:f,state:g,status:m,value:s}),[h,a,o,f,g,m,s]),y=$e(`div`,e,{state:g,ref:t,props:[_,u],stateAttributesMapping:Iu});return(0,X.jsx)(Nu.Provider,{value:v,children:y})}),zu=Y.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{state:a}=Pu();return $e(`div`,e,{state:a,ref:t,props:i,stateAttributesMapping:Iu})}),Bu=Y.forwardRef(function(e,t){let{render:n,className:r,...i}=e,{max:a,min:o,value:s,state:c}=Pu(),l=Number.isFinite(s)&&s!==null?ye(s,o,a):null,u=Y.useCallback(()=>l==null?{}:{insetInlineStart:0,height:`inherit`,width:`${l}%`},[l]);return $e(`div`,e,{state:c,ref:t,props:[{style:u()},i],stateAttributesMapping:Iu})}),Vu=Y.forwardRef(function(e,t){let{className:n,render:r,children:i,...a}=e,{value:o,formattedValue:s,state:c}=Pu();
86return $e(`span`,e,{state:c,ref:t,props:[{"aria-hidden":!0,children:typeof i==`function`?i(o==null?`indeterminate`:s,o):o==null?null:s},a],stateAttributesMapping:Iu})}),Hu=Y.forwardRef(function(e,t){let{render:n,className:r,id:i,...a}=e,o=xt(i),{setLabelId:s,state:c}=Pu();return jt(()=>(s(o),()=>s(void 0)),[o,s]),$e(`span`,e,{state:c,ref:t,props:[{id:o},a],stateAttributesMapping:Iu})}),Uu=function(e){return e.checked=`data-checked`,e.unchecked=`data-unchecked`,e.disabled=`data-disabled`,e.readonly=`data-readonly`,e.required=`data-required`,e.valid=`data-valid`,e.invalid=`data-invalid`,e.touched=`data-touched`,e.dirty=`data-dirty`,e.filled=`data-filled`,e.focused=`data-focused`,e}({}),Wu={checked(e){return e?{[Uu.checked]:``}:{[Uu.unchecked]:``}},...Qt,...ot},Gu=Y.createContext(void 0);function Ku(){return Y.useContext(Gu)}var qu=Y.createContext(void 0);function Ju(){let e=Y.useContext(qu);if(e===void 0)throw Error(Et(52));return e}var Yu=Y.forwardRef(function(e,t){let{render:n,className:r,disabled:i=!1,readOnly:a=!1,required:o=!1,value:s,inputRef:c,nativeButton:l=!1,id:u,...d}=e,f=Ku(),{disabled:p,readOnly:m,required:h,checkedValue:g,touched:_=!1,validation:v,name:y}=f??{},b=f?.setCheckedValue??Rt,x=f?.setTouched??Rt,S=f?.registerControlRef??Rt,C=f?.registerInputRef??Rt,{setDirty:w,validityData:T,setTouched:E,setFilled:D,state:O,disabled:k}=Tt(),A=Go(),{labelId:j,getDescriptionProps:M}=Ct(),N=k||A.disabled||p||i,P=m||a,F=h||o,I=f?g===s:s===``,L=Y.useMemo(()=>on(s),[s]),ee=Y.useRef(null),te=Y.useRef(null),ne=En(e=>{e&&S(e,N)}),re=Ce(c,te,C);jt(()=>{te.current?.checked&&D(!0)},[D]),jt(()=>{if(te.current){if(N&&I){C(null);return}ee.current&&S(ee.current,N),C(te.current)}},[I,N,S,C]);let R=xt(),ie=Be({id:u,implicit:!1,controlRef:ee}),ae=l?void 0:ie,oe={role:`radio`,"aria-checked":I,"aria-required":F||void 0,"aria-readonly":P||void 0,"aria-labelledby":j,[Ye]:I?``:void 0,id:l?ie:R,onKeyDown(e){e.key===`Enter`&&e.preventDefault()},onClick(e){e.defaultPrevented||N||P||(e.preventDefault(),te.current?.dispatchEvent(new PointerEvent(`click`,{bubbles:!0,shiftKey:e.shiftKey,ctrlKey:e.ctrlKey,altKey:e.altKey,metaKey:e.metaKey})))},onFocus(e){e.defaultPrevented||N||P||!_||(te.current?.click(),x(!1))}},{getButtonProps:z,buttonRef:se}=Ge({disabled:N,native:l}),ce={type:`radio`,ref:re,id:ae,name:y,tabIndex:-1,style:y?Oe:pt,"aria-hidden":!0,...s===void 0?Ft:{value:L},disabled:N,checked:I,required:F,readOnly:P,onChange(e){if(e.nativeEvent.defaultPrevented||N||P||s===void 0)return;let t=qe(ct,e.nativeEvent);t.isCanceled||(E(!0),w(s!==T.initialValue),D(!0),b(s,t))},onFocus(){ee.current?.focus()}},le=Y.useMemo(()=>({...O,required:F,disabled:N,readOnly:P,checked:I}),[O,N,P,I,F]),ue=le,de=f!==void 0,fe=[t,ee,se,ne],pe=[oe,M,v?.getValidationProps??Ft,d,z],B=$e(`span`,e,{enabled:!de,state:le,ref:fe,props:pe,stateAttributesMapping:Wu});return(0,X.jsxs)(qu.Provider,{value:ue,children:[de?(0,X.jsx)(mt,{tag:`span`,render:n,className:r,state:le,refs:fe,props:pe,stateAttributesMapping:Wu}):B,(0,X.jsx)(`input`,{...ce})]})}),Xu=Y.forwardRef(function(e,t){let{render:n,className:r,keepMounted:i=!1,...a}=e,o=Ju(),s=o.checked,{mounted:c,transitionStatus:l,setMounted:u}=Ut(s),d={...o,transitionStatus:l},f=Y.useRef(null),p=i||c,m=$e(`span`,e,{ref:[t,f],state:d,props:a,stateAttributesMapping:Wu});return Lt({open:s,ref:f,onComplete(){s||u(!1)}}),p?m:null}),Zu=[ke],Qu=Y.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,name:u,inputRef:d,id:f,...p}=e,{setTouched:m,setFocused:h,shouldValidateOnChange:g,validationMode:_,name:v,disabled:y,state:b,validation:x,setDirty:S,setFilled:C,validityData:w}=Tt(),{labelId:T}=Ct(),{clearErrors:E}=He(),D=Uo(!0),O=y||i,k=v??u,A=xt(f),[j,M]=wn({controlled:c,default:l,name:`RadioGroup`,state:`value`}),N=En(s),P=En((e,t)=>{N(e,t),!t.isCanceled&&M(e)}),F=Y.useRef(null),I=Y.useRef(null),L=Y.useRef(null);function ee(e){let t;return d&&(typeof d==`function`?t=d(e):d.current=e),I.current=e,x.inputRef.current=e,t}let te=En((e,t=!1)=>{if(e){if(t){F.current===e&&(F.current=null);return}F.current??=e}}),ne=En(e=>{if(!e||e.disabled)return;L.current||=e;let t=I.current;if(e.checked||t==null||t.disabled)return ee(e)});Ne({id:A,commit:x.commit,value:j,controlRef:F,name:k,getValue:()=>j??null}),yt(j,()=>{E(k),S(j!==w.initialValue),C(j!=null),g()?x.commit(j):x.commit(j,!0);let e=L.current;j==null&&e&&!e.disabled&&ee(e)}
86);let[re,R]=Y.useState(!1),ie=p[`aria-labelledby`]??T??D?.legendId,ae={...b,disabled:O??!1,required:o??!1,readOnly:a??!1},oe=Y.useMemo(()=>({...b,checkedValue:j,disabled:O,validation:x,name:k,onValueChange:N,readOnly:a,registerControlRef:te,registerInputRef:ne,required:o,setCheckedValue:P,setTouched:R,touched:re}),[j,O,x,b,k,N,a,te,ne,o,P,R,re]),z={role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":O||void 0,"aria-readonly":a||void 0,"aria-labelledby":ie,onFocus(){h(!0)},onBlur(e){It(e.currentTarget,e.relatedTarget)||(m(!0),h(!1),_===`onBlur`&&x.commit(j))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(m(!0),R(!0),h(!0))}};return(0,X.jsx)(Gu.Provider,{value:oe,children:(0,X.jsx)(Ke,{render:n,className:r,state:ae,props:[z,x.getValidationProps,p],refs:[t],stateAttributesMapping:ot,enableHomeAndEndKeys:!1,modifierKeys:Zu})})});function $u({columns:e,value:t,onValueChange:n}){let r=(0,Y.useMemo)(()=>new Map(e.map(e=>[e.id,e.label])),[e]),i=(0,Y.useMemo)(()=>e.map(e=>e.id),[e]),a=t.filter(e=>r.has(e)),o=Z(`components.table.data.table.search.fields.all`);return a.length===1?o=r.get(a[0]??``)??o:a.length>1&&(o=Z(`components.table.data.table.search.fields.count`).replace(`{{count}}`,String(a.length))),(0,X.jsxs)(ut,{items:i,multiple:!0,value:a,onValueChange:n,itemToStringLabel:e=>r.get(e)??e,children:[(0,X.jsxs)(Qe,{render:(0,X.jsx)(U,{variant:`outline`,size:`sm`}),className:`h-8 max-w-48 shrink-0 gap-1.5 text-[13px]`,"aria-label":a.length===0?o:`${Z(`components.table.data.table.search.fields.label`)}: ${o}`,children:[(0,X.jsx)(ki,{className:`size-3.5`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`truncate`,children:o})]}),(0,X.jsxs)(Se,{className:`min-w-56 p-1.5`,children:[(0,X.jsx)(ft,{showTrigger:!1,placeholder:Z(`components.table.data.table.search.fields.filter`),"aria-label":Z(`components.table.data.table.search.fields.filter`)}),(0,X.jsx)(bn,{className:`py-3`,children:Z(`components.table.data.table.search.fields.empty`)}),(0,X.jsx)(Te,{className:`py-1.5`,children:e=>(0,X.jsx)(De,{value:e,className:`px-2.5`,children:r.get(e)??e},e)}),(0,X.jsx)(`div`,{className:`border-t px-1 pt-1.5`,children:(0,X.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,className:`w-full justify-start`,disabled:a.length===0,onClick:()=>n([]),children:[(0,X.jsx)(gi,{className:`size-3.5`,"aria-hidden":`true`}),Z(`components.table.data.table.search.fields.reset`)]})})]})]})}$u.displayName=`DataTableSearchFields`;var ed=new Set([`select`,`actions`]),td=`__mobile_list_no_sort__`;
86function nd(e){let t=e.columnDef.header;return typeof t==`string`?t:e.id}function rd(e){return nd(e.column)}function id({table:e,onRowClick:t,onNavigate:n,batchSize:r=20}){let i=e.getPrePaginationRowModel().rows,a=(0,Y.useMemo)(()=>i.map(e=>e.id).join(`|`),[i]),o=(0,Y.useMemo)(()=>e.getAllLeafColumns().filter(e=>e.getCanSort()&&!ed.has(e.id)),[e]),s=e.getState().sorting[0],c=s?.id??``,l=s?.desc??!1,u=c||td,d=o.find(e=>e.id===u),f=d?nd(d):`Default order`;return(0,X.jsxs)(`div`,{className:`space-y-3`,children:[o.length>0&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(Vt,{value:u,onValueChange:t=>{if(t===td){e.resetSorting();return}e.setSorting([{id:t,desc:l}])},children:[(0,X.jsx)(Dn,{className:`h-9 min-w-0 flex-1`,children:(0,X.jsx)(Mt,{placeholder:`Sort by`,children:f})}),(0,X.jsxs)(Dt,{alignItemWithTrigger:!1,align:`start`,children:[(0,X.jsx)(yn,{value:td,className:`px-4`,children:`Default order`}),o.map(e=>(0,X.jsx)(yn,{value:e.id,className:`px-4`,children:nd(e)},e.id))]})]}),(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,className:`h-9 shrink-0`,disabled:!c,onClick:()=>{c&&e.setSorting([{id:c,desc:!l}])},"aria-label":l?`Sort ascending`:`Sort descending`,children:[l?(0,X.jsx)(ia,{className:`size-4`,"aria-hidden":`true`}):(0,X.jsx)(ea,{className:`size-4`,"aria-hidden":`true`}),l?`Desc`:`Asc`]})]}),(0,X.jsx)(ad,{rows:i,onRowClick:t,onNavigate:n,batchSize:r},`${r}:${a}`)]})}function ad({rows:e,onRowClick:t,onNavigate:n,batchSize:r}){let i=(0,Y.useRef)(null),[a,o]=(0,Y.useState)(r),s=(0,Y.useMemo)(()=>e.slice(0,a),[e,a]),c=a<e.length;return(0,Y.useEffect)(function(){let t=i.current;if(!t||!c)return;let n=new IntersectionObserver(([t])=>{t?.isIntersecting&&o(t=>Math.min(t+r,e.length))},{rootMargin:`240px 0px`});return n.observe(t),()=>n.disconnect()},[r,c,e.length]),e.length===0?(0,X.jsx)(`div`,{className:`rounded-lg border border-dashed border-border px-4 py-10 text-center text-sm text-muted-foreground`,children:Z(`components.table.data.table.no.results`)}):(0,X.jsxs)(`div`,{className:`space-y-2`,children:[s.map(e=>{let r=e.getVisibleCells(),i=r.find(e=>e.column.id===`select`),a=r.find(e=>e.column.id===`actions`),o=r.filter(e=>!ed.has(e.column.id)),s=o[0],c=o.slice(1),l=!!n||!!t;return(0,X.jsx)(`article`,{"data-state":e.getIsSelected()&&`selected`,className:q(`rounded-lg border border-border bg-background p-3 shadow-xs`,`data-[state=selected]:border-primary/40 data-[state=selected]:bg-primary/5`),children:(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[i&&(0,X.jsx)(`div`,{className:`pt-0.5`,onClick:e=>e.stopPropagation(),children:me(i.column.columnDef.cell,i.getContext())}),(0,X.jsxs)(`button`,{type:`button`,disabled:!l,onClick:()=>{if(n){n(e.id);return}t?.(e.original)},className:q(`min-w-0 flex-1 text-left`,l?`cursor-pointer rounded focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`:`cursor-default`),children:[(0,X.jsx)(`div`,{className:`min-w-0 truncate text-sm font-medium text-foreground`,children:s?me(s.column.columnDef.cell,s.getContext()):`-`}),c.length>0&&(0,X.jsx)(`dl`,{className:`mt-2 grid gap-1.5 text-xs`,children:c.map(e=>(0,X.jsxs)(`div`,{className:`grid grid-cols-[6.5rem_minmax(0,1fr)] gap-2`,children:[(0,X.jsx)(`dt`,{className:`truncate text-muted-foreground`,children:rd(e)}),(0,X.jsx)(`dd`,{className:`min-w-0 truncate text-foreground`,children:me(e.column.columnDef.cell,e.getContext())})]},e.id))})]}),a&&(0,X.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:me(a.column.columnDef.cell,a.getContext())})]})},e.id)}),c&&(0,X.jsx)(`div`,{ref:i,className:`py-3 text-center text-xs text-muted-foreground`,children:`Loading more...`})]})}function od(e,t){return typeof e!=`string`&&typeof e!=`number`&&typeof e!=`boolean`?!1:String(e).toLowerCase().includes(t)}function sd(e,t){let n=t.trim().toLowerCase();return n?Array.isArray(e)?e.some(e=>od(e,n)):od(e,n):!0}function cd(e,t){let n=new Set(e.map(e=>e.id)),r=t.filter(e=>n.has(e));return r.length>0?new Set(r):n}function ld(e){return typeof e==`object`&&!!e&&`query`in e&&typeof e.query==`string`}function ud(e){return ld(e)?e.query:typeof e==`string`?e:``}
86function dd(e,t,n){return sd(e.getValue(t),ud(n))}dd.autoRemove=e=>!ud(e);var fd=250;function pd({columns:e,data:t,meta:n,primaryAction:r,secondaryActions:i=[],navigateTo:a,onRowClick:o,rowSelection:s,onRowSelectionChange:l,getRowId:u,pageSize:d=20,initialSorting:f,fixedLayout:p=!1,fillHeight:m=!1,multiSelect:h=!0,searchableColumns:g,onDeleteSelected:_,multipleDeleteString:v}){let[y,b]=(0,Y.useState)(f??[]),[x,S]=(0,Y.useState)([]),[C,w]=(0,Y.useState)({}),[T,E]=(0,Y.useState)({}),[D,O]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(``),j=(0,Y.useRef)(void 0),[M,N]=(0,Y.useState)([]);(0,Y.useEffect)(()=>()=>clearTimeout(j.current),[]);let P=e=>{if(A(e),clearTimeout(j.current),!e){O(``);return}j.current=setTimeout(()=>O(e),fd)},F=c(),I=g?cd(g,M):null,L=I?[...I].join(`|`):null,ee=(0,Y.useMemo)(()=>L!==null&&D?{query:D,columnKey:L}:D,[D,L]),te=(g??[]).filter(e=>M.includes(e.id)).map(e=>e.label),ne=te.length>0?Z(`components.table.data.table.search.placeholder.fields`).replace(`{{fields}}`,te.join(`, `)):Z(`components.table.data.table.search.placeholder`),re=s??T,R=l??E,ie=ue({data:t,columns:e,meta:n,getCoreRowModel:pe(),getPaginationRowModel:se(),onSortingChange:b,getSortedRowModel:de(),onColumnFiltersChange:S,getFilteredRowModel:le(),onColumnVisibilityChange:w,onRowSelectionChange:R,onGlobalFilterChange:O,enableMultiRowSelection:h,enableRowSelection:!0,globalFilterFn:I?dd:`includesString`,...I&&{getColumnCanGlobalFilter:e=>I.has(e.id)},getRowId:u,initialState:{pagination:{pageSize:d??20}},state:{sorting:y,columnFilters:x,columnVisibility:C,rowSelection:re,globalFilter:ee}}),ae=ie.getSelectedRowModel().rows.length,oe=!!_&&ae>0,z=r?.hidden?void 0:r,ce=i.filter(e=>!e.hidden),fe=ce.filter(e=>!!e.icon).slice(0,3),B=new Set(fe.map(e=>e.id)),V=ce.filter(e=>!B.has(e.id)),he=oe||ce.length>0,ge=oe||V.length>0,_e=e=>{if(!a)return;let t=ie.getRowModel().rows.find(t=>t.id===e);if(t){let e=`${t.original[a.key]}${a.additionalPath?`/${a.additionalPath}`:``}${a.params?`?${a.params}`:``}`;F(e,{relative:`path`})}};function ve(e){return q(`flex w-full items-center gap-2.5 rounded-md px-2.5 py-1.5 text-left text-[13.5px] outline-none`,`[&_svg]:size-[15px] [&_svg]:shrink-0 [&_svg]:stroke-[1.75]`,`disabled:pointer-events-none disabled:opacity-50`,e===`destructive`?`text-destructive hover:bg-destructive/10 focus-visible:bg-destructive/10`:`text-foreground hover:bg-accent focus-visible:bg-accent focus-visible:text-accent-foreground`)}function ye(){return(0,X.jsxs)(cr,{children:[(0,X.jsx)(Nn,{render:e=>(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:ve(`destructive`),...e,children:[(0,X.jsx)(Qi,{}),(0,X.jsxs)(`span`,{className:`flex-1`,children:[v?v.start:`Delete`,` (`,ie.getSelectedRowModel().rows.length,`)`,` `,v?v.end:`items`,ie.getSelectedRowModel().rows.length>1?`s`:``]})]})}),(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:`Are you absolutely sure?`}),(0,X.jsx)(Cr,{children:`This action cannot be undone. This will permanently delete the selected items.`})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{nativeButton:!1,render:e=>(0,X.jsxs)(U,{variant:`outline`,size:`sm`,...e,children:[(0,X.jsx)(Xa,{className:`size-4`}),`Cancel`]})}),(0,X.jsx)(sr,{nativeButton:!1,render:e=>(0,X.jsxs)(U,{variant:`destructive`,size:`sm`,...e,onClick:async t=>{await _?.(ie.getSelectedRowModel().rows.map(e=>e.original)),ie.resetRowSelection(),e.onClick?.(t)},children:[(0,X.jsx)(Qi,{className:``}),`Delete`]})})]})]})]})}function be({action:e,className:t}){return(0,X.jsxs)(U,{type:`button`,variant:e.variant??`outline`,size:`sm`,disabled:e.disabled,className:q(`h-8`,t,e.className),"aria-label":e.ariaLabel??e.label,"data-quick-help":e.quickHelpTarget,onClick:e.onClick,children:[e.icon,(0,X.jsx)(`span`,{children:e.label})]})}function xe({mobile:e=!1}){return(0,X.jsxs)(`div`,{role:`menu`,className:`flex flex-col`,children:[oe&&(0,X.jsx)(ye,{}),(e?V:ce).map((e,t)=>(0,X.jsxs)(Y.Fragment,{children:[e.separator===!0&&(t>0||oe)&&(0,X.jsx)(`div`,{role:`separator`,className:`mx-1.5 my-1 h-px bg-border`}),e.group!=null&&(0,X.jsx)(`div`,{className:`px-2.5 pt-2 pb-1 text-[10.5px] font-medium tracking-widest text-muted-foreground uppercase`,children:e.group}),(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,disabled:e.disabled,className:q(ve(e.variant),e.className),"aria-label":e.ariaLabel??e.label,"data-quick-help":e.quickHelpTarget,onClick:e.onClick,children:[e.icon,(0,X.jsx)(`span`,{className:`flex-1`,children:e.label})]})]},e.id))]})}return(0,X.jsxs)(`div`,{className:q(`flex min-w-0 flex-col`,m&&`h-full min-h-0`),children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 flex-col gap-2 pb-4 sm:flex-row sm:items-center`,children:[(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-2 sm:max-w-md`,children:[(0,X.jsxs)(`div`,{className:`relative min-w-0 flex-1`,children:[(0,X.jsx)(W,{placeholder:ne,value:k,onChange:e=>P(e.target.value),className:`peer h-8 w-full pl-8 text-[13px]`}),(0,X.jsx)(eo,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`})]}),g&&(0,X.jsx)($u,{columns:g,value:M,onValueChange:N})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center justify-between gap-2 sm:ml-auto sm:justify-end`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[z&&(0,X.jsx)(be,{action:z}),he&&(0,X.jsxs)(jn,{children:[(0,X.jsx)(Kn,{render:e=>(0,X.jsx)(U,{type:`button`,variant:`outline`,size:`sm`,className:`hidden size-8 p-0 md:inline-flex`,"aria-label":`Open table actions`,...e,children:(0,X.jsx)(kr,{className:`size-4`})})}),(0,X.jsx)(ur,{align:`end`,className:`w-58 p-1.5`,children:(0,X.jsx)(xe,{})})]}),ge&&(0,X.jsxs)(jn,{children:[(0,X.jsx)(Kn,{render:e=>(0,X.jsx)(U,{type:`button`,variant:`outline`,size:`sm`,className:`size-8 p-0 md:hidden`,"aria-label":`Open table actions`,...e,children:(0,X.jsx)(lo,{className:`size-4`})})}),(0,X.jsx)(ur,{align:`end`,className:`w-[min(18rem,calc(100vw-2rem))] p-1.5`,children:(0,X.jsx)(xe,{mobile:!0})})]}),fe.map(e=>(0,X.jsx)(U,{type:`button`,variant:e.variant??`outline`,size:`sm`,disabled:e.disabled,className:q(`h-8 w-8 p-0 md:hidden`,e.className),"aria-label":e.ariaLabel??e.label,"data-quick-help":e.quickHelpTarget,onClick:e.onClick,children:e.icon},e.id))]}),(0,X.jsx)(wu,{table:ie,className:q((z||he||ge)&&`ml-0`)})]})]}),(0,X.jsx)(`div`,{className:q(`md:hidden`,m&&[`min-h-0 flex-1 overflow-y-auto`,$n({style:`base`})]),children:(0,X.jsx)(id,{table:ie,onRowClick:o,onNavigate:a?_e:void 0})}),(0,X.jsx)(`div`,{className:q(`hidden overflow-x-auto md:block`,m&&[`min-h-0 flex-1 overflow-y-auto [&>[data-slot=table-container]]:overflow-visible`,$n({style:`base`}),`[&::-webkit-scrollbar]:h-2.5 [&::-webkit-scrollbar]:w-2.5`]),children:(0,X.jsxs)(vu,{className:q(p&&`table-fixed`),children:[(0,X.jsx)(yu,{className:q(m&&`sticky top-0 z-10 bg-background [&_th]:sha
86dow-[inset_0_-1px_0_var(--color-border)]`),children:ie.getHeaderGroups().map(e=>(0,X.jsx)(xu,{children:e.headers.map(e=>(0,X.jsx)(Su,{className:q(e.column.columnDef.meta?.className,e.column.id===`actions`&&`sticky right-0 bg-background`),children:e.isPlaceholder?null:me(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,X.jsx)(bu,{children:ie.getRowModel().rows?.length?ie.getRowModel().rows.map(e=>(0,X.jsx)(xu,{"data-state":e.getIsSelected()&&`selected`,className:q(`group`,(a||o)&&`cursor-pointer`),onClick:t=>{t.detail===2&&a?_e(e.id):o&&o(e.original)},children:e.getVisibleCells().map(e=>(0,X.jsx)(Cu,{className:q(e.column.columnDef.meta?.className,e.column.id===`actions`&&`sticky right-0 bg-background group-hover:bg-muted/50 group-data-[state=selected]:bg-muted`),children:me(e.column.columnDef.cell,e.getContext())},e.id))},e.id)):(0,X.jsx)(xu,{children:(0,X.jsx)(Cu,{colSpan:e.length,className:`h-24 text-center text-muted-foreground`,children:Z(`components.table.data.table.no.results`)})})})]})}),(0,X.jsx)(`div`,{className:q(`hidden md:block`,m&&`shrink-0`),children:(0,X.jsx)(Tu,{table:ie})})]})}function md(){let{activeOrganization:e}=z();if(!e?.id)throw Error(`useActiveOrganizationId() must be used within the ActiveOrganizationGuard (no active organization is set). Render this component under a dashboard route.`);return e.id}var hd=2e3;function gd(e={}){let{resetDelay:t=hd,onSuccess:n,onError:r}=e,[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=(0,Y.useRef)(null),l=(0,Y.useMemo)(()=>{let e=typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`,t=typeof document<`u`&&document.execCommand&&typeof document.execCommand==`function`;return e||t},[]),u=(0,Y.useCallback)(e=>new Promise((t,n)=>{try{let r=document.createElement(`textarea`);if(r.value=e,r.style.position=`fixed`,r.style.left=`-999999px`,r.style.top=`-999999px`,r.style.opacity=`0`,r.style.pointerEvents=`none`,document.body.appendChild(r),navigator.userAgent.match(/ipad|iphone/i)){let e=document.createRange();e.selectNodeContents(r);let t=window.getSelection();t?.removeAllRanges(),t?.addRange(e),r.setSelectionRange(0,999999)}else r.focus(),r.select();let i=document.execCommand(`copy`);document.body.removeChild(r),i?t():n(Error(`Failed to copy text using execCommand`))}catch(e){n(e instanceof Error?e:Error(String(e)))}}),[]),d=(0,Y.useCallback)(async e=>{try{await navigator.clipboard.writeText(e)}catch(t){if(t instanceof Error&&t.name===`NotAllowedError`)return u(e);throw t}},[u]),f=(0,Y.useCallback)(async e=>{if(c.current&&=(clearTimeout(c.current),null),s(null),a(!1),typeof e!=`string`){let e=Error(`Text must be a string`);throw s(e),r?.(e),e}if(!l){let e=Error(`Clipboard API is not supported in this browser`);throw s(e),r?.(e),e}try{typeof navigator<`u`&&navigator.clipboard&&typeof navigator.clipboard.writeText==`function`?await d(e):await u(e),a(!0),n?.(),t>0&&(c.current=setTimeout(()=>{a(!1),c.current=null},t))}catch(e){let t=e instanceof Error?e:Error(String(e));throw s(t),r?.(t),t}},[l,d,u,t,n,r]);return(0,Y.useEffect)(function(){return()=>{c.current&&clearTimeout(c.current)}},[]),{copyToClipboard:f,copied:i,error:o,isSupported:l}}async function _d(e,t,n,r){return await fetch(t,{method:`PUT`,body:e,headers:{"Content-Type":n,"Content-Length":r}})}function vd(e){let{onSuccess:t,onError:n,onBatchComplete:r,visibility:i=`public`,organizationId:a,showToast:o=!0,invalidateQueries:s=!0,fetchFileUrl:c=!1,getMimetype:l}=e??{},[u,d]=(0,Y.useState)(!1),f=R(),p=ie(),m=fe(),{activeOrganization:h}=z(),g=a??h?.id;if(!g)throw Error(`useFileUpload requires an organizationId or active organization context`);let _=f.files.list.queryKey(),v=B(f.files.startUpload.mutationOptions()),y=B(f.files.finishUpload.mutationOptions({onSuccess:()=>{s&&m.invalidateQueries({queryKey:_})}})),b=B(f.files.markUploadFailed.mutationOptions());return{uploadFile:(0,Y.useCallback)(async e=>{if(console.log(`uploadFile`,e),!e)return console.error(`No file provided`),null;if(u)return console.warn(`Upload already in progress`),null;d(!0);let r;try{let a=l?l(e):e.type,s=await v.mutateAsync({filename:e.name,sizeBytes:e.size,visibility:i,mimetype:a,organizationId:g});if(!s)throw Error(`No response from startUpload`);r=s.fileId;try{let n=await _d(e,s.presignedUrl,a,e.size.toString());if(!n.ok)throw Error(`Upload failed with status: ${n.status}`);await y.mutateAsync({fileId:s.fileId});let r;return c&&(r=(await p.files.list.query({organizationId:g,sorting:[{id:`createdAt`,desc:!0}]})).items?.find(e=>e.id===s.fileId)?.url),o&&J.success(`File uploaded successfully`),t?.(s.fileId,r),{fileId:s.fileId,fileUrl:r,file:e,status:`success`}}catch(t){console.error(`Upload error:`,t),r&&await b.mutateAsync({fileId:r});let i=t instanceof Error?t:Error(`Upload failed`);return o&&J.error(`Upload failed`),n?.(i,e),null}}catch(t){console.error(`Start upload error:`,t),r&&await b.mutateAsync({fileId:r});let i=t instanceof Error?t:Error(`Failed to start upload`);return o&&J.error(`Failed to start upload`),n?.(i,e),null}finally{d(!1)}},[u,v,y,b,p,i,g,c,o,t,n,l]),uploadFiles:(0,Y.useCallback)(async e=>{if(console.log(`uploadFiles`,e),!e||e.length===0)return console.error(`No files provided`),[];if(u)return console.warn(`Upload already in progress`),[];d(!0);try{let a=e.map(async e=>{let r;try{let n=l?l(e):e.type,a=await v.mutateAsync({filename:e.name,sizeBytes:e.size,visibility:i,mimetype:n,organizationId:g});if(!a)throw Error(`No response from startUpload`);r=a.fileId;let o=await _d(e,a.presignedUrl,n,e.size.toString());if(!o.ok)throw Error(`Upload failed with status: ${o.status}`);await y.mutateAsync({fileId:a.fileId});let s;return c&&(s=(await p.files.list.query({organizationId:g,sorting:[{id:`createdAt`,desc:!0}]})).items?.find(e=>e.id===a.fileId)?.url),t?.(a.fileId,s),{fileId:a.fileId,fileUrl:s,file:e,status:`success`}}catch(t){console.error(`Upload error:`,t),r&&await b.mutateAsync({fileId:r}).catch(e=>{console.error(`Failed to mark upload as failed:`,e)});let i=t instanceof Error?t:Error(`Upload failed`);return n?.(i,e),null}}),s=await Promise.all(a);if(o){let e=s.filter(e=>e!==null).length,t=s.length-e;t===0?J.success(`${e} file${e===1?``:`s`} uploaded successfully`):e===0?J.error(`Failed to upload ${t} file${t===1?``:`s`}`):J.warning(`${e} uploaded, ${t} failed`)}return r?.(s),s}finally{d(!1)}},[u,v,y,b,p,i,g,c,o,t,n,r,l]),uploading:u,ready:!!g}}var yd=1024,bd=3e4;function xd({getFilename:e,onCaptured:t}){let n=(0,Y.useRef)(!1),r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)(!1),{ready:o,uploadFile:s,uploading:c}=vd({fetchFileUrl:!0}),l=(0,Y.useRef)(e),u=(0,Y.useRef)(t),d=(0,Y.useRef)(s);(0,Y.useEffect)(()=>{l.current=e,u.current=t,d.current=s});let f=(0,Y.useCallback)(()=>{n.current=!1,r.current&&=(clearTimeout(r.current),null),a(!1)},[]);(0,Y.useEffect)(function(){let e=P.get$(`renderer.screenshot.response`).subscribe(async e=>{if(!n.current)return;f();let t=e.payload&&`dataUrl`in e.payload&&typeof e.payload.dataUrl==`string`?e.payload.dataUrl:null;if(!t)return;let r=l.current().trim()||`space`,i=await(await fetch(t)).blob(),a=new File([i],`${r}-space-${Date.now()}.png`,{type:`image/png`}),o=await d.current(a);o&&u.current({fileId:o.fileId,fileUrl:o.fileUrl})});return()=>{e.unsubscribe(),r.current&&=(clearTimeout(r.current),null)}},[f]);let p=!o||c||i;return{capture:(0,Y.useCallback)(()=>{p||(r.current&&clearTimeout(r.current),n.current=!0,a(!0),r.current=setTimeout(f,bd),P.publish({type:`renderer.screenshot.request`,payload:{width:yd,height:yd}}))},[p,f]),busy:p,isCapturing:i,isUploading:c,ready:o}}function Sd(e){let{activeOrganization:t,isLoadingSession:n,hasPermissions:r}=z();return n?(0,X.jsx)(`div`,{className:`flex h-svh w-svw items-center justify-center`,role:`status`,"aria-label":`Loading`,children:(0,X.jsx)(An,{className:`size-10`})}):t&&r(t.id,e.scope,e.action)?null:(0,X.jsx)(m,{to:e.fallback,replace:!0})}function Cd(e){let t=new Map;for(let[n,r]of Object.entries(e.cms?.entries??{})){let i=e.cms?.collections[r.collectionId]?.fields;t.set(n,i?{...r,fields:i}:r)}return t}function wd(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Td(e){return wd(e)?wd(e.system)&&wd(e.ui)&&wd(e.cms)&&wd(e.labels):!1}function Ed(e){return{languageData:e,entries:Cd(e),labels:I(e.labels?.translations)}}function Dd(e){let t=new Map;if(!e)return t;for(let[n,r]of Object.entries(e))Td(r)&&t.set(n,Ed(r));return t}function Od(e,t){return!e||!Td(t)?null:{[e]:t}}function kd(e){if(!wd(e))return!1;let t=Object.values(e);return t.length===0||t.every(Td)}function Ad(e){if(e==null)return null;if(Array.isArray(e)){let t=e[0];return wd(t)&&kd(t.languageData)?t.languageData:null}return wd(e)?kd(e.languageData)?e.languageData:kd(e)?e:null:null}
86function jd(e){L.getInstance().resources.setValue(te.LANGUAGE_DATA_RESOURCE,e)}function Md(e){let t=L.getInstance().resources;e&&t.getValue(te.LANGUAGE_DATA_RESOURCE)!==e||t.setValue(te.LANGUAGE_DATA_RESOURCE,void 0)}function Nd(e){let[t,n]=(0,Y.useState)(()=>L.getInstance().resources.getValue(te.LANGUAGE_DATA_RESOURCE));(0,Y.useEffect)(()=>{let e=L.getInstance().resources.getValue$(te.LANGUAGE_DATA_RESOURCE).subscribe(n);return()=>e.unsubscribe()},[]),(0,Y.useEffect)(()=>{if(e)return jd(e),()=>Md(e)},[e]);let r=(0,Y.useMemo)(()=>Dd(t),[t]),i=(0,Y.useCallback)(e=>e?r.get(e):r.values().next().value,[r]);return{languageData:t,languageMap:r,getPack:i,getEntry:(0,Y.useCallback)((e,t)=>i(t)?.entries.get(e),[i]),getLabel:(0,Y.useCallback)((e,t)=>i(t)?.labels.get(e),[i])}}function Pd({className:e,...t}){return(0,X.jsx)(ju,{"data-slot":`checkbox`,className:q(`peer relative flex size-4 shrink-0 items-center justify-center rounded-[5px] border border-transparent bg-input/90 transition-shadow outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,e),...t,children:(0,X.jsx)(Mu,{"data-slot":`checkbox-indicator`,className:`grid place-content-center text-current transition-none [&>svg]:size-3.5`,children:(0,X.jsx)(Ea,{})})})}function Fd({column:e,title:t,className:n}){if(!e.getCanSort())return(0,X.jsx)(`div`,{className:q(n),children:t});function r(e){switch(e){case`asc`:return(0,X.jsx)(Ji,{className:`size-3`});case`desc`:return(0,X.jsx)(sa,{className:`size-3`});default:return(0,X.jsx)(Oi,{className:`size-3`})}}return(0,X.jsx)(`div`,{className:q(`flex items-center gap-2`,n),children:(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:n=>(0,X.jsxs)(U,{type:`button`,variant:`ghost`,size:`sm`,className:`-ml-3 h-7 text-[11px] font-bold tracking-[0.06em] text-muted-foreground uppercase hover:text-foreground data-[state=open]:bg-accent`,...n,children:[(0,X.jsx)(`span`,{children:t}),(0,X.jsx)(`span`,{className:`ml-1 opacity-60`,children:r(e.getIsSorted())})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`start`,children:[(0,X.jsxs)(st,{onClick:()=>e.toggleSorting(!1),children:[(0,X.jsx)(Ji,{}),Z(`components.table.data.table.column.header.asc`)]}),(0,X.jsxs)(st,{onClick:()=>e.toggleSorting(!0),children:[(0,X.jsx)(sa,{}),Z(`components.table.data.table.column.header.desc`)]}),(0,X.jsx)(xe,{}),(0,X.jsxs)(st,{onClick:()=>e.toggleVisibility(!1),children:[(0,X.jsx)(li,{}),Z(`common.hide`)]})]})})]})})}var Id=(e,t)=>{if(e==null)return`-`;switch(t){case`toggle`:return(0,X.jsx)(fr,{variant:e?`default`:`secondary`,children:e?`Yes`:`No`});case`date`:return new Date(e).toLocaleDateString();case`image`:return typeof e==`object`&&e.url?(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded bg-muted`,children:(0,X.jsx)(`img`,{src:e.url,alt:e.alt||``,className:`h-full w-full object-cover`})}),e.alt&&(0,X.jsx)(`span`,{className:`max-w-[150px] truncate text-xs text-muted-foreground`,children:e.alt})]}):typeof e==`string`?(0,X.jsx)(`div`,{className:`flex size-10 shrink-0 items-center justify-center overflow-hidden rounded bg-muted`,children:(0,X.jsx)(`img`,{src:e,alt:``,className:`h-full w-full object-cover`})}):`-`;case`file`:return typeof e==`object`&&e.url?(0,X.jsxs)(`div`,{className:`flex flex-row items-center gap-2`,children:[(0,X.jsx)(oa,{className:`mr-2 size-4`}),(0,X.jsx)(`span`,{className:`max-w-[150px] truncate text-foreground`,children:e.filename})]}):`-`;case`gallery`:case`multi-reference`:return Array.isArray(e)?`${e.length} items`:`-`;case`color`:return(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`div`,{className:`size-4 rounded border`,style:{backgroundColor:e}}),e]});default:return String(e)}};function Ld(e){return`field.${e}`}function Rd(e,t){return[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`name`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.name`)}),cell:({row:e})=>
86(0,X.jsx)(`div`,{children:e.original.name})},{accessorKey:`slug`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`views.content-manager.columns.slug`)}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.slug})},{accessorKey:`status`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.status`)}),cell:({row:e})=>{let t=e.original.status;function n(e){return e===`draft`?`bg-yellow-500`:e===`published`?`bg-green-500`:`bg-red-500`}return(0,X.jsx)(fr,{className:q(n(t)),children:t&&t.charAt(0).toUpperCase()+t.slice(1)})}},...e.fields?.map(e=>({id:Ld(e.propertyName),accessorKey:`properties.${e.propertyName}`,header:({column:t})=>(0,X.jsx)(Fd,{column:t,title:e.name}),cell:({row:t})=>{let n=t.original.properties?.[e.propertyName];return(0,X.jsx)(`div`,{className:`truncate`,children:Id(n,e.type)})}}))||[],{id:`actions`,cell:({row:e})=>{let n=e.original;return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,variant:`ghost`,className:`h-8 w-8 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(xe,{}),t&&(0,X.jsxs)(st,{onClick:e=>{e.stopPropagation(),t(n)},children:[(0,X.jsx)(Qi,{className:`mr-2 h-4 w-4 text-red-500`}),(0,X.jsx)(`span`,{className:`text-red-500`,children:`Delete`})]})]})})]})}}]}var zd=typeof window<`u`?window.btoa?function(e){return btoa(unescape(encodeURIComponent(e)))}:function(e){let t=unescape(encodeURIComponent(e+``)),n=``;for(let e,r,i=0,a=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=`;t.charAt(i|0)||(a=`=`,i%1);n+=a.charAt(63&e>>8-i%1*8)){if(r=t.charCodeAt(i+=3/4),r>255)throw Error(`'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.`);e=e<<8|r}return n}:function(e){return Buffer.from(e).toString(`base64`)};function Bd(e,t){let n=Ud(e,t);return(t&&t.fallback!==void 0?t.fallback:Bd.defaults.fallback)===!0&&n===``&&(n=Ud(zd(e),t)),n}var Vd={bg:{Й:`Y`,й:`y`,X:`H`,x:`h`,Ц:`Ts`,ц:`ts`,Щ:`Sht`,щ:`sht`,Ъ:`A`,ъ:`a`,Ь:`Y`,ь:`y`},de:{Ä:`AE`,ä:`ae`,Ö:`OE`,ö:`oe`,Ü:`UE`,ü:`ue`},sr:{đ:`dj`,Đ:`DJ`}
86,uk:{И:`Y`,и:`y`,Й:`Y`,й:`y`,Ц:`Ts`,ц:`ts`,Ð¥:`Kh`,х:`kh`,Щ:`Shch`,щ:`shch`,Г:`H`,г:`h`}},Hd={};function Ud(e,t){if(typeof e!=`string`)throw Error(`slug() requires a string argument, received `+typeof e);if(!e.isWellFormed())throw Error(`slug() received a malformed string with lone surrogates`);typeof t==`string`&&(t={replacement:t}),t=t?Object.assign({},t):{},t.mode=t.mode||Bd.defaults.mode;let n=Bd.defaults.modes[t.mode],r=[`replacement`,`multicharmap`,`charmap`,`remove`,`lower`,`trim`];for(let e,i=0,a=r.length;i<a;i++)e=r[i],t[e]=e in t?t[e]:n[e];let i=Vd[t.locale]||Hd,a=[];for(let e in t.multicharmap){if(!Object.prototype.hasOwnProperty.call(t.multicharmap,e))continue;let n=e.length;a.indexOf(n)===-1&&a.push(n)}a=a.sort(function(e,t){return t-e});let o=t.mode===`rfc3986`?/[^\w\s\-.~]/:/[^A-Za-z0-9\s]/,s=``;for(let n,r=0,c=e.length;r<c;r++){n=e[r];let c=!1;for(let i=0;i<a.length;i++){let o=a[i],s=e.substr(r,o);if(t.multicharmap[s]){r+=o-1,n=t.multicharmap[s],c=!0;break}}c||(n=i[n]?i[n]:t.charmap[n]?t.charmap[n].replace(t.replacement,` `):n.includes(t.replacement)?n.replace(t.replacement,` `):n.replace(o,``)),s+=n}return t.remove&&(s=s.replace(t.remove,``)),t.trim&&(s=s.trim()),s=s.replace(/\s+/g,t.replacement),t.lower&&(s=s.toLowerCase()),s}var Wd={फ़:`Fi`,ग़:`Ghi`,ख़:`Khi`,क़:`Qi`,ड़:`ugDha`,ढ़:`ugDhha`,य़:`Yi`,ज़:`Za`,בִי:`i`,בֵ:`e`,בֵי:`e`,בֶ:`e`,בַ:`a`,בָ:`a`,בֹ:`o`,וֹ:`o`,בֻ:`u`,וּ:`u`,בּ:`b`,כּ:`k`,ךּ:`k`,פּ:`p`,שׁ:`sh`,שׂ:`s`,בְ:`e`,חֱ:`e`,חֲ:`a`,חֳ:`o`,בִ:`i`},Gd={À:`A`,Á:`A`,Â:`A`,Ã:`A`,Ä:`A`,Å:`A`,Æ:`AE`,Ç:`C`,È:`E`,É:`E`,Ê:`E`,Ë:`E`,Ì:`I`,Í:`I`,Î:`I`,Ï:`I`,Ð:`D`,Ñ:`N`,Ò:`O`,Ó:`O`,Ô:`O`,Õ:`O`,Ö:`O`,Ő:`O`,Ø:`O`,Ō:`O`,Ù:`U`,Ú:`U`,Û:`U`,Ü:`U`,Ű:`U`,Ý:`Y`,Þ:`TH`,ß:`ss`,à:`a`,á:`a`,â:`a`,ã:`a`,ä:`a`,Ã¥:`a`,æ:`ae`,ç:`c`,è:`e`,é:`e`,ê:`e`,ë:`e`,ì:`i`,í:`i`,î:`i`,ï:`i`,ð:`d`,ñ:`n`,ò:`o`,ó:`o`,ô:`o`,õ:`o`,ö:`o`,ő:`o`,ø:`o`,ō:`o`,Œ:`OE`,œ:`oe`,ù:`u`,ú:`u`,û:`u`,ü:`u`,ű:`u`,ý:`y`,þ:`th`,ÿ:`y`,ẞ:`SS`,α:`a`,β:`b`,γ:`g`,δ:`d`,ε:`e`,ζ:`z`,η:`h`,θ:`th`,ι:`i`,κ:`k`,λ:`l`,μ:`m`,ν:`n`,ξ:`3`,ο:`o`,π:`p`,ρ:`r`,σ:`s`,τ:`t`,υ:`y`,φ:`f`,χ:`x`,ψ:`ps`,ω:`w`,ά:`a`,έ:`e`,ί:`i`,ό:`o`,ύ:`y`,ή:`h`,ώ:`w`,ς:`s`,ϊ:`i`,ΰ:`y`,ϋ:`y`,ΐ:`i`,Α:`A`,Β:`B`,Γ:`G`,Δ:`D`,Ε:`E`,Ζ:`Z`,Η:`H`,Θ:`Th`,Ι:`I`,Κ:`K`,Λ:`L`,Μ:`M`,Ν:`N`,Ξ:`3`,Ο:`O`,Π:`P`,Ρ:`R`,Σ:`S`,Τ:`T`,Î¥:`Y`,Φ:`F`,Χ:`X`,Ψ:`PS`,Ω:`W`,Ά:`A`,Έ:`E`,Ί:`I`,Ό:`O`,Ύ:`Y`,Ή:`H`,Ώ:`W`,Ϊ:`I`,Ϋ:`Y`,ş:`s`,Ş:`S`,ı:`i`,İ:`I`,ğ:`g`,Ğ:`G`,а:`a`,б:`b`,в:`v`,г:`g`,д:`d`,е:`e`,ё:`yo`,ж:`zh`,з:`z`,и:`i`,й:`j`,к:`k`,л:`l`,м:`m`,н:`n`,о:`o`,п:`p`,р:`r`,с:`s`,т:`t`,у:`u`,ф:`f`,х:`h`,ц:`c`,ч:`ch`,ш:`sh`,щ:`sh`,ъ:`u`,ы:`y`,ь:``,э:`e`,ю:`yu`,я:`ya`,А:`A`,Б:`B`,В:`V`,Г:`G`,Д:`D`,Е:`E`,Ё:`Yo`,Ж:`Zh`,З:`Z`,И:`I`,Й:`J`,К:`K`,Л:`L`,М:`M`,Н:`N`,О:`O`,П:`P`,Р:`R`,С:`S`,Т:`T`,У:`U`,Ф:`F`,Ð¥:`H`,Ц:`C`,Ч:`Ch`,Ш:`Sh`,Щ:`Sh`,Ъ:`U`,Ы:`Y`,Ь:``,Э:`E`,Ю:`Yu`,Я:`Ya`,Є:`Ye`,І:`I`,Ї:`Yi`,Ґ:`G`,є:`ye`,і:`i`,ї:`yi`,ґ:`g`,č:`c`,ď:`d`,ě:`e`,ň:`n`,ř:`r`,Å¡:`s`,Å¥:`t`,ů:`u`,ž:`z`,Č:`C`,Ď:`D`,Ě:`E`,Ň:`N`,Ř:`R`,Å :`S`,Ť:`T`,Å®:`U`,Ž:`Z`,ľ:`l`,ĺ:`l`,ŕ:`r`,Ľ:`L`,Ĺ:`L`,Ŕ:`R`,ą:`a`,ć:`c`,ę:`e`,ł:`l`,ń:`n`,ś:`s`,ź:`z`,ż:`z`,Ą:`A`,Ć:`C`,Ę:`E`,Ł:`L`,Ń:`N`,Ś:`S`,Ź:`Z`,Å»:`Z`,ā:`a`,ē:`e`,Ä£:`g`,Ä«:`i`,Ä·:`k`,ļ:`l`,ņ:`n`,Å«:`u`,Ā:`A`,Ē:`E`,Ä¢:`G`,Ī:`I`,Ķ:`K`,Ä»:`L`,Ņ:`N`,Ū:`U`,Ø£:`a`,Ø¥:`i`,ب:`b`,ت:`t`,Ø«:`th`,ج:`g`,Ø­:`h`,Ø®:`kh`,د:`d`,ذ:`th`,ر:`r`,ز:`z`,س:`s`,Ø´:`sh`,ص:`s`,ض:`d`,Ø·:`t`,ظ:`th`,ع:`aa`,غ:`gh`,ف:`f`,ق:`k`,ك:`k`,ل:`l`,م:`m`,ن:`n`,ه:`h`,و:`o`,ي:`y`,Ø¡:`aa`,Ø©:`a`,Ø¢:`a`,ا:`a`,Ù¾:`p`,ژ:`zh`,Ú¯:`g`,چ:`ch`,Ú©:`k`,ی:`i`,ė:`e`,į:`i`,ų:`u`,Ė:`E`,Ä®:`I`,Ų:`U`,ț:`t`,Ț:`T`,Å£:`t`,Å¢:`T`,ș:`s`,Ș:`S`,ă:`a`,Ă:`A`,Ạ:`A`,Ả:`A`,Ầ:`A`,Ấ:`A`,Ậ:`A`,Ẩ:`A`,Ẫ:`A`,Ằ:`A`,Ắ:`A`,Ặ:`A`,Ẳ:`A`,Ẵ:`A`,Ẹ:`E`,Ẻ:`E`,Ẽ:`E`,Ề:`E`,Ế:`E`,Ệ:`E`,Ể:`E`,Ễ:`E`,Ị:`I`,Ỉ:`I`,Ĩ:`I`,Ọ:`O`,Ỏ:`O`,Ồ:`O`,Ố:`O`,Ộ:`O`,Ổ:`O`,Ỗ:`O`,Æ :`O`,Ờ:`O`,Ớ:`O`,Ợ:`O`,Ở:`O`,á» :`O`,Ụ:`U`,Ủ:`U`,Ũ:`U`,Ư:`U`,á»
86ª:`U`,Ứ:`U`,á»°:`U`,Ử:`U`,á»®:`U`,Ỳ:`Y`,á»´:`Y`,á»¶:`Y`,Ỹ:`Y`,Đ:`D`,ạ:`a`,ả:`a`,ầ:`a`,ấ:`a`,ậ:`a`,ẩ:`a`,ẫ:`a`,ằ:`a`,ắ:`a`,ặ:`a`,ẳ:`a`,ẵ:`a`,ẹ:`e`,ẻ:`e`,ẽ:`e`,ề:`e`,ế:`e`,ệ:`e`,ể:`e`,ễ:`e`,ị:`i`,ỉ:`i`,Ä©:`i`,ọ:`o`,ỏ:`o`,ồ:`o`,ố:`o`,ộ:`o`,ổ:`o`,ỗ:`o`,Æ¡:`o`,ờ:`o`,ớ:`o`,ợ:`o`,ở:`o`,ỡ:`o`,ụ:`u`,á»§:`u`,Å©:`u`,ư:`u`,ừ:`u`,ứ:`u`,á»±:`u`,á»­:`u`,ữ:`u`,ỳ:`y`,ỵ:`y`,á»·:`y`,ỹ:`y`,đ:`d`,Ә:`AE`,ә:`ae`,Ғ:`GH`,ғ:`gh`,Қ:`KH`,қ:`kh`,Ò¢:`NG`,Ò£:`ng`,Ò®:`UE`,Ò¯:`ue`,Ò°:`U`,Ò±:`u`,Òº:`H`,Ò»:`h`,Ó¨:`OE`,Ó©:`oe`,ђ:`dj`,ј:`j`,љ:`lj`,њ:`nj`,ћ:`c`,џ:`dz`,Ђ:`Dj`,Ј:`j`,Љ:`Lj`,Њ:`Nj`,Ћ:`C`,Џ:`Dz`,nj:`nj`,lj:`lj`,Nj:`NJ`,Lj:`LJ`,अ:`a`,आ:`aa`,ए:`e`,ई:`ii`,ऍ:`ei`,ऎ:`ae`,ऐ:`ai`,इ:`i`,ओ:`o`,ऑ:`oi`,ऒ:`oii`,ऊ:`uu`,औ:`ou`,उ:`u`,ब:`B`,भ:`Bha`,च:`Ca`,छ:`Chha`,ड:`Da`,ढ:`Dha`,फ:`Fa`,ग:`Ga`,घ:`Gha`,ग़:`Ghi`,ह:`Ha`,ज:`Ja`,झ:`Jha`,क:`Ka`,ख:`Kha`,ख़:`Khi`,ल:`L`,ळ:`Li`,ऌ:`Li`,ऴ:`Lii`,ॡ:`Lii`,म:`Ma`,न:`Na`,ङ:`Na`,ञ:`Nia`,ण:`Nae`,ऩ:`Ni`,ॐ:`oms`,प:`Pa`,à
86¤•़:`Qi`,र:`Ra`,ऋ:`Ri`,ॠ:`Ri`,ऱ:`Ri`,स:`Sa`,श:`Sha`,ष:`Shha`,ट:`Ta`,त:`Ta`,ठ:`Tha`,द:`Tha`,थ:`Tha`,ध:`Thha`,ड़:`ugDha`,ढ़:`ugDhha`,व:`Va`,य:`Ya`,य़:`Yi`,ज़:`Za`,ə:`e`,Ə:`E`,ა:`a`,ბ:`b`,გ:`g`,დ:`d`,ე:`e`,ვ:`v`,ზ:`z`,თ:`t`,ი:`i`,კ:`k`,ლ:`l`,მ:`m`,ნ:`n`,ო:`o`,პ:`p`,ჟ:`zh`,რ:`r`,ს:`s`,ტ:`t`,უ:`u`,ფ:`p`,ქ:`k`,ღ:`gh`,ყ:`q`,შ:`sh`,ჩ:`ch`,ც:`ts`,ძ:`dz`,წ:`ts`,ჭ:`ch`,ხ:`kh`,ჯ:`j`,ჰ:`h`,ב:`v`,גּ:`g`,ג:`g`,ד:`d`,דּ:`d`,ה:`h`,ו:`v`,ז:`z`,ח:`h`,ט:`t`,י:`y`,כ:`kh`,ך:`kh`,ל:`l`,מ:`m`,ם:`m`,× :`n`,ן:`n`,ס:`s`,פ:`f`,×£:`f`,×¥:`ts`,צ:`ts`,×§:`k`,ר:`r`,תּ:`t`,ת:`t`};Bd.charmap=Object.assign({},Gd),Bd.multicharmap=Object.assign({},Wd),Bd.defaults={charmap:Bd.charmap,mode:`pretty`,modes:{rfc3986:{replacement:`-`,remove:null,lower:!0,charmap:Bd.charmap,multicharmap:Bd.multicharmap,trim:!0},pretty:{replacement:`-`,remove:null,lower:!0,charmap:Bd.charmap,multicharmap:Bd.multicharmap,trim:!0}},multicharmap:Bd.multicharmap,fallback:!0},Bd.reset=function(){Bd.defaults.modes.rfc3986.charmap=Bd.defaults.modes.pretty.charmap=Bd.charmap=Bd.defaults.charmap=Object.assign({},Gd),Bd.defaults.modes.rfc3986.multicharmap=Bd.defaults.modes.pretty.multicharmap=Bd.multicharmap=Bd.defaults.multicharmap=Object.assign({},Wd),Hd=``},Bd.extend=function(e){let t=Object.keys(e),n={},r={};for(let i=0;i<t.length;i++)t[i].length>1?n[t[i]]=e[t[i]]:r[t[i]]=e[t[i]];Object.assign(Bd.charmap,r),Object.assign(Bd.multicharmap,n)},Bd.setLocale=function(e){Hd=Vd[e]||{}};function Kd(e){let t={id:H().uuid().optional(),collectionId:H().uuid(),name:H().default(``),slug:H().default(``),status:Xe([`draft`,`published`,`archived`]).default(`draft`)},n=lt({fileid:H().optional(),url:H(),alt:H().optional(),filename:H().optional(),mimetype:H().optional(),sizeBytes:We().optional(),region:H().optional(),visibility:H().optional(),status:H().optional(),checksumSha256:H().optional(),metadata:kn(et()).optional(),createdAt:qt().optional(),updatedAt:qt().optional(),deletedAt:qt().optional()}).optional().nullable(),r={};return e.forEach(e=>{let t;switch(e.type){case`text`:case`formatted-text`:case`link`:case`color`:t=e.required?H().min(1):H().optional();break;case`number`:t=e.required?We():We().optional();break;case`date`:case`datetime`:t=e.required?H():H().optional();break;case`toggle`:t=be().default(!1);break;case`option`:return e.required?H():H().optional();case`image`:case`file`:t=n;break;case`video`:{let r=_t([H(),lt({mode:Xe([`file`,`url`]).default(`url`),url:H().optional(),file:n})]);t=e.required?r:r.optional().nullable();break}case`group`:case`iframe`:t=e.required?H().min(1):H().optional();break;case`template`:{let n=Xe([`info`,`article`,`gallery`]);t=e.required?n:n.optional();break}case`placement`:{let n=Xe([`center`,`left`,`right`,`edge-left`,`edge-right`]);t=e.required?n:n.optional();break}case`gallery`:case`multi-reference`:t=Yt(H()).default([]);break;case`reference`:t=e.required?H().uuid():H().uuid().optional();break;default:t=et().optional()}r[e.propertyName]=t}),t.properties=lt(r).default({}),lt(t)}var qd={center:`justify-center bg-black/40 px-4`,left:`justify-center px-4 md:justify-start md:pr-12 md:pl-[max(1rem,min(13rem,(100vw_-_3rem)/3))]`,right:`justify-center px-4 md:justify-end md:pl-12 md:pr-[max(1rem,min(13rem,(100vw_-_3rem)/3))]`},Jd={center:`max-w-[min(90vw,820px)]`,left:`max-w-[min(100%,26rem)]`,right:`max-w-[min(100%,26rem)]`},Yd=`border border-white/10 bg-black/50 text-white shadow-2xl ring-1 ring-inset ring-white/10 backdrop-blur-lg`,Xd=`bg-black/50 text-white ring-1 ring-inset ring-white/10`,Zd=`inline-flex items-center justify-center rounded-md text-white/75 transition-colors hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/45 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent`,Qd=`overflow-y-auto [scrollbar-color:rgba(255,255,255,0.28)_transparent] [scrollbar-width:thin] [&::-webkit-scrollbar]:w-1 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-white/25 hover:[&::-webkit-scrollbar-thumb]:bg-white/35`;function $d(e){switch(e){case`left`:case`edge-left`:return{mode:`overlay`,side:`left`};case`right`:case`edge-right`:return{mode:`overlay`,side:`right`};case`center`:return{mode:`overlay`,side:`center`};default:return{mode:`overlay`,side:`center`}}}function ef(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var tf=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,nf=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,rf={};function af(e,t){return((t||rf).jsx?nf:tf).test(e)}var of=/[ \t\n\f\r]/g;function sf(e){return typeof e==`object`?e.type===`text`&&cf(e.value):cf(e)}function cf(e){return e.replace(of,``)===``}var lf=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};lf.prototype.normal={},lf.prototype.property={},lf.prototype.space=void 0;function uf(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new lf(n,r,t)}function df(e){return e.toLowerCase()}var ff=class{constructor(e,t){this.attribute=t,this.property=e}};ff.prototype.attribute=``,ff.prototype.booleanish=!1,ff.prototype.boolean=!1,ff.prototype.commaOrSpaceSeparated=!1,ff.prototype.commaSeparated=!1,ff.prototype.defined=!1,ff.prototype.mustUseProperty=!1,ff.prototype.number=!1,ff.prototype.overloadedBoolean=!1,ff.prototype.property=``,ff.prototype.spaceSeparated=!1,ff.prototype.space=void 0;var pf=t({boolean:()=>hf,booleanish:()=>gf,commaOrSpaceSeparated:()=>bf,commaSeparated:()=>yf,number:()=>Q,overloadedBoolean:()=>_f,spaceSeparated:()=>vf}),mf=0,hf=xf(),gf=xf(),_f=xf(),Q=xf(),vf=xf(),yf=xf(),bf=xf();function xf(){return 2**++mf}var Sf=Object.keys(pf),Cf=class extends ff{constructor(e,t,n,r){let i=-1;
vendor: 4,297 bytes, line 86
86if(super(e,t),wf(this,`space`,r),typeof n==`number`)for(;++i<Sf.length;){let e=Sf[i];wf(this,Sf[i],(n&pf[e])===pf[e])}}};Cf.prototype.defined=!0;function wf(e,t,n){n&&(e[t]=n)}function Tf(e){let t={},n={};for(let[r,i]of Object.entries(e.properties)){let a=new Cf(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(a.mustUseProperty=!0),t[r]=a,n[df(r)]=r,n[df(a.attribute)]=r}return new lf(t,n,e.space)}var Ef=Tf({properties:{ariaActiveDescendant:null,ariaAtomic:gf,ariaAutoComplete:null,ariaBusy:gf,ariaChecked:gf,ariaColCount:Q,ariaColIndex:Q,ariaColSpan:Q,ariaControls:vf,ariaCurrent:null,ariaDescribedBy:vf,ariaDetails:null,ariaDisabled:gf,ariaDropEffect:vf,ariaErrorMessage:null,ariaExpanded:gf,ariaFlowTo:vf,ariaGrabbed:gf,ariaHasPopup:null,ariaHidden:gf,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:vf,ariaLevel:Q,ariaLive:null,ariaModal:gf,ariaMultiLine:gf,ariaMultiSelectable:gf,ariaOrientation:null,ariaOwns:vf,ariaPlaceholder:null,ariaPosInSet:Q,ariaPressed:gf,ariaReadOnly:gf,ariaRelevant:null,ariaRequired:gf,ariaRoleDescription:vf,ariaRowCount:Q,ariaRowIndex:Q,ariaRowSpan:Q,ariaSelected:gf,ariaSetSize:Q,ariaSort:null,ariaValueMax:Q,ariaValueMin:Q,ariaValueNow:Q,ariaValueText:null,role:null},transform(e,t){return t===`role`?t:`aria-`+t.slice(4).toLowerCase()}});function Df(e,t){return t in e?e[t]:t}function Of(e,t){return Df(e,t.toLowerCase())}var kf=Tf({attributes:{acceptcharset:`accept-charset`,classname:`class`,htmlfor:`for`,httpequiv:`http-equiv`},mustUseProperty:[`checked`,`multiple`,`muted`,`selected`],properties:{abbr:null,accept:yf,acceptCharset:vf,accessKey:vf,action:null,allow:null,allowFullScreen:hf,allowPaymentRequest:hf,allowUserMedia:hf,alpha:hf,alt:null,as:null,async:hf,autoCapitalize:null,autoComplete:vf,autoFocus:hf,autoPlay:hf,blocking:vf,capture:null,charSet:null,checked:hf,cite:null,className:vf,closedBy:null,colorSpace:null,cols:Q,colSpan:Q,command:null,commandFor:null,content:null,contentEditable:gf,controls:hf,controlsList:vf,coords:Q|yf,crossOrigin:null,data:null,dateTime:null,decoding:null,default:hf,defer:hf,dir:null,dirName:null,disabled:hf,download:_f,draggable:gf,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:hf,formTarget:null,headers:vf,height:Q,hidden:_f,high:Q,href:null,hrefLang:null,htmlFor:vf,httpEquiv:vf,id:null,imageSizes:null,imageSrcSet:null,inert:hf,inputMode:null,integrity:null,is:null,isMap:hf,itemId:null,itemProp:vf,itemRef:vf,itemScope:hf,itemType:vf,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:hf,low:Q,manifest:null,max:null,maxLength:Q,media:null,method:null,min:null,minLength:Q,multiple:hf,muted:hf,name:null,nonce:null,noModule:hf,noValidate:hf,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:hf,optimum:Q,pattern:null,ping:vf,placeholder:null,playsInl
86ine:hf,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:hf,referrerPolicy:null,rel:vf,required:hf,reversed:hf,rows:Q,rowSpan:Q,sandbox:vf,scope:null,scoped:hf,seamless:hf,selected:hf,shadowRootClonable:hf,shadowRootCustomElementRegistry:hf,shadowRootDelegatesFocus:hf,shadowRootMode:null,shadowRootSerializable:hf,shape:null,size:Q,sizes:null,slot:null,span:Q,spellCheck:gf,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Q,step:null,style:null,tabIndex:Q,target:null,title:null,translate:null,type:null,typeMustMatch:hf,useMap:null,value:gf,width:Q,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:vf,axis:null,background:null,bgColor:null,border:Q,borderColor:null,bottomMargin:Q,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:hf,declare:hf,event:null,face:null,frame:null,frameBorder:null,hSpace:Q,leftMargin:Q,link:null,longDesc:null,lowSrc:null,marginHeight:Q,marginWidth:Q,noResize:hf,noHref:hf,noShade:hf,noWrap:hf,object:null,profile:null,prompt:null,rev:null,rightMargin:Q,rules:null,scheme:null,scrolling:gf,standby:null,summary:null,text:null,topMargin:Q,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Q,allowTransparency:null,autoCorrect:null,autoSave:null,credentialless:hf,disablePictureInPicture:hf,disableRemotePlayback:hf,exportParts:yf,part:vf,prefix:null,property:null,results:Q,security:null,unselectable:null},space:`html`,transform:Of}),Af=Tf({attributes:{accentHeight:`accent-height`,alignmentBaseline:`alignment-baseline`,arabicForm:`arabic-form`,baselineShift:`baseline-shift`,capHeight:`cap-height`,className:`class`,clipPath:`clip-path`,clipRule:`clip-rule`,colorInterpolation:`color-interpolation`,colorInterpolationFilters:`color-interpolation-filters`,colorProfile:`color-profile`,colorRendering:`color-rendering`,crossOrigin:`crossorigin`,dataType:`datatype`,dominantBaseline:`dominant-baseline`,enableBackground:`enable-background`,fillOpacity:`fill-opacity`,fillRule:`fill-rule`,floodColor:`flood-color`,floodOpacity:`flood-opacity`,fontFamily:`font-family`,fontSize:`font-size`,fontSizeAdjust:`font-size-adjust`,fontStretch:`font-stretch`,fontStyle:`font-style`,fontVariant:`font-variant`,fontWeight:`font-weight`,glyphName:`glyph-name`,glyphOrientationHorizontal:`glyph-orientation-horizontal`,glyphOrientationVertical:`glyph-orientation-vertical`,hrefLang:`hreflang`,horizAdvX:`horiz-adv-x`,horizOriginX:`horiz-origin-x`,horizOriginY:`horiz-origin-y`,imageRendering:`image-rendering`,letterSpacing:`letter-spacing`,lightingColor:`lighting-color`,markerEnd:`marker-end`,markerMid:`marker-mid`,markerStart:`marker-start`,maskType:`mask-type`,navDown:`nav-down`,navDownLeft:`nav-down-left`,navDownRight:`nav-down-right`,navLeft:`nav-left`,navNext:`nav-next`,navPrev:`nav-prev`,navRight:`nav-right`,navUp:`nav-up`,navUpLeft:`nav-up-left`,navUpRight:`nav-up-right`,onAbort:`onabort`,onActivate:`onactivate`,onAfterPrint:`onafterprint`,onBeforePrint:`onbeforeprint`,onBegin:`onbegin`,onCancel:`oncancel`,onCanPlay:`oncanplay`,onCanPlayThrough:`oncanplaythrough`,onChange:`onchange`,onClick:`onclick`,onClose:`onclose`,onCopy:`oncopy`,onCueChange:`oncuechange`,onCut:`oncut`,onDblClick:`ondblclick`,onDrag:`ondrag`,onDragEnd:`ondragend`,onDragEnter:`ondragenter`,onDragExit:`ondragexit`,onDragLeave:`ondragleave`,onDragOver:`ondragover`,onDragStart:`ondragstart`,onDrop:`ondrop`,onDurationChange:`ondurationchange`,onEmptied:`onemptied`,onEnd:`onend`,onEnded:`onended`,onError:`onerror`,onFocus:`onfocus`,onFocusIn:`onfocusin`,onFocusOut:`onfocusout`,onHashChange:`onhashchange`,onInput:`oninput`,onInvalid:`oninvalid`,onKeyDown:`onkeydown`,onKeyPress:`onkeypress`,onKeyUp:`onkeyup`,onLoad:`onload`,onLoadedData:`onloadeddata`,onLoadedMetadata:`onloadedmetadata`,onLoadStart:`onloadstart`,onMessage:`onmessage`,onMouseDown:`onmousedown`,onMouseEnter:`onmouseenter`,onMouseLeave:`onmouseleave`,onMouseMove:`onmousemove`,onMouseOut:`onmouseout`,onMouseOver:`onmouseover`,onMouseUp:`onmouseup`,onMouseWheel:`onmousewheel`,onOffline:`onoffline`,onOnline:`ononline`,onPageHide:`onpagehide`,onPageShow:`onpageshow`,onPaste:`onpaste`,onPause:`onpause`,onPlay:`onplay`,onPlaying:`onplaying`,onPopState:`onpopstate`,onProgress:`onprogress`,onRateChange:`onratechange`,onRepeat:`onrepeat`,onReset:`onreset`,onResize:`onresize`,onScroll:`onscroll`,onSeeked:`onseeked`,onSeeking:`onseeking`,onSelect:`onselect`,onShow:`onshow`,onStalled:`onstalled`,onStorage:`onstorage`,onSubmit:`onsubmit`,onSuspend:`onsuspend`,onTimeUpdate:`ontimeupdate`,onToggle:`ontoggle`,onUnload:`onunload`,onVolumeChange:`onvolumechange`,onWaiting:`onwaiting`,onZoom:`onzoom`,overlinePosition:`overline-position`,overlineThickness:`overline-thickness`,paintOrder:`paint-order`,panose1:`panose-1`,pointerEvents:`pointer-events`,referrerPolicy:`referrerpolicy`,renderingIntent:`rendering-intent`,shapeRendering:`shape-rendering`,stopColor:`stop-color`,stopOpacity:`stop-opacity`,strikethroughPosition:`strikethrough-position`,strikethroughThickness:`strikethrough-thickness`,strokeDashArray:`stroke-dasharray`,strokeDashOffset:`stroke-dashoffset`,strokeLineCap:`stroke-linecap`,strokeLineJoin:`stroke-linejoin`,strokeMiterLimit:`stroke-miterlimit`,strokeOpacity:`stroke-opacity`,strokeWidth:`stroke-width`,tabIndex:`tabindex`,textAnchor:`text-anchor`,textDecoration:`text-decoration`,textRendering:`text-rendering`,transformOrigin:`transform-origin`,typeOf:`typeof`,underlinePosition:`underline-position`,underlineThickness:`underline-thickness`,unicodeBidi:`unicode
86-bidi`,unicodeRange:`unicode-range`,unitsPerEm:`units-per-em`,vAlphabetic:`v-alphabetic`,vHanging:`v-hanging`,vIdeographic:`v-ideographic`,vMathematical:`v-mathematical`,vectorEffect:`vector-effect`,vertAdvY:`vert-adv-y`,vertOriginX:`vert-origin-x`,vertOriginY:`vert-origin-y`,wordSpacing:`word-spacing`,writingMode:`writing-mode`,xHeight:`x-height`,playbackOrder:`playbackorder`,timelineBegin:`timelinebegin`},properties:{about:bf,accentHeight:Q,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Q,amplitude:Q,arabicForm:null,ascent:Q,attributeName:null,attributeType:null,azimuth:Q,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Q,by:null,calcMode:null,capHeight:Q,className:vf,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:Q,diffuseConstant:Q,direction:null,display:null,dur:null,divisor:Q,dominantBaseline:null,download:hf,dx:null,dy:null,edgeMode:null,editable:null,elevation:Q,enableBackground:null,end:null,event:null,exponent:Q,externalResourcesRequired:null,fill:null,fillOpacity:Q,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:yf,g2:yf,glyphName:yf,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Q,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Q,horizOriginX:Q,horizOriginY:Q,id:null,ideographic:Q,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Q,k:Q,k1:Q,k2:Q,k3:Q,k4:Q,kernelMatrix:bf,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Q,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskType:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:Q,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:Q,overlineThickness:Q,paintOrder:null,panose1:null,path:null,pathLength:Q,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:vf,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Q,pointsAtY:Q,pointsAtZ:Q,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:bf,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:bf,rev:bf,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:bf,requiredFeatures:bf,requiredFonts:bf,requiredFormats:bf,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,
vendor: 8,039 bytes, lines 86-87
86scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:Q,specularExponent:Q,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Q,strikethroughThickness:Q,string:null,stroke:null,strokeDashArray:bf,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Q,strokeOpacity:Q,strokeWidth:null,style:null,surfaceScale:Q,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:bf,tabIndex:Q,tableValues:null,target:null,targetX:Q,targetY:Q,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:bf,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Q,underlineThickness:Q,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Q,values:null,vAlphabetic:Q,vMathematical:Q,vectorEffect:null,vHanging:Q,vIdeographic:Q,version:null,vertAdvY:Q,vertOriginX:Q,vertOriginY:Q,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Q,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:`svg`,transform:Df}),jf=Tf({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:`xlink`,transform(e,t){return`xlink:`+t.slice(5).toLowerCase()}}),Mf=Tf({attributes:{xmlnsxlink:`xmlns:xlink`},properties:{xmlnsXLink:null,xmlns:null},space:`xmlns`,transform:Of}),Nf=Tf({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:`xml`,transform(e,t){return`xml:`+t.slice(3).toLowerCase()}}),Pf={classId:`classID`,dataType:`datatype`,itemId:`itemID`,strokeDashArray:`strokeDasharray`,strokeDashOffset:`strokeDashoffset`,strokeLineCap:`strokeLinecap`,strokeLineJoin:`strokeLinejoin`,strokeMiterLimit:`strokeMiterlimit`,typeOf:`typeof`,xLinkActuate:`xlinkActuate`,xLinkArcRole:`xlinkArcrole`,xLinkHref:`xlinkHref`,xLinkRole:`xlinkRole`,xLinkShow:`xlinkShow`,xLinkTitle:`xlinkTitle`,xLinkType:`xlinkType`,xmlnsXLink:`xmlnsXlink`},Ff=/[A-Z]/g,If=/-[a-z]/g,Lf=/^data[-\w.:]+$/i;function Rf(e,t){let n=df(t),r=t,i=ff;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)===`data`&&Lf.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(If,Bf);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!If.test(e)){let n=e.replace(Ff,zf);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Cf}return new i(r,t)}function zf(e){return`-`+e.toLowerCase()}function Bf(e){return e.charAt(1).toUpperCase()}var Vf=uf([Ef,kf,jf,Mf,Nf],`html`),Hf=uf([Ef,Af,jf,Mf,Nf],`svg`);function Uf(e){return e.join(` `).trim()}var Wf=n(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g;function u(e,t){if(typeof e!=`string`)throw TypeError(`First argument must be a string`);if(!e)return[];t||={};var l=1,u=1;function f(e){var t=e.match(r);t&&(l+=t.length);var n=e.lastIndexOf(`
87`);u=~n?e.length-n:u+e.length}function p(){var e={line:l,column:u};return function(t){return t.position=new m(e),_(),t}}function m(e){this.start=e,this.end={line:l,column:u},this.source=t.source}m.prototype.content=e;function h(n){var r=Error(t.source+`:`+l+`:`+u+`: `+n);if(r.reason=n,r.filename=t.source,r.line=l,r.column=u,r.source=e,!t.silent)throw r}function g(t){var n=t.exec(e);if(n){var r=n[0];return f(r),e=e.slice(r.length),n}}function _(){g(i)}function v(e){var t;for(e||=[];t=y();)t!==!1&&e.push(t);return e}function y(){var t=p();if(e.charAt(0)==`/`&&e.charAt(1)==`*`){for(var n=2;e.charAt(n)!=``&&(e.charAt(n)!=`*`||e.charAt(n+1)!=`/`);)++n;if(n+=2,e.charAt(n-1)===``)return h(`End of comment missing`);var r=e.slice(2,n-2);return u+=2,f(r),e=e.slice(n),u+=2,t({type:`comment`,comment:r})}}function b(){var e=p(),t=g(a);if(t){if(y(),!g(o))return h(`property missing ':'`);var r=g(s),i=e({type:`declaration`,property:d(t[0].replace(n,``)),value:r?d(r[0].replace(n,``)):``});return g(c),i}}function x(){var e=[];v(e);for(var t;t=b();)t!==!1&&(e.push(t),v(e));return e}return _(),x()}function d(e){return e?e.replace(l,``):``}t.exports=u})),Gf=n((e=>{var t=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.default=r;var n=t(Wf());function r(e,t){let r=null;if(!e||typeof e!=`string`)return r;let i=(0,n.default)(e),a=typeof t==`function`;return i.forEach(e=>{if(e.type!==`declaration`)return;let{property:n,value:i}=e;a?t(n,i,e):i&&(r||={},r[n]=i)}),r}})),Kf=n((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,n=/-([a-z])/g,r=/^[^-]+$/,i=/^-(webkit|moz|ms|o|khtml)-/,a=/^-(ms)-/,o=function(e){return!e||r.test(e)||t.test(e)},s=function(e,t){return t.toUpperCase()},c=function(e,t){return`${t}-`};e.camelCase=function(e,t){return t===void 0&&(t={}),o(e)?e:(e=e.toLowerCase(),e=t.reactCompat?e.replace(a,c):e.replace(i,c),e.replace(n,s))}})),qf=n(((e,t)=>{var n=(e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}})(Gf()),r=Kf();function i(e,t){var i={};return!e||typeof e!=`string`||(0,n.default)(e,function(e,n){e&&n&&(i[(0,r.camelCase)(e,t)]=n)}),i}i.default=i,t.exports=i})),Jf=Xf(`end`),Yf=Xf(`start`);function Xf(e){return t;function t(t){let n=t&&t.position&&t.position[e]||{};if(typeof n.line==`number`&&n.line>0&&typeof n.column==`number`&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset==`number`&&n.offset>-1?n.offset:void 0}}}function Zf(e){let t=Yf(e),n=Jf(e);if(t&&n)return{start:t,end:n}}function Qf(e){return!e||typeof e!=`object`?``:`position`in e||`type`in e?ep(e.position):`start`in e||`end`in e?ep(e):`line`in e||`column`in e?$f(e):``}function $f(e){return tp(e&&e.line)+`:`+tp(e&&e.column)}function ep(e){return $f(e&&e.start)+`-`+$f(e&&e.end)}function tp(e){return e&&typeof e==`number`?e:1}var np=class extends Error{constructor(e,t,n){super(),typeof t==`string`&&(n=t,t=void 0);let r=``,i={},a=!1;if(t&&(i=`line`in t&&`column`in t||`start`in t&&`end`in t?{place:t}:`type`in t?{ancestors:[t],place:t.position}:{...t}),typeof e==`string`?r=e:!i.cause&&e&&(a=!0,r=e.message,i.cause=e),!i.ruleId&&!i.source&&typeof n==`string`){let e=n.indexOf(`:`);e===-1?i.ruleId=n:(i.source=n.slice(0,e),i.ruleId=n.slice(e+1))}if(!i.place&&i.ancestors&&i.ancestors){let e=i.ancestors[i.ancestors.length-1];e&&(i.place=e.position)}let o=i.place&&`start`in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.cause||void 0,this.column=o?o.column:void 0,this.fatal=void 0,this.file=``,this.message=r,this.line=o?o.line:void 0,this.name=Qf(i.place)||`1:1`,this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack==`string`?i.cause.stack:``,this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}};np.prototype.file=``,np.prototype.name=``,np.prototype.reason=``,np.prototype.message=``,np.prototype.stack=``,np.prototype.column=void 0,np.prototype.line=void 0,np.prototype.ancestors=void 0,np.prototype.cause=void 0,np.prototype.fatal=void 0,np.prototype.place=void 0,np.prototype.ruleId=void 0,np.prototype.source=void 0;var rp=e(qf(),1),ip={}.hasOwnProperty,ap=new Map,op=/[A-Z]/g,sp=new Set([`table`,`tbody`,`thead`,`tfoot`,`tr`]),cp=new Set([`td`,`th`]),lp=`https://github.com/syntax-tree/hast-util-to-jsx-runtime`;function up(e,t){if(!t||t.Fragment===void 0)throw TypeError("Expected `Fragment` in options");let n=t.filePath||void 0,r;if(t.development){if(typeof t.jsxDEV!=`function`)throw TypeError("Expected `jsxDEV` in options when `development: true`");r=xp(n,t.jsxDEV)}else{if(typeof t.jsx!=`function`)throw TypeError("Expected `jsx` in production options");
vendor: 4,480 bytes, line 87
87if(typeof t.jsxs!=`function`)throw TypeError("Expected `jsxs` in production options");r=bp(n,t.jsx,t.jsxs)}let i={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,elementAttributeNameCase:t.elementAttributeNameCase||`react`,evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:t.passKeys!==!1,passNode:t.passNode||!1,schema:t.space===`svg`?Hf:Vf,stylePropertyNameCase:t.stylePropertyNameCase||`dom`,tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},a=dp(i,e,void 0);return a&&typeof a!=`string`?a:i.create(e,i.Fragment,{children:a||void 0},void 0)}function dp(e,t,n){if(t.type===`element`)return fp(e,t,n);if(t.type===`mdxFlowExpression`||t.type===`mdxTextExpression`)return pp(e,t);if(t.type===`mdxJsxFlowElement`||t.type===`mdxJsxTextElement`)return hp(e,t,n);if(t.type===`mdxjsEsm`)return mp(e,t);if(t.type===`root`)return gp(e,t,n);if(t.type===`text`)return _p(e,t)}function fp(e,t,n){let r=e.schema,i=r;t.tagName.toLowerCase()===`svg`&&r.space===`html`&&(i=Hf,e.schema=i),e.ancestors.push(t);let a=Dp(e,t.tagName,!1),o=Sp(e,t),s=wp(e,t);return sp.has(t.tagName)&&(s=s.filter(function(e){return typeof e!=`string`||!sf(e)})),vp(e,o,a,t),yp(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function pp(e,t){if(t.data&&t.data.estree&&e.evaluater){let n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}Op(e,t.position)}function mp(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Op(e,t.position)}function hp(e,t,n){let r=e.schema,i=r;t.name===`svg`&&r.space===`html`&&(i=Hf,e.schema=i),e.ancestors.push(t);let a=t.name===null?e.Fragment:Dp(e,t.name,!0),o=Cp(e,t),s=wp(e,t);return vp(e,o,a,t),yp(o,s),e.ancestors.pop(),e.schema=r,e.create(t,a,o,n)}function gp(e,t,n){let r={};return yp(r,wp(e,t)),e.create(t,e.Fragment,r,n)}function _p(e,t){return t.value}function vp(e,t,n,r){typeof n!=`string`&&n!==e.Fragment&&e.passNode&&(t.node=r)}function yp(e,t){if(t.length>0){let n=t.length>1?t:t[0];n&&(e.children=n)}}function bp(e,t,n){return r;function r(e,r,i,a){let o=Array.isArray(i.children)?n:t;return a?o(r,i,a):o(r,i)}}function xp(e,t){return n;function n(n,r,i,a){let o=Array.isArray(i.children),s=Yf(n);return t(r,i,a,o,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}function Sp(e,t){let n={},r,i;for(i in t.properties)if(i!==`children`&&ip.call(t.properties,i)){let a=Tp(e,i,t.properties[i]);if(a){let[i,o]=a;e.tableCellAlignToStyle&&i===`align`&&typeof o==`string`&&cp.has(t.tagName)?r=o:n[i]=o}}if(r){let t=n.style||={};t[e.stylePropertyNameCase===`css`?`text-align`:`textAlign`]=r}return n}function Cp(e,t){let n={};for(let r of t.attributes)if(r.type===`mdxJsxExpressionAttribute`){if(r.data&&r.data.estree&&e.evaluater){let t=r.data.estree.body[0];t.type;let i=t.expression;i.type;let a=i.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else Op(e,t.position)}else{let i=r.name,a;if(r.value&&typeof r.value==`object`){if(r.value.data&&r.value.data.estree&&e.evaluater){let t=r.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else Op(e,t.position)}else a=r.value===null||r.value;n[i]=a}return n}function wp(e,t){let n=[],r=-1,i=e.passKeys?new Map:ap;for(;++r<t.children.length;){let a=t.children[r],o;if(e.passKeys){let e=a.type===`element`?a.tagName:a.type===`mdxJsxFlowElement`||a.type===`mdxJsxTextElement`?a.name:void 0;if(e){let t=i.get(e)||0;o=e+`-`+t,i.set(e,t+1)}}let s=dp(e,a,o);s!==void 0&&n.push(s)}return n}function Tp(e,t,n){let r=Rf(e.schema,t);if(!(n==null||typeof n==`number`&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?ef(n):Uf(n)),r.property===`style`){let t=typeof n==`object`?n:Ep(e,String(n));return e.stylePropertyNameCase===`css`&&(t=kp(t)),[`style`,t]}return[e.elementAttributeNameCase===`react`&&r.space?Pf[r.property]||r.property:r.attribute,n]}}function Ep(e,t){try{return(0,rp.default)(t,{reactCompat:!0})}catch(t){if(e.ignoreInvalidStyle)return{};let n=t,r=new np("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:n,ruleId:`style`,source:`hast-util-to-jsx-runtime`});throw r.file=e.filePath||void 0,r.url=lp+`#cannot-parse-style-attribute`,r}}function Dp(e,t,n){let r;if(!n)r={type:`Literal`,value:t};else if(t.includes(`.`)){let e=t.split(`.`),n=-1,i;for(;++n<e.length;){let t=af(e[n])?{type:`Identifier`,name:e[n]}:{type:`Literal`,value:e[n]};
vendor: 5,266 bytes, line 87
87i=i?{type:`MemberExpression`,object:i,property:t,computed:!!(n&&t.type===`Literal`),optional:!1}:t}r=i}else r=af(t)&&!/^[a-z]/.test(t)?{type:`Identifier`,name:t}:{type:`Literal`,value:t};if(r.type===`Literal`){let t=r.value;return ip.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);Op(e)}function Op(e,t){let n=new np("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:`mdx-estree`,source:`hast-util-to-jsx-runtime`});throw n.file=e.filePath||void 0,n.url=lp+`#cannot-handle-mdx-estrees-without-createevaluater`,n}function kp(e){let t={},n;for(n in e)ip.call(e,n)&&(t[Ap(n)]=e[n]);return t}function Ap(e){let t=e.replace(op,jp);return t.slice(0,3)===`ms-`&&(t=`-`+t),t}function jp(e){return`-`+e.toLowerCase()}var Mp={action:[`form`],cite:[`blockquote`,`del`,`ins`,`q`],data:[`object`],formAction:[`button`,`input`],href:[`a`,`area`,`base`,`link`],icon:[`menuitem`],itemId:null,manifest:[`html`],ping:[`a`,`area`],poster:[`video`],src:[`audio`,`embed`,`iframe`,`img`,`input`,`script`,`source`,`track`,`video`]},Np={};function Pp(e,t){let n=t||Np;return Fp(e,typeof n.includeImageAlt!=`boolean`||n.includeImageAlt,typeof n.includeHtml!=`boolean`||n.includeHtml)}function Fp(e,t,n){if(Lp(e)){if(`value`in e)return e.type===`html`&&!n?``:e.value;if(t&&`alt`in e&&e.alt)return e.alt;if(`children`in e)return Ip(e.children,t,n)}return Array.isArray(e)?Ip(e,t,n):``}function Ip(e,t,n){let r=[],i=-1;for(;++i<e.length;)r[i]=Fp(e[i],t,n);return r.join(``)}function Lp(e){return!!(e&&typeof e==`object`)}var Rp=document.createElement(`i`);function zp(e){let t=`&`+e+`;`;Rp.innerHTML=t;let n=Rp.textContent;return n.charCodeAt(n.length-1)===59&&e!==`semi`?!1:n!==t&&n}function Bp(e,t,n,r){let i=e.length,a=0,o;if(t=t<0?-t>i?0:i+t:t>i?i:t,n=n>0?n:0,r.length<1e4)o=Array.from(r),o.unshift(t,n),e.splice(...o);else for(n&&e.splice(t,n);a<r.length;)o=r.slice(a,a+1e4),o.unshift(t,0),e.splice(...o),a+=1e4,t+=1e4}function Vp(e,t){return e.length>0?(Bp(e,e.length,0,t),e):t}var Hp={}.hasOwnProperty;function Up(e){let t={},n=-1;for(;++n<e.length;)Wp(t,e[n]);return t}function Wp(e,t){let n;for(n in t){let r=(Hp.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n],a;if(i)for(a in i){Hp.call(r,a)||(r[a]=[]);let e=i[a];Gp(r[a],Array.isArray(e)?e:e?[e]:[])}}}function Gp(e,t){let n=-1,r=[];for(;++n<t.length;)(t[n].add===`after`?e:r).push(t[n]);Bp(e,0,0,r)}function Kp(e,t){let n=Number.parseInt(e,t);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||(n&65535)==65535||(n&65535)==65534||n>1114111?`�`:String.fromCodePoint(n)}function qp(e){return e.replace(/[\t\n\r ]+/g,` `).replace(/^ | $/g,``).toLowerCase().toUpperCase()}var Jp=om(/[A-Za-z]/),Yp=om(/[\dA-Za-z]/),Xp=om(/[#-'*+\--9=?A-Z^-~]/);function Zp(e){return e!==null&&(e<32||e===127)}var Qp=om(/\d/),$p=om(/[\dA-Fa-f]/),em=om(/[!-/:-@[-`{-~]/);function tm(e){return e!==null&&e<-2}function nm(e){return e!==null&&(e<0||e===32)}function rm(e){return e===-2||e===-1||e===32}var im=om(/\p{P}|\p{S}/u),am=om(/\s/);function om(e){return t;function t(t){return t!==null&&t>-1&&e.test(String.fromCharCode(t))}}function sm(e){let t=[],n=-1,r=0,i=0;for(;++n<e.length;){let a=e.charCodeAt(n),o=``;if(a===37&&Yp(e.charCodeAt(n+1))&&Yp(e.charCodeAt(n+2)))i=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(o=String.fromCharCode(a));else if(a>55295&&a<57344){let t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(o=String.fromCharCode(a,t),i=1):o=`�`}else o=String.fromCharCode(a);o&&=(t.push(e.slice(r,n),encodeURIComponent(o)),r=n+i+1,``),i&&=(n+=i,0)}return t.join(``)+e.slice(r)}function cm(e,t,n,r){let i=r?r-1:1/0,a=0;return o;function o(r){return rm(r)?(e.enter(n),s(r)):t(r)}function s(r){return rm(r)&&a++<i?(e.consume(r),s):(e.exit(n),t(r))}}var lm={tokenize:um};function um(e){let t=e.attempt(this.parser.constructs.contentInitial,r,i),n;return t;function r(n){if(n===null){e.consume(n);return}return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),cm(e,t,`linePrefix`)}function i(t){return e.enter(`paragraph`),a(t)}function a(t){let r=e.enter(`chunkText`,{contentType:`text`,previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){if(t===null){e.exit(`chunkText`),e.exit(`paragraph`),e.consume(t);return}return tm(t)?(e.consume(t),e.exit(`chunkText`),a):(e.consume(t),o)}}var dm={tokenize:pm},fm={tokenize:mm};function pm(e){let t=this,n=[],r=0,i,a,o;return s;function s(i){if(r<n.length){let a=n[r];return t.containerState=a[1],e.attempt(a[0].continuation,c,l)(i)}return l(i)}function c(e){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&v();let n=t.events.length,a=n,o;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){o=t.events[a][1].end;break}_(r);let s=n;for(;s<t.events.length;)t.events[s][1].end={...o},s++;return Bp(t.events,a+1,0,t.events.slice(n)),t.events.length=s,l(e)}return s(e)}function l(a){if(r===n.length){if(!i)return f(a);if(i.currentConstruct&&i.currentConstruct.concrete)return m(a);t.interrupt=!(!i.currentConstruct||i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(fm,u,d)(a)}function u(e){return i&&v(),_(r),f(e)}function d(e){return t.parser.lazy[t.now().line]=r!==n.length,o=t.now().offset,m
vendor: 41,705 bytes, lines 87-89
87(e)}function f(n){return t.containerState={},e.attempt(fm,p,m)(n)}function p(e){return r++,n.push([t.currentConstruct,t.containerState]),f(e)}function m(n){if(n===null){i&&v(),_(0),e.consume(n);return}return i||=t.parser.flow(t.now()),e.enter(`chunkFlow`,{_tokenizer:i,contentType:`flow`,previous:a}),h(n)}function h(n){if(n===null){g(e.exit(`chunkFlow`),!0),_(0),e.consume(n);return}return tm(n)?(e.consume(n),g(e.exit(`chunkFlow`)),r=0,t.interrupt=void 0,s):(e.consume(n),h)}function g(e,n){let s=t.sliceStream(e);if(n&&s.push(null),e.previous=a,a&&(a.next=e),a=e,i.defineSkip(e.start),i.write(s),t.parser.lazy[e.start.line]){let e=i.events.length;for(;e--;)if(i.events[e][1].start.offset<o&&(!i.events[e][1].end||i.events[e][1].end.offset>o))return;let n=t.events.length,a=n,s,c;for(;a--;)if(t.events[a][0]===`exit`&&t.events[a][1].type===`chunkFlow`){if(s){c=t.events[a][1].end;break}s=!0}for(_(r),e=n;e<t.events.length;)t.events[e][1].end={...c},e++;Bp(t.events,a+1,0,t.events.slice(n)),t.events.length=e}}function _(r){let i=n.length;for(;i-->r;){let r=n[i];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function v(){i.write([null]),a=void 0,i=void 0,t.containerState._closeFlow=void 0}}function mm(e,t,n){return cm(e,e.attempt(this.parser.constructs.document,t,n),`linePrefix`,this.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)}function hm(e){if(e===null||nm(e)||am(e))return 1;if(im(e))return 2}function gm(e,t,n){let r=[],i=-1;for(;++i<e.length;){let a=e[i].resolveAll;a&&!r.includes(a)&&(t=a(t,n),r.push(a))}return t}var _m={name:`attention`,resolveAll:vm,tokenize:ym};function vm(e,t){let n=-1,r,i,a,o,s,c,l,u;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`attentionSequence`&&e[n][1]._close){for(r=n;r--;)if(e[r][0]===`exit`&&e[r][1].type===`attentionSequence`&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;let d={...e[r][1].end},f={...e[n][1].start};bm(d,-c),bm(f,c),o={type:c>1?`strongSequence`:`emphasisSequence`,start:d,end:{...e[r][1].end}},s={type:c>1?`strongSequence`:`emphasisSequence`,start:{...e[n][1].start},end:f},a={type:c>1?`strongText`:`emphasisText`,start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?`strong`:`emphasis`,start:{...o.start},end:{...s.end}},e[r][1].end={...o.start},e[n][1].start={...s.end},l=[],e[r][1].end.offset-e[r][1].start.offset&&(l=Vp(l,[[`enter`,e[r][1],t],[`exit`,e[r][1],t]])),l=Vp(l,[[`enter`,i,t],[`enter`,o,t],[`exit`,o,t],[`enter`,a,t]]),l=Vp(l,gm(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),l=Vp(l,[[`exit`,a,t],[`enter`,s,t],[`exit`,s,t],[`exit`,i,t]]),e[n][1].end.offset-e[n][1].start.offset?(u=2,l=Vp(l,[[`enter`,e[n][1],t],[`exit`,e[n][1],t]])):u=0,Bp(e,r-1,n-r+3,l),n=r+l.length-u-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`attentionSequence`&&(e[n][1].type=`data`);return e}function ym(e,t){let n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=hm(r),a;return o;function o(t){return a=t,e.enter(`attentionSequence`),s(t)}function s(o){if(o===a)return e.consume(o),s;let c=e.exit(`attentionSequence`),l=hm(o),u=!l||l===2&&i||n.includes(o),d=!i||i===2&&l||n.includes(r);return c._open=!!(a===42?u:u&&(i||!d)),c._close=!!(a===42?d:d&&(l||!u)),t(o)}}function bm(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}var xm={name:`autolink`,tokenize:Sm};function Sm(e,t,n){let r=0;return i;function i(t){return e.enter(`autolink`),e.enter(`autolinkMarker`),e.consume(t),e.exit(`autolinkMarker`),e.enter(`autolinkProtocol`),a}function a(t){return Jp(t)?(e.consume(t),o):t===64?n(t):l(t)}function o(e){return e===43||e===45||e===46||Yp(e)?(r=1,s(e)):l(e)}function s(t){return t===58?(e.consume(t),r=0,c):(t===43||t===45||t===46||Yp(t))&&r++<32?(e.consume(t),s):(r=0,l(t))}function c(r){return r===62?(e.exit(`autolinkProtocol`),e.enter(`autolinkMarker`),e.consume(r),e.exit(`autolinkMarker`),e.exit(`autolink`),t):r===null||r===32||r===60||Zp(r)?n(r):(e.consume(r),c)}function l(t){return t===64?(e.consume(t),u):Xp(t)?(e.consume(t),l):n(t)}function u(e){return Yp(e)?d(e):n(e)}function d(n){return n===46?(e.consume(n),r=0,u):n===62?(e.exit(`autolinkProtocol`).type=`autolinkEmail`,e.enter(`autolinkMarker`),e.consume(n),e.exit(`autolinkMarker`),e.exit(`autolink`),t):f(n)}function f(t){if((t===45||Yp(t))&&r++<63){let n=t===45?f:d;return e.consume(t),n}return n(t)}}var Cm={partial:!0,tokenize:wm};function wm(e,t,n){return r;function r(t){return rm(t)?cm(e,i,`linePrefix`)(t):i(t)}function i(e){return e===null||tm(e)?t(e):n(e)}}var Tm={continuation:{tokenize:Dm},exit:Om,name:`blockQuote`,tokenize:Em};function Em(e,t,n){let r=this;return i;function i(t){if(t===62){let n=r.containerState;return n.open||=(e.enter(`blockQuote`,{_container:!0}),!0),e.enter(`blockQuotePrefix`),e.enter(`blockQuoteMarker`),e.consume(t),e.exit(`blockQuoteMarker`),a}return n(t)}function a(n){return rm(n)?(e.enter(`blockQuotePrefixWhitespace`),e.consume(n),e.exit(`blockQuotePrefixWhitespace`),e.exit(`blockQuotePrefix`),t):(e.exit(`blockQuotePrefix`),t(n))}}function Dm(e,t,n){let r=this;return i;function i(t){return rm(t)?cm(e,a,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):a(t)}function a(r){return e.attempt(Tm,t,n)(r)}}function Om(e){e.exit(`blockQuote`)}var km={name:`characterEscape`,tokenize:Am};function Am(e,t,n){return r;function r(t){return e.enter(`characterEscape`),e.enter(`escapeMarker`),e.consume(t),e.exit(`escapeMarker`),i}function i(r){return em(r)?(e.enter(`characterEscapeValue`),e.consume(r),e.exit(`characterEscapeValue`),e.exit(`characterEscape`),t):n(r)}}var jm={name:`characterReference`,tokenize:Mm};function Mm(e,t,n){let r=this,i=0,a,o;return s;function s(t){return e.enter(`characterReference`),e.enter(`characterReferenceMarker`),e.consume(t),e.exit(`characterReferenceMarker`),c}function c(t){return t===35?(e.enter(`characterReferenceMarkerNumeric`),e.consume(t),e.exit(`characterReferenceMarkerNumeric`),l):(e.enter(`characterReferenceValue`),a=31,o=Yp,u(t))}function l(t){return t===88||t===120?(e.enter(`characterReferenceMarkerHexadecimal`),e.consume(t),e.exit(`characterReferenceMarkerHexadecimal`),e.enter(`characterReferenceValue`),a=6,o=$p,u):(e.enter(`characterReferenceValue`),a=7,o=Qp,u(t))}function u(s){if(s===59&&i){let i=e.exit(`characterReferenceValue`);return o===Yp&&!zp(r.sliceSerialize(i))?n(s):(e.enter(`characterReferenceMarker`),e.consume(s),e.exit(`characterReferenceMarker`),e.exit(`characterReference`),t)}return o(s)&&i++<a?(e.consume(s),u):n(s)}}var Nm={partial:!0,tokenize:Im},Pm={concrete:!0,name:`codeFenced`,tokenize:Fm};function Fm(e,t,n){let r=this,i={partial:!0,tokenize:x},a=0,o=0,s;return c;function c(e){return l(e)}function l(t){let n=r.events[r.events.length-1];return a=n&&n[1].type===`linePrefix`?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter(`codeFenced`),e.enter(`codeFencedFence`),e.enter(`codeFencedFenceSequence`),u(t)}function u(t){return t===s?(o++,e.consume(t),u):o<3?n(t):(e.exit(`codeFencedFenceSequence`),rm(t)?cm(e,d,`whitespace`)(t):d(t))}function d(n){return n===null||tm(n)?(e.exit(`codeFencedFence`),r.interrupt?t(n):e.check(Nm,h,b)(n)):(e.enter(`codeFencedFenceInfo`),e.enter(`chunkString`,{contentType:`string`}),f(n))}function f(t){return t===null||tm(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),d(t)):rm(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceInfo`),cm(e,p,`whitespace`)(t)):t===96&&t===s?n(t):(e.consume(t),f)}function p(t){return t===null||tm(t)?d(t):(e.enter(`codeFencedFenceMeta`),e.enter(`chunkString`,{contentType:`string`}),m(t))}function m(t){return t===null||tm(t)?(e.exit(`chunkString`),e.exit(`codeFencedFenceMeta`),d(t)):t===96&&t===s?n(t):(e.consume(t),m)}function h(t){return e.attempt(i,b,g)(t)}function g(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),_}function _(t){return a>0&&rm(t)?cm(e,v,`linePrefix`,a+1)(t):v(t)}function v(t){return t===null||tm(t)?e.check(Nm,h,b)(t):(e.enter(`codeFlowValue`),y(t))}function y(t){return t===null||tm(t)?(e.exit(`codeFlowValue`),v(t)):(e.consume(t),y)}function b(n){return e.exit(`codeFenced`),t(n)}function x(e,t,n){let i=0;return a;function a(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c}function c(t){return e.enter(`codeFencedFence`),rm(t)?cm(e,l,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):l(t)}function l(t){return t===s?(e.enter(`codeFencedFenceSequence`),u(t)):n(t)}function u(t){return t===s?(i++,e.consume(t),u):i>=o?(e.exit(`codeFencedFenceSequence`),rm(t)?cm(e,d,`whitespace`)(t):d(t)):n(t)}function d(r){return r===null||tm(r)?(e.exit(`codeFencedFence`),t(r)):n(r)}}}function Im(e,t,n){let r=this;return i;function i(t){return t===null?n(t):(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}var Lm={name:`codeIndented`,tokenize:zm},Rm={partial:!0,tokenize:Bm};function zm(e,t,n){let r=this;return i;function i(t){return e.enter(`codeIndented`),cm(e,a,`linePrefix`,5)(t)}function a(e){let t=r.events[r.events.length-1];return t&&t[1].type===`linePrefix`&&t[2].sliceSerialize(t[1],!0).length>=4?o(e):n(e)}function o(t){return t===null?c(t):tm(t)?e.attempt(Rm,o,c)(t):(e.enter(`codeFlowValue`),s(t))}function s(t){return t===null||tm(t)?(e.exit(`codeFlowValue`),o(t)):(e.consume(t),s)}function c(n){return e.exit(`codeIndented`),t(n)}}function Bm(e,t,n){let r=this;return i;function i(t){return r.parser.lazy[r.now().line]?n(t):tm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),i):cm(e,a,`linePrefix`,5)(t)}function a(e){let a=r.events[r.events.length-1];return a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):tm(e)?i(e):n(e)}}var Vm={name:`codeText`,previous:Um,resolve:Hm,tokenize:Wm};function Hm(e){let t=e.length-4,n=3,r,i;if((e[n][1].type===`lineEnding`||e[n][1].type===`space`)&&(e[t][1].type===`lineEnding`||e[t][1].type===`space`)){for(r=n;++r<t;)if(e[r][1].type===`codeTextData`){e[n][1].type=`codeTextPadding`,e[t][1].type=`codeTextPadding`,n+=2,t-=2;break}}for(r=n-1,t++;++r<=t;)i===void 0?r!==t&&e[r][1].type!==`lineEnding`&&(i=r):(r===t||e[r][1].type===`lineEnding`)&&(e[i][1].type=`codeTextData`,r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function Um(e){return e!==96||this.events[this.events.length-1][1].type===`characterEscape`}function Wm(e,t,n){let r=0,i,a;return o;function o(t){return e.enter(`codeText`),e.enter(`codeTextSequence`),s(t)}function s(t){return t===96?(e.consume(t),r++,s):(e.exit(`codeTextSequence`),c(t))}function c(t){return t===null?n(t):t===32?(e.enter(`space`),e.consume(t),e.exit(`space`),c):t===96?(a=e.enter(`codeTextSequence`),i=0,u(t)):tm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),c):(e.enter(`codeTextData`),l(t))}function l(t){return t===null||t===32||t===96||tm(t)?(e.exit(`codeTextData`),c(t)):(e.consume(t),l)}function u(n){return n===96?(e.consume(n),i++,u):i===r?(e.exit(`codeTextSequence`),e.exit(`codeText`),t(n)):(a.type=`codeTextData`,l(n))}}var Gm=class{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){let n=t??1/0;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){let r=t||0;this.setCursor(Math.trunc(e));let i=this.right.splice(this.right.length-r,1/0);return n&&Km(this.left,n),i.reverse()}pop(){return this.setCursor(1/0),this.left.pop()}push(e){this.setCursor(1/0),this.left.push(e)}pushMany(e){this.setCursor(1/0),Km(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),Km(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0)){if(e<this.left.length){let t=this.left.splice(e,1/0);Km(this.right,t.reverse())}else{let t=this.right.splice(this.left.length+this.right.length-e,1/0);Km(this.left,t.reverse())}}}};function Km(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function qm(e){let t={},n=-1,r,i,a,o,s,c,l,u=new Gm(e);for(;++n<u.length;){for(;n in t;)n=t[n];if(r=u.get(n),n&&r[1].type===`chunkFlow`&&u.get(n-1)[1].type===`listItemPrefix`&&(c=r[1]._tokenizer.events,a=0,a<c.length&&c[a][1].type===`lineEndingBlank`&&(a+=2),a<c.length&&c[a][1].type===`content`))for(;++a<c.length&&c[a][1].type!==`content`;)c[a][1].type===`chunkText`&&(c[a][1]._isInFirstContentOfListItem=!0,a++);if(r[0]===`enter`)r[1].contentType&&(Object.assign(t,Jm(u,n)),n=t[n],l=!0);else if(r[1]._container){for(a=n,i=void 0;a--;)if(o=u.get(a),o[1].type===`lineEnding`||o[1].type===`lineEndingBlank`)o[0]===`enter`&&(i&&(u.get(i)[1].type=`lineEndingBlank`),o[1].type=`lineEnding`,i=a);else if(o[1].type!==`linePrefix`&&o[1].type!==`listItemIndent`)break;i&&(r[1].end={...u.get(i)[1].start},s=u.slice(i,n),s.unshift(r),u.splice(i,n-i+1,s))}}return Bp(e,0,1/0,u.slice(0)),!l}function Jm(e,t){let n=e.get(t)[1],r=e.get(t)[2],i=t-1,a=[],o=n._tokenizer;o||(o=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(o._contentTypeTextTrailing=!0));let s=o.events,c=[],l={},u,d,f=-1,p=n,m=0,h=0,g=[h];for(;p;){for(;e.get(++i)[1]!==p;);a.push(i),p._tokenizer||(u=r.sliceStream(p),p.next||u.push(null),d&&o.defineSkip(p.start),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=!0),o.write(u),p._isInFirstContentOfListItem&&(o._gfmTasklistFirstContentOfListItem=void 0)),d=p,p=p.next}for(p=n;++f<s.length;)s[f][0]===`exit`&&s[f-1][0]===`enter`&&s[f][1].type===s[f-1][1].type&&s[f][1].start.line!==s[f][1].end.line&&(h=f+1,g.push(h),p._tokenizer=void 0,p.previous=void 0,p=p.next);for(o.events=[],p?(p._tokenizer=void 0,p.previous=void 0):g.pop(),f=g.length;f--;){let t=s.slice(g[f],g[f+1]),n=a.pop();c.push([n,n+t.length-1]),e.splice(n,2,t)}for(c.reverse(),f=-1;++f<c.length;)l[m+c[f][0]]=m+c[f][1],m+=c[f][1]-c[f][0]-1;return l}var Ym={resolve:Zm,tokenize:Qm},Xm={partial:!0,tokenize:$m};function Zm(e){return qm(e),e}function Qm(e,t){let n;return r;function r(t){return e.enter(`content`),n=e.enter(`chunkContent`,{contentType:`content`}),i(t)}function i(t){return t===null?a(t):tm(t)?e.check(Xm,o,a)(t):(e.consume(t),i)}function a(n){return e.exit(`chunkContent`),e.exit(`content`),t(n)}function o(t){return e.consume(t),e.exit(`chunkContent`),n.next=e.enter(`chunkContent`,{contentType:`content`,previous:n}),n=n.next,i}}function $m(e,t,n){let r=this;return i;function i(t){return e.exit(`chunkContent`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),cm(e,a,`linePrefix`)}function a(i){if(i===null||tm(i))return n(i);let a=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes(`codeIndented`)&&a&&a[1].type===`linePrefix`&&a[2].sliceSerialize(a[1],!0).length>=4?t(i):e.interrupt(r.parser.constructs.flow,n,t)(i)}}function eh(e,t,n,r,i,a,o,s,c){let l=c||1/0,u=0;return d;function d(t){return t===60?(e.enter(r),e.enter(i),e.enter(a),e.consume(t),e.exit(a),f):t===null||t===32||t===41||Zp(t)?n(t):(e.enter(r),e.enter(o),e.enter(s),e.enter(`chunkString`,{contentType:`string`}),h(t))}function f(n){return n===62?(e.enter(a),e.consume(n),e.exit(a),e.exit(i),e.exit(r),t):(e.enter(s),e.enter(`chunkString`,{contentType:`string`}),p(n))}function p(t){return t===62?(e.exit(`chunkString`),e.exit(s),f(t)):t===null||t===60||tm(t)?n(t):(e.consume(t),t===92?m:p)}function m(t){return t===60||t===62||t===92?(e.consume(t),p):p(t)}function h(i){return!u&&(i===null||i===41||nm(i))?(e.exit(`chunkString`),e.exit(s),e.exit(o),e.exit(r),t(i)):u<l&&i===40?(e.consume(i),u++,h):i===41?(e.consume(i),u--,h):i===null||i===32||i===40||Zp(i)?n(i):(e.consume(i),i===92?g:h)}function g(t){return t===40||t===41||t===92?(e.consume(t),h):h(t)}}function th(e,t,n,r,i,a){let o=this,s=0,c;return l;function l(t){return e.enter(r),e.enter(i),e.consume(t),e.exit(i),e.enter(a),u}function u(l){return s>999||l===null||l===91||l===93&&!c||l===94&&!s&&`_hiddenFootnoteSupport`in o.parser.constructs?n(l):l===93?(e.exit(a),e.enter(i),e.consume(l),e.exit(i),e.exit(r),t):tm(l)?(e.enter(`lineEnding`),e.consume(l),e.exit(`lineEnding`),u):(e.enter(`chunkString`,{contentType:`string`}),d(l))}function d(t){return t===null||t===91||t===93||tm(t)||s++>999?(e.exit(`chunkString`),u(t)):(e.consume(t),c||=!rm(t),t===92?f:d)}function f(t){return t===91||t===92||t===93?(e.consume(t),s++,d):d(t)}}function nh(e,t,n,r,i,a){let o;return s;function s(t){return t===34||t===39||t===40?(e.enter(r),e.enter(i),e.consume(t),e.exit(i),o=t===40?41:t,c):n(t)}function c(n){return n===o?(e.enter(i),e.consume(n),e.exit(i),e.exit(r),t):(e.enter(a),l(n))}function l(t){return t===o?(e.exit(a),c(o)):t===null?n(t):tm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),cm(e,l,`linePrefix`)):(e.enter(`chunkString`,{contentType:`string`}),u(t))}function u(t){return t===o||t===null||tm(t)?(e.exit(`chunkString`),l(t)):(e.consume(t),t===92?d:u)}function d(t){return t===o||t===92?(e.consume(t),u):u(t)}}function rh(e,t){let n;return r;function r(i){return tm(i)?(e.enter(`lineEnding`),e.consume(i),e.exit(`lineEnding`),n=!0,r):rm(i)?cm(e,r,n?`linePrefix`:`lineSuffix`)(i):t(i)}}var ih={name:`definition`,tokenize:oh},ah={partial:!0,tokenize:sh};function oh(e,t,n){let r=this,i;return a;function a(t){return e.enter(`definition`),o(t)}function o(t){return th.call(r,e,s,n,`definitionLabel`,`definitionLabelMarker`,`definitionLabelString`)(t)}function s(t){return i=qp(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),c):n(t)}function c(t){return nm(t)?rh(e,l)(t):l(t)}function l(t){return eh(e,u,n,`definitionDestination`,`definitionDestinationLiteral`,`definitionDestinationLiteralMarker`,`definitionDestinationRaw`,`definitionDestinationString`)(t)}function u(t){return e.attempt(ah,d,d)(t)}function d(t){return rm(t)?cm(e,f,`whitespace`)(t):f(t)}function f(a){return a===null||tm(a)?(e.exit(`definition`),r.parser.defined.push(i),t(a)):n(a)}}function sh(e,t,n){return r;function r(t){return nm(t)?rh(e,i)(t):n(t)}function i(t){return nh(e,a,n,`definitionTitle`,`definitionTitleMarker`,`definitionTitleString`)(t)}function a(t){return rm(t)?cm(e,o,`whitespace`)(t):o(t)}function o(e){return e===null||tm(e)?t(e):n(e)}}var ch={name:`hardBreakEscape`,tokenize:lh};function lh(e,t,n){return r;function r(t){return e.enter(`hardBreakEscape`),e.consume(t),i}function i(r){return tm(r)?(e.exit(`hardBreakEscape`),t(r)):n(r)}}var uh={name:`headingAtx`,resolve:dh,tokenize:fh};function dh(e,t){let n=e.length-2,r=3,i,a;return e[r][1].type===`whitespace`&&(r+=2),n-2>r&&e[n][1].type===`whitespace`&&(n-=2),e[n][1].type===`atxHeadingSequence`&&(r===n-1||n-4>r&&e[n-2][1].type===`whitespace`)&&(n-=r+1===n?2:4),n>r&&(i={type:`atxHeadingText`,start:e[r][1].start,end:e[n][1].end},a={type:`chunkText`,start:e[r][1].start,end:e[n][1].end,contentType:`text`},Bp(e,r,n-r+1,[[`enter`,i,t],[`enter`,a,t],[`exit`,a,t],[`exit`,i,t]])),e}function fh(e,t,n){let r=0;return i;function i(t){return e.enter(`atxHeading`),a(t)}function a(t){return e.enter(`atxHeadingSequence`),o(t)}function o(t){return t===35&&r++<6?(e.consume(t),o):t===null||nm(t)?(e.exit(`atxHeadingSequence`),s(t)):n(t)}function s(n){return n===35?(e.enter(`atxHeadingSequence`),c(n)):n===null||tm(n)?(e.exit(`atxHeading`),t(n)):rm(n)?cm(e,s,`whitespace`)(n):(e.enter(`atxHeadingText`),l(n))}function c(t){return t===35?(e.consume(t),c):(e.exit(`atxHeadingSequence`),s(t))}function l(t){return t===null||t===35||nm(t)?(e.exit(`atxHeadingText`),s(t)):(e.consume(t),l)}}var ph=`address.article.aside.base.basefont.blockquote.body.caption.center.col.colgroup.dd.details.dialog.dir.div.dl.dt.fieldset.figcaption.figure.footer.form.frame.frameset.h1.h2.h3.h4.h5.h6.head.header.hr.html.iframe.legend.li.link.main.menu.menuitem.nav.noframes.ol.optgroup.option.p.param.search.section.summary.table.tbody.td.tfoot.th.thead.title.tr.track.ul`.split(`.`),mh=[`pre`,`script`,`style`,`textarea`],hh={concrete:!0,name:`htmlFlow`,resolveTo:vh,tokenize:yh},gh={partial:!0,tokenize:xh},_h={partial:!0,tokenize:bh};function vh(e){let t=e.length;for(;t--&&(e[t][0]!==`enter`||e[t][1].type!==`htmlFlow`););return t>1&&e[t-2][1].type===`linePrefix`&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2)),e}function yh(e,t,n){let r=this,i,a,o,s,c;return l;function l(e){return u(e)}function u(t){return e.enter(`htmlFlow`),e.enter(`htmlFlowData`),e.consume(t),d}function d(s){return s===33?(e.consume(s),f):s===47?(e.consume(s),a=!0,h):s===63?(e.consume(s),i=3,r.interrupt?t:I):Jp(s)?(e.consume(s),o=String.fromCharCode(s),g):n(s)}function f(a){return a===45?(e.consume(a),i=2,p):a===91?(e.consume(a),i=5,s=0,m):Jp(a)?(e.consume(a),i=4,r.interrupt?t:I):n(a)}function p(i){return i===45?(e.consume(i),r.interrupt?t:I):n(i)}function m(i){return i===`CDATA[`.charCodeAt(s++)?(e.consume(i),s===6?r.interrupt?t:O:m):n(i)}function h(t){return Jp(t)?(e.consume(t),o=String.fromCharCode(t),g):n(t)}function g(s){if(s===null||s===47||s===62||nm(s)){let c=s===47,l=o.toLowerCase();return!c&&!a&&mh.includes(l)?(i=1,r.interrupt?t(s):O(s)):ph.includes(o.toLowerCase())?(i=6,c?(e.consume(s),_):r.interrupt?t(s):O(s)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(s):a?v(s):y(s))}return s===45||Yp(s)?(e.consume(s),o+=String.fromCharCode(s),g):n(s)}function _(i){return i===62?(e.consume(i),r.interrupt?t:O):n(i)}function v(t){return rm(t)?(e.consume(t),v):E(t)}function y(t){return t===47?(e.consume(t),E):t===58||t===95||Jp(t)?(e.consume(t),b):rm(t)?(e.consume(t),y):E(t)}function b(t){return t===45||t===46||t===58||t===95||Yp(t)?(e.consume(t),b):x(t)}function x(t){return t===61?(e.consume(t),S):rm(t)?(e.consume(t),x):y(t)}function S(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),c=t,C):rm(t)?(e.consume(t),S):w(t)}function C(t){return t===c?(e.consume(t),c=null,T):t===null||tm(t)?n(t):(e.consume(t),C)}function w(t){return t===null||t===34||t===39||t===47||t===60||t===61||t===62||t===96||nm(t)?x(t):(e.consume(t),w)}function T(e){return e===47||e===62||rm(e)?y(e):n(e)}function E(t){return t===62?(e.consume(t),D):n(t)}function D(t){return t===null||tm(t)?O(t):rm(t)?(e.consume(t),D):n(t)}function O(t){return t===45&&i===2?(e.consume(t),M):t===60&&i===1?(e.consume(t),N):t===62&&i===4?(e.consume(t),L):t===63&&i===3?(e.consume(t),I):t===93&&i===5?(e.consume(t),F):tm(t)&&(i===6||i===7)?(e.exit(`htmlFlowData`),e.check(gh,ee,k)(t)):t===null||tm(t)?(e.exit(`htmlFlowData`),k(t)):(e.consume(t),O)}function k(t){return e.check(_h,A,ee)(t)}function A(t){return e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),j}function j(t){return t===null||tm(t)?k(t):(e.enter(`htmlFlowData`),O(t))}function M(t){return t===45?(e.consume(t),I):O(t)}function N(t){return t===47?(e.consume(t),o=``,P):O(t)}function P(t){if(t===62){let n=o.toLowerCase();return mh.includes(n)?(e.consume(t),L):O(t)}return Jp(t)&&o.length<8?(e.consume(t),o+=String.fromCharCode(t),P):O(t)}function F(t){return t===93?(e.consume(t),I):O(t)}function I(t){return t===62?(e.consume(t),L):t===45&&i===2?(e.consume(t),I):O(t)}function L(t){return t===null||tm(t)?(e.exit(`htmlFlowData`),ee(t)):(e.consume(t),L)}function ee(n){return e.exit(`htmlFlow`),t(n)}}function bh(e,t,n){let r=this;return i;function i(t){return tm(t)?(e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),a):n(t)}function a(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}function xh(e,t,n){return r;function r(r){return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),e.attempt(Cm,t,n)}}var Sh={name:`htmlText`,tokenize:Ch};function Ch(e,t,n){let r=this,i,a,o;return s;function s(t){return e.enter(`htmlText`),e.enter(`htmlTextData`),e.consume(t),c}function c(t){return t===33?(e.consume(t),l):t===47?(e.consume(t),x):t===63?(e.consume(t),y):Jp(t)?(e.consume(t),w):n(t)}function l(t){return t===45?(e.consume(t),u):t===91?(e.consume(t),a=0,m):Jp(t)?(e.consume(t),v):n(t)}function u(t){return t===45?(e.consume(t),p):n(t)}function d(t){return t===null?n(t):t===45?(e.consume(t),f):tm(t)?(o=d,N(t)):(e.consume(t),d)}function f(t){return t===45?(e.consume(t),p):d(t)}function p(e){return e===62?M(e):e===45?f(e):d(e)}function m(t){return t===`CDATA[`.charCodeAt(a++)?(e.consume(t),a===6?h:m):n(t)}function h(t){return t===null?n(t):t===93?(e.consume(t),g):tm(t)?(o=h,N(t)):(e.consume(t),h)}function g(t){return t===93?(e.consume(t),_):h(t)}function _(t){return t===62?M(t):t===93?(e.consume(t),_):h(t)}function v(t){return t===null||t===62?M(t):tm(t)?(o=v,N(t)):(e.consume(t),v)}function y(t){return t===null?n(t):t===63?(e.consume(t),b):tm(t)?(o=y,N(t)):(e.consume(t),y)}function b(e){return e===62?M(e):y(e)}function x(t){return Jp(t)?(e.consume(t),S):n(t)}function S(t){return t===45||Yp(t)?(e.consume(t),S):C(t)}function C(t){return tm(t)?(o=C,N(t)):rm(t)?(e.consume(t),C):M(t)}function w(t){return t===45||Yp(t)?(e.consume(t),w):t===47||t===62||nm(t)?T(t):n(t)}function T(t){return t===47?(e.consume(t),M):t===58||t===95||Jp(t)?(e.consume(t),E):tm(t)?(o=T,N(t)):rm(t)?(e.consume(t),T):M(t)}function E(t){return t===45||t===46||t===58||t===95||Yp(t)?(e.consume(t),E):D(t)}function D(t){return t===61?(e.consume(t),O):tm(t)?(o=D,N(t)):rm(t)?(e.consume(t),D):T(t)}function O(t){return t===null||t===60||t===61||t===62||t===96?n(t):t===34||t===39?(e.consume(t),i=t,k):tm(t)?(o=O,N(t)):rm(t)?(e.consume(t),O):(e.consume(t),A)}function k(t){return t===i?(e.consume(t),i=void 0,j):t===null?n(t):tm(t)?(o=k,N(t)):(e.consume(t),k)}function A(t){return t===null||t===34||t===39||t===60||t===61||t===96?n(t):t===47||t===62||nm(t)?T(t):(e.consume(t),A)}function j(e){return e===47||e===62||nm(e)?T(e):n(e)}function M(r){return r===62?(e.consume(r),e.exit(`htmlTextData`),e.exit(`htmlText`),t):n(r)}function N(t){return e.exit(`htmlTextData`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),P}function P(t){return rm(t)?cm(e,F,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):F(t)}function F(t){return e.enter(`htmlTextData`),o(t)}}var wh={name:`labelEnd`,resolveAll:Oh,resolveTo:kh,tokenize:Ah},Th={tokenize:jh},Eh={tokenize:Mh},Dh={tokenize:Nh};function Oh(e){let t=-1,n=[];for(;++t<e.length;){let r=e[t][1];if(n.push(e[t]),r.type===`labelImage`||r.type===`labelLink`||r.type===`labelEnd`){let e=r.type===`labelImage`?4:2;r.type=`data`,t+=e}}return e.length!==n.length&&Bp(e,0,e.length,n),e}function kh(e,t){let n=e.length,r=0,i,a,o,s;for(;n--;)if(i=e[n][1],a){if(i.type===`link`||i.type===`labelLink`&&i._inactive)break;e[n][0]===`enter`&&i.type===`labelLink`&&(i._inactive=!0)}else if(o){if(e[n][0]===`enter`&&(i.type===`labelImage`||i.type===`labelLink`)&&!i._balanced&&(a=n,i.type!==`labelLink`)){r=2;break}}else i.type===`labelEnd`&&(o=n);let c={type:e[a][1].type===`labelLink`?`link`:`image`,start:{...e[a][1].start},end:{...e[e.length-1][1].end}},l={type:`label`,start:{...e[a][1].start},end:{...e[o][1].end}},u={type:`labelText`,start:{...e[a+r+2][1].end},end:{...e[o-2][1].start}};return s=[[`enter`,c,t],[`enter`,l,t]],s=Vp(s,e.slice(a+1,a+r+3)),s=Vp(s,[[`enter`,u,t]]),s=Vp(s,gm(t.parser.constructs.insideSpan.null,e.slice(a+r+4,o-3),t)),s=Vp(s,[[`exit`,u,t],e[o-2],e[o-1],[`exit`,l,t]]),s=Vp(s,e.slice(o+1)),s=Vp(s,[[`exit`,c,t]]),Bp(e,a,e.length,s),e}function Ah(e,t,n){let r=this,i=r.events.length,a,o;for(;i--;)if((r.events[i][1].type===`labelImage`||r.events[i][1].type===`labelLink`)&&!r.events[i][1]._balanced){a=r.events[i][1];break}return s;function s(t){return a?a._inactive?d(t):(o=r.parser.defined.includes(qp(r.sliceSerialize({start:a.end,end:r.now()}))),e.enter(`labelEnd`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelEnd`),c):n(t)}function c(t){return t===40?e.attempt(Th,u,o?u:d)(t):t===91?e.attempt(Eh,u,o?l:d)(t):o?u(t):d(t)}function l(t){return e.attempt(Dh,u,d)(t)}function u(e){return t(e)}function d(e){return a._balanced=!0,n(e)}}function jh(e,t,n){return r;function r(t){return e.enter(`resource`),e.enter(`resourceMarker`),e.consume(t),e.exit(`resourceMarker`),i}function i(t){return nm(t)?rh(e,a)(t):a(t)}function a(t){return t===41?u(t):eh(e,o,s,`resourceDestination`,`resourceDestinationLiteral`,`resourceDestinationLiteralMarker`,`resourceDestinationRaw`,`resourceDestinationString`,32)(t)}function o(t){return nm(t)?rh(e,c)(t):u(t)}function s(e){return n(e)}function c(t){return t===34||t===39||t===40?nh(e,l,n,`resourceTitle`,`resourceTitleMarker`,`resourceTitleString`)(t):u(t)}function l(t){return nm(t)?rh(e,u)(t):u(t)}function u(r){return r===41?(e.enter(`resourceMarker`),e.consume(r),e.exit(`resourceMarker`),e.exit(`resource`),t):n(r)}}function Mh(e,t,n){let r=this;return i;function i(t){return th.call(r,e,a,o,`reference`,`referenceMarker`,`referenceString`)(t)}function a(e){return r.parser.defined.includes(qp(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function o(e){return n(e)}}function Nh(e,t,n){return r;function r(t){return e.enter(`reference`),e.enter(`referenceMarker`),e.consume(t),e.exit(`referenceMarker`),i}function i(r){return r===93?(e.enter(`referenceMarker`),e.consume(r),e.exit(`referenceMarker`),e.exit(`reference`),t):n(r)}}var Ph={name:`labelStartImage`,resolveAll:wh.resolveAll,tokenize:Fh};function Fh(e,t,n){let r=this;return i;function i(t){return e.enter(`labelImage`),e.enter(`labelImageMarker`),e.consume(t),e.exit(`labelImageMarker`),a}function a(t){return t===91?(e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelImage`),o):n(t)}function o(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Ih={name:`labelStartLink`,resolveAll:wh.resolveAll,tokenize:Lh};function Lh(e,t,n){let r=this;return i;function i(t){return e.enter(`labelLink`),e.enter(`labelMarker`),e.consume(t),e.exit(`labelMarker`),e.exit(`labelLink`),a}function a(e){return e===94&&`_hiddenFootnoteSupport`in r.parser.constructs?n(e):t(e)}}var Rh={name:`lineEnding`,tokenize:zh};function zh(e,t){return n;function n(n){return e.enter(`lineEnding`),e.consume(n),e.exit(`lineEnding`),cm(e,t,`linePrefix`)}}var Bh={name:`thematicBreak`,tokenize:Vh};function Vh(e,t,n){let r=0,i;return a;function a(t){return e.enter(`thematicBreak`),o(t)}function o(e){return i=e,s(e)}function s(a){return a===i?(e.enter(`thematicBreakSequence`),c(a)):r>=3&&(a===null||tm(a))?(e.exit(`thematicBreak`),t(a)):n(a)}function c(t){return t===i?(e.consume(t),r++,c):(e.exit(`thematicBreakSequence`),rm(t)?cm(e,s,`whitespace`)(t):s(t))}}var Hh={continuation:{tokenize:Kh},exit:Jh,name:`list`,tokenize:Gh},Uh={partial:!0,tokenize:Yh},Wh={partial:!0,tokenize:qh};function Gh(e,t,n){let r=this,i=r.events[r.events.length-1],a=i&&i[1].type===`linePrefix`?i[2].sliceSerialize(i[1],!0).length:0,o=0;return s;function s(t){let i=r.containerState.type||(t===42||t===43||t===45?`listUnordered`:`listOrdered`);if(i===`listUnordered`?!r.containerState.marker||t===r.containerState.marker:Qp(t)){if(r.containerState.type||(r.containerState.type=i,e.enter(i,{_container:!0})),i===`listUnordered`)return e.enter(`listItemPrefix`),t===42||t===45?e.check(Bh,n,l)(t):l(t);if(!r.interrupt||t===49)return e.enter(`listItemPrefix`),e.enter(`listItemValue`),c(t)}return n(t)}function c(t){return Qp(t)&&++o<10?(e.consume(t),c):(!r.interrupt||o<2)&&(r.containerState.marker?t===r.containerState.marker:t===41||t===46)?(e.exit(`listItemValue`),l(t)):n(t)}function l(t){return e.enter(`listItemMarker`),e.consume(t),e.exit(`listItemMarker`),r.containerState.marker=r.containerState.marker||t,e.check(Cm,r.interrupt?n:u,e.attempt(Uh,f,d))}function u(e){return r.containerState.initialBlankLine=!0,a++,f(e)}function d(t){return rm(t)?(e.enter(`listItemPrefixWhitespace`),e.consume(t),e.exit(`listItemPrefixWhitespace`),f):n(t)}function f(n){return r.containerState.size=a+r.sliceSerialize(e.exit(`listItemPrefix`),!0).length,t(n)}}function Kh(e,t,n){let r=this;return r.containerState._closeFlow=void 0,e.check(Cm,i,a);function i(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,cm(e,t,`listItemIndent`,r.containerState.size+1)(n)}function a(n){return r.containerState.furtherBlankLines||!rm(n)?(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n)):(r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(Wh,t,o)(n))}function o(i){return r.containerState._closeFlow=!0,r.interrupt=void 0,cm(e,e.attempt(Hh,t,n),`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(i)}}function qh(e,t,n){let r=this;return cm(e,i,`listItemIndent`,r.containerState.size+1);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`listItemIndent`&&i[2].sliceSerialize(i[1],!0).length===r.containerState.size?t(e):n(e)}}function Jh(e){e.exit(this.containerState.type)}function Yh(e,t,n){let r=this;return cm(e,i,`listItemPrefixWhitespace`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:5);function i(e){let i=r.events[r.events.length-1];return!rm(e)&&i&&i[1].type===`listItemPrefixWhitespace`?t(e):n(e)}}var Xh={name:`setextUnderline`,resolveTo:Zh,tokenize:Qh};function Zh(e,t){let n=e.length,r,i,a;for(;n--;)if(e[n][0]===`enter`){if(e[n][1].type===`content`){r=n;break}e[n][1].type===`paragraph`&&(i=n)}else e[n][1].type===`content`&&e.splice(n,1),!a&&e[n][1].type===`definition`&&(a=n);let o={type:`setextHeading`,start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type=`setextHeadingText`,a?(e.splice(i,0,[`enter`,o,t]),e.splice(a+1,0,[`exit`,e[r][1],t]),e[r][1].end={...e[a][1].end}):e[r][1]=o,e.push([`exit`,o,t]),e}function Qh(e,t,n){let r=this,i;return a;function a(t){let a=r.events.length,s;for(;a--;)if(r.events[a][1].type!==`lineEnding`&&r.events[a][1].type!==`linePrefix`&&r.events[a][1].type!==`content`){s=r.events[a][1].type===`paragraph`;break}return!r.parser.lazy[r.now().line]&&(r.interrupt||s)?(e.enter(`setextHeadingLine`),i=t,o(t)):n(t)}function o(t){return e.enter(`setextHeadingLineSequence`),s(t)}function s(t){return t===i?(e.consume(t),s):(e.exit(`setextHeadingLineSequence`),rm(t)?cm(e,c,`lineSuffix`)(t):c(t))}function c(r){return r===null||tm(r)?(e.exit(`setextHeadingLine`),t(r)):n(r)}}var $h={tokenize:eg};function eg(e){let t=this,n=e.attempt(Cm,r,e.attempt(this.parser.constructs.flowInitial,i,cm(e,e.attempt(this.parser.constructs.flow,i,e.attempt(Ym,i)),`linePrefix`)));return n;function r(r){if(r===null){e.consume(r);return}return e.enter(`lineEndingBlank`),e.consume(r),e.exit(`lineEndingBlank`),t.currentConstruct=void 0,n}function i(r){if(r===null){e.consume(r);return}return e.enter(`lineEnding`),e.consume(r),e.exit(`lineEnding`),t.currentConstruct=void 0,n}}var tg={resolveAll:ag()},ng=ig(`string`),rg=ig(`text`);function ig(e){return{resolveAll:ag(e===`text`?og:void 0),tokenize:t};function t(t){let n=this,r=this.parser.constructs[e],i=t.attempt(r,a,o);return a;function a(e){return c(e)?i(e):o(e)}function o(e){if(e===null){t.consume(e);return}return t.enter(`data`),t.consume(e),s}function s(e){return c(e)?(t.exit(`data`),i(e)):(t.consume(e),s)}function c(e){if(e===null)return!0;let t=r[e],i=-1;if(t)for(;++i<t.length;){let e=t[i];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}function ag(e){return t;function t(t,n){let r=-1,i;for(;++r<=t.length;)i===void 0?t[r]&&t[r][1].type===`data`&&(i=r,r++):(!t[r]||t[r][1].type!==`data`)&&(r!==i+2&&(t[i][1].end=t[r-1][1].end,t.splice(i+2,r-i-2),r=i+2),i=void 0);return e?e(t,n):t}}function og(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||e[n][1].type===`lineEnding`)&&e[n-1][1].type===`data`){let r=e[n-1][1],i=t.sliceStream(r),a=i.length,o=-1,s=0,c;for(;a--;){let e=i[a];if(typeof e==`string`){for(o=e.length;e.charCodeAt(o-1)===32;)s++,o--;if(o)break;o=-1}else if(e===-2)c=!0,s++;else if(e!==-1){a++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(s=0),s){let i={type:n===e.length||c||s<2?`lineSuffix`:`hardBreakTrailing`,start:{_bufferIndex:a?o:r.start._bufferIndex+o,_index:r.start._index+a,line:r.end.line,column:r.end.column-s,offset:r.end.offset-s},end:{...r.end}};r.end={...i.start},r.start.offset===r.end.offset?Object.assign(r,i):(e.splice(n,0,[`enter`,i,t],[`exit`,i,t]),n+=2)}n++}return e}var sg=t({attentionMarkers:()=>hg,contentInitial:()=>lg,disable:()=>gg,document:()=>cg,flow:()=>dg,flowInitial:()=>ug,insideSpan:()=>mg,string:()=>fg,text:()=>pg}),cg={42:Hh,43:Hh,45:Hh,48:Hh,49:Hh,50:Hh,51:Hh,52:Hh,53:Hh,54:Hh,55:Hh,56:Hh,57:Hh,62:Tm},lg={91:ih},ug={[-2]:Lm,[-1]:Lm,32:Lm},dg={35:uh,42:Bh,45:[Xh,Bh],60:hh,61:Xh,95:Bh,96:Pm,126:Pm},fg={38:jm,92:km},pg={[-5]:Rh,[-4]:Rh,[-3]:Rh,33:Ph,38:jm,42:_m,60:[xm,Sh],91:Ih,92:[ch,km],93:wh,95:_m,96:Vm},mg={null:[_m,tg]},hg={null:[42,95]},gg={null:[]};function _g(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0},i={},a=[],o=[],s=[],c={attempt:C(x),check:C(S),consume:v,enter:y,exit:b,interrupt:C(S,{interrupt:!0})},l={code:null,containerState:{},defineSkip:h,events:[],now:m,parser:e,previous:null,sliceSerialize:f,sliceStream:p,write:d},u=t.tokenize.call(l,c);return t.resolveAll&&a.push(t),l;function d(e){return o=Vp(o,e),g(),o[o.length-1]===null?(w(t,0),l.events=gm(a,l.events,l),l.events):[]}function f(e,t){return yg(p(e),t)}function p(e){return vg(o,e)}function m(){let{_bufferIndex:e,_index:t,line:n,column:i,offset:a}=r;return{_bufferIndex:e,_index:t,line:n,column:i,offset:a}}function h(e){i[e.line]=e.column,E()}function g(){let e;for(;r._index<o.length;){let t=o[r._index];if(typeof t==`string`)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)_(t.charCodeAt(r._bufferIndex));else _(t)}}function _(e){u=u(e)}function v(e){tm(e)?(r.line++,r.column=1,r.offset+=e===-3?2:1,E()):e!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===o[r._index].length&&(r._bufferIndex=-1,r._index++)),l.previous=e}function y(e,t){let n=t||{};return n.type=e,n.start=m(),l.events.push([`enter`,n,l]),s.push(n),n}function b(e){let t=s.pop();return t.end=m(),l.events.push([`exit`,t,l]),t}function x(e,t){w(e,t.from)}function S(e,t){t.restore()}function C(e,t){return n;function n(n,r,i){let a,o,s,u;return Array.isArray(n)?f(n):`tokenize`in n?f([n]):d(n);function d(e){return t;function t(t){let n=t!==null&&e[t],r=t!==null&&e.null;return f([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}function f(e){return a=e,o=0,e.length===0?i:p(e[o])}function p(e){return n;function n(n){return u=T(),s=e,e.partial||(l.currentConstruct=e),e.name&&l.parser.constructs.disable.null.includes(e.name)?h(n):e.tokenize.call(t?Object.assign(Object.create(l),t):l,c,m,h)(n)}}function m(t){return e(s,u),r}function h(e){return u.restore(),++o<a.length?p(a[o]):i}}}function w(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&Bp(l.events,t,l.events.length-t,e.resolve(l.events.slice(t),l)),e.resolveTo&&(l.events=e.resolveTo(l.events,l))}function T(){let e=m(),t=l.previous,n=l.currentConstruct,i=l.events.length,a=Array.from(s);return{from:i,restore:o};function o(){r=e,l.previous=t,l.currentConstruct=n,l.events.length=i,s=a,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function vg(e,t){let n=t.start._index,r=t.start._bufferIndex,i=t.end._index,a=t.end._bufferIndex,o;if(n===i)o=[e[n].slice(r,a)];else{if(o=e.slice(n,i),r>-1){let e=o[0];typeof e==`string`?o[0]=e.slice(r):o.shift()}a>0&&o.push(e[i].slice(0,a))}return o}function yg(e,t){let n=-1,r=[],i;for(;++n<e.length;){let a=e[n],o;if(typeof a==`string`)o=a;else switch(a){case-5:o=`\r`;break;case-4:o=`
88`;break;case-3:o=`\r
89`;break;case-2:o=t?` `:`	`;break;case-1:if(!t&&i)continue;o=` `;break;default:o=String.fromCharCode(a)}i=a===-2,r.push(o)}return r.join(``)}function bg(e){let t={constructs:Up([sg,...(e||{}).extensions||[]]),content:n(lm),defined:[],document:n(dm),flow:n($h),lazy:{},string:n(ng),text:n(rg)};return t;function n(e){return n;function n(n){return _g(t,e,n)}}}function xg(e){for(;!qm(e););return e}var Sg=/[\0\t\n\r]/g;function Cg(){let e=1,t=``,n=!0,r;return i;function i(i,a,o){let s=[],c,l,u,d,f;for(i=t+(typeof i==`string`?i.toString():new TextDecoder(a||void 0).decode(i)),u=0,t=``,n&&=(i.charCodeAt(0)===65279&&u++,void 0);u<i.length;){if(Sg.lastIndex=u,c=Sg.exec(i),d=c&&c.index!==void 0?c.index:i.length,f=i.charCodeAt(d),!c){t=i.slice(u);break}if(f===10&&u===d&&r)s.push(-3),r=void 0;else switch(r&&=(s.push(-5),void 0),u<d&&(s.push(i.slice(u,d)),e+=d-u),f){case 0:s.push(65533),e++;break;case 9:for(l=Math.ceil(e/4)*4,s.push(-2);e++<l;)s.push(-1);break;case 10:s.push(-4),e=1;break;default:r=!0,e=1}u=d+1}return o&&(r&&s.push(-5),t&&s.push(t),s.push(null)),s}}var wg=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function Tg(e){return e.replace(wg,Eg)}function Eg(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){let e=n.charCodeAt(1),t=e===120||e===88;
vendor: 6,453 bytes, line 89
89return Kp(n.slice(t?2:1),t?16:10)}return zp(n)||e}var Dg={}.hasOwnProperty;function Og(e,t,n){return t&&typeof t==`object`&&(n=t,t=void 0),kg(n)(xg(bg(n).document().write(Cg()(e,t,!0))))}function kg(e){let t={transforms:[],canContainEols:[`emphasis`,`fragment`,`heading`,`paragraph`,`strong`],enter:{autolink:a(me),autolinkProtocol:T,autolinkEmail:T,atxHeading:a(de),blockQuote:a(z),characterEscape:T,characterReference:T,codeFenced:a(se),codeFencedFenceInfo:o,codeFencedFenceMeta:o,codeIndented:a(se,o),codeText:a(ce,o),codeTextData:T,data:T,codeFlowValue:T,definition:a(le),definitionDestinationString:o,definitionLabelString:o,definitionTitleString:o,emphasis:a(ue),hardBreakEscape:a(fe),hardBreakTrailing:a(fe),htmlFlow:a(pe,o),htmlFlowData:T,htmlText:a(pe,o),htmlTextData:T,image:a(B),label:o,link:a(me),listItem:a(he),listItemValue:f,listOrdered:a(V,d),listUnordered:a(V),paragraph:a(ge),reference:te,referenceString:o,resourceDestinationString:o,resourceTitleString:o,setextHeading:a(de),strong:a(_e),thematicBreak:a(ye)},exit:{atxHeading:c(),atxHeadingSequence:x,autolink:c(),autolinkEmail:oe,autolinkProtocol:ae,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:re,characterReferenceMarkerNumeric:re,characterReferenceValue:R,characterReference:ie,codeFenced:c(g),codeFencedFence:h,codeFencedFenceInfo:p,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:c(_),codeText:c(j),codeTextData:E,data:E,definition:c(),definitionDestinationString:b,definitionLabelString:v,definitionTitleString:y,emphasis:c(),hardBreakEscape:c(O),hardBreakTrailing:c(O),htmlFlow:c(k),htmlFlowData:E,htmlText:c(A),htmlTextData:E,image:c(N),label:F,labelText:P,lineEnding:D,link:c(M),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ne,resourceDestinationString:I,resourceTitleString:L,resource:ee,setextHeading:c(w),setextHeadingLineSequence:C,setextHeadingText:S,strong:c(),thematicBreak:c()}};jg(t,(e||{}).mdastExtensions||[]);let n={};return r;function r(e){let r={type:`root`,children:[]},a={stack:[r],tokenStack:[],config:t,enter:s,exit:l,buffer:o,resume:u,data:n},c=[],d=-1;for(;++d<e.length;)(e[d][1].type===`listOrdered`||e[d][1].type===`listUnordered`)&&(e[d][0]===`enter`?c.push(d):d=i(e,c.pop(),d));for(d=-1;++d<e.length;){let n=t[e[d][0]];Dg.call(n,e[d][1].type)&&n[e[d][1].type].call(Object.assign({sliceSerialize:e[d][2].sliceSerialize},a),e[d][1])}if(a.tokenStack.length>0){let e=a.tokenStack[a.tokenStack.length-1];(e[1]||Ng).call(a,void 0,e[0])}for(r.position={start:Ag(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Ag(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},d=-1;++d<t.transforms.length;)r=t.transforms[d](r)||r;return r}function i(e,t,n){let r=t-1,i=-1,a=!1,o,s,c,l;for(;++r<=n;){let t=e[r];switch(t[1].type){case`listUnordered`:case`listOrdered`:case`blockQuote`:t[0]===`enter`?i++:i--,l=void 0;break;case`lineEndingBlank`:t[0]===`enter`&&(o&&!l&&!i&&!c&&(c=r),l=void 0);break;case`linePrefix`:case`listItemValue`:case`listItemMarker`:case`listItemPrefix`:case`listItemPrefixWhitespace`:break;default:l=void 0}if(!i&&t[0]===`enter`&&t[1].type===`listItemPrefix`||i===-1&&t[0]===`exit`&&(t[1].type===`listUnordered`||t[1].type===`listOrdered`)){if(o){let i=r;for(s=void 0;i--;){let t=e[i];if(t[1].type===`lineEnding`||t[1].type===`lineEndingBlank`){if(t[0]===`exit`)continue;s&&(e[s][1].type=`lineEndingBlank`,a=!0),t[1].type=`lineEnding`,s=i}else if(t[1].type!==`linePrefix`&&t[1].type!==`blockQuotePrefix`&&t[1].type!==`blockQuotePrefixWhitespace`&&t[1].type!==`blockQuoteMarker`&&t[1].type!==`listItemIndent`)break}c&&(!s||c<s)&&(o._spread=!0),o.end=Object.assign({},s?e[s][1].start:t[1].end),e.splice(s||r,0,[`exit`,o,t[2]]),r++,n++}if(t[1].type===`listItemPrefix`){let i={type:`listItem`,_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=i,e.splice(r,0,[`enter`,i,t[2]]),r++,n++,c=void 0,l=!0}}}return e[t][1]._spread=a,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function o(){this.stack.push({type:`fragment`,children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:Ag(t.start),end:void 0}}function c(e){return t;function t(t){e&&e.call(this,t),l.call(this,t)}}function l(e,t){let n=this.stack.pop(),r=this.tokenStack.pop();if(r)r[0].type!==e.type&&(t?t.call(this,e,r[0]):(r[1]||Ng).call(this,e,r[0]));else throw Error("Cannot close `"+e.type+"` ("+Qf({start:e.start,end:e.end})+`): it’s not open`);n.position.end=Ag(e.end)}function u(){return Pp(this.stack.pop())}function d(){this.data.expectingFirstListItemValue=!0}function f(e){if(this.data.expectingFirstListItemValue){let t=this.stack[this.stack.length-2];t.start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function p(){let e=this.resume(),t=this.stack[this.stack.length-1];t.lang=e}function m(){let e=this.resume(),t=this.stack[this.stack.length-1];t.meta=e}function h(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,``),this.data.flowCodeInside=void 0}function _(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e.replace(/(\r?\n|\r)$/g,``)}function v(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=qp(this.sliceSerialize(e)).toLowerCase()}function y(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function b(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function x(e){let t=this.stack[this.stack.length-1];t.depth||=this.sliceSerialize(e).length}function S(){this.data.setextHeadingSlurpLineEnding=!0}function C(e){let t=this.stack[this.stack.length-1];t.depth=this.sliceSerialize(e).codePointAt(0)===61?1:2}function w(){this.data.setextHeadingSlurpLineEnding=void 0}function T(e){let t=this.stack[this.stack.length-1].children,n=t[t.length-1];(!n||n.type!==`text`)&&(n=ve(),n.position={start:Ag(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){let t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=Ag(e.end)}function D(e){let n=this.stack[this.stack.length-1];if(this.data.atHardBreak){let t=n.children[n.children.length-1];t.position.end=Ag(e.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.t
vendor: 4,752 bytes, lines 89-91
89ype)&&(T.call(this,e),E.call(this,e))}function O(){this.data.atHardBreak=!0}function k(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function A(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function j(){let e=this.resume(),t=this.stack[this.stack.length-1];t.value=e}function M(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function N(){let e=this.stack[this.stack.length-1];if(this.data.inReference){let t=this.data.referenceType||`shortcut`;e.type+=`Reference`,e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function P(e){let t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=Tg(t),n.identifier=qp(t).toLowerCase()}function F(){let e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];this.data.inReference=!0,n.type===`link`?n.children=e.children:n.alt=t}function I(){let e=this.resume(),t=this.stack[this.stack.length-1];t.url=e}function L(){let e=this.resume(),t=this.stack[this.stack.length-1];t.title=e}function ee(){this.data.inReference=void 0}function te(){this.data.referenceType=`collapsed`}function ne(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=qp(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType=`full`}function re(e){this.data.characterReferenceType=e.type}function R(e){let t=this.sliceSerialize(e),n=this.data.characterReferenceType,r;n?(r=Kp(t,n===`characterReferenceMarkerNumeric`?10:16),this.data.characterReferenceType=void 0):r=zp(t);let i=this.stack[this.stack.length-1];i.value+=r}function ie(e){let t=this.stack.pop();t.position.end=Ag(e.end)}function ae(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=this.sliceSerialize(e)}function oe(e){E.call(this,e);let t=this.stack[this.stack.length-1];t.url=`mailto:`+this.sliceSerialize(e)}function z(){return{type:`blockquote`,children:[]}}function se(){return{type:`code`,lang:null,meta:null,value:``}}function ce(){return{type:`inlineCode`,value:``}}function le(){return{type:`definition`,identifier:``,label:null,title:null,url:``}}function ue(){return{type:`emphasis`,children:[]}}function de(){return{type:`heading`,depth:0,children:[]}}function fe(){return{type:`break`}}function pe(){return{type:`html`,value:``}}function B(){return{type:`image`,title:null,url:``,alt:null}}function me(){return{type:`link`,title:null,url:``,children:[]}}function V(e){return{type:`list`,ordered:e.type===`listOrdered`,start:null,spread:e._spread,children:[]}}function he(e){return{type:`listItem`,spread:e._spread,checked:null,children:[]}}function ge(){return{type:`paragraph`,children:[]}}function _e(){return{type:`strong`,children:[]}}function ve(){return{type:`text`,value:``}}function ye(){return{type:`thematicBreak`}}}function Ag(e){return{line:e.line,column:e.column,offset:e.offset}}function jg(e,t){let n=-1;for(;++n<t.length;){let r=t[n];Array.isArray(r)?jg(e,r):Mg(e,r)}}function Mg(e,t){let n;for(n in t)if(Dg.call(t,n))switch(n){case`canContainEols`:{let r=t[n];r&&e[n].push(...r);break}case`transforms`:{let r=t[n];r&&e[n].push(...r);break}case`enter`:case`exit`:{let r=t[n];r&&Object.assign(e[n],r);break}}}function Ng(e,t){throw Error(e?"Cannot close `"+e.type+"` ("+Qf({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Qf({start:t.start,end:t.end})+`) is open`:"Cannot close document, a token (`"+t.type+"`, "+Qf({start:t.start,end:t.end})+`) is still open`)}function Pg(e){let t=this;t.parser=n;function n(n){return Og(n,{...t.data(`settings`),...e,extensions:t.data(`micromarkExtensions`)||[],mdastExtensions:t.data(`fromMarkdownExtensions`)||[]})}}function Fg(e,t){let n={type:`element`,tagName:`blockquote`,properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)}function Ig(e,t){let n={type:`element`,tagName:`br`,properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:`text`,value:`
90`}]}function Lg(e,t){let n=t.value?t.value+`
91`:``,r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=[`language-`+i[0]]);let a={type:`element`,tagName:`code`,properties:r,children:[{type:`text`,value:n}]};return t.meta&&(a.data={meta:t.meta}),e.patch(t,a),a=e.applyData(t,a),a={type:`element`,tagName:`pre`,properties:{},children:[a]},e.patch(t,a),a}function Rg(e,t){let n={type:`element`,tagName:`del`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function zg(e,t){let n={type:`element`,tagName:`em`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}
vendor: 8,462 bytes, lines 91-93
91function Bg(e,t){let n=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,r=String(t.identifier).toUpperCase(),i=sm(r.toLowerCase()),a=e.footnoteOrder.indexOf(r),o,s=e.footnoteCounts.get(r);s===void 0?(s=0,e.footnoteOrder.push(r),o=e.footnoteOrder.length):o=a+1,s+=1,e.footnoteCounts.set(r,s);let c={type:`element`,tagName:`a`,properties:{href:`#`+n+`fn-`+i,id:n+`fnref-`+i+(s>1?`-`+s:``),dataFootnoteRef:!0,ariaDescribedBy:[`footnote-label`]},children:[{type:`text`,value:String(o)}]};e.patch(t,c);let l={type:`element`,tagName:`sup`,properties:{},children:[c]};return e.patch(t,l),e.applyData(t,l)}function Vg(e,t){let n={type:`element`,tagName:`h`+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function Hg(e,t){if(e.options.allowDangerousHtml){let n={type:`raw`,value:t.value};return e.patch(t,n),e.applyData(t,n)}}function Ug(e,t){let n=t.referenceType,r=`]`;if(n===`collapsed`?r+=`[]`:n===`full`&&(r+=`[`+(t.label||t.identifier)+`]`),t.type===`imageReference`)return[{type:`text`,value:`![`+t.alt+r}];let i=e.all(t),a=i[0];a&&a.type===`text`?a.value=`[`+a.value:i.unshift({type:`text`,value:`[`});let o=i[i.length-1];return o&&o.type===`text`?o.value+=r:i.push({type:`text`,value:r}),i}function Wg(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Ug(e,t);let i={src:sm(r.url||``),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`img`,properties:i,children:[]};return e.patch(t,a),e.applyData(t,a)}function Gg(e,t){let n={src:sm(t.url)};t.alt!==null&&t.alt!==void 0&&(n.alt=t.alt),t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`img`,properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)}function Kg(e,t){let n={type:`text`,value:t.value.replace(/\r?\n|\r/g,` `)};e.patch(t,n);let r={type:`element`,tagName:`code`,properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)}function qg(e,t){let n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Ug(e,t);let i={href:sm(r.url||``)};r.title!==null&&r.title!==void 0&&(i.title=r.title);let a={type:`element`,tagName:`a`,properties:i,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)}function Jg(e,t){let n={href:sm(t.url)};t.title!==null&&t.title!==void 0&&(n.title=t.title);let r={type:`element`,tagName:`a`,properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function Yg(e,t,n){let r=e.all(t),i=n?Xg(n):Zg(t),a={},o=[];if(typeof t.checked==`boolean`){let e=r[0],n;e&&e.type===`element`&&e.tagName===`p`?n=e:(n={type:`element`,tagName:`p`,properties:{},children:[]},r.unshift(n)),n.children.length>0&&n.children.unshift({type:`text`,value:` `}),n.children.unshift({type:`element`,tagName:`input`,properties:{type:`checkbox`,checked:t.checked,disabled:!0},children:[]}),a.className=[`task-list-item`]}let s=-1;for(;++s<r.length;){let e=r[s];(i||s!==0||e.type!==`element`||e.tagName!==`p`)&&o.push({type:`text`,value:`
92`}),e.type===`element`&&e.tagName===`p`&&!i?o.push(...e.children):o.push(e)}let c=r[r.length-1];c&&(i||c.type!==`element`||c.tagName!==`p`)&&o.push({type:`text`,value:`
93`});let l={type:`element`,tagName:`li`,properties:a,children:o};return e.patch(t,l),e.applyData(t,l)}function Xg(e){let t=!1;if(e.type===`list`){t=e.spread||!1;let n=e.children,r=-1;for(;!t&&++r<n.length;)t=Zg(n[r])}return t}function Zg(e){return e.spread??e.children.length>1}function Qg(e,t){let n={},r=e.all(t),i=-1;for(typeof t.start==`number`&&t.start!==1&&(n.start=t.start);++i<r.length;){let e=r[i];if(e.type===`element`&&e.tagName===`li`&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes(`task-list-item`)){n.className=[`contains-task-list`];break}}let a={type:`element`,tagName:t.ordered?`ol`:`ul`,properties:n,children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)}function $g(e,t){let n={type:`element`,tagName:`p`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function e_(e,t){let n={type:`root`,children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function t_(e,t){let n={type:`element`,tagName:`strong`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function n_(e,t){let n=e.all(t),r=n.shift(),i=[];if(r){let n={type:`element`,tagName:`thead`,properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),i.push(n)}if(n.length>0){let r={type:`element`,tagName:`tbody`,properties:{},children:e.wrap(n,!0)},a=Yf(t.children[1]),o=Jf(t.children[t.children.length-1]);a&&o&&(r.position={start:a,end:o}),i.push(r)}let a={type:`element`,tagName:`table`,properties:{},children:e.wrap(i,!0)};return e.patch(t,a),e.applyData(t,a)}function r_(e,t,n){let r=n?n.children:void 0,i=(r?r.indexOf(t):1)===0?`th`:`td`,a=n&&n.type===`table`?n.align:void 0,o=a?a.length:t.children.length,s=-1,c=[];for(;++s<o;){let n=t.children[s],r={},o=a?a[s]:void 0;o&&(r.align=o);let l={type:`element`,tagName:i,properties:r,children:[]};n&&(l.children=e.all(n),e.patch(n,l),l=e.applyData(n,l)),c.push(l)}let l={type:`element`,tagName:`tr`,properties:{},children:e.wrap(c,!0)};return e.patch(t,l),e.applyData(t,l)}function i_(e,t){let n={type:`element`,tagName:`td`,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}var a_=9,o_=32;function s_(e){let t=String(e),n=/\r?\n|\r/g,r=n.exec(t),i=0,a=[];for(;r;)a.push(c_(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return a.push(c_(t.slice(i),i>0,!1)),a.join(``)}function c_(e,t,n){let r=0,i=e.length;if(t){let t=e.codePointAt(r);for(;t===a_||t===o_;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(i-1);for(;t===a_||t===o_;)i--,t=e.codePointAt(i-1)}return i>r?e.slice(r,i):``}function l_(e,t){let n={type:`text`,value:s_(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function u_(e,t){let n={type:`element`,tagName:`hr`,properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}var d_={blockquote:Fg,break:Ig,code:Lg,delete:Rg,emphasis:zg,footnoteReference:Bg,heading:Vg,html:Hg,imageReference:Wg,image:Gg,inlineCode:Kg,linkReference:qg,link:Jg,listItem:Yg,list:Qg,paragraph:$g,root:e_,strong:t_,table:n_,tableCell:i_,tableRow:r_,text:l_,thematicBreak:u_,toml:f_,yaml:f_,definition:f_,footnoteDefinition:f_};function f_(){}var p_=typeof self==`object`?self:globalThis,m_=(e,t)=>{let n=(t,n)=>(e.set(n,t),t),r=i=>{if(e.has(i))return e.get(i);let[a,o]=t[i];switch(a){case 0:case-1:return n(o,i);case 1:{let e=n([],i);for(let t of o)e.push(r(t));return e}case 2:{let e=n({},i);for(let[t,n]of o)e[r(t)]=r(n);return e}case 3:return n(new Date(o),i);case 4:{let{source:e,flags:t}=o;return n(new RegExp(e,t),i)}case 5:{let e=n(new Map,i);for(let[t,n]of o)e.set(r(t),r(n));return e}case 6:{let e=n(new Set,i);for(let t of o)e.add(r(t));return e}case 7:{let{name:e,message:t}=o;return n(new p_[e](t),i)}case 8:return n(BigInt(o),i);case`BigInt`:return n(Object(BigInt(o)),i);case`ArrayBuffer`:return n(new Uint8Array(o).buffer,o);case`DataView`:{let{buffer:e}=new Uint8Array(o);return n(new DataView(e),o)}}return n(new p_[a](o),i)};return r},h_=e=>m_(new Map,e)(0),g_=``,{toString:__}={},{keys:v_}=Object,y_=e=>{let t=typeof e;if(t!==`object`||!e)return[0,t];let n=__.call(e).slice(8,-1);switch(n){case`Array`:return[1,g_];case`Object`:return[2,g_];case`Date`:return[3,g_];case`RegExp`:return[4,g_];case`Map`:return[5,g_];case`Set`:return[6,g_];case`DataView`:return[1,n]}return n.includes(`Array`)?[1,n]:n.includes(`Error`)?[7,n]:[2,n]},b_=([e,t])=>e===0&&(t===`function`||t===`symbol`),x_=(e,t,n,r)=>{let i=(e,t)=>{let i=r.push(e)-1;return n.set(t,i),i},a=r=>{if(n.has(r))return n.get(r);let[o,s]=y_(r);switch(o){case 0:{let t=r;switch(s){case`bigint`:o=8,t=r.toString();break;case`function`:case`symbol`:if(e)throw TypeError(`unable to serialize `+s);t=null;break;case`undefined`:return i([-1],r)}return i([o,t],r)}case 1:{if(s){let e=r;return s===`DataView`?e=new Uint8Array(r.buffer):s===`ArrayBuffer`&&(e=new Uint8Array(r)),i([s,[...e]],r)}let e=[],t=i([o,e],r);for(let t of r)e.push(a(t));return t}case 2:{if(s)switch(s){case`BigInt`:return i([s,r.toString()],r);case`Boolean`:case`Number`:case`String`:return i([s,r.valueOf()],r)}if(t&&`toJSON`in r)return a(r.toJSON());let n=[],c=i([o,n],r);for(let t of v_(r))(e||!b_(y_(r[t])))&&n.push([a(t),a(r[t])]);return c}case 3:return i([o,r.toISOString()],r);case 4:{let{source:e,flags:t}=r;return i([o,{source:e,flags:t}],r)}case 5:{let t=[],n=i([o,t],r);
vendor: 2,785 bytes, lines 93-95
93for(let[n,i]of r)(e||!(b_(y_(n))||b_(y_(i))))&&t.push([a(n),a(i)]);return n}case 6:{let t=[],n=i([o,t],r);for(let n of r)(e||!b_(y_(n)))&&t.push(a(n));return n}}let{message:c}=r;return i([o,{name:s,message:c}],r)};return a},S_=(e,{json:t,lossy:n}={})=>{let r=[];return x_(!(t||n),!!t,new Map,r)(e),r},C_=typeof structuredClone==`function`?(e,t)=>t&&(`json`in t||`lossy`in t)?h_(S_(e,t)):structuredClone(e):(e,t)=>h_(S_(e,t));function w_(e,t){let n=[{type:`text`,value:`↩`}];return t>1&&n.push({type:`element`,tagName:`sup`,properties:{},children:[{type:`text`,value:String(t)}]}),n}function T_(e,t){return`Back to reference `+(e+1)+(t>1?`-`+t:``)}function E_(e){let t=typeof e.options.clobberPrefix==`string`?e.options.clobberPrefix:`user-content-`,n=e.options.footnoteBackContent||w_,r=e.options.footnoteBackLabel||T_,i=e.options.footnoteLabel||`Footnotes`,a=e.options.footnoteLabelTagName||`h2`,o=e.options.footnoteLabelProperties||{className:[`sr-only`]},s=[],c=-1;for(;++c<e.footnoteOrder.length;){let i=e.footnoteById.get(e.footnoteOrder[c]);if(!i)continue;let a=e.all(i),o=String(i.identifier).toUpperCase(),l=sm(o.toLowerCase()),u=0,d=[],f=e.footnoteCounts.get(o);for(;f!==void 0&&++u<=f;){d.length>0&&d.push({type:`text`,value:` `});let e=typeof n==`string`?n:n(c,u);typeof e==`string`&&(e={type:`text`,value:e}),d.push({type:`element`,tagName:`a`,properties:{href:`#`+t+`fnref-`+l+(u>1?`-`+u:``),dataFootnoteBackref:``,ariaLabel:typeof r==`string`?r:r(c,u),className:[`data-footnote-backref`]},children:Array.isArray(e)?e:[e]})}let p=a[a.length-1];if(p&&p.type===`element`&&p.tagName===`p`){let e=p.children[p.children.length-1];e&&e.type===`text`?e.value+=` `:p.children.push({type:`text`,value:` `}),p.children.push(...d)}else a.push(...d);let m={type:`element`,tagName:`li`,properties:{id:t+`fn-`+l},children:e.wrap(a,!0)};e.patch(i,m),s.push(m)}if(s.length!==0)return{type:`element`,tagName:`section`,properties:{dataFootnotes:!0,className:[`footnotes`]},children:[{type:`element`,tagName:a,properties:{...C_(o),id:`footnote-label`},children:[{type:`text`,value:i}]},{type:`text`,value:`
94`},{type:`element`,tagName:`ol`,properties:{},children:e.wrap(s,!0)},{type:`text`,value:`
95`}]}}var D_=(function(e){if(e==null)return M_;if(typeof e==`function`)return j_(e);if(typeof e==`object`)return Array.isArray(e)?O_(e):k_(e);if(typeof e==`string`)return A_(e);throw Error(`Expected function, string, or object as test`)});function O_(e){let t=[],n=-1;for(;++n<e.length;)t[n]=D_(e[n]);return j_(r);function r(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}function k_(e){let t=e;return j_(n);function n(n){let r=n,i;for(i in e)if(r[i]!==t[i])return!1;return!0}}function A_(e){return j_(t);function t(t){return t&&t.type===e}}function j_(e){return t;
vendor: 4,621 bytes, lines 95-99
95function t(t,n,r){return!!(N_(t)&&e.call(this,t,typeof n==`number`?n:void 0,r||void 0))}}function M_(){return!0}function N_(e){return typeof e==`object`&&!!e&&`type`in e}function P_(e){return e}var F_=[];function I_(e,t,n,r){let i;typeof t==`function`&&typeof n!=`function`?(r=n,n=t):i=t;let a=D_(i),o=r?-1:1;s(e,void 0,[])();function s(e,i,c){let l=e&&typeof e==`object`?e:{};if(typeof l.type==`string`){let t=typeof l.tagName==`string`?l.tagName:typeof l.name==`string`?l.name:void 0;Object.defineProperty(u,"name",{value:`node (`+P_(e.type+(t?`<`+t+`>`:``))+`)`})}return u;function u(){let l=F_,u,d,f;if((!t||a(e,i,c[c.length-1]||void 0))&&(l=L_(n(e,c)),l[0]===!1))return l;if(`children`in e&&e.children){let t=e;if(t.children&&l[0]!==`skip`)for(d=(r?t.children.length:-1)+o,f=c.concat(t);d>-1&&d<t.children.length;){let e=t.children[d];if(u=s(e,d,f)(),u[0]===!1)return u;d=typeof u[1]==`number`?u[1]:d+o}}return l}}}function L_(e){return Array.isArray(e)?e:typeof e==`number`?[!0,e]:e==null?F_:[e]}function R_(e,t,n,r){let i,a,o;typeof t==`function`&&typeof n!=`function`?(a=void 0,o=t,i=n):(a=t,o=n,i=r),I_(e,a,s,i);function s(e,t){let n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return o(e,r,n)}}var z_={}.hasOwnProperty,B_={};function V_(e,t){let n=t||B_,r=new Map,i=new Map,a={all:s,applyData:U_,definitionById:r,footnoteById:i,footnoteCounts:new Map,footnoteOrder:[],handlers:{...d_,...n.handlers},one:o,options:n,patch:H_,wrap:G_};return R_(e,function(e){if(e.type===`definition`||e.type===`footnoteDefinition`){let t=e.type===`definition`?r:i,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}}),a;function o(e,t){let n=e.type,r=a.handlers[n];if(z_.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if(`children`in e){let{children:t,...n}=e,r=C_(n);return r.children=a.all(e),r}return C_(e)}return(a.options.unknownHandler||W_)(a,e,t)}function s(e){let t=[];if(`children`in e){let n=e.children,r=-1;for(;++r<n.length;){let i=a.one(n[r],e);if(i){if(r&&n[r-1].type===`break`&&(!Array.isArray(i)&&i.type===`text`&&(i.value=K_(i.value)),!Array.isArray(i)&&i.type===`element`)){let e=i.children[0];e&&e.type===`text`&&(e.value=K_(e.value))}Array.isArray(i)?t.push(...i):t.push(i)}}}return t}}function H_(e,t){e.position&&(t.position=Zf(e))}function U_(e,t){let n=t;if(e&&e.data){let t=e.data.hName,r=e.data.hChildren,i=e.data.hProperties;typeof t==`string`&&(n.type===`element`?n.tagName=t:n={type:`element`,tagName:t,properties:{},children:`children`in n?n.children:[n]}),n.type===`element`&&i&&Object.assign(n.properties,C_(i)),`children`in n&&n.children&&r!=null&&(n.children=r)}return n}function W_(e,t){let n=t.data||{},r=`value`in t&&!(z_.call(n,`hProperties`)||z_.call(n,`hChildren`))?{type:`text`,value:t.value}:{type:`element`,tagName:`div`,properties:{},children:e.all(t)};return e.patch(t,r),e.applyData(t,r)}function G_(e,t){let n=[],r=-1;for(t&&n.push({type:`text`,value:`
96`});++r<e.length;)r&&n.push({type:`text`,value:`
97`}),n.push(e[r]);return t&&e.length>0&&n.push({type:`text`,value:`
98`}),n}function K_(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function q_(e,t){let n=V_(e,t),r=n.one(e,void 0),i=E_(n),a=Array.isArray(r)?{type:`root`,children:r}:r||{type:`root`,children:[]};return i&&(`children`in a,a.children.push({type:`text`,value:`
99`},i)),a}function J_(e,t){return e&&`run`in e?async function(n,r){let i=q_(n,{file:r,...t});await e.run(i,r)}:function(n,r){return q_(n,{file:r,...e||t})}}function Y_(e){if(e)throw e}var X_=e(n(((e,t)=>{var n=Object.prototype.hasOwnProperty,r=Object.prototype.toString,i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=function(e){return typeof Array.isArray==`function`?Array.isArray(e):r.call(e)===`[object Array]`},s=function(e){if(!e||r.call(e)!==`[object Object]`)return!1;var t=n.call(e,`constructor`),i=e.constructor&&e.constructor.prototype&&n.call(e.constructor.prototype,`isPrototypeOf`);if(e.constructor&&!t&&!i)return!1;for(var a in e);return a===void 0||n.call(e,a)},c=function(e,t){i&&t.name===`__proto__`?i(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},l=function(e,t){if(t===`__proto__`){if(!n.call(e,t))return;if(a)return a(e,t).value}return e[t]};t.exports=function e(){var t,n,r,i,a,u,d=arguments[0],f=1,p=arguments.length,m=!1;for(typeof d==`boolean`&&(m=d,d=arguments[1]||{},f=2),(d==null||typeof d!=`object`&&typeof d!=`function`)&&(d={});f<p;++f)if(t=arguments[f],t!=null)for(n in t)r=l(d,n),i=l(t,n),d!==i&&(m&&i&&(s(i)||(a=o(i)))?(a?(a=!1,u=r&&o(r)?r:[]):u=r&&s(r)?r:{}
vendor: 4,523 bytes, line 99
99,c(d,{name:n,newValue:e(m,u,i)})):i!==void 0&&c(d,{name:n,newValue:i}));return d}}))(),1);function Z_(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)}function Q_(){let e=[],t={run:n,use:r};return t;function n(...t){let n=-1,r=t.pop();if(typeof r!=`function`)throw TypeError(`Expected function as last argument, not `+r);i(null,...t);function i(a,...o){let s=e[++n],c=-1;if(a){r(a);return}for(;++c<t.length;)(o[c]===null||o[c]===void 0)&&(o[c]=t[c]);t=o,s?$_(s,i)(...o):r(null,...o)}}function r(n){if(typeof n!=`function`)throw TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}}function $_(e,t){let n;return r;function r(...t){let r=e.length>t.length,o;r&&t.push(i);try{o=e.apply(this,t)}catch(e){let t=e;if(r&&n)throw t;return i(t)}r||(o&&o.then&&typeof o.then==`function`?o.then(a,i):o instanceof Error?i(o):a(o))}function i(e,...r){n||(n=!0,t(e,...r))}function a(e){i(null,e)}}var ev={basename:tv,dirname:nv,extname:rv,join:iv,sep:`/`};function tv(e,t){if(t!==void 0&&typeof t!=`string`)throw TypeError(`"ext" argument must be a string`);sv(e);let n=0,r=-1,i=e.length,a;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else r<0&&(a=!0,r=i+1);return r<0?``:e.slice(n,r)}if(t===e)return``;let o=-1,s=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(a){n=i+1;break}}else o<0&&(a=!0,o=i+1),s>-1&&(e.codePointAt(i)===t.codePointAt(s--)?s<0&&(r=i):(s=-1,r=o));return n===r?r=o:r<0&&(r=e.length),e.slice(n,r)}function nv(e){if(sv(e),e.length===0)return`.`;let t=-1,n=e.length,r;for(;--n;)if(e.codePointAt(n)===47){if(r){t=n;break}}else r||=!0;return t<0?e.codePointAt(0)===47?`/`:`.`:t===1&&e.codePointAt(0)===47?`//`:e.slice(0,t)}function rv(e){sv(e);let t=e.length,n=-1,r=0,i=-1,a=0,o;for(;t--;){let s=e.codePointAt(t);if(s===47){if(o){r=t+1;break}continue}n<0&&(o=!0,n=t+1),s===46?i<0?i=t:a!==1&&(a=1):i>-1&&(a=-1)}return i<0||n<0||a===0||a===1&&i===n-1&&i===r+1?``:e.slice(i,n)}function iv(...e){let t=-1,n;for(;++t<e.length;)sv(e[t]),e[t]&&(n=n===void 0?e[t]:n+`/`+e[t]);return n===void 0?`.`:av(n)}function av(e){sv(e);let t=e.codePointAt(0)===47,n=ov(e,!t);return n.length===0&&!t&&(n=`.`),n.length>0&&e.codePointAt(e.length-1)===47&&(n+=`/`),t?`/`+n:n}function ov(e,t){let n=``,r=0,i=-1,a=0,o=-1,s,c;for(;++o<=e.length;){if(o<e.length)s=e.codePointAt(o);else if(s===47)break;else s=47;if(s===47){if(i!==o-1&&a!==1){if(i!==o-1&&a===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf(`/`),c!==n.length-1){c<0?(n=``,r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf(`/`)),i=o,a=0;continue}}else if(n.length>0){n=``,r=0,i=o,a=0;continue}}t&&(n=n.length>0?n+`/..`:`..`,r=2)}else n.length>0?n+=`/`+e.slice(i+1,o):n=e.slice(i+1,o),r=o-i-1}i=o,a=0}else s===46&&a>-1?a++:a=-1}return n}function sv(e){if(typeof e!=`string`)throw TypeError(`Path must be a string. Received `+JSON.stringify(e))}var cv={cwd:lv};function lv(){return`/`}function uv(e){return!!(typeof e==`object`&&e&&`href`in e&&e.href&&`protocol`in e&&e.protocol&&e.auth===void 0)}function dv(e){if(typeof e==`string`)e=new URL(e);else if(!uv(e)){let t=TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code=`ERR_INVALID_ARG_TYPE`,t}if(e.protocol!==`file:`){let e=TypeError(`The URL must be of scheme file`);throw e.code=`ERR_INVALID_URL_SCHEME`,e}return fv(e)}function fv(e){if(e.hostname!==``){let e=TypeError(`File URL host must be "localhost" or empty on darwin`);throw e.code=`ERR_INVALID_FILE_URL_HOST`,e}let t=e.pathname,n=-1;for(;++n<t.length;)if(t.codePointAt(n)===37&&t.codePointAt(n+1)===50){let e=t.codePointAt(n+2);if(e===70||e===102){let e=TypeError(`File URL path must not include encoded / characters`);throw e.code=`ERR_INVALID_FILE_URL_PATH`,e}}return decodeURIComponent(t)}var pv=[`history`,`path`,`basename`,`stem`,`extname`,`dirname`],mv=class{constructor(e){let t;t=e?uv(e)?{path:e}:typeof e==`string`||vv(e)?{value:e}:e:{},this.cwd=`cwd`in t?``:cv.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n=-1;for(;++n<pv.length;){let e=pv[n];e in t&&t[e]!==void 0&&t[e]!==null&&(this[e]=e===`history`?[...t[e]]:t[e])}let r;for(r in t)pv.includes(r)||(this[r]=t[r])}get basename(){return typeof this.path==`string`?ev.basename(this.path):void 0}
vendor: 13,890 bytes, lines 99-100
99set basename(e){gv(e,`basename`),hv(e,`basename`),this.path=ev.join(this.dirname||``,e)}get dirname(){return typeof this.path==`string`?ev.dirname(this.path):void 0}set dirname(e){_v(this.basename,`dirname`),this.path=ev.join(e||``,this.basename)}get extname(){return typeof this.path==`string`?ev.extname(this.path):void 0}set extname(e){if(hv(e,`extname`),_v(this.dirname,`extname`),e){if(e.codePointAt(0)!==46)throw Error("`extname` must start with `.`");if(e.includes(`.`,1))throw Error("`extname` cannot contain multiple dots")}this.path=ev.join(this.dirname,this.stem+(e||``))}get path(){return this.history[this.history.length-1]}set path(e){uv(e)&&(e=dv(e)),gv(e,`path`),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path==`string`?ev.basename(this.path,this.extname):void 0}set stem(e){gv(e,`stem`),hv(e,`stem`),this.path=ev.join(this.dirname||``,e+(this.extname||``))}fail(e,t,n){let r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){let r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){let r=new np(e,t,n);return this.path&&(r.name=this.path+`:`+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?``:typeof this.value==`string`?this.value:new TextDecoder(e||void 0).decode(this.value)}};function hv(e,t){if(e&&e.includes(ev.sep))throw Error("`"+t+"` cannot be a path: did not expect `"+ev.sep+"`")}function gv(e,t){if(!e)throw Error("`"+t+"` cannot be empty")}function _v(e,t){if(!e)throw Error("Setting `"+t+"` requires `path` to be set too")}function vv(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var yv=(function(e){let t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r}),bv={}.hasOwnProperty,xv=new class e extends yv{constructor(){super(`copy`),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=Q_()}copy(){let t=new e,n=-1;for(;++n<this.attachers.length;){let e=this.attachers[n];t.use(...e)}return t.data((0,X_.default)(!0,{},this.namespace)),t}data(e,t){return typeof e==`string`?arguments.length===2?(wv(`data`,this.frozen),this.namespace[e]=t,this):bv.call(this.namespace,e)&&this.namespace[e]||void 0:e?(wv(`data`,this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;let e=this;for(;++this.freezeIndex<this.attachers.length;){let[t,...n]=this.attachers[this.freezeIndex];if(n[0]===!1)continue;n[0]===!0&&(n[0]=void 0);let r=t.call(e,...n);typeof r==`function`&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=1/0,this}parse(e){this.freeze();let t=Dv(e),n=this.parser||this.Parser;return Sv(`parse`,n),n(String(t),t)}process(e,t){let n=this;return this.freeze(),Sv(`process`,this.parser||this.Parser),Cv(`process`,this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,i){let a=Dv(e),o=n.parse(a);n.run(o,a,function(e,t,r){if(e||!t||!r)return s(e);let i=t,a=n.stringify(i,r);kv(a)?r.value=a:r.result=a,s(e,r)});function s(e,n){e||!n?i(e):r?r(n):t(void 0,n)}}}processSync(e){let t=!1,n;return this.freeze(),Sv(`processSync`,this.parser||this.Parser),Cv(`processSync`,this.compiler||this.Compiler),this.process(e,r),Ev(`processSync`,`process`,t),n;function r(e,r){t=!0,Y_(e),n=r}}run(e,t,n){Tv(e),this.freeze();let r=this.transformers;return!n&&typeof t==`function`&&(n=t,t=void 0),n?i(void 0,n):new Promise(i);function i(i,a){let o=Dv(t);r.run(e,o,s);function s(t,r,o){let s=r||e;t?a(t):i?i(s):n(void 0,s,o)}}}runSync(e,t){let n=!1,r;return this.run(e,t,i),Ev(`runSync`,`run`,n),r;function i(e,t){Y_(e),r=t,n=!0}}stringify(e,t){this.freeze();let n=Dv(t),r=this.compiler||this.Compiler;return Cv(`stringify`,r),Tv(e),r(e,n)}use(e,...t){let n=this.attachers,r=this.namespace;if(wv(`use`,this.frozen),e!=null){if(typeof e==`function`)s(e,t);else if(typeof e==`object`)Array.isArray(e)?o(e):a(e);else throw TypeError("Expected usable value, not `"+e+"`")}return this;function i(e){if(typeof e==`function`)s(e,[]);else if(typeof e==`object`){if(Array.isArray(e)){let[t,...n]=e;s(t,n)}else a(e)}else throw TypeError("Expected usable value, not `"+e+"`")}function a(e){if(!(`plugins`in e)&&!(`settings`in e))throw Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");o(e.plugins),e.settings&&(r.settings=(0,X_.default)(!0,r.settings,e.settings))}function o(e){let t=-1;if(e!=null){if(Array.isArray(e))for(;++t<e.length;){let n=e[t];i(n)}else throw TypeError("Expected a list of plugins, not `"+e+"`")}}function s(e,t){let r=-1,i=-1;for(;++r<n.length;)if(n[r][0]===e){i=r;break}if(i===-1)n.push([e,...t]);else if(t.length>0){let[r,...a]=t,o=n[i][1];Z_(o)&&Z_(r)&&(r=(0,X_.default)(!0,o,r)),n[i]=[e,r,...a]}}}}().freeze();function Sv(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `parser`")}function Cv(e,t){if(typeof t!=`function`)throw TypeError("Cannot `"+e+"` without `compiler`")}function wv(e,t){if(t)throw Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Tv(e){if(!Z_(e)||typeof e.type!=`string`)throw TypeError("Expected node, got `"+e+"`")}function Ev(e,t,n){if(!n)throw Error("`"+e+"` finished async. Use `"+t+"` instead")}function Dv(e){return Ov(e)?e:new mv(e)}function Ov(e){return!!(e&&typeof e==`object`&&`message`in e&&`messages`in e)}function kv(e){return typeof e==`string`||Av(e)}function Av(e){return!!(e&&typeof e==`object`&&`byteLength`in e&&`byteOffset`in e)}var jv=[],Mv={allowDangerousHtml:!0},Nv=/^(https?|ircs?|mailto|xmpp)$/i,Pv=[{from:`astPlugins`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowDangerousHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`allowNode`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowElement`},{from:`allowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`allowedElements`},{from:`className`,id:`remove-classname`},{from:`disallowedTypes`,id:`replace-allownode-allowedtypes-and-disallowedtypes`,to:`disallowedElements`},{from:`escapeHtml`,id:`remove-buggy-html-in-markdown-parser`},{from:`includeElementIndex`,id:`#remove-includeelementindex`},{from:`includeNodeIndex`,id:`change-includenodeindex-to-includeelementindex`},{from:`linkTarget`,id:`remove-linktarget`},{from:`plugins`,id:`change-plugins-to-remarkplugins`,to:`remarkPlugins`},{from:`rawSourcePos`,id:`#remove-rawsourcepos`},{from:`renderers`,id:`change-renderers-to-components`,to:`components`},{from:`source`,id:`change-source-to-children`,to:`children`},{from:`sourcePos`,id:`#remove-sourcepos`},{from:`transformImageUri`,id:`#add-urltransform`,to:`urlTransform`},{from:`transformLinkUri`,id:`#add-urltransform`,to:`urlTransform`}];function Fv(e){let t=Iv(e),n=Lv(e);return Rv(t.runSync(t.parse(n),n),e)}function Iv(e){let t=e.rehypePlugins||jv,n=e.remarkPlugins||jv,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Mv}:Mv;return xv().use(Pg).use(n).use(J_,r).use(t)}function Lv(e){let t=e.children||``,n=new mv;return typeof t==`string`?n.value=t:``+t,n}function Rv(e,t){let n=t.allowedElements,r=t.allowElement,i=t.components,a=t.disallowedElements,o=t.skipHtml,s=t.unwrapDisallowed,c=t.urlTransform||zv;for(let e of Pv)Object.hasOwn(t,e.from)&&``+e.from+(e.to?"use `"+e.to+"` instead":`remove it`)+e.id;return R_(e,l),up(e,{Fragment:X.Fragment,components:i,ignoreInvalidStyle:!0,jsx:X.jsx,jsxs:X.jsxs,passKeys:!0,passNode:!0});function l(e,t,i){if(e.type===`raw`&&i&&typeof t==`number`)return o?i.children.splice(t,1):i.children[t]={type:`text`,value:e.value},t;if(e.type===`element`){let t;for(t in Mp)if(Object.hasOwn(Mp,t)&&Object.hasOwn(e.properties,t)){let n=e.properties[t],r=Mp[t];(r===null||r.includes(e.tagName))&&(e.properties[t]=c(String(n||``),t,e))}}if(e.type===`element`){let o=n?!n.includes(e.tagName):a?a.includes(e.tagName):!1;if(!o&&r&&typeof t==`number`&&(o=!r(e,t,i)),o&&i&&typeof t==`number`)return s&&e.children?i.children.splice(t,1,...e.children):i.children.splice(t,1),t}}}function zv(e){let t=e.indexOf(`:`),n=e.indexOf(`?`),r=e.indexOf(`#`),i=e.indexOf(`/`);return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Nv.test(e.slice(0,t))?e:``}function Bv(e,t){let n=String(e);if(typeof t!=`string`)throw TypeError(`Expected character`);let r=0,i=n.indexOf(t);for(;i!==-1;)r++,i=n.indexOf(t,i+t.length);return r}function Vv(e){if(typeof e!=`string`)throw TypeError(`Expected a string`);return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}function Hv(e,t,n){let r=D_((n||{}).ignore||[]),i=Uv(t),a=-1;for(;++a<i.length;)I_(e,`text`,o);function o(e,t){let n=-1,i;for(;++n<t.length;){let e=t[n],a=i?i.children:void 0;if(r(e,a?a.indexOf(e):void 0,i))return;i=e}if(i)return s(e,t)}function s(e,t){let n=t[t.length-1],r=i[a][0],o=i[a][1],s=0,c=n.children.indexOf(e),l=!1,u=[];r.lastIndex=0;let d=r.exec(e.value);for(;d;){let n=d.index,i={index:d.index,input:d.input,stack:[...t,e]},a=o(...d,i);if(typeof a==`string`&&(a=a.length>0?{type:`text`,value:a}:void 0),a===!1?r.lastIndex=n+1:(s!==n&&u.push({type:`text`,value:e.value.slice(s,n)}),Array.isArray(a)?u.push(...a):a&&u.push(a),s=n+d[0].length,l=!0),!r.global)break;d=r.exec(e.value)}return l?(s<e.value.length&&u.push({type:`text`,value:e.value.slice(s)}),n.children.splice(c,1,...u)):u=[e],c+u.length}}function Uv(e){let t=[];if(!Array.isArray(e))throw TypeError(`Expected find and replace tuple or list of tuples`);let n=!e[0]||Array.isArray(e[0])?e:[e],r=-1;for(;++r<n.length;){let e=n[r];t.push([Wv(e[0]),Gv(e[1])])}return t}function Wv(e){return typeof e==`string`?new RegExp(Vv(e),`g`):e}function Gv(e){return typeof e==`function`?e:function(){return e}}var Kv=`phrasing`,qv=[`autolink`,`link`,`image`,`label`];function Jv(){return{transforms:[ny],enter:{literalAutolink:Xv,literalAutolinkEmail:Zv,literalAutolinkHttp:Zv,literalAutolinkWww:Zv},exit:{literalAutolink:ty,literalAutolinkEmail:ey,literalAutolinkHttp:Qv,literalAutolinkWww:$v}}}function Yv(){return{unsafe:[{character:`@`,before:`[+\\-.\\w]`,after:`[\\-.\\w]`,inConstruct:Kv,notInConstruct:qv},{character:`.`,before:`[Ww]`,after:`[\\-.\\w]`,inConstruct:Kv,notInConstruct:qv},{character:`:`,before:`[ps]`,after:`\\/`,inConstruct:Kv,notInConstruct:qv}]}}function Xv(e){this.enter({type:`link`,title:null,url:``,children:[]},e)}function Zv(e){this.config.enter.autolinkProtocol.call(this,e)}function Qv(e){this.config.exit.autolinkProtocol.call(this,e)}function $v(e){this.config.exit.data.call(this,e);let t=this.stack[this.stack.length-1];t.type,t.url=`http://`+this.sliceSerialize(e)}function ey(e){this.config.exit.autolinkEmail.call(this,e)}function ty(e){this.exit(e)}function ny(e){Hv(e,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,ry],[/(?<=^|\s|\p{P}|\p{S})([-.\w+]+)@([-\w]+(?:\.[-\w]+)+)/gu,iy]],{ignore:[`link`,`linkReference`]})}function ry(e,t,n,r,i){let a=``;if(!sy(i)||(/^w/i.test(t)&&(n=t+n,t=``,a=`http://`),!ay(n)))return!1;let o=oy(n+r);if(!o[0])return!1;let s={type:`link`,title:null,url:a+t+o[0],children:[{type:`text`,value:t+o[0]}]};return o[1]?[s,{type:`text`,value:o[1]}]:s}function iy(e,t,n,r){return!sy(r,!0)||/[-\d_]$/.test(n)?!1:{type:`link`,title:null,url:`mailto:`+t+`@`+n,children:[{type:`text`,value:t+`@`+n}]}}function ay(e){let t=e.split(`.`);return!(t.length<2||t[t.length-1]&&(/_/.test(t[t.length-1])||!/[a-zA-Z\d]/.test(t[t.length-1]))||t[t.length-2]&&(/_/.test(t[t.length-2])||!/[a-zA-Z\d]/.test(t[t.length-2])))}function oy(e){let t=/[!"&'),.:;<>?\]}]+$/.exec(e);if(!t)return[e,void 0];e=e.slice(0,t.index);let n=t[0],r=n.indexOf(`)`),i=Bv(e,`(`),a=Bv(e,`)`);for(;r!==-1&&i>a;)e+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(`)`),a++;return[e,n]}function sy(e,t){let n=e.input.charCodeAt(e.index-1);return(e.index===0||am(n)||im(n))&&(!t||n!==47)}_y.peek=gy;function cy(){this.buffer()}function ly(e){this.enter({type:`footnoteReference`,identifier:``,label:``},e)}function uy(){this.buffer()}function dy(e){this.enter({type:`footnoteDefinition`,identifier:``,label:``,children:[]},e)}function fy(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=qp(this.sliceSerialize(e)).toLowerCase(),n.label=t}function py(e){this.exit(e)}function my(e){let t=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=qp(this.sliceSerialize(e)).toLowerCase(),n.label=t}function hy(e){this.exit(e)}function gy(){return`[`}function _y(e,t,n,r){let i=n.createTracker(r),a=i.move(`[^`),o=n.enter(`footnoteReference`),s=n.enter(`reference`);return a+=i.move(n.safe(n.associationId(e),{after:`]`,before:a})),s(),o(),a+=i.move(`]`),a}function vy(){return{enter:{gfmFootnoteCallString:cy,gfmFootnoteCall:ly,gfmFootnoteDefinitionLabelString:uy,gfmFootnoteDefinition:dy},exit:{gfmFootnoteCallString:fy,gfmFootnoteCall:py,gfmFootnoteDefinitionLabelString:my,gfmFootnoteDefinition:hy}}}function yy(e){let t=!1;return e&&e.firstLineBlank&&(t=!0),{handlers:{footnoteDefinition:n,footnoteReference:_y},unsafe:[{character:`[`,inConstruct:[`label`,`phrasing`,`reference`]}]};function n(e,n,r,i){let a=r.createTracker(i),o=a.move(`[^`),s=r.enter(`footnoteDefinition`),c=r.enter(`label`);return o+=a.move(r.safe(r.associationId(e),{before:o,after:`]`})),c(),o+=a.move(`]:`),e.children&&e.children.length>0&&(a.shift(4),o+=a.move((t?`
100`:` `)+r.indentLines(r.containerFlow(e,a.current()),t?xy:by))),s(),o}}function by(e,t,n){return t===0?e:xy(e,t,n)}function xy(e,t,n){return(n?``:`    `)+e}var Sy=[`autolink`,`destinationLiteral`,`destinationRaw`,`reference`,`titleQuote`,`titleApostrophe`];Dy.peek=Oy;function Cy(){return{canContainEols:[`delete`],enter:{strikethrough:Ty},exit:{strikethrough:Ey}}}function wy(){return{unsafe:[{character:`~`,inConstruct:`phrasing`,notInConstruct:Sy}
vendor: 8,884 bytes, lines 100-112
100],handlers:{delete:Dy}}}function Ty(e){this.enter({type:`delete`,children:[]},e)}function Ey(e){this.exit(e)}function Dy(e,t,n,r){let i=n.createTracker(r),a=n.enter(`strikethrough`),o=i.move(`~~`);return o+=n.containerPhrasing(e,{...i.current(),before:o,after:`~`}),o+=i.move(`~~`),a(),o}function Oy(){return`~`}function ky(e){return e.length}function Ay(e,t){let n=t||{},r=(n.align||[]).concat(),i=n.stringLength||ky,a=[],o=[],s=[],c=[],l=0,u=-1;for(;++u<e.length;){let t=[],r=[],a=-1;for(e[u].length>l&&(l=e[u].length);++a<e[u].length;){let o=jy(e[u][a]);if(n.alignDelimiters!==!1){let e=i(o);r[a]=e,(c[a]===void 0||e>c[a])&&(c[a]=e)}t.push(o)}o[u]=t,s[u]=r}let d=-1;if(typeof r==`object`&&`length`in r)for(;++d<l;)a[d]=My(r[d]);else{let e=My(r);for(;++d<l;)a[d]=e}d=-1;let f=[],p=[];for(;++d<l;){let e=a[d],t=``,r=``;e===99?(t=`:`,r=`:`):e===108?t=`:`:e===114&&(r=`:`);let i=n.alignDelimiters===!1?1:Math.max(1,c[d]-t.length-r.length),o=t+`-`.repeat(i)+r;n.alignDelimiters!==!1&&(i=t.length+i+r.length,i>c[d]&&(c[d]=i),p[d]=i),f[d]=o}o.splice(1,0,f),s.splice(1,0,p),u=-1;let m=[];for(;++u<o.length;){let e=o[u],t=s[u];d=-1;let r=[];for(;++d<l;){let i=e[d]||``,o=``,s=``;if(n.alignDelimiters!==!1){let e=c[d]-(t[d]||0),n=a[d];n===114?o=` `.repeat(e):n===99?e%2?(o=` `.repeat(e/2+.5),s=` `.repeat(e/2-.5)):(o=` `.repeat(e/2),s=o):s=` `.repeat(e)}n.delimiterStart!==!1&&!d&&r.push(`|`),n.padding!==!1&&(n.alignDelimiters!==!1||i!==``)&&(n.delimiterStart!==!1||d)&&r.push(` `),n.alignDelimiters!==!1&&r.push(o),r.push(i),n.alignDelimiters!==!1&&r.push(s),n.padding!==!1&&r.push(` `),(n.delimiterEnd!==!1||d!==l-1)&&r.push(`|`)}m.push(n.delimiterEnd===!1?r.join(``).replace(/ +$/,``):r.join(``))}return m.join(`
101`)}function jy(e){return e==null?``:String(e)}function My(e){let t=typeof e==`string`?e.codePointAt(0):0;return t===67||t===99?99:t===76||t===108?108:t===82||t===114?114:0}function Ny(e,t,n,r){let i=n.enter(`blockquote`),a=n.createTracker(r);a.move(`> `),a.shift(2);let o=n.indentLines(n.containerFlow(e,a.current()),Py);return i(),o}function Py(e,t,n){return`>`+(n?``:` `)+e}function Fy(e,t){return Iy(e,t.inConstruct,!0)&&!Iy(e,t.notInConstruct,!1)}function Iy(e,t,n){if(typeof t==`string`&&(t=[t]),!t||t.length===0)return n;let r=-1;for(;++r<t.length;)if(e.includes(t[r]))return!0;return!1}function Ly(e,t,n,r){let i=-1;for(;++i<n.unsafe.length;)if(n.unsafe[i].character===`
102`&&Fy(n.stack,n.unsafe[i]))return/[ \t]/.test(r.before)?``:` `;return`\\
103`}function Ry(e,t){let n=String(e),r=n.indexOf(t),i=r,a=0,o=0;if(typeof t!=`string`)throw TypeError(`Expected substring`);for(;r!==-1;)r===i?++a>o&&(o=a):a=1,i=r+t.length,r=n.indexOf(t,i);return o}function zy(e,t){return!(t.options.fences!==!1||!e.value||e.lang||!/[^ \r\n]/.test(e.value)||/^[\t ]*(?:[\r\n]|$)|(?:^|[\r\n])[\t ]*$/.test(e.value))}function By(e){let t=e.options.fence||"`";if(t!=="`"&&t!==`~`)throw Error("Cannot serialize code with `"+t+"` for `options.fence`, expected `` ` `` or `~`");return t}function Vy(e,t,n,r){let i=By(n),a=e.value||``,o=i==="`"?`GraveAccent`:`Tilde`;if(zy(e,n)){let e=n.enter(`codeIndented`),t=n.indentLines(a,Hy);return e(),t}let s=n.createTracker(r),c=i.repeat(Math.max(Ry(a,i)+1,3)),l=n.enter(`codeFenced`),u=s.move(c);if(e.lang){let t=n.enter(`codeFencedLang${o}`);u+=s.move(n.safe(e.lang,{before:u,after:` `,encode:["`"],...s.current()})),t()}if(e.lang&&e.meta){let t=n.enter(`codeFencedMeta${o}`);u+=s.move(` `),u+=s.move(n.safe(e.meta,{before:u,after:`
104`,encode:["`"],...s.current()})),t()}return u+=s.move(`
105`),a&&(u+=s.move(a+`
106`)),u+=s.move(c),l(),u}function Hy(e,t,n){return(n?``:`    `)+e}function Uy(e){let t=e.options.quote||`"`;if(t!==`"`&&t!==`'`)throw Error("Cannot serialize title with `"+t+"` for `options.quote`, expected `\"`, or `'`");return t}function Wy(e,t,n,r){let i=Uy(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`definition`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`[`);return l+=c.move(n.safe(n.associationId(e),{before:l,after:`]`,...c.current()})),l+=c.move(`]: `),s(),!e.url||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`
107`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),o(),l}function Gy(e){let t=e.options.emphasis||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize emphasis with `"+t+"` for `options.emphasis`, expected `*`, or `_`");return t}function Ky(e){return`&#x`+e.toString(16).toUpperCase()+`;`}function qy(e,t,n){let r=hm(e),i=hm(t);return r===void 0?i===void 0?n===`_`?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!0}:r===1?i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!0}:{inside:!1,outside:!1}:i===void 0?{inside:!1,outside:!1}:i===1?{inside:!0,outside:!1}:{inside:!1,outside:!1}}Jy.peek=Yy;function Jy(e,t,n,r){let i=Gy(n),a=n.enter(`emphasis`),o=n.createTracker(r),s=o.move(i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=qy(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Ky(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=qy(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Ky(d));let p=o.move(i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Yy(e,t,n){return n.options.emphasis||`*`}function Xy(e,t){let n=!1;return R_(e,function(e){if(`value`in e&&/\r?\n|\r/.test(e.value)||e.type===`break`)return n=!0,!1}),!!((!e.depth||e.depth<3)&&Pp(e)&&(t.options.setext||n))}function Zy(e,t,n,r){let i=Math.max(Math.min(6,e.depth||1),1),a=n.createTracker(r);if(Xy(e,n)){let t=n.enter(`headingSetext`),r=n.enter(`phrasing`),o=n.containerPhrasing(e,{...a.current(),before:`
108`,after:`
109`});return r(),t(),o+`
110`+(i===1?`=`:`-`).repeat(o.length-(Math.max(o.lastIndexOf(`\r`),o.lastIndexOf(`
111`))+1))}let o=`#`.repeat(i),s=n.enter(`headingAtx`),c=n.enter(`phrasing`);a.move(o+` `);let l=n.containerPhrasing(e,{before:`# `,after:`
112`,...a.current()});return/^[\t ]/.test(l)&&(l=Ky(l.charCodeAt(0))+l.slice(1)),l=l?o+` `+l:o,n.options.closeAtx&&(l+=` `+o),c(),s(),l}Qy.peek=$y;function Qy(e){return e.value||``}function $y(){return`<`}eb.peek=tb;function eb(e,t,n,r){let i=Uy(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.enter(`image`),s=n.enter(`label`),c=n.createTracker(r),l=c.move(`![`);return l+=c.move(n.safe(e.alt,{before:l,after:`]`,...c.current()})),l+=c.move(`](`),s(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(s=n.enter(`destinationLiteral`),l+=c.move(`<`),l+=c.move(n.safe(e.url,{before:l,after:`>`,...c.current()})),l+=c.move(`>`)):(s=n.enter(`destinationRaw`),l+=c.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...c.current()}))),s(),e.title&&(s=n.enter(`title${a}`),l+=c.move(` `+i),l+=c.move(n.safe(e.title,{before:l,after:i,...c.current()})),l+=c.move(i),s()),l+=c.move(`)`),o(),l}function tb(){return`!`}nb.peek=rb;function nb(e,t,n,r){let i=e.referenceType,a=n.enter(`imageReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`![`),l=n.safe(e.alt,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function rb(){return`!`}ib.peek=ab;function ib(e,t,n){let r=e.value||``,i="`",a=-1;for(;RegExp("(^|[^`])"+i+"([^`]|$)").test(r);)i+="`";for(/[^ \r\n]/.test(r)&&(/^[ \r\n]/.test(r)&&/[ \r\n]$/.test(r)||/^`|`$/.test(r))&&(r=` `+r+` `);++a<n.unsafe.length;){let e=n.unsafe[a],t=n.compilePattern(e),i;if(e.atBreak)for(;i=t.exec(r);){let e=i.index;r.charCodeAt(e)===10&&r.charCodeAt(e-1)===13&&e--,r=r.slice(0,e)+` `+r.slice(i.index+1)}}return i+r+i}function ab(){return"`"}function ob(e,t){let n=Pp(e);return!(t.options.resourceLink||!e.url||e.title||!e.children||e.children.length!==1||e.children[0].type!==`text`||n!==e.url&&`mailto:`+n!==e.url||!/^[a-z][a-z+.-]+:/i.test(e.url)||/[\0- <>\u007F]/.test(e.url))}sb.peek=cb;function sb(e,t,n,r){let i=Uy(n),a=i===`"`?`Quote`:`Apostrophe`,o=n.createTracker(r),s,c;if(ob(e,n)){let t=n.stack;n.stack=[],s=n.enter(`autolink`);let r=o.move(`<`);return r+=o.move(n.containerPhrasing(e,{before:r,after:`>`,...o.current()})),r+=o.move(`>`),s(),n.stack=t,r}s=n.enter(`link`),c=n.enter(`label`);let l=o.move(`[`);return l+=o.move(n.containerPhrasing(e,{before:l,after:`](`,...o.current()})),l+=o.move(`](`),c(),!e.url&&e.title||/[\0- \u007F]/.test(e.url)?(c=n.enter(`destinationLiteral`),l+=o.move(`<`),l+=o.move(n.safe(e.url,{before:l,after:`>`,...o.current()})),l+=o.move(`>`)):(c=n.enter(`destinationRaw`),l+=o.move(n.safe(e.url,{before:l,after:e.title?` `:`)`,...o.current()}
vendor: 24,174 bytes, lines 112-114
112))),c(),e.title&&(c=n.enter(`title${a}`),l+=o.move(` `+i),l+=o.move(n.safe(e.title,{before:l,after:i,...o.current()})),l+=o.move(i),c()),l+=o.move(`)`),s(),l}function cb(e,t,n){return ob(e,n)?`<`:`[`}lb.peek=ub;function lb(e,t,n,r){let i=e.referenceType,a=n.enter(`linkReference`),o=n.enter(`label`),s=n.createTracker(r),c=s.move(`[`),l=n.containerPhrasing(e,{before:c,after:`]`,...s.current()});c+=s.move(l+`][`),o();let u=n.stack;n.stack=[],o=n.enter(`reference`);let d=n.safe(n.associationId(e),{before:c,after:`]`,...s.current()});return o(),n.stack=u,a(),i===`full`||!l||l!==d?c+=s.move(d+`]`):i===`shortcut`?c=c.slice(0,-1):c+=s.move(`]`),c}function ub(){return`[`}function db(e){let t=e.options.bullet||`*`;if(t!==`*`&&t!==`+`&&t!==`-`)throw Error("Cannot serialize items with `"+t+"` for `options.bullet`, expected `*`, `+`, or `-`");return t}function fb(e){let t=db(e),n=e.options.bulletOther;if(!n)return t===`*`?`-`:`*`;if(n!==`*`&&n!==`+`&&n!==`-`)throw Error("Cannot serialize items with `"+n+"` for `options.bulletOther`, expected `*`, `+`, or `-`");if(n===t)throw Error("Expected `bullet` (`"+t+"`) and `bulletOther` (`"+n+"`) to be different");return n}function pb(e){let t=e.options.bulletOrdered||`.`;if(t!==`.`&&t!==`)`)throw Error("Cannot serialize items with `"+t+"` for `options.bulletOrdered`, expected `.` or `)`");return t}function mb(e){let t=e.options.rule||`*`;if(t!==`*`&&t!==`-`&&t!==`_`)throw Error("Cannot serialize rules with `"+t+"` for `options.rule`, expected `*`, `-`, or `_`");return t}function hb(e,t,n,r){let i=n.enter(`list`),a=n.bulletCurrent,o=e.ordered?pb(n):db(n),s=e.ordered?o===`.`?`)`:`.`:fb(n),c=t&&n.bulletLastUsed?o===n.bulletLastUsed:!1;if(!e.ordered){let t=e.children?e.children[0]:void 0;if((o===`*`||o===`-`)&&t&&(!t.children||!t.children[0])&&n.stack[n.stack.length-1]===`list`&&n.stack[n.stack.length-2]===`listItem`&&n.stack[n.stack.length-3]===`list`&&n.stack[n.stack.length-4]===`listItem`&&n.indexStack[n.indexStack.length-1]===0&&n.indexStack[n.indexStack.length-2]===0&&n.indexStack[n.indexStack.length-3]===0&&(c=!0),mb(n)===o&&t){let t=-1;for(;++t<e.children.length;){let n=e.children[t];if(n&&n.type===`listItem`&&n.children&&n.children[0]&&n.children[0].type===`thematicBreak`){c=!0;break}}}}c&&(o=s),n.bulletCurrent=o;let l=n.containerFlow(e,r);return n.bulletLastUsed=o,n.bulletCurrent=a,i(),l}function gb(e){let t=e.options.listItemIndent||`one`;if(t!==`tab`&&t!==`one`&&t!==`mixed`)throw Error("Cannot serialize items with `"+t+"` for `options.listItemIndent`, expected `tab`, `one`, or `mixed`");return t}function _b(e,t,n,r){let i=gb(n),a=n.bulletCurrent||db(n);t&&t.type===`list`&&t.ordered&&(a=(typeof t.start==`number`&&t.start>-1?t.start:1)+(n.options.incrementListMarker===!1?0:t.children.indexOf(e))+a);let o=a.length+1;(i===`tab`||i===`mixed`&&(t&&t.type===`list`&&t.spread||e.spread))&&(o=Math.ceil(o/4)*4);let s=n.createTracker(r);s.move(a+` `.repeat(o-a.length)),s.shift(o);let c=n.enter(`listItem`),l=n.indentLines(n.containerFlow(e,s.current()),u);return c(),l;function u(e,t,n){return t?(n?``:` `.repeat(o))+e:(n?a:a+` `.repeat(o-a.length))+e}}function vb(e,t,n,r){let i=n.enter(`paragraph`),a=n.enter(`phrasing`),o=n.containerPhrasing(e,r);return a(),i(),o}var yb=D_([`break`,`delete`,`emphasis`,`footnote`,`footnoteReference`,`image`,`imageReference`,`inlineCode`,`inlineMath`,`link`,`linkReference`,`mdxJsxTextElement`,`mdxTextExpression`,`strong`,`text`,`textDirective`]);function bb(e,t,n,r){return(e.children.some(function(e){return yb(e)})?n.containerPhrasing:n.containerFlow).call(n,e,r)}function xb(e){let t=e.options.strong||`*`;if(t!==`*`&&t!==`_`)throw Error("Cannot serialize strong with `"+t+"` for `options.strong`, expected `*`, or `_`");return t}Sb.peek=Cb;function Sb(e,t,n,r){let i=xb(n),a=n.enter(`strong`),o=n.createTracker(r),s=o.move(i+i),c=o.move(n.containerPhrasing(e,{after:i,before:s,...o.current()})),l=c.charCodeAt(0),u=qy(r.before.charCodeAt(r.before.length-1),l,i);u.inside&&(c=Ky(l)+c.slice(1));let d=c.charCodeAt(c.length-1),f=qy(r.after.charCodeAt(0),d,i);f.inside&&(c=c.slice(0,-1)+Ky(d));let p=o.move(i+i);return a(),n.attentionEncodeSurroundingInfo={after:f.outside,before:u.outside},s+c+p}function Cb(e,t,n){return n.options.strong||`*`}function wb(e,t,n,r){return n.safe(e.value,r)}function Tb(e){let t=e.options.ruleRepetition||3;if(t<3)throw Error("Cannot serialize rules with repetition `"+t+"` for `options.ruleRepetition`, expected `3` or more");return t}function Eb(e,t,n){let r=(mb(n)+(n.options.ruleSpaces?` `:``)).repeat(Tb(n));return n.options.ruleSpaces?r.slice(0,-1):r}var Db={blockquote:Ny,break:Ly,code:Vy,definition:Wy,emphasis:Jy,hardBreak:Ly,heading:Zy,html:Qy,image:eb,imageReference:nb,inlineCode:ib,link:sb,linkReference:lb,list:hb,listItem:_b,paragraph:vb,root:bb,strong:Sb,text:wb,thematicBreak:Eb};function Ob(){return{enter:{table:kb,tableData:Nb,tableHeader:Nb,tableRow:jb},exit:{codeText:Pb,table:Ab,tableData:Mb,tableHeader:Mb,tableRow:Mb}}}function kb(e){let t=e._align;this.enter({type:`table`,align:t.map(function(e){return e===`none`?null:e}),children:[]},e),this.data.inTable=!0}function Ab(e){this.exit(e),this.data.inTable=void 0}function jb(e){this.enter({type:`tableRow`,children:[]},e)}function Mb(e){this.exit(e)}function Nb(e){this.enter({type:`tableCell`,children:[]},e)}function Pb(e){let t=this.resume();this.data.inTable&&(t=t.replace(/\\([\\|])/g,Fb));let n=this.stack[this.stack.length-1];n.type,n.value=t,this.exit(e)}function Fb(e,t){return t===`|`?t:e}function Ib(e){let t=e||{},n=t.tableCellPadding,r=t.tablePipeAlign,i=t.stringLength,a=n?` `:`|`;return{unsafe:[{character:`\r`,inConstruct:`tableCell`},{character:`
113`,inConstruct:`tableCell`},{atBreak:!0,character:`|`,after:`[	 :-]`},{character:`|`,inConstruct:`tableCell`},{atBreak:!0,character:`:`,after:`-`},{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{inlineCode:f,table:o,tableCell:c,tableRow:s}};function o(e,t,n,r){return l(u(e,n,r),e.align)}function s(e,t,n,r){let i=l([d(e,n,r)]);return i.slice(0,i.indexOf(`
114`))}function c(e,t,n,r){let i=n.enter(`tableCell`),o=n.enter(`phrasing`),s=n.containerPhrasing(e,{...r,before:a,after:a});return o(),i(),s}function l(e,t){return Ay(e,{align:t,alignDelimiters:r,padding:n,stringLength:i})}function u(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`table`);for(;++i<r.length;)a[i]=d(r[i],t,n);return o(),a}function d(e,t,n){let r=e.children,i=-1,a=[],o=t.enter(`tableRow`);for(;++i<r.length;)a[i]=c(r[i],e,t,n);return o(),a}function f(e,t,n){let r=Db.inlineCode(e,t,n);return n.stack.includes(`tableCell`)&&(r=r.replace(/\|/g,`\\$&`)),r}}function Lb(){return{exit:{taskListCheckValueChecked:zb,taskListCheckValueUnchecked:zb,paragraph:Bb}}}function Rb(){return{unsafe:[{atBreak:!0,character:`-`,after:`[:|-]`}],handlers:{listItem:Vb}}}function zb(e){let t=this.stack[this.stack.length-2];t.type,t.checked=e.type===`taskListCheckValueChecked`}function Bb(e){let t=this.stack[this.stack.length-2];if(t&&t.type===`listItem`&&typeof t.checked==`boolean`){let e=this.stack[this.stack.length-1];e.type;let n=e.children[0];if(n&&n.type===`text`){let r=t.children,i=-1,a;for(;++i<r.length;){let e=r[i];if(e.type===`paragraph`){a=e;break}}a===e&&(n.value=n.value.slice(1),n.value.length===0?e.children.shift():e.position&&n.position&&typeof n.position.start.offset==`number`&&(n.position.start.column++,n.position.start.offset++,e.position.start=Object.assign({},n.position.start)))}}this.exit(e)}function Vb(e,t,n,r){let i=e.children[0],a=typeof e.checked==`boolean`&&i&&i.type===`paragraph`,o=`[`+(e.checked?`x`:` `)+`] `,s=n.createTracker(r);a&&s.move(o);let c=Db.listItem(e,t,n,{...r,...s.current()});return a&&(c=c.replace(/^(?:[*+-]|\d+\.)([\r\n]| {1,3})/,l)),c;function l(e){return e+o}}function Hb(){return[Jv(),vy(),Cy(),Ob(),Lb()]}function Ub(e){return{extensions:[Yv(),yy(e),wy(),Ib(e),Rb()]}}var Wb={tokenize:ix,partial:!0},Gb={tokenize:ax,partial:!0},Kb={tokenize:ox,partial:!0},qb={tokenize:sx,partial:!0},Jb={tokenize:cx,partial:!0},Yb={name:`wwwAutolink`,tokenize:nx,previous:lx},Xb={name:`protocolAutolink`,tokenize:rx,previous:ux},Zb={name:`emailAutolink`,tokenize:tx,previous:dx},Qb={};function $b(){return{text:Qb}}for(var ex=48;ex<123;)Qb[ex]=Zb,ex++,ex===58?ex=65:ex===91&&(ex=97);Qb[43]=Zb,Qb[45]=Zb,Qb[46]=Zb,Qb[95]=Zb,Qb[72]=[Zb,Xb],Qb[104]=[Zb,Xb],Qb[87]=[Zb,Yb],Qb[119]=[Zb,Yb];function tx(e,t,n){let r=this,i,a;return o;function o(t){return!fx(t)||!dx.call(r,r.previous)||px(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkEmail`),s(t))}function s(t){return fx(t)?(e.consume(t),s):t===64?(e.consume(t),c):n(t)}function c(t){return t===46?e.check(Jb,u,l)(t):t===45||t===95||Yp(t)?(a=!0,e.consume(t),c):u(t)}function l(t){return e.consume(t),i=!0,c}function u(o){return a&&i&&Jp(r.previous)?(e.exit(`literalAutolinkEmail`),e.exit(`literalAutolink`),t(o)):n(o)}}function nx(e,t,n){let r=this;return i;function i(t){return t!==87&&t!==119||!lx.call(r,r.previous)||px(r.events)?n(t):(e.enter(`literalAutolink`),e.enter(`literalAutolinkWww`),e.check(Wb,e.attempt(Gb,e.attempt(Kb,a),n),n)(t))}function a(n){return e.exit(`literalAutolinkWww`),e.exit(`literalAutolink`),t(n)}}function rx(e,t,n){let r=this,i=``,a=!1;return o;function o(t){return(t===72||t===104)&&ux.call(r,r.previous)&&!px(r.events)?(e.enter(`literalAutolink`),e.enter(`literalAutolinkHttp`),i+=String.fromCodePoint(t),e.consume(t),s):n(t)}function s(t){if(Jp(t)&&i.length<5)return i+=String.fromCodePoint(t),e.consume(t),s;if(t===58){let n=i.toLowerCase();if(n===`http`||n===`https`)return e.consume(t),c}return n(t)}function c(t){return t===47?(e.consume(t),a?l:(a=!0,c)):n(t)}function l(t){return t===null||Zp(t)||nm(t)||am(t)||im(t)?n(t):e.attempt(Gb,e.attempt(Kb,u),n)(t)}function u(n){return e.exit(`literalAutolinkHttp`),e.exit(`literalAutolink`),t(n)}}function ix(e,t,n){let r=0;return i;function i(t){return(t===87||t===119)&&r<3?(r++,e.consume(t),i):t===46&&r===3?(e.consume(t),a):n(t)}function a(e){return e===null?n(e):t(e)}}function ax(e,t,n){let r,i,a;return o;function o(t){return t===46||t===95?e.check(qb,c,s)(t):t===null||nm(t)||am(t)||t!==45&&im(t)?c(t):(a=!0,e.consume(t),o)}function s(t){return t===95?r=!0:(i=r,r=void 0),e.consume(t),o}function c(e){return i||r||!a?n(e):t(e)}}function ox(e,t){let n=0,r=0;return i;function i(o){return o===40?(n++,e.consume(o),i):o===41&&r<n?a(o):o===33||o===34||o===38||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===60||o===63||o===93||o===95||o===126?e.check(qb,t,a)(o):o===null||nm(o)||am(o)?t(o):(e.consume(o),i)}function a(t){return t===41&&r++,e.consume(t),i}}function sx(e,t,n){return r;function r(o){return o===33||o===34||o===39||o===41||o===42||o===44||o===46||o===58||o===59||o===63||o===95||o===126?(e.consume(o),r):o===38?(e.consume(o),a):o===93?(e.consume(o),i):o===60||o===null||nm(o)||am(o)?t(o):n(o)}function i(e){return e===null||e===40||e===91||nm(e)||am(e)?t(e):r(e)}function a(e){return Jp(e)?o(e):n(e)}function o(t){return t===59?(e.consume(t),r):Jp(t)?(e.consume(t),o):n(t)}}function cx(e,t,n){return r;function r(t){return e.consume(t),i}function i(e){return Yp(e)?n(e):t(e)}}function lx(e){return e===null||e===40||e===42||e===95||e===91||e===93||e===126||nm(e)}function ux(e){return!Jp(e)}function dx(e){return!(e===47||fx(e))}function fx(e){return e===43||e===45||e===46||e===95||Yp(e)}function px(e){let t=e.length,n=!1;for(;t--;){let r=e[t][1];if((r.type===`labelLink`||r.type===`labelImage`)&&!r._balanced){n=!0;break}if(r._gfmAutolinkLiteralWalkedInto){n=!1;break}}return e.length>0&&!n&&(e[e.length-1][1]._gfmAutolinkLiteralWalkedInto=!0),n}var mx={tokenize:Sx,partial:!0};function hx(){return{document:{91:{name:`gfmFootnoteDefinition`,tokenize:yx,continuation:{tokenize:bx},exit:xx}},text:{91:{name:`gfmFootnoteCall`,tokenize:vx},93:{name:`gfmPotentialFootnoteCall`,add:`after`,tokenize:gx,resolveTo:_x}}}}function gx(e,t,n){let r=this,i=r.events.length,a=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),o;for(;i--;){let e=r.events[i][1];if(e.type===`labelImage`){o=e;break}if(e.type===`gfmFootnoteCall`||e.type===`labelLink`||e.type===`label`||e.type===`image`||e.type===`link`)break}return s;function s(i){if(!o||!o._balanced)return n(i);let s=qp(r.sliceSerialize({start:o.end,end:r.now()}));return s.codePointAt(0)!==94||!a.includes(s.slice(1))?n(i):(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(i),e.exit(`gfmFootnoteCallLabelMarker`),t(i))}}function _x(e,t){let n=e.length;for(;n--;)if(e[n][1].type===`labelImage`&&e[n][0]===`enter`){e[n][1];break}e[n+1][1].type=`data`,e[n+3][1].type=`gfmFootnoteCallLabelMarker`;let r={type:`gfmFootnoteCall`,start:Object.assign({},e[n+3][1].start),end:Object.assign({},e[e.length-1][1].end)},i={type:`gfmFootnoteCallMarker`,start:Object.assign({},e[n+3][1].end),end:Object.assign({},e[n+3][1].end)};i.end.column++,i.end.offset++,i.end._bufferIndex++;let a={type:`gfmFootnoteCallString`,start:Object.assign({},i.end),end:Object.assign({},e[e.length-1][1].start)},o={type:`chunkString`,contentType:`string`,start:Object.assign({},a.start),end:Object.assign({},a.end)},s=[e[n+1],e[n+2],[`enter`,r,t],e[n+3],e[n+4],[`enter`,i,t],[`exit`,i,t],[`enter`,a,t],[`enter`,o,t],[`exit`,o,t],[`exit`,a,t],e[e.length-2],e[e.length-1],[`exit`,r,t]];return e.splice(n,e.length-n+1,...s),e}function vx(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a=0,o;return s;function s(t){return e.enter(`gfmFootnoteCall`),e.enter(`gfmFootnoteCallLabelMarker`),e.consume(t),e.exit(`gfmFootnoteCallLabelMarker`),c}function c(t){return t===94?(e.enter(`gfmFootnoteCallMarker`),e.consume(t),e.exit(`gfmFootnoteCallMarker`),e.enter(`gfmFootnoteCallString`),e.enter(`chunkString`).contentType=`string`,l):n(t)}function l(s){if(a>999||s===93&&!o||s===null||s===91||nm(s))return n(s);if(s===93){e.exit(`chunkString`);let a=e.exit(`gfmFootnoteCallString`);return i.includes(qp(r.sliceSerialize(a)))?(e.enter(`gfmFootnoteCallLabelMarker`),e.consume(s),e.exit(`gfmFootnoteCallLabelMarker`),e.exit(`gfmFootnoteCall`),t):n(s)}return nm(s)||(o=!0),a++,e.consume(s),s===92?u:l}function u(t){return t===91||t===92||t===93?(e.consume(t),a++,l):l(t)}}function yx(e,t,n){let r=this,i=r.parser.gfmFootnotes||(r.parser.gfmFootnotes=[]),a,o=0,s;return c;function c(t){return e.enter(`gfmFootnoteDefinition`)._container=!0,e.enter(`gfmFootnoteDefinitionLabel`),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),l}function l(t){return t===94?(e.enter(`gfmFootnoteDefinitionMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionMarker`),e.enter(`gfmFootnoteDefinitionLabelString`),e.enter(`chunkString`).contentType=`string`,u):n(t)}function u(t){if(o>999||t===93&&!s||t===null||t===91||nm(t))return n(t);if(t===93){e.exit(`chunkString`);let n=e.exit(`gfmFootnoteDefinitionLabelString`);return a=qp(r.sliceSerialize(n)),e.enter(`gfmFootnoteDefinitionLabelMarker`),e.consume(t),e.exit(`gfmFootnoteDefinitionLabelMarker`),e.exit(`gfmFootnoteDefinitionLabel`),f}return nm(t)||(s=!0),o++,e.consume(t),t===92?d:u}function d(t){return t===91||t===92||t===93?(e.consume(t),o++,u):u(t)}function f(t){return t===58?(e.enter(`definitionMarker`),e.consume(t),e.exit(`definitionMarker`),i.includes(a)||i.push(a),cm(e,p,`gfmFootnoteDefinitionWhitespace`)):n(t)}function p(e){return t(e)}}function bx(e,t,n){return e.check(Cm,t,e.attempt(mx,t,n))}function xx(e){e.exit(`gfmFootnoteDefinition`)}function Sx(e,t,n){let r=this;return cm(e,i,`gfmFootnoteDefinitionIndent`,5);function i(e){let i=r.events[r.events.length-1];return i&&i[1].type===`gfmFootnoteDefinitionIndent`&&i[2].sliceSerialize(i[1],!0).length===4?t(e):n(e)}}function Cx(e){let t=(e||{}).singleTilde,n={name:`strikethrough`,tokenize:i,resolveAll:r};return t??=!0,{text:{126:n},insideSpan:{null:[n]},attentionMarkers:{null:[126]}};function r(e,t){let n=-1;for(;++n<e.length;)if(e[n][0]===`enter`&&e[n][1].type===`strikethroughSequenceTemporary`&&e[n][1]._close){let r=n;for(;r--;)if(e[r][0]===`exit`&&e[r][1].type===`strikethroughSequenceTemporary`&&e[r][1]._open&&e[n][1].end.offset-e[n][1].start.offset===e[r][1].end.offset-e[r][1].start.offset){e[n][1].type=`strikethroughSequence`,e[r][1].type=`strikethroughSequence`;let i={type:`strikethrough`,start:Object.assign({},e[r][1].start),end:Object.assign({},e[n][1].end)},a={type:`strikethroughText`,start:Object.assign({},e[r][1].end),end:Object.assign({},e[n][1].start)},o=[[`enter`,i,t],[`enter`,e[r][1],t],[`exit`,e[r][1],t],[`enter`,a,t]],s=t.parser.constructs.insideSpan.null;s&&Bp(o,o.length,0,gm(s,e.slice(r+1,n),t)),Bp(o,o.length,0,[[`exit`,a,t],[`enter`,e[n][1],t],[`exit`,e[n][1],t],[`exit`,i,t]]),Bp(e,r-1,n-r+3,o),n=r+o.length-2;break}}for(n=-1;++n<e.length;)e[n][1].type===`strikethroughSequenceTemporary`&&(e[n][1].type=`data`);return e}function i(e,n,r){let i=this.previous,a=this.events,o=0;return s;function s(t){return i===126&&a[a.length-1][1].type!==`characterEscape`?r(t):(e.enter(`strikethroughSequenceTemporary`),c(t))}function c(a){let s=hm(i);if(a===126)return o>1?r(a):(e.consume(a),o++,c);if(o<2&&!t)return r(a);let l=e.exit(`strikethroughSequenceTemporary`),u=hm(a);return l._open=!u||u===2&&!!s,l._close=!s||s===2&&!!u,n(a)}}}var wx=class{constructor(){this.map=[]}add(e,t,n){Tx(this,e,t,n)}consume(e){if(this.map.sort(function(e,t){return e[0]-t[0]}),this.map.length===0)return;let t=this.map.length,n=[];for(;t>0;)--t,n.push(e.slice(this.map[t][0]+this.map[t][1]),this.map[t][2]),e.length=this.map[t][0];n.push(e.slice()),e.length=0;let r=n.pop();for(;r;){for(let t of r)e.push(t);r=n.pop()}this.map.length=0}};function Tx(e,t,n,r){let i=0;if(n!==0||r.length!==0){for(;i<e.map.length;){if(e.map[i][0]===t){e.map[i][1]+=n,e.map[i][2].push(...r);return}i+=1}e.map.push([t,n,r])}}function Ex(e,t){let n=!1,r=[];for(;t<e.length;){let i=e[t];if(n){if(i[0]===`enter`)i[1].type===`tableContent`&&r.push(e[t+1][1].type===`tableDelimiterMarker`?`left`:`none`);else if(i[1].type===`tableContent`){if(e[t-1][1].type===`tableDelimiterMarker`){let e=r.length-1;r[e]=r[e]===`left`?`center`:`right`}}else if(i[1].type===`tableDelimiterRow`)break}else i[0]===`enter`&&i[1].type===`tableDelimiterRow`&&(n=!0);t+=1}return r}function Dx(){return{flow:{null:{name:`table`,tokenize:Ox,resolveAll:kx}}}}function Ox(e,t,n){let r=this,i=0,a=0,o;return s;function s(e){let t=r.events.length-1;for(;t>-1;){let e=r.events[t][1].type;if(e===`lineEnding`||e===`linePrefix`)t--;else break}let i=t>-1?r.events[t][1].type:null,a=i===`tableHead`||i===`tableRow`?S:c;return a===S&&r.parser.lazy[r.now().line]?n(e):a(e)}function c(t){return e.enter(`tableHead`),e.enter(`tableRow`),l(t)}function l(e){return e===124?u(e):(o=!0,a+=1,u(e))}function u(t){return t===null?n(t):tm(t)?a>1?(a=0,r.interrupt=!0,e.exit(`tableRow`),e.enter(`lineEnding`),e.consume(t),e.exit(`lineEnding`),p):n(t):rm(t)?cm(e,u,`whitespace`)(t):(a+=1,o&&(o=!1,i+=1),t===124?(e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),o=!0,u):(e.enter(`data`),d(t)))}function d(t){return t===null||t===124||nm(t)?(e.exit(`data`),u(t)):(e.consume(t),t===92?f:d)}function f(t){return t===92||t===124?(e.consume(t),d):d(t)}function p(t){return r.interrupt=!1,r.parser.lazy[r.now().line]?n(t):(e.enter(`tableDelimiterRow`),o=!1,rm(t)?cm(e,m,`linePrefix`,r.parser.constructs.disable.null.includes(`codeIndented`)?void 0:4)(t):m(t))}function m(t){return t===45||t===58?g(t):t===124?(o=!0,e.enter(`tableCellDivider`),e.consume(t),e.exit(`tableCellDivider`),h):x(t)}function h(t){return rm(t)?cm(e,g,`whitespace`)(t):g(t)}function g(t){return t===58?(a+=1,o=!0,e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),_):t===45?(a+=1,_(t)):t===null||tm(t)?b(t):x(t)}function _(t){return t===45?(e.enter(`tableDelimiterFiller`),v(t)):x(t)}function v(t){return t===45?(e.consume(t),v):t===58?(o=!0,e.exit(`tableDelimiterFiller`),e.enter(`tableDelimiterMarker`),e.consume(t),e.exit(`tableDelimiterMarker`),y):(e.exit(`tableDelimiterFiller`),y(t))}function y(t){return rm(t)?cm(e,b,`whitespace`)(t):b(t)}function b(n){return n===124?m(n):n===null||tm(n)?!o||i!==a?x(n):(e.exit(`tableDelimiterRow`),e.exit(`tableHead`),t(n)):x(n)}function x(e){return n(e)}function S(t){return e.enter(`tableRow`),C(t)}function C(n){return n===124?(e.enter(`tableCellDivider`),e.consume(n),e.exit(`tableCellDivider`),C):n===null||tm(n)?(e.exit(`tableRow`),t(n)):rm(n)?cm(e,C,`whitespace`)(n):(e.enter(`data`),w(n))}function w(t){return t===null||t===124||nm(t)?(e.exit(`data`),C(t)):(e.consume(t),t===92?T:w)}function T(t){return t===92||t===124?(e.consume(t),w):w(t)}}function kx(e,t){let n=-1,r=!0,i=0,a=[0,0,0,0],o=[0,0,0,0],s=!1,c=0,l,u,d,f=new wx;for(;++n<e.length;){let p=e[n],m=p[1];p[0]===`enter`?m.type===`tableHead`?(s=!1,c!==0&&(jx(f,t,c,l,u),u=void 0,c=0),l={type:`table`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,l,t]])):m.type===`tableRow`||m.type===`tableDelimiterRow`?(r=!0,d=void 0,a=[0,0,0,0],o=[0,n+1,0,0],s&&(s=!1,u={type:`tableBody`,start:Object.assign({},m.start),end:Object.assign({},m.end)},f.add(n,0,[[`enter`,u,t]])),i=m.type===`tableDelimiterRow`?2:u?3:1):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)?(r=!1,o[2]===0&&(a[1]!==0&&(o[0]=o[1],d=Ax(f,t,a,i,void 0,d),a=[0,0,0,0]),o[2]=n)):m.type===`tableCellDivider`&&(r?r=!1:(a[1]!==0&&(o[0]=o[1],d=Ax(f,t,a,i,void 0,d)),a=o,o=[a[1],n,0,0])):m.type===`tableHead`?(s=!0,c=n):m.type===`tableRow`||m.type===`tableDelimiterRow`?(c=n,a[1]===0?o[1]!==0&&(d=Ax(f,t,o,i,n,d)):(o[0]=o[1],d=Ax(f,t,a,i,n,d)),i=0):i&&(m.type===`data`||m.type===`tableDelimiterMarker`||m.type===`tableDelimiterFiller`)&&(o[3]=n)}for(c!==0&&jx(f,t,c,l,u),f.consume(t.events),n=-1;++n<t.events.length;){let e=t.events[n];e[0]===`enter`&&e[1].type===`table`&&(e[1]._align=Ex(t.events,n))}return e}function Ax(e,t,n,r,i,a){let o=r===1?`tableHeader`:r===2?`tableDelimiter`:`tableData`;n[0]!==0&&(a.end=Object.assign({},Mx(t.events,n[0])),e.add(n[0],0,[[`exit`,a,t]]));let s=Mx(t.events,n[1]);if(a={type:o,start:Object.assign({},s),end:Object.assign({},s)},e.add(n[1],0,[[`enter`,a,t]]),n[2]!==0){let i=Mx(t.events,n[2]),a=Mx(t.events,n[3]),o={type:`tableContent`,start:Object.assign({},i),end:Object.assign({},a)};if(e.add(n[2],0,[[`enter`,o,t]]),r!==2){let r=t.events[n[2]],i=t.events[n[3]];if(r[1].end=Object.assign({},i[1].end),r[1].type=`chunkText`,r[1].contentType=`text`,n[3]>n[2]+1){let t=n[2]+1,r=n[3]-n[2]-1;e.add(t,r,[])}}e.add(n[3]+1,0,[[`exit`,o,t]])}return i!==void 0&&(a.end=Object.assign({},Mx(t.events,i)),e.add(i,0,[[`exit`,a,t]]),a=void 0),a}function jx(e,t,n,r,i){let a=[],o=Mx(t.events,n);i&&(i.end=Object.assign({},o),a.push([`exit`,i,t])),r.end=Object.assign({},o),a.push([`exit`,r,t]),e.add(n+1,0,a)}function Mx(e,t){let n=e[t],r=n[0]===`enter`?`start`:`end`;return n[1][r]}var Nx={name:`tasklistCheck`,tokenize:Fx};function Px(){return{text:{91:Nx}}}function Fx(e,t,n){let r=this;return i;function i(t){return r.previous!==null||!r._gfmTasklistFirstContentOfListItem?n(t):(e.enter(`taskListCheck`),e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),a)}function a(t){return nm(t)?(e.enter(`taskListCheckValueUnchecked`),e.consume(t),e.exit(`taskListCheckValueUnchecked`),o):t===88||t===120?(e.enter(`taskListCheckValueChecked`),e.consume(t),e.exit(`taskListCheckValueChecked`),o):n(t)}function o(t){return t===93?(e.enter(`taskListCheckMarker`),e.consume(t),e.exit(`taskListCheckMarker`),e.exit(`taskListCheck`),s):n(t)}function s(r){return tm(r)?t(r):rm(r)?e.check({tokenize:Ix},t,n)(r):n(r)}}function Ix(e,t,n){return cm(e,r,`whitespace`);function r(e){return e===null?n(e):t(e)}}function Lx(e){return Up([$b(),hx(),Cx(e),Dx(),Px()])}var Rx={};function zx(e){let t=this,n=e||Rx,r=t.data(),i=r.micromarkExtensions||=[],a=r.fromMarkdownExtensions||=[],o=r.toMarkdownExtensions||=[];i.push(Lx(n)),a.push(Hb()),o.push(Ub(n))}var Bx={h1:({node:e,...t})=>(0,X.jsx)(`h1`,{...t,className:`mt-6 mb-3 scroll-m-20 text-3xl font-bold tracking-tight first:mt-0`}),h2:({node:e,...t})=>(0,X.jsx)(`h2`,{...t,className:`mt-6 mb-3 scroll-m-20 text-2xl font-semibold tracking-tight first:mt-0`}),h3:({node:e,...t})=>
114(0,X.jsx)(`h3`,{...t,className:`mt-5 mb-2 scroll-m-20 text-xl font-semibold tracking-tight first:mt-0`}),h4:({node:e,...t})=>(0,X.jsx)(`h4`,{...t,className:`mt-4 mb-2 scroll-m-20 text-lg font-semibold first:mt-0`}),h5:({node:e,...t})=>(0,X.jsx)(`h5`,{...t,className:`mt-4 mb-2 text-base font-semibold first:mt-0`}),h6:({node:e,...t})=>(0,X.jsx)(`h6`,{...t,className:`mt-4 mb-2 text-sm font-semibold text-muted-foreground first:mt-0`}),p:({node:e,...t})=>(0,X.jsx)(`p`,{...t,className:`leading-relaxed [&:not(:first-child)]:mt-3`}),a:({node:e,...t})=>(0,X.jsx)(`a`,{...t,target:`_blank`,rel:`noopener noreferrer`,className:`font-medium text-primary underline underline-offset-4 hover:no-underline`}),ul:({node:e,...t})=>(0,X.jsx)(`ul`,{...t,className:`my-3 ml-6 list-disc space-y-1 marker:text-muted-foreground`}),ol:({node:e,...t})=>(0,X.jsx)(`ol`,{...t,className:`my-3 ml-6 list-decimal space-y-1 marker:text-muted-foreground`}),li:({node:e,...t})=>(0,X.jsx)(`li`,{...t,className:`leading-relaxed`}),blockquote:({node:e,...t})=>(0,X.jsx)(`blockquote`,{...t,className:`mt-3 border-l-2 border-border pl-4 text-muted-foreground italic`}),hr:({node:e,...t})=>(0,X.jsx)(`hr`,{...t,className:`my-6 border-border`}),strong:({node:e,...t})=>(0,X.jsx)(`strong`,{...t,className:`font-semibold`}),em:({node:e,...t})=>(0,X.jsx)(`em`,{...t,className:`italic`}),code:({node:e,...t})=>(0,X.jsx)(`code`,{...t,className:`rounded bg-muted px-1.5 py-0.5 font-mono text-sm`}),pre:({node:e,...t})=>(0,X.jsx)(`pre`,{...t,className:`my-3 overflow-x-auto rounded-lg bg-muted p-4 text-sm [&>code]:bg-transparent [&>code]:p-0`}),img:({node:e,...t})=>(0,X.jsx)(`img`,{...t,className:`my-3 h-auto max-w-full rounded-lg`}),table:({node:e,...t})=>(0,X.jsx)(`div`,{className:`my-3 w-full overflow-x-auto`,children:(0,X.jsx)(`table`,{...t,className:`w-full border-collapse text-sm`})}),thead:({node:e,...t})=>(0,X.jsx)(`thead`,{...t,className:`border-b border-border`}),tbody:({node:e,...t})=>(0,X.jsx)(`tbody`,{...t,className:`[&>tr]:border-border [&>tr:not(:last-child)]:border-b`}),tr:({node:e,...t})=>(0,X.jsx)(`tr`,{...t}),th:({node:e,...t})=>(0,X.jsx)(`th`,{...t,className:`px-3 py-2 text-left font-semibold`}),td:({node:e,...t})=>(0,X.jsx)(`td`,{...t,className:`px-3 py-2`})};function Vx(e){return q(`text-sm wrap-break-word text-foreground`,e)}var Hx=[`normal`,`h1`,`h2`,`h3`,`h4`,`h5`],Ux=Xe(Hx),Wx={normal:`Normal`,h1:`Heading 1`,h2:`Heading 2`,h3:`Heading 3`,h4:`Heading 4`,h5:`Heading 5`};function Gx(e){let t=Ux.safeParse(e);return t.success?Wx[t.data]:Wx.normal}var Kx=Hx.map(e=>({value:e,label:Wx[e]})),qx={normal:void 0,h1:`text-4xl font-bold tracking-tight`,h2:`text-3xl font-semibold tracking-tight`,h3:`text-2xl font-semibold tracking-tight`,h4:`text-xl font-semibold`,h5:`text-lg font-medium`};function Jx(e){if(!e||e===`normal`)return;let t=Ux.safeParse(e);if(t.success)return qx[t.data]}function Yx(e){if(!e||typeof e!=`object`)return;let t=e.textStyle,n=Ux.safeParse(t);return n.success?n.data:void 0}function Xx(e){return!!(e==null||e===``||Array.isArray(e)&&e.length===0)}function Zx(e,t){return e===`gallery`?`grid-cols-2 md:grid-cols-3`:t===1?`grid-cols-1`:`grid-cols-1 md:grid-cols-2`}var Qx=(0,Y.memo)(function({link:e,variant:t=`default`,template:n=`info`}){let r=t===`overlay`,i=e.fields??[],a=e.properties??{},o=e=>{if(e.propertyName)return a[e.propertyName]},s=i.find(e=>e.propertyName===`title`||e.propertyName===`name`),c=i.length>0,l=new Set([`slug`,`name`,`title`]);s?.propertyName&&l.add(s.propertyName);let u=new Set([`group`,`template`,`placement`]),d=new Set([`image`,`gallery`,`file`]),f=i.filter(e=>d.has(e.type??``)&&!l.has(e.propertyName??``)&&!u.has(e.type??``)),p=i.filter(e=>!d.has(e.type??``)&&!l.has(e.propertyName??``)&&!u.has(e.type??``));return(0,X.jsxs)(`div`,{className:q(`space-y-0`,r&&`text-white [&_img]:ring-0`),children:[f.length>0&&(0,X.jsx)(`section`,{className:`pb-4`,children:(0,X.jsx)(`div`,{className:q(`grid gap-4`,Zx(n,f.length)),children:(n===`info`?f.slice(0,1):f).map((e,t)=>{let n=o(e);return Xx(n)?null:(0,X.jsx)(`div`,{children:(0,X.jsx)(`div`,{children:$x(e,n,r)})},e.propertyName||t)})})}),(0,X.jsx)(`section`,{className:`space-y-0`,children:c?p.map((e,t)=>{if(e.type===`layout-divider`)return(0,X.jsxs)(`div`,{className:`py-8`,children:[!r&&(0,X.jsx)(gn,{}),e.name&&(0,X.jsx)(`p`,{className:q(`mt-3 text-[10px] font-bold tracking-widest uppercase`,r?`text-white/60`:`text-muted-foreground`),children:e.name})]},e.propertyName||t);let n=o(e);return Xx(n)?null:(0,X.jsx)(`div`,{className:q(`py-5`,r?`border-0`:`border-b border-border/50 last:border-0`),children:(0,X.jsx)(`div`,{children:$x(e,n,r)})},e.propertyName||t)}):Object.entries(a).map(([e,t])=>e===`title`||e===`name`||e===`slug`||Xx(t)?null:(0,X.jsx)(`div`,{className:q(`py-5`,r?`border-0`:`border-b border-border/50 last:border-0`),children:(0,X.jsx)(`div`,{children:$x({propertyName:e,name:e},t,r)})},e))})]})});function $x(e,t,n=!1){if(t==null||t===``)return null;switch(e.type){case`layout-divider`:return null;case`text`:{let r=Yx(e.options),i=r!==void 0&&r!==`normal`;return(0,X.jsx)(i?r:`p`,{className:q(i?Jx(r):`text-sm leading-relaxed`,`wrap-break-word`,n&&`text-white`),children:String(t)})}case`formatted-text`:return(0,X.jsx)(`div`,{className:Vx(n?`text-white **:text-white`:void 0),children:(0,X.jsx)(Fv,{remarkPlugins:[zx],components:Bx,children:String(t)})});case`number`:return(0,X.jsx)(`span`,{className:q(`inline-block rounded-md px-3 py-1.5 font-mono text-sm font-semibold tabular-nums`,n?`bg-white/10 text-white`:`bg-muted/40`),children:typeof t==`number`?t.toLocaleStr
114ing():t});case`date`:case`datetime`:try{let r=new Date(t);return(0,X.jsxs)(`div`,{className:q(`inline-flex items-center gap-2.5 rounded-md px-3 py-2`,n?`bg-white/10 text-white`:`bg-muted/40`),children:[(0,X.jsx)(da,{className:q(`size-4`,n?`text-white/80`:`text-muted-foreground`)}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`text-sm font-medium`,children:$i(r,`PPP`)}),e.type===`datetime`&&(0,X.jsx)(`span`,{className:q(`ml-2 text-xs`,n?`text-white/70`:`text-muted-foreground`),children:$i(r,`p`)})]})]})}catch{return(0,X.jsx)(`span`,{className:q(`text-sm`,n&&`text-white`),children:String(t)})}case`toggle`:{let e=!!t,r=`bg-muted ring-1 ring-border`;return n?r=e?`bg-white/15`:`bg-white/10`:e&&(r=`bg-green-500/10 ring-1 ring-green-500/30`),(0,X.jsxs)(`div`,{className:`inline-flex items-center gap-2.5`,children:[(0,X.jsx)(`div`,{className:q(`flex size-8 items-center justify-center rounded-full`,r),children:e?(0,X.jsx)(Ea,{className:q(`size-4`,n?`text-white`:`text-green-600 dark:text-green-400`)}):(0,X.jsx)(so,{className:q(`size-4`,n?`text-white/70`:`text-muted-foreground`)})}),(0,X.jsx)(`span`,{className:q(`text-sm font-medium`,n&&`text-white`),children:e?`Enabled`:`Disabled`})]})}case`color`:return(0,X.jsxs)(`div`,{className:`inline-flex items-center gap-3`,children:[(0,X.jsx)(`div`,{className:q(`size-10 rounded-lg shadow-sm`,n?``:`ring-1 ring-border`),style:{backgroundColor:t}}),(0,X.jsx)(`span`,{className:q(`font-mono text-sm font-medium uppercase`,n&&`text-white`),children:t})]});case`link`:return(0,X.jsxs)(`a`,{href:t,target:`_blank`,rel:`noopener noreferrer`,className:q(`group inline-flex items-center gap-2.5 rounded-md px-0 py-2 text-sm font-medium underline-offset-4 transition-colors`,n?`border-0 bg-transparent text-white no-underline hover:text-white/90`:`border border-border bg-muted/20 text-primary hover:bg-muted/40`),children:[(0,X.jsx)(Mi,{className:`size-4 shrink-0 opacity-90`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate`,children:t}),(0,X.jsx)(_a,{className:`size-3.5 shrink-0 opacity-80`})]});case`option`:return(0,X.jsx)(fr,{variant:`secondary`,className:n?`border-0 bg-white/15 px-3 py-1 text-xs font-semibold text-white shadow-none ring-0`:`border border-primary/20 bg-primary/5 px-3 py-1 text-xs font-semibold text-primary`,children:t});case`reference`:return(0,X.jsx)(fr,{variant:n?`secondary`:`outline`,className:n?`border-0 bg-white/15 px-3 py-1 text-xs font-medium text-white shadow-none ring-0`:`px-3 py-1 text-xs font-medium`,children:t||`No reference`});case`image`:{let r=null;typeof t==`object`&&t?.url?r=t.url:typeof t==`string`&&(r=t);let i=e.name||`Content image`;return typeof t==`object`&&t?.alt&&(i=t.alt),r?(0,X.jsx)(`div`,{className:q(`overflow-hidden rounded-xl`,n?`border-0 shadow-none ring-0`:`border border-border`),children:(0,X.jsx)(`img`,{src:r,alt:i,className:`h-auto max-h-80 w-full object-cover`})}):null}case`file`:{let e=null;typeof t==`object`&&t?.url?e=t.url:typeof t==`string`&&(e=t);let r=`Download file`;return typeof t==`object`&&t?.filename&&(r=t.filename),e?(0,X.jsxs)(`a`,{href:e,target:`_blank`,rel:`noopener noreferrer`,className:q(`group inline-flex items-center gap-2.5 rounded-md px-0 py-2.5 transition-colors`,n?`border-0 bg-transparent text-white hover:text-white/90`:`border border-border bg-muted/20 hover:bg-muted/40`),children:[(0,X.jsx)(oa,{className:q(`size-4`,n?`text-white/80`:`text-muted-foreground`)}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm font-medium`,children:r}),(0,X.jsx)(Wr,{className:q(`size-4 transition-colors group-hover:text-foreground`,n?`text-white/80 group-hover:text-white`:``)})]}):null}case`gallery`:return Array.isArray(t)&&t.length>0?(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-2 md:grid-cols-3 lg:grid-cols-4`,children:t.map((e,t)=>{let r=null;return typeof e==`object`&&e?.url?r=e.url:typeof e==`string`&&(r=e),r?(0,X.jsx)(`div`,{className:q(`aspect-square overflow-hidden rounded-lg`,n?`border-0`:`border border-border`),children:(0,X.jsx)(`img`,{src:r,alt:`Gallery ${t+1}`,className:`size-full object-cover`})},t):null})}):null;case`multi-reference`:return Array.isArray(t)&&t.length>0?(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:t.map((e,t)=>(0,X.jsx)(fr,{variant:n?`secondary`:`outline`,className:n?`border-0 bg-white/15 text-xs font-medium text-white shadow-none ring-0`:`text-xs font-medium`,children:e},t))}):null;case`iframe`:{let r=typeof t==`string`?t:t?.url;return r?(0,X.jsx)(`div`,{className:q(`aspect-video w-full overflow-hidden rounded-xl`,n?``:`border border-border`),children:(0,X.jsx)(`iframe`,{src:r,title:e.name||`Embedded content`,className:`size-full`,sandbox:`allow-scripts allow-same-origin allow-popups allow-forms allow-presentation`,allow:`auto
114play; fullscreen; picture-in-picture`,referrerPolicy:`no-referrer`,loading:`lazy`})}):null}case`video`:{let r=null,i;return typeof t==`string`?r=t:t&&typeof t==`object`&&(i=t.mode,r=t.mode===`file`?t.file?.url??null:t.url??null),r?i===`file`||/\.(mp4|webm|ogg|mov)(\?|$)/i.test(r)?(0,X.jsx)(`video`,{src:r,controls:!0,className:q(`max-h-80 w-full rounded-xl`,n?``:`border border-border`)}):(0,X.jsx)(`div`,{className:q(`aspect-video w-full overflow-hidden rounded-xl`,n?``:`border border-border`),children:(0,X.jsx)(`iframe`,{src:r,title:e.name||`Video`,className:`size-full`,allow:`autoplay; fullscreen; picture-in-picture`,allowFullScreen:!0,loading:`lazy`})}):null}default:return(0,X.jsx)(`div`,{className:q(`rounded-md px-3 py-2`,n?`border-0 bg-white/10 text-white`:`bg-muted/30`),children:(0,X.jsx)(`pre`,{className:q(`text-xs wrap-break-word whitespace-pre-wrap`,n&&`text-white`),children:typeof t==`object`?JSON.stringify(t,null,2):String(t)})})}}var eS=[{value:`info`,label:`Info (compact)`},{value:`article`,label:`Article (wide)`},{value:`gallery`,label:`Gallery (media)`}],tS=[{value:`center`,label:`Center overlay`},{value:`left`,label:`Left panel`},{value:`right`,label:`Right panel`},{value:`edge-left`,label:`Edge overlay (left)`},{value:`edge-right`,label:`Edge overlay (right)`}];function nS(e,t){let n=(e.fields??[]).find(e=>e.type===t);return n?.propertyName?{propertyName:n.propertyName,value:e.properties?.[n.propertyName]}:{}}function rS(e){let t=nS(e,`template`).value,n=nS(e,`placement`).value,r=nS(e,`group`);return{template:t??`info`,placement:n??`center`,groupPropertyName:r.propertyName,groupValue:typeof r.value==`string`&&r.value.length>0?r.value:void 0}}function iS({collection:e,open:t,onClose:n}){let{watch:r}=p();if((0,Y.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n]),!t)return null;let i=r(),a={type:`Content`,id:i.id||`preview`,name:i.name,slug:i.slug,status:i.status,properties:i.properties??{},fields:e.fields??[]},o=rS(a),s=$d(o.placement);return(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50`,role:`presentation`,onClick:n,children:[(0,X.jsx)(`div`,{className:`absolute inset-0 bg-black/80 backdrop-blur-sm`,"aria-hidden":!0}),(0,X.jsx)(`div`,{className:q(`pointer-events-none absolute inset-0 flex items-center py-8`,qd[s.side]),children:(0,X.jsxs)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":a.name||`Content preview`,"data-content-side":s.side,onClick:e=>e.stopPropagation(),className:q(`pointer-events-auto relative flex max-h-[85svh] w-full flex-col overflow-hidden rounded-xl px-4 pt-4 pb-4 sm:px-5`,s.side===`center`?Yd:Xd,Jd[s.side]),children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close preview`,onClick:n,className:q(`absolute top-3 right-3 z-10 p-1 sm:right-4`,Zd),children:(0,X.jsx)(so,{className:`size-5`,strokeWidth:2,"aria-hidden":!0})}),(0,X.jsx)(`div`,{className:q(`min-h-0 flex-1 pr-1`,Qd),children:(0,X.jsx)(Qx,{link:a,variant:`overlay`,template:o.template})})]})})]})}iS.displayName=`ItemEditorPreview`;function aS(e){return(e.fields??[]).some(e=>e.type===`template`||e.type===`placement`)}function oS(e,t,n=`long`){return new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,timeZone:e,timeZoneName:n}).format(t).split(/\s/g).slice(2).join(` `)}var sS={},cS={};function lS(e,t){try{let n=(sS[e]||=new Intl.DateTimeFormat(`en-US`,{timeZone:e,timeZoneName:`longOffset`}).format)(t).split(`GMT`)[1];return n in cS?cS[n]:dS(n,n.split(`:`))}catch{if(e in cS)return cS[e];let t=e?.match(uS);return t?dS(e,t.slice(1)):NaN}}var uS=/([+-]\d\d):?(\d\d)?/;function dS(e,t){let n=+(t[0]||0),r=+(t[1]||0),i=(t[2]||0)/60;return cS[e]=n*60+r>0?n*60+r+i:n*60-r-i}var fS=class e extends Date{constructor(...e){super(),e.length>1&&typeof e[e.length-1]==`string`&&(this.timeZone=e.pop()),this.internal=new Date,isNaN(lS(this.timeZone,this))?this.setTime(NaN):e.length?typeof e[0]==`number`&&(e.length===1||e.length===2&&typeof e[1]!=`number`)?this.setTime(e[0]):typeof e[0]==`string`?this.setTime(+new Date(e[0])):e[0]instanceof Date?this.setTime(+e[0]):(this.setTime(+new Date(...e)),gS(this,NaN),mS(this)):this.setTime(Date.now())}static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}withTimeZone(t){return new e(+this,t)}getTimezoneOffset(){let e=-lS(this.timeZone,this);return e>0?Math.floor(e):Math.ceil(e)}setTime(e){return Date.prototype.setTime.apply(this,arguments),mS(this),+this}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},pS=/^(get|set)(?!UTC)/;
vendor: 4,445 bytes, line 114
114Object.getOwnPropertyNames(Date.prototype).forEach(e=>{if(!pS.test(e))return;let t=e.replace(pS,`$1UTC`);fS.prototype[t]&&(e.startsWith(`get`)?fS.prototype[e]=function(){return this.internal[t]()}:(fS.prototype[e]=function(){return Date.prototype[t].apply(this.internal,arguments),hS(this),+this},fS.prototype[t]=function(){return Date.prototype[t].apply(this,arguments),mS(this),+this}))});function mS(e){e.internal.setTime(+e),e.internal.setUTCSeconds(e.internal.getUTCSeconds()-Math.round(-lS(e.timeZone,e)*60))}function hS(e){Date.prototype.setFullYear.call(e,e.internal.getUTCFullYear(),e.internal.getUTCMonth(),e.internal.getUTCDate()),Date.prototype.setHours.call(e,e.internal.getUTCHours(),e.internal.getUTCMinutes(),e.internal.getUTCSeconds(),e.internal.getUTCMilliseconds()),gS(e)}function gS(e){let t=lS(e.timeZone,e),n=t>0?Math.floor(t):Math.ceil(t),r=new Date(+e);r.setUTCHours(r.getUTCHours()-1);let i=-new Date(+e).getTimezoneOffset(),a=i- -new Date(+r).getTimezoneOffset(),o=Date.prototype.getHours.apply(e)!==e.internal.getUTCHours();a&&o&&e.internal.setUTCMinutes(e.internal.getUTCMinutes()+a);let s=i-n;s&&Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+s);let c=new Date(+e);c.setUTCSeconds(0);let l=i>0?c.getSeconds():(c.getSeconds()-60)%60,u=Math.round(-(lS(e.timeZone,e)*60))%60;(u||l)&&(e.internal.setUTCSeconds(e.internal.getUTCSeconds()+u),Date.prototype.setUTCSeconds.call(e,Date.prototype.getUTCSeconds.call(e)+u+l));let d=lS(e.timeZone,e),f=d>0?Math.floor(d):Math.ceil(d),p=-new Date(+e).getTimezoneOffset()-f,m=f!==n,h=p-s;if(m&&h){Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+h);let t=lS(e.timeZone,e),n=f-(t>0?Math.floor(t):Math.ceil(t));n&&(e.internal.setUTCMinutes(e.internal.getUTCMinutes()+n),Date.prototype.setUTCMinutes.call(e,Date.prototype.getUTCMinutes.call(e)+n))}}var _S=class e extends fS{static tz(t,...n){return n.length?new e(...n,t):new e(Date.now(),t)}toISOString(){let[e,t,n]=this.tzComponents(),r=`${e}${t}:${n}`;return this.internal.toISOString().slice(0,-1)+r}toString(){return`${this.toDateString()} ${this.toTimeString()}`}toDateString(){let[e,t,n,r]=this.internal.toUTCString().split(` `);return`${e?.slice(0,-1)} ${n} ${t} ${r}`}toTimeString(){let e=this.internal.toUTCString().split(` `)[4],[t,n,r]=this.tzComponents();return`${e} GMT${t}${n}${r} (${oS(this.timeZone,this)})`}toLocaleString(e,t){return Date.prototype.toLocaleString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleDateString(e,t){return Date.prototype.toLocaleDateString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}toLocaleTimeString(e,t){return Date.prototype.toLocaleTimeString.call(this,e,{...t,timeZone:t?.timeZone||this.timeZone})}tzComponents(){let e=this.getTimezoneOffset();return[e>0?`-`:`+`,String(Math.floor(Math.abs(e)/60)).padStart(2,`0`),String(Math.abs(e)%60).padStart(2,`0`)]}withTimeZone(t){return new e(+this,t)}[Symbol.for(`constructDateFrom`)](t){return new e(+new Date(t),this.timeZone)}},vS=5,yS=4;function bS(e,t){let n=t.startOfMonth(e),r=n.getDay()>0?n.getDay():7,i=t.addDays(e,-r+1),a=t.addDays(i,34);return t.getMonth(e)===t.getMonth(a)?vS:yS}function xS(e,t){let n=t.startOfMonth(e),r=n.getDay();return r===1?n:r===0?t.addDays(n,-6):t.addDays(n,-1*(r-1))}function SS(e,t){let n=xS(e,t),r=bS(e,t);return t.addDays(n,r*7-1)}var CS={...aa,labels:{labelDayButton:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>$i(e,t,{locale:aa,...n});let a=i(e,`PPPP`);return t.today&&(a=`Today, ${a}`),t.selected&&(a=`${a}, selected`),a},labelMonthDropdown:`Choose the Month`,labelNext:`Go to the Next Month`,labelPrevious:`Go to the Previous Month`,labelWeekNumber:e=>`Week ${e}`,labelYearDropdown:`Choose the Year`,labelGrid:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>$i(e,n,{locale:aa,...t}),r(e,`LLLL yyyy`)},labelGridcell:(e,t,n,r)=>{let i;i=r&&typeof r.format==`function`?r.format.bind(r):(e,t)=>$i(e,t,{locale:aa,...n});let a=i(e,`PPPP`);return t?.today&&(a=`Today, ${a}`),a},labelNav:`Navigation bar`,labelWeekNumberHeader:`Week Number`,labelWeekday:(e,t,n)=>{let r;return r=n&&typeof n.format==`function`?n.format.bind(n):(e,n)=>$i(e,n,{locale:aa,...t}),r(e,`cccc`)}}},wS=class e{constructor(e,t){this.today=()=>this.overrides?.today?this.overrides.today():this.options.timeZone?_S.tz(this.options.timeZone):new(this.options.Date??Date),this.newDate=(e,t,n
vendor: 37,536 bytes, line 114
114)=>this.overrides?.newDate?this.overrides.newDate(e,t,n):this.options.timeZone?new _S(e,t,n,this.options.timeZone):new Date(e,t,n),this.addDays=(e,t)=>this.overrides?.addDays?this.overrides.addDays(e,t):Xr(e,t),this.addMonths=(e,t)=>this.overrides?.addMonths?this.overrides.addMonths(e,t):Ur(e,t),this.addWeeks=(e,t)=>this.overrides?.addWeeks?this.overrides.addWeeks(e,t):Or(e,t),this.addYears=(e,t)=>this.overrides?.addYears?this.overrides.addYears(e,t):ga(e,t),this.differenceInCalendarDays=(e,t)=>this.overrides?.differenceInCalendarDays?this.overrides.differenceInCalendarDays(e,t):pa(e,t),this.differenceInCalendarMonths=(e,t)=>this.overrides?.differenceInCalendarMonths?this.overrides.differenceInCalendarMonths(e,t):to(e,t),this.eachMonthOfInterval=e=>this.overrides?.eachMonthOfInterval?this.overrides.eachMonthOfInterval(e):mi(e),this.eachYearOfInterval=e=>{let t=this.overrides?.eachYearOfInterval?this.overrides.eachYearOfInterval(e):Qa(e),n=new Set(t.map(e=>this.getYear(e)));if(n.size===t.length)return t;let r=[];return n.forEach(e=>{r.push(new Date(e,0,1))}),r},this.endOfBroadcastWeek=e=>this.overrides?.endOfBroadcastWeek?this.overrides.endOfBroadcastWeek(e):SS(e,this),this.endOfISOWeek=e=>this.overrides?.endOfISOWeek?this.overrides.endOfISOWeek(e):na(e),this.endOfMonth=e=>this.overrides?.endOfMonth?this.overrides.endOfMonth(e):Pr(e),this.endOfWeek=(e,t)=>this.overrides?.endOfWeek?this.overrides.endOfWeek(e,t):Ni(e,this.options),this.endOfYear=e=>this.overrides?.endOfYear?this.overrides.endOfYear(e):Vi(e),this.format=(e,t,n)=>{let r=this.overrides?.format?this.overrides.format(e,t,this.options):$i(e,t,this.options);return this.options.numerals&&this.options.numerals!==`latn`?this.replaceDigits(r):r},this.getISOWeek=e=>this.overrides?.getISOWeek?this.overrides.getISOWeek(e):xa(e),this.getMonth=(e,t)=>this.overrides?.getMonth?this.overrides.getMonth(e,this.options):Ja(e,this.options),this.getYear=(e,t)=>this.overrides?.getYear?this.overrides.getYear(e,this.options):ya(e,this.options),this.getWeek=(e,t)=>this.overrides?.getWeek?this.overrides.getWeek(e,this.options):Ma(e,this.options),this.isAfter=(e,t)=>this.overrides?.isAfter?this.overrides.isAfter(e,t):Ui(e,t),this.isBefore=(e,t)=>this.overrides?.isBefore?this.overrides.isBefore(e,t):Va(e,t),this.isDate=e=>this.overrides?.isDate?this.overrides.isDate(e):_i(e),this.isSameDay=(e,t)=>this.overrides?.isSameDay?this.overrides.isSameDay(e,t):Br(e,t),this.isSameMonth=(e,t)=>this.overrides?.isSameMonth?this.overrides.isSameMonth(e,t):Oa(e,t),this.isSameYear=(e,t)=>this.overrides?.isSameYear?this.overrides.isSameYear(e,t):Li(e,t),this.max=e=>this.overrides?.max?this.overrides.max(e):ci(e),this.min=e=>this.overrides?.min?this.overrides.min(e):Lr(e),this.setMonth=(e,t)=>this.overrides?.setMonth?this.overrides.setMonth(e,t):la(e,t),this.setYear=(e,t)=>this.overrides?.setYear?this.overrides.setYear(e,t):La(e,t),this.startOfBroadcastWeek=(e,t)=>this.overrides?.startOfBroadcastWeek?this.overrides.startOfBroadcastWeek(e,this):xS(e,this),this.startOfDay=e=>this.overrides?.startOfDay?this.overrides.startOfDay(e):ai(e),this.startOfISOWeek=e=>this.overrides?.startOfISOWeek?this.overrides.startOfISOWeek(e):oi(e),this.startOfMonth=e=>this.overrides?.startOfMonth?this.overrides.startOfMonth(e):no(e),this.startOfWeek=(e,t)=>this.overrides?.startOfWeek?this.overrides.startOfWeek(e,this.options):ui(e,this.options),this.startOfYear=e=>this.overrides?.startOfYear?this.overrides.startOfYear(e):ao(e),this.options={locale:CS,...e},this.overrides=t}getDigitMap(){let{numerals:e=`latn`}=this.options,t=new Intl.NumberFormat(`en-US`,{numberingSystem:e}),n={};for(let e=0;e<10;e++)n[e.toString()]=t.format(e);return n}replaceDigits(e){let t=this.getDigitMap();return e.replace(/\d/g,e=>t[e]||e)}formatNumber(e){return this.replaceDigits(e.toString())}getMonthYearOrder(){let t=this.options.locale?.code;return t&&e.yearFirstLocales.has(t)?`year-first`:`month-first`}formatMonthYear(t){let{locale:n,timeZone:r,numerals:i}=this.options,a=n?.code;if(a&&e.yearFirstLocales.has(a))try{return new Intl.DateTimeFormat(a,{month:`long`,year:`numeric`,timeZone:r,numberingSystem:i}).format(t)}catch{}let o=this.getMonthYearOrder()===`year-first`?`y LLLL`:`LLLL y`;return this.format(t,o)}};wS.yearFirstLocales=new Set([`eu`,`hu`,`ja`,`ja-Hira`,`ja-JP`,`ko`,`ko-KR`,`lt`,`lt-LT`,`lv`,`lv-LV`,`mn`,`mn-MN`,`zh`,`zh-CN`,`zh-HK`,`zh-TW`]);var TS=new wS,ES=class{constructor(e,t,n=TS){this.date=e,this.displayMonth=t,this.outside=!(!t||n.isSameMonth(e,t)),this.dateLib=n,this.isoDate=n.format(e,`yyyy-MM-dd`),this.displayMonthId=n.format(t,`yyyy-MM`),this.dateMonthId=n.format(e,`yyyy-MM`)}isEqualTo(e){return this.dateLib.isSameDay(e.date,this.date)&&this.dateLib.isSameMonth(e.displayMonth,this.displayMonth)}},DS=class{constructor(e,t){this.date=e,this.weeks=t}},OS=class{constructor(e,t){this.days=t,this.weekNumber=e}};function kS(e){return Y.createElement(`span`,{...e})}function AS(e){let{size:t=24,orientation:n=`left`,className:r,style:i}=e;return Y.createElement(`svg`,{className:r,style:i,width:t,height:t,viewBox:`0 0 24 24`},n===`up`&&Y.createElement(`polygon`,{points:`6.77 17 12.5 11.43 18.24 17 20 15.28 12.5 8 5 15.28`}),n===`down`&&Y.createElement(`polygon`,{points:`6.77 8 12.5 13.57 18.24 8 20 9.72 12.5 17 5 9.72`}),n===`left`&&Y.createElement(`polygon`,{points:`16 18.112 9.81111111 12 16 5.87733333 14.0888889 4 6 12 14.0888889 20`}),n===`right`&&Y.createElement(`polygon`,{points:`8 18.112 14.18888889 12 8 5.87733333 9.91111111 4 18 12 9.91111111 20`}))}function jS(e){let{day:t,modifiers:n,...r}=e;return Y.createElement(`td`,{...r})}function MS(e){let{day:t,modifiers:n,...r}=e,i=Y.useRef(null);return Y.useEffect(()=>{n.focused&&i.current?.focus()},[n.focused]),Y.createElement(`button`,{ref:i,...r})}var $;(function(e){e.Root=`root`,e.Chevron=`chevron`,e.Day=`day`,e.DayButton=`day_button`,e.CaptionLabel=`caption_label`,e.Dropdowns=`dropdowns`,e.Dropdown=`dropdown`,e.DropdownRoot=`dropdown_root`,e.Footer=`footer`,e.MonthGrid=`month_grid`,e.MonthCaption=`month_caption`,e.MonthsDropdown=`months_dropdown`,e.Month=`month`,e.Months=`months`,e.Nav=`nav`,e.NextMonthButton=`button_next`,e.PreviousMonthButton=`button_previous`,e.Week=`week`,e.Weeks=`weeks`,e.Weekday=`weekday`,e.Weekdays=`weekdays`,e.WeekNumber=`week_number`,e.WeekNumberHeader=`week_number_header`,e.YearsDropdown=`years_dropdown`})($||={});var NS;(function(e){e.disabled=`disabled`,e.hidden=`hidden`,e.outside=`outside`,e.focused=`focused`,e.today=`today`})(NS||={});var PS;(function(e){e.range_end=`range_end`,e.range_middle=`range_middle`,e.range_start=`range_start`,e.selected=`selected`})(PS||={});var FS;(function(e){e.weeks_before_enter=`weeks_before_enter`,e.weeks_before_exit=`weeks_before_exit`,e.weeks_after_enter=`weeks_after_enter`,e.weeks_after_exit=`weeks_after_exit`,e.caption_after_enter=`caption_after_enter`,e.caption_after_exit=`caption_after_exit`,e.caption_before_enter=`caption_before_enter`,e.caption_before_exit=`caption_before_exit`})(FS||={});var IS=(0,Y.createContext)(void 0);function LS(){let e=(0,Y.useContext)(IS);if(e===void 0)throw Error(`useDayPicker() must be used within a custom component.`);return e}function RS(e){let{options:t,className:n,...r}=e,{classNames:i,components:a,styles:o}=LS(),s=[i[$.Dropdown],n].join(` `),c=t?.find(({value:e})=>e===r.value);return Y.createElement(`span`,{"data-disabled":r.disabled,className:i[$.DropdownRoot],style:o?.[$.DropdownRoot]},Y.createElement(a.Select,{className:s,...r},t?.map(({value:e,label:t,disabled:n})=>Y.createElement(a.Option,{key:e,value:e,disabled:n},t))),Y.createElement(`span`,{className:i[$.CaptionLabel],style:o?.[$.CaptionLabel],"aria-hidden":!0},c?.label,Y.createElement(a.Chevron,{orientation:`down`,size:18,className:i[$.Chevron],style:o?.[$.Chevron]})))}function zS(e){return Y.createElement(`div`,{...e})}function BS(e){return Y.createElement(`div`,{...e})}function VS(e){let{calendarMonth:t,displayIndex:n,...r}=e;return Y.createElement(`div`,{...r},e.children)}function HS(e){let{calendarMonth:t,displayIndex:n,...r}=e;return Y.createElement(`div`,{...r})}function US(e){return Y.createElement(`table`,{...e})}function WS(e){return Y.createElement(`div`,{...e})}function GS(e){let{components:t}=LS();return Y.createElement(t.Dropdown,{...e})}function KS(e){let{onPreviousClick:t,onNextClick:n,previousMonth:r,nextMonth:i,...a}=e,{components:o,classNames:s,styles:c,labels:{labelPrevious:l,labelNext:u}}=LS(),d=(0,Y.useCallback)(e=>{i&&n?.(e)},[i,n]),f=(0,Y.useCallback)(e=>{r&&t?.(e)},[r,t]);return Y.createElement(`nav`,{...a},Y.createElement(o.PreviousMonthButton,{type:`button`,className:s[$.PreviousMonthButton],style:c?.[$.PreviousMonthButton],tabIndex:r?void 0:-1,"aria-disabled":!r||void 0,"aria-label":l(r),onClick:f},Y.createElement(o.Chevron,{disabled:!r||void 0,className:s[$.Chevron],style:c?.[$.Chevron],orientation:`left`})),Y.createElement(o.NextMonthButton,{type:`button`,className:s[$.NextMonthButton],style:c?.[$.NextMonthButton],tabIndex:i?void 0:-1,"aria-disabled":!i||void 0,"aria-label":u(i),onClick:d},Y.createElement(o.Chevron,{disabled:!i||void 0,orientation:`right`,className:s[$.Chevron],style:c?.[$.Chevron]})))}function qS(e){return Y.createElement(`button`,{...e})}function JS(e){return Y.createElement(`option`,{...e})}function YS(e){return Y.createElement(`button`,{...e})}function XS(e){let{rootRef:t,...n}=e;return Y.createElement(`div`,{...n,ref:t})}function ZS(e){return Y.createElement(`select`,{...e})}function QS(e){let{week:t,...n}=e;return Y.createElement(`tr`,{...n})}function $S(e){return Y.createElement(`th`,{...e})}function eC(e){return Y.createElement(`thead`,{"aria-hidden":!0},Y.createElement(`tr`,{...e}))}function tC(e){let{week:t,...n}=e;return Y.createElement(`th`,{...n})}function nC(e){return Y.createElement(`th`,{...e})}function rC(e){return Y.createElement(`tbody`,{...e})}function iC(e){let{components:t}=LS();return Y.createElement(t.Dropdown,{...e})}var aC=t({CaptionLabel:()=>kS,Chevron:()=>AS,Day:()=>jS,DayButton:()=>MS,Dropdown:()=>RS,DropdownNav:()=>zS,Footer:()=>BS,Month:()=>VS,MonthCaption:()=>HS,MonthGrid:()=>US,Months:()=>WS,MonthsDropdown:()=>GS,Nav:()=>KS,NextMonthButton:()=>qS,Option:()=>JS,PreviousMonthButton:()=>YS,Root:()=>XS,Select:()=>ZS,Week:()=>QS,WeekNumber:()=>tC,WeekNumberHeader:()=>nC,Weekday:()=>$S,Weekdays:()=>eC,Weeks:()=>rC,YearsDropdown:()=>iC});function oC(e,t,n=!1,r=TS){let{from:i,to:a}=e,{differenceInCalendarDays:o,isSameDay:s}=r;return i&&a?(o(a,i)<0&&([i,a]=[a,i]),o(t,i)>=+!!n&&o(a,t)>=+!!n):!n&&a?s(a,t):!n&&i?s(i,t):!1}function sC(e){return!!(e&&typeof e==`object`&&`before`in e&&`after`in e)}function cC(e){return!!(e&&typeof e==`object`&&`from`in e)}function lC(e){return!!(e&&typeof e==`object`&&`after`in e)}function uC(e){return!!(e&&typeof e==`object`&&`before`in e)}function dC(e){return!!(e&&typeof e==`object`&&`dayOfWeek`in e)}function fC(e,t){return Array.isArray(e)&&e.every(t.isDate)}function pC(e,t,n=TS){let r=Array.isArray(t)?t:[t],{isSameDay:i,differenceInCalendarDays:a,isAfter:o}=n;return r.some(t=>{if(typeof t==`boolean`)return t;if(n.isDate(t))return i(e,t);if(fC(t,n))return t.some(t=>i(e,t));if(cC(t))return oC(t,e,!1,n);if(dC(t))return Array.isArray(t.dayOfWeek)?t.dayOfWeek.includes(e.getDay()):t.dayOfWeek===e.getDay();if(sC(t)){let n=a(t.before,e),r=a(t.after,e),i=n>0,s=r<0;return o(t.before,t.after)?s&&i:i||s}return lC(t)?a(e,t.after)>0:uC(t)?a(t.before,e)>0:typeof t==`function`&&t(e)})}function mC(e,t,n,r,i){let{disabled:a,hidden:o,modifiers:s,showOutsideDays:c,broadcastCalendar:l,today:u=i.today()}=t,{isSameDay:d,isSameMonth:f,startOfMonth:p,isBefore:m,endOfMonth:h,isAfter:g}=i,_=n&&p(n),v=r&&h(r),y={[NS.focused]:[],[NS.outside]:[],[NS.disabled]:[],[NS.hidden]:[],[NS.today]:[]},b={};for(let t of e){let{date:e,displayMonth:n}=t,r=!(!n||f(e,n)),p=!!(_&&m(e,_)),h=!!(v&&g(e,v)),x=!!(a&&pC(e,a,i)),S=!!(o&&pC(e,o,i))||p||h||!l&&!c&&r||l&&c===!1&&r,C=d(e,u);r&&y.outside.push(t),x&&y.disabled.push(t),S&&y.hidden.push(t),C&&y.today.push(t),s&&Object.keys(s).forEach(n=>{let r=s?.[n];r&&pC(e,r,i)&&(b[n]?b[n].push(t):b[n]=[t])})}return e=>{let t={[NS.focused]:!1,[NS.disabled]:!1,[NS.hidden]:!1,[NS.outside]:!1,[NS.today]:!1},n={};for(let n in y)t[n]=y[n].some(t=>t===e);for(let t in b)n[t]=b[t].some(t=>t===e);return{...t,...n}}}function hC(e,t,n={}){return Object.entries(e).filter(([,e])=>e===!0).reduce((e,[r])=>(n[r]?e.push(n[r]):t[NS[r]]?e.push(t[NS[r]]):t[PS[r]]&&e.push(t[PS[r]]),e),[t[$.Day]])}function gC(e){return{...aC,...e}}function _C(e){let t={"data-mode":e.mode??void 0,"data-required":`required`in e?e.required:void 0,"data-multiple-months":e.numberOfMonths&&e.numberOfMonths>1||void 0,"data-week-numbers":e.showWeekNumber||void 0,"data-broadcast-calendar":e.broadcastCalendar||void 0,"data-nav-layout":e.navLayout||void 0};return Object.entries(e).forEach(([e,n])=>{e.startsWith(`data-`)&&(t[e]=n)}),t}function vC(){let e={};for(let t in $)e[$[t]]=`rdp-${$[t]}`;for(let t in NS)e[NS[t]]=`rdp-${NS[t]}`;for(let t in PS)e[PS[t]]=`rdp-${PS[t]}`;for(let t in FS)e[FS[t]]=`rdp-${FS[t]}`;return e}function yC(e,t,n){return(n??new wS(t)).formatMonthYear(e)}function bC(e,t,n){return(n??new wS(t)).format(e,`d`)}function xC(e,t=TS){return t.format(e,`LLLL`)}function SC(e,t,n){return(n??new wS(t)).format(e,`cccccc`)}function CC(e,t=TS){return e<10?t.formatNumber(`0${e.toLocaleString()}`):t.formatNumber(`${e.toLocaleString()}`)}function wC(){return``}function TC(e,t=TS){return t.format(e,`yyyy`)}var EC=t({formatCaption:()=>yC,formatDay:()=>bC,formatMonthDropdown:()=>xC,formatWeekNumber:()=>CC,formatWeekNumberHeader:()=>wC,formatWeekdayName:()=>SC,formatYearDropdown:()=>TC});function DC(e){return{...EC,...e}}function OC(e,t,n,r){let i=(r??new wS(n)).format(e,`PPPP`);return t.today&&(i=`Today, ${i}`),t.selected&&(i=`${i}, selected`),i}function kC(e,t,n){return(n??new wS(t)).formatMonthYear(e)}function AC(e,t,n,r){let i=(r??new wS(n)).format(e,`PPPP`);return t?.today&&(i=`Today, ${i}`),i}function jC(e){return`Choose the Month`}function MC(){return``}var NC=`Go to the Next Month`;function PC(e,t){return NC}function FC(e){return`Go to the Previous Month`}function IC(e,t,n){return(n??new wS(t)).format(e,`cccc`)}function LC(e,t){return`Week ${e}`}function RC(e){return`Week Number`}function zC(e){return`Choose the Year`}var BC=t({labelDayButton:()=>OC,labelGrid:()=>kC,labelGridcell:()=>AC,labelMonthDropdown:()=>jC,labelNav:()=>MC,labelNext:()=>PC,labelPrevious:()=>FC,labelWeekNumber:()=>LC,labelWeekNumberHeader:()=>RC,labelWeekday:()=>IC,labelYearDropdown:()=>zC}),VC=(e,t,n)=>t||(n?typeof n==`function`?n:(...e)=>n:e);function HC(e,t){let n=t.locale?.labels??{};return{...BC,...e??{},labelDayButton:VC(OC,e?.labelDayButton,n.labelDayButton),labelMonthDropdown:VC(jC,e?.labelMonthDropdown,n.labelMonthDropdown),labelNext:VC(PC,e?.labelNext,n.labelNext),labelPrevious:VC(FC,e?.labelPrevious,n.labelPrevious),labelWeekNumber:VC(LC,e?.labelWeekNumber,n.labelWeekNumber),labelYearDropdown:VC(zC,e?.labelYearDropdown,n.labelYearDropdown),labelGrid:VC(kC,e?.labelGrid,n.labelGrid),labelGridcell:VC(AC,e?.labelGridcell,n.labelGridcell),labelNav:VC(MC,e?.labelNav,n.labelNav),labelWeekNumberHeader:VC(RC,e?.labelWeekNumberHeader,n.labelWeekNumberHeader),labelWeekday:VC(IC,e?.labelWeekday,n.labelWeekday)}}function UC(e,t,n,r,i){let{startOfMonth:a,startOfYear:o,endOfYear:s,eachMonthOfInterval:c,getMonth:l}=i;return c({start:o(e),end:s(e)}).map(e=>{let o=r.formatMonthDropdown(e,i);return{value:l(e),label:o,disabled:t&&e<a(t)||n&&e>a(n)||!1}})}function WC(e,t={},n={}){let r={...t?.[$.Day]};return Object.entries(e).filter(([,e])=>e===!0).forEach(([e])=>{r={...r,...n?.[e]}}),r}function GC(e,t,n,r){let i=r??e.today(),a=n?e.startOfBroadcastWeek(i,e):t?e.startOfISOWeek(i):e.startOfWeek(i),o=[];for(let t=0;t<7;t++){let n=e.addDays(a,t);o.push(n)}return o}function KC(e,t,n,r,i=!1){if(!e||!t)return;let{startOfYear:a,endOfYear:o,eachYearOfInterval:s,getYear:c}=r,l=s({start:a(e),end:o(t)});return i&&l.reverse(),l.map(e=>{let t=n.formatYearDropdown(e,r);return{value:c(e),label:t,disabled:!1}})}function qC(e,t={}){let{weekStartsOn:n,locale:r}=t,i=n??r?.options?.weekStartsOn??0,a=t=>{let n=typeof t==`number`||typeof t==`string`?new Date(t):t;return new _S(n.getFullYear(),n.getMonth(),n.getDate(),12,0,0,e)},o=e=>{let t=a(e);return new Date(t.getFullYear(),t.getMonth(),t.getDate(),0,0,0,0)};return{today:()=>a(_S.tz(e)),newDate:(t,n,r)=>new _S(t,n,r,12,0,0,e),startOfDay:e=>a(e),startOfWeek:(e,t)=>{let n=a(e),r=t?.weekStartsOn??i,o=(n.getDay()-r+7)%7;return n.setDate(n.getDate()-o),n},startOfISOWeek:e=>{let t=a(e),n=(t.getDay()-1+7)%7;return t.setDate(t.getDate()-n),t},startOfMonth:e=>{let t=a(e);return t.setDate(1),t},startOfYear:e=>{let t=a(e);return t.setMonth(0,1),t},endOfWeek:(e,t)=>{let n=a(e),r=(((t?.weekStartsOn??i)+6)%7-n.getDay()+7)%7;return n.setDate(n.getDate()+r),n},endOfISOWeek:e=>{let t=a(e),n=(7-t.getDay())%7;return t.setDate(t.getDate()+n),t},endOfMonth:e=>{let t=a(e);return t.setMonth(t.getMonth()+1,0),t},endOfYear:e=>{let t=a(e);return t.setMonth(11,31),t},eachMonthOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new _S(n.getFullYear(),n.getMonth(),1,12,0,0,e),s=r.getFullYear()*12+r.getMonth();for(;o.getFullYear()*12+o.getMonth()<=s;)i.push(new _S(o,e)),o.setMonth(o.getMonth()+1,1);return i},addDays:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t),n},addWeeks:(e,t)=>{let n=a(e);return n.setDate(n.getDate()+t*7),n},addMonths:(e,t)=>{let n=a(e);return n.setMonth(n.getMonth()+t),n},addYears:(e,t)=>{let n=a(e);return n.setFullYear(n.getFullYear()+t),n},eachYearOfInterval:t=>{let n=a(t.start),r=a(t.end),i=[],o=new _S(n.getFullYear(),0,1,12,0,0,e);for(;o.getFullYear()<=r.getFullYear();)i.push(new _S(o,e)),o.setFullYear(o.getFullYear()+1,0,1);return i},getWeek:(e,t)=>{let n=o(e);return Ma(n,{weekStartsOn:t?.weekStartsOn??i,firstWeekContainsDate:t?.firstWeekContainsDate??r?.options?.firstWeekContainsDate??1})},getISOWeek:e=>{let t=o(e);return xa(t)},differenceInCalendarDays:(e,t)=>{let n=o(e),r=o(t);return pa(n,r)},differenceInCalendarMonths:(e,t)=>{let n=o(e),r=o(t);return to(n,r)}}}var JC=e=>e instanceof HTMLElement?e:null,YC=e=>[...e.querySelectorAll(`[data-animated-month]`)??[]],XC=e=>JC(e.querySelector(`[data-animated-month]`)),ZC=e=>JC(e.querySelector(`[data-animated-caption]`)),QC=e=>JC(e.querySelector(`[data-animated-weeks]`)),$C=e=>JC(e.querySelector(`[data-animated-nav]`)),ew=e=>JC(e.querySelector(`[data-animated-weekdays]`));function tw(e,t,{classNames:n,months:r,focused:i,dateLib:a}){let o=(0,Y.useRef)(null),s=(0,Y.useRef)(r),c=(0,Y.useRef)(!1);(0,Y.useLayoutEffect)(()=>{let l=s.current;if(s.current=r,!t||!e.current||!(e.current instanceof HTMLElement)||r.length===0||l.length===0||r.length!==l.length)return;let u=a.isSameMonth(r[0].date,l[0].date),d=a.isAfter(r[0].date,l[0].date),f=d?n[FS.caption_after_enter]:n[FS.caption_before_enter],p=d?n[FS.weeks_after_enter]:n[FS.weeks_before_enter],m=o.current,h=e.current.cloneNode(!0);if(h instanceof HTMLElement?(YC(h).forEach(e=>{if(!(e instanceof HTMLElement))return;let t=XC(e);t&&e.contains(t)&&e.removeChild(t);let n=ZC(e);n&&n.classList.remove(f);let r=QC(e);r&&r.classList.remove(p)}),o.current=h):o.current=null,c.current||u||i)return;let g=m instanceof HTMLElement?YC(m):[],_=YC(e.current);if(_?.every(e=>e instanceof HTMLElement)&&g?.every(e=>e instanceof HTMLElement)){c.current=!0;let t=[];e.current.style.isolation=`isolate`;let r=$C(e.current);r&&(r.style.zIndex=`1`),_.forEach((i,a)=>{let o=g[a];if(!o)return;i.style.position=`relative`,i.style.overflow=`hidden`;let s=ZC(i);s&&s.classList.add(f);let l=QC(i);l&&l.classList.add(p);let u=()=>{c.current=!1,e.current&&(e.current.style.isolation=``),r&&(r.style.zIndex=``),s&&s.classList.remove(f),l&&l.classList.remove(p),i.style.position=``,i.style.overflow=``,i.contains(o)&&i.removeChild(o)};t.push(u),o.style.pointerEvents=`none`,o.style.position=`absolute`,o.style.overflow=`hidden`,o.setAttribute(`aria-hidden`,`true`);let m=ew(o);m&&(m.style.opacity=`0`);let h=ZC(o);h&&(h.classList.add(d?n[FS.caption_before_exit]:n[FS.caption_after_exit]),h.addEventListener(`animationend`,u));let _=QC(o);_&&_.classList.add(d?n[FS.weeks_before_exit]:n[FS.weeks_after_exit]),i.insertBefore(o,i.firstChild)})}})}function nw(e,t,n,r){let i=e[0],a=e[e.length-1],{ISOWeek:o,fixedWeeks:s,broadcastCalendar:c}=n??{},{addDays:l,differenceInCalendarDays:u,differenceInCalendarMonths:d,endOfBroadcastWeek:f,endOfISOWeek:p,endOfMonth:m,endOfWeek:h,isAfter:g,startOfBroadcastWeek:_,startOfISOWeek:v,startOfWeek:y}=r,b=c?_(i,r):o?v(i):y(i),x=c?f(a):o?p(m(a)):h(m(a)),S=t&&(c?f(t):o?p(t):h(t)),C=u(S&&g(x,S)?S:x,b),w=d(a,i)+1,T=[];for(let e=0;e<=C;e++){let t=l(b,e);T.push(t)}let E=(c?35:42)*w;if(s&&T.length<E){let e=E-T.length;for(let t=0;t<e;t++){let e=l(T[T.length-1],1);T.push(e)}}return T}function rw(e){let t=[];return e.reduce((e,n)=>{let r=n.weeks.reduce((e,t)=>e.concat(t.days.slice()),t.slice());return e.concat(r.slice())},t.slice())}function iw(e,t,n,r){let{numberOfMonths:i=1}=n,a=[];for(let n=0;n<i;n++){let i=r.addMonths(e,n);if(t&&i>t)break;a.push(i)}return a}function aw(e,t,n,r){let{month:i,defaultMonth:a,today:o=r.today(),numberOfMonths:s=1}=e,c=i||a||o,{differenceInCalendarMonths:l,addMonths:u,startOfMonth:d}=r;return n&&l(n,c)<s-1&&(c=u(n,-1*(s-1))),t&&l(c,t)<0&&(c=t),d(c)}function ow(e,t,n,r){let{addDays:i,endOfBroadcastWeek:a,endOfISOWeek:o,endOfMonth:s,endOfWeek:c,getISOWeek:l,getWeek:u,startOfBroadcastWeek:d,startOfISOWeek:f,startOfWeek:p}=r,m=e.reduce((e,m)=>{let h=n.broadcastCalendar?d(m,r):n.ISOWeek?f(m):p(m),g=n.broadcastCalendar?a(m):n.ISOWeek?o(s(m)):c(s(m)),_=t.filter(e=>e>=h&&e<=g),v=n.broadcastCalendar?35:42;if(n.fixedWeeks&&_.length<v){let e=t.filter(e=>{let t=v-_.length;return e>g&&e<=i(g,t)});_.push(...e)}let y=new DS(m,_.reduce((e,t)=>{let i=n.ISOWeek?l(t):u(t),a=e.find(e=>e.weekNumber===i),o=new ES(t,m,r);return a?a.days.push(o):e.push(new OS(i,[o])),e},[]));return e.push(y),e},[]);return n.reverseMonths?m.reverse():m}function sw(e,t){let{startMonth:n,endMonth:r}=e,{startOfYear:i,startOfDay:a,startOfMonth:o,endOfMonth:s,addYears:c,endOfYear:l,today:u}=t,d=e.captionLayout===`dropdown`||e.captionLayout===`dropdown-years`;return n?n=o(n):!n&&d&&(n=i(c(e.today??u(),-100))),r?r=s(r):!r&&d&&(r=l(e.today??u())),[n&&a(n),r&&a(r)]}function cw(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a=1}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a:1,u=o(e);if(!t||!(c(t,e)<a))return s(u,l)}function lw(e,t,n,r){if(n.disableNavigation)return;let{pagedNavigation:i,numberOfMonths:a}=n,{startOfMonth:o,addMonths:s,differenceInCalendarMonths:c}=r,l=i?a??1:1,u=o(e);if(!t||!(c(u,t)<=0))return s(u,-l)}function uw(e){return e.reduce((e,t)=>e.concat(t.weeks.slice()),[].slice())}function dw(e,t){let[n,r]=(0,Y.useState)(e);return[t===void 0?n:t,r]}function fw(e,t){let[n,r]=sw(e,t),{startOfMonth:i,endOfMonth:a}=t,o=aw(e,n,r,t),[s,c]=dw(o,e.month?o:void 0);(0,Y.useEffect)(()=>{let i=aw(e,n,r,t);c(i)},[e.timeZone]);let{months:l,weeks:u,days:d,previousMonth:f,nextMonth:p}=(0,Y.useMemo)(()=>{let i=iw(s,r,{numberOfMonths:e.numberOfMonths},t),o=ow(i,nw(i,e.endMonth?a(e.endMonth):void 0,{ISOWeek:e.ISOWeek,fixedWeeks:e.fixedWeeks,broadcastCalendar:e.broadcastCalendar},t),{broadcastCalendar:e.broadcastCalendar,fixedWeeks:e.fixedWeeks,ISOWeek:e.ISOWeek,reverseMonths:e.reverseMonths},t);return{months:o,weeks:uw(o),days:rw(o),previousMonth:lw(s,n,e,t),nextMonth:cw(s,r,e,t)}},[t,s.getTime(),r?.getTime(),n?.getTime(),e.disableNavigation,e.broadcastCalendar,e.endMonth?.getTime(),e.fixedWeeks,e.ISOWeek,e.numberOfMonths,e.pagedNavigation,e.reverseMonths]),{disableNavigation:m,onMonthChange:h}=e,g=e=>u.some(t=>t.days.some(t=>t.isEqualTo(e))),_=e=>{if(m)return;let t=i(e);n&&t<i(n)&&(t=i(n)),r&&t>i(r)&&(t=i(r)),c(t),h?.(t)};return{months:l,weeks:u,days:d,navStart:n,navEnd:r,previousMonth:f,nextMonth:p,goToMonth:_,goToDay:e=>{g(e)||_(e.date)}}}var pw;(function(e){e[e.Today=0]=`Today`,e[e.Selected=1]=`Selected`,e[e.LastFocused=2]=`LastFocused`,e[e.FocusedModifier=3]=`FocusedModifier`})(pw||={});function mw(e){return!e[NS.disabled]&&!e[NS.hidden]&&!e[NS.outside]}function hw(e,t,n,r){let i,a=-1;for(let o of e){let e=t(o);mw(e)&&(e[NS.focused]&&a<pw.FocusedModifier?(i=o,a=pw.FocusedModifier):r?.isEqualTo(o)&&a<pw.LastFocused?(i=o,a=pw.LastFocused):n(o.date)&&a<pw.Selected?(i=o,a=pw.Selected):e[NS.today]&&a<pw.Today&&(i=o,a=pw.Today))}return i||=e.find(e=>mw(t(e))),i}function gw(e,t,n,r,i,a,o){let{ISOWeek:s,broadcastCalendar:c}=a,{addDays:l,addMonths:u,addWeeks:d,addYears:f,endOfBroadcastWeek:p,endOfISOWeek:m,endOfWeek:h,max:g,min:_,startOfBroadcastWeek:v,startOfISOWeek:y,startOfWeek:b}=o,x={day:l,week:d,month:u,year:f,startOfWeek:e=>c?v(e,o):s?y(e):b(e),endOfWeek:e=>c?p(e):s?m(e):h(e)}[e](n,t===`after`?1:-1);return t===`before`&&r?x=g([r,x]):t===`after`&&i&&(x=_([i,x])),x}function _w(e,t,n,r,i,a,o,s=0){if(s>365)return;let c=gw(e,t,n.date,r,i,a,o),l=!!(a.disabled&&pC(c,a.disabled,o)),u=!!(a.hidden&&pC(c,a.hidden,o)),d=new ES(c,c,o);return!l&&!u?d:_w(e,t,d,r,i,a,o,s+1)}function vw(e,t,n,r,i){let{autoFocus:a}=e,[o,s]=(0,Y.useState)(),c=hw(t.days,n,r||(()=>!1),o),[l,u]=(0,Y.useState)(a?c:void 0);return{isFocusTarget:e=>!!c?.isEqualTo(e),setFocused:u,focused:l,blur:()=>{s(l),u(void 0)},moveFocus:(n,r)=>{if(!l)return;let a=_w(n,r,l,t.navStart,t.navEnd,e,i);a&&(!e.disableNavigation||t.days.some(e=>e.isEqualTo(a)))&&(t.goToDay(a),u(a))}}}function yw(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=dw(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t,l=e=>s?.some(t=>c(t,e))??!1,{min:u,max:d}=e;return{selected:s,select:(e,t,n)=>{let a=[...s??[]];if(l(e)){if(s?.length===u||r&&s?.length===1)return;a=s?.filter(t=>!c(t,e))}else a=s?.length===d?[e]:[...a,e];return i||o(a),i?.(a,e,t,n),a},isSelected:l}}function bw(e,t,n=0,r=0,i=!1,a=TS){let{from:o,to:s}=t||{},{isSameDay:c,isAfter:l,isBefore:u}=a,d;if(!o&&!s)d={from:e,to:n>0?void 0:e};else if(o&&!s)d=c(o,e)?n===0?{from:o,to:e}:i?{from:o,to:void 0}:void 0:u(e,o)?{from:e,to:o}:{from:o,to:e};else if(o&&s){if(c(o,e)&&c(s,e))d=i?{from:o,to:s}:void 0;else if(c(o,e))d={from:o,to:n>0?void 0:e};else if(c(s,e))d={from:e,to:n>0?void 0:e};else if(u(e,o))d={from:e,to:s};else if(l(e,o))d={from:o,to:e};else if(l(e,s))d={from:o,to:e};else throw Error(`Invalid range`)}if(d?.from&&d?.to){let t=a.differenceInCalendarDays(d.to,d.from);(r>0&&t>r||n>1&&t<n)&&(d={from:e,to:void 0})}return d}function xw(e,t,n=TS){let r=Array.isArray(t)?t:[t],i=e.from,a=n.differenceInCalendarDays(e.to,e.from),o=Math.min(a,6);for(let e=0;e<=o;e++){if(r.includes(i.getDay()))return!0;i=n.addDays(i,1)}return!1}function Sw(e,t,n=TS){return oC(e,t.from,!1,n)||oC(e,t.to,!1,n)||oC(t,e.from,!1,n)||oC(t,e.to,!1,n)}function Cw(e,t,n=TS){let r=Array.isArray(t)?t:[t];if(r.filter(e=>typeof e!=`function`).some(t=>typeof t==`boolean`?t:n.isDate(t)?oC(e,t,!1,n):fC(t,n)?t.some(t=>oC(e,t,!1,n)):cC(t)?t.from&&t.to?Sw(e,{from:t.from,to:t.to},n):!1:dC(t)?xw(e,t.dayOfWeek,n):sC(t)?n.isAfter(t.before,t.after)?Sw(e,{from:n.addDays(t.after,1),to:n.addDays(t.before,-1)},n):pC(e.from,t,n)||pC(e.to,t,n):lC(t)||uC(t)?pC(e.from,t,n)||pC(e.to,t,n):!1))return!0;let i=r.filter(e=>typeof e==`function`);if(i.length){let t=e.from,r=n.differenceInCalendarDays(e.to,e.from);for(let e=0;e<=r;e++){if(i.some(e=>e(t)))return!0;t=n.addDays(t,1)}}return!1}function ww(e,t){let{disabled:n,excludeDisabled:r,resetOnSelect:i,selected:a,required:o,onSelect:s}=e,[c,l]=dw(a,s?a:void 0),u=s?a:c;return{selected:u,select:(a,c,d)=>{let{min:f,max:p}=e,m;if(a){let e=u?.from,n=u?.to,r=!!e&&!!n,s=!!e&&!!n&&t.isSameDay(e,n)&&t.isSameDay(a,e);m=i&&(r||!u?.from)?!o&&s?void 0:{from:a,to:void 0}:bw(a,u,f,p,o,t)}return r&&n&&m?.from&&m.to&&Cw({from:m.from,to:m.to},n,t)&&(m.from=a,m.to=void 0),s||l(m),s?.(m,a,c,d),m},isSelected:e=>u&&oC(u,e,!1,t)}}function Tw(e,t){let{selected:n,required:r,onSelect:i}=e,[a,o]=dw(n,i?n:void 0),s=i?n:a,{isSameDay:c}=t;return{selected:s,select:(e,t,n)=>{let a=e;return!r&&s&&s&&c(e,s)&&(a=void 0),i||o(a),i?.(a,e,t,n),a},isSelected:e=>s?c(s,e):!1}}function Ew(e,t){let n=Tw(e,t),r=yw(e,t),i=ww(e,t);switch(e.mode){case`single`:return n;case`multiple`:return r;case`range`:return i;default:return}}function Dw(e,t){return e instanceof _S&&e.timeZone===t?e:new _S(e,t)}function Ow(e,t,n){if(!n)return Dw(e,t);let r=Dw(e,t),i=new _S(r.getFullYear(),r.getMonth(),r.getDate(),12,0,0,t);return new Date(i.getTime())}function kw(e,t,n){return typeof e==`boolean`||typeof e==`function`?e:e instanceof Date?Ow(e,t,n):Array.isArray(e)?e.map(e=>e instanceof Date?Ow(e,t,n):e):cC(e)?{...e,from:e.from?Dw(e.from,t):e.from,to:e.to?Dw(e.to,t):e.to}:sC(e)?{before:Ow(e.before,t,n),after:Ow(e.after,t,n)}:lC(e)?{after:Ow(e.after,t,n)}:uC(e)?{before:Ow(e.before,t,n)}:e}function Aw(e,t,n){return e&&(Array.isArray(e)?e.map(e=>kw(e,t,n)):kw(e,t,n))}function jw(e){let t=e,n=t.timeZone;if(n&&(t={...e,timeZone:n},t.today&&(t.today=Dw(t.today,n)),t.month&&(t.month=Dw(t.month,n)),t.defaultMonth&&(t.defaultMonth=Dw(t.defaultMonth,n)),t.startMonth&&(t.startMonth=Dw(t.startMonth,n)),t.endMonth&&(t.endMonth=Dw(t.endMonth,n)),t.mode===`single`&&t.selected?t.selected=Dw(t.selected,n):t.mode===`multiple`&&t.selected?t.selected=t.selected?.map(e=>Dw(e,n)):t.mode===`range`&&t.selected&&(t.selected={from:t.selected.from?Dw(t.selected.from,n):t.selected.from,to:t.selected.to?Dw(t.selected.to,n):t.selected.to}),t.disabled!==void 0&&(t.disabled=Aw(t.disabled,n)),t.hidden!==void 0&&(t.hidden=Aw(t.hidden,n)),t.modifiers)){let e={};Object.keys(t.modifiers).forEach(r=>{e[r]=Aw(t.modifiers?.[r],n)}),t.modifiers=e}let{components:r,formatters:i,labels:a,dateLib:o,locale:s,classNames:c}=(0,Y.useMemo)(()=>{let e={...CS,...t.locale},n=t.broadcastCalendar?1:t.weekStartsOn,r=t.noonSafe&&t.timeZone?qC(t.timeZone,{weekStartsOn:n,locale:e}):void 0,i=t.dateLib&&r?{...r,...t.dateLib}:t.dateLib??r,a=new wS({locale:e,weekStartsOn:n,firstWeekContainsDate:t.firstWeekContainsDate,useAdditionalWeekYearTokens:t.useAdditionalWeekYearTokens,useAdditionalDayOfYearTokens:t.useAdditionalDayOfYearTokens,timeZone:t.timeZone,numerals:t.numerals},i);return{dateLib:a,components:gC(t.components),formatters:DC(t.formatters),labels:HC(t.labels,a.options),locale:e,classNames:{...vC(),...t.classNames}}},[t.locale,t.broadcastCalendar,t.weekStartsOn,t.firstWeekContainsDate,t.useAdditionalWeekYearTokens,t.useAdditionalDayOfYearTokens,t.timeZone,t.numerals,t.dateLib,t.noonSafe,t.components,t.formatters,t.labels,t.classNames]);t.today||(t={...t,today:o.today()});let{captionLayout:l,mode:u,navLayout:d,numberOfMonths:f=1,onDayBlur:p,onDayClick:m,onDayFocus:h,onDayKeyDown:g,onDayMouseEnter:_,onDayMouseLeave:v,onNextClick:y,onPrevClick:b,showWeekNumber:x,styles:S}=t,{formatCaption:C,formatDay:w,formatMonthDropdown:T,formatWeekNumber:E,formatWeekNumberHeader:D,formatWeekdayName:O,formatYearDropdown:k}=i,A=fw(t,o),{days:j,months:M,navStart:N,navEnd:P,previousMonth:F,nextMonth:I,goToMonth:L}=A,ee=mC(j,t,N,P,o),{isSelected:te,select:ne,selected:re}=Ew(t,o)??{},{blur:R,focused:ie,isFocusTarget:ae,moveFocus:oe,setFocused:z}=vw(t,A,ee,te??(()=>!1),o),{labelDayButton:se,labelGridcell:ce,labelGrid:le,labelMonthDropdown:ue,labelNav:de,labelPrevious:fe,labelNext:pe,labelWeekday:B,labelWeekNumber:me,labelWeekNumberHeader:V,labelYearDropdown:he}=a,ge=(0,Y.useMemo)(()=>GC(o,t.ISOWeek,t.broadcastCalendar,t.today),[o,t.ISOWeek,t.broadcastCalendar,t.today]),_e=u!==void 0||m!==void 0,ve=(0,Y.useCallback)(()=>{F&&(L(F),b?.(F))},[F,L,b]),ye=(0,Y.useCallback)(()=>{I&&(L(I),y?.(I))},[L,I,y]),be=(0,Y.useCallback)((e,t)=>n=>{n.preventDefault(),n.stopPropagation(),z(e),!t.disabled&&(ne?.(e.date,t,n),m?.(e.date,t,n))},[ne,m,z]),xe=(0,Y.useCallback)((e,t)=>n=>{z(e),h?.(e.date,t,n)},[h,z]),H=(0,Y.useCallback)((e,t)=>n=>{R(),p?.(e.date,t,n)},[R,p]),Se=(0,Y.useCallback)((e,n)=>r=>{let i={ArrowLeft:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`after`:`before`],ArrowRight:[r.shiftKey?`month`:`day`,t.dir===`rtl`?`before`:`after`],ArrowDown:[r.shiftKey?`year`:`week`,`after`],ArrowUp:[r.shiftKey?`year`:`week`,`before`],PageUp:[r.shiftKey?`year`:`month`,`before`],PageDown:[r.shiftKey?`year`:`month`,`after`],Home:[`startOfWeek`,`before`],End:[`endOfWeek`,`after`]};if(i[r.key]){r.preventDefault(),r.stopPropagation();let[e,t]=i[r.key];oe(e,t)}g?.(e.date,n,r)},[oe,g,t.dir]),Ce=(0,Y.useCallback)((e,t)=>n=>{_?.(e.date,t,n)},[_]),we=(0,Y.useCallback)((e,t)=>n=>{v?.(e.date,t,n)},[v]),Te=(0,Y.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setMonth(o.startOfMonth(e),r);L(o.addMonths(i,-t))},[o,L]),Ee=(0,Y.useCallback)((e,t)=>n=>{let r=Number(n.target.value),i=o.setYear(o.startOfMonth(e),r);L(o.addMonths(i,-t))},[o,L]),{className:De,style:Oe}=(0,Y.useMemo)(()=>({className:[c[$.Root],t.className].filter(Boolean).join(` `),style:{...S?.[$.Root],...t.style}}),[c,t.className,t.style,S]),ke=_C(t),Ae=e=>{let t=S?.[$.Dropdown],n=S?.[e];if(t||n)return{...t,...n}},je=(0,Y.useRef)(null);tw(je,!!t.animate,{classNames:c,months:M,focused:ie,dateLib:o});let Me={dayPickerProps:t,selected:re,select:ne,isSelected:te,months:M,nextMonth:I,previousMonth:F,goToMonth:L,getModifiers:ee,components:r,classNames:c,styles:S,labels:a,formatters:i};return Y.createElement(IS.Provider,{value:Me},Y.createElement(r.Root,{rootRef:t.animate?je:void 0,className:De,style:Oe,dir:t.dir,id:t.id,lang:t.lang??s.code,nonce:t.nonce,title:t.title,role:t.role,"aria-label":t[`aria-label`],"aria-labelledby":t[`aria-labelledby`],...ke},Y.createElement(r.Months,{className:c[$.Months],style:S?.[$.Months]},!t.hideNavigation&&!d&&Y.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[$.Nav],style:S?.[$.Nav],"aria-label":de(),onPreviousClick:ve,onNextClick:ye,previousMonth:F,nextMonth:I}),M.map((e,n)=>{let a=t.reverseMonths?M.length-1-n:n;return Y.createElement(r.Month,{"data-animated-month":t.animate?`true`:void 0,className:c[$.Month],style:S?.[$.Month],key:n,displayIndex:n,calendarMonth:e},d===`around`&&!t.hideNavigation&&n===0&&Y.createElement(r.PreviousMonthButton,{type:`button`,className:c[$.PreviousMonthButton],style:S?.[$.PreviousMonthButton],tabIndex:F?void 0:-1,"aria-disabled":!F||void 0,"aria-label":fe(F),onClick:ve,"data-animated-button":t.animate?`true`:void 0},Y.createElement(r.Chevron,{disabled:!F||void 0,className:c[$.Chevron],style:S?.[$.Chevron],orientation:t.dir===`rtl`?`right`:`left`})),Y.createElement(r.MonthCaption,{"data-animated-caption":t.animate?`true`:void 0,className:c[$.MonthCaption],style:S?.[$.MonthCaption],calendarMonth:e,displayIndex:n},l?.startsWith(`dropdown`)?Y.createElement(r.DropdownNav,{className:c[$.Dropdowns],style:S?.[$.Dropdowns]},(()=>{let n=l===`dropdown`||l===`dropdown-months`?Y.createElement(r.MonthsDropdown,{key:`month`,className:c[$.MonthsDropdown],"aria-label":ue(),disabled:!!t.disableNavigation,onChange:Te(e.date,a),options:UC(e.date,N,P,i,o),style:Ae($.MonthsDropdown),value:o.getMonth(e.date)}):Y.createElement(`span`,{key:`month`},T(e.date,o)),s=l===`dropdown`||l===`dropdown-years`?Y.createElement(r.YearsDropdown,{key:`year`,className:c[$.YearsDropdown],"aria-label":he(o.options),disabled:!!t.disableNavigation,onChange:Ee(e.date,a),options:KC(N,P,i,o,!!t.reverseYears),style:Ae($.YearsDropdown),value:o.getYear(e.date)}):Y.createElement(`span`,{key:`year`},k(e.date,o));return o.getMonthYearOrder()===`year-first`?[s,n]:[n,s]})(),Y.createElement(`span`,{role:`status`,"aria-live":`polite`,style:{border:0,clip:`rect(0 0 0 0)`,height:`1px`,margin:`-1px`,overflow:`hidden`,padding:0,position:`absolute`,width:`1px`,whiteSpace:`nowrap`,wordWrap:`normal`}},C(e.date,o.options,o))):Y.createElement(r.CaptionLabel,{className:c[$.CaptionLabel],style:S?.[$.CaptionLabel],role:`status`,"aria-live":`polite`},C(e.date,o.options,o))),d===`around`&&!t.hideNavigation&&n===f-1&&Y.createElement(r.NextMonthButton,{type:`button`,className:c[$.NextMonthButton],style:S?.[$.NextMonthButton],tabIndex:I?void 0:-1,"aria-disabled":!I||void 0,"aria-label":pe(I),onClick:ye,"data-animated-button":t.animate?`true`:void 0},Y.createElement(r.Chevron,{disabled:!I||void 0,className:c[$.Chevron],style:S?.[$.Chevron],orientation:t.dir===`rtl`?`left`:`right`})),n===f-1&&d===`after`&&!t.hideNavigation&&Y.createElement(r.Nav,{"data-animated-nav":t.animate?`true`:void 0,className:c[$.Nav],style:S?.[$.Nav],"aria-label":de(),onPreviousClick:ve,onNextClick:ye,previousMonth:F,nextMonth:I}),Y.createElement(r.MonthGrid,{role:`grid`,"aria-multiselectable":u===`multiple`||u===`range`,"aria-label":le(e.date,o.options,o)||void 0,className:c[$.MonthGrid],style:S?.[$.MonthGrid]},!t.hideWeekdays&&Y.createElement(r.Weekdays,{"data-animated-weekdays":t.animate?`true`:void 0,className:c[$.Weekdays],style:S?.[$.Weekdays]},x&&Y.createElement(r.WeekNumberHeader,{"aria-label":V(o.options),className:c[$.WeekNumberHeader],style:S?.[$.WeekNumberHeader],scope:`col`},D()),ge.map(e=>Y.createElement(r.Weekday,{"aria-label":B(e,o.options,o),className:c[$.Weekday],key:String(e),style:S?.[$.Weekday],scope:`col`},O(e,o.options,o)))),Y.createElement(r.Weeks,{"data-animated-weeks":t.animate?`true`:void 0,className:c[$.Weeks],style:S?.[$.Weeks]},e.weeks.map(e=>Y.createElement(r.Week,{className:c[$.Week],key:e.weekNumber,style:S?.[$.Week],week:e},x&&Y.createElement(r.WeekNumber,{week:e,style:S?.[$.WeekNumber],"aria-label":me(e.weekNumber,{locale:s}),className:c[$.WeekNumber],scope:`row`,role:`rowheader`},E(e.weekNumber,o)),e.days.map(e=>{let{date:n}=e,i=ee(e);
114if(i[NS.focused]=!i.hidden&&!!ie?.isEqualTo(e),i[PS.selected]=te?.(n)||i.selected,cC(re)){let{from:e,to:t}=re;i[PS.range_start]=!!(e&&t&&o.isSameDay(n,e)),i[PS.range_end]=!!(e&&t&&o.isSameDay(n,t)),i[PS.range_middle]=oC(re,n,!0,o)}let a=WC(i,S,t.modifiersStyles),s=hC(i,c,t.modifiersClassNames),l=!_e&&!i.hidden?ce(n,i,o.options,o):void 0;return Y.createElement(r.Day,{key:`${e.isoDate}_${e.displayMonthId}`,day:e,modifiers:i,className:s.join(` `),style:a,role:`gridcell`,"aria-selected":i.selected||void 0,"aria-label":l,"data-day":e.isoDate,"data-month":e.outside?e.dateMonthId:void 0,"data-selected":i.selected||void 0,"data-disabled":i.disabled||void 0,"data-hidden":i.hidden||void 0,"data-outside":e.outside||void 0,"data-focused":i.focused||void 0,"data-today":i.today||void 0},!i.hidden&&_e?Y.createElement(r.DayButton,{className:c[$.DayButton],style:S?.[$.DayButton],type:`button`,day:e,modifiers:i,disabled:!i.focused&&i.disabled||void 0,"aria-disabled":i.focused&&i.disabled||void 0,tabIndex:ae(e)?0:-1,"aria-label":se(n,i,o.options,o),onClick:be(e,i),onBlur:H(e,i),onFocus:xe(e,i),onKeyDown:Se(e,i),onMouseEnter:Ce(e,i),onMouseLeave:we(e,i)},w(n,o.options,o)):!i.hidden&&w(e.date,o.options,o))}))))))})),t.footer&&Y.createElement(r.Footer,{className:c[$.Footer],style:S?.[$.Footer],role:`status`,"aria-live":`polite`},t.footer)))}function Mw({className:e,classNames:t,showOutsideDays:n=!0,captionLayout:r=`label`,buttonVariant:i=`ghost`,locale:a,formatters:o,components:s,...c}){let l=vC();return(0,X.jsx)(jw,{showOutsideDays:n,className:q(`group/calendar bg-background p-3 [--cell-radius:var(--radius-2xl)] [--cell-size:--spacing(8)] in-data-[slot=card-content]:bg-transparent in-data-[slot=popover-content]:bg-transparent`,String.raw`rtl:**:[.rdp-button\_next>svg]:rotate-180`,String.raw`rtl:**:[.rdp-button\_previous>svg]:rotate-180`,e),captionLayout:r,locale:a,formatters:{formatMonthDropdown:e=>e.toLocaleString(a?.code,{month:`short`}),...o},classNames:{root:q(`w-fit`,l.root),months:q(`relative flex flex-col gap-4 md:flex-row`,l.months),month:q(`flex w-full flex-col gap-4`,l.month),nav:q(`absolute inset-x-0 top-0 flex w-full items-center justify-between gap-1`,l.nav),button_previous:q(zt({variant:i}),`size-(--cell-size) p-0 select-none aria-disabled:opacity-50`,l.button_previous),button_next:q(zt({variant:i}),`size-(--cell-size) p-0 select-none aria-disabled:opacity-50`,l.button_next),month_caption:q(`flex h-(--cell-size) w-full items-center justify-center px-(--cell-size)`,l.month_caption),dropdowns:q(`flex h-(--cell-size) w-full items-center justify-center gap-1.5 text-sm font-medium`,l.dropdowns),dropdown_root:q(`relative rounded-(--cell-radius)`,l.dropdown_root),dropdown:q(`absolute inset-0 bg-popover opacity-0`,l.dropdown),caption_label:q(`font-medium select-none`,r===`label`?`text-sm`:`flex items-center gap-1 rounded-(--cell-radius) text-sm [&>svg]:size-3.5 [&>svg]:text-muted-foreground`,l.caption_label),month_grid:q(`w-full border-collapse`,l.month_grid),weekdays:q(`flex`,l.weekdays),weekday:q(`flex-1 rounded-(--cell-radius) text-[0.8rem] font-normal text-muted-foreground select-none`,l.weekday),week:q(`mt-2 flex w-full`,l.week),week_number_header:q(`w-(--cell-size) select-none`,l.week_number_header),week_number:q(`text-[0.8rem] text-muted-foreground select-none`,l.week_number),day:q(`group/day relative aspect-square h-full w-full rounded-(--cell-radius) p-0 text-center select-none [&:last-child[data-selected=true]_button]:rounded-r-(--cell-radius)`,c.showWeekNumber?`[&:nth-child(2)[data-selected=true]_button]:rounded-l-(--cell-radius)`:`[&:first-child[data-selected=true]_button]:rounded-l-(--cell-radius)`,l.day),range_start:q(`relative isolate z-0 rounded-l-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:right-0 after:w-4 after:bg-muted`,l.range_start),range_middle:q(`rounded-none`,l.range_middle),range_end:q(`relative isolate z-0 rounded-r-(--cell-radius) bg-muted after:absolute after:inset-y-0 after:left-0 after:w-4 after:bg-muted`,l.range_end),today:q(`rounded-(--cell-radius) bg-muted text-foreground data-[selected=true]:rounded-none`,l.today),outside:q(`text-muted-foreground aria-selected:text-muted-foreground`,l.outside),disabled:q(`text-muted-foreground opacity-50`,l.disabled),hidden:q(`invisible`,l.hidden),...t}
114,components:{Root:({className:e,rootRef:t,...n})=>(0,X.jsx)(`div`,{"data-slot":`calendar`,ref:t,className:q(e),...n}),Chevron:({className:e,orientation:t,...n})=>t===`left`?(0,X.jsx)(Zi,{className:q(`size-4`,e),...n}):t===`right`?(0,X.jsx)(Er,{className:q(`size-4`,e),...n}):(0,X.jsx)(Ka,{className:q(`size-4`,e),...n}),DayButton:({...e})=>(0,X.jsx)(Nw,{locale:a,...e}),WeekNumber:({children:e,...t})=>(0,X.jsx)(`td`,{...t,children:(0,X.jsx)(`div`,{className:`flex size-(--cell-size) items-center justify-center text-center`,children:e})}),...s},...c})}function Nw({className:e,day:t,modifiers:n,locale:r,...i}){let a=vC(),o=Y.useRef(null);return Y.useEffect(()=>{n.focused&&o.current?.focus()},[n.focused]),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,"data-day":t.date.toLocaleDateString(r?.code),"data-selected-single":n.selected&&!n.range_start&&!n.range_end&&!n.range_middle,"data-range-start":n.range_start,"data-range-end":n.range_end,"data-range-middle":n.range_middle,className:q(`relative isolate z-10 flex aspect-square size-auto w-full min-w-(--cell-size) flex-col gap-1 border-0 leading-none font-normal group-data-[focused=true]/day:relative group-data-[focused=true]/day:z-10 group-data-[focused=true]/day:border-ring group-data-[focused=true]/day:ring-[3px] group-data-[focused=true]/day:ring-ring/50 data-[range-end=true]:rounded-(--cell-radius) data-[range-end=true]:rounded-r-(--cell-radius) data-[range-end=true]:bg-primary data-[range-end=true]:text-primary-foreground data-[range-middle=true]:rounded-none data-[range-middle=true]:bg-muted data-[range-middle=true]:text-foreground data-[range-start=true]:rounded-(--cell-radius) data-[range-start=true]:rounded-l-(--cell-radius) data-[range-start=true]:bg-primary data-[range-start=true]:text-primary-foreground data-[selected-single=true]:bg-primary data-[selected-single=true]:text-primary-foreground dark:hover:text-foreground [&>span]:text-xs [&>span]:opacity-70`,a.day,e),...i})}function Pw(e){let[t,n]=(0,Y.useState)(null),r=(0,Y.useRef)(e);return(0,Y.useEffect)(()=>{r.current=e}),(0,Y.useEffect)(()=>{if(!t)return;let e=P.get$(`file.response`).pipe(O(e=>e.source===t)).subscribe(e=>{if(e.payload&&`files`in e.payload){let t=e.payload.files[0];t&&r.current({id:t.id,url:t.url,mimetype:t.mimetype,metadata:t.metadata??{}})}n(null)});return()=>e.unsubscribe()},[t]),{requestFile:(0,Y.useCallback)((e,t)=>{let r=xr();n(r),P.publish({type:`file.request`,id:r,payload:{fileType:e,multiple:!1,title:t,uploadOnly:!1}})},[])}}var Fw={image:`image`,video:`video`,file:`any`},Iw={image:`Select Image`,video:`Select Video`,file:`Select File`},Lw={image:`Image`,video:`Video`,file:`File`},Rw={image:Ri,video:Si,file:wi};function zw({onReplace:e,onRemove:t,className:n}){return(0,X.jsxs)(`div`,{className:q(`absolute top-2 right-2 flex gap-1.5`,n),children:[(0,X.jsx)(U,{type:`button`,size:`icon`,variant:`outline`,className:`size-8 rounded-full border-border/80 bg-background/95 text-foreground shadow-md backdrop-blur-sm hover:bg-background`,"aria-label":`Replace`,onClick:e,children:(0,X.jsx)(wi,{className:`size-4`})}),(0,X.jsx)(U,{type:`button`,size:`icon`,className:`size-8 rounded-full bg-destructive text-destructive-foreground shadow-md hover:bg-destructive/90`,"aria-label":`Remove`,onClick:t,children:(0,X.jsx)(so,{className:`size-4`,strokeWidth:2.5})})]})}function Bw({variant:e,propertyName:t,value:n,onChange:r}){let{requestFile:i}=Pw(e=>{r({fileid:e.id,url:e.url,mimetype:e.mimetype,filename:e.metadata.filename??``,alt:e.metadata.alt??n?.alt??``})}),a=()=>i(Fw[e],Iw[e]);if(!n?.url){let t=Rw[e];return(0,X.jsxs)(U,{type:`button`,variant:`outline`,className:`w-full justify-start`,onClick:a,children:[(0,X.jsx)(t,{className:`mr-2 size-4`}),`Select `,Lw[e]]})}return(0,X.jsxs)(`div`,{className:`space-y-2`,children:[e===`image`&&(0,X.jsxs)(`div`,{className:`relative w-full`,children:[(0,X.jsx)(`img`,{src:n.url,alt:n.alt||`Preview`,className:`block w-full rounded-lg`}),(0,X.jsx)(zw,{onReplace:a,onRemove:()=>r(null)})]}),e===`video`&&(0,X.jsxs)(`div`,{className:`relative w-full`,children:[(0,X.jsx)(`video`,{src:n.url,controls:!0,className:`block aspect-video w-full rounded-lg bg-black`}),(0,X.jsx)(zw,{onReplace:a,onRemove:()=>r(null)})]}),e===`file`&&(0,X.jsxs)(`div`,{className:`relative flex items-center gap-2.5 rounded-lg border border-border bg-muted/20 p-2.5`,children:[(0,X.jsx)(`div`,{className:`flex size-7 shrink-0 items-center justify-center rounded bg-muted`,children:(0,X.jsx)(oa,{className:`size-3.5 text-muted-foreground`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 pr-[4.5rem]`,children:[(0,X.jsx)(`p`,{className:`truncate text-sm`,children:n.filename||`File`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`File selected`})]}),(0,X.jsx)(zw,{className:`top-1.5 right-1.5`,onReplace:a,onRemove:()=>r(null)})]}),e===`image`&&(0,X.jsxs)(G,{children:[(0,X.jsxs)(K,{htmlFor:`${t}-alt`,className:`text-sm`,children:[`Alt Text`,(0,X.jsx)(`span`,{className:`ml-2 text-muted-foreground`,children:`(for accessibility)`})]}),(0,X.jsx)(W,{id:`${t}-alt`,value:n.alt||``,onChange:e=>r({...n,alt:e.target.value}),placeholder:`Describe this image for screen readers`})]})]})}Bw.displayName=`FilePickerField`;function Vw({propertyName:e,value:t,onChange:n}){return(0,X.jsx)(W,{id:e,type:`url`,value:t??``,onChange:e=>n(e.target.value),placeholder:`https://example.com/embed`})}Vw.displayName=`IframeField`;function Hw({id:e,value:t,onChange:n,rows:r=6}){return(0,X.jsxs)(pu,{defaultValue:`write`,children:[(0,X.jsxs)(hu,{variant:`line`,children:[(0,X.jsx)(gu,{value:`write`,children:`Write`}),(0,X.jsx)(gu,{value:`preview`,children:`Preview`})]}),(0,X.jsx)(_u,{value:`write`,children:(0,X.jsx)(bt,{id:e,value:t||``,onChange:e=>n(e.target.value),rows:r,placeholder:`Write markdown…`})}),(0,X.jsx)(_u,{value:`preview`,children:(0,X.jsx)(`div`,{className:Vx(`min-h-20 rounded-md border border-input bg-muted/10 px-3 py-2`),children:t?(0,X.jsx)(Fv,{remarkPlugins:[zx],components:Bx,children:t}):(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground italic`,children:`Nothing to preview`})})})]})}Hw.displayName=`MarkdownEditorField`;
114function Uw({value:e,onChange:t}){return(0,X.jsxs)(Vt,{value:e??``,onValueChange:e=>t(e),children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{placeholder:`Select placement`})}),(0,X.jsx)(Dt,{children:tS.map(e=>(0,X.jsx)(yn,{value:e.value,children:e.label},e.value))})]})}Uw.displayName=`PlacementField`;function Ww({value:e,onChange:t}){return(0,X.jsxs)(Vt,{value:e??``,onValueChange:e=>t(e),children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{placeholder:`Select a template`})}),(0,X.jsx)(Dt,{children:eS.map(e=>(0,X.jsx)(yn,{value:e.value,children:e.label},e.value))})]})}Ww.displayName=`TemplateField`;function Gw(e){return typeof e==`string`?{mode:`url`,url:e}:e??{mode:`url`}}function Kw({propertyName:e,value:t,onChange:n}){let r=Gw(t);return(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`inline-flex rounded-md border border-border p-0.5`,children:[(0,X.jsx)(U,{type:`button`,size:`sm`,variant:r.mode===`file`?`default`:`ghost`,className:`h-7 px-3`,onClick:()=>n({...r,mode:`file`}),children:`File`}),(0,X.jsx)(U,{type:`button`,size:`sm`,variant:r.mode===`url`?`default`:`ghost`,className:`h-7 px-3`,onClick:()=>n({...r,mode:`url`}),children:`URL`})]}),r.mode===`file`?(0,X.jsx)(Bw,{variant:`video`,propertyName:e,value:r.file,onChange:e=>n({...r,mode:`file`,file:e})}):(0,X.jsx)(W,{type:`url`,value:r.url??``,onChange:e=>n({...r,mode:`url`,url:e.target.value}),placeholder:`https://youtu.be/...`})]})}Kw.displayName=`VideoField`;function qw({collectionField:e,form:t}){let n=`properties.${e.propertyName}`;return e.type===`layout-divider`?(0,X.jsxs)(`div`,{className:`py-2`,children:[(0,X.jsx)(gn,{}),e.name&&(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:e.name})]},e.id):(0,X.jsx)(`div`,{className:`space-y-2`,children:(0,X.jsx)(h,{name:n,control:t.control,render:({field:t,fieldState:n})=>(0,X.jsxs)(G,{"data-invalid":n.invalid,children:[(0,X.jsxs)(K,{htmlFor:e.propertyName,children:[e.name,e.required&&(0,X.jsx)(`span`,{className:`ml-1 text-destructive`,children:`*`})]}),e.helpText&&(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e.helpText}),e.type===`text`&&(0,X.jsx)(W,{id:e.propertyName,value:t.value||``,onChange:e=>t.onChange(e.target.value)}),e.type===`formatted-text`&&(0,X.jsx)(Hw,{id:e.propertyName,value:t.value||``,onChange:t.onChange}),e.type===`number`&&(0,X.jsx)(W,{id:e.propertyName,type:`number`,value:t.value||``,onChange:e=>t.onChange(parseFloat(e.target.value))}),(e.type===`date`||e.type===`datetime`)&&(0,X.jsxs)(jn,{children:[(0,X.jsx)(Kn,{render:e=>(0,X.jsxs)(U,{variant:`outline`,className:`w-full justify-start`,...e,children:[(0,X.jsx)(da,{className:`mr-2 size-4`}),t.value?$i(new Date(t.value),`PPP`):`Pick a date`]})}),(0,X.jsx)(ur,{className:`w-auto p-0`,align:`start`,children:(0,X.jsx)(Mw,{mode:`single`,selected:t.value?new Date(t.value):void 0,onSelect:e=>t.onChange(e?.toISOString().split(`T`)[0])})})]}),e.type===`toggle`&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Cn,{id:e.propertyName,checked:t.value||!1,onCheckedChange:e=>t.onChange(e)}),(0,X.jsx)(`label`,{htmlFor:e.propertyName,className:`cursor-pointer text-sm`,children:t.value?`Enabled`:`Disabled`})]}),e.type===`color`&&(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(W,{type:`color`,value:t.value||`#000000`,onChange:e=>t.onChange(e.target.value),className:`w-20`}),(0,X.jsx)(W,{value:t.value||`#000000`,onChange:e=>t.onChange(e.target.value),placeholder:`#000000`})]}),e.type===`link`&&(0,X.jsx)(W,{id:e.propertyName,type:`url`,value:t.value||``,onChange:e=>t.onChange(e.target.value),placeholder:`https://example.com`}),e.type===`option`&&(0,X.jsxs)(Vt,{value:t.value||``,onValueChange:e=>t.onChange(e),children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{})}),(0,X.jsx)(Dt,{children:e.options?.options?.map(e=>(0,X.jsx)(yn,{value:e.value,children:e.label},e.value))})]}),e.type===`reference`&&(0,X.jsxs)(Vt,{value:t.value||``,onValueChange:e=>t.onChange(e),children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{})}),(0,X.jsx)(Dt,{children:(0,X.jsx)(yn,{value:`placeholder`,children:`Select a reference`})})]}),(e.type===`image`||e.type===`file`)&&(0,X.jsx)(Bw,{variant:e.type,propertyName:e.propertyName,value:t.value,onChange:t.onChange}),e.type===`video`&&(0,X.jsx)(Kw,{propertyName:e.propertyName,value:t.value,onChange:t.onChange}),e.type===`group`&&(0,X.jsxs)(Vt,{value:t.value||``,onValueChange:e=>t.onChange(e),children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{})}),(0,X.jsx)(Dt,{children:e.options?.choices?.map(e=>(0,X.jsx)(yn,{value:e,children:e},e))})]}),e.type===`iframe`&&(0,X.jsx)(Vw,{propertyName:e.propertyName,value:t.value,onChange:t.onChange}),e.type===`template`&&(0,X.jsx)(Ww,{value:t.value,onChange:t.onChange}),e.type===`placement`&&(0,X.jsx)(Uw,{value:t.value,onChange:t.onChange}),e.type===`gallery`&&(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(W,{type:`file`,multiple:!0,accept:`image/*`,onCh
114ange:e=>{let n=Array.from(e.target.files||[]).map(e=>URL.createObjectURL(e));t.onChange([...t.value||[],...n])}}),t.value&&Array.isArray(t.value)&&t.value.length>0&&(0,X.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[t.value.length,` image(s) uploaded`]})]}),e.type===`multi-reference`&&(0,X.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:`Multi-reference field (not fully implemented)`}),n.error&&(0,X.jsx)(kt,{errors:[n.error]})]})})},e.id)}function Jw({collection:e,open:t,setOpen:n,entry:r=void 0,desktopContainer:i}){let a=Fn(),[o,s]=(0,Y.useState)(!1),c=aS(e);return!a&&i?(0,X.jsx)(Yw,{collection:e,open:t,setOpen:n,entry:r,container:i}):(0,X.jsx)(Ln,{open:t,onOpenChange:e=>n(e?r:void 0),children:(0,X.jsxs)(Vn,{className:`flex w-full flex-col overflow-y-auto p-0 sm:max-w-2xl`,"data-quick-help":`content-item-editor`,children:[(0,X.jsx)(tr,{className:`border-b px-6 py-4`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-2 pr-8`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(er,{children:r?`Edit Item`:`Create Item`}),(0,X.jsx)(gr,{className:`mt-1`,children:e.name})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(Hl,{guideId:`content-item-editor`,iconOnly:!0}),c&&(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>s(!0),children:[(0,X.jsx)(Rr,{className:`size-4`,"aria-hidden":`true`}),`Preview`]})]})]})}),(0,X.jsx)(Xw,{collection:e,entry:r,setOpen:n,previewOpen:c?o:void 0,onPreviewOpenChange:c?s:void 0})]},e.id+r?.id)})}function Yw({collection:e,open:t,setOpen:n,entry:r=void 0,container:i}){let[a,o]=(0,Y.useState)(t),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),d=aS(e),f=t||a;return(0,Y.useEffect)(()=>{if(!f)return;let e=requestAnimationFrame(()=>{t&&o(!0),c(t)});return()=>cancelAnimationFrame(e)},[f,t]),f?(0,Rs.createPortal)((0,X.jsx)(`div`,{"data-state":s?`open`:`closed`,onTransitionEnd:e=>{e.propertyName===`width`&&!t&&o(!1)},className:`ml-2 h-full w-0 overflow-hidden transition-[width] duration-300 ease-in-out data-[state=open]:w-md`,children:(0,X.jsxs)(`div`,{className:q(`flex h-full w-md flex-col overflow-y-auto rounded-xl bg-background`,$n({style:`base`})),"data-quick-help":`content-item-editor`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between border-b px-6 py-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`text-lg font-semibold`,children:r?`Edit Item`:`Create Item`}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:e.name})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(Hl,{guideId:`content-item-editor`,iconOnly:!0}),d&&(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>u(!0),children:[(0,X.jsx)(Rr,{className:`size-4`,"aria-hidden":`true`}),`Preview`]}),(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>n(void 0),"aria-label":`Close editor`,children:(0,X.jsx)(so,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,X.jsx)(Xw,{collection:e,entry:r,setOpen:n,previewOpen:d?l:void 0,onPreviewOpenChange:d?u:void 0})]},e.id+r?.id)}),i):null}var Xw=({collection:e,entry:t=void 0,setOpen:n,fn:r,previewOpen:i,onPreviewOpenChange:a})=>{let o=R(),s=fe(),{hasPermissions:c}=z(),u=md(),d=c(u,`cms`,`create`),f=c(u,`cms`,`update`),p=t?f:d,m=o.cms.entries.list.queryKey(),g=o.cms.entries.update.mutationOptions({onSuccess:()=>{s.invalidateQueries({queryKey:m})}}),v=B(g),y=o.cms.entries.create.mutationOptions({onSuccess:()=>{s.invalidateQueries({queryKey:m})}}),b=B(y),x=Kd(e.fields||[]),S=l({resolver:pn(x),defaultValues:{id:t?t.id:void 0,collectionId:t?t.collectionId:e.id,name:t?t.name:``,slug:t?t.slug:``,status:t?t.status:`draft`,properties:t?t.properties:{}}}),C=i=>{let a=new Date,o={id:t?i.id:xr(),name:i.name,slug:i.slug,status:i.status,properties:i.properties,collectionId:e.id,updatedAt:a};
114t?v.mutate([o]):(b.mutate([o]),r&&r()),n&&n(void 0),S.reset()};function w(){return v.isPending||b.isPending?t?`Saving...`:`Creating...`:t?`Save Changes`:`Create Item`}return(0,X.jsxs)(_,{...S,children:[a&&(0,X.jsx)(iS,{collection:e,open:!!i,onClose:()=>a(!1)}),(0,X.jsxs)(`form`,{onSubmit:S.handleSubmit(C),className:`flex-1 overflow-y-auto`,children:[(0,X.jsxs)(`div`,{className:`space-y-6 px-6 py-6`,"data-quick-help":`content-item-details`,children:[(0,X.jsx)(h,{name:`name`,control:S.control,render:({field:e,fieldState:t})=>{let n=t=>{e.onChange(t.target.value),S.setValue(`slug`,Bd(t.target.value))};return(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`name`,children:`Name`}),(0,X.jsx)(W,{id:`name`,...e,onChange:n,placeholder:`Entry name`}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}}),(0,X.jsx)(`div`,{className:`space-y-3`,children:(0,X.jsx)(h,{name:`slug`,control:S.control,render:({field:e,fieldState:t})=>{let n=t=>{e.onChange(Bd(t))};return(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`slug`,className:`text-sm`,children:`Slug`}),(0,X.jsx)(W,{id:`slug`,...e,onBlur:e=>n(e.target.value),placeholder:`entry-slug`,className:`font-mono text-sm`}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}})}),(0,X.jsx)(h,{name:`status`,control:S.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`status`,children:`Status`}),(0,X.jsxs)(Vt,{value:e.value,onValueChange:t=>e.onChange(t),children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{})}),(0,X.jsxs)(Dt,{children:[(0,X.jsx)(yn,{value:`draft`,children:`Draft`}),(0,X.jsx)(yn,{value:`published`,children:`Published`}),(0,X.jsx)(yn,{value:`archived`,children:`Archived`})]})]}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsxs)(`div`,{className:`space-y-6`,"data-quick-help":`content-item-fields`,children:[(0,X.jsx)(gn,{}),(0,X.jsx)(`h3`,{className:`text-sm font-medium text-muted-foreground`,children:`Content Fields`}),e.fields?.map(e=>qw({collectionField:e,form:S}))]})]}),p&&(0,X.jsx)(`div`,{className:`sticky bottom-0 border-t bg-background px-6 py-4`,"data-quick-help":`content-item-save`,children:(0,X.jsx)(U,{type:`submit`,className:`w-full`,disabled:v.isPending,children:w()})})]})]})},Zw=()=>{let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(null),[u,d]=(0,Y.useState)({}),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(null),g=R(),_=fe(),v=md(),{data:y}=V(g.cms.collections.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:v},{enabled:!!e&&!!v})),b=n??y?.items?.[0]?.id??null,x=g.cms.entries.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:v,collectionId:b},{enabled:!!e&&!!b&&!!v}),{data:S}=V(x),{data:C,isLoading:w}=V(g.cms.collections.getWithFields.queryOptions([b],{enabled:!!e&&!!b})),{data:T}=V(g.space.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],pagination:{pageIndex:0,pageSize:100}},{enabled:!!e&&i===j.Space})),[E,D]=(0,Y.useState)(``),O=(0,Y.useMemo)(()=>T?.items?T?.items?.filter(e=>e.name.toLowerCase().includes(E.toLowerCase())):[],[T,E]);(0,Y.useEffect)(function(){let e=P.get$(`content.request`).subscribe(e=>{console.log(`content request`,e),e.id&&(p(e.id),a(j.Content),t(!0))});return()=>{e.unsubscribe()}},[]),(0,Y.useEffect)(function(){let e=P.get$(`content-collection.request`).subscribe(e=>{e.id&&(p(e.id),a(j.Content),s(!0),t(!0))});return()=>{e.unsubscribe()}},[]),(0,Y.useEffect)(function(){let e=P.get$(`space.request`).subscribe(e=>{e.id&&(p(e.id),a(j.Space),t(!0))});return()=>{e.unsubscribe()}},[]);let k=g.cms.entries.remove.mutationOptions({onSuccess:()=>{_.invalidateQueries({queryKey:g.cms.entries.list.queryKey()})}}),A=B(k),M=(0,Y.useMemo)(()=>C?.[0]?Rd(C[0],e=>{A.mutate([e.id])}):[],[C,A]),N=()=>{if(console.log(`selectedLinkType`,i),o){if(b){let e=y?.items?.find(e=>e.id===b);P.publish({type:`content-collection.response`,id:xr(),source:f,payload:{collectionId:b,name:e?.name}})}t(!1),p(null),s(!1),r(null),d({});return}if(i===j.Space&&P.publish({type:`space.response`,id:xr(),source:f,payload:{type:i,id:m}}),i===j.Content){let e=Object.keys(u).map(e=>S?.items?.find(t=>
114t.id===e));if(console.log(`selectedEntries`,e),!e?.length)return;P.publish({type:`content.response`,id:xr(),source:f,payload:{type:i,id:e?.[0]?.id}}),console.log(`sending`)}t(!1),p(null),h(null),r(null),s(!1),d({})},F=()=>o?`Collection`:i===j.Content?`Content`:`Space`;return!e||!v?null:(0,X.jsx)(ar,{open:e,onOpenChange:t,children:(0,X.jsxs)(pr,{className:`flex max-h-[85svh] w-full flex-col gap-2 sm:max-w-[60svw]`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsxs)(mr,{children:[`Select `,F()]}),(0,X.jsxs)(_r,{children:[`Link `,F().toLowerCase(),` to the current field`]})]}),(0,X.jsxs)(pu,{value:c??void 0,onValueChange:e=>l(e),defaultValue:i===j.Content?`collections`:i===j.Space?`spaces`:`Create new`,className:`flex h-full w-full flex-1 flex-col overflow-hidden`,children:[(0,X.jsxs)(hu,{className:`border border-neutral-200 bg-neutral-100 shadow-xs dark:border-border/70 dark:bg-muted/60`,children:[i===j.Content&&(0,X.jsx)(gu,{value:`collections`,children:Z(`common.collections`)}),i===j.Space&&(0,X.jsx)(gu,{value:`spaces`,children:Z(`common.spaces`)}),i===j.Content&&!o&&(0,X.jsx)(gu,{value:`create-new`,children:Z(`features.content-selection.dialog.create-new.tab`)})]}),(0,X.jsxs)(_u,{value:`collections`,className:`h-full w-full overflow-y-auto`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)($t,{children:Z(`features.content-selection.dialog.select-collection`)}),(0,X.jsxs)(Vt,{onValueChange:e=>r(e),value:b??void 0,children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{children:b?y?.items.find(e=>e.id===b)?.name:Z(`features.content-selection.dialog.select-collection`)})}),(0,X.jsx)(Dt,{children:y?.items.map(e=>(0,X.jsx)(yn,{value:e.id,children:e.name},e.id))})]})]}),C?.[0]&&!o&&(0,X.jsx)(`div`,{className:`mt-4 flex-1`,children:(0,X.jsx)(pd,{columns:M,data:S?.items||[],getRowId:e=>e.id,multiSelect:!1,rowSelection:u,onRowSelectionChange:e=>d(e)},b)})]}),(0,X.jsx)(_u,{value:`create-new`,className:`flex h-full w-full flex-1 flex-col overflow-y-auto`,children:i===j.Content&&(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)($t,{children:Z(`features.content-selection.dialog.select-collection`)}),(0,X.jsxs)(Vt,{onValueChange:e=>r(e),value:b??void 0,children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{children:b?y?.items.find(e=>e.id===b)?.name:Z(`features.content-selection.dialog.select-collection`)})}),(0,X.jsx)(Dt,{children:y?.items.map(e=>(0,X.jsx)(yn,{value:e.id,children:e.name},e.id))})]})]}),w?(0,X.jsx)(`div`,{children:Z(`common.loading`)}):(0,X.jsx)(Xw,{collection:C?.[0],entry:void 0,fn:()=>{l(`collections`)}})]})}),(0,X.jsx)(_u,{value:`spaces`,className:`flex h-full w-full flex-1 flex-col gap-2 overflow-hidden`,children:i===j.Space&&(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col gap-2 p-4`,children:[(0,X.jsxs)(Me,{className:`mx-4 max-w-sm`,children:[(0,X.jsx)(Ve,{children:(0,X.jsx)(eo,{className:``})}),(0,X.jsx)(ze,{placeholder:Z(`features.content-selection.dialog.search-spaces`),value:E,onChange:e=>D(e.target.value)})]}),(0,X.jsx)(`div`,{className:`grid h-full w-full auto-rows-max grid-cols-2 gap-4 overflow-y-auto p-4 md:grid-cols-3`,children:O.map(e=>(0,X.jsxs)(Fo,{className:q(`cursor-pointer gap-0 overflow-hidden p-0 transition-all hover:shadow-md`,m===e.id&&`bg-accent ring-2 ring-primary`),onClick:()=>h(e.id),children:[(0,X.jsx)(`div`,{className:`relative aspect-video w-full overflow-hidden bg-muted`,children:e.thumbnail?.url?(0,X.jsx)(`img`,{src:e.thumbnail?.url,alt:e.name,className:`h-full w-full object-cover`}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center bg-linear-to-br from-muted to-muted-foreground/10`,children:(0,X.jsx)(`span`,{className:`text-4xl font-bold text-muted-foreground/30`,children:e.name.substring(0,2).toUpperCase()})})}),(0,X.jsxs)(Io,{className:`space-y-2 py-4`,children:[(0,X.jsx)(Lo,{className:`text-base`,children:e.name}),(0,X.jsx)(Ro,{className:`text-sm`,children:e.description||Z(`features.content-selection.dialog.no-description`)})]}),(0,X.jsx)(Bo,{className:`pt-2 pb-4`,children:(0,X.jsx)(U,{variant:m===e.id?`default`:`outline`,size:`sm`,className:`w-full`,onClick:t=>{t.stopPropagation(),m===e.id?h(null):h(e.id)},children:m===e.id?Z(`features.content-selection.dialog.selected`):Z(`common.select`)})})]},e.id))})]})})]}),(0,X.jsx)(lr,{children:(0,X.jsxs)(U,{onClick:()=>{N(),t(!1)},children:[(0,X.jsx)(io,{}),Z(`common.save`)]})})]})})};Zw.displayName=`ContentSelectionDialog`;function Qw(e){let[t,n]=(0,Y.useState)(),r=e===void 0?void 0:[].concat(e),i=r?.join(`,`);return(0,Y.useEffect)(()=>{let e=L.getInstance().entities.getAll$().subscribe(e=>{let t=r?e.filter(e=>r.includes(e.type)):e;n(t)});return()=>{e.unsubscribe()}},[i]),{entities:t}}function $w(e,t){return t?{...e,name:t.name||e.name,slug:t.slug||e.slug,status:t.status,fields:t.fields??e.fields,properties:{...e.properties,...t.properties}}:e}var eT=`inline-flex items-center justify-center rounded-md text-white/75 transition-colors hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-white/45 focus-visible:ring-offset-2 focus-visible:ring-offset-transparent`;function tT({index:e,count:t,onPrev:n,onNext:r}){return t<=1?null:(0,X.jsxs)(`footer`,{className:`flex shrink-0 items-center justify-between gap-3 pt-3`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Previous item`,onClick:n,className:`${eT} -ml-1 p-1`,children:(0,X.jsx)(Zi,{className:`size-6`,strokeWidth:2,"aria-hidden":!0})}),(0,X.jsxs)(`span`,{className:`text-xs tracking-wide text-white/45 tabular-nums select-none`,children:[e
114+1,` / `,t]}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Next item`,onClick:r,className:`${eT} -mr-1 p-1`,children:(0,X.jsx)(Er,{className:`size-6`,strokeWidth:2,"aria-hidden":!0})})]})}tT.displayName=`GroupNavigation`;function nT(e){let t=e.definition.properties?.link;return t?.type===`Content`?t:void 0}function rT(e,t){return(e??[]).map(nT).find(e=>e?.id===t)}function iT(e){return typeof e.id!=`string`||!e.id?!1:!(typeof e.name==`string`||Array.isArray(e.fields)&&e.fields.length>0||e.properties!=null&&typeof e.properties==`object`&&Object.keys(e.properties).length>0)}function aT(e,t){if(!e||typeof e!=`object`)return null;let n=e;if(typeof n.id!=`string`||!n.id)return null;let{preview:r,...i}=n;return iT(i)?rT(t,n.id)??i:i}function oT(e,t){return!e?.id||!iT(e)?e:rT(t,e.id)??e}function sT({link:e,spots:t,isPreview:n,isLoading:r=!1,onClose:i}){let[a]=wo(),o=a??void 0,{getEntry:s}=Nd(),c=(0,Y.useRef)(null),l=(0,Y.useMemo)(()=>{let n=oT(e,t);return n?.id?$w(n,s(n.id,o)):n},[e,t,s,o]),u=(0,Y.useMemo)(()=>l?rS(l):null,[l]),d=$d(u?.placement),f=(0,Y.useMemo)(()=>{if(!u?.groupPropertyName||!u.groupValue)return[];let e=u.groupPropertyName;return(t??[]).map(nT).filter(t=>t?.type===`Content`&&t.properties?.[e]===u.groupValue).map(e=>{let t=e?.id?s(e.id,o):void 0;return{id:e?.id,name:t?.name||e?.name,slug:t?.slug||e?.slug,status:e?.status,properties:{...e?.properties,...t?.properties}}})},[t,u,s,o]),p=(0,Y.useMemo)(()=>f.findIndex(e=>e.id===l?.id),[f,l]),m=e=>{if(f.length===0||p<0)return;let t=(p+e+f.length)%f.length,r=f[t];r?.id&&P.publish({type:`content.open`,payload:{id:r.id,...n?{preview:!0}:{}}})},h=(0,Y.useRef)(!1),g=(0,Y.useCallback)(e=>{h.current=e.target===e.currentTarget},[]),_=(0,Y.useCallback)(()=>{h.current&&(h.current=!1,i())},[i]);return(0,Y.useEffect)(function(){let e=e=>{e.key===`Escape`&&i()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[i]),(0,Y.useEffect)(function(){let e=document.activeElement;return c.current?.focus(),()=>{e?.focus?.()}},[]),l?(0,X.jsx)(`div`,{className:q(`fixed inset-0 z-50 flex items-center py-8`,qd[d.side]),onPointerDown:g,onClick:_,children:(0,X.jsxs)(`div`,{role:`dialog`,"aria-modal":`false`,"aria-label":l.name||Z(`features.content-viewer.default-label`),"data-content-side":d.side,onClick:e=>e.stopPropagation(),className:q(`pointer-events-auto relative flex max-h-[85svh] w-full flex-col overflow-hidden rounded-xl px-4 pt-4 pb-4 sm:px-5`,d.side===`center`?Yd:Xd,Jd[d.side]),children:[(0,X.jsx)(`button`,{ref:c,type:`button`,"aria-label":Z(`common.close`),onClick:i,className:q(`absolute top-3 right-3 z-10 p-1 sm:right-4`,Zd),children:(0,X.jsx)(so,{className:`size-5`,strokeWidth:2,"aria-hidden":!0})}),(0,X.jsx)(`div`,{className:q(`min-h-0 flex-1 pr-1`,Qd),children:r?(0,X.jsx)(`p`,{role:`status`,"aria-live":`polite`,className:`py-10 text-center text-sm text-white/60`,children:Z(`common.loading`)}):(0,X.jsx)(Qx,{link:l,variant:`overlay`,template:u?.template})}),(0,X.jsx)(tT,{index:p<0?0:p,count:f.length,onPrev:()=>m(-1),onNext:()=>m(1)})]})}):null}sT.displayName=`ContentPanel`;var cT=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function lT(e,t,n){return t?{...e,collectionId:t.collectionId,name:t.name||e.name,slug:t.slug||e.slug,status:t.status??e.status,properties:{...e.properties,...t.properties},fields:n?.fields??e.fields}:e}function uT(e){let t=R(),n=e?.id&&cT.test(e.id)?e.id:void 0,r=!!n,{data:i,isLoading:a}=V(t.cms.entries.get.queryOptions([n],{enabled:r})),o=i?.[0],s=o?.collectionId??e?.collectionId,c=!!s,{data:l,isLoading:u}=V(t.cms.collections.getWithFields.queryOptions([s],{enabled:c})),d=l?.[0];return{link:(0,Y.useMemo)(()=>e&&lT(e,o,d),[e,o,d]),isLoading:r&&a||c&&u}}function dT({link:e,...t}){let{link:n,isLoading:r}=uT(e);return(0,X.jsx)(sT,{...t,link:n??e,isLoading:r})}dT.displayName=`EditorContentPanel`;var fT=()=>{let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),{entities:c}=Qw([`BasicSpotEntity`,`SpotEntity`]),l=(0,Y.useRef)(null),u=(0,Y.useRef)(c),d=(0,Y.useRef)(!1);(0,Y.useEffect)(()=>{l.current=n},[n]),(0,Y.useEffect)(()=>{u.current=c},[c]),(0,Y.useEffect)(()=>{let e=L.getInstance().resources.get$(te.ENVIRONMENT_SETTINGS_RESOURCE).pipe(D(e=>e?.definition$?e.definition$.pipe(w(e=>e.properties?.preset)):T(void 0))).subscribe(e=>{let n=e===`spaceEditor`||e===`worldEditor`;d.current=n,s(n),n&&(t(!1),r(null),a(!1))});return()=>e.unsubscribe()},[]),(0,Y.useEffect)(function(){let e=P.get$(`content.open`).subscribe(e=>{if(!e.payload||typeof e.payload!=`object`)return;let n=e.payload.preview===!0;if(d.current&&!n)return;let i=aT(e.payload,u.current);i&&(r(i),a(n),t(!0))}),n=P.get$(`content.close`).subscribe(e=>{e.payload?.id===l.current?.id&&(t(!1),a(!1))});return()=>{e.unsubscribe(),n.unsubscribe()}},[]);let f=(0,Y.useCallback)(()=>{let e=l.current?.id;e?P.publish({type:`content.close`,payload:{id:e}}):(t(!1),a(!1))},[]);return!e||!n||o&&!i?null:o&&i?(0,X.jsx)(dT,{link:n,spots:c,isPreview:!0,onClose:f}):(0,X.jsx)(sT,{link:n,spots:c,isPreview:i,onClose:f})};fT.displayName=`ContentViewer`;var pT=({title:e,placeholder:t,searchValue:n,changeSearchValue:r,formValues:i,...a})=>(0,X.jsxs)(`div`,{className:q(`w-full max-w-sm space-y-2`,a.className),...a,children:[(0,X.jsx)($t,{htmlFor:`search-input`,children:e}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(eo,{className:`absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2 text-muted-foreground`}),(0,X.jsx)(W,{className:`bg-background pl-9`,id:`search-input`,placeholder:t,type:`search`,value:n,onChange:e=>r?.(e.target.value),...i})]})]});pT.displayName=`SearchInput`;var mT=({src:e,alt:t,className:n})=>{let[r,i]=(0,Y.useState)(!1);return(0,X.jsx)(`div`,{className:q(`relative aspect-square h-full w-full`,n),children:r||!e?(0,X.jsx)(Ri,{className:`absolute top-1/2 left-1/2 size-10 -translate-x-1/2 -translate-y-1/2 transform text-muted-foreground`}):(0,X.jsx)(`img`,{src:e,alt:t,className:q(`h-full w-full object-cover`,n),onError:()=>i(!0)})})},hT=({file:e,selected:t,onClick:n,onDelete:r,showDelete:i})=>(0,X.jsx)(`div`,{className:`min-w-0 p-1`,children:(0,X.jsxs)(`div`,{role:`button`,tabIndex:0,className:q(`relative flex w-full cursor-pointer items-center gap-4 roun
114ded-lg border border-transparent bg-card px-3 py-2.5 text-left shadow-sm transition-colors`,`hover:border-border hover:bg-muted/50`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:outline-none`,`ring-offset-2 ring-offset-background`,t&&`border-primary/50 ring-1 ring-primary/30`,!t&&`hover:ring-1 hover:ring-primary/20`),onClick:n,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n?.())},children:[(0,X.jsx)(`div`,{className:`flex size-14 shrink-0 items-center justify-center overflow-hidden rounded-md bg-muted/50`,children:e.mimetype.startsWith(`application/`)?(0,X.jsx)(oa,{className:`size-14 shrink-0 text-muted-foreground`}):e.mimetype.startsWith(`image/`)&&e.url?(0,X.jsx)(mT,{src:e.url,alt:e.filename,className:`size-14 object-cover`}):e.mimetype.startsWith(`video/`)&&e.url?(0,X.jsx)(`video`,{src:e.url,className:`size-14 object-cover`,muted:!0,playsInline:!0}):e.mimetype.startsWith(`audio/`)&&e.url?(0,X.jsx)(`audio`,{src:e.url,className:`size-14 object-cover`}):(0,X.jsx)(oa,{className:`size-14 shrink-0 text-muted-foreground`})}),(0,X.jsx)(`p`,{className:`min-w-0 flex-1 truncate text-sm font-medium text-foreground`,children:e.filename}),i&&r&&(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`size-8 shrink-0 text-red-600 hover:bg-red-50 hover:text-red-700`,onClick:e=>{e.stopPropagation(),r?.()},children:(0,X.jsx)(Qi,{className:`size-4`})})]})});hT.displayName=`FileGridItem`;var gT={image:[`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`,`image/bmp`,`image/tiff`],video:[`video/mp4`,`video/webm`,`video/ogg`,`video/quicktime`,`video/x-msvideo`,`video/x-ms-wmv`],audio:[`audio/mpeg`,`audio/mp3`,`audio/ogg`,`audio/wav`,`audio/webm`],model:[`model/gltf-binary`,`model/gltf+json`],hdr:[`image/vnd.radiance`,`image/x-hdr`,`image/x-exr`,`application/octet-stream`],any:[`image/jpeg`,`image/jpg`,`image/png`,`image/gif`,`image/webp`,`image/svg+xml`,`image/bmp`,`image/tiff`,`video/mp4`,`video/webm`,`video/ogg`,`video/quicktime`,`video/x-msvideo`,`video/x-ms-wmv`,`audio/mpeg`,`audio/mp3`,`audio/ogg`,`audio/wav`,`audio/webm`,`model/gltf-binary`,`model/gltf+json`]},_T=({filters:e,selectedFiles:t,onToggleSelection:n,onSelect:r,onSelectFile:i,isOpen:a})=>{let{activeOrganization:o}=z(),[s,c]=(0,Y.useState)(``),l=R(),{data:u}=V(l.files.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:o?.id},{enabled:a&&!!o?.id})),{fileType:d}=e,f=(0,Y.useMemo)(()=>u?.items?u.items.filter(e=>{let t=e.filename.toLowerCase().includes(s.toLowerCase()),n=d?gT[d]:void 0,r=!n||n.includes(e.mimetype);return t&&r}):[],[u,s,d]),p=e?.multiple===!0,m=p&&!!r,h=!p&&!!i,g=e=>{m?n(e):h&&i&&i(e)};return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[m&&t.length>0&&(0,X.jsxs)(`p`,{className:`py-1 text-sm text-muted-foreground`,children:[`Selected Files: `,t.length]}),(0,X.jsx)(pT,{title:`Search files`,placeholder:`Search files`,searchValue:s,changeSearchValue:c}),(0,X.jsx)(jl,{className:`h-[40svh] w-full rounded-md border bg-muted`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2 px-4 py-2`,children:[f.length===0&&(0,X.jsx)(`p`,{className:`py-4 text-center text-sm text-muted-foreground`,children:`No files found`}),f.map(e=>(0,X.jsx)(hT,{file:e,selected:m?t.some(t=>t.id===e.id):!1,onClick:m||h?()=>g(e):void 0},e.id))]})}),m&&t.length>0&&(0,X.jsxs)(U,{onClick:r,className:`w-full`,children:[`Select `,t.length,` file(s)`]})]})};_T.displayName=`FileListTab`;function vT(e){let{callback:t,delay:n,enabled:r=!0,dependencies:i=[],updateInterval:a=100}=e,o=(0,Y.useRef)(t),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(!0),[d,f]=(0,Y.useState)(r?n:0),[p,m]=(0,Y.useState)(!1);(0,Y.useEffect)(function(){o.current=t},[t]);let h=(0,Y.useCallback)(()=>{c.current&&=(clearInterval(c.current),null),o.current(),u.current&&(m(!1),f(0)),l.current=null},[]),g=(0,Y.useCallback)(()=>{s.current&&=(clearTimeout(s.current),null),c.current&&=(clearInterval(c.current),null),u.current&&(m(!1),f(0)),l.current=null},[]),_=(0,Y.useCallback)(()=>{g(),r&&n>=0&&(l.current=Date.now(),m(!0),f(n),s.current=setTimeout(h,n))},[g,r,n,h]);return(0,Y.useEffect)(function(){if(!(!p||!r||n<0))return c.current=setInterval(()=>{if(l.current===null||!u.current)return;let e=Date.now()-l.current,t=Math.max(0,n-e);f(t),t===0&&(m(!1),c.current&&=(clearInterval(c.current),null))},a),()=>{c.current&&=(clearInterval(c.current),null)}},[p,r,n,a]),(0,Y.useEffect)(function(){if(!r||n<0){queueMicrotask(()=>{u.current&&(m(!1),f(0))});return}return l.current=Date.now(),s.current=setTimeout(h,n),queueMicrotask(()=>{u.current&&(m(!0),f(n))}),()=>
114{s.current&&=(clearTimeout(s.current),null),c.current&&=(clearInterval(c.current),null),queueMicrotask(()=>{u.current&&(m(!1),f(0))}),l.current=null}},[r,n,h,i]),(0,Y.useEffect)(function(){return u.current=!0,()=>{u.current=!1}},[]),{clear:g,reset:_,remaining:d,remainingSeconds:Math.floor(d/1e3),isActive:p}}var yT=({notification:e,onDismiss:t,autoDismissDelay:n})=>(vT({callback:()=>{t(e.id)},delay:n??0,enabled:n!==void 0&&n>0}),(0,X.jsxs)(`div`,{className:q(`flex items-start gap-3 rounded-md border p-3`,(e=>{switch(e){case`success`:return`border-green-200 bg-green-50`;case`error`:return`border-red-200 bg-red-50`;case`warning`:return`border-yellow-200 bg-yellow-50`;case`info`:return`border-blue-200 bg-blue-50`}})(e.type)),children:[(0,X.jsx)(`div`,{className:`shrink-0 pt-0.5`,children:(e=>{switch(e){case`success`:return(0,X.jsx)(ni,{className:`size-5 text-green-600`});case`error`:return(0,X.jsx)($r,{className:`size-5 text-red-600`});case`warning`:return(0,X.jsx)(fi,{className:`size-5 text-yellow-600`});case`info`:return(0,X.jsx)(ua,{className:`size-5 text-blue-600`})}})(e.type)}),(0,X.jsxs)(`div`,{className:`flex-1 space-y-1`,children:[(0,X.jsx)(`p`,{className:q(`text-sm font-medium`,(e=>{switch(e){case`success`:return`text-green-900`;case`error`:return`text-red-900`;case`warning`:return`text-yellow-900`;case`info`:return`text-blue-900`}})(e.type)),children:e.title}),e.message&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.message})]}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`-mt-1 -mr-1 size-6 shrink-0 text-muted-foreground hover:text-foreground`,onClick:()=>t(e.id),children:(0,X.jsx)(so,{className:`size-4`})})]}));yT.displayName=`NotificationItem`;var bT=({notifications:e,onDismiss:t,onClearAll:n,className:r})=>{if(e.length===0)return null;let i=e=>{if(e.autoDismiss!==!1)switch(e.type){case`success`:case`info`:return 5e3;case`warning`:return 1e4;case`error`:return}};return(0,X.jsxs)(`div`,{className:q(`flex flex-col gap-2 py-4`,r),children:[(0,X.jsx)(`div`,{className:`flex items-center justify-between`,children:n&&e.length>1&&(0,X.jsx)(U,{variant:`ghost`,size:`sm`,onClick:n,className:`h-7 text-xs text-muted-foreground`,children:`Clear all`})}),(0,X.jsx)(jl,{className:`max-h-50 w-full`,children:(0,X.jsx)(`div`,{className:`flex flex-col gap-2 pr-4`,children:e.map(e=>(0,X.jsx)(yT,{notification:e,onDismiss:t,autoDismissDelay:i(e)},e.id))})})]})};bT.displayName=`NotificationPanel`;function xT(){let[e,t]=(0,Y.useState)([]),n=(0,Y.useCallback)(e=>{t(t=>t.filter(t=>t.id!==e))},[]),r=(0,Y.useCallback)((e,n,r,i=!0)=>{let a=`${Date.now()}-${Math.random()}`,o={id:a,type:e,title:n,message:r,timestamp:Date.now(),autoDismiss:i};return t(e=>[...e,o]),a},[]);return{notifications:e,addNotification:r,dismissNotification:n,clearAll:(0,Y.useCallback)(()=>{t([])},[]),success:(0,Y.useCallback)((e,t)=>r(`success`,e,t),[r]),error:(0,Y.useCallback)((e,t)=>r(`error`,e,t,!1),[r]),warning:(0,Y.useCallback)((e,t)=>r(`warning`,e,t),[r]),info:(0,Y.useCallback)((e,t)=>r(`info`,e,t),[r])}}var ST=({uploadedFiles:e,filters:t,selectedFiles:n,onToggleSelection:r,onAddMore:i,onDone:a,onSelect:o,onSelectFile:s,onDelete:c})=>{let l=t?.multiple===!0,u=l&&!!o,d=!l&&!!s,f=e=>{u?r(e):d&&s&&s(e)},p=e.filter(e=>e.backendFile);return(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[u&&n.length>0&&(0,X.jsxs)(`p`,{className:`py-1 text-sm text-muted-foreground`,children:[`Selected Files: `,n.length]}),(0,X.jsx)(jl,{className:`h-[40svh] w-full rounded-md border bg-muted p-4`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[e.length===0&&(0,X.jsx)(`p`,{className:`py-4 text-center text-sm text-muted-foreground`,children:`No files uploaded`}),e.map(e=>e.backendFile?(0,X.jsx)(hT,{file:e.backendFile,selected:u?n.some(t=>t.id===e.backendFile?.id):!1,onClick:u||d?()=>f(e.backendFile):void 0,showDelete:!!c,onDelete:()=>c?.(e.fileId)},e.fileId):(0,X.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border bg-card p-2`,children:[(0,X.jsx)(An,{className:`size-5`}),(0,X.jsxs)(`div`,{className:`flex-1`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:e.file.name}),(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Processing...`,` `,(e.file.size/1024/1024).toFixed(2),` MB`]})]})]},e.fileId))]})}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsxs)(U,{variant:`outline`,onClick:i,className:`flex-1`,children:[(0,X.jsx)(Hr,{className:`mr-2 size-4`}),`Add More Files`]}),u&&n.length>0?(0,X.jsxs)(U,{onClick:o,className:`flex-1`,disabled:n.length===0,children:[`Select `,n.length,` file(s)`]}):(0,X.jsx)(U,{onClick:a,className:`flex-1`,disabled:p.length===0,children:`Done`})]})]})};ST.displayName=`UploadDoneView`;var CT=`FileUpload`,wT=`FileUploadDropzone`,TT=`FileUploadTrigger`,ET=`FileUploadList`,DT=`FileUploadItem`,OT=`FileUploadItemPreview`,kT=`FileUploadItemMetadata`,AT=`FileUploadItemProgress`,jT=`FileUploadItemDelete`;function MT(e){let t=Y.useRef(null);return t.current===null&&(t.current=e()),t}var NT=Y.createContext(void 0);function PT(e){let t=Y.useContext(NT);return e??t??`ltr`}function FT(e,t,n,r,i){let a={files:t,dragOver:!1,invalid:r};function o(e,r){switch(r.type){case`ADD_FILES`:for(let e of r.files)t.set(e,{file:e,progress:0,status:`idle`});return i&&i(Array.from(t.values()).map(e=>e.file)),{...e,files:t};case`SET_FILES`:{let n=new Set(r.files);for(let e of t.keys())n.has(e)||t.delete(e);for(let e of r.files)t.get(e)||t.set(e,{file:e,progress:0,status:`idle`});return{...e,files:t}}case`SET_PROGRESS`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,progress:r.progress,status:`uploading`}),{...e,files:t}}case`SET_SUCCESS`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,progress:100,status:`success`}),{...e,files:t}}case`SET_ERROR`:{let n=t.get(r.file);return n&&t.set(r.file,{...n,error:r.error,status:`error`}),{...e,files:t}}case`REMOVE_FILE`:if(n){let e=n.get(r.file);e&&(URL.revokeObjectURL(e),n.delete(r.file))}return t.delete(r.file),i&&i(Array.from(t.values()).map(e=>e.file)),{...e,files:t};case`SET_DRAG_OVER`:return{...e,dragOver:r.dragOver};
114case`SET_INVALID`:return{...e,invalid:r.invalid};case`CLEAR`:if(n)for(let e of t.keys()){let t=n.get(e);t&&(URL.revokeObjectURL(t),n.delete(e))}return t.clear(),i&&i([]),{...e,files:t,invalid:!1};default:return e}}function s(){return a}function c(t){a=o(a,t);for(let t of e)t()}function l(t){return e.add(t),()=>e.delete(t)}return{getState:s,dispatch:c,subscribe:l}}var IT=Y.createContext(null);function LT(e){let t=Y.useContext(IT);if(!t)throw Error(`\`${e}\` must be used within \`${CT}\``);return t}function RT(e){let t=LT(`useStore`),n=MT(()=>null),r=Y.useCallback(()=>{let r=t.getState(),i=n.current;if(i&&i.state===r)return i.value;let a=e(r);return n.current={value:a,state:r},a},[t,e,n]);return Y.useSyncExternalStore(t.subscribe,r,r)}var zT=Y.createContext(null);function BT(e){let t=Y.useContext(zT);if(!t)throw Error(`\`${e}\` must be used within \`${CT}\``);return t}function VT(e){let{value:t,defaultValue:n,onValueChange:r,onAccept:i,onFileAccept:a,onFileReject:o,onFileValidate:s,onUpload:c,accept:l,maxFiles:u,maxSize:d,dir:f,label:p,name:m,asChild:h,disabled:g=!1,invalid:_=!1,multiple:v=!1,required:y=!1,children:b,className:x,...S}=e,C=Y.useId(),w=Y.useId(),T=Y.useId(),E=Y.useId(),D=PT(f),O=MT(()=>new Set).current,k=MT(()=>new Map).current,A=MT(()=>new WeakMap).current,j=Y.useRef(null),M=t!==void 0,N=Y.useMemo(()=>FT(O,k,A,_,r),[O,k,_,r,A]),P=Y.useMemo(()=>l?.split(`,`).map(e=>e.trim())??null,[l]),F=MT(()=>{let e=0;return(t,n)=>{e||=requestAnimationFrame(()=>{e=0,N.dispatch({type:`SET_PROGRESS`,file:t,progress:Math.min(Math.max(0,n),100)})})}}).current;Y.useEffect(()=>{M?N.dispatch({type:`SET_FILES`,files:t}):n&&n.length>0&&!N.getState().files.size&&N.dispatch({type:`SET_FILES`,files:n})},[t,n,M,N]),Y.useEffect(()=>()=>{for(let e of k.keys()){let t=A.get(e);t&&URL.revokeObjectURL(t)}},[k,A]);let I=Y.useCallback(async e=>{try{for(let t of e)N.dispatch({type:`SET_PROGRESS`,file:t,progress:0});if(c)await c(e,{onProgress:F,onSuccess:e=>{N.dispatch({type:`SET_SUCCESS`,file:e})},onError:(e,t)=>{N.dispatch({type:`SET_ERROR`,file:e,error:t.message??`Upload failed`})}});else for(let t of e)N.dispatch({type:`SET_SUCCESS`,file:t})}catch(t){let n=t instanceof Error?t.message:`Upload failed`;for(let t of e)N.dispatch({type:`SET_ERROR`,file:t,error:n})}},[N,c,F]),L=Y.useCallback(e=>{if(g)return;let t=[...e],n=!1;if(u){let e=N.getState().files.size,r=Math.max(0,u-e);if(r<t.length){let e=t.slice(r);n=!0,t=t.slice(0,r);for(let t of e){let e=`Maximum ${u} files allowed`;if(s){let n=s(t);n&&(e=n)}o?.(t,e)}}}let l=[],f=[];for(let e of t){let t=!1,r=``;if(s){let i=s(e);if(i){r=i,o?.(e,r),t=!0,n=!0;continue}}if(P){let i=e.type,a=`.${e.name.split(`.`).pop()}`;P.some(e=>e===i||e===a||e.includes(`/*`)&&i.startsWith(e.replace(`/*`,`/`)))||(r=`File type not accepted`,o?.(e,r),t=!0,n=!0)}d&&e.size>d&&(r=`File too large`,o?.(e,r),t=!0,n=!0),t?f.push({file:e,message:r}):l.push(e)}if(n&&(N.dispatch({type:`SET_INVALID`,invalid:n}),setTimeout(()=>{N.dispatch({type:`SET_INVALID`,invalid:!1})},2e3)),l.length>0){if(N.dispatch({type:`ADD_FILES`,files:l}),M&&r){let e=Array.from(N.getState().files.values()).map(e=>e.file);r([...e])}i&&i(l);for(let e of l)a?.(e);c&&requestAnimationFrame(()=>{I(l)})}},[N,M,r,i,a,c,I,u,s,o,P,d,g]),ee=Y.useCallback(e=>{let t=Array.from(e.target.files??[]);L(t),e.target.value=``},[L]),te=Y.useMemo(()=>({dropzoneId:w,inputId:C,listId:T,labelId:E,dir:D,disabled:g,inputRef:j,urlCache:A}),[w,C,T,E,D,g,A]),ne=h?wt:`div`;return(0,X.jsx)(IT.Provider,{value:N,children:(0,X.jsx)(zT.Provider,{value:te,children:(0,X.jsxs)(ne,{"data-disabled":g?``:void 0,"data-slot":`file-upload`,dir:D,...S,className:q(`relative flex flex-col gap-2`,x),children:[b,(0,X.jsx)(`input`,{type:`file`,id:C,"aria-labelledby":E,"aria-describedby":w,ref:j,tabIndex:-1,accept:l,name:m,className:`sr-only`,disabled:g,multiple:v,required:y,onChange:ee}),(0,X.jsx)(`span`,{id:E,className:`sr-only`,children:p??`File upload`})]})})})}function HT(e){let{asChild:t,className:n,onClick:r,onDragOver:i,onDragEnter:a,onDragLeave:o,onDrop:s,onPaste:c,onKeyDown:l,...u}=e,d=BT(wT),f=LT(wT),p=RT(e=>e.dragOver),m=RT(e=>e.invalid),h=Y.useCallback(e=>{if(r?.(e),e.defaultPrevented)return;let t=e.target;t instanceof HTMLElement&&t.closest(`[data-slot="file-upload-trigger"]`)||d.inputRef.current?.click()},[d.inputRef,r]),g=Y.useCallback(e=>{i?.(e),!e.defaultPrevented&&(e.preventDefault(),f.dispatch({type:`SET_DRAG_OVER`,dragOver:!0}))},[f,i]),_=Y.useCallback(e=>{a?.(e),!e.defaultPrevented&&(e.preventDefault(),f.dispatch({type:`SET_DRAG_OVER`,dragOver:!0}))},[f,a]),v=Y.useCallback(e=>{if(o?.(e),e.defaultPrevented)return;let t=e.relatedTarget;t&&t instanceof Node&&e.currentTarget.contains(t)||(e.preventDefault(),f.dispatch({type:`SET_DRAG_OVER`,dragOver:!1}))},[f,o]),y=Y.useCallback(e=>{if(s?.(e),e.defaultPrevented)return;e.preventDefault(),f.dispatch({type:`SET_DRAG_OVER`,dragOver:!1});let t=Array.from(e.dataTransfer.files),n=d.inputRef.current;if(!n)return;let r=new DataTransfer;for(let e of t)r.items.add(e);n.files=r.files,n.dispatchEvent(new Event(`change`,{bubbles:!0}))},[f,d.inputRef,s]),b=Y.useCallback(e=>{if(c?.(e),e.defaultPrevented)return;e.preventDefault(),f.dispatch({type:`SET_DRAG_OVER`,dragOver:!1});let t=e.clipboardData?.items;if(!t)return;let n=[];for(let e=0;e<t.length;e++){let r=t[e];if(r?.kind===`file`){let e=r.getAsFile();e&&n.push(e)}}if(n.length===0)return;let r=d.inputRef.current;if(!r)return;let i=new DataTransfer;for(let e of n)i.items.add(e);r.files=i.files,r.dispatchEvent(new Event(`change`,{bubbles:!0}))},[f,d.inputRef,c]),x=Y.useCallback(e=>{l?.(e),!e.defaultPrevented&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),d.inputRef.current?.click())},[d.inputRef,l]);return(0,X.jsx)(t?wt:`div`,{role:`region`,id:d.dropzoneId,"aria-controls":`${d.inputId} ${d.listId}`,"aria-disabled":d.disabled,"aria-invalid":m,"data-disabled":d.disabled?``:void 0,"data-dragging":p?``:void 0,"data-invalid":m?``:void 0,"data-slot":`file-upload-dropzone`,dir:d.dir,tabIndex:d.disabled?void 0:0,...u,className:q(`relative flex select-none flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 outline-none transition-colors hover:bg-accent/30 focus-visible:border-ring/50 data-[disabled]:pointer-events-none data-[dragging]:border-primary/30 data-[invalid]:border-destructive data-[dragging]:bg-accent/30 data-[invalid]:ring-destructive/20`,n),onClick:h,onDragEnter:_,onDragLeave:v,onDragOver:g,onDrop:y,onKeyDown:x,onPaste:b})}function UT(e){let{asChild:t,onClick:n,...r}=e,i=BT(TT),a=Y.useCallback(e=>{n?.(e),!e.defaultPrevented&&i.inputRef.current?.click()},[i.inputRef,n]);return(0,X.jsx)(t?wt:`button`,{type:`button`,"aria-controls":i.inputId,"data-disabled":i.disabled?``:void 0,"data-slot":`file-upload-trigger`,...r,disabled:i.disabled,onClick:a})}function WT(e){let{className:t,orientation:n=`vertical`,asChild:r,forceMount:i,...a}=e,o=BT(ET),s=RT(e=>e.files.size),c=i||s>0;return c?(0,X.jsx)(r?wt:`div`,{role:`list`,id:o.listId,"aria-orientation":n,"data-orientation":n,"data-slot":`file-upload-list`,"data-state":c?`active`:`inactive`,dir:o.dir,...a,className:q(`data-[state=inactive]:fade-out-0 data-[state=active]:fade-in-0 data-[state=inactive]:slide-out-to-top-2 data-[state=active]:slide-in-from-top-2 flex flex-col gap-2 data-[state=active]:animate-in data-[state=inactive]:animate-out`,n===`horizontal`&&`flex-row overflow-x-auto p-1.5`,t)}):null}var GT=Y.createContext(null);function KT(e){let t=Y.useContext(GT);if(!t)throw Error(`\`${e}\` must be used within \`${DT}\``);return t}function qT(e){let{value:t,asChild:n,className:r,...i}=e,a=Y.useId(),o=`${a}-status`,s=`${a}-name`,c=`${a}-size`,l=`${a}-message`,u=BT(DT),d=RT(e=>e.files.get(t)),f=RT(e=>e.files.size),p=RT(e=>Array.from(e.files.keys()).indexOf(t)+1),m=Y.useMemo(()=>({id:a,fileState:d,nameId:s,sizeId:c,statusId:o,messageId:l}),[a,d,o,s,c,l]);if(!d)return null;let h=d.error?`Error: ${d.error}`:d.status===`uploading`?`Uploading: ${d.progress}% complete`:d.status===`success`?`Upload complete`:`Ready to upload`,g=n?wt:`div`;return(0,X.jsx)(GT.Provider,{value:m,children:(0,X.jsxs)(g,{role:`listitem`,id:a,"aria-setsize":f,"aria-posinset":p,"aria-describedby":`${s} ${c} ${o} ${d.error?l:``}`,"aria-labelledby":s,"data-slot":`file-upload-item`,dir:u.dir,...i,className:q(`relative flex items-center gap-2.5 rounded-md border p-3`,r),children:[e.children,(0,X.jsx)(`span`,{id:o,className:`sr-only`,children:h})]})})}function JT(e){if(e===0)return`0 B`;let t=[`B`,`KB`,`MB`,`GB`,`TB`],n=Math.floor(Math.log(e)/Math.log(1024));return`${(e/1024**n).toFixed(+!!n)} ${t[n]}`}function YT(e){let t=e.type,n=e.name.split(`.`).pop()?.toLowerCase()??``;return t.startsWith(`video/`)?(0,X.jsx)($a,{}):t.startsWith(`audio/`)?(0,X.jsx)(Hi,{}):t.startsWith(`text/`)||[`txt`,`md`,`rtf`,`pdf`].includes(n)?(0,X.jsx)(Pi,{}):[`html`,`css`,`js`,`jsx`,`ts`,`tsx`,`json`,`xml`,`php`,`py`,`rb`,`java`,`c`,`
114cpp`,`cs`].includes(n)?(0,X.jsx)(Fr,{}):[`zip`,`rar`,`7z`,`tar`,`gz`,`bz2`].includes(n)?(0,X.jsx)(Vr,{}):[`exe`,`msi`,`app`,`apk`,`deb`,`rpm`].includes(n)||t.startsWith(`application/`)?(0,X.jsx)(hi,{}):(0,X.jsx)(oa,{})}function XT(e){let{render:t,asChild:n,children:r,className:i,...a}=e,o=KT(OT),s=BT(OT),c=Y.useCallback(e=>{if(o.fileState?.file.type.startsWith(`image/`)){let t=s.urlCache.get(e);return t||(t=URL.createObjectURL(e),s.urlCache.set(e,t)),(0,X.jsx)(`img`,{src:t,alt:e.name,className:`size-full object-cover`})}return YT(e)},[o.fileState?.file.type,s.urlCache]),l=Y.useCallback(e=>t?t(e,()=>c(e)):c(e),[t,c]);return o.fileState?(0,X.jsxs)(n?wt:`div`,{"aria-labelledby":o.nameId,"data-slot":`file-upload-preview`,...a,className:q(`relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border bg-accent/50 [&>svg]:size-10`,i),children:[l(o.fileState.file),r]}):null}function ZT(e){let{asChild:t,size:n=`default`,children:r,className:i,...a}=e,o=BT(kT),s=KT(kT);return s.fileState?(0,X.jsx)(t?wt:`div`,{"data-slot":`file-upload-metadata`,dir:o.dir,...a,className:q(`flex min-w-0 flex-1 flex-col`,i),children:r??(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{id:s.nameId,className:q(`truncate font-medium text-sm`,n===`sm`&&`font-normal text-[13px] leading-snug`),children:s.fileState.file.name}),(0,X.jsx)(`span`,{id:s.sizeId,className:q(`truncate text-muted-foreground text-xs`,n===`sm`&&`text-[11px] leading-snug`),children:JT(s.fileState.file.size)}),s.fileState.error&&(0,X.jsx)(`span`,{id:s.messageId,className:`text-destructive text-xs`,children:s.fileState.error})]})}):null}function QT(e){let{variant:t=`linear`,size:n=40,asChild:r,forceMount:i,className:a,...o}=e,s=KT(AT);if(!s.fileState||!(i||s.fileState.progress!==100))return null;let c=r?wt:`div`;switch(t){case`circular`:{let e=2*Math.PI*((n-4)/2),t=e-s.fileState.progress/100*e;return(0,X.jsx)(c,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":s.fileState.progress,"aria-valuetext":`${s.fileState.progress}%`,"aria-labelledby":s.nameId,"data-slot":`file-upload-progress`,...o,className:q(`-translate-x-1/2 -translate-y-1/2 absolute top-1/2 left-1/2`,a),children:(0,X.jsxs)(`svg`,{className:`rotate-[-90deg] transform`,width:n,height:n,viewBox:`0 0 ${n} ${n}`,fill:`none`,stroke:`currentColor`,children:[(0,X.jsx)(`circle`,{className:`text-primary/20`,strokeWidth:`2`,cx:n/2,cy:n/2,r:(n-4)/2}),(0,X.jsx)(`circle`,{className:`text-primary transition-[stroke-dashoffset] duration-300 ease-linear`,strokeWidth:`2`,strokeLinecap:`round`,strokeDasharray:e,strokeDashoffset:t,cx:n/2,cy:n/2,r:(n-4)/2})]})})}case`fill`:{let e=s.fileState.progress,t=100-e;return(0,X.jsx)(c,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":e,"aria-valuetext":`${e}%`,"aria-labelledby":s.nameId,"data-slot":`file-upload-progress`,...o,className:q(`absolute inset-0 bg-primary/50 transition-[clip-path] duration-300 ease-linear`,a),style:{clipPath:`inset(${t}% 0% 0% 0%)`}})}default:return(0,X.jsx)(c,{role:`progressbar`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":s.fileState.progress,"aria-valuetext":`${s.fileState.progress}%`,"aria-labelledby":s.nameId,"data-slot":`file-upload-progress`,...o,className:q(`relative h-1.5 w-full overflow-hidden rounded-full bg-primary/20`,a),children:(0,X.jsx)(`div`,{className:`h-full w-full flex-1 bg-primary transition-transform duration-300 ease-linear`,style:{transform:`translateX(-${100-s.fileState.progress}%)`}})})}}function $T(e){let{asChild:t,onClick:n,...r}=e,i=LT(jT),a=KT(jT),o=Y.useCallback(e=>{n?.(e),a.fileState&&!e.defaultPrevented&&i.dispatch({type:`REMOVE_FILE`,file:a.fileState.file})},[i,a.fileState,n]);return a.fileState?(0,X.jsx)(t?wt:`button`,{type:`button`,"aria-controls":a.id,"aria-describedby":a.nameId,"data-slot":`file-upload-item-delete`,...r,onClick:o}):null}async function eE(e){return new Promise((t,n)=>{let r=new FileReader,i=e.name.split(`.`).pop()?.toLowerCase();r.onload=async e=>{try{let n=e.target?.result,r=new Uint8Array(n);t(i===`glb`?tE(r):i===`gltf`?nE(new TextDecoder().decode(r)):{valid:!1,errors:[`Unsupported file format. Only .glb and .gltf files are supported.`]})}catch(e){n(Error(`Validation error: ${e instanceof Error?e.message:`Unknown error`}`))}},r.onerror=()=>{n(Error(`Failed to read file`))},r.readAsArrayBuffer(e)})}function tE(e){let t=[],n=[];if(e.length<12)return{valid:!1,errors:[`File too small to be a valid GLB file`]};new Uint32Array(e.buffer,0,1)[0]!==1179937895&&t.push(`Invalid GLB magic number. File may be corrupted or not a valid GLB file.`);let r=new Uint32Array(e.buffer,4,1)[0];r!==2&&t.push(`Unsupported GLTF version: ${r}. Only version 2.0 is supported.`);let i=new Uint32Array(e.buffer,8,1)[0];if(i!==e.length&&n.push(`File length mismatch. Header claims ${i} bytes, actual size is ${e.length} bytes.`),e.length>
114=20){let n=new Uint32Array(e.buffer,12,1)[0],r=new Uint32Array(e.buffer,16,1)[0];if(r!==1313821514&&t.push(`Missing or invalid JSON chunk in GLB file.`),r===1313821514&&typeof n==`number`&&n>0&&e.length>=20+n)try{let r=new Uint8Array(e.buffer,20,n),i=new TextDecoder().decode(r),a=rE(JSON.parse(i));t.push(...a)}catch{t.push(`Failed to parse JSON chunk in GLB file.`)}}return{valid:t.length===0,errors:t.length>0?t:void 0,warnings:n.length>0?n:void 0}}function nE(e){let t=[],n=[];try{let n=rE(JSON.parse(e));t.push(...n)}catch{t.push(`Invalid JSON format. File may be corrupted.`)}return{valid:t.length===0,errors:t.length>0?t:void 0,warnings:n.length>0?n:void 0}}function rE(e){let t=[];return e.asset?e.asset.version?e.asset.version.startsWith(`2.`)||t.push(`Unsupported GLTF version: ${e.asset.version}. Only version 2.x is supported.`):t.push(`Missing required "asset.version" property.`):t.push(`Missing required "asset" property.`),e.scenes&&!Array.isArray(e.scenes)&&t.push(`"scenes" property must be an array.`),e.nodes&&!Array.isArray(e.nodes)&&t.push(`"nodes" property must be an array.`),e.meshes&&!Array.isArray(e.meshes)&&t.push(`"meshes" property must be an array.`),e.buffers&&!Array.isArray(e.buffers)&&t.push(`"buffers" property must be an array.`),t}var iE=({onUploadComplete:e,onNotification:t})=>{let[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)([]),o=(0,Y.useRef)(new Set),{uploadFiles:s,uploading:c}=vd({visibility:`public`,showToast:!1,invalidateQueries:!0,getMimetype:(0,Y.useCallback)(e=>{let t={glb:`model/gltf-binary`,gltf:`model/gltf+json`,hdr:`image/vnd.radiance`};if(e.type&&e.type.length>0)return e.type;let n=e.name.split(`.`).pop()?.toLowerCase();return n&&t[n]?t[n]:``},[])}),l=(0,Y.useCallback)(async n=>{if(!n||n.length===0||c)return;let r=e=>`${e.name}-${e.size}-${e.lastModified}`,i=n.filter(e=>{let t=r(e);return!o.current.has(t)});if(i.length===0)return;let l=[];for(let e of i){let n=e.name.split(`.`).pop()?.toLowerCase();if(n===`glb`||n===`gltf`)try{let n=await eE(e);if(!n.valid){let r=n.errors?.[0]||`Invalid GLTF file`;t?.(`error`,e.name,r);continue}n.warnings&&n.warnings.length>0&&(t?.(`warning`,e.name,n.warnings[0]),console.warn(`${e.name} warnings:`,n.warnings))}catch(n){let r=n instanceof Error?n.message:`Validation failed`;t?.(`error`,e.name,r);continue}l.push(e)}if(l.length!==0){l.forEach(e=>{o.current.add(r(e))});try{let n=await s(l),r=n.filter(e=>e!==null).map(e=>({file:e.file,fileId:e.fileId,presignedUrl:``,status:`available`}));a(e=>[...e,...r]),r.length>0&&(e(r),t?.(`success`,`${r.length} file${r.length===1?``:`s`} uploaded successfully`));let i=n.length-r.length;i>0&&t?.(`error`,`${i} file${i===1?``:`s`} failed to upload`)}catch(e){console.error(`Upload error`,e),t?.(`error`,`Upload failed`)}finally{l.forEach(e=>{o.current.delete(r(e))})}}},[c,s,e,t]),u=(0,Y.useCallback)((e,n)=>{let r=e.name.length>20?`${e.name.slice(0,20)}...`:e.name;t?.(`error`,n,`"${r}" has been rejected`)},[t]);return(0,X.jsxs)(VT,{value:n,onValueChange:r,maxFiles:10,maxSize:314572800,className:`w-full max-w-lg`,onUpload:l,onFileReject:u,multiple:!0,children:[(0,X.jsxs)(HT,{className:`h-full w-full`,children:[(0,X.jsxs)(`div`,{className:`flex w-full flex-col items-center gap-1 text-center`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center rounded-full border p-2.5`,children:(0,X.jsx)(wi,{className:`size-6 text-muted-foreground`})}),(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:`Drag & drop files here`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Or click to browse (max 10 files, up to 300MB each)`})]}),(0,X.jsx)(UT,{asChild:!0,children:(0,X.jsx)(U,{variant:`outline`,size:`sm`,className:`mt-2 w-fit`,children:`Browse files`})})]}),(0,X.jsx)(WT,{orientation:`horizontal`,children:i.map((e,t)=>(0,X.jsxs)(qT,{value:e.file,className:`p-0`,children:[(0,X.jsx)(XT,{className:`size-20`,children:(0,X.jsx)(QT,{variant:`fill`})}),(0,X.jsx)(ZT,{className:`sr-only`}),(0,X.jsx)($T,{asChild:!0,children:(0,X.jsx)(U,{variant:`secondary`,size:`icon`,className:`absolute -top-1 -right-1 size-5 rounded-full`,children:(0,X.jsx)(so,{className:`size-3`})})})]},t))})]})};iE.displayName=`UploadTab`;var aE=()=>{let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!0),[o,s]=(0,Y.useState)(`idle`),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)(null),[f,p]=(0,Y.useState)({}),[m,h]=(0,Y.useState)(`file-list`),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(!1),[b,x]=(0,Y.useState)([]),S=R(),C=fe(),{activeOrganization:w}=z(),{notifications:T,dismissNotification:E,clearAll:D,success:O,error:k,warning:A,info:j}=xT(),M=(e,t,n)=>{switch(e){case`success`:O(t,n);break;case`error`:k(t,n);break;case`warning`:A(t,n);break;case`info`:j(t,n)}},N=S.files.list.queryKey(),F=B(S.files.remove.mutationOptions({onSuccess:()=>{C.invalidateQueries({queryKey:N})}}));(0,Y.useEffect)(function(){let e=P.get$(`file.request`).subscribe(e=>{e.id&&d(e.id),t(!0),s(`idle`),console.log(`event.payload`,e.payload),l([]),x([]);let n=e.payload?.uploadOnly===!0;r(n),a(e.payload?.selectUploadedFile??!0),h(n?`upload`:`file-list`),p({accept:e.payload.accept,multiple:e.payload.multiple,title:e.payload.title,maxSize:e.payload.maxSize,fileType:e.payload.fileType})});return()=>{e.unsubscribe()}},[]);let{refetch:I}=V(S.files.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:w?.id},{enabled:e&&!!w?.id})),L=async e=>{l(t=>[...t,...e]),s(`done`),x([]),await new Promise(e=>setTimeout(e,500));let{data:t}=await I(),n=e.map(e=>{let n=t?.items.find(t=>
114t.id===e.fileId);return n?{...e,backendFile:n}:e});if(n.filter(e=>!e.backendFile).length>0){await new Promise(e=>setTimeout(e,1e3));let{data:e}=await I();n=n.map(t=>{if(t.backendFile)return t;let n=e?.items.find(e=>e.id===t.fileId);return n?{...t,backendFile:n}:t})}if(l(e=>e.map(e=>n.find(t=>t.fileId===e.fileId)??e)),u&&i){let e=n.filter(e=>e.backendFile).map(e=>e.backendFile);e.length>0&&se(e)}},ee=()=>{s(`idle`),h(`upload`)},te=e=>{_(e)},ne=async()=>{if(y(!0),g)try{await F.mutateAsync({ids:[g],deleteFromS3:!0}),l(e=>e.filter(e=>e.fileId!==g)),_(null),J.success(`File deleted successfully`)}catch(e){console.error(`Failed to delete file:`,e),J.error(`Failed to delete file from server`)}finally{y(!1)}},re=()=>{_(null)},ie=e=>{t(e),e||(l([]),s(`idle`),_(null),d(null),x([]),a(!0))},ae=e=>{f.multiple?x(t=>t.some(t=>t.id===e.id)?t.filter(t=>t.id!==e.id):[...t,e]):x([e])},oe=()=>{if(!u)return;let e=c.filter(e=>e.backendFile).map(e=>({type:`file`,id:e.fileId,url:e.backendFile?.url??``,mimetype:e.backendFile?.mimetype??``,metadata:e.backendFile?.metadata??{}}));P.publish({type:`file.response`,id:xr(),source:u,payload:{requestId:xr(),files:e}}),t(!1),d(null),l([]),s(`idle`)},se=e=>{if(!u)return;let n=e.map(e=>({type:`file`,id:e.id??``,url:e.url??``,mimetype:e.mimetype??``,metadata:e.metadata??{}}));P.publish({type:`file.response`,id:xr(),source:u,payload:{requestId:xr(),files:n}}),t(!1),d(null),x([])},ce=()=>{b.length>0&&se(b)},le=e=>{se([e])};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ar,{open:e,onOpenChange:ie,children:(0,X.jsxs)(pr,{className:`flex max-h-[80svh] w-full max-w-[80vw] flex-col gap-2`,children:[(0,X.jsx)(bT,{notifications:T,onDismiss:E,onClearAll:D}),(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:n?`Upload Files`:`Select or Upload Files`}),(0,X.jsx)(_r,{children:n?`Upload files to the server`:`Choose existing files or upload new ones`})]}),n?o===`done`?(0,X.jsx)(ST,{uploadedFiles:c,filters:f,selectedFiles:b,onToggleSelection:ae,onAddMore:ee,onDone:oe,onSelect:void 0,onSelectFile:void 0,onDelete:te}):(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsx)(iE,{filters:f,onUploadComplete:L,onNotification:M}),c.length>0&&(0,X.jsxs)(U,{variant:`outline`,onClick:()=>{s(`done`)},children:[`View Uploaded Files (`,c.length,`)`]})]}):(0,X.jsxs)(pu,{value:m,onValueChange:h,className:`flex flex-1 flex-col overflow-hidden`,children:[(0,X.jsxs)(hu,{className:`border border-neutral-200 bg-neutral-100 shadow-xs dark:border-border/70 dark:bg-muted/60`,children:[(0,X.jsx)(gu,{value:`file-list`,children:`All Files`}),(0,X.jsx)(gu,{value:`upload`,children:`Upload New`})]}),(0,X.jsx)(_u,{value:`file-list`,className:`p-2`,children:(0,X.jsx)(_T,{filters:f,selectedFiles:b,onToggleSelection:ae,onSelect:f.multiple?ce:void 0,onSelectFile:f.multiple?void 0:le,isOpen:e&&m===`file-list`})}),(0,X.jsx)(_u,{value:`upload`,className:`flex flex-col gap-4 p-2`,children:o===`done`?(0,X.jsx)(ST,{uploadedFiles:c,filters:f,selectedFiles:b,onToggleSelection:ae,onAddMore:ee,onDone:oe,onSelect:f.multiple?ce:void 0,onSelectFile:f.multiple?void 0:le,onDelete:te}):(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[(0,X.jsx)(iE,{filters:f,onUploadComplete:L,onNotification:M}),c.length>0&&(0,X.jsxs)(U,{variant:`outline`,onClick:()=>{s(`done`),h(`upload`)},children:[`View Uploaded Files (`,c.length,`)`]})]})})]})]})}),(0,X.jsx)(cr,{open:!!g,onOpenChange:e=>!e&&re(),children:(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:`Delete File`}),(0,X.jsx)(Cr,{children:`Are you sure you want to delete this file? This will permanently delete the file from the server. This action cannot be undone.`})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{disabled:v,onClick:re,className:q(`bg-secondary hover:bg-secondary/80`,v&&`cursor-not-allowed opacity-50`),children:`Cancel`}),(0,X.jsx)(sr,{disabled:v,onClick:ne,className:q(`bg-red-600 hover:bg-red-700`,v&&`cursor-not-allowed opacity-50`),children:`Delete`})]})]})})]})};aE.displayName=`FilesDialog`;var oE=2e3,sE=4194304;function cE(e,t,n){let r=[],i=[],a=0;for(let o of e){let e=JSON.stringify(o).length+1;i.length>0&&(i.length>=t||a+e>n)&&(r.push(i),i=[],a=0),i.push(o),a+=e}return i.length>0&&r.push(i),r}function lE(e,t){let n=[];for(let r=0;r<e.length;r+=t)n.push(e.slice(r,r+t));return n}async function uE(e){let t=[];for(let n=0;;n+=1){let r=await e(n);if(t.push(...r.items),r.items.length<2e3)return t}}function dE(e,t){let n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=e,document.body.appendChild(r),r.click(),document.body.removeChild(r),URL.revokeObjectURL(n)}function fE(e,t){return{queryKey:[...e,`allPages`],queryFn:()=>uE(e=>t({pageIndex:e,pageSize:oE}))}}function pE(){let e=R(),t=fe(),n=md(),r=ko(),i=r.find(e=>e.isDefault)?.languageCode??r[0]?.languageCode??`en`,[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null);(0,Y.useEffect)(function(){let e=P.get$(`label.request`).subscribe(e=>{e.id&&(o({id:e.id,collectionId:e.payload?.collectionId,key:e.payload?.key,spaceId:e.payload?.spaceId}),c(e.payload?.collectionId??null),u(e.payload?.key??null))});return()=>e.unsubscribe()},[]);let{data:d,isError:f,isLoading:p}=V(e.space.get.queryOptions([a?.spaceId],{enabled:!!a?.spaceId})),m=d?.[0]?.labelCollectionIds??[],{data:h=[],isError:g,isLoading:_}=V(e.localization.labelCollections.get.queryOptions(m,{enabled:!!(a&&m.length>0)})),v=(h.find(e=>e.id===s)??h[0])?.id??null,y=fE(e.localization.labelTranslations.list.queryKey({organizationId:n,labelCollectionId:v??void 0,language:i,isActive:!0}),r=>t.fetchQuery(e.localization.labelTranslations.list.queryOptions({organizationId:n,labelCollectionId:v,language:i,isActive:!0,sorting:[{id:`key`,desc:!1}],pagination:r,columnFilters:[],globalFilter:``}))),{data:b=[],isError:x,isLoading:S}=V({...y,enabled:!!(a&&v)}),C=(0,Y.useMemo)(()=>b.find(e=>e.key===l),[b,l]),w=()=>{o(null),c(null),u(null)},T=()=>{a&&v&&C&&(P.publish({type:`label.response`,id:xr(),source:a.id,payload:{collectionId:v,key:C.key,value:C.value}}),w())},E=p||_||S,D=f||g||x;return(0,X.jsx)(ar,{open:!!a,onOpenChange:e=>!e&&w(),children:(0,X.jsxs)(pr,{className:`max-w-2xl`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:Z(`features.label-selection.dialog.title`)}),(0,X.jsx)(_r,{children:Z(`features.label-selection.dialog.description`)})]}),a?.spaceId?D?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:Z(`features.label-selection.dialog.error`)}):E&&h.length===0?(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:Z(`common.loading`)}):h.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`features.label-selection.dialog.no-collections`)}
114):(0,X.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)($t,{htmlFor:`label-collection-select`,children:Z(`features.label-selection.dialog.collection`)}),(0,X.jsxs)(Vt,{value:v??void 0,items:Object.fromEntries(h.map(e=>[e.id,e.name])),onValueChange:e=>{c(e),u(null)},children:[(0,X.jsx)(Dn,{id:`label-collection-select`,className:`w-full`,children:(0,X.jsx)(Mt,{children:e=>h.find(t=>t.id===e)?.name??Z(`features.label-selection.dialog.collection`)})}),(0,X.jsx)(Dt,{children:h.map(e=>(0,X.jsx)(yn,{value:e.id,children:e.name},e.id))})]})]}),S?(0,X.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:Z(`common.loading`)}):b.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`features.label-selection.dialog.no-labels`)}):(0,X.jsx)(jl,{className:`h-80 rounded-md border`,children:(0,X.jsx)(`div`,{className:`flex flex-col p-2`,children:b.map(e=>(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":l===e.key,className:q(`grid grid-cols-[minmax(0,1fr)_minmax(0,2fr)] gap-4 rounded-md px-3 py-2 text-left text-sm hover:bg-muted`,l===e.key&&`bg-muted`),onClick:()=>u(e.key),children:[(0,X.jsx)(`span`,{className:`truncate font-mono text-xs`,children:e.key}),(0,X.jsx)(`span`,{children:e.value})]},e.id))})})]}):(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`features.label-selection.dialog.no-space`)}),(0,X.jsxs)(lr,{children:[(0,X.jsx)(U,{type:`button`,variant:`outline`,onClick:w,children:Z(`common.cancel`)}),(0,X.jsx)(U,{type:`button`,disabled:!C,onClick:T,children:Z(`common.select`)})]})]})})}pE.displayName=`LabelSelectionDialog`;function mE(){return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(aE,{}),(0,X.jsx)(Zw,{}),(0,X.jsx)(pE,{})]})}function hE(){return(0,X.jsx)(X.Fragment,{children:(0,X.jsx)(fT,{})})}function gE(e){if(typeof e!=`object`||!e)return;let t=e.data;return typeof t?.code==`string`?t.code:void 0}function _E({className:e,invitationId:t,organizationSlug:n}){let[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),{session:s,client:l,refetchSession:u,signOut:d}=z(),f=R(),p=c(),m=C(),{theme:h,setTheme:g}=qn(),_=B(f.user.acceptInvitationExistingUser.mutationOptions()),v=()=>{p(`/signin`,{state:{from:{pathname:m.pathname,search:m.search}}})},y=async()=>{i(null);try{if(await _.mutateAsync({invitationId:t}),n)try{await l.organization.setActive({organizationSlug:n})}catch(e){console.error(`Failed to set active organization`,e)}await u(),J.success(Z(`routes.accept-invitation.success`)),p(n?`/${n}/dashboard`:`/`,{replace:!0})}catch(e){if(gE(e)===`FORBIDDEN`){o(!0);return}console.error(`Failed to accept invitation`,e),i(Z(`routes.accept-invitation.error`))}},b=async()=>{await d(),v()},x=h===`dark`||h===`system`&&typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches,S=`login`;a?S=`wrong-account`:s&&(S=`accept`);let{Icon:w,title:T,subtitle:E,showSlug:D}={accept:{Icon:Aa,title:Z(`routes.accept-invitation.invited.title`),subtitle:Z(`routes.accept-invitation.invited.subtitle`),showSlug:!0},login:{Icon:Kr,title:Z(`routes.accept-invitation.login.title`),subtitle:Z(`routes.accept-invitation.login.subtitle`),showSlug:!0},"wrong-account":{Icon:Qr,title:Z(`routes.accept-invitation.wrong-account.title`),subtitle:Z(`routes.accept-invitation.wrong-account.subtitle`),showSlug:!1}}[S];return(0,X.jsxs)(`div`,{className:q(`w-full max-w-107`,e),children:[(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`fixed top-4 right-4 z-50 text-muted-foreground hover:text-foreground`,onClick:()=>g(x?`light`:`dark`),"aria-label":x?`Switch to light mode`:`Switch to dark mode`,children:x?(0,X.jsx)(fa,{className:`size-4`}):(0,X.jsx)(si,{className:`size-4`})}),(0,X.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-8 text-center shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-6 flex flex-col items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-primary/10`,children:(0,X.jsx)(w,{className:`h-7 w-7 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`text-[1.75rem] font-normal tracking-tight text-foreground`,children:T}),(0,X.jsxs)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:[E,D&&n?(0,X.jsxs)(`span`,{className:`font-medium text-foreground`,children:[` `,n]}):null]})]})]}),(0,X.jsx)(Vo,{error:r}),S===`accept`&&(0,X.jsx)(U,{type:`button`,className:`mt-2 h-12 w-full rounded-full text-base font-medium`,size:`lg`,onClick:y,disabled:_.isPending,children:_.isPending?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(An,{className:`mr-2 h-4 w-4`}),Z(`common.accept.invitation`),`…`]}):Z(`common.accept.invitation`)}),S===`login`&&(0,X.jsx)(U,{type:`button`,className:`mt-2 h-12 w-full rounded-full text-base font-medium`,size:`lg`,onClick:v,children:Z(`routes.accept-invitation.login.button`)}),S===`wrong-account`&&(0,X.jsx)(U,{type:`button`,className:`mt-2 h-12 w-full rounded-full text-base font-medium`,size:`lg`,onClick:b,children:Z(`routes.accept-invitation.wrong-account.button`)})]}),(0,X.jsx)(ds,{})]})}_E.displayName=`AcceptInvitationCard`;var vE=lt({name:H().trim().min(1,`First name is required`),password:H().min(8,`Password must be at least 8 characters`).refine(e=>/[A-Z]/.test(e),`Password must contain one uppercase letter`).refine(e=>/[a-z]/.test(e),`Password must contain one lowercase letter`).refine(e=>/\d/.test(e),`Password must contain one number`).refine(e=>/[^A-Za-z0-9]/.test(e),`Password must contain one special character`),confirmPassword:H().min(8)}).refine(e=>e.password===e.confirmPassword,{message:Z(`routes.signup.password.error.match`),path:[`confirmPassword`]}),yE=[{key:`routes.signup.password.must.contain.at.least.8.characters`,test:e=>e.length>=8},{key:`routes.signup.password.must.contain.one.uppercase.letter`,test:e=>/[A-Z]/.test(e)},{key:`routes.signup.password.must.contain.one.lowercase.letter`,test:e=>/[a-z]/.test(e)},{key:`routes.signup.password.must.contain.one.number`,test:e=>/\d/.test(e)},{key:`routes.accept-invitation.password.must.contain.one.special.character`,test:e=>/[^A-Za-z0-9]/.test(e)}];function bE({password:e}){let t=e.length===0;return(0,X.jsx)(`ul`,{className:`mt-1.5 space-y-1 pl-0.5`,children:yE.map(({key:n,test:r})=>{let i=r(e);return(0,X.jsxs)(`li`,{className:q(`flex items-center gap-1.5 text-xs transition-colors`,{"text-muted-foreground":t,"text-green-600 dark:text-green-400":!t&&i,"text-destructive":!t&&!i}),children:[(0,X.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`}),Z(n)]},n)})})}function xE({className:e,invitationId:t,organizationSlug:n}){let[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,u]=(0,Y.useState)(!1),d=R(),{client:f,refetchSession:p}=z(),m=c(),{theme:g,setTheme:_}=qn(),v=d.user.acceptInvitation.mutationOptions(),y=B(v),b=l({resolver:pn(vE),defaultValues:{name:``,password:``,confirmPassword:``}}),x=async e=>{if(!t){i(Z(`routes.accept-invitation.missing`));return}i(null);try{if(await y.mutateAsync({invitationId:t,password:e.password,name:e.name}),n)try{await f.organization.setActive({organizationSlug:n})}catch(e){console.error(`Failed to set active organization`,e)}await p(),J.success(Z(`routes.accept-invitation.success`)),m(n?`/${n}/dashboard`:`/`,{replace:!0})}catch{i(Z(`routes.accept-invitation.error`))}},S=y.isPending||b.formState.isSubmitting,C=!t,w=g===`dark`||g===`system`&&typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches;return(0,X.jsxs)(`div`,{className:q(`w-full max-w-107`,e),children:[(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`fixed top-4 right-4 z-50 text-muted-foreground hover:text-foreground`,onClick:()=>_(w?`light`:`dark`),"aria-label":w?`Switch to light mode`:`Switch to dark mode`,children:w?(0,X.jsx)(fa,{className:`size-4`}):(0,X.jsx)(si,{className:`size-4`})}),(0,X.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-8 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-primary/10`,children:(0,X.jsx)(Di,{className:`h-7 w-7 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`h1`,{className:`text-[1.75rem] font-normal tracking-tight text-foreground`,children:Z(`common.accept.invitation`)}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:Z(`routes.accept-invitation.autheader.subtitle`)})]})]}),(0,X.jsxs)(`form`,{onSubmit:b.handleSubmit(x),className:`space-y-5`,children:[(0,X.jsx)(Vo,{error:C?Z(`routes.accept-invitation.missing`):r}),(0,X.jsx)(h,{control:b.control,name:`name`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":!!t.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`routes.accept-invitation.first.name`)}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,type:`text`,autoComplete:`given-name`,disabled:S||C,className:`h-12 rounded-lg border-input bg-background px-4 focus-visible:ring-2 focus-visible:ring-primary/30`})}),(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:b.control,name:`password`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":!!t.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`common.password`)}),(0,X.jsx)(ln,{children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(W,{...e,type:a?`text`:`password`,autoComplete:`new-password`,disabled:S||C,className:`h-12 rounded-lg border-input bg-background px-4 pr-12 focus-visible:ring-2 focus-visible:ring-primary/30`}),e.value.length>0&&(0,X.jsx)(U,{variant:`ghost`,size:`icon`,type:`button`,className:`absolute top-0 right-0 h-12 w-12 text-muted-foreground hover:bg-transparent hover:text-foreground`,onClick:()=>o(!a),"aria-label":a?`Hide password`:`Show password`,children:a?(0,X.jsx)(li,{className:`h-4 w-4`}):(0,X.jsx)(Rr,{className:`h-4 w-4`})})]})}),(0,X.jsx)(bE,{password:e.value}),(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:b.control,name:`confirmPassword`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":!!t.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`common.confirm.password`)}),(0,X.jsx)(ln,{children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(W,{...e,type:s?`text`:`password`,autoComplete:`new-password`,disabled:S||C,className:`h-12 rounded-lg border-input bg-background px-4 pr-12 focus-visible:ring-2 focus-visible:ring-primary/30`}),e.value.length>0&&(0,X.jsx)(U,{variant:`ghost`,size:`icon`,type:`button`,className:`absolute top-0 right-0 h-12 w-12 text-muted-foreground hover:bg-transparent hover:text-foreground`,onClick:()=>u(!s),"aria-label":s?`Hide password`:`Show password`,children:s?(0,X.jsx)(li,{className:`h-4 w-4`}):(0,X.jsx)(Rr,{className:`h-4 w-4`})})]})}),(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(U,{type:`submit`,className:`mt-2 h-12 w-full rounded-full text-base font-medium`,size:`lg`,disabled:S||C,children:S?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(An,{className:`mr-2 h-4 w-4`}),Z(`common.accept.invitation`),`…`]}):Z(`common.accept.invitation`)})]})]}),(0,X.jsx)(ds,{})]})}xE.displayName=`AcceptInvitationForm`;var SE=({className:e,...t})=>{let[n]=o(),{organizationSlug:r}=S(),i=c(),{isLoadingSession:a}=z(),[s]=(0,Y.useState)(n.get(`invitation`)??void 0),[l]=(0,Y.useState)(n.get(`alreadyexisting`)===`1`);if((0,Y.useEffect)(()=>{s||i(`/`,{replace:!0})},[s,i]),!s)return null;let u=l;return a?(0,X.jsx)(`div`,{className:q(`flex h-svh items-center justify-center bg-muted/50 p-4 sm:p-6`,e),role:`status`,"aria-label":`Loading`,...t,children:(0,X.jsx)(An,{className:`size-10`})}):(0,X.jsx)(`div`,{className:q(`flex h-svh items-center justify-center overflow-y-auto bg-muted/50 p-4 sm:p-6`,e),...t,children:u?(0,X.jsx)(_E,{inv
114itationId:s,organizationSlug:r}):(0,X.jsx)(xE,{invitationId:s,organizationSlug:r})})};SE.displayName=`AcceptInvitation`;function CE({title:e,actions:t,className:n,...r}){return(0,X.jsxs)(`header`,{className:q(`flex flex-col gap-2 border-b border-border px-6 py-3 sm:flex-row sm:items-center sm:justify-between`,n),"aria-label":`Page header`,"data-quick-help":`page-header`,...r,children:[(0,X.jsx)(`h1`,{className:`text-xl font-bold`,children:e}),t&&(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:t})]})}var wE=({children:e,className:t,...n})=>(0,X.jsx)(`div`,{className:q(`min-h-0 flex-1 overflow-x-hidden overflow-y-auto px-6 py-4`,$n({style:`base`}),t),"data-quick-help":`page-content`,...n,children:e});wE.displayName=`PagesContentContainer`;var TE=()=>{let{session:e,client:t,refetchSession:n}=z(),[r,i]=(0,Y.useState)(null);(0,Y.useEffect)(function(){if(!r)return;let a=P.get$(`file.response`).pipe(O(e=>e.source===r)).subscribe(async r=>{if(r.payload&&`files`in r.payload){let a=r.payload.files[0];if(a?.url)try{await t.admin.updateUser({userId:e?.user.id||``,data:{image:a.url}}),n(),J.success(`Avatar updated successfully`)}catch(e){console.error(`Failed to update avatar:`,e),J.error(`Failed to update avatar`)}i(null)}});return()=>{a.unsubscribe()}},[r,t,e,n]);let a=()=>{let e=xr();i(e),P.publish({type:`file.request`,id:e,payload:{fileType:`image`,multiple:!1,title:`Select Avatar Image`,uploadOnly:!1}})};return(0,X.jsxs)(`div`,{className:`flex items-center gap-8 rounded-xl border border-border bg-card p-8`,children:[(0,X.jsx)(`div`,{className:`group relative`,children:(0,X.jsx)(`div`,{className:`cursor-pointer overflow-hidden rounded-full ring-4 ring-primary/20 transition-transform duration-500 group-hover:scale-105`,onClick:a,children:(0,X.jsxs)(rs,{className:`h-32 w-32`,children:[(0,X.jsx)(is,{src:e?.user.image||``}),(0,X.jsx)(as,{className:`text-2xl`,children:e?.user.image?e?.user.name.charAt(0):(0,X.jsx)(oo,{className:`h-8 w-8 text-muted-foreground`})})]})})}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h3`,{className:`text-xl font-bold`,children:e?.user.name}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`JPG, PNG or GIF. Max size 2MB.`}),(0,X.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,X.jsx)(`button`,{type:`button`,className:`text-[10px] font-bold tracking-widest text-primary uppercase hover:underline`,onClick:a,children:`Upload New`}),e?.user.image&&(0,X.jsx)(`button`,{type:`button`,className:`text-[10px] font-bold tracking-widest text-destructive/70 uppercase hover:text-destructive`,onClick:async()=>{try{await t.admin.updateUser({userId:e?.user.id||``,data:{image:``}}),n(),J.success(`Avatar removed`)}catch(e){console.error(`Failed to remove avatar:`,e),J.error(`Failed to remove avatar`)}},children:`Remove`})]})]})]})};TE.displayName=`AccountAvatar`;var EE=({className:e,...t})=>{let{client:n,refetchSession:r}=z(),i=c(),[a,o]=(0,Y.useState)(!1),[s,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),m=s.trim().toLowerCase()===`delete`&&u.length>0&&!f,h=window.location.origin+`/goodbye?deleted=1`,g=()=>{l(``),d(``)},_=e=>{o(e),e||g()},v=async e=>{if(e.preventDefault(),m){p(!0);try{await n.deleteUser({password:u,callbackURL:h}),J.success(Z(`components.account.delete.account.alert.success`)),await r(),o(!1),g(),i(`/`,{replace:!0})}catch(e){console.error(`Failed to delete account:`,e),J.error(Z(`components.account.delete.account.alert.error`))}finally{p(!1)}}};return(0,X.jsxs)(`div`,{className:q(`flex flex-col items-center justify-between gap-8 rounded-2xl border border-destructive/10 bg-destructive/5 p-8 md:flex-row`,e),...t,children:[(0,X.jsxs)(`div`,{className:`space-y-2 text-center md:text-left`,children:[(0,X.jsx)(`h3`,{className:`text-2xl font-extrabold tracking-tighter text-destructive uppercase`,children:Z(`common.delete.account`)}),(0,X.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:Z(`components.account.delete.account.description`)})]}),(0,X.jsxs)(cr,{open:a,onOpenChange:_,children:[(0,X.jsx)(Nn,{render:e=>(0,X.jsx)(U,{variant:`outline`,className:`shrink-0 rounded-full border-2 border-destructive px-8 py-4 text-[11px] font-bold tracking-[0.2em] text-destructive uppercase hover:bg-destructive hover:text-destructive-foreground`,...e,children:Z(`common.delete.account`)})}),(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:Z(`components.account.delete.account.alert.title`)}),(0,X.jsx)(Cr,{children:Z(`components.account.delete.account.alert.description`)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`label`,{htmlFor:`delete-account-verification`,className:`text-xs font-medium text-muted-foreground`,children:Z(`components.account.delete.account.alert.verification.label`)}),(0,X.jsx)(W,{id:`delete-account-verification`,type:`text`,autoComplete:`off`,value:s,onChange:e=>l(e.target.value),placeholder:Z(`components.account.delete.account.alert.placeholder`),disabled:f})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`label`,{htmlFor:`delete-account-password`,className:`text-xs font-medium text-muted-foreground`,children:Z(`common.password`)}),(0,X.jsx)(W,{id:`delete-account-password`,type:`password`,autoComplete:`current-password`,value:u,onChange:e=>d(e.target.value),disabled:f})]})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{disabled:f,children:Z(`common.cancel`)}),(0,X.jsx)(sr,{variant:`destructive`,disabled:!m,onClick:v,children:Z(`components.account.delete.account.alert.delete`)})]})]})]})]})};EE.displayName=`DeleteAccount`;var DE=lt({email:H().email()}),OE=({className:e,...t})=>{let{client:n,session:r}=z(),i=l({resolver:pn(DE),defaultValues:{email:r?.user?.email}}),a=async e=>{let t=e.email;try{await n.changeEmail({newEmail:t,callbackURL:window.location.href}),J.success(`Success!`,{description:`A verification email has been sent to your new address`})}catch(e){console.error(e),J.error(`Error changing email`)}};return(0,X.jsx)(`div`,{className:q(`space-y-2`,e),...t,children:(0,X.jsx)(_,{...i,children:(0,X.jsxs)(`form`,{onSubmit:i.handleSubmit(a),id:`email-change-form`,children:[(0,X.jsx)(`label`,{className:`block px-1 text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`common.email`)}),(0,X.jsx)(h,{name:`email`,control:i.control,render:({field:e})=>(0,X.jsx)(W,{...e,placeholder:Z(`components.account.email.change.placeholder`),type:`email`,className:`mt-2 rounded-lg border-0 border-b-2 border-transparent bg-muted px-4 py-3 transition-all outline-none focus:border-primary focus:ring-0`})}),i.formState.isDirty&&(0,X.jsx)(U,{type:`submit`,size:`sm`,className:`mt-3`,disabled:i.formState.isSubmitting,children:i.formState.isSubmitting?`Saving...`:`Save`})]})})})};OE.displayName=`EmailChange`;var kE=lt({name:H().min(1)}),AE=({className:e,...t})=>{let{client:n,session:r}=z(),i=l({resolver:pn(kE),defaultValues:{name:r?.user?.name}}),a=async e=>{let t=e.name;try{await n.updateUser({name:t}),J.success(`Success !`,{description:`Your name has been changed successfully`})}catch(e){console.error(e),J.error(`Error changing name`)}};return(0,X.jsx)(`div`,{className:q(`space-y-2`,e),...t,children:(0,X.jsx)(_,{...i,children:(0,X.jsxs)(`form`,{onSubmit:i.handleSubmit(a),id:`name-change-form`,children:[(0,X.jsx)(`label`,{className:`block px-1 text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`common.name`)}),(0,X.jsx)(h,{control:i.control,name:`name`,render:({field:e})=>(0,X.jsx)(W,{...e,placeholder:Z(`common.name`),type:`text`,className:`mt-2 rounded-lg border-0 border-b-2 border-transparent bg-muted px-4 py-3 transition-all outline-none focus:border-primary focus:ring-0`})}),i.formState.isDirty&&(0,X.jsx)(U,{type:`submit`,size:`sm`,className:`mt-3`,disabled:i.formState.isSubmitting,children:i.formState.isSubmitting?`Saving...`:`Save`})]})})})};AE.displayName=`NameChange`;var jE=lt({currentPassword:H().min(1),newPassword:H().min(8,`Password must be at least 8 characters`),confirmPassword:H().min(1)}).refine(e=>e.newPassword===e.confirmPassword,{message:`Passwords do not match`,path:[`confirmPassword`]}),ME=({className:e,...t})=>{let{client:n}=z(),r=l({resolver:pn(jE),defaultValues:{currentPassword:``,newPassword:``,confirmPassword:``}}),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,u]=(0,Y.useState)(!1),d=async e=>{let t=await n.changePassword({currentPassword:e.currentPassword,newPassword:e.newPassword});t.error?J.error(`Error changing password`,{description:t.error.message??`Please try again.`}):(J.success(`Password changed`,{description:`Your password has been updated successfully.`}),r.reset())};return(0,X.jsx)(`div`,{className:q(`rounded-xl border border-border bg-card p-8`,e),...t,children:(0,X.jsxs)(`form`,{onSubmit:r.handleSubmit(d),className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(h,{control:r.control,name:`currentPassword`,render:({field:e,fieldState:t})=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-2 block text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`common.current.password`)}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(W,{...e,"data-invalid":t.invali
114d||void 0,placeholder:Z(`common.current.password`),type:i?`text`:`password`,autoComplete:`current-password`,className:`rounded-lg bg-muted pr-12 outline-none focus:ring-2 focus:ring-primary/20`}),(0,X.jsx)(`button`,{type:`button`,className:`absolute top-1/2 right-4 -translate-y-1/2 text-muted-foreground hover:text-primary`,onClick:()=>a(!i),"aria-label":i?`Hide password`:`Show password`,children:i?(0,X.jsx)(li,{className:`size-5`}):(0,X.jsx)(Rr,{className:`size-5`})})]}),t.error&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:t.error.message})]})}),(0,X.jsx)(h,{control:r.control,name:`newPassword`,render:({field:e,fieldState:t})=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-2 block text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`common.new.password`)}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(W,{...e,"data-invalid":t.invalid||void 0,placeholder:Z(`common.new.password`),type:o?`text`:`password`,autoComplete:`new-password`,className:`rounded-lg bg-muted pr-12 outline-none focus:ring-2 focus:ring-primary/20`}),(0,X.jsx)(`button`,{type:`button`,className:`absolute top-1/2 right-4 -translate-y-1/2 text-muted-foreground hover:text-primary`,onClick:()=>s(!o),"aria-label":o?`Hide password`:`Show password`,children:o?(0,X.jsx)(li,{className:`size-5`}):(0,X.jsx)(Rr,{className:`size-5`})})]}),t.error&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:t.error.message})]})}),(0,X.jsx)(h,{control:r.control,name:`confirmPassword`,render:({field:e,fieldState:t})=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`mb-2 block text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`common.confirm.new.password`)}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(W,{...e,"data-invalid":t.invalid||void 0,placeholder:Z(`common.confirm.new.password`),type:c?`text`:`password`,autoComplete:`new-password`,className:`rounded-lg bg-muted pr-12 outline-none focus:ring-2 focus:ring-primary/20`}),(0,X.jsx)(`button`,{type:`button`,className:`absolute top-1/2 right-4 -translate-y-1/2 text-muted-foreground hover:text-primary`,onClick:()=>u(!c),"aria-label":c?`Hide password`:`Show password`,children:c?(0,X.jsx)(li,{className:`size-5`}):(0,X.jsx)(Rr,{className:`size-5`})})]}),t.error&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-destructive`,children:t.error.message})]})})]}),(0,X.jsxs)(U,{type:`submit`,className:`rounded-full px-6 py-2.5`,disabled:r.formState.isSubmitting,children:[r.formState.isSubmitting?(0,X.jsx)(An,{className:`mr-2 size-4`}):(0,X.jsx)(Ra,{className:`mr-2 size-4`}),Z(`common.change.password`)]})]})})};ME.displayName=`PasswordChange-component`;var NE=[[`Edge`,/Edg\/([\d.]+)/i],[`Chrome`,/Chrome\/([\d.]+)/i],[`Firefox`,/Firefox\/([\d.]+)/i],[`Safari`,/Version\/([\d.]+)\s+Safari/i],[`Mobile Safari`,/Mobile\/[^\s]+\s+Version\/([\d.]+)\s+Safari/i],[`Opera`,/OPR\/([\d.]+)/i],[`IE`,/MSIE\s([\d.]+)/i],[`IE`,/Trident\/[^\s]+\s+rv:([\d.]+)/i]],PE=[[`Windows`,/Windows NT [\d.]+/i],[`macOS`,/Mac OS X [\d_]+/i],[`iOS`,/iPhone|iPad|iPod/i],[`Android`,/Android [\d.]+/i],[`Linux`,/Linux|X11/i],[`ChromeOS`,/CrOS/i]];function FE(e){return/bot|crawl|spider|slurp|bingpreview/i.test(e)?`bot`:/tablet|ipad|playbook|silk/i.test(e)?`tablet`:/mobi|iphone|ipod|android(?!.*tablet)/i.test(e)?`mobile`:/tv|smarttv|hbbtv|appletv|googletv|roku/i.test(e)?`tv`:`desktop`}function IE(e,t){for(let[n,r]of e){let e=t.match(r);if(e)return[n,e[1]]}return null}function LE(e){let t=e||``,n=IE(NE,t),r=IE(PE,t),i=FE(t);return{browser:n?n[0]:`Unknown`,browserVersion:n?.[1],os:r?r[0]:`Unknown`,device:i}}var RE=({className:e,...t})=>{let[n,r]=(0,Y.useState)(void 0),{session:i,client:a}=z(),[o,s]=(0,Y.useState)();(0,Y.useEffect)(function(){if(!i?.user.id)return;let e=!1;return a.admin.listUserSessions({userId:i.user.id}).then(t=>{e||(r(t.data?.sessions.filter(e=>e.token!==(i?.session).token)),s(LE(t.data?.sessions?.[0]?.userAgent??``)))}),()=>{e=!0}},[i?.user.id,i?.session,a]);let c=async e=>{try{await a.admin.revokeUserSession({sessionToken:e}),r(n?.filter(t=>t.token!==e)),J.success(Z(`components.account.sessions.success`),{description:Z(`components.account.sessions.revoke.success`)})}catch(e){console.error(`revokeSession`,e),J.error(Z(`common.error`),{description:Z(`components.account.sessions.revoke.error`)})}};return(0,X.jsx)(`div`,{className:q(`overflow-hidden rounded-xl border border-border bg-card`,e),...t,children:(0,X.jsxs)(vu,{className:`w-full text-left`,children:[(0,X.jsx)(yu,{className:`border-b border-border bg-muted`,children:(0,X.jsxs)(xu,{children:[(0,X.jsxs)(Su,{className:`px-6 py-4 text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:[Z(`components.account.sessions.device`),` /`,` `,Z(`components.account.sessions.browser`)]}),(0,X.jsx)(Su,{className:`px-6 py-4 text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`components.account.sessions.ip.address`)}),(0,X.jsx)(Su,{className:`px-6 py-4 text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`components.account.sessions.os`)}),(0,X.jsx)(Su,{className:`px-6 py-4 text-right text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`components.account.sessions.revoke`)})]})}
114),(0,X.jsxs)(bu,{className:`divide-y divide-border`,children:[(0,X.jsxs)(xu,{className:`transition-colors hover:bg-accent/50`,children:[(0,X.jsx)(Cu,{className:`px-6 py-5`,children:(0,X.jsx)(`div`,{className:`flex items-center gap-3`,children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:o?.device||`Current Device`}),(0,X.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[o?.browser,` ·`,` `,o?.os]})]})})}),(0,X.jsxs)(Cu,{className:`px-6 py-5 text-sm text-muted-foreground`,children:[(0,X.jsx)(`p`,{children:i?.session.ipAddress}),(0,X.jsx)(`p`,{className:`text-[10px] opacity-50`,children:$i(i?.session.createdAt??new Date,`dd-MM-yyyy HH:mm`)})]}),(0,X.jsx)(Cu,{className:`px-6 py-5`,children:(0,X.jsx)(`span`,{className:`rounded bg-primary/10 px-2 py-1 text-[9px] font-bold tracking-widest text-primary uppercase`,children:`Current`})}),(0,X.jsx)(Cu,{className:`px-6 py-5 text-right`,children:(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`text-xs font-bold text-muted-foreground hover:text-foreground`,onClick:()=>c(i?.session.token??``),children:Z(`components.account.sessions.sign.out`)})})]}),n&&n.map(e=>{let{browser:t,os:n,device:r}=LE(e.userAgent??``);return(0,X.jsxs)(xu,{className:`transition-colors hover:bg-accent/50`,children:[(0,X.jsx)(Cu,{className:`px-6 py-5`,children:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:r||`Unknown Device`}),(0,X.jsxs)(`p`,{className:`text-[10px] text-muted-foreground`,children:[t,` · `,n]})]})}),(0,X.jsxs)(Cu,{className:`px-6 py-5 text-sm text-muted-foreground`,children:[(0,X.jsx)(`p`,{children:e.ipAddress}),(0,X.jsx)(`p`,{className:`text-[10px] opacity-50`,children:$i(e.createdAt,`dd-MM-yyyy HH:mm`)})]}),(0,X.jsx)(Cu,{className:`px-6 py-5`,children:(0,X.jsx)(`span`,{className:`rounded bg-accent px-2 py-1 text-[9px] font-bold tracking-widest text-muted-foreground uppercase`,children:`Active`})}),(0,X.jsx)(Cu,{className:`px-6 py-5 text-right`,children:(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`text-xs font-bold text-muted-foreground hover:text-destructive`,onClick:()=>c(e.token),children:Z(`components.account.sessions.revoke`)})})]},e.id)})]})]})})};RE.displayName=`Sessions`;var zE=()=>(0,X.jsxs)(`div`,{className:`w-full max-w-5xl space-y-12`,children:[(0,X.jsxs)(`section`,{className:`grid gap-8 md:grid-cols-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold`,children:Z(`common.profile`)}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:Z(`components.account.section.profile.description`)})]}),(0,X.jsxs)(`div`,{className:`space-y-6 md:col-span-2`,children:[(0,X.jsx)(TE,{}),(0,X.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,X.jsx)(AE,{}),(0,X.jsx)(OE,{})]})]})]}),(0,X.jsxs)(`section`,{className:`grid gap-8 border-t border-border pt-8 md:grid-cols-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold`,children:Z(`components.account.section.security`)}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:Z(`components.account.section.security.description`)})]}),(0,X.jsx)(`div`,{className:`space-y-6 md:col-span-2`,children:(0,X.jsx)(ME,{})})]}),(0,X.jsxs)(`section`,{className:`border-t border-border pt-8`,children:[(0,X.jsxs)(`div`,{className:`mb-6`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold`,children:Z(`components.account.sessions.title`)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:Z(`components.account.section.security.description`)})]}),(0,X.jsx)(RE,{})]}),(0,X.jsx)(`section`,{className:`border-t border-destructive/20 pt-8`,children:(0,X.jsx)(EE,{})})]});zE.displayName=`AccountComponent`;var BE=()=>(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.account`)}),(0,X.jsx)(wE,{children:(0,X.jsx)(zE,{})})]});BE.displayName=`Account`;var VE=class extends Y.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(e){return{hasError:!0,error:e}}componentDidCatch(e,t){console.error(`Content Manager Error:`,e,t)}render(){return this.state.hasError?this.props.fallback?this.props.fallback:(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center p-8`,children:(0,X.jsxs)(`div`,{className:`text-center space-y-4 max-w-md`,children:[(0,X.jsx)(`div`,{className:`flex justify-center`,children:(0,X.jsx)($r,{className:`size-12 text-destructive`})}),(0,X.jsx)(`h2`,{className:`text-lg font-semibold`,children:`Something went wrong`}),(0,X.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:this.state.error?.message||`An unexpected error occurred`}),(0,X.jsx)(`button`,{onClick:()=>window.location.reload(),className:`px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors`,children:`Reload Page`})]})}):this.props.children}},HE=(0,Y.createContext)(null);function UE(){let e=(0,Y.useContext)(HE);if(!e)throw Error(`useContentManager must be used within ContentManagerProvider`);return e}var WE={languageCode:`en`,name:`English`,nativeName:`English`,isDefault:!0,order:1};function GE(e){let t=e.filter(e=>/^en(?:-|$)/i.test(e.languageCode));return{...t.find(e=>e.isDefault)??t.find(e=>e.languageCode.toLowerCase()===`en`)??t[0]??WE,isDefault:!0,order:1}}function KE({canDelete:e}){let t=R(),n=fe(),r=md(),{activeOrganization:i,client:a,refetchSession:o}=z(),{setCurrentActiveCollectionId:s,setCurrentActiveLabelCollectionId:c,setCurrentActiveLanguageCode:l}=UE(),[u,d]=(0,Y.useState)(!1),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)({completed:0,total:0}),g=B(t.cms.collections.remove.mutationOptions()),_=B(t.cms.entries.remove.mutationOptions()),v=B(t.localization.entryTranslations.remove.mutationOptions()),y=B(t.localization.labelCollections.remove.mutationOptions()),b=B(t.localization.labelTranslations.remove.mutationOptions());if(!e)return null;let x=async()=>{p(!0),h({completed:0,total:0});try{let e=[{id:`id`,desc:!1}],[u,f,p,m,x]=await Promise.all([uE(i=>n.fetchQuery({...t.cms.collections.list.queryOptions({organizationId:r,sorting:e,pagination:{pageIndex:i,pageSize:oE}}),staleTime:0})),uE(i=>n.fetchQuery({...t.cms.entries.list.queryOptions({organizationId:r,sorting:e,pagination:{pageIndex:i,pageSize:oE}}),staleTime:0})),uE(i=>n.fetchQuery({...t.localization.entryTranslations.list.queryOptions({organizationId:r,sorting:e,pagination:{pageIndex:i,pageSize:oE}}),staleTime:0})),uE(i=>n.fetchQuery({...t.localization.labelCollections.list.queryOptions({organizationId:r,sorting:e,pagination:{pageIndex:i,pageSize:oE}}),staleTime:0})),uE(i=>n.fetchQuery({...t.localization.labelTranslations.list.queryOptions({organizationId:r,sorting:e,pagination:{pageIndex:i,pageSize:oE}}),staleTime:0}))]),S=u.length+f.length+p.length+m.length+x.length;h({completed:0,total:S});let C=0,w=async(e,t)=>
114{for(let n of lE(e,200))await t(n),C+=n.length,h({completed:C,total:S})};await w(p.map(e=>e.id),v.mutateAsync),await w(x.map(e=>e.id),b.mutateAsync),await w(f.map(e=>e.id),_.mutateAsync),await w(m.map(e=>e.id),y.mutateAsync),await w(u.map(e=>e.id),g.mutateAsync);let T=i?.metadata&&typeof i.metadata==`object`?i.metadata:{},E=GE(`locales`in T&&Array.isArray(T.locales)?T.locales:[]);await a.organization.update({organizationId:r,data:{metadata:{...T,locales:[E]}}}),await o(),s(``),c(null),l(E.languageCode),localStorage.removeItem(`cms-active-label-collection`),await Promise.all([n.invalidateQueries({queryKey:t.cms.collections.list.queryKey()}),n.invalidateQueries({queryKey:t.cms.entries.list.queryKey()}),n.invalidateQueries({queryKey:t.localization.entryTranslations.list.queryKey()}),n.invalidateQueries({queryKey:t.localization.labelCollections.list.queryKey()}),n.invalidateQueries({queryKey:t.localization.labelTranslations.list.queryKey()})]),J.success(`Content Manager data cleared`),d(!1)}catch(e){J.error(e instanceof Error?`Unable to clear data: ${e.message}`:`Unable to clear data`)}finally{p(!1),h({completed:0,total:0})}};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,className:`border-destructive/50 text-destructive hover:bg-destructive/10`,onClick:()=>d(!0),"aria-label":`Clear all Content Manager data`,children:[(0,X.jsx)(Qi,{className:`size-4`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`hidden xl:inline`,children:`Clear data`})]}),(0,X.jsx)(cr,{open:u,onOpenChange:e=>!f&&d(e),children:(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:`Clear all Content Manager data?`}),(0,X.jsx)(Cr,{children:`This permanently removes every collection, field, entry, label collection, and label, together with their translations. All configured languages are removed except English. UI and system translations are not affected. This action cannot be undone.`})]}),f&&(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:m.total===0?`Reading data…`:`Deleting ${m.completed.toLocaleString()} / ${m.total.toLocaleString()}…`}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{disabled:f,children:`Cancel`}),(0,X.jsxs)(sr,{variant:`destructive`,disabled:f,onClick:e=>{e.preventDefault(),x()},children:[f?(0,X.jsx)(An,{className:`size-4`}):(0,X.jsx)(Qi,{className:`size-4`,"aria-hidden":`true`}),f?`Clearing…`:`Delete all data`]})]})]})})]})}function qE({className:e,children:t,value:n,...r}){return(0,X.jsxs)(Ru,{value:n,"data-slot":`progress`,className:q(`flex flex-wrap gap-3`,e),...r,children:[t,(0,X.jsx)(JE,{children:(0,X.jsx)(YE,{})})]})}function JE({className:e,...t}){return(0,X.jsx)(zu,{className:q(`relative flex h-2 w-full items-center overflow-x-hidden rounded-2xl bg-muted`,e),"data-slot":`progress-track`,...t})}function YE({className:e,...t}){return(0,X.jsx)(Bu,{"data-slot":`progress-indicator`,className:q(`h-full bg-primary transition-all`,e),...t})}function XE({className:e,...t}){return(0,X.jsx)(Hu,{className:q(`text-sm font-medium`,e),"data-slot":`progress-label`,...t})}function ZE({className:e,...t}){return(0,X.jsx)(Vu,{className:q(`ml-auto text-sm text-muted-foreground tabular-nums`,e),"data-slot":`progress-value`,...t})}var QE=20;function $E({message:e,outcome:t}){let n=t.failed>0||t.skipped>0;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(or,{className:n?`border-amber-500/50 bg-amber-500/10`:`border-emerald-500/50 bg-emerald-500/10`,children:[n?(0,X.jsx)($r,{className:`size-4 text-amber-600`}):(0,X.jsx)(ni,{className:`size-4 text-emerald-600`}),(0,X.jsxs)(hr,{className:`space-y-2`,children:[(0,X.jsx)(`span`,{className:`block`,children:e}),n&&(0,X.jsxs)(`span`,{className:`block text-xs`,children:[t.failed.toLocaleString(),` row(s) failed,`,` `,t.skipped.toLocaleString(),` skipped because a parent record could not be created. Re-run the same archive to fill the gaps.`]})]})]}),n&&t.failures.length>0&&(0,X.jsxs)(`ul`,{className:`max-h-40 space-y-1 overflow-y-auto rounded-lg border bg-muted/30 p-3 font-mono text-xs`,children:[t.failures.slice(0,QE).map(e=>(0,X.jsxs)(`li`,{children:[e.step,` batch `,e.batchIndex,` (`,e.count,`):`,` `,e.message]},`${e.step}-${e.batchIndex}`)),t.failures.length>QE&&(0,X.jsxs)(`li`,{className:`text-muted-foreground`,children:[`… and `,t.failures.length-QE,` more, see the report`]})]})]})}$E.displayName=`ImportResultAlert`;var eD={},tD=(function(e,t,n,r,i){var a=new Worker(eD[t]||(eD[t]=URL.createObjectURL(new Blob([e+`;addEventListener("error",function(e){e=e.error;postMessage({$e$:[e.message,e.code,e.stack]})})`],{type:`text/javascript`}))));return a.onmessage=function(e){var t=e.data,n=t.$e$;if(n){var r=Error(n[0]);r.code=n[1],r.stack=n[2],i(r,null)}else i(null,t)},a.postMessage(n,r),a}),nD=Uint8Array,rD=Uint16Array,iD=Int32Array,aD=new nD([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),oD=new nD([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),sD=new nD([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),cD=function(e,t){for(var n=new rD(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new iD(n[30]),r=1;r<30;++r)for(var a=n[r];a<n[r+1];++a)i[a]=a-n[r]<<5|r;return{b:n,r:i}},lD=cD(aD,2),uD=lD.b,dD=lD.r;uD[28]=258,dD[258]=28;for(var fD=cD(oD,0),pD=fD.b,mD=fD.r,hD=new rD(32768),gD=0;gD<32768;++gD){var _D=(gD&43690)>>1|(gD&21845)<<1;_D=(_D&52428)>>2|(_D&13107)<<2,_D=(_D&61680)>>4|(_D&3855)<<4,hD[gD]=((_D&65280)>>8|(_D&255)<<8)>>1}for(var vD=(function(e,t,n){for(var r=e.length,i=0,a=new rD(t);i<r;++i)e[i]&&++a[e[i]-1];var o=new rD(t);for(i=1;i<t;++i)o[i]=o[i-1]+a[i-1]<<1;var s;if(n){s=new rD(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var l=i<<4|e[i],u=t-e[i],d=o[e[i]-1]++<<u,f=d|(1<<u)-1;d<=f;++d)s[hD[d]>>c]=l}else for(s=new rD(r),i=0;i<r;++i)e[i]&&(s[i]=hD[o[e[i]-1]++]>>15-e[i]);return s}),yD=new nD(288),gD=0;gD<144;++gD)yD[gD]=8;for(var gD=144;gD<256;++gD)yD[gD]=9;for(var gD=256;gD<280;++gD)yD[gD]=7;for(var gD=280;gD<288;++gD)yD[gD]=8;for(var bD=new nD(32),gD=0;gD<32;++gD)bD[gD]=5;
vendor: 7,998 bytes, line 114
114var xD=vD(yD,9,0),SD=vD(yD,9,1),CD=vD(bD,5,0),wD=vD(bD,5,1),TD=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},ED=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},DD=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},OD=function(e){return(e+7)/8|0},kD=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new nD(e.subarray(t,n))},AD=[`unexpected EOF`,`invalid block type`,`invalid length/literal`,`invalid distance`,`stream finished`,`no stream handler`,,`no callback`,`invalid UTF-8 data`,`extra field too long`,`date not in range 1980-2099`,`filename too long`,`stream finishing`,`invalid zip data`],jD=function(e,t,n){var r=Error(t||AD[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,jD),!n)throw r;return r},MD=function(e,t,n,r){var i=e.length,a=r?r.length:0;if(!i||t.f&&!t.l)return n||new nD(0);var o=!n,s=o||t.i!=2,c=t.i;o&&(n=new nD(i*3));var l=function(e){var t=n.length;if(e>t){var r=new nD(Math.max(t*2,e));r.set(n),n=r}},u=t.f||0,d=t.p||0,f=t.b||0,p=t.l,m=t.d,h=t.m,g=t.n,_=i*8;do{if(!p){u=ED(e,d,1);var v=ED(e,d+1,3);if(d+=3,!v){var y=OD(d)+4,b=e[y-4]|e[y-3]<<8,x=y+b;if(x>i){c&&jD(0);break}s&&l(f+b),n.set(e.subarray(y,x),f),t.b=f+=b,t.p=d=x*8,t.f=u;continue}if(v==1)p=SD,m=wD,h=9,g=5;else if(v==2){var S=ED(e,d,31)+257,C=ED(e,d+10,15)+4,w=S+ED(e,d+5,31)+1;d+=14;for(var T=new nD(w),E=new nD(19),D=0;D<C;++D)E[sD[D]]=ED(e,d+D*3,7);d+=C*3;for(var O=TD(E),k=(1<<O)-1,A=vD(E,O,1),D=0;D<w;){var j=A[ED(e,d,k)];d+=j&15;var y=j>>4;if(y<16)T[D++]=y;else{var M=0,N=0;for(y==16?(N=3+ED(e,d,3),d+=2,M=T[D-1]):y==17?(N=3+ED(e,d,7),d+=3):y==18&&(N=11+ED(e,d,127),d+=7);N--;)T[D++]=M}}var P=T.subarray(0,S),F=T.subarray(S);h=TD(P),g=TD(F),p=vD(P,h,1),m=vD(F,g,1)}else jD(1);if(d>_){c&&jD(0);break}}s&&l(f+131072);for(var I=(1<<h)-1,L=(1<<g)-1,ee=d;;ee=d){var M=p[DD(e,d)&I],te=M>>4;if(d+=M&15,d>_){c&&jD(0);break}if(M||jD(2),te<256)n[f++]=te;else if(te==256){ee=d,p=null;break}else{var ne=te-254;if(te>264){var D=te-257,re=aD[D];ne=ED(e,d,(1<<re)-1)+uD[D],d+=re}var R=m[DD(e,d)&L],ie=R>>4;R||jD(3),d+=R&15;var F=pD[ie];if(ie>3){var re=oD[ie];F+=DD(e,d)&(1<<re)-1,d+=re}if(d>_){c&&jD(0);break}s&&l(f+131072);var ae=f+ne;if(f<F){var oe=a-F,z=Math.min(F,ae);for(oe+f<0&&jD(3);f<z;++f)n[f]=r[oe+f]}for(;f<ae;++f)n[f]=n[f-F]}}t.l=p,t.p=ee,t.b=f,t.f=u,p&&(u=1,t.m=h,t.d=m,t.n=g)}while(!u);return f!=n.length&&o?kD(n,0,f):n.subarray(0,f)},ND=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8},PD=function(e,t,n){n<<=t&7;var r=t/8|0;e[r]|=n,e[r+1]|=n>>8,e[r+2]|=n>>16},FD=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,a=n.slice();if(!i)return{t:HD,l:0};if(i==1){var o=new nD(n[0].s+1);return o[n[0].s]=1,{t:o,l:1}}n.sort(function(e,t){return e.f-t.f}),n.push({s:-1,f:25001});var s=n[0],c=n[1],l=0,u=1,d=2;for(n[0]={s:-1,f:s.f+c.f,l:s,r:c};u!=i-1;)s=n[n[l].f<n[d].f?l++:d++],c=n[l!=u&&n[l].f<n[d].f?l++:d++],n[u++]={s:-1,f:s.f+c.f,l:s,r:c};for(var f=a[0].s,r=1;r<i;++r)a[r].s>f&&(f=a[r].s);var p=new rD(f+1),m=ID(n[u-1],p,0);if(m>t){var r=0,h=0,g=m-t,_=1<<g;for(a.sort(function(e,t){return p[t.s]-p[e.s]||e.f-t.f});r<i;++r){var v=a[r].s;if(p[v]>t)h+=_-(1<<m-p[v]),p[v]=t;else break}for(h>>=g;h>0;){var y=a[r].s;p[y]<t?h-=1<<t-p[y]++-1:++r}for(;r>=0&&h;--r){var b=a[r].s;p[b]==t&&(--p[b],++h)}m=t}return{t:new nD(p),l:m}},ID=function(e,t,n){return e.s==-1?Math.max(ID(e.l,t,n+1),ID(e.r,t,n+1)):t[e.s]=n},LD=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new rD(++t),r=0,i=e[0],a=1,o=function(e){n[r++]=e},s=1;s<=t;++s)if(e[s]==i&&s!=t)++a;else{if(!i&&a>2){for(;a>138;a-=138)o(32754);a>2&&(o(a>10?a-11<<5|28690:a-3<<5|12305),a=0)}else if(a>3){for(o(i),--a;a>6;a-=6)o(8304);a>2&&(o(a-3<<5|8208),a=0)}for(;a--;)o(i);a=1,i=e[s]}return{c:n.subarray(0,r),n:t}},RD=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},zD=function(e,t,n){var r=n.length,i=OD(t+2);e[i]=r&255,e[i+1]=r>>8,e[i+2]=e[i]^255,e[i+3]=e[i+1]^255;for(var a=0;a<r;++a)e[i+a+4]=n[a];return(i+4+r)*8},BD=function(e,t,n,r,i,a,o,s,c,l,u){ND(t,u++,n),++i[256];for(var d=FD(i,15),f=d.t,p=d.l,m=FD(a,15),h=m.t,g=m.l,_=LD(f),v=_.c,y=_.n,b=LD(h),x=b.c,S=b.n,C=new rD(19),w=0;w<v.length;++w)++C[v[w]&31];for(var w=0;w<x.length;++w)++C[x[w]&31];for(var T=FD(C,7),E=T.t,D=T.l,O=19;O>4&&!E[sD[O-1]];--O);var k=l+5<<3,A=RD(i,yD)+RD(a,bD)+o,j=RD(i,f)+RD(a,h)+o+14+3*O+RD(C,E)+2*C[16]+3*C[17]+7*C[18];if(c>=0&&k<=A&&k<=j)return zD(t,u,e.subarray(c,c+l));var M,N,P,F;if(ND(t,u,1+(j<A)),u+=2,j<A){M=vD(f,p,0),N=f,P=vD(h,g,0),F=h;var I=vD(E,D,0);ND(t,u,y-257),ND(t,u+5,S-1),ND(t,u+10,O-4),u+=14;for(var w=0;w<O;++w)ND(t,u+3*w,E[sD[w]]);u+=3*O;for(var L=[v,x],ee=0;ee<2;++ee)for(var te=L[ee],w=0;w<te.length;++w){var ne=te[w]&31;ND(t,u,I[ne]),u+=E[ne],ne>15&&(ND(t,u,te[w]>>5&127),u+=te[w]>>12)}}else M=xD,N=yD,P=CD,F=bD;for(var w=0;w<s;++w){var re=r[w];if(re>255){var ne=re>>18&31;PD(t,u,M[ne+257]),u+=N[ne+257],ne>7&&(ND(t,u,re>>23&31),u+=aD[ne]);var R=re&31;PD(t,u,P[R]),u+=F[R],R>3&&(PD(t,u,re>>5&8191),u+=oD[R])}else PD(t,u,M[re]),u+=N[re]}return PD(t,u,M[256]),u+N[256]},VD=new iD([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),HD=new nD(0),UD=function(e,t,n,r,i,a){var o=a.z||e.length,s=new nD(r+o+5*(1+Math.ceil(o/7e3))+i),c=s.subarray(r,s.length-i),l=a.l,u=(a.r||0)&7;if(t){u&&(c[0]=a.r>>3);for(var d=VD[t-1],f=d>>13,p=d&8191,m=(1<<n)-1,h=a.p||new rD(32768),g=a.h||new rD(m+1),_=Math.ceil(n/3),v=2*_,y=function(t){return(e[t]^e[t+1]<<_^e[t+2]<<v)&m},b=new iD(25e3),x=new rD(288),S=new rD(32),C=0,w=0,T=a.i||0,E=0,D=a.w||0,O=0;T+2<o;++T){var k=y(T),A=T&32767,j=g[k];if(h[A]=j,g[k]=A,D<=T){var M=o-T;if((C>7e3||E>24576)&&(M>423||!l)){u=BD(e,c,0,b,x,S,w,E,O,T-O,u),E=C=w=0,O=T;for(var N=0;N<286;++N)x[N]=0;for(var N=0;N<30;++N)S[N]=0}var P=2,F=0,I=p,L=A-j&32767;if(M>2&&k==y(T-L))for(var ee=Math.min(f,M)-1,te=Math.min(32767,T),ne=Math.min(258,M);L<=te&&--I&&A!=j;){if(e[T+P]==e[T+P-L]){for(var re=0;re<ne&&e[T+re]==e[T+re-L];++re);if(re>P){if(P=re,F=L,re>ee)break;for(var R=Math.min(L,re-2),ie=0,N=0;N<R;++N){var ae=T-L+N&32767,oe=ae-h[ae]&32767;oe>ie&&(ie=oe,j=ae)}}}A=j,j=h[A],L+=A-j&32767}if(F){b[E++]=268435456|dD[P]<<18|mD[F];var z=dD[P]&31,se=mD[F]&31;w+=aD[z]+oD[se],++x[257+z],++S[se],D=T+P,++C}else b[E++]=e[T],++x[e[T]]}}for(T=Math.max(T,D);T<o;++T)b[E++]=e[T],++x[e[T]];u=BD(e,c,l,b,x,S,w,E,O,T-O,u),l||(a.r=u&7|c[u/8|0]<<3,u-=7,a.h=g,a.p=h,a.i=T,a.w=D)}else{for(var T=a.w||0;T<o+l;T+=65535){var ce=T+65535;ce>=o&&(c[u/8|0]=l,ce=o),u=zD(c,u+1,e.subarray(T,ce))}a.i=o}return kD(s,0,r+OD(u)+i)},WD=(function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(n&1&&-306674912)^n>>>1;e[t]=n}return e})(),GD=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=WD[n&255^t[r]]^n>>>8;e=n},d:function(){return~e}}},KD=function(e,t,n,r,i){if(!i&&(i={l:1},t.dictionary)){var a=t.dictionary.subarray(-32768),o=new nD(a.length+e.length);o.set(a),o.set(e,a.length),e=o,i.w=a.length}return UD(e,t.level==null?6:t.level,t.mem==null?i.l?Math.ceil(Math.max(8,Math.min(13,Math.log(e.length)))*1.5):20:12+t.mem,n,r,i)},qD=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},JD=function(e,t,n){for(var r=e(),i=e.toString(),a=i.slice(i.indexOf(`[`)+1,i.lastIndexOf(`]`)).replace(/\s+/g,``).split(`,`),o=0;o<r.length;++o){var s=r[o],c=a[o];if(typeof s==`function`){t+=`;`+c+`=`;var l=s.toString();if(s.prototype){if(l.indexOf(`[native code]`)!=-1){var u=l.indexOf(` `,8)+1;t+=l.slice(u,l.indexOf(`(`,u))}else for(var d in t+=l,s.prototype)t+=`;`+c+`.prototype.`+d+`=`+s.prototype[d].toString()}else t+=l}else n[c]=s}return t},YD=[],XD=function(e){var t=[];for(var n in e)e[n].buffer&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t},ZD=function(e,t,n,r){if(!YD[n]){for(var i=``,a={},o=e.length-1,s=0;s<o;++s)i=JD(e[s],i,a);YD[n]={c:JD(e[o],i,a),e:a}}var c=qD({},YD[n].e);return tD(YD[n].c+`;onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage=`+t.toString()+`}`,n,c,XD(c),r)}
114,QD=function(){return[nD,rD,iD,aD,oD,sD,uD,pD,SD,wD,hD,AD,vD,TD,ED,DD,OD,kD,jD,MD,uO,eO,tO]},$D=function(){return[nD,rD,iD,aD,oD,sD,dD,mD,xD,yD,CD,bD,hD,VD,HD,vD,ND,PD,FD,ID,LD,RD,zD,BD,OD,kD,UD,KD,cO,eO]},eO=function(e){return postMessage(e,[e.buffer])},tO=function(e){return e&&{out:e.size&&new nD(e.size),dictionary:e.dictionary}},nO=function(e,t,n,r,i,a){var o=ZD(n,r,i,function(e,t){o.terminate(),a(e,t)});return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},rO=function(e,t){return e[t]|e[t+1]<<8},iO=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},aO=function(e,t){return iO(e,t)+iO(e,t+4)*4294967296},oO=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8};function sO(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&jD(7),nO(e,t,[$D],function(e){return eO(cO(e.data[0],e.data[1]))},0,n)}function cO(e,t){return KD(e,t||{},0,0)}function lO(e,t,n){return n||(n=t,t={}),typeof n!=`function`&&jD(7),nO(e,t,[QD],function(e){return eO(uO(e.data[0],tO(e.data[1])))},1,n)}function uO(e,t){return MD(e,{i:2},t&&t.out,t&&t.dictionary)}var dO=function(e,t,n,r){for(var i in e){var a=e[i],o=t+i,s=r;Array.isArray(a)&&(s=qD(r,a[1]),a=a[0]),ArrayBuffer.isView(a)?n[o]=[a,s]:(n[o+=`/`]=[new nD(0),s],dO(a,o,n,r))}},fO=typeof TextEncoder<`u`&&new TextEncoder,pO=typeof TextDecoder<`u`&&new TextDecoder;try{pO.decode(HD,{stream:!0})}catch{}var mO=function(e){for(var t=``,n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:kD(e,n-1)};i?i==3?(r=((r&15)<<18|(e[n++]&63)<<12|(e[n++]&63)<<6|e[n++]&63)-65536,t+=String.fromCharCode(55296|r>>10,56320|r&1023)):i&1?t+=String.fromCharCode((r&31)<<6|e[n++]&63):t+=String.fromCharCode((r&15)<<12|(e[n++]&63)<<6|e[n++]&63):t+=String.fromCharCode(r)}};function hO(e,t){if(t){for(var n=new nD(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(fO)return fO.encode(e);for(var i=e.length,a=new nD(e.length+(e.length>>1)),o=0,s=function(e){a[o++]=e},r=0;r<i;++r){if(o+5>a.length){var c=new nD(o+8+(i-r<<1));c.set(a),a=c}var l=e.charCodeAt(r);l<128||t?s(l):l<2048?(s(192|l>>6),s(128|l&63)):l>55295&&l<57344?(l=65536+(l&1047552)|e.charCodeAt(++r)&1023,s(240|l>>18),s(128|l>>12&63),s(128|l>>6&63),s(128|l&63)):(s(224|l>>12),s(128|l>>6&63),s(128|l&63))}return kD(a,0,o)}function gO(e,t){if(t){for(var n=``,r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(pO)return pO.decode(e);var i=mO(e),a=i.s,n=i.r;return n.length&&jD(8),a}var _O=function(e,t){return t+30+rO(e,t+26)+rO(e,t+28)},vO=function(e,t,n){var r=rO(e,t+28),i=rO(e,t+30),a=gO(e.subarray(t+46,t+46+r),!(rO(e,t+8)&2048)),o=t+46+r,s=yO(e,o,i,n,iO(e,t+20),iO(e,t+24),iO(e,t+42)),c=s[0],l=s[1],u=s[2];return[rO(e,t+10),c,l,a,o+i+rO(e,t+32),u]},yO=function(e,t,n,r,i,a,o){var s=i==4294967295,c=a==4294967295,l=o==4294967295,u=t+n,d=s+c+l;if(r&&d){for(;t+4<u;t+=4+rO(e,t+2))if(rO(e,t)==1)return[s?aO(e,t+4+8*c):i,c?aO(e,t+4):a,l?aO(e,t+4+8*(c+s)):o,1];r<2&&jD(13)}return[i,a,o,0]},bO=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;r>65535&&jD(9),t+=r+4}return t},xO=function(e,t,n,r,i,a,o,s){var c=r.length,l=n.extra,u=s&&s.length,d=bO(l);oO(e,t,o==null?67324752:33639248),t+=4,o!=null&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(a<0&&8),e[t++]=i&&8,e[t++]=n.compression&255,e[t++]=n.
114compression>>8;var f=new Date(n.mtime==null?Date.now():n.mtime),p=f.getFullYear()-1980;if((p<0||p>119)&&jD(10),oO(e,t,p<<25|f.getMonth()+1<<21|f.getDate()<<16|f.getHours()<<11|f.getMinutes()<<5|f.getSeconds()>>1),t+=4,a!=-1&&(oO(e,t,n.crc),oO(e,t+4,a<0?-a-2:a),oO(e,t+8,n.size)),oO(e,t+12,c),oO(e,t+14,d),t+=16,o!=null&&(oO(e,t,u),oO(e,t+6,n.attrs),oO(e,t+10,o),t+=14),e.set(r,t),t+=c,d)for(var m in l){var h=l[m],g=h.length;oO(e,t,+m),oO(e,t+2,g),e.set(h,t+4),t+=4+g}return u&&(e.set(s,t),t+=u),t},SO=function(e,t,n,r,i){oO(e,t,101010256),oO(e,t+8,n),oO(e,t+10,n),oO(e,t+12,r),oO(e,t+16,i)};function CO(e,t,n){n||(n=t,t={}),typeof n!=`function`&&jD(7);var r={};dO(e,``,r,t);var i=Object.keys(r),a=i.length,o=0,s=0,c=a,l=Array(a),u=[],d=function(){for(var e=0;e<u.length;++e)u[e]()},f=function(e,t){wO(function(){n(e,t)})};wO(function(){f=n});var p=function(){var e=new nD(s+22),t=o,n=s-o;s=0;for(var r=0;r<c;++r){var i=l[r];try{var a=i.c.length;xO(e,s,i,i.f,i.u,a);var u=30+i.f.length+bO(i.extra),d=s+u;e.set(i.c,d),xO(e,o,i,i.f,i.u,a,s,i.m),o+=16+u+(i.m?i.m.length:0),s=d+a}catch(e){return f(e,null)}}SO(e,o,l.length,n,t),f(null,e)};a||p();for(var m=function(e){var t=i[e],n=r[t],c=n[0],m=n[1],h=GD(),g=c.length;h.p(c);var _=hO(t),v=_.length,y=m.comment,b=y&&hO(y),x=b&&b.length,S=bO(m.extra),C=m.level==0?0:8,w=function(n,r){if(n)d(),f(n,null);else{var i=r.length;l[e]=qD(m,{size:g,crc:h.d(),c:r,f:_,m:b,u:v!=t.length||b&&y.length!=x,compression:C}),o+=30+v+S+i,s+=76+2*(v+S)+(x||0)+i,--a||p()}};if(v>65535&&w(jD(11,0,1),null),!C)w(null,c);else if(g<16e4)try{w(null,cO(c,m))}catch(e){w(e,null)}else u.push(sO(c,m,w))},h=0;h<c;++h)m(h);return d}var wO=typeof queueMicrotask==`function`?queueMicrotask:typeof setTimeout==`function`?setTimeout:function(e){e()};function TO(e,t,n){n||(n=t,t={}),typeof n!=`function`&&jD(7);var r=[],i=function(){for(var e=0;e<r.length;++e)r[e]()},a={},o=function(e,t){wO(function(){n(e,t)})};wO(function(){o=n});for(var s=e.length-22;iO(e,s)!=101010256;--s)if(!s||e.length-s>65558)return o(jD(13,0,1),null),i;var c=rO(e,s+8);if(c){var l=c,u=iO(e,s+16),d=iO(e,s-20)==117853008;if(d){var f=iO(e,s-12);d=iO(e,f)==101075792,d&&(l=c=iO(e,f+32),u=iO(e,f+48))}for(var p=t&&t.filter,m=function(t){var n=vO(e,u,d),s=n[0],l=n[1],f=n[2],m=n[3],h=n[4],g=n[5],_=_O(e,g);u=h;var v=function(e,t){e?(i(),o(e,null)):(t&&(a[m]=t),--c||o(null,a))};if(!p||p({name:m,size:l,originalSize:f,compression:s})){if(!s)v(null,kD(e,_,_+l));else if(s==8){var y=e.subarray(_,_+l);if(f<524288||l>.8*f)try{v(null,uO(y,{out:new nD(f)}))}catch(e){v(e,null)}else r.push(lO(y,{size:f},v))}else v(jD(14,`unknown compression type `+s,1),null)}else v(null,null)},h=0;h<l;++h)m(h)}else o(null,{});return i}var EO=H().uuid(),DO=rt(()=>_t([H(),We(),be(),Le(),Yt(DO),kn(DO)])),OO=lt({format:je(`storyverse-content-manager`),version:je(`3.0`),exportedAt:H().datetime(),defaultLocale:H().min(1),exportedLocales:Yt(H().min(1))}),kO={richtext:`formatted-text`,"rich-text":`formatted-text`,markdown:`formatted-text`,html:`formatted-text`,boolean:`toggle`};function AO(e){return kO[e.toLowerCase()]??e}var jO=lt({id:EO,name:H(),propertyName:H().min(1),type:H().transform(AO),required:be(),options:kn(Fe()),order:We(),helpText:H().nullable().optional()}),MO=lt({id:EO,collectionId:EO,name:H(),slug:H().min(1),properties:kn(Fe()),status:Xe([`draft`,`published`,`archived`])}),NO=lt({id:EO,name:H().min(1),slug:H().min(1),description:H().nullable().optional(),fields:Yt(jO),entries:Yt(MO)}),PO=lt({id:EO,entryId:EO,collectionSlug:H().min(1).optional(),entrySlug:H().min(1).optional(),propertyName:H().min(1),language:H().min(1),value:DO,isActive:be()}),FO=lt({id:EO,language:H().min(1),value:H(),description:H().nullable().optional(),isActive:be()}),IO=lt({key:H().min(1),translations:Yt(FO)}),LO=lt({id:EO,name:H().min(1),slug:H().min(1),description:H().nullable().optional(),labels:Yt(IO)});function RO(e,t,n,r){let i=new Set;for(let a of e)i.has(a)&&t.addIssue({code:ht.custom,message:`Duplicate ${r}: ${a}`,path:n}),i.add(a)}var zO=lt({metadata:OO,content:lt({collections:Yt(NO),entryTranslations:Yt(PO)}),labels:lt({collections:Yt(LO)}
114)}).superRefine((e,t)=>{e.metadata.exportedLocales.includes(e.metadata.defaultLocale)||t.addIssue({code:ht.custom,message:`exportedLocales must include the default locale`,path:[`metadata`,`exportedLocales`]}),RO(e.content.collections.map(e=>e.slug),t,[`content`,`collections`],`content collection slug`),RO(e.labels.collections.map(e=>e.slug),t,[`labels`,`collections`],`label collection slug`);let n=new Set,r=new Map;for(let[i,a]of e.content.collections.entries()){RO(a.fields.map(e=>e.propertyName),t,[`content`,`collections`,i,`fields`],`field property name`),RO(a.entries.map(e=>e.slug),t,[`content`,`collections`,i,`entries`],`entry slug`);for(let[e,o]of a.entries.entries())n.has(o.id)&&t.addIssue({code:ht.custom,message:`Duplicate entry id: ${o.id}`,path:[`content`,`collections`,i,`entries`,e,`id`]}),n.add(o.id),r.set(o.id,new Set(a.fields.map(e=>e.propertyName))),o.collectionId!==a.id&&t.addIssue({code:ht.custom,message:`Entry collectionId does not match its parent collection`,path:[`content`,`collections`,i,`entries`,e,`collectionId`]})}RO(e.content.entryTranslations.map(e=>`${e.entryId}:${e.propertyName}:${e.language}`),t,[`content`,`entryTranslations`],`entry translation`);for(let[i,a]of e.content.entryTranslations.entries())n.has(a.entryId)?r.get(a.entryId)?.has(a.propertyName)||t.addIssue({code:ht.custom,message:`Unknown translated field: ${a.propertyName}`,path:[`content`,`entryTranslations`,i,`propertyName`]}):a.entrySlug||t.addIssue({code:ht.custom,message:`Unknown entryId: ${a.entryId}`,path:[`content`,`entryTranslations`,i,`entryId`]});for(let[n,r]of e.labels.collections.entries()){RO(r.labels.map(e=>e.key),t,[`labels`,`collections`,n,`labels`],`label key`);for(let[e,i]of r.labels.entries())RO(i.translations.map(e=>e.language),t,[`labels`,`collections`,n,`labels`,e,`translations`],`label language`)}}),BO=`by-collection`,VO=`storyverse-content-manager.json`,HO=`index.json`;function UO(e,t){return e.localeCompare(t)}var WO=lt({metadata:OO,kind:je(`index`),files:Yt(lt({path:H().min(1),kind:H().min(1),count:We()}))}),GO=lt({metadata:OO,kind:je(`content-collection`),collection:NO}),KO=lt({metadata:OO,kind:je(`label-collection`),collection:LO.omit({labels:!0}).extend({labels:Yt(lt({key:H().min(1),value:H()}))})}),qO=lt({metadata:OO,kind:je(`content-translations`),collectionSlug:H().min(1),language:H().min(1),entryTranslations:Yt(PO.omit({collectionSlug:!0}))}),JO=lt({metadata:OO,kind:je(`label-translations`),collectionSlug:H().min(1),collectionId:H().uuid(),language:H().min(1),labelTranslations:Yt(FO.extend({key:H().min(1)}))}),YO=Je(`kind`,[WO,GO,KO,qO,JO]);function XO(e){let{metadata:t}=e,n=[],r=new Map,i=new Map;for(let a of e.content.collections){for(let e of a.entries)r.set(e.id,a.slug),i.set(e.id,e.slug);n.push({path:`content/${a.slug}.json`,kind:`content-collection`,count:a.entries.length,value:{metadata:t,kind:`content-collection`,collection:a}})}let a=new Map;for(let t of e.content.entryTranslations){let e=r.get(t.entryId);if(!e)continue;let n=`${t.language}/${e}`,o=a.get(n)??{language:t.language,collectionSlug:e,entryTranslations:[]},{collectionSlug:s,...c}=t;o.entryTranslations.push({...c,entrySlug:t.entrySlug??i.get(c.entryId)}),a.set(n,o)}for(let e of a.values())n.push({path:`translations/content/${e.language}/${e.language}-${e.collectionSlug}.json`,kind:`content-translations`,count:e.entryTranslations.length,value:{metadata:t,kind:`content-translations`,collectionSlug:e.collectionSlug,language:e.language,entryTranslations:e.entryTranslations}});for(let r of e.labels.collections){n.push({path:`labels/${r.slug}.json`,kind:`label-collection`,count:r.labels.length,value:{metadata:t,kind:`label-collection`,collection:{id:r.id,name:r.name,slug:r.slug,description:r.description??null,labels:r.labels.map(e=>({key:e.key,value:e.translations.find(e=>e.language===t.defaultLocale)?.value??``}))}}});let e=new Map;for(let t of r.labels)for(let n of t.translations){let r=e.get(n.language)??[];r.push({...n,key:t.key}),e.set(n.language,r)}for(let[i,a]of e)n.push({path:`translations/labels/${i}/${i}-${r.slug}.json`,kind:`label-translations`,count:a.length,value:{metadata:t,kind:`label-translations`,collectionSlug:r.slug,collectionId:r.id,language:i,labelTranslations:a}})}return n.sort((e,t)=>
114UO(e.path,t.path)),n.unshift({path:HO,kind:`index`,count:n.length,value:{metadata:t,kind:`index`,files:n.map(({path:e,kind:t,count:n})=>({path:e,kind:t,count:n}))}}),n}function ZO(e,t,n){let r=[];for(let i of e){if(i.value.kind!==`content-translations`)continue;let{collectionSlug:e,entryTranslations:a}=i.value;if(!t.has(e)&&a.some(e=>!e.entrySlug))throw Error(n(i,e));for(let t of a)r.push({...t,collectionSlug:e})}return r}function QO(e){let t=e.find(e=>e.value.kind!==`index`)?.value.metadata;if(!t)throw Error(`Select at least one exported collection or translation file`);let n=e.filter(e=>e.value.kind===`content-collection`).map(e=>e.value.collection).sort((e,t)=>UO(e.slug,t.slug)),r=ZO(e,new Set(n.map(e=>e.slug)),(e,t)=>`${e.path} holds translations for "${t}" that do not name their entry, because they predate entry slugs in the export. Select content/${t}.json as well, so the entries they belong to can be matched — or export again.`),i=new Map,a=new Map;for(let t of e){if(t.value.kind!==`label-translations`)continue;let e=i.get(t.value.collectionSlug)??[];e.push(...t.value.labelTranslations),i.set(t.value.collectionSlug,e),a.set(t.value.collectionSlug,t.value.collectionId)}let o=e.filter(e=>e.value.kind===`label-collection`).map(e=>e.value.collection),s=new Set(o.map(e=>e.slug)),c=o.map(e=>{let n=new Map;for(let{key:t,...r}of i.get(e.slug)??[])n.set(t,[...n.get(t)??[],r]);return{id:e.id,name:e.name,slug:e.slug,description:e.description??null,labels:[...e.labels].sort((e,t)=>UO(e.key,t.key)).map(r=>{let i=n.get(r.key);return{key:r.key,translations:i?.sort((e,t)=>UO(e.language,t.language))??[{id:e.id,language:t.defaultLocale,value:r.value,description:null,isActive:!0}]}})}});for(let[e,t]of i){if(s.has(e))continue;let n=new Map;for(let{key:e,...r}of t)n.set(e,[...n.get(e)??[],r]);c.push({id:a.get(e),name:e,slug:e,description:null,labels:[...n.entries()].sort(([e],[t])=>UO(e,t)).map(([e,t])=>({key:e,translations:t.sort((e,t)=>UO(e.language,t.language))}))})}return zO.parse({metadata:t,content:{collections:n,entryTranslations:r.sort((e,t)=>UO(e.entryId,t.entryId)||UO(e.propertyName,t.propertyName)||UO(e.language,t.language))},labels:{collections:c.sort((e,t)=>UO(e.slug,t.slug))}})}function $O(e,t){let n=YO.safeParse(t);if(n.success)return n.data;let r=n.error.issues[0],i=r?`${r.path.join(`.`)||`file`}: ${r.message}`:`does not match any known split file shape`;throw Error(`${e}: ${i}`)}function ek(e,t){let n=e.files.map(e=>e.path).filter(e=>!t.has(e));if(!n.length)return;let r=n.slice(0,3).join(`, `);throw Error(`Archive is missing ${n.length} file(s) listed in ${HO}: ${r}${n.length>3?`, …`:``}`)}function tk(e){let t=e.find(e=>e.value.kind===`index`);if(!t)throw Error(`Archive has no ${HO}, so there is no way to tell it is complete`);ek(t.value,new Set(e.map(e=>e.path)));let n=e.filter(e=>e.value.kind===`content-collection`).map(e=>e.value.collection).sort((e,t)=>UO(e.slug,t.slug)),r=ZO(e,new Set(n.map(e=>e.slug)),(e,t)=>`${e.path}: no content/${t}.json in the archive`);r.sort((e,t)=>UO(e.entryId,t.entryId)||UO(e.propertyName,t.propertyName)||UO(e.language,t.language));let i=new Map,a=e.filter(e=>e.value.kind===`label-collection`),o=new Set(a.map(e=>e.value.collection.slug));for(let t of e){if(t.value.kind!==`label-translations`)continue;if(!o.has(t.value.collectionSlug))throw Error(`${t.path}: no labels/${t.value.collectionSlug}.json in the archive`);let e=i.get(t.value.collectionSlug)??[];e.push(...t.value.labelTranslations),i.set(t.value.collectionSlug,e)}
114let s=a.map(e=>{let{collection:t}=e.value,n=new Map;for(let e of i.get(t.slug)??[]){let{key:t,...r}=e,i=n.get(t)??[];i.push(r),n.set(t,i)}let r=new Set(t.labels.map(e=>e.key));for(let e of n.keys())if(!r.has(e))throw Error(`labels/${t.slug}.json does not list key "${e}" that its translations reference`);return{id:t.id,name:t.name,slug:t.slug,description:t.description??null,labels:[...t.labels].sort((e,t)=>UO(e.key,t.key)).map(e=>({key:e.key,translations:(n.get(e.key)??[]).sort((e,t)=>UO(e.language,t.language))}))}}).sort((e,t)=>UO(e.slug,t.slug));return zO.parse({metadata:t.value.metadata,content:{collections:n,entryTranslations:r},labels:{collections:s}})}var nk=`storyverse-content-manager.zip`;function rk(e){return hO(`${JSON.stringify(e,null,2)}\n`)}async function ik(e){let t={[VO]:rk(e)};for(let n of XO(e))t[`${BO}/${n.path}`]=rk(n.value);return new Promise((e,n)=>{CO(t,{level:6},(t,r)=>t?n(t):e(r))})}function ak(e){return new Promise((t,n)=>{TO(e,(e,r)=>e?n(e):t(r))})}function ok(e){return e.endsWith(`/`)||e.startsWith(`__MACOSX/`)||e.split(`/`).some(e=>e.startsWith(`._`))||e.split(`/`).includes(`.DS_Store`)}function sk(e){let t=e.filter(e=>e===`index.json`||e.endsWith(`/index.json`)).sort((e,t)=>e.length-t.length||e.localeCompare(t))[0];return t===void 0?null:t.slice(0,-HO.length)}async function ck(e){let t=await ak(e),n=Object.keys(t).filter(e=>!ok(e)),r=sk(n);if(r===null){let e=n.find(e=>e.endsWith(VO));if(!e)throw Error(`Archive contains neither a ${BO}/${HO} nor a ${VO}`);return uk(gO(t[e]))}let i=[];for(let e of n){if(!e.startsWith(r)||!e.endsWith(`.json`))continue;let n=e.slice(r.length);i.push({path:n,value:$O(n,lk(n,t[e]))})}return tk(i)}function lk(e,t){if(!t)throw Error(`${e}: unreadable archive entry`);try{return JSON.parse(gO(t))}catch{throw Error(`${e}: not valid JSON`)}}function uk(e){let t;try{t=JSON.parse(e)}catch{throw Error(`The file is not valid JSON`)}let n=zO.safeParse(t);if(n.success)return n.data;let r=n.error.issues[0];throw Error(r?`${r.path.join(`.`)||`file`}: ${r.message}`:`The file does not match the unified v3 format`)}var dk=[80,75,3,4];function fk(e){return dk.every((t,n)=>e[n]===t)}function pk(e){if(Array.isArray(e))return`this is an older Content export (a bare list of collections). Export again from the Content tab to get the current format.`;let t=e?.metadata?.version;return typeof t==`string`&&t.startsWith(`2.`)?`this is an older localization export (v${t}). Export again from the Localization tab to get the current format.`:null}async function mk(e){if(e.length===0)throw Error(`Select a file to import`);let t=await Promise.all(e.map(async e=>({name:e.name,bytes:new Uint8Array(await e.arrayBuffer())}))),n=t.find(e=>fk(e.bytes));if(n)return ck(n.bytes);let r=t.map(e=>({name:e.name,text:new TextDecoder().decode(e.bytes)}));for(let e of r)try{return uk(e.text)}catch{}return QO(r.map(e=>{let t;try{t=JSON.parse(e.text)}catch{throw Error(`${e.name}
114: not valid JSON`)}let n=pk(t);if(n)throw Error(`${e.name}: ${n}`);return{path:e.name,value:$O(e.name,t)}}))}function hk(e,t){return JSON.stringify(e)===JSON.stringify(t)}function gk({file:e,existing:t,organizationId:n,newId:r,now:i}){let a={collectionsToCreate:[],collectionsToUpdate:[],entriesToCreate:[],entriesToUpdate:[],entryTranslationsToCreate:[],entryTranslationsToUpdate:[],labelCollectionsToCreate:[],labelCollectionsToUpdate:[],labelTranslationsToCreate:[],labelTranslationsToUpdate:[],unchanged:0},o=new Map(t.collections.map(e=>[e.slug,e])),s=new Map(t.entries.map(e=>[`${e.collectionId}:${e.slug}`,e])),c=new Map(t.entryTranslations.map(e=>[`${e.entryId}:${e.propertyName}:${e.language}`,e])),l=new Map(t.labelCollections.map(e=>[e.slug,e])),u=new Map(t.labelTranslations.map(e=>[`${e.labelCollectionId}:${e.key}:${e.language}`,e])),d=new Map;function f(e){if(!e.collectionSlug||!e.entrySlug)return;let t=o.get(e.collectionSlug);if(t)return s.get(`${t.id}:${e.entrySlug}`)?.id}for(let t of e.content.collections){let e=o.get(t.slug),c=e?.id??r(),l=i(),u=new Map((e?.fields??[]).map(e=>[e.propertyName,e])),f=new Set(t.fields.map(e=>e.propertyName)),p=[...t.fields.map(e=>{let t=u.get(e.propertyName);return{...e,id:t?.id??r(),createdAt:t?.createdAt??l,updatedAt:l}}),...(e?.fields??[]).filter(e=>!f.has(e.propertyName))];if(e){let r=t.fields.some(e=>{let t=u.get(e.propertyName);return!t||t.name!==e.name||t.type!==e.type||t.required!==e.required||!hk(t.options,e.options)||t.order!==e.order||(t.helpText??null)!==(e.helpText??null)});e.name===t.name&&(e.description??null)===(t.description??null)&&!r?a.unchanged+=1:a.collectionsToUpdate.push({id:e.id,name:t.name,slug:t.slug,description:t.description??null,organizationId:n,fields:p})}else a.collectionsToCreate.push({id:c,name:t.name,slug:t.slug,description:t.description??null,organizationId:n,fields:p,createdAt:l,updatedAt:l});for(let e of t.entries){let t=s.get(`${c}:${e.slug}`),n=t?.id??r();if(d.set(e.id,n),t){let n={...t.properties,...e.properties};t.name===e.name&&t.status===e.status&&hk(t.properties,n)?a.unchanged+=1:a.entriesToUpdate.push({id:t.id,collectionId:c,name:e.name,slug:e.slug,properties:n,status:e.status})}else{let t=i();a.entriesToCreate.push({id:n,collectionId:c,name:e.name,slug:e.slug,properties:e.properties,status:e.status,createdAt:t,updatedAt:t})}}}for(let t of e.content.entryTranslations){let e=d.get(t.entryId)??f(t);if(!e)continue;let n=`${e}:${t.propertyName}:${t.language}`,o=c.get(n);if(o)hk(o.value,t.value)&&o.isActive===t.isActive?a.unchanged+=1:a.entryTranslationsToUpdate.push({id:o.id,value:t.value,isActive:t.isActive});else{let n=i();a.entryTranslationsToCreate.push({id:r(),entryId:e,propertyName:t.propertyName,language:t.language,value:t.value,isActive:t.isActive,createdAt:n,updatedAt:n})}}for(let t of e.labels.collections){let o=l.get(t.slug),s=o?.id??r(),c=i();o?o.name===t.name&&(o.description??null)===(t.description??null)?a.unchanged+=1:a.labelCollectionsToUpdate.push({id:o.id,name:t.name,slug:t.slug,description:t.description??null,organizationId:n}):a.labelCollectionsToCreate.push({id:s,organizationId:n,name:t.name,slug:t.slug,description:t.description??null,createdAt:c,updatedAt:c});for(let n of t.labels)for(let t of n.translations){let o=`${s}:${n.key}:${t.language}`,c=u.get(o);if(c)c.value===t.value&&(c.description??null)===(t.description??null)&&c.isActive===t.isActive?a.unchanged+=1:a.labelTranslationsToUpdate.push({id:c.id,value:t.value,description:t.description??null,isActive:t.isActive});else if(t.language===e.metadata.defaultLocale||t.value.trim()!==``){let e=i();a.labelTranslationsToCreate.push({id:r(),labelCollectionId:s,key:n.key,language:t.language,value:t.value,description:t.description??null,isActive:t.isActive,createdAt:e,updatedAt:e})}}}return a}function _k(e){return e.collectionsToCreate.length+e.collectionsToUpdate.length+e.entriesToCreate.length+e.entriesToUpdate.length+e.entryTranslationsToCreate.length+e.entryTranslationsToUpdate.length+e.labelCollectionsToCreate.length+e.labelCollectionsToUpdate.length+e.labelTranslationsToCreate.length+e.labelTranslationsToUpdate.length}var vk={"collections.create":`Creating collections`,"collections.update":`Updating collections`,"entries.create":`Creating entries`,"entries.update":`Updating entries`,"labelCollections.create":`Creating label collections`,"labelCollections.update":`Updating label collections`,"labelTranslations.create":`Creating label translations`,"labelTranslations.update":`Updating label translations`,"entryTranslations.create":`Creating entry translations`,"entryTranslations.update":`Updating entry translations`};function yk(e){return e instanceof Error?e.message:String(e)}async function bk({plan:e,mutations:t,batchSize:n=200,maxRequestBytes:r=sE,onProgress:i}){let a=[],o=[],s=_k(e),c=0,l=0,u=new Set,d=new Set,f=new Set;async function p(e,t,a,o){for(let[u,d]of cE(t,n,r).entries()){let t=await m(e,u,d,a);for(let e of t)o?.([e]);c+=d.length-t.length,l+=d.length,i?.({step:e,processed:l,total:s})}}async function m(e,t,n,r){try{return await r(n),[]}catch(i){if(n.length===1)return a.push({step:e,batchIndex:t,count:1,message:yk(i)}),n;let o=Math.ceil(n.length/2);return[...await m(e,t,n.slice(0,o),r),...await m(e,t,n.slice(o),r)]}}function h(e,t,n,r,a){let c=t.filter(n);if(c.length){o.push({step:e,count:c.length,reason:r});for(let e of c)a?.(e);l+=c.length,i?.({step:e,processed:l,total:s})}return t.filter(e=>!n(e))}await p(`collections.create`,e.collectionsToCreate,t.createCollections,e=>{for(let t of e)u.add(t.id)}),await p(`collections.update`,e.collectionsToUpdate,t.updateCollections),await p(`entries.create`,h(`entries.create`,e.entriesToCreate,e=>u.has(e.collectionId),`their collection could not be created`,e=>d.add(e.id)),t.createEntries,e=>{for(let t of e)d.add(t.id)}),await p(`entries.update`,e.entriesToUpdate,t.updateEntries),await p(`labelCollections.create`,e.labelCollectionsToCreate,t.createLabelCollections,e=>{for(let t of e)f.add(t.id)}),await p(`labelCollections.update`,e.labelCollectionsToUpdate,t.updateLabelCollections),await p(`labelTranslations.create`,h(`labelTranslations.create`,e.labelTranslationsToCreate,e=>f.has(e.labelCollectionId),`their label collection could not be created`),t.createLabelTranslations),await p(`labelTranslations.update`,e.labelTranslationsToUpdate,t.updateLabelTranslations),await p(`entryTranslations.create`,h(`entryTranslations.create`,e.entryTranslationsToCreate,e=>d.has(e.entryId),`their entry could not be created`),t.createEntryTranslations),await p(`entryTranslations.update`,e.entryTranslationsToUpdate,t.updateEntryTranslations);let g=a.reduce((e,t)=>
114e+t.count,0),_=o.reduce((e,t)=>e+t.count,0);return{written:c,failed:g,skipped:_,total:s,failures:a,skips:o}}function xk(e){let t=[`Storyverse Content Manager import report`,`Generated: ${new Date().toISOString()}`,``,`Planned:  ${e.total}`,`Written:  ${e.written}`,`Failed:   ${e.failed}`,`Skipped:  ${e.skipped}`];if(e.skips.length){t.push(``,`Skipped:`);for(let n of e.skips)t.push(`  ${n.step}: ${n.count} row(s) — ${n.reason}`)}if(e.failures.length){t.push(``,`Failed batches:`);for(let n of e.failures)t.push(`  ${n.step} batch ${n.batchIndex} (${n.count} row(s)): ${n.message}`)}return t.push(``,`Re-running the same archive re-plans against current state, so rows that`,`landed are reported as unchanged and only the gaps above are rewritten.`),t.join(`
115`)}var Sk=[{id:`id`,desc:!1}],Ck=500;async function wk({client:e,queryClient:t,organizationId:n}){let r=(e,n)=>t.fetchQuery({...fE(e,n),staleTime:0}),[i,a,o,s,c]=await Promise.all([r(e.cms.collections.list.queryKey({organizationId:n}),r=>t.fetchQuery(e.cms.collections.list.queryOptions({organizationId:n,sorting:Sk,pagination:r}))),r(e.cms.entries.list.queryKey({organizationId:n}),r=>t.fetchQuery(e.cms.entries.list.queryOptions({organizationId:n,sorting:Sk,pagination:r}))),r(e.localization.entryTranslations.list.queryKey({organizationId:n}),r=>t.fetchQuery(e.localization.entryTranslations.list.queryOptions({organizationId:n,sorting:Sk,pagination:r}))),r(e.localization.labelCollections.list.queryKey({organizationId:n}),r=>t.fetchQuery(e.localization.labelCollections.list.queryOptions({organizationId:n,sorting:Sk,pagination:r}))),r(e.localization.labelTranslations.list.queryKey({organizationId:n}),r=>t.fetchQuery(e.localization.labelTranslations.list.queryOptions({organizationId:n,sorting:Sk,pagination:r})))]),l=[];for(let n of lE(i.map(e=>e.id),Ck))l.push(...await t.fetchQuery({...e.cms.collections.getWithFields.queryOptions(n),staleTime:0}));return{collections:l,entries:a,entryTranslations:o,labelCollections:s,labelTranslations:c}}function Tk(e,t){return Promise.all([t.invalidateQueries({queryKey:e.cms.collections.list.queryKey()}),t.invalidateQueries({queryKey:e.cms.entries.list.queryKey()}),t.invalidateQueries({queryKey:e.localization.entryTranslations.list.queryKey()}),t.invalidateQueries({queryKey:e.localization.labelCollections.list.queryKey()}),t.invalidateQueries({queryKey:e.localization.labelTranslations.list.queryKey()})])}function Ek(e){return e===void 0?()=>!0:t=>e.includes(t)}function Dk(e,t){let n=Ek(t.contentCollectionSlugs),r=Ek(t.labelCollectionSlugs),i=Ek(t.languages),a=e.content.collections.filter(e=>n(e.slug)),o=new Set(a.flatMap(e=>e.entries.map(e=>e.id)));return{metadata:e.metadata,content:{collections:a,entryTranslations:e.content.entryTranslations.filter(e=>o.has(e.entryId)&&i(e.language))},labels:{collections:e.labels.collections.filter(e=>r(e.slug)).map(e=>({...e,labels:e.labels.map(e=>({...e,translations:e.translations.filter(e=>i(e.language))}))}))}}}function Ok(e,t){let n=(e,n)=>t.includes(n)?e:[];return{collectionsToCreate:n(e.collectionsToCreate,`collections`),collectionsToUpdate:n(e.collectionsToUpdate,`collections`),entriesToCreate:n(e.entriesToCreate,`entries`),entriesToUpdate:n(e.entriesToUpdate,`entries`),entryTranslationsToCreate:n(e.entryTranslationsToCreate,`translations`),entryTranslationsToUpdate:n(e.entryTranslationsToUpdate,`translations`),labelCollectionsToCreate:n(e.labelCollectionsToCreate,`labelCollections`),labelCollectionsToUpdate:n(e.labelCollectionsToUpdate,`labelCollections`),labelTranslationsToCreate:n(e.labelTranslationsToCreate,`translations`),labelTranslationsToUpdate:n(e.labelTranslationsToUpdate,`translations`),unchanged:e.unchanged}}function kk(){let e=R(),t=fe(),n=md(),[r,i]=(0,Y.useState)(null),a=B(e.cms.collections.create.mutationOptions()),o=B(e.cms.collections.update.mutationOptions()),s=B(e.cms.entries.create.mutationOptions()),c=B(e.cms.entries.update.mutationOptions()),l=B(e.localization.entryTranslations.create.mutationOptions()),u=B(e.localization.entryTranslations.update.mutationOptions()),d=B(e.localization.labelCollections.create.mutationOptions()),f=B(e.localization.labelCollections.update.mutationOptions()),p=B(e.localization.labelTranslations.create.mutationOptions()),m=B(e.localization.labelTranslations.update.mutationOptions());return{runScopedImport:async({file:r,scope:h,kinds:g})=>{i(null);let _=await wk({client:e,queryClient:t,organizationId:n}),v=Ok(gk({file:Dk(r,h),existing:_,organizationId:n,newId:xr,now:()=>new Date}),g),y=await bk({plan:v,mutations:{createCollections:a.mutateAsync,updateCollections:o.mutateAsync,createEntries:s.mutateAsync,updateEntries:c.mutateAsync,createLabelCollections:d.mutateAsync,updateLabelCollections:f.mutateAsync,createLabelTranslations:p.mutateAsync,updateLabelTranslations:m.mutateAsync,createEntryTranslations:l.mutateAsync,updateEntryTranslations:u.mutateAsync},onProgress:i});return await Tk(e,t),{outcome:y,unchanged:v.unchanged,planned:_k(v)}},progress:r}}function Ak(e,t){return t===`content`?e.content.collections.map(e=>({slug:e.slug,name:e.name,count:e.entries.length})):e.labels.collections.map(e=>({slug:e.slug,name:e.name,count:e.labels.length}))}function jk({open:e,onClose:t,title:n,description:r,kinds:i,baseScope:a,selection:o,confirmLabel:s}){let{runScopedImport:c,progress:l}=kk(),u=(0,Y.useRef)(null),[d,f]=(0,Y.useState)([]),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(new Set),[_,v]=(0,Y.useState)(`idle`),[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(null),C=_===`reading`||_===`importing`,w=p&&o?Ak(p,o):[],T=!!p&&!C&&(!o||h.size>0),E=()=>{f([]),m(null),g(new Set),v(`idle`),b(``),S(null),u.current&&(u.current.value=``)},D=()=>{E(),t()},O=async e=>{f(e),m(null),S(null),v(`reading`),b(``);try{let t=await mk(e);
115m(t),g(new Set(o?Ak(t,o).map(e=>e.slug):[])),v(`idle`)}catch(e){v(`error`),b(e instanceof Error?e.message:`Unable to read this file`)}},k=async()=>{if(p){v(`importing`),b(``);try{let e=[...h],t=await c({file:p,scope:{...a,...o===`content`?{contentCollectionSlugs:e}:{},...o===`labels`?{labelCollectionSlugs:e}:{}},kinds:i});S(t),v(`done`),b(t.planned===0?`Everything in this file is already up to date.`:`Wrote ${t.outcome.written.toLocaleString()} of ${t.outcome.total.toLocaleString()} planned changes.`)}catch(e){v(`error`),b(e instanceof Error?e.message:`The import failed`)}}},A=l&&l.total>0?Math.round(l.processed/l.total*100):0;return(0,X.jsx)(ar,{open:e,onOpenChange:e=>{!e&&!C&&D()},children:(0,X.jsxs)(pr,{className:`sm:max-w-150`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:n}),(0,X.jsx)(_r,{children:r})]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`input`,{ref:u,type:`file`,multiple:!0,accept:`.zip,application/zip,.json,application/json`,className:`hidden`,onChange:e=>{let t=[...e.target.files??[]];t.length>0&&O(t)}}),(0,X.jsx)(U,{type:`button`,variant:`outline`,className:`h-auto w-full rounded-lg border-2 border-dashed p-6 text-center transition-colors hover:border-primary/50 hover:bg-muted/20 disabled:cursor-not-allowed disabled:opacity-60`,disabled:C,onClick:()=>u.current?.click(),onDragOver:e=>e.preventDefault(),onDrop:e=>{e.preventDefault();let t=[...e.dataTransfer.files];t.length>0&&!C&&O(t)},children:(0,X.jsxs)(`span`,{children:[(0,X.jsx)(Vr,{className:`mx-auto mb-2 size-7 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`block text-sm font-medium`,children:d.length===0?Z(`views.data-transfer.choose-files`):d.length===1?d[0]?.name:`${d.length} files selected`}),(0,X.jsx)(`span`,{className:`mt-1 block text-xs text-muted-foreground`,children:Z(_===`reading`?`views.data-transfer.reading`:`views.data-transfer.accepted-files`)})]})}),_!==`done`&&w.length>0&&(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsx)(`legend`,{className:`text-sm font-medium`,children:o===`content`?`Collections`:`Label collections`}),(0,X.jsx)(`div`,{className:`max-h-50 divide-y overflow-y-auto rounded-lg border`,children:w.map(e=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 p-3 text-sm transition-colors hover:bg-muted/50`,children:[(0,X.jsx)(Pd,{checked:h.has(e.slug),disabled:C,onCheckedChange:t=>g(n=>{let r=new Set(n);return t?r.add(e.slug):r.delete(e.slug),r})}),(0,X.jsx)(`span`,{className:`flex-1 font-medium`,children:e.name}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[e.count,` `,o===`content`?`entries`:`keys`]})]},e.slug))})]}),_===`importing`&&(0,X.jsxs)(qE,{value:A,children:[(0,X.jsx)(XE,{children:l?vk[l.step]:Z(`views.data-transfer.reading-data`)}),(0,X.jsx)(ZE,{children:()=>l?`${l.processed.toLocaleString()} / ${l.total.toLocaleString()}`:``})]}),_===`done`&&x&&(0,X.jsx)($E,{message:y,outcome:x.outcome}),_===`error`&&(0,X.jsxs)(or,{variant:`destructive`,children:[(0,X.jsx)($r,{className:`size-4`}),(0,X.jsx)(hr,{children:y})]})]}),(0,X.jsxs)(lr,{children:[_===`done`&&x&&(x.outcome.failed>0||x.outcome.skipped>0)&&(0,X.jsxs)(U,{variant:`outline`,onClick:()=>{dE(`storyverse-import-report.txt`,new Blob([xk(x.outcome)],{type:`text/plain`})),J.success(Z(`views.data-transfer.report-downloaded`))},children:[(0,X.jsx)(ro,{className:`size-4`,"aria-hidden":`true`}),Z(`views.data-transfer.download-report`)]}),(0,X.jsx)(U,{variant:`outline`,onClick:D,disabled:C,children:Z(_===`done`?`common.close`:`common.cancel`)}),_!==`done`&&(0,X.jsxs)(U,{onClick:()=>void k(),disabled:!T,children:[_===`importing`?(0,X.jsx)(An,{className:`size-4`}):(0,X.jsx)(wi,{className:`size-4`,"aria-hidden":`true`}),_===`importing`?Z(`views.data-transfer.importing`):s]})]})]})})}jk.displayName=`ImportArchiveDialog`;function Mk({canImport:e}){let[t,n]=(0,Y.useState)(!1);return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{variant:`outline`,size:`sm`,onClick:()=>n(!0),"aria-label":`Import everything from an export`,children:[(0,X.jsx)(ii,{className:`size-4`,"aria-hidden":`true`}),`Import all`]}),(0,X.jsx)(jk,{open:t,onClose:()=>
115n(!1),title:`Import everything`,description:Z(`views.data-transfer.import-everything.description`),kinds:[`collections`,`entries`,`labelCollections`,`translations`],confirmLabel:`Import everything`})]}):null}Mk.displayName=`DevImportEverythingDialog`;function Nk(e,t){return e.localeCompare(t)}function Pk(e,t,n=new Date().toISOString()){let r=new Map;for(let t of e.entries){let e=r.get(t.collectionId)??[];e.push(t),r.set(t.collectionId,e)}let i=[...e.collections].sort((e,t)=>Nk(e.slug,t.slug)).map(e=>({id:e.id,name:e.name,slug:e.slug,description:e.description??null,fields:[...e.fields??[]].map((e,t)=>({id:e.id,name:e.name,propertyName:e.propertyName??``,type:e.type,required:e.required??!1,options:e.options??{},order:e.order??t,helpText:e.helpText??null})).sort((e,t)=>e.order-t.order||Nk(e.propertyName,t.propertyName)),entries:[...r.get(e.id)??[]].map(e=>({id:e.id,collectionId:e.collectionId,name:e.name,slug:e.slug??``,properties:e.properties??{},status:e.status})).sort((e,t)=>Nk(e.slug,t.slug))})),a=new Map;for(let e of i)for(let t of e.entries)a.set(t.id,{collectionSlug:e.slug,entrySlug:t.slug});let o=[];for(let t of e.entryTranslations){let e=a.get(t.entryId);e&&o.push({id:t.id,entryId:t.entryId,collectionSlug:e.collectionSlug,entrySlug:e.entrySlug,propertyName:t.propertyName,language:t.language,value:t.value,isActive:t.isActive})}o.sort((e,t)=>Nk(e.entryId,t.entryId)||Nk(e.propertyName,t.propertyName)||Nk(e.language,t.language));let s=new Map;for(let t of e.labelTranslations){let e=s.get(t.labelCollectionId)??[];e.push(t),s.set(t.labelCollectionId,e)}let c=[...e.labelCollections].sort((e,t)=>Nk(e.slug,t.slug)).map(e=>{let t=new Map;for(let n of s.get(e.id)??[]){let e=t.get(n.key)??[];e.push({id:n.id,language:n.language,value:n.value,description:n.description??null,isActive:n.isActive??!0}),t.set(n.key,e)}return{id:e.id,name:e.name,slug:e.slug,description:e.description??null,labels:[...t.entries()].sort(([e],[t])=>Nk(e,t)).map(([e,t])=>({key:e,translations:t.sort((e,t)=>Nk(e.language,t.language))}))}}),l=new Set([t]);for(let e of o)l.add(e.language);for(let e of c)for(let t of e.labels)for(let e of t.translations)l.add(e.language);return zO.parse({metadata:{format:`storyverse-content-manager`,version:`3.0`,exportedAt:n,defaultLocale:t,exportedLocales:[t,...[...l].filter(e=>e!==t).sort(Nk)]},content:{collections:i,entryTranslations:o},labels:{collections:c}})}function Fk(e){let[t,n]=(0,Y.useState)(new Set),r=e.map(e=>e.slug).join(`\0`);return(0,Y.useEffect)(()=>{n(new Set(r?r.split(`\0`):[]))},[r]),{ticked:t,setTicked:n,toggle:(e,t)=>n(n=>{let r=new Set(n);return t?r.add(e):r.delete(e),r})}}function Ik({open:e,onClose:t}){let n=R(),r=fe(),i=md(),{activeOrganization:a}=z(),[o,s]=(0,Y.useState)(`idle`),[c,l]=(0,Y.useState)(``),[u,d]=(0,Y.useState)(null),f=(()=>{let e=a?.metadata&&typeof a.metadata==`object`?a.metadata:{};return`locales`in e&&Array.isArray(e.locales)?e.locales:[]})(),p=f.find(e=>e.isDefault)?.languageCode??f[0]?.languageCode??`en`,m=u?.content.collections.map(e=>({slug:e.slug,name:e.name,count:e.entries.length}))??[],h=u?.labels.collections.map(e=>({slug:e.slug,name:e.name,count:e.labels.length}))??[],g=u?.metadata.exportedLocales.map(e=>({slug:e,name:e,count:0}))??[],_=Fk(m),v=Fk(h),y=Fk(g),b=o===`reading`||o===`building`;(0,Y.useEffect)(()=>{if(!e||u||o!==`idle`)return;let t=!1;return(async()=>{s(`reading`);try{let e=await wk({client:n,queryClient:r,organizationId:i});if(t)return;d(Pk(e,p)),s(`idle`)}catch(e){if(t)return;l(e instanceof Error?e.message:String(e)),s(`error`)}})(),()=>{t=!0}},[e,u,o,n,r,i,p]);let x=()=>{b||(d(null),s(`idle`),l(``),t())},S=async()=>{if(u){s(`building`);try{let e=await ik(Dk(u,{contentCollectionSlugs:[..._.ticked],labelCollectionSlugs:[...v.ticked],languages:[...new Set([p,...y.ticked])]}));dE(nk,new Blob([e],{type:`application/zip`})),s(`done`),J.success(`Export downloaded`),x()}catch(e){l(e instanceof Error?e.message:String(e)),s(`error`)}}},C=(e,t,n,r=!0)=>t.length>0&&(0,X.jsxs)(`fieldset`,{className:`space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`legend`,{className:`text-sm font-medium`,children:e}),(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,disabled:b,onClick:()=>n.setTicked(n.ticked.size===t.length?new Set:new Set(t.map(e=>e.slug))),children:n.ticked.size===t.length?`None`:`All`})]}),(0,X.jsx)(`div`,{className:`max-h-50 divide-y overflow-y-auto rounded-lg border`,children:t.map(e=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-3 p-3 text-sm transition-colors hover:bg-muted/50`,children:[(0,X.jsx)(Pd,{checked:n.ticked.has(e.slug),disabled:b,onCheckedChange:t=>n.toggle(e.slug,t===!0)}),(0,X.jsx)(`span`,{className:`flex-1 font-medium`,children:e.name}),r&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.count})]},e.slug))})]});return(0,X.jsx)(ar,{open:e,onOpenChange:e=>{e||x()}
115,children:(0,X.jsxs)(pr,{className:`sm:max-w-150`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:`Export everything`}),(0,X.jsx)(_r,{children:`Download this organization as a zip holding the combined JSON and the by-collection tree. Untick anything you do not want to send.`})]}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[o===`reading`&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,X.jsx)(An,{className:`size-4`}),`Reading the organization…`]}),C(`Collections`,m,_),C(`Label collections`,h,v),C(`Languages`,g,y,!1),o===`error`&&(0,X.jsxs)(or,{variant:`destructive`,children:[(0,X.jsx)($r,{className:`size-4`,"aria-hidden":`true`}),(0,X.jsx)(hr,{children:c})]})]}),(0,X.jsxs)(lr,{children:[(0,X.jsx)(U,{variant:`outline`,onClick:x,disabled:b,children:`Cancel`}),(0,X.jsxs)(U,{onClick:()=>void S(),disabled:!u||b,children:[o===`building`?(0,X.jsx)(An,{className:`size-4`}):(0,X.jsx)(Wr,{className:`size-4`,"aria-hidden":`true`}),`Download zip`]})]})]})})}Ik.displayName=`ExportArchiveDialog`;function Lk({canExport:e}){let[t,n]=(0,Y.useState)(!1);return e?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(U,{variant:`outline`,size:`sm`,onClick:()=>n(!0),"aria-label":`Export everything as a zip`,children:[(0,X.jsx)(Wr,{className:`size-4`,"aria-hidden":`true`}),`Export all`]}),(0,X.jsx)(Ik,{open:t,onClose:()=>n(!1)})]}):null}Lk.displayName=`ExportAllButton`;function Rk(){let{hasPermissions:e,session:t}=z(),n=md();if(t?.user?.role!==`admin`)return null;let r=e(n,`cms`,`list`)&&e(n,`cms`,`delete`)&&e(n,`translateEntry`,`list`)&&e(n,`translateEntry`,`delete`)&&e(n,`translateLabel`,`list`)&&e(n,`translateLabel`,`delete`)&&e(n,`translateUi`,`list`)&&e(n,`translateUi`,`delete`)&&e(n,`organization`,`update`),i=e(n,`cms`,`list`)&&e(n,`translateEntry`,`list`)&&e(n,`translateLabel`,`list`),a=e(n,`cms`,`create`)&&e(n,`cms`,`update`)&&e(n,`translateEntry`,`create`)&&e(n,`translateEntry`,`update`)&&e(n,`translateLabel`,`create`)&&e(n,`translateLabel`,`update`);return(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,X.jsx)(Lk,{canExport:i}),(0,X.jsx)(Mk,{canImport:a}),(0,X.jsx)(KE,{canDelete:r})]})}Rk.displayName=`DataTransferActions`;function zk(){let{activeOrganization:e,hasPermissions:t}=z(),n=md(),r=t(n,`translateEntry`,`list-view`);return{orgId:n,activeOrganization:e,canViewTranslateEntry:r,canViewLocalization:r,canViewLabels:t(n,`translateLabel`,`list-view`),canViewSystem:t(n,`translateSystem`,`list-view`)}}function Bk(e){let t=e?.locales;return t?.length?t.map(e=>`${e.languageCode}:${e.isDefault?`1`:`0`}`).sort().join(`|`):``}function Vk(e,t,n){let r=Bk(t);(0,Y.useEffect)(()=>{if(!e||!r||!t?.locales?.length)return;let i=t.locales;n(i.find(e=>e.isDefault)?.languageCode??i[0]?.languageCode??`en`)},[e,r,t,n])}function Hk({open:e,onOpenChange:t,title:n,description:r,onConfirm:i}){let[a,o]=(0,Y.useState)(!1);return(0,X.jsx)(cr,{open:e,onOpenChange:t,children:(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:n}),(0,X.jsx)(Cr,{children:r})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{type:`button`,disabled:a,children:Z(`common.cancel`)}),(0,X.jsx)(sr,{type:`button`,variant:`destructive`,disabled:a,onClick:async()=>{o(!0);try{await i(),t(!1)}catch(e){console.error(`Delete failed:`,e)}finally{o(!1)}},children:Z(`common.delete`)})]})]})})}Hk.displayName=`ConfirmDeleteDialog`;function Uk({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`skeleton`,className:q(`animate-pulse rounded-2xl bg-muted`,e),...t})}var Wk=6,Gk=8;function Kk(){return(0,X.jsx)(`div`,{className:`divide-y`,role:`status`,"aria-label":Z(`common.loading`),children:Array.from({length:Wk},(e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-3 px-6 py-3`,"aria-hidden":`true`,children:[(0,X.jsx)(Uk,{className:`size-4 shrink-0 rounded-sm`}),(0,X.jsx)(Uk,{className:`size-8 shrink-0 rounded-lg`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,X.jsx)(Uk,{className:`h-4 w-40 max-w-full`}),(0,X.jsx)(Uk,{className:`h-3 w-24 max-w-[60%]`})]}),(0,X.jsx)(Uk,{className:`h-5 w-16 shrink-0 rounded-full`})]},t))})}function qk({rows:e=Gk}){return(0,X.jsxs)(`div`,{className:`flex h-full flex-col gap-4 p-4`,role:`status`,"aria-label":Z(`common.loading`),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,"aria-hidden":`true`,children:[(0,X.jsx)(Uk,{className:`h-8 w-48 max-w-[50%]`}),(0,X.jsx)(Uk,{className:`ml-auto h-8 w-24`}),(0,X.jsx)(Uk,{className:`h-8 w-8`})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,"aria-hidden":`true`,children:[(0,X.jsxs)(`div`,{className:`flex gap-4 border-b pb-2`,children:[(0,X.jsx)(Uk,{className:`h-4 w-8`}),(0,X.jsx)(Uk,{className:`h-4 w-32`}),(0,X.jsx)(Uk,{className:`h-4 flex-1`}),(0,X.jsx)(Uk,{className:`h-4 w-20`})]}),Array.from({length:e},(e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-4 py-2`,children:[(0,X.jsx)(Uk,{className:`h-4 w-8`}),(0,X.jsx)(Uk,{className:`h-4 w-32`}),(0,X.jsx)(Uk,{className:`h-4 flex-1`}),(0,X.jsx)(Uk,{className:`h-4 w-20`})]},t))]})]})}function Jk({rows:e=Gk,showHeading:t=!0}){return(0,X.jsxs)(`div`,{className:`space-y-4`,role:`status`,"aria-label":Z(`common.loading`),children:[t&&(0,X.jsxs)(`div`,{className:`space-y-2`,"aria-hidden":`true`,children:[(0,X.jsx)(Uk,{className:`h-5 w-40`}),(0,X.jsx)(Uk,{className:`h-4 w-64 max-w-full`})]}),(0,X.jsx)(`div`,{className:`space-y-2`,"aria-hidden":`true`,children:Array.from({length:e},(e,t)=>(0,X.jsxs)(`div`,{className:`flex items-center gap-4 py-2`,children:[(0,X.jsx)(Uk,{className:`h-4 w-1/4`}),(0,X.jsx)(Uk,{className:`h-8 flex-1`})]},t))})]})}function Yk(e){return e.createdAt?new Date(e.createdAt).getTime():0}function Xk(e,t){return Yk(t)-Yk(e)||e.id.localeCompare(t.id)}function Zk(e){return[...e??[]].sort(Xk)}function Qk(e){return!e||Array.isArray(e)?!1:`fields`in e&&Array.isArray(e.fields)}function $k(e,t=0){if(!e||!e[t])return null;let n=e[t];return Qk(n)?n:null}function eA({open:e,onClose:t}){let{currentActiveCollectionId:n}=UE(),r=R(),i=md(),{data:a}=V(r.cms.collections.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:i})),{data:o}=V(r.cms.entries.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:i})),s=a?.items.map(e=>e.id)??[],{data:c}=V(r.cms.collections.getWithFields.queryOptions(s,{enabled:s.length>0})),[l,u]=(0,Y.useState)(new Set(n?[n]:[])),d=(e,t)=>{let n=new Set(l);t?n.add(e):n.delete(e),u(n)},f=e=>{u(e?new Set(a?.items.map(e=>e.id)??[]):new Set)},p=a?.items.filter(e=>l.has(e.id));return(0,X.jsx)(ar,{open:e,onOpenChange:t,children:(0,X.jsxs)(pr,{className:`sm:max-w-125`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:`Export Collection`}),(0,X.jsx)(_r,{children:`Export content from selected collections`})]}),(0,X.jsxs)(`div`,{className:`space-y-6 py-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)($t,{children:`Select Collections`}),(0,X.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>f(l.size!==(a?.items.length??0)),className:`h-auto p-0 text-xs text-muted-foreground hover:text-foreground`,children:l.size===(a?.items.length??0)?`Deselect All`:`Select All`})]}),(0,X.jsx)(`div`,{className:`max-h-50 divide-y overflow-y-auto rounded-lg border`,children:a?.items.map(e=>
115{let t=o?.items.filter(t=>t.collectionId===e.id).length??0;return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 p-3 transition-colors hover:bg-muted/50`,children:[(0,X.jsx)(Pd,{checked:l.has(e.id),onCheckedChange:t=>d(e.id,t),id:`collection-${e.id}`}),(0,X.jsxs)(`label`,{htmlFor:`collection-${e.id}`,className:`flex flex-1 cursor-pointer items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.name}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t,` item`,t===1?``:`s`]})]})]},e.id)})})]}),(0,X.jsxs)(`div`,{className:`rounded-md bg-muted/50 p-3 text-sm text-muted-foreground`,children:[`This will export`,` `,p?.reduce((e,t)=>e+(o?.items.filter(e=>e.collectionId===t.id).length??0),0),` `,`item(s) from the selected collections.`]})]}),(0,X.jsxs)(lr,{children:[(0,X.jsx)(U,{variant:`outline`,onClick:t,children:`Cancel`}),(0,X.jsxs)(U,{onClick:()=>{if(p?.length===0)return;let e=p?.map(e=>({...e,id:e.id,collection:e.name,fields:c?.find(t=>t.id===e.id)?.fields??[],entries:o?.items.filter(t=>t.collectionId===e.id)??[],exportedAt:new Date().toISOString()})),n=JSON.stringify(e??[],null,2),r=new Blob([n],{type:`application/json`}),i=URL.createObjectURL(r),a=document.createElement(`a`);a.href=i,a.download=`collections-content.json`,document.body.appendChild(a),a.click(),document.body.removeChild(a),URL.revokeObjectURL(i),t()},children:[(0,X.jsx)(Wr,{className:`mr-2 size-4`}),`Export`]})]})]})})}function tA(e){if(typeof e!=`object`||!e)return;let t=e.data;return typeof t?.code==`string`?t.code:void 0}function nA(e){let t=tA(e),n=``;(e instanceof Error||typeof e==`object`&&e&&`message`in e&&typeof e.message==`string`)&&(n=e.message);let r=n.toLowerCase();switch(t){case`UNAUTHORIZED`:return`Your session may have expired. Sign in again, then reopen this collection.`;case`FORBIDDEN`:return`You don’t have permission to open this collection. Ask an organization admin if you need access.`;case`NOT_FOUND`:return`This collection isn’t available anymore. Choose another one from the list on the left.`;case`TIMEOUT`:return`The server took too long to respond. Check your connection and try again.`;case`INTERNAL_SERVER_ERROR`:return`Something went wrong on our side. Please wait a moment and try again.`;case`BAD_REQUEST`:return`We couldn’t load this data. Refresh the page or pick a different collection.`}if(r.includes(`unauthorized`)||r.includes(`401`))return`Your session may have expired. Sign in again, then reopen this collection.`;if(r.includes(`forbidden`)||r.includes(`403`))return`You don’t have permission to open this collection. Ask an organization admin if you need access.`;if(r.includes(`not found`)||r.includes(`404`))return`This collection isn’t available anymore. Choose another one from the list on the left.`;if(r.includes(`failed to fetch`)||r.includes(`network`)||r.includes(`load failed`))return`We couldn’t reach the server. Check your internet connection and try again.`;if(r.includes(`timeout`))return`The server took too long to respond. Check your connection and try again.`;let i=n.trim();return i.length>0&&i.length<=160&&!i.includes(`
116`)&&!i.includes(` at `)&&!r.includes(`trpc`)&&!r.includes(`undefined`)&&!r.includes(`unexpected token`)?i:`We couldn’t load this right now. Refresh the page or try again in a few moments.`}function rA({title:e,message:t,onRefresh:n,isRefreshing:r}){return(0,X.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 p-6 text-center`,role:`alert`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium text-destructive`,children:e}),(0,X.jsx)(`p`,{className:`max-w-md text-sm text-muted-foreground`,children:t}),(0,X.jsx)(`p`,{className:`mt-2 max-w-md text-xs text-muted-foreground`,children:`If this keeps happening, try another collection or contact your admin.`}),n!=null&&(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,className:`mt-2`,disabled:r,onClick:()=>void n(),"aria-label":`Refresh and try again`,children:[(0,X.jsx)(Ir,{className:q(`mr-2 size-4`,r===!0&&`animate-spin`),"aria-hidden":`true`}),`Try again`]})]})}function iA({editorSlot:e}={}){let{currentActiveCollectionId:t,setCurrentActiveCollectionId:n}=UE(),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(void 0),[d,f]=(0,Y.useState)({}),[p,m]=(0,Y.useState)(!1),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(t);t!==_&&(v(t),i(!1),u(void 0),f({}));let{hasPermissions:y}=z(),b=R(),x=md(),S=y(x,`cms`,`create`),C=y(x,`cms`,`delete`),w=b.cms.collections.list.queryKey(),T=b.cms.entries.list.queryKey(),E=fe(),{data:D,isLoading:O,isError:k,error:A,refetch:j,isFetching:M}=V({...fE(b.cms.entries.list.queryKey({organizationId:x,collectionId:t||void 0}),e=>E.fetchQuery(b.cms.entries.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],columnFilters:[],globalFilter:``,organizationId:x,collectionId:t||void 0,pagination:e}))),enabled:!!t}),{data:N,isLoading:P,isError:F,error:I,refetch:L,isFetching:ee}=V(b.cms.collections.getWithFields.queryOptions([t],{enabled:!!t})),te=(0,Y.useMemo)(()=>Zk(D),[D]),ne=B(b.cms.entries.remove.mutationOptions({onSuccess:()=>{E.invalidateQueries({queryKey:T}),f({})}})),re=B(b.cms.collections.remove.mutationOptions({onSuccess:async()=>{m(!1),await E.invalidateQueries({queryKey:w}),await E.invalidateQueries({queryKey:T});let e=(await E.fetchQuery(b.cms.collections.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],pagination:{pageIndex:0,pageSize:10},columnFilters:[],globalFilter:``,organizationId:x})))?.items?.[0]?.id??null;n(e??``),e?localStorage.setItem(`cms-active-collection`,e):localStorage.removeItem(`cms-active-collection`)}})),ie=e=>{u(e),i(!0)},ae=()=>{i(!1),u(void 0)},oe=e=>{r&&l?.id===e.id?ae():ie(e)},se=e=>{e?ie(e):ae()},ce=e=>{g(e)},le=async()=>{h&&await ne.mutateAsync(h.map(e=>e.id))}
116,ue=String(h?.length??0),de=h?.length===1?h[0]:void 0,pe=de?Z(`views.cms.delete.entry.title`):Z(`views.cms.delete.entries.title`).replace(`{{count}}`,ue),me=de?Z(`views.cms.delete.entry.description`).replace(`{{name}}`,de.name||de.slug||``):Z(`views.cms.delete.entries.description`).replace(`{{count}}`,ue),he=(0,Y.useMemo)(()=>te.length===0?[]:Object.keys(d).map(e=>te.find(t=>t.id===e)).filter(e=>!!e),[d,te]),ge=(0,Y.useCallback)(e=>{g([e])},[]),_e=(0,Y.useCallback)(async()=>{await Promise.all([L(),j()])},[L,j]),ve=(ee||M)&&!P&&!O,ye=$k(N),be=(0,Y.useMemo)(()=>ye?Rd(ye,C?ge:void 0):[],[ye,ge,C]),xe=(0,Y.useMemo)(()=>[{id:`name`,label:Z(`common.name`)},{id:`slug`,label:Z(`views.content-manager.columns.slug`)},{id:`status`,label:Z(`common.status`)},...(ye?.fields??[]).map(e=>({id:Ld(e.propertyName),label:e.name}))],[ye]);if(!t)return(0,X.jsx)(`div`,{className:`flex h-full items-center justify-center`,children:(0,X.jsx)(`div`,{className:`text-muted-foreground`,children:`Select or create a collection to view its entries`})});if(P||O)return(0,X.jsx)(qk,{});if(F)return(0,X.jsx)(rA,{title:`We couldn’t open this collection`,message:nA(I),onRefresh:_e,isRefreshing:ve});if(!ye)return(0,X.jsx)(rA,{title:`This collection isn’t available`,message:`It may have been removed or you may not have access. Pick another collection from the sidebar.`,onRefresh:_e,isRefreshing:ve});if(k)return(0,X.jsx)(rA,{title:`We couldn’t load the items in this collection`,message:nA(A),onRefresh:_e,isRefreshing:ve});let H=te.length,Se=C&&H===0;return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(pd,{fillHeight:!0,columns:be,data:te,searchableColumns:xe,getRowId:e=>e.id,rowSelection:d,onRowSelectionChange:f,onRowClick:e=>oe(e),primaryAction:S?{id:`create-item`,label:`Create Item`,icon:(0,X.jsx)(va,{className:`size-4`,"aria-hidden":`true`}),variant:`default`,ariaLabel:`Create new item`,quickHelpTarget:`content-create-item`,onClick:()=>ie()}:void 0,secondaryActions:[{id:`refresh`,label:`Refresh`,icon:(0,X.jsx)(Ir,{className:q(`size-4`,ve&&`animate-spin`),"aria-hidden":`true`}),disabled:ve,ariaLabel:`Refresh table`,onClick:()=>void _e()},{id:`export`,label:`Export`,icon:(0,X.jsx)(Wr,{className:`size-4`,"aria-hidden":`true`}),group:`Data`,ariaLabel:`Export content`,onClick:()=>o(!0)},{id:`import`,label:`Import`,icon:(0,X.jsx)(wi,{className:`size-4`,"aria-hidden":`true`}),hidden:!S,ariaLabel:`Import content`,onClick:()=>c(!0)},{id:`delete-selected`,label:`Delete (${he.length})`,icon:(0,X.jsx)(Qi,{className:`size-4`,"aria-hidden":`true`}),variant:`destructive`,separator:!0,hidden:!(C&&he.length>0),ariaLabel:`Delete ${he.length} selected entries`,onClick:()=>ce(he)},{id:`remove-collection`,label:`Remove collection`,icon:(0,X.jsx)(Qi,{className:`size-4`,"aria-hidden":`true`}),variant:`destructive`,separator:!0,hidden:!Se,ariaLabel:`Remove empty collection`,onClick:()=>m(!0)}]})}),Se&&(0,X.jsx)(cr,{open:p,onOpenChange:m,children:(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:`Remove this collection?`}),(0,X.jsxs)(Cr,{children:[`This will permanently delete "`,ye.name,`" and its field schema. There are no entries in this collection. This cannot be undone.`]})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{children:`Cancel`}),(0,X.jsx)(sr,{variant:`destructive`,disabled:re.isPending,onClick:()=>{t&&re.mutate([t])},children:`Remove collection`})]})]})}),(0,X.jsx)(Hk,{open:h!==null,onOpenChange:e=>!e&&g(null),title:pe,description:me,onConfirm:le}),(0,X.jsx)(Jw,{open:r,setOpen:se,collection:ye,entry:l,desktopContainer:e}),(0,X.jsx)(eA,{open:a,onClose:()=>o(!1)}),(0,X.jsx)(jk,{open:s,onClose:()=>c(!1),title:`Import collections`,description:`Create and update collections and their entries from a Storyverse export archive. Translations are imported from the Localization tab.`,kinds:[`collections`,`entries`],baseScope:{labelCollectionSlugs:[],languages:[]},selection:`content`,confirmLabel:`Import collections`})]},t)}function aA(e){return e.replace(/[\s-]+/g,e=>/\s/.test(e)?`-`:e)}var oA=lt({name:H(),slug:H(),description:H()});function sA({collection:e,canUpdate:t,defaultLocaleName:n}){let r=R(),i=fe(),a=l({resolver:pn(oA),defaultValues:{name:e.name,slug:e.slug,description:e.description??``}}),o=(0,Y.useRef)(e.slug.length===0),s=(0,Y.useRef)(null),c=(0,Y.useRef)(null);(0,Y.useLayoutEffect)(()=>
116{let e=c.current;e!==null&&(c.current=null,s.current?.setSelectionRange(e,e))});let u=B(r.localization.labelCollections.update.mutationOptions({onSuccess:()=>{i.invalidateQueries({queryKey:r.localization.labelCollections.list.queryKey()}),J.success(`Label collection saved`)},onError:()=>J.error(`Unable to save label collection`)}));return(0,X.jsxs)(`form`,{className:`border-b pb-6`,"data-quick-help":`labels-collection-details`,onSubmit:a.handleSubmit(n=>{if(!t)return;let r={name:n.name.trim(),slug:aA(n.slug.trim()),description:n.description.trim()};a.setValue(`name`,r.name),a.setValue(`slug`,r.slug),a.setValue(`description`,r.description),u.mutate([{id:e.id,name:r.name,slug:r.slug,description:r.description||null}],{onSuccess:()=>a.reset(r)})}),children:[(0,X.jsxs)(`div`,{className:`mb-4 flex items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Label collection`}),(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Source labels are managed in `,n,`.`]})]}),t&&(0,X.jsxs)(U,{type:`submit`,size:`sm`,disabled:!a.formState.isDirty||u.isPending,children:[(0,X.jsx)(io,{className:`size-4`}),`Save`]})]}),(0,X.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-2`,children:[(0,X.jsx)(h,{name:`name`,control:a.control,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{className:`gap-1.5`,"data-invalid":n.invalid,children:[(0,X.jsx)(K,{htmlFor:`label-collection-name`,children:`Name`}),(0,X.jsx)(W,{...e,id:`label-collection-name`,readOnly:!t,"aria-invalid":n.invalid,onChange:t=>{e.onChange(t);let n=t.target.value,r=a.getValues(`slug`);(o.current||r.length===0)&&a.setValue(`slug`,aA(n),{shouldDirty:!0})}})]})}),(0,X.jsx)(h,{name:`slug`,control:a.control,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{className:`gap-1.5`,"data-invalid":n.invalid,children:[(0,X.jsx)(K,{htmlFor:`label-collection-slug`,children:`Slug`}),(0,X.jsx)(W,{...e,id:`label-collection-slug`,ref:t=>{e.ref(t),s.current=t},readOnly:!t,"aria-invalid":n.invalid,onChange:t=>{let{value:n,selectionStart:r}=t.target,i=aA(n);c.current=aA(n.slice(0,r??n.length)).length,o.current=i.length===0,e.onChange(i)}})]})}),(0,X.jsx)(h,{name:`description`,control:a.control,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{className:`gap-1.5 md:col-span-2`,"data-invalid":n.invalid,children:[(0,X.jsx)(K,{htmlFor:`label-collection-description`,children:`Description`}),(0,X.jsx)(bt,{...e,id:`label-collection-description`,readOnly:!t,"aria-invalid":n.invalid,placeholder:`Optional description`})]})})]})]})}var cA=1500;function lA(e=cA){let[t,n]=(0,Y.useState)(new Set),r=(0,Y.useRef)(new Map);return(0,Y.useEffect)(()=>{let e=r.current;return()=>{e.forEach(e=>clearTimeout(e)),e.clear()}},[]),{savedIds:t,flashSaved:(0,Y.useCallback)(t=>{let i=r.current,a=i.get(t);a&&clearTimeout(a),n(e=>new Set(e).add(t)),i.set(t,setTimeout(()=>{i.delete(t),n(e=>{let n=new Set(e);return n.delete(t),n})},e))},[e])}}function uA(e,t){if(t)return;let n=e.currentTarget;document.activeElement!==n&&n.focus({preventScroll:!0})}function dA(e){let t=e.currentTarget,n=t.value.length;t.setSelectionRange(n,n)}function fA(e,t){return`${e}:${t}`}var pA=`border-emerald-500`,mA=`transition-[color,box-shadow,border-color]`,hA=`h-full min-h-8`;function gA(e){return e.replace(/[\s.]+/g,e=>/\s/.test(e)?`.`:e)}var _A=[{id:`key`,desc:!1}],vA=[{id:`key`,label:Z(`common.key`)},{id:`value`,label:Z(`common.value`)},{id:`description`,label:Z(`common.description`)}],yA=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all source labels on this page`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select ${e.original.key}`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1,meta:{className:`w-10`}},{accessorKey:`key`,meta:{className:`w-1/4 whitespace-normal wrap-break-word`},header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Key`}),cell:({row:e,table:t})=>{let n=t.options.meta?.sourceLabels;return n?(0,X.jsx)(xA,{label:e.original,canUpdate:n.canUpdate,saved:n.savedIds.has(fA(e.original.id,`key`)),onUpdate:n.onUpdate}):null}},{accessorKey:`value`,meta:{className:`w-1/3 align-top`},header:({column:e,table:t})=>(0,X.jsx)(Fd,{column:e,title:`Value (${t.options.meta?.sourceLabels?.defaultLocale.toUpperCase()??``})`}),cell:({row:e,table:t})=>{let n=t.options.meta?.sourceLabels;if(!n)return null;let r=e.original;return(0,X.jsx)(bt,{rows:1,className:q(hA,mA,n.savedIds.has(fA(r.id,`value`))&&pA),defaultValue:r.value,readOnly:!n.
116canUpdate,onMouseDown:e=>uA(e,!n.canUpdate),onFocus:dA,onBlur:e=>e.target.value!==r.value&&n.onUpdate(r,{value:e.target.value}),"aria-label":`Value for ${r.key}`})}},{accessorKey:`description`,meta:{className:`w-1/3 align-top`},header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Description`}),cell:({row:e,table:t})=>{let n=t.options.meta?.sourceLabels;if(!n)return null;let r=e.original;return(0,X.jsx)(bt,{rows:1,className:q(`text-muted-foreground`,hA,mA,n.savedIds.has(fA(r.id,`description`))&&pA),defaultValue:r.description??``,placeholder:`Optional description`,readOnly:!n.canUpdate,onMouseDown:e=>uA(e,!n.canUpdate),onFocus:dA,onBlur:e=>e.target.value!==(r.description??``)&&n.onUpdate(r,{description:e.target.value}),"aria-label":`Description for ${r.key}`})}}];function bA({collectionId:e,defaultLocale:t}){let n=R(),r=fe(),i=md(),{hasPermissions:a}=z(),{savedIds:o,flashSaved:s}=lA(),c=a(i,`translateLabel`,`create`),l=a(i,`translateLabel`,`delete`),u=a(i,`translateLabel`,`update`),d=n.localization.labelTranslations.list.queryKey(),{data:f,isError:p,isLoading:m}=V(fE(n.localization.labelTranslations.list.queryKey({organizationId:i,labelCollectionId:e,language:t}),a=>r.fetchQuery(n.localization.labelTranslations.list.queryOptions({organizationId:i,labelCollectionId:e,language:t,sorting:[{id:`createdAt`,desc:!0}],pagination:a,columnFilters:[],globalFilter:``})))),h=(0,Y.useMemo)(()=>Zk(f),[f]),g=t=>r.fetchQuery(fE(n.localization.labelTranslations.list.queryKey({organizationId:i,labelCollectionId:e,key:t}),a=>r.fetchQuery(n.localization.labelTranslations.list.queryOptions({organizationId:i,labelCollectionId:e,key:t,sorting:[{id:`createdAt`,desc:!0}],pagination:a,columnFilters:[],globalFilter:``})))),_=()=>r.invalidateQueries({queryKey:d}),v=e=>{let t=new Map(e.map(e=>[e.id,e])),n=e=>e.map(e=>{let n=t.get(e.id);return n?{...e,...n}:e});r.setQueriesData({queryKey:d},e=>e&&(Array.isArray(e)?n(e):e.items?{...e,items:n(e.items)}:e))},y=B(n.localization.labelTranslations.create.mutationOptions({onSuccess:()=>{_()},onError:()=>J.error(`Unable to create source label`)})),b=B(n.localization.labelTranslations.update.mutationOptions({onError:()=>{_(),J.error(`Unable to update source label`)}})),x=B(n.localization.labelTranslations.remove.mutationOptions({onSuccess:()=>{_()},onError:()=>J.error(`Unable to remove source label`)}));return(0,X.jsxs)(`div`,{className:`space-y-4`,"data-quick-help":`labels-source-items`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`font-medium`,children:`Source labels`}),(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Manage the source values in `,t.toUpperCase(),`.`]})]}),m&&(0,X.jsx)(Jk,{showHeading:!1}),p&&(0,X.jsx)(`p`,{className:`text-sm text-destructive`,children:`Unable to load source labels.`}),!m&&!p&&(0,X.jsx)(pd,{columns:yA,data:h,searchableColumns:vA,meta:{sourceLabels:{canUpdate:u,defaultLocale:t,savedIds:o,onUpdate:(e,t)=>{if(t.key!==void 0){let n=t.key.trim();if(!n){J.error(`A label key is required`);return}if(n===e.key)return;g(e.key).then(t=>{let r=t.map(e=>({id:e.id,key:n}));v(r),b.mutate(r,{onSuccess:()=>s(fA(e.id,`key`))})}).catch(()=>J.error(`Unable to load label translations`));return}let[n]=Object.keys(t),r=[{id:e.id,...t}];v(r),b.mutate(r,{onSuccess:()=>n&&s(fA(e.id,n))})}}},getRowId:e=>e.id,pageSize:20,initialSorting:_A,fixedLayout:!0,primaryAction:c?{id:`add-source-label`,label:`Add label`,icon:(0,X.jsx)(Hr,{className:`size-4`,"aria-hidden":`true`}),disabled:y.isPending,quickHelpTarget:`labels-add-item`,onClick:()=>{let n=new Date;y.mutate([{id:xr(),labelCollectionId:e,key:`new.label.${Date.now()}`,value:``,description:null,language:t,isActive:!0,createdAt:n,updatedAt:n}])}}:void 0,onDeleteSelected:l?async e=>{let t=new Set(e.map(e=>e.key)),n=await g();await x.mutateAsync(n.filter(e=>t.has(e.key)).map(e=>e.id))}:void 0,multipleDeleteString:{start:`Delete`,end:`source label`}})]})}function xA({label:e,canUpdate:t,saved:n,onUpdate:r}){let[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(e.key),c=(0,Y.useRef)(null),l=(0,Y.useRef)(null);if((0,Y.useEffect)(()=>{i&&c.current?.focus({preventScroll:!0})},[i]),(0,Y.useLayoutEffect)(()=>{let e=l.current;e!==null&&(l.current=null,c.current?.setSelectionRange(e,e))}),!t)return(0,X.jsx)(`div`,{className:`font-mono text-sm font-medium`,children:e.key});let u=()=>
116{s(e.key),a(!0)};return(0,X.jsx)(`div`,{onClick:()=>!i&&u(),children:i?(0,X.jsx)(W,{ref:c,type:`text`,className:q(`font-mono font-medium`,mA,n&&pA),value:o,onChange:e=>{let{value:t,selectionStart:n}=e.target;l.current=gA(t.slice(0,n??t.length)).length,s(gA(t))},onMouseDown:e=>uA(e,!1),onFocus:dA,onBlur:()=>{r(e,{key:o}),a(!1)},"aria-label":`Key for ${e.key}`}):(0,X.jsx)(`div`,{className:q(`flex h-8 cursor-text items-center rounded-2xl border border-transparent px-2.5 py-1 font-mono text-sm font-medium`,mA,n&&pA),children:e.key})})}function SA(){let e=R(),t=md(),{activeOrganization:n,hasPermissions:r}=z(),{currentActiveLabelCollectionId:i}=UE(),a=r(t,`translateLabel`,`update`),o=Oo(n?.metadata),s=o.find(e=>e.isDefault)??o[0],{data:c,isError:l,isLoading:u}=V(e.localization.labelCollections.list.queryOptions({organizationId:t,sorting:[{id:`createdAt`,desc:!0}]})),d=c?.items.find(e=>e.id===i);return u?(0,X.jsx)(`div`,{className:`p-6`,children:(0,X.jsx)(Jk,{})}):l?(0,X.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:`Unable to load the selected label collection.`}):d?s?(0,X.jsxs)(`section`,{className:`flex w-full flex-col gap-6`,children:[(0,X.jsx)(sA,{collection:d,canUpdate:a,defaultLocaleName:s.name},d.id),(0,X.jsx)(bA,{collectionId:d.id,defaultLocale:s.languageCode})]}):(0,X.jsx)(`div`,{className:`p-6 text-sm text-muted-foreground`,children:`Set an organization default locale before managing source labels.`}):(0,X.jsxs)(`section`,{className:`flex min-h-112 flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,X.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,X.jsx)(Da,{className:`size-5`})}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Labels`}),(0,X.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:`Create or select a label collection to manage its source labels.`})]})]})}function CA(e,t){let n=new Uint32Array(1);window.crypto&&typeof window.crypto.getRandomValues==`function`?window.crypto.getRandomValues(n):n[0]=Math.floor(Math.random()*4294967296);let r=(typeof n[0]==`number`?n[0]:0)/4294967296;return Math.floor(r*(t-e)+e)}function wA(e){let t=new Map;for(let n of e??[]){let e=t.get(n.labelCollectionId);e?e.add(n.key):t.set(n.labelCollectionId,new Set([n.key]))}let n=new Map;for(let[e,r]of t)n.set(e,r.size);return n}function TA({onSelect:e}){let t=R(),n=fe(),r=md(),{hasPermissions:i,activeOrganization:a}=z(),{currentActiveLabelCollectionId:o,setCurrentActiveLabelCollectionId:s}=UE(),c=(0,Y.useRef)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),h=i(r,`translateLabel`,`create`),g=i(r,`translateLabel`,`delete`),_=h&&i(r,`translateLabel`,`update`),v=vo.array().safeParse(a?.metadata&&typeof a.metadata==`object`&&`locales`in a.metadata?a.metadata.locales:void 0),y=v.success?(v.data.find(e=>e.isDefault)??v.data[0])?.languageCode:void 0,b=t.localization.labelCollections.list.queryKey(),{data:x,isError:S,isLoading:C}=V(t.localization.labelCollections.list.queryOptions({organizationId:r,sorting:[{id:`createdAt`,desc:!0}]})),w=(0,Y.useMemo)(()=>Zk(x?.items),[x]),{data:T,isLoading:E}=V({...fE(t.localization.labelTranslations.list.queryKey({organizationId:r,language:y}),e=>n.fetchQuery(t.localization.labelTranslations.list.queryOptions({organizationId:r,language:y,sorting:[{id:`createdAt`,desc:!0}],pagination:e}))),enabled:!!y}),D=(0,Y.useMemo)(()=>wA(T),[T]),O=B(t.localization.labelCollections.create.mutationOptions({onSuccess:(t,r)=>{let i=r[0];i&&(u(i.id),s(i.id),e?.(),n.invalidateQueries({queryKey:b}))},onError:()=>J.error(`Unable to create label collection`)})),k=B(t.localization.labelCollections.remove.mutationOptions({onSuccess:()=>{f(null),n.invalidateQueries({queryKey:b})},onError:()=>J.error(`Unable to remove label collection`)}));return(0,Y.useEffect)(()=>{if(x?.items){if(l){if(x.items.some(e=>e.id===l))requestAnimationFrame(()=>{if(o===l){let e=document.getElementById(`label-collection-name`);e instanceof HTMLInputElement&&!e.readOnly&&(e.focus({preventScroll:!0}),e.select())}u(null)});else if(o===l)return}if(x.items.length===0){o&&s(null);return}x.items.some(e=>e.id===o)||s(x.items[0]?.id??null)}},[o,x?.items,l,s]),(0,Y.useEffect)(()=>
116{if(c.current||!x?.items?.length)return;let e=localStorage.getItem(`cms-active-label-collection`);x.items.some(t=>t.id===e)&&s(e),c.current=!0},[x?.items,s]),(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col md:w-64`,"data-quick-help":`labels-navigation`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Da,{className:`size-4`,"aria-hidden":`true`}),(0,X.jsx)(`h2`,{className:`text-sm`,children:`Label collections`})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[_&&y&&(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-8 p-0`,onClick:()=>m(!0),"aria-label":`Import label collections`,children:(0,X.jsx)(ra,{className:`size-4`,"aria-hidden":`true`})}),h&&(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-8 p-0`,onClick:()=>{let e=CA(0,1e6),t=new Date;O.mutate([{id:xr(),name:`New label collection ${e}`,slug:`new-label-collection-${e}`,organizationId:r,createdAt:t,updatedAt:t}])},disabled:O.isPending,"aria-label":`Create label collection`,"data-quick-help":`labels-add-collection`,children:(0,X.jsx)(Hr,{className:`size-4`,"aria-hidden":`true`})})]})]}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:[C&&Array.from({length:5}).map((e,t)=>(0,X.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded-md p-2.5`,children:[(0,X.jsx)(Uk,{className:`size-4 shrink-0 rounded-sm`}),(0,X.jsx)(Uk,{className:`h-4 flex-1`}),(0,X.jsx)(Uk,{className:`h-3 w-6 shrink-0`})]},t)),S&&(0,X.jsx)(`p`,{className:`px-3 py-2 text-sm text-destructive`,children:`Unable to load label collections.`}),!C&&!S&&w.length===0&&(0,X.jsx)(`p`,{className:`px-3 py-2 text-sm text-muted-foreground`,children:`Create a collection to begin adding source labels.`}),!C&&!S&&w.map(t=>(0,X.jsxs)(`div`,{className:`group mb-0.5 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors hover:bg-foreground
116/5 ${o===t.id?`bg-foreground/10`:``}`,onClick:()=>{s(t.id),e?.()},children:[(0,X.jsx)(Da,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-sm`,children:t.name}),E?(0,X.jsx)(Uk,{className:`h-3 w-6 shrink-0`,"aria-hidden":`true`}):(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:D.get(t.id)??0}),g&&(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{nativeButton:!0,render:e=>(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-6 p-0 transition-opacity md:opacity-0 md:group-hover:opacity-100`,"aria-label":`Label collection options for ${t.name}`,onClick:e=>e.stopPropagation(),...e,children:(0,X.jsx)(kr,{className:`size-4`,"aria-hidden":`true`})})}),(0,X.jsx)(Ie,{align:`end`,children:(0,X.jsxs)(st,{className:`text-destructive`,onClick:()=>f({id:t.id,name:t.name}),children:[(0,X.jsx)(Qi,{className:`mr-2 size-4`}),`Delete`]})})]})]},t.id))]}),y&&(0,X.jsx)(jk,{open:p,onClose:()=>m(!1),title:`Import label collections`,description:`Create label collections and their source labels in ${y}. Other locales are imported from the Localization tab.`,kinds:[`labelCollections`,`translations`],baseScope:{contentCollectionSlugs:[],languages:[y]},selection:`labels`,confirmLabel:`Import labels`}),(0,X.jsx)(cr,{open:d!==null,onOpenChange:e=>!e&&f(null),children:(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:`Remove this label collection?`}),(0,X.jsxs)(Cr,{children:[`This permanently deletes "`,d?.name,`" and all of its label translations. This cannot be undone.`]})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{type:`button`,children:`Cancel`}),(0,X.jsx)(sr,{type:`button`,variant:`destructive`,disabled:k.isPending,onClick:()=>d&&k.mutate([d.id]),children:`Remove collection`})]})]})})]})}var EA=[`text`,`formatted-text`,`number`,`link`];function DA(e){return EA.includes(e)}function OA(e){return!e||typeof e!=`object`||e.localized!==!1}function kA(e){return DA(e.type)&&OA(e.options)}function AA(e){return String(e??``).trim()!==``}function jA(e,t){return AA(e)&&String(t??``).trim()!==``}var MA=[{id:`createdAt`,desc:!0}];function NA(e){let t=R(),n=fe(),r=V(fE(t.cms.collections.list.queryKey({organizationId:e}),r=>n.fetchQuery(t.cms.collections.list.queryOptions({sorting:MA,organizationId:e,pagination:r})))),i=V(fE(t.cms.entries.list.queryKey({organizationId:e}),r=>n.fetchQuery(t.cms.entries.list.queryOptions({sorting:MA,organizationId:e,pagination:r}))));return(0,Y.useMemo)(()=>({collections:r.data??[],entries:i.data??[],isLoading:r.isLoading||i.isLoading,isFetching:r.isFetching||i.isFetching}),[r.data,r.isFetching,r.isLoading,i.data,i.isFetching,i.isLoading])}function PA(e,t){let n=R(),r=fe(),i=V({...fE(n.localization.entryTranslations.list.queryKey({organizationId:e,language:t??void 0}),i=>r.fetchQuery(n.localization.entryTranslations.list.queryOptions({sorting:MA,organizationId:e,language:t??void 0,pagination:i}))),enabled:!!t});return(0,Y.useMemo)(()=>({items:i.data??[],isLoading:i.isLoading,isFetching:i.isFetching}),[i.data,i.isFetching,i.isLoading])}function FA(e,t){return`${e}:${t}`}function IA(e){let t=R(),n=md(),{collections:r,entries:i,isLoading:a}=NA(n),{items:o,isLoading:s}=PA(n,e),c=(0,Y.useMemo)(()=>r.map(e=>e.id),[r]),l=V(t.cms.collections.getWithFields.queryOptions(c,{enabled:e!==null&&c.length>0})),u=l.data,d=(0,Y.useMemo)(()=>{let e=new Map;for(let t of r){let n=(u?.find(e=>e.id===t.id)?.fields??[]).filter(kA),r=i.filter(e=>e.collectionId===t.id);for(let t of r)for(let r of n){let n=t.properties?.[r.propertyName];AA(n)&&e.set(FA(t.id,r.propertyName),n)}}return e},[r,u,i]);return{progress:(0,Y.useMemo)(()=>{if(e===null)return null;let t=d.size,n=o.filter(e=>{let t=FA(e.entryId,e.propertyName);return d.has(t)&&jA(d.get(t),e.value)}).length;return{languageCode:e,translated:n,total:t,percent:t===0?0:Math.round(n/t*100)}},[e,d,o]),isLoading:e!==null&&(a||s||c.length>0&&l.isLoading)}}async function LA(e,t,n){let r=(await uE(r=>e.list({organizationId:t,language:n,sorting:[{id:`createdAt`,desc:!0}],pagination:{pageIndex:r,pageSize:oE}}))).map(e=>e.id);for(let t of lE(r,200))await e.remove(t)}function RA(e){let t=e.trim();if(!t)return``;let n=t.split(`-`),r=n[0]?.toLowerCase()||``,i=n[1]?.toUpperCase();return i?`${r}-${i}`:r}function zA({children:e,onSave:t,existingLocales:n,editingLocale:r}){let i=R(),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(n),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(`picker`),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(``),{data:_}=V(i.localization.languages.list.queryOptions()),v=_||[],[y,b]=(0,Y.useState)(``),[x,S]=(0,Y.useState)(``),[C,w]=(0,Y.useState)(``),[T,E]=(0,Y.useState)(``),[D,O]=(0,Y.useState)(``),[k,A]=(0,Y.useState)(``),[j,M]=(0,Y.useState)(!1),N=(0,Y.useCallback)(e=>{b(e.languageCode),S(e.region||``),w(e.name),E(e.nativeName),O(e.fallbackLanguageCode||``),A(e.aiStyleDescription||``),M(e.isDefault||!1)},[]),P=(0,Y.useCallback)(e=>{o(e),e&&(c(n),r?(u(r.languageCode),f(`editor`),N(r)):(u(null),f(`picker`)))},[n,r,N]),F=()=>{b(``),S(``),w(``),E(``),O(``),A(``),M(!1)},I=()=>{u(null),f(`picker`),g(``),F()},L=e=>{let t={languageCode:RA(e.code),name:e.englishName,nativeName:e.nativeName,isDefault:s.length===0,order:s.length+1},n=[...s,t];c(n),u(t.languageCode),N(t),f(`editor`)},ee=v.filter(e=>!s.some(t=>t.languageCode===e.code)).filter(e=>e.englishName.toLowerCase().includes(h.toLowerCase())||e.nativeName.toLowerCase().includes(h.toLowerCase())||e.code.toLowerCase().includes(h.toLowerCase())),te=e=>{let t=s.find(t=>t.languageCode===e);t&&(u(e),N(t),f(`editor`))},ne=()=>{if(!l)return;let e=s.length===1,t=e?!0:j,n=s.map(e=>e.languageCode===l?{...e,languageCode:RA(y),name:C.trim()||y.trim(),nativeName:T.trim()||C.trim()||y.trim(),region:x.trim()||void 0,fallbackLanguageCode:D||void 0,aiStyleDescription:k.trim()||void 0,isDefault:t}:{...e,isDefault:t&&j?!1:e.isDefault});c(n),e&&!j&&M(!0)},re=e=>{let t=s.filter(t=>t.languageCode!==e);c(t),l===e&&(u(null),f(`picker`),F())},ie=e=>{m(e)},ae=(e,t)=>{if(e.preventDefault(),p===null||p===t)return;let n=[...s],r=n[p];r!==void 0&&(n.splice(p,1),n.splice(t,0,r),c(n),m(t))},oe=()=>{m(null)},z=()=>{let e=s;if(l&&d===`editor`){let t=s.length===1||j;e=s.map(e=>e.languageCode===l?{...e,languageCode:RA(y),name:C.trim()||y.trim(),nativeName:T.trim()||C.trim()||y.trim(),region:x.trim()||void 0,fallbackLanguageCode:D||void 0,aiStyleDescription:k.trim()||void 0,isDefault:t}:{...e,isDefault:t&&j?!1:e.isDefault})}!e.some(e=>e.isDefault)&&e.length>0&&(e=e.map((e,t)=>({...e,isDefault:t===0}))),t(e),se()},se=()=>{F(),u(null),f(`picker`),g(``),o(!1)},ce=s.find(e=>e.languageCode===l);return(0,X.jsxs)(ar,{open:a,onOpenChange:P,children:[(0,X.jsx)(vr,{render:t=>Y.cloneElement(e,t)}),(0,X.jsxs)(pr,{className:`flex h-auto max-h-[85vh] w-full max-w-[95vw] flex-col gap-0 p-0 sm:max-w-225`,"data-quick-help":`language-dialog`,children:[(0,X.jsx)(mr,{className:`sr-only`,children:Z(`views.locale-settings.title`)}),(0,X.jsx)(_r,{className:`sr-only`,children:Z(`views.locale-settings.description`)}),(0,X.jsx)(Hl,{guideId:`content-language-dialog`,iconOnly:!0,className:`absolute top-4 right-14 z-10`}),(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden`,children:[(0,X.jsxs)(`div`,{className:`flex w-64 shrink-0 flex-col border-r bg-muted/30`,"data-quick-help":`language-dialog-locales`,children:[(0,X.jsx)(`div`,{className:`shrink-0 border-b p-3`,children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`h2`,{children:Z(`views.locale-settings.languages`)}),(0,X.jsx)(U,{size:`icon`,variant:`ghost`,className:`size-6`,onClick:I,children:(0,X.jsx)(Hr,{className:`size-4`})})]})}),(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:[s.map((e,t)=>(0,X.jsxs)(`div`,{draggable:!0,onDragStart:()=>ie(t),onDragOver:e=>ae(e,t),onDragEnd:oe,onClick:()=>te(e.languageCode),className:`group mb-1 flex cursor-pointer items-center gap-2 rounded p-2 text-sm hover:bg-muted/50 ${l===e.languageCode?`bg-muted`:``}`,children:[(0,X.jsx)(Ya,{className:`size-4 shrink-0 cursor-grab active:cursor-grabbing`}),(0,X.jsx)(`div`,{className:`min-w-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`truncate`,children:e.nativeName||e.name||e.languageCode}),e.isDefault&&(0,X.jsx)(`span`,{className:`shrink-0 rounded bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:Z(`common.default`)})]})}),(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`size-6 shrink-0 opacity-0 group-hover:opacity-100`,onClick:t=>{t.stopPropagation(),re(e.languageCode)},children:(0,X.jsx)(so,{className:`size-3`})})]},e.languageCode)),s.length===0&&(0,X.jsx)(`div`,{className:`p-4 text-center text-sm text-muted-foreground`,children:Z(`views.locale-settings.no-languages`)})]})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[d===`picker`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`shrink-0 border-b p-6`,"data-quick-help":`language-picker`,children:[(0,X.jsx)(`h3`,{className:`mb-2`,children:Z(`views.locale-settings.add-language`)}),(0,X.jsx)(`p`,{className:`mb-4 text-sm text-muted-foreground`,children:Z(`views.locale-settings.add-language.description`)}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(eo,{className:`absolute top-1/2 left-3 size-4 -translate-y-1/2 text-muted-foreground`}),(0,X.jsx)(W,{placeholder:Z(`views.locale-settings.search`),value:h,onChange:e=>g(e.target.value),className:`pl-9`})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,X.jsxs)(`div`,{className:`grid gap-2`,children:[ee.map(e=>(0,X.jsxs)(`button`,{onClick:()=>L(e),className:`flex items-center justify-between rounded-lg border p-3 text-left transition-colors hover:bg-muted/50`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`div`,{className:`font-medium`,children:e.englishName}),(0,X.jsx)(`div`,{className:`text-sm text-muted-foreground`,children:e.nativeName})]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground uppercase`,children:e.code})]},e.code)),ee.length===0&&(0,X.jsx)(`p`,{className:`py-8 text-center text-muted-foreground`,children:Z(h?`views.locale-settings.no-results`:`views.locale-settings.all-added`)})]})})]}):(0,X.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-6 overflow-y-auto p-6`,"data-quick-help":`language-settings`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h3`,{className:`mb-1`,children:ce?.nativeName||ce?.name||Z(`views.locale-settings.edit-language`)}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`views.locale-settings.edit-language.description`)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($t,{htmlFor:`languageCode`,children:Z(`views.locale-settings.language-code`)}),(0,X.jsx)(W,{id:`languageCode`,placeholder:Z(`views.locale-settings.language-code.placeholder`),value:y,onChange:e=>b(e.target.value),onBlur:e=>{let t=RA(e.target.value);t!==y&&b(t),ne()}}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Z(`views.locale-settings.language-code.hint`)})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($t,{htmlFor:`region`,children:Z(`views.locale-settings.region`)}
116),(0,X.jsx)(W,{id:`region`,placeholder:Z(`views.locale-settings.region.placeholder`),value:x,onChange:e=>S(e.target.value),onBlur:ne})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($t,{htmlFor:`name`,children:Z(`views.locale-settings.display-name`)}),(0,X.jsx)(W,{id:`name`,placeholder:`English`,value:C,onChange:e=>w(e.target.value),onBlur:ne})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($t,{htmlFor:`nativeName`,children:Z(`views.locale-settings.native-name`)}),(0,X.jsx)(W,{id:`nativeName`,placeholder:`English`,value:T,onChange:e=>E(e.target.value),onBlur:ne})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($t,{htmlFor:`fallback`,children:Z(`views.locale-settings.fallback`)}),(0,X.jsxs)(Vt,{value:D||void 0,onValueChange:e=>{O(e||`en`),setTimeout(ne,0)},children:[(0,X.jsx)(Dn,{id:`fallback`,children:(0,X.jsx)(Mt,{})}),(0,X.jsx)(Dt,{children:s.filter(e=>e.languageCode!==l).map(e=>(0,X.jsxs)(yn,{value:e.languageCode,children:[e.nativeName||e.name,e.isDefault&&Z(`views.locale-settings.is-default-suffix`)]},e.languageCode))})]})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($t,{htmlFor:`aiStyleDescription`,children:Z(`views.locale-settings.ai-style`)}),(0,X.jsx)(bt,{id:`aiStyleDescription`,placeholder:Z(`views.locale-settings.ai-style.placeholder`),value:k,onChange:e=>A(e.target.value),onBlur:ne,rows:4})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between py-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,X.jsx)($t,{htmlFor:`isDefault`,children:Z(`views.locale-settings.set-as-default`)}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`views.locale-settings.set-as-default.description`)})]}),(0,X.jsx)(Cn,{id:`isDefault`,checked:j,onCheckedChange:e=>{M(e),setTimeout(ne,0)}})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between border-t p-4`,"data-quick-help":`language-dialog-save`,children:[(0,X.jsxs)(`div`,{className:`text-sm text-muted-foreground`,children:[s.length,` `,s.length===1?`language`:`languages`,` selected`]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(U,{variant:`outline`,onClick:se,children:Z(`common.cancel`)}),(0,X.jsx)(U,{onClick:z,disabled:s.length===0,children:Z(`common.save`)})]})]})]})]})]})]})}function BA(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.languageCode==`string`&&typeof t.name==`string`&&typeof t.nativeName==`string`&&typeof t.isDefault==`boolean`}function VA(e){if(!e||typeof e!=`object`)return[];let t=e.locales;return Array.isArray(t)?t.filter(BA):[]}function HA({onSelect:e}){let t=R(),n=ie(),r=fe(),{client:i,refetchSession:a,activeOrganization:o}=z(),{currentActiveLanguageCode:s,setCurrentActiveLanguageCode:c}=UE(),l=VA(o?.metadata),u=l.find(e=>e.languageCode===s),{progress:d,isLoading:f}=IA(u&&!u.isDefault?u.languageCode:null),p=e=>{c(e)},[m,h]=(0,Y.useState)(null),g=async e=>{if(o?.id)try{await i.organization.update({organizationId:o.id,data:{metadata:{locales:e}}}),a()}catch(e){console.error(`Error saving locales`,e)}},_=async e=>{if(!o)return;try{await LA({list:e=>n.localization.entryTranslations.list.query(e),remove:e=>n.localization.entryTranslations.remove.mutate(e)},o.id,e)}finally{r.invalidateQueries({queryKey:t.localization.entryTranslations.list.queryKey()})}let s=l.filter(t=>t.languageCode!==e);s.length!==0&&(await i.organization.update({organizationId:o.id,data:{metadata:{locales:s}}}),a())};return(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col md:w-64`,"data-quick-help":`localization-locales`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Na,{className:`size-4`}),(0,X.jsx)(`h2`,{className:`text-sm`,children:Z(`common.locales`)})]}),(0,X.jsx)(zA,{existingLocales:l,onSave:g,children:(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-8 p-0`,"data-quick-help":`localization-add-language`,children:(0,X.jsx)(Hr,{className:`size-5`})})})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:l?.map(t=>{let n=s===t.languageCode,r=n&&!t.isDefault;return(0,X.jsxs)(`div`,{className:q(`group mb-0.5 cursor-pointer rounded-lg px-3 py-2 transition-colors hover:bg-foreground
116/5`,n&&`bg-foreground/10`),onClick:()=>{p(t.languageCode),e?.()},children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-sm`,children:t.nativeName}),t.isDefault&&(0,X.jsx)(`span`,{className:`rounded bg-primary/10 px-1.5 py-0.5 text-xs text-primary`,children:Z(`common.default`)})]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t.isDefault?`${t.languageCode} · source`:!r||f?`${t.languageCode}`:`${t.languageCode} · ${d?.translated??0} of ${d?.total??0}`})]}),r&&(f?(0,X.jsx)(Uk,{className:`h-4 w-8 shrink-0`,"aria-hidden":`true`}):(0,X.jsxs)(`span`,{className:`shrink-0 text-xs font-medium text-muted-foreground tabular-nums`,children:[d?.percent??0,`%`]})),(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-8 p-0 md:opacity-0 md:group-hover:opacity-100`,...e,children:(0,X.jsx)(ma,{className:`size-4`})})}),(0,X.jsx)(Ue,{children:(0,X.jsx)(Ie,{align:`end`,children:(0,X.jsx)(st,{onClick:e=>{e.stopPropagation(),h(t)},className:`text-destructive focus:text-destructive`,children:Z(`common.delete`)})})})]})]}),r&&(f?(0,X.jsx)(Uk,{className:`mt-1.5 h-1 w-full`,"aria-hidden":`true`}):(0,X.jsx)(`div`,{className:`mt-1.5 h-1 w-full overflow-hidden rounded-full bg-muted`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${d?.percent??0}%`}})}))]},t.languageCode)})}),(0,X.jsx)(Hk,{open:m!==null,onOpenChange:e=>!e&&h(null),title:Z(`views.cms.delete.locale.title`),description:Z(`views.cms.delete.locale.de
116scription`).replace(`{{name}}`,m?.nativeName||m?.name||``),onConfirm:()=>m?_(m.languageCode):void 0})]})}function UA({labelCollections:e,labelTranslations:t,selectedLocaleCodes:n}){let r=new Map;for(let e of t){if(!n.includes(e.language))continue;let t=r.get(e.labelCollectionId)??new Map,i=t.get(e.key)??new Map;i.set(e.language,e),t.set(e.key,i),r.set(e.labelCollectionId,t)}let i={};for(let t of e){let e=r.get(t.id);if(!e||e.size===0)continue;let a={};for(let[t,r]of[...e.entries()].sort(([e],[t])=>e.localeCompare(t))){let e={};for(let t of n){let n=r.get(t);e[t]=n?{id:n.id,value:n.value,description:n.description??null,isActive:n.isActive,createdAt:n.createdAt?.toISOString(),updatedAt:n.updatedAt?.toISOString()}:{value:``,isActive:!0}}a[t]=e}i[t.name]={labelCollectionId:t.id,slug:t.slug,labels:a}}return i}function WA({open:e,onClose:t}){let n=R(),{activeOrganization:r}=z(),i=md(),a=r?.metadata?.locales??[],o=n.localization.entryTranslations.list.queryOptions({organizationId:i,sorting:[{id:`createdAt`,desc:!0}]},{enabled:e}),s=n.cms.collections.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:i},{enabled:e}),c=n.cms.entries.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:i},{enabled:e}),l=n.localization.labelCollections.list.queryOptions({organizationId:i,sorting:[{id:`createdAt`,desc:!0}]},{enabled:e}),u=n.localization.labelTranslations.list.queryOptions({organizationId:i,sorting:[{id:`createdAt`,desc:!0}]},{enabled:e}),[{data:d},{data:f},{data:p},{data:m},{data:h}]=ce({queries:[o,s,c,l,u]}),g=f?.items.map(e=>e.id)??[],{data:_}=V(n.cms.collections.getWithFields.queryOptions(g,{enabled:e&&g.length>0})),[v,y]=(0,Y.useState)(new Set(a?.map(e=>e.languageCode)||[])),b=(e,t)=>{let n=new Set(v);t?n.add(e):n.delete(e),y(n)},x=e=>{y(e?new Set(a?.map(e=>e.languageCode)||[]):new Set)},S=a?.filter(e=>v.has(e.languageCode))||[],C=()=>{if(!d||!f||!p||!_)return;let e={metadata:{exportedAt:new Date().toISOString(),exportedLocales:S.map(e=>e.languageCode),version:`2.1`}},n={};d?.items?.forEach(e=>{let t=e.entryId,r=e.propertyName,i=e.language;v.has(i)&&(n[t]||(n[t]={}),n[t][r]||(n[t][r]={}),n[t][r][i]={id:e.id,value:e.value,isActive:e.isActive,createdAt:e.createdAt?.toISOString(),updatedAt:e.updatedAt?.toISOString()})});let r={};f.items?.forEach(e=>{let t=(_?.find(t=>t.id===e.id)?.fields||[]).filter(kA),i=p.items?.filter(t=>t.collectionId===e.id)||[],a={};i.forEach(e=>{let r={},i=n[e.id]||{};if(t.forEach(t=>{let n=i[t.propertyName]||{},a={};S.forEach(r=>{let i=n[r.languageCode];if(i)a[r.languageCode]=i;else{let n;if(e.properties&&typeof e.properties==`object`){let i=e.properties[t.propertyName];i!==void 0&&r.languageCode===S[0]?.languageCode&&(n=i)}a[r.languageCode]={value:n===void 0?``:n,isActive:!0}}}),S.length>0&&(r[t.name]=a)}),Object.keys(r).length>0){let t=e.slug||e.name||e.id;a[t]={entryId:e.id,entrySlug:e.slug,entryName:e.name,fields:r}}}),Object.keys(a).length>0&&(r[e.name]={collectionId:e.id,items:a})}),Object.keys(r).length>0&&(e.collections=r);let i=UA({labelCollections:m?.items??[],labelTranslations:h?.items??[],selectedLocaleCodes:S.map(e=>e.languageCode)});Object.keys(i).length>0&&(e.labels=i);let a=JSON.stringify(e,null,2),o=new Blob([a],{type:`application/json`}),s=URL.createObjectURL(o),c=document.createElement(`a`);c.href=s,c.download=`localization.json`,document.body.appendChild(c),c.click(),document.body.removeChild(c),URL.revokeObjectURL(s),t()},w={};d?.items?.forEach(e=>{w[e.language]=(w[e.language]||0)+1});let T={};return h?.items?.forEach(e=>{T[e.language]=(T[e.language]||0)+1}),(0,X.jsx)(ar,{open:e,onOpenChange:t,children:(0,X.jsxs)(pr,{className:`sm:max-w-125`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:`Export Localization`}),(0,X.jsx)(_r,{children:`Export localized content for selected locales`})]}),(0,X.jsx)(`div`,{className:`space-y-6 py-4`,children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)($t,{children:`Select Locales to Export`}),(0,X.jsx)(U,{variant:`ghost`,size:`sm`,onClick:()=>x(v.size!==(a?.length||0)),className:`h-auto p-0 text-xs text-muted-foreground hover:text-foreground`,children:v.size===(a?.length||0)?`Deselect All`:`Select All`})]}),(0,X.jsx)(`div`,{className:`max-h-[200px] divide-y overflow-y-auto rounded-lg border`,children:a?.map(e=>{let t=w[e.languageCode]||0,n=T[e.languageCode]||0;return(0,X.jsxs)(`div`,{className:`flex items-center gap-3 p-3 transition-colors hover:bg-muted/50`,children:[(0,X.jsx)(Pd,{checked:v.has(e.languageCode),onCheckedChange:t=>b(e.languageCode,t),id:`locale-${e.languageCode}`}),(0,X.jsxs)(`label`,{htmlFor:`locale-${e.languageCode}`,className:`flex flex-1 cursor-pointer items-center justify-between`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:e.nativeName}),(0,X.jsxs)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:[`(`,e.languageCode,`)`]})]}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[t,` translations, `,n,` labels`]})]})]},e.languageCode)})})]})}),(0,X.jsxs)(lr,{children:[(0,X.jsx)(U,{variant:`outline`,onClick:t,children:`Cancel`}),(0,X.jsxs)(U,{onClick:C,children:[(0,X.jsx)(Wr,{className:`mr-2 size-4`}),`Export`]})]})]})})}function GA({existing:e,source:t,language:n,value:r,newId:i,now:a}
116){if(e)return r===e.value?{type:`noop`}:{type:`update`,id:e.id,value:r};if(r.trim()===``)return{type:`noop`};let o=a();return{type:`create`,translation:{id:i(),labelCollectionId:t.labelCollectionId,key:t.key,value:r,description:null,language:n,isActive:!0,createdAt:o,updatedAt:o}}}function KA(e,t){return`${e}:${t}`}var qA=(0,Y.createContext)(null);function JA({children:e}){let{currentActiveLanguageCode:t,setCurrentActiveLabelCollectionId:n}=UE(),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(!1),{activeOrganization:s,hasPermissions:c}=z(),l=R(),u=fe(),d=md(),f=c(d,`translateEntry`,`create`),m=c(d,`translateEntry`,`update`),h=c(d,`translateLabel`,`list-view`),g=c(d,`translateLabel`,`update`),{setValue:_}=p(),[v,y]=(0,Y.useState)(new Set),b=(0,Y.useMemo)(()=>s?.metadata?.locales??[],[s?.metadata]),x=b.find(e=>e.isDefault)||b[0],S=b.find(e=>e.languageCode===t)||x,C=S?.languageCode===x?.languageCode,w=l.localization.entryTranslations.list.queryKey(),{collections:T,entries:E,isLoading:D,isFetching:O}=NA(d),{items:k,isLoading:A,isFetching:j}=PA(d,t),M=k,N=(0,Y.useMemo)(()=>T.map(e=>({...e,entries:E.filter(t=>t.collectionId===e.id)})),[T,E]),P=l.localization.labelTranslations.list.queryKey(),{data:F,isLoading:I,isFetching:L}=V(l.localization.labelCollections.list.queryOptions({organizationId:d,sorting:[{id:`createdAt`,desc:!0}]},{enabled:h})),{data:ee,isLoading:te,isFetching:ne}=V({...fE(l.localization.labelTranslations.list.queryKey({organizationId:d,language:x?.languageCode}),e=>u.fetchQuery(l.localization.labelTranslations.list.queryOptions({organizationId:d,language:x?.languageCode,sorting:[{id:`createdAt`,desc:!0}],pagination:e}))),enabled:h&&!!x?.languageCode}),{data:re,isLoading:ie,isFetching:ae}=V({...fE(l.localization.labelTranslations.list.queryKey({organizationId:d,language:t||void 0}),e=>u.fetchQuery(l.localization.labelTranslations.list.queryOptions({organizationId:d,language:t||void 0,sorting:[{id:`createdAt`,desc:!0}],pagination:e}))),enabled:h&&!!t&&!C}),oe=D||A||h&&(I||te||!C&&ie),se=O||j||h&&(L||ne||!C&&ae),ce=(0,Y.useMemo)(()=>{let e=ee??[];return(F?.items??[]).map(t=>({id:t.id,name:t.name,slug:t.slug,labels:e.filter(e=>e.labelCollectionId===t.id).sort((e,t)=>e.key.localeCompare(t.key))}))},[F,ee]),le=(0,Y.useMemo)(()=>{let e=new Map;if(C)return e;for(let t of re??[])e.set(KA(t.labelCollectionId,t.key),t);return e},[C,re]),ue=B(l.localization.entryTranslations.create.mutationOptions({onSuccess(){u.invalidateQueries({queryKey:w})}})),de=B(l.localization.entryTranslations.update.mutationOptions({onSuccess(){u.invalidateQueries({queryKey:w})}})),pe=(0,Y.useCallback)((e,n,r)=>{if(!t)return;let i=M.find(t=>t.entryId===e&&t.propertyName===n),a=r;i?de.mutate([{id:i.id,value:a}]):ue.mutate([{id:crypto.randomUUID(),entryId:e,propertyName:n,value:a,language:t,isActive:!0,createdAt:new Date,updatedAt:new Date}])},[ue,t,M,de]),me=(0,Y.useCallback)(()=>u.invalidateQueries({queryKey:P}),[P,u]),he=B(l.localization.labelTranslations.create.mutationOptions({onSuccess:me,onError:()=>J.error(`Unable to save label translation`)})),ge=B(l.localization.labelTranslations.update.mutationOptions({onSuccess:me,onError:()=>J.error(`Unable to save label translation`)})),_e=(0,Y.useCallback)((e,n,r)=>{if(!t||C)return;let i=GA({existing:le.get(KA(e,n)),source:{labelCollectionId:e,key:n},language:t,value:r,newId:()=>crypto.randomUUID(),now:()=>new Date});i.type===`update`?ge.mutate([{id:i.id,value:i.value}]):i.type===`create`&&he.mutate([i.translation])},[he,t,C,le,ge]),ve=(0,Y.useCallback)(e=>{n(e),_(`cmsMode`,`labels`)},[_,n]),ye=(0,Y.useCallback)(e=>{y(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[y]),be=(0,Y.useMemo)(()=>({currentActiveLanguageCode:t,activeOrganization:s,locales:b,defaultLocale:x,currentLocale:S,isDefaultLocale:C,entryTranslations:M,collectionsWithEntries:N,labelCollectionsWithLabels:ce,labelTranslationsByIdentity:le,expandedCollections:v,toggleCollection:ye,exportLocalizationModalOpen:r,setExportLocalizationModalOpen:i,importLocalizationModalOpen:a,setImportLocalizationModalOpen:o,handleUpdateEntryTranslation:pe,handleUpdateLabelTranslation:_e,openLabelCollectionInLabelsTab:ve,canCreateEntry:f,canUpdateEntry:m,canViewLabel:h,canU
116pdateLabel:g,isLoading:oe,isFetching:se}),[s,f,m,g,h,N,t,S,x,M,v,r,pe,_e,a,C,se,oe,ce,le,b,ve,ye]);return(0,X.jsxs)(qA.Provider,{value:be,children:[e,(0,X.jsx)(WA,{open:r,onClose:()=>i(!1)}),(0,X.jsx)(jk,{open:a,onClose:()=>o(!1),title:`Import translations`,description:`Fill in entry and label translations from a Storyverse export archive. Collections and source labels are imported from the Content and Labels tabs.`,kinds:[`translations`],confirmLabel:`Import translations`})]})}function YA(){let e=(0,Y.useContext)(qA);if(!e)throw Error(`useLocalizationWorkspace must be used within LocalizationWorkspaceProvider`);return e}function XA({kind:e,slug:t,name:n}){let{currentLocale:r,isDefaultLocale:i,canCreateEntry:a}=YA(),[o,s]=(0,Y.useState)(!1),c=r?.languageCode;return i||!c||!a?null:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-6 shrink-0 p-0 transition-opacity md:opacity-0 md:group-hover:opacity-100`,"aria-label":`Import ${c} translations for ${n}`,onClick:e=>{e.stopPropagation(),s(!0)},children:(0,X.jsx)(ra,{className:`size-4`,"aria-hidden":`true`})}),(0,X.jsx)(jk,{open:o,onClose:()=>s(!1),title:`Import ${c} translations`,description:`Fill in ${c} translations for ${n} from a Storyverse export archive. Other collections and locales in the file are ignored.`,kinds:[`translations`],baseScope:e===`content`?{contentCollectionSlugs:[t],labelCollectionSlugs:[],languages:[c]}:{contentCollectionSlugs:[],labelCollectionSlugs:[t],languages:[c]},confirmLabel:`Import translations`})]})}XA.displayName=`AccordionImportButton`;function ZA(){let{control:e}=p(),{setExportLocalizationModalOpen:t,setImportLocalizationModalOpen:n,canCreateEntry:r,isFetching:i,isLoading:a}=YA();return(0,X.jsx)(`div`,{className:`shrink-0 border-b p-4`,"data-quick-help":`localization-tools`,children:(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between`,children:[(0,X.jsx)(h,{control:e,name:`search`,render:({field:e})=>(0,X.jsxs)(`div`,{className:`relative w-full sm:max-w-sm`,children:[(0,X.jsx)(K,{htmlFor:`localization-search`,className:`sr-only`,children:`Search localization items`}),(0,X.jsx)(W,{...e,id:`localization-search`,placeholder:`Search collections or items...`,className:`peer h-8 w-full pl-8 text-[13px]`,"aria-label":`Search localization items`}),(0,X.jsx)(eo,{className:`pointer-events-none absolute top-1/2 left-2.5 size-3.5 -translate-y-1/2 text-muted-foreground`,"aria-hidden":`true`})]})}),(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 lg:justify-end`,children:[i&&!a&&(0,X.jsx)(An,{className:`size-4`,"aria-label":Z(`common.loading`)}),(0,X.jsxs)(U,{variant:`outline`,size:`sm`,onClick:()=>t(!0),"aria-label":`Export localization data`,children:[(0,X.jsx)(Wr,{className:`mr-2 size-4`,"aria-hidden":`true`}),`Export`]}),r&&(0,X.jsxs)(U,{variant:`outline`,size:`sm`,onClick:()=>n(!0),"aria-label":`Import localization data`,children:[(0,X.jsx)(ra,{className:`mr-2 size-4`,"aria-hidden":`true`}),`Import`]})]})]})})}function QA({title:e,count:t}){return(0,X.jsxs)(`div`,{className:`sticky top-0 z-10 flex items-center gap-2 border-b bg-muted/60 px-6 py-2 backdrop-blur`,children:[(0,X.jsx)(`h2`,{className:`text-xs font-semibold tracking-wide text-muted-foreground uppercase`,children:e}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`(`,t,`)`]})]})}function $A({translatedCount:e,totalCount:t,hidden:n,countInLabel:r=!0}){if(n||t===0)return null;let i=e/t*100,a=r?`${e}/${t} `:``;return i===100?(0,X.jsxs)(fr,{className:`bg-green-500 text-xs text-white hover:bg-green-600`,children:[a,`Translated`]}):i>0?(0,X.jsxs)(fr,{variant:`outline`,className:`border-yellow-500/50 bg-yellow-500/10 text-xs text-yellow-700`,children:[a,`In Progress`]}):(0,X.jsxs)(fr,{variant:`outline`,className:`bg-muted/50 text-xs text-muted-foreground`,children:[a,`Not Started`]})}var ej=lt({textStyle:Ux.optional(),maxLength:We().optional(),textArea:be().optional(),localized:be().optional(),choices:Yt(H()).optional(),referenceCollection:H().optional()}).passthrough(),tj=[{value:`text`,label:`Text`},{value:`formatted-text`,label:`Formatted Text`},{value:`number`,label:`Number`},{value:`date`,label:`Date`},{value:`datetime`,label:`Datetime`},{value:`link`,label:`Link`},{value:`file`,label:`File`},{value:`image`,label:`Image`},{value:`video`,label:`Video`},{value:`group`,label:`Group`},{value:`iframe`,label:`IFrame`},{value:`template`,label:`View Template`},{value:`placement`,label:`View Placement`},{value:`layout-divider`,label:`Layout Divider`}],nj=new Map(tj.map(e=>[e.value,e.label]));function rj(e){return e?nj.get(e)??e:``}var ij=lt({id:H(),name:H().min(1,`Name is required`),propertyName:H().min(1,`Property name is required`),type:H(),required:be().default(!1),options:ej.default({}),order:We().default(0),helpText:H().nullable().optional()}),aj=lt({fields:Yt(ij)}),oj=[`text`,`formatted-text`,`link`],sj=[`formatted-text`];function cj(e){return tj.find(t=>t.value===e)?.label??e}function lj(e){return e==null?``:typeof e==`string`?e:String(e)}function uj(e,t){if(!oj.includes(e.type))return null;let n=lj(t).length,r=e.options?.maxLength;return r?`${n} / ${r}`:n===0?null:`${n} chars`}function dj({fields:e,entry:t,entryTranslations:n,defaultLocaleCode:r,currentLocaleCode:i,isDefaultLocale:a,onUp
116dateTranslation:o,readOnly:s=!1}){let c=e.filter(kA).filter(e=>AA(t.properties?.[e.propertyName]));if(c.length===0)return null;let l=e=>n.find(n=>n.entryId===t.id&&n.propertyName===e)?.value??``,u=e=>t.properties?.[e]??``;return(0,X.jsx)(`div`,{className:`space-y-4`,children:c.map(e=>{let n=u(e.propertyName),c=l(e.propertyName);return(0,X.jsxs)(`div`,{className:q(`grid gap-4 border-b border-border/40 pb-4 last:border-b-0 last:pb-0`,a?`md:grid-cols-[10rem_1fr]`:`md:grid-cols-[10rem_1fr_1fr]`),children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)($t,{className:`text-sm font-medium`,children:e.name}),e.required&&(0,X.jsx)(`span`,{className:`text-xs text-destructive`,children:`*`})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:cj(e.type)}),e.helpText&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:e.helpText})]}),(0,X.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,X.jsx)(fj,{locale:r,role:`Source`,caption:uj(e,n)}),(0,X.jsx)(pj,{field:e,value:n})]}),!a&&(0,X.jsxs)(`div`,{className:`min-w-0 space-y-1`,children:[(0,X.jsx)(fj,{locale:i,role:`Translation`,caption:uj(e,c),emphasis:!0}),(0,X.jsx)(mj,{field:e,entryId:t.id,value:c,onUpdate:o,readOnly:s})]})]},e.id)})})}function fj({locale:e,role:t,caption:n,emphasis:r}){return(0,X.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,X.jsxs)(`span`,{className:q(`text-xs font-medium uppercase`,r?`text-foreground`:`text-muted-foreground`),children:[e,` — `,t]}),n&&(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground tabular-nums`,children:n})]})}function pj({field:e,value:t}){let n=lj(t);return sj.includes(e.type)?(0,X.jsx)(bt,{value:n,readOnly:!0,tabIndex:-1,className:`pointer-events-none`,placeholder:`Not set`,rows:6,"aria-label":`${e.name} source`}):(0,X.jsx)(W,{value:n,readOnly:!0,tabIndex:-1,className:`pointer-events-none`,placeholder:`Not set`,"aria-label":`${e.name} source`})}function mj({field:e,entryId:t,value:n,onUpdate:r,readOnly:i}){let a=lj(n),o=n=>{i||n===a||r(t,e.propertyName,n)};return sj.includes(e.type)?(0,X.jsx)(bt,{defaultValue:a,readOnly:i,rows:6,onBlur:e=>o(e.target.value),"aria-label":`${e.name} translation`}):(0,X.jsx)(W,{defaultValue:a,readOnly:i,onBlur:e=>o(e.target.value),"aria-label":`${e.name} translation`})}function hj({collection:e}){let{entryTranslations:t,defaultLocale:n,currentLocale:r,isDefaultLocale:i,expandedCollections:a,toggleCollection:o,handleUpdateEntryTranslation:s,canUpdateEntry:c}=YA(),l=n?.languageCode||`en`,u=r?.languageCode||``,d=!c,f=a.has(e.id),p=t=>{t!==a.has(e.id)&&o(e.id)},m=R(),{data:h,isLoading:g}=V(m.cms.collections.getWithFields.queryOptions([e.id],{enabled:!!e.id})),_=h?.[0]?.fields||[],v=t.filter(t=>e.entries.some(e=>e.id===t.entryId)),{translatedCount:y,totalCount:b}=(()=>{let t=0,n=0;return e.entries.forEach(e=>{_.filter(kA).forEach(r=>{let i=e.properties?.[r.propertyName];AA(i)&&(n++,jA(i,v.find(t=>t.entryId===e.id&&t.propertyName===r.propertyName)?.value)&&t++)})}),{translatedCount:t,totalCount:n}})();return(0,X.jsxs)(_n,{open:f,onOpenChange:p,children:[(0,X.jsxs)(`div`,{className:`group flex items-center pr-4 transition-colors hover:bg-muted/30`,children:[(0,X.jsxs)(At,{className:`flex min-w-0 flex-1 items-center gap-3 px-6 py-3 text-left`,"aria-label":`${f?`Collapse`:`Expand`} ${e.name} collection`,children:[f?(0,X.jsx)(Ka,{className:`size-4 shrink-0 text-muted-foreground`}):(0,X.jsx)(Er,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted`,children:(0,X.jsx)(Pi,{className:`size-4 text-muted-foreground`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium`,children:e.name}),(0,X.jsxs)(`div`,{className:`truncate text-xs text-muted-foreground`,children:[e.entries.length===0?Z(`views.localization.collection.no-items`):`${e.entries.length} item${e.entries.length===1?``:`s`}`,e.updatedAt?` · updated ${Ki(e.updatedAt,{addSuffix:!0})}`:``]})]}),(0,X.jsx)(`div`,{className:`flex shrink-0 items-center gap-3`,children:g&&!i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Uk,{className:`hidden h-1 w-24 sm:block`,"aria-hidden":`true`}),(0,X.jsx)(Uk,{className:`h-5 w-16 rounded-full`,"aria-hidden":`true`})]}):(0,X.jsxs)(X.Fragment,{children:[!i&&b>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`hidden h-1 w-24 overflow-hidden rounded-full bg-muted sm:block`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${Math.round(y/b*100)}%`}})}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[y,`/`,b]})]}),!i&&b===0?(0,X.jsx)(fr,{variant:`outline`,className:`bg-muted/50 text-xs text-muted-foreground`,children:Z(`views.localization.collection.empty-badge`)}):(0,X.jsx)($A,{translatedCount:y,totalCount:b,hidden:i,countInLabel:!1})]})})]}),(0,X.jsx)(XA,{kind:`content`,slug:e.slug,name:e.name})]}),(0,X.jsx)(Tn,{children:(0,X.jsx)(`div`,{className:`bg-muted/10`,children:g?(0,X.jsx)(`div`,{className:`space-y-3 px-6 py-4`,role:`status`,"aria-label":Z(`common.loading`),children:Array.from({length:3},(e,t)=>(0,X.jsxs)(`div`,{className:`space-y-2`,"aria-hidden":`true`,children:[(0,X.jsx)(Uk,{className:`h-4 w-32`}),(0,X.jsx)(Uk,{className:`h-16 w-full`})]},t))}):(0,X.jsxs)(X.Fragment,{children:[e.entries.map(e=>
116{let t=e.slug||e.name||e.id,n=v.filter(t=>t.entryId===e.id),r=_.filter(kA).filter(t=>AA(e.properties?.[t.propertyName]));if(r.length===0)return null;let a=r.filter(t=>n.find(n=>n.propertyName===t.propertyName&&jA(e.properties?.[t.propertyName],n.value))).length,o=r.length;return(0,X.jsxs)(`div`,{className:`border-b border-border/50`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border/30 bg-muted/20 px-6 py-2`,children:[(0,X.jsx)(`span`,{className:`truncate rounded bg-muted px-2 py-1 font-mono text-xs`,children:t}),(0,X.jsx)($A,{translatedCount:a,totalCount:o,hidden:i,countInLabel:!1})]}),(0,X.jsx)(`div`,{className:`px-6 py-4`,children:(0,X.jsx)(dj,{fields:_,entry:e,entryTranslations:n,defaultLocaleCode:l,currentLocaleCode:u,isDefaultLocale:i,onUpdateTranslation:s,readOnly:d})})]},e.id)}),e.entries.length===0&&(0,X.jsx)(`div`,{className:`px-6 py-4 text-sm text-muted-foreground`,children:Z(`views.localization.collection.no-entries`)})]})})})]})}var gj=lt({search:H()}),_j={search:``};function vj(e){let t=e.filter(e=>e.sourceValue.trim()!==``);return{translatedCount:t.filter(e=>jA(e.sourceValue,e.translationValue)).length,totalCount:t.length}}function yj({labelCollectionId:e,labels:t,translationByIdentity:n,identityOf:r,defaultLocaleCode:i,currentLocaleCode:a,isDefaultLocale:o,readOnly:s,onUpdate:c}){return t.length===0?(0,X.jsx)(`div`,{className:`px-6 py-4 text-sm text-muted-foreground`,children:Z(`views.localization.labels.no-labels`)}):(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full table-fixed`,children:[(0,X.jsx)(`thead`,{className:`bg-muted/30`,children:(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{className:`w-1/3 py-3 pr-3 pl-6 text-left text-xs font-medium text-muted-foreground`,children:Z(`common.key`)}),(0,X.jsxs)(`th`,{className:q(`p-3 text-left text-xs font-medium text-muted-foreground`,!o&&`w-1/4`),children:[`Source (`,i.toUpperCase(),`)`]}),!o&&(0,X.jsxs)(`th`,{className:`p-3 text-left text-xs font-medium text-muted-foreground`,children:[`Value (`,a.toUpperCase(),`)`]})]})}),(0,X.jsx)(`tbody`,{children:t.map(t=>{let i=n.get(r(t.key));return(0,X.jsxs)(`tr`,{className:`border-b border-border/50 transition-colors last:border-b-0 hover:bg-muted/20`,children:[(0,X.jsxs)(`td`,{className:`py-3 pr-3 pl-6 align-top wrap-break-word`,children:[(0,X.jsx)(`div`,{className:`font-mono text-sm font-medium`,children:t.key}),t.description&&(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:t.description})]}),(0,X.jsx)(`td`,{className:`p-3 align-top text-sm wrap-break-word text-muted-foreground`,children:t.value||(0,X.jsx)(`span`,{className:`italic`,children:Z(`views.localization.labels.no-source-value`)})}),!o&&(0,X.jsx)(`td`,{className:`p-3 align-top`,children:(0,X.jsx)(bt,{rows:1,className:`min-h-8`,defaultValue:i?.value??``,placeholder:t.value,readOnly:s,onMouseDown:e=>uA(e,s),onBlur:n=>{s||c(e,t.key,n.target.value)},"aria-label":`${a} translation for ${t.key}`},`${r(t.key)}:${a}`)})]},t.id)})})]})})}function bj({collection:e}){let{labelTranslationsByIdentity:t,defaultLocale:n,currentLocale:r,isDefaultLocale:i,expandedCollections:a,toggleCollection:o,handleUpdateLabelTranslation:s,canUpdateLabel:c}=YA(),l=n?.languageCode||`en`,u=r?.languageCode||``,d=a.has(e.id),f=t=>KA(e.id,t),p=e.labels.length,m=p===0?`No keys yet`:`${p} ${p===1?`key`:`keys`}`,{translatedCount:h,totalCount:g}=vj(e.labels.map(e=>({sourceValue:e.value,translationValue:t.get(f(e.key))?.value})));return(0,X.jsxs)(_n,{open:d,onOpenChange:t=>{t!==d&&o(e.id)},children:[(0,X.jsxs)(`div`,{className:`group flex items-center pr-4 transition-colors hover:bg-muted/30`,children:[(0,X.jsxs)(At,{className:`flex min-w-0 flex-1 items-center gap-3 px-6 py-3 text-left`,"aria-label":`${d?`Collapse`:`Expand`} ${e.name} label collection`,children:[d?(0,X.jsx)(Ka,{className:`size-4 shrink-0 text-muted-foreground`}):(0,X.jsx)(Er,{className:`size-4 shrink-0 text-muted-foreground`}),(0,X.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted`,children:(0,X.jsx)(Da,{
116className:`size-4 text-muted-foreground`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate font-medium`,children:e.name}),(0,X.jsx)(`div`,{className:`truncate text-xs text-muted-foreground`,children:m})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[!i&&g>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`hidden h-1 w-24 overflow-hidden rounded-full bg-muted sm:block`,children:(0,X.jsx)(`div`,{className:`h-full rounded-full bg-primary transition-all`,style:{width:`${Math.round(h/g*100)}%`}})}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground tabular-nums`,children:[h,`/`,g]})]}),(0,X.jsx)($A,{translatedCount:h,totalCount:g,hidden:i,countInLabel:!1})]})]}),(0,X.jsx)(XA,{kind:`labels`,slug:e.slug,name:e.name})]}),(0,X.jsx)(Tn,{children:(0,X.jsxs)(`div`,{className:`bg-muted/10`,children:[i&&(0,X.jsxs)(`p`,{className:`border-b border-border/30 px-6 py-2 text-xs text-muted-foreground`,children:[l.toUpperCase(),` is the source language. Edit these values in the Labels tab, or pick another locale to translate them.`]}),(0,X.jsx)(yj,{labelCollectionId:e.id,labels:e.labels,translationByIdentity:t,identityOf:f,defaultLocaleCode:l,currentLocaleCode:u,isDefaultLocale:i,readOnly:!c,onUpdate:s})]})})]})}function xj(e,t){return e.name?.toLowerCase().includes(t)===!0||e.slug?.toLowerCase().includes(t)===!0}function Sj(e,t){return e.key.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)}function Cj(){let e=l({resolver:pn(gj),defaultValues:_j,mode:`onChange`}),t=y({control:e.control,name:`search`}),n=YA(),r=(0,Y.useMemo)(()=>{let e=t?.trim().toLowerCase();return e?n.collectionsWithEntries.flatMap(t=>{if(t.name.toLowerCase().includes(e))return[t];let n=t.entries.filter(t=>xj(t,e));return n.length>0?[{...t,entries:n}]:[]}):n.collectionsWithEntries},[n.collectionsWithEntries,t]),i=(0,Y.useMemo)(()=>{if(!n.canViewLabel)return[];let e=t?.trim().toLowerCase();return e?n.labelCollectionsWithLabels.flatMap(t=>{if(t.name.toLowerCase().includes(e))return[t];let n=t.labels.filter(t=>Sj(t,e));return n.length>0?[{...t,labels:n}]:[]}):n.labelCollectionsWithLabels},[n.canViewLabel,n.labelCollectionsWithLabels,t]),a=r.length>0,o=i.length>0,s=a||o;return(0,X.jsx)(_,{...e,children:(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col overflow-hidden bg-background`,children:[(0,X.jsx)(ZA,{}),(0,X.jsx)(`div`,{className:`flex-1 overflow-auto [overflow-anchor:none]`,"aria-busy":n.isLoading||n.isFetching,children:n.isLoading?(0,X.jsx)(Kk,{}):s?(0,X.jsxs)(X.Fragment,{children:[a&&(0,X.jsxs)(`section`,{"data-quick-help":`localization-content-translations`,children:[(0,X.jsx)(QA,{title:`Collections`,count:r.length}),(0,X.jsx)(`div`,{className:`divide-y`,children:r.map(e=>(0,X.jsx)(hj,{collection:e},e.id))})]}),o&&(0,X.jsxs)(`section`,{"data-quick-help":`localization-label-translations`,children:[(0,X.jsx)(QA,{title:`Labels`,count:i.length}),(0,X.jsx)(`div`,{className:`divide-y`,children:i.map(e=>(0,X.jsx)(bj,{collection:e},e.id))})]})]}):(0,X.jsx)(`div`,{className:`p-8 text-center text-muted-foreground`,children:t?`No items found matching your search`:`No localization items found. Add entries to a collection to translate them.`})},n.currentActiveLanguageCode??``)]})})}function wj(){return(0,X.jsx)(JA,{children:(0,X.jsx)(Cj,{})})}function Tj({control:e,selectedIndex:t}){let n=`fields.${t}`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(h,{control:e,name:`${n}.name`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:`Name`}),(0,X.jsx)(W,{...e,placeholder:`Field name`,className:`border-2 focus-visible:border-primary`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:e,name:`${n}.propertyName`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:`Property Name`}),(0,X.jsx)(W,{...e,placeholder:`property_name`,className:`border-2 focus-visible:border-primary`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:e,name:`${n}.helpText`,render:({field:e,fieldState:t})=>
116(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:`Description`}),(0,X.jsx)(bt,{...e,value:e.value??``,placeholder:`Optional field description`,rows:3,className:`resize-none`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:e,name:`${n}.required`,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Required`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(U,{type:`button`,variant:e.value?`secondary`:`outline`,size:`sm`,className:`flex-1`,onClick:()=>e.onChange(!0),children:`Yes`}),(0,X.jsx)(U,{type:`button`,variant:e.value?`outline`:`secondary`,size:`sm`,className:`flex-1`,onClick:()=>e.onChange(!1),children:`No`})]})]})}),(0,X.jsx)(h,{control:e,name:`${n}.type`,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Field Type`}),(0,X.jsxs)(Vt,{value:e.value,onValueChange:e.onChange,children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{children:rj(e.value)})}),(0,X.jsx)(Dt,{children:tj.map(e=>(0,X.jsx)(yn,{value:e.value,children:e.label},e.value))})]})]})})]})}function Ej({canUpdate:e,isSaving:t,getFieldName:n,onDeleteField:r,onCancel:i,onSave:a}){let[o,s]=(0,Y.useState)(null);return(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-t p-4`,"data-quick-help":`field-schema-save`,children:[e?(0,X.jsx)(U,{variant:`destructive`,size:`sm`,onClick:()=>s(n()),disabled:t,children:`Delete Field`}):(0,X.jsx)(`span`,{}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(U,{variant:`outline`,type:`button`,onClick:i,children:`Cancel`}),e&&(0,X.jsx)(U,{type:`button`,onClick:a,disabled:t,children:t?`Saving...`:`Save Schema`})]}),(0,X.jsx)(Hk,{open:o!==null,onOpenChange:e=>!e&&s(null),title:Z(`views.cms.delete.field.title`),description:Z(`views.cms.delete.field.description`).replace(`{{name}}`,o??``),onConfirm:r})]})}function Dj({control:e,selectedIndex:t,watchedType:n,collections:r}){let i=`fields.${t}.options`;return(0,X.jsxs)(X.Fragment,{children:[n===`option`&&(0,X.jsx)(h,{control:e,name:i,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Options (comma-separated)`}),(0,X.jsx)(W,{value:e.value?.choices?.join(`, `)??``,onChange:t=>e.onChange({...e.value,choices:t.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)}),placeholder:`Option 1, Option 2, Option 3`})]})}),n===`group`&&(0,X.jsx)(h,{control:e,name:i,render:({field:e})=>(0,X.jsx)(Oj,{choices:e.value?.choices??[],onChange:t=>e.onChange({...e.value,choices:t})})}),(n===`reference`||n===`multi-reference`)&&(0,X.jsx)(h,{control:e,name:i,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Reference Collection`}),(0,X.jsxs)(Vt,{value:e.value?.referenceCollection??``,onValueChange:t=>e.onChange({...e.value,referenceCollection:t}),children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{})}),(0,X.jsx)(Dt,{children:r.map(e=>(0,X.jsx)(yn,{value:e.id,children:e.name},e.id))})]})]})})]})}function Oj({choices:e,onChange:t}){let[n,r]=(0,Y.useState)(``),i=()=>{let i=n.trim();i&&!e.includes(i)&&(t([...e,i]),r(``))},a=n=>{t(e.filter(e=>e!==n))};return(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Groups`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(W,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),i())},placeholder:`Add a group, e.g. history`}),(0,X.jsxs)(U,{type:`button`,variant:`outline`,onClick:i,disabled:!n.trim(),children:[(0,X.jsx)(Hr,{className:`mr-2 size-4`}),`Add`]})]}),e.length>0&&(0,X.jsx)(`ul`,{className:`mt-2 space-y-1`,children:e.map(e=>(0,X.jsxs)(`li`,{className:`flex items-center justify-between rounded-md border px-3 py-1.5 text-sm`,children:[(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,className:`size-6`,"aria-label":`Remove group ${e}`,onClick:()=>a(e),children:(0,X.jsx)(so,{className:`size-4`})})]},e))})]})}Oj.displayName=`GroupChoicesEditor`;function kj({control:e,selectedIndex:t,watchedType:n}){let r=`fields.${t}.options`;return(0,X.jsxs)(X.Fragment,{children:[n===`text`&&(0,X.jsx)(h,{control:e,name:r,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Text appearance`}),(0,X.jsxs)(Vt,{value:e.value?.textStyle??`normal`,onValueChange:t=>e.onChange({...e.value,textStyle:t}),children:[(0,X.jsx)(Dn,{children:(0,X.jsx)(Mt,{children:Gx(e.value?.textStyle)})}),(0,X.jsx)(Dt,{children:Kx.map(e=>(0,X.jsx)(yn,{value:e.value,children:e.label},e.value))})]})]})}),(n===`text`||n===`formatted-text`)&&(0,X.jsx)(h,{control:e,name:r,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Max Length`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(W,{type:`number`,value:e.value?.maxLength??``,onChange:t=>e.onChange({...e.value,maxLength:parseInt(t.target.value)||void 0}),placeholder:`No limit`}),(0,X.jsx)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>e.onChange({...e.value,maxLength:void 0}),children:`Clear`})]})]})}),n===`formatted-text`&&(0,X.jsx)(h,{control:e,name:r,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Text Area`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(U,{type:`button`,variant:e.value?.textArea?`secondary`:`outline`,size:`sm`,className:`flex-1`,onClick:()=>e.onChange({...e.value,textArea:!0}
116),children:`Yes`}),(0,X.jsx)(U,{type:`button`,variant:e.value?.textArea?`outline`:`secondary`,size:`sm`,className:`flex-1`,onClick:()=>e.onChange({...e.value,textArea:!1}),children:`No`})]})]})}),(0,X.jsx)(h,{control:e,name:r,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:`Localization`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(U,{type:`button`,variant:e.value?.localized===!1?`outline`:`secondary`,size:`sm`,className:`flex-1`,onClick:()=>e.onChange({...e.value,localized:!0}),children:`On`}),(0,X.jsx)(U,{type:`button`,variant:e.value?.localized===!1?`secondary`:`outline`,size:`sm`,className:`flex-1`,onClick:()=>e.onChange({...e.value,localized:!1}),children:`Off`})]})]})})]})}function Aj({fields:e,selectedIndex:t,form:n,watchedType:r,collections:i,canUpdate:a,isSaving:o,onAddField:s,onRemoveField:c,onCancel:l,onSave:u}){if(!(e.length>0&&e[t]))return(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-quick-help":`field-schema-settings`,children:(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-4 text-muted-foreground`,children:[(0,X.jsx)(`p`,{children:`No fields yet`}),(0,X.jsxs)(U,{variant:`outline`,size:`sm`,onClick:s,children:[(0,X.jsx)(Hr,{className:`mr-2 size-4`}),`Add your first field`]})]})});let d=e[t];return(0,X.jsx)(`div`,{className:`flex min-h-0 flex-1 flex-col`,"data-quick-help":`field-schema-settings`,children:(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-6`,children:(0,X.jsxs)(`div`,{className:`max-w-xl space-y-6`,children:[(0,X.jsx)(Tj,{control:n.control,selectedIndex:t}),(0,X.jsx)(kj,{control:n.control,selectedIndex:t,watchedType:r}),(0,X.jsx)(Dj,{control:n.control,selectedIndex:t,watchedType:r,collections:i})]})}),(0,X.jsx)(Ej,{canUpdate:a,isSaving:o,getFieldName:()=>n.getValues(`fields.${t}.name`),onDeleteField:()=>c(t),onCancel:l,onSave:u})]},d.id)})}function jj(e){let t=`size-4`;switch(e){case`text`:return(0,X.jsx)(Ai,{className:t});case`formatted-text`:return(0,X.jsx)(Pi,{className:t});case`number`:return(0,X.jsx)(Wi,{className:t});case`date`:return(0,X.jsx)(da,{className:t});case`toggle`:return(0,X.jsx)(qa,{className:t});case`color`:return(0,X.jsx)(ha,{className:t});case`link`:return(0,X.jsx)(Ei,{className:t});case`option`:return(0,X.jsx)(ei,{className:t});case`image`:return(0,X.jsx)(Ri,{className:t});case`gallery`:return(0,X.jsx)(Xi,{className:t});case`file`:return(0,X.jsx)(oa,{className:t});case`video`:return(0,X.jsx)(Si,{className:t});case`group`:return(0,X.jsx)(Ua,{className:t});case`iframe`:return(0,X.jsx)(Fi,{className:t});case`template`:return(0,X.jsx)(Dr,{className:t});case`placement`:return(0,X.jsx)(Ar,{className:t});default:return(0,X.jsx)(Ai,{className:t})}}function Mj({index:e,selectedIndex:t,onSelect:n,form:r}){let i=r.watch(`fields.${e}.name`),a=r.watch(`fields.${e}.type`);return(0,X.jsxs)(`div`,{className:`group mb-1 flex cursor-pointer items-center gap-2 rounded-md p-2 hover:bg-muted/50 ${t===e?`bg-muted`:``}`,onClick:n,children:[(0,X.jsx)(`div`,{className:`flex size-6 shrink-0 items-center justify-center rounded bg-primary/10 text-primary`,children:jj(a)}),(0,X.jsx)(`span`,{className:`flex-1 truncate text-sm`,children:i}),(0,X.jsx)(Ya,{className:`size-4 text-muted-foreground opacity-0 group-hover:opacity-100`})]})}function Nj({collectionName:e,fields:t,selectedIndex:n,setSelectedIndex:r,form:i,move:a,onAddField:o}){return(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 w-64 flex-col border-r bg-muted/20`,"data-quick-help":`field-schema-list`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b p-4`,children:[(0,X.jsxs)(`h2`,{className:`min-w-0 truncate text-sm`,children:[e,` Fields`]}),(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-8 shrink-0 p-0`,onClick:o,"data-quick-help":`field-schema-add`,"aria-label":`Add collection field`,children:(0,X.jsx)(Hr,{className:`size-4`})})]}),(0,X.jsx)(`div`,{className:`h-full min-h-0 flex-1 overflow-y-auto p-2`,children:t.length>
1160&&(0,X.jsx)(mn,{value:t,getItemValue:e=>e.id,onMove:({activeIndex:e,overIndex:t})=>{e!==t&&a(e,t)},children:(0,X.jsx)(un,{className:`space-y-1`,children:t.map((e,t)=>(0,X.jsx)(Nt,{value:e.id,children:(0,X.jsx)(Mj,{index:t,selectedIndex:n,onSelect:()=>r(t),form:i})},e.id))})})})]})}function Pj({collectionId:e,collections:t,open:n,handleOpenChange:r}){let i=R(),{hasPermissions:a}=z(),o=a(md(),`cms`,`update`),{data:s}=V(i.cms.collections.getWithFields.queryOptions([e])),c=fe(),u=B(i.cms.collections.update.mutationOptions()),[d,f]=(0,Y.useState)(0),p=l({resolver:pn(aj),defaultValues:{fields:[]}}),{fields:m,append:h,remove:g,move:b}=v({control:p.control,name:`fields`});(0,Y.useEffect)(function(){n&&s?.[0]?.fields&&p.reset({fields:s[0].fields.map(e=>({id:e.id,name:e.name,propertyName:e.propertyName,type:e.type,required:e.required??!1,options:e.options??{},order:e.order??0,helpText:e.helpText??``}))})},[n,s,p]);let x=()=>{h({id:xr(),name:`New Field ${m.length+1}`,propertyName:`new_field_${m.length+1}`,type:`text`,required:!1,options:{},order:m.length,helpText:``}),f(m.length)},S=e=>{g(e),d>=m.length-1&&f(Math.max(0,m.length-2))},C=async()=>{let e=p.getValues(),t=e.fields.map(e=>e.propertyName),n=t.filter((e,n)=>t.indexOf(e)!==n);if(n.length>0){J.error(`Duplicate variable names: ${[...new Set(n)].join(`, `)}`);let t=e.fields.findIndex(e=>n.includes(e.propertyName));t!==-1&&(p.setError(`fields.${t}.propertyName`,{type:`manual`,message:Z(`views.field-schema.duplicate-variable`)}),f(t));return}if(s?.[0]){try{await u.mutateAsync([{id:s[0].id,updatedAt:new Date(Date.now()),fields:e.fields.map((e,t)=>({id:e.id,name:e.name,propertyName:e.propertyName,type:e.type,required:e.required,options:e.options,order:t,helpText:e.helpText}))}]),J.success(Z(`views.field-schema.update.success`)),r(!1)}catch(e){console.error(`Failed to update fields`,e),J.error(Z(`views.field-schema.update.error`))}c.invalidateQueries()}},w=y({control:p.control,name:`fields.${d}.type`});if(!e)return null;let T=s&&s[0]?s[0].name:``;return(0,X.jsx)(ar,{open:n,onOpenChange:r,children:(0,X.jsx)(_,{...p,children:(0,X.jsxs)(pr,{className:`z-50 h-[85vh] min-h-0 max-w-4xl! gap-0 overflow-hidden p-0 sm:max-w-4xl!`,"data-quick-help":`field-schema-dialog`,children:[(0,X.jsxs)(mr,{className:`sr-only`,children:[`Edit Fields - `,T]}),(0,X.jsx)(_r,{className:`sr-only`,children:`Configure the fields for this collection. Add, remove, and reorder fields.`}),(0,X.jsx)(Hl,{guideId:`content-fields-dialog`,iconOnly:!0,className:`absolute top-4 right-14 z-10`}),(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 overflow-hidden`,children:[(0,X.jsx)(Nj,{collectionName:T,fields:m,selectedIndex:d,setSelectedIndex:f,form:p,move:b,onAddField:x}),(0,X.jsx)(Aj,{fields:m,selectedIndex:d,form:p,watchedType:w,collections:t,canUpdate:o,isSaving:u.isPending,onAddField:x,onRemoveField:S,onCancel:()=>r(!1),onSave:C})]})]})})})}function Fj({collectionName:e,canRename:t,canDuplicate:n,canEditFields:r,canDelete:i,onRename:a,onDuplicate:o,onEditFields:s,onDelete:c}){let[l,u]=(0,Y.useState)(!1),d=[...t?[{id:`rename`,label:`Rename`,icon:va,shortcutKey:`R`,onSelect:a}]:[],...n?[{id:`duplicate`,label:`Duplicate`,icon:pi,shortcutKey:`D`,onSelect:o}]:[],...r?[{id:`edit-fields`,label:`Edit Fields`,icon:wa,shortcutKey:`F`,onSelect:s}]:[]];return d.length===0&&!i?null:(0,X.jsxs)(nt,{open:l,onOpenChange:u,children:[(0,X.jsx)(Pe,{nativeButton:!0,render:t=>(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-6 p-0 transition-opacity md:opacity-0 md:group-hover:opacity-100`,"aria-label":`Collection options for ${e}`,"data-quick-help":`content-collection-actions`,...t,children:(0,X.jsx)(kr,{className:`size-4`,"aria-hidden":`true`})})}),(0,X.jsxs)(Ie,{align:`end`,className:`w-56`,onKeyDown:e=>{if(e.metaKey||e.ctrlKey||e.altKey)return;let t=d.find(t=>t.shortcutKey?.toLowerCase()===e.key.toLowerCase());t&&(e.preventDefault(),e.stopPropagation(),u(!1),t.onSelect())},children:[d.length>0&&(0,X.jsxs)(Ue,{children:[(0,X.jsx)(On,{className:`text-[10px] font-medium tracking-widest uppercase`,children:`Manage`}),d.map(({id:e,label:t,icon:n,shortcutKey:r,onSelect:i})=>(0,X.jsxs)(st,{"aria-keyshortcuts":r,onClick:i,children:[(0,X.jsx)(n,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`flex-1`,children:t}),r&&(0,X.jsx)(gt,{className:`font-mono`,children:r})]},e))]}),i&&(0,X.jsxs)(X.Fragment,{children:[d.length>0&&(0,X.jsx)(xe,{}),(0,X.jsxs)(st,{variant:`destructive`,onClick:c,children:[(0,X.jsx)(Qi,{"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`flex-1`,children:`Delete collection`})]})]})]})]})}Fj.displayName=`CollectionActionsMenu`;var Ij=lt({name:H().min(1)}),Lj=1e3,Rj=({editingId:e,setEditingId:t,collection:n,inputRef:r})=>{let i=l({resolver:pn(Ij),defaultValues:{name:n.name}}),a=R(),o=ie(),s={organizationId:md(),collectionId:n.id,sorting:[{id:`createdAt`,desc:!0}],pagination:{pageIndex:0,pageSize:Lj},columnFilters:[],globalFilter:``},{data:c,isLoading:u}=V({queryKey:[...a.cms.entries.list.queryKey(s),`sidebar-count`],queryFn:async()=>{let e=0,t=0;for(;;){let n=await o.cms.entries.list.query({...s,pagination:{pageIndex:t,pageSize:Lj}});if(e+=n.items.length,n.items.length<Lj)return e;t+=1}}}),d=fe(),f=a.cms.collections.list.queryKey(),p=a.cms.collections.update.mutationOptions({onSuccess(){d.invalidateQueries({queryKey:f})}}),m=B(p),g=(e,n)=>{m.mutate([{id:n,name:e.name}]),t(null)};return(0,Y.useEffect)(function(){e===n.id&&r.current&&setTimeout(()=>{r.current?.focus()},25)},[e,r,n.id]),(0,X.jsx)(_,{...i,children:(0,X.jsx)(h,{control:i.control,name:`name`,render:({field:a})=>(0,X.jsx)(G,{className:`min-w-0 flex-1`,children:e===n.id?(0,X.jsx)(W,{...a,ref:r,onBlur:()=>g({name:a.value},n.id),onKeyDown:e=>{e.key===`Enter`&&g({name:a.value},n.id),e.key===`Escape`&&(i.reset(),t(null))},onClick:e=>e.stopPropagation(),className:`h-7 text-sm`}):(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`truncate text-sm`,children:n.name}),(0,X.jsx)(`span`,{className:`shrink-0 text-xs text-muted-foreground`,children:u?``:c??0})]})})})})};Rj.displayName=`CollectionName`;function zj({onSelect:e}){let t=R(),n=ie(),r=(0,Y.useRef)(!1),i=(0,Y.useRef)(null),{hasPermissions:a}
116=z(),o=md(),s=a(o,`cms`,`create`),c=a(o,`cms`,`delete`),l=a(o,`cms`,`update`),{currentActiveCollectionId:u,setCurrentActiveCollectionId:d}=UE(),[f,p]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(null),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(null),b=fe(),x=t.cms.collections.list.queryKey(),S=t.cms.entries.list.queryKey(),C=t.cms.entries.create.mutationOptions({onSuccess(){b.invalidateQueries({queryKey:S}),b.invalidateQueries({queryKey:x})}}),w=B(C),T=t.cms.collections.create.mutationOptions({onSuccess(e,t){b.invalidateQueries({queryKey:x}),t?.[0]&&(d(t[0].id),_(t[0].id))}}),E=B(T),D=t.cms.collections.remove.mutationOptions({onSuccess:()=>{b.invalidateQueries({queryKey:x}),b.invalidateQueries({queryKey:S}),y(null)}}),O=B(D),k=t.cms.collections.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],pagination:{pageIndex:0,pageSize:10},columnFilters:[],globalFilter:``,organizationId:o}),{data:A,isLoading:j}=V(k),M=(0,Y.useMemo)(()=>A?.items??[],[A?.items]),N=ce({queries:M.map(e=>t.cms.entries.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],columnFilters:[],globalFilter:``,organizationId:o,collectionId:e.id,pagination:{pageIndex:0,pageSize:1}},{enabled:!j&&M.length>0}))});(0,Y.useEffect)(function(){if(A?.items){if(A.items.length===0){u&&(d(``),localStorage.removeItem(`cms-active-collection`));return}if(u&&!A.items.some(e=>e.id===u)){let e=A.items[0]?.id??``;d(e),e?localStorage.setItem(`cms-active-collection`,e):localStorage.removeItem(`cms-active-collection`)}}},[A?.items,u,d]),(0,Y.useEffect)(function(){if(r.current||!A?.items?.length)return;let e=localStorage.getItem(`cms-active-collection`),t=A.items[0];e&&A.items.find(t=>t.id===e)?d(e):u||t&&d(t.id),r.current=!0},[A?.items,u,d]),(0,Y.useEffect)(function(){u&&localStorage.setItem(`cms-active-collection`,u)},[u]);let P=()=>{let e=xr(),t=new Date,n=CA(0,1e6);E.mutate([{id:e,name:`New Collection-`+n,slug:`new-collection-`+n,organizationId:o,createdAt:t,updatedAt:t}])},F=e=>{O.mutate([e])},I=async e=>{let t=A?.items.find(t=>t.id===e);if(!t)return;let r=xr(),i=new Date;Promise.resolve(n.cms.entries.list.query({organizationId:o,sorting:[{id:`createdAt`,desc:!0}],pagination:{pageIndex:0,pageSize:10},columnFilters:[],globalFilter:``,collectionId:e})).then(async({items:e})=>{let n=e?.map(e=>({...e,id:xr(),collectionId:r,createdAt:i,updatedAt:i})),a=CA(0,1e6),s={...t,id:r,name:t.name+` (Copy)`+a,slug:t.slug+`-copy`+a,organizationId:o,createdAt:i,updatedAt:i};if(await E.mutateAsync([s]),n?.length>0)return w.mutateAsync(n)}).catch(async e=>{await Promise.reject(e),J.error(`Error duplicating collection`)})},L=e=>{p(e),e||h(null)},ee=e=>{h(e),p(!0)};return(0,X.jsxs)(`div`,{className:`flex h-full w-full flex-col md:w-64`,"data-quick-help":`content-collections-navigation`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Zr,{className:`size-4`,"aria-hidden":`true`}),(0,X.jsx)(`h2`,{className:`text-sm`,children:`Collections`})]}),s&&(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`size-8 p-0`,onClick:P,"aria-label":`Create new collection`,"data-quick-help":`content-add-collection`,children:(0,X.jsx)(Hr,{className:`size-4`,"aria-hidden":`true`})})]}),(0,X.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-2`,children:[j&&Array.from({length:5}).map((e,t)=>(0,X.jsxs)(`div`,{className:`mb-1 flex items-center gap-2 rounded-md p-2.5`,children:[(0,X.jsx)(Uk,{className:`size-4 shrink-0 rounded-sm`}),(0,X.jsx)(Uk,{className:`h-4 flex-1`})]},t)),!j&&M.map((t,n)=>{let r=N[n],a=c&&r?.isSuccess===!0&&(r.data?.items?.length??0)===0;return(0,X.jsxs)(`div`,{"data-quick-help":`content-collection`,className:`group mb-0.5 flex cursor-pointer items-center gap-2 rounded-lg px-3 py-2 transition-colors hover:bg-foreground
116/5 ${u===t.id?`bg-foreground/10`:``}`,onClick:()=>{d(t.id),e?.()},children:[(0,X.jsx)(Zr,{className:`size-4 flex-shrink-0 text-muted-foreground`}),(0,X.jsx)(Rj,{editingId:g,setEditingId:_,collection:t,inputRef:i}),(0,X.jsx)(Fj,{collectionName:t.name,canRename:l,canDuplicate:s,canEditFields:l,canDelete:a,onRename:()=>_(t.id),onDuplicate:()=>I(t.id),onEditFields:()=>ee(t.id),onDelete:()=>y({id:t.id,name:t.name})})]},t.id)})]}),(0,X.jsx)(cr,{open:v!==null,onOpenChange:e=>{e||y(null)},children:(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:`Remove this collection?`}),(0,X.jsxs)(Cr,{children:[`This will permanently delete "`,v?.name,`" and its field schema. There are no entries in this collection. This cannot be undone.`]})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{type:`button`,children:`Cancel`}),(0,X.jsx)(sr,{type:`button`,variant:`destructive`,disabled:O.isPending,onClick:()=>{v&&F(v.id)},children:`Remove collection`})]})]})}),m&&(0,X.jsx)(Pj,{open:f,handleOpenChange:L,collectionId:m,collections:A?.items||[]})]})}function Bj(e,t){for(let n of e){let e=n[t];if(e)return e}return null}function Vj(e,t){return e.language.localeCompare(t.language)}function Hj(e){let t=new Map;for(let n of e){let e=t.get(n.key);e?e.push(n):t.set(n.key,[n])}return[...t.entries()].sort(([e],[t])=>e.localeCompare(t)).map(([e,t])=>{let n=[...t].sort(Vj);return{key:e,description:Bj(n,`description`),context:Bj(n,`context`),byLanguage:Object.fromEntries(n.map(e=>[e.language,{id:e.id,value:e.value}]))}})}function Uj({languages:e,onCreate:t,submitting:n=!1}){let[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)({});return(0,X.jsxs)(`form`,{className:`flex flex-col gap-5 p-6`,onSubmit:n=>{n.preventDefault();let i=r.trim();i&&t({key:i,description:a.trim(),context:s.trim(),values:Object.fromEntries(e.map(({code:e})=>[e,l[e]??``]))})},children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{htmlFor:`new-system-key`,children:Z(`common.key`)}),(0,X.jsx)(W,{id:`new-system-key`,value:r,onChange:e=>i(e.target.value),placeholder:Z(`views.system-keys.create.key.placeholder`),required:!0})]}),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{htmlFor:`new-system-key-description`,children:Z(`common.description`)}),(0,X.jsx)(bt,{id:`new-system-key-description`,value:a,onChange:e=>o(e.target.value)})]}),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{htmlFor:`new-system-key-context`,children:Z(`views.system-keys.editor.context`)}),(0,X.jsx)(bt,{id:`new-system-key-context`,value:s,onChange:e=>c(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`space-y-4 border-t pt-5`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:Z(`views.system-keys.editor.translations`)}),e.map(({code:e,name:t})=>(0,X.jsxs)(G,{children:[(0,X.jsxs)(K,{htmlFor:`new-system-key-${e}`,children:[t,(0,X.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.toUpperCase()})]}),(0,X.jsx)(bt,{id:`new-system-key-${e}`,rows:2,className:`min-h-16`,value:l[e]??``,onChange:t=>u(n=>({...n,[e]:t.target.value})),"aria-label":`${t} ${Z(`views.system-keys.editor.value`)}`})]},e))]}),(0,X.jsx)(U,{type:`submit`,disabled:n||!r.trim(),children:Z(`common.create`)})]})}function Wj({open:e,onOpenChange:t,desktopContainer:n,title:r,description:i,children:a}){return!Fn()&&n?(0,X.jsx)(Gj,{open:e,onOpenChange:t,container:n,title:r,description:i,children:a}):(0,X.jsx)(Ln,{open:e,onOpenChange:t,children:(0,X.jsxs)(Vn,{className:`flex w-full flex-col overflow-y-auto p-0 sm:max-w-md`,children:[(0,X.jsxs)(tr,{className:`border-b px-6 py-4`,children:[(0,X.jsx)(er,{children:r}),i&&(0,X.jsx)(gr,{className:`wrap-break-word`,children:i})]}),a]})})}function Gj({open:e,onOpenChange:t,container:n,title:r,description:i,children:a}){let[o,s]=(0,Y.useState)(e),[c,l]=(0,Y.useState)(!1),u=e||o;return(0,Y.useEffect)(()=>{if(!u)return;let t=requestAnimationFrame(()=>{e&&s(!0),l(e)});return()=>cancelAnimationFrame(t)},[e,u]),u?(0,Rs.createPortal)((0,X.jsx)(`div`,{"data-state":c?`open`:`closed`,onTransitionEnd:t=>{t.propertyName===`width`&&!e&&s(!1)},className:`ml-2 h-full w-0 overflow-hidden transition-[width] duration-300 ease-in-out data-[state=open]:w-md`,children:(0,X.jsxs)(`aside`,{className:q(`flex h-full w-md flex-col overflow-y-auto rounded-xl bg-background`,$n({style:`base`})),children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between border-b px-6 py-4`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsx)(`h2`,{className:`text-lg font-semibold`,children:r}),i&&(0,X.jsx)(`p`,{className:`mt-1 text-sm wrap-break-word text-muted-foreground`,children:i})]}),(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>t(!1),"aria-label":Z(`common.close`),children:(0,X.jsx)(so,{className:`size-4`,"aria-hidden":`true`})})]}),a]})}),n):null}function Kj(e){return Object.entries(e.byLanguage).sort(([e],[t])=>e===`en`?-1:t===`en`?1:e.localeCompare(t))}function qj({row:e,languageNames:t,canUpdate:n,onSave:r,saving:i=!1}){let[a,o]=(0,Y.useState)(e.description??``),[s,c]=(0,Y.useState)(e.context??``),[l,u]=(0,Y.useState)(()=>Object.fromEntries(Object.entries(e.byLanguage).map(([e,t])=>[e,t.value])));return(0,X.jsxs)(`form`,{className:`flex flex-col gap-6 p-6`,onSubmit:t=>{if(t.preventDefault(),!n)return;let i=a.trim()||null,o=s.trim()||null;r(Kj(e).map(([e,t])=>({id:t.id,value:l[e]??``,description:i,context:o})))},children:[(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{children:Z(`common.key`)}),(0,X.jsx)(`div`,{className:`rounded-lg bg-muted px-3 py-2 font-mono text-sm wrap-break-word`,children:e.key})]}),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{htmlFor:`system-key-description`,children:Z(`common.description`)}),(0,X.jsx)(bt,{id:`system-key-description`,rows:3,value:a,readOnly:!n,onChange:e=>o(e.target.value),onMouseDown:e=>uA(e,!n)})]}),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{htmlFor:`system-key-context`,children:Z(`views.system-keys.editor.context`)}),(0,X.jsx)(bt,{id:`system-key-context`,rows:3,value:s,readOnly:!n,onChange:e=>c(e.target.value),onMouseDown:e=>uA(e,!n)})]}),(0,X.jsxs)(`div`,{className:`space-y-4 border-t pt-6`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:Z(`views.system-keys.editor.translations`)}),Kj(e).map(([e,r])=>{let i=t.get(e)??e.toUpperCase();return(0,X.jsxs)(G,{children:[(0,X.jsxs)(K,{htmlFor:`system-translation-${r.id}`,children:[i,(0,X.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.toUpperCase()})]}),(0,X.jsx)(bt,{id:`system-translation-${r.id}`,rows:2,className:`min-h-16`,value:l[e]??``,readOnly:!n,onChange:t=>u(n=>({...n,[e]:t.target.value})),onMouseDown:e=>uA(e,!n),"aria-label":`${i} ${Z(`views.system-keys.editor.value`)}`})]},r.id)})]}),(0,X.jsx)(`div`,{className:`border-t pt-6`,children:(0,X.jsx)(U,{type:`submit`,className:`w-full`,disabled:!n||i,children:Z(`common.save`)})})]})}function Jj({open:e,onOpenChange:t,desktopContainer:n,...r}){return r.row?(0,X.jsx)(Wj,{open:e,onOpenChange:t,desktopContainer:n,title:Z(`views.system-keys.editor.title`),description:r.row.key,children:(0,X.jsx)(qj,{...r})}):null}var Yj=[{id:`key`,desc:!1}];function Xj({translations:e,onSelect:t,onDelete:n,canDelete:r}){let i=(0,Y.useMemo)(()=>Hj(e),[e]),a=[{accessorKey:`key`,meta:{className:`w-[45%] whitespace-normal wrap-break-word`},header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.key`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`py-1 font-mono text-sm font-medium`,children:e.original.key})},{id:`english`,accessorFn:e=>e.byLanguage.en?.value??``,meta:{className:`w-[45%] whitespace-normal wrap-break-word`},header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`views.system-keys.english`)}),cell:({row:e})=>e.original.byLanguage.en?.value||(0,X.jsx)(`span`,{className:`text-muted-foreground italic`,children:Z(`views.system-keys.not-translated`)})},...r?[{id:`actions`,meta:{className:`w-[10%] text-right`},header:()=>null,cell:({row:e})=>(0,X.jsx)(Zj,{row:e.original,onDelete:n})}]:[]];return(0,X.jsx)(pd,{columns:a,data:i,getRowId:e=>e.key,pageSize:20,initialSorting:Yj,fixedLayout:!0,onRowClick:t})}function Zj({row:e,onDelete:t}){let[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(!1);return(0,X.jsx)(`div`,{className:`flex justify-end`,onClick:e=>e.stopPropagation(),children:(0,X.jsxs)(cr,{open:n,onOpenChange:r,children:[(0,X.jsx)(Nn,{render:(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-sm`,"aria-label":Z(`views.system-keys.delete.label`)}),children:(0,X.jsx)(Qi,{className:`size-4`,"aria-hidden":`true`})}),(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:Z(`views.system-keys.delete.title`)}),(0,X.jsx)(Cr,{children:Z(`views.system-keys.delete.description`)})]}),(0,X.jsx)(`div`,{className:`rounded-lg bg-muted px-3 py-2 font-mono text-sm wrap-break-word`,children:e.key}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{disabled:i,children:Z(`common.cancel`)}),(0,X.jsxs)(sr,{variant:`destructive`,disabled:i,onClick:async()=>{a(!0);try{await t(e),r(!1)}finally{a(!1)}},children:[(0,X.jsx)(Qi,{className:`size-4`,"aria-hidden":`true`}),Z(`common.delete`)]})]})]})]})})}function Qj({editorSlot:e}={}){let t=R(),n=fe(),r=md(),{hasPermissions:i}=z(),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(`edit`),[l,u]=(0,Y.useState)(!1),d=i(r,`translateSystem`,`update`),f=i(r,`translateSystem`,`create`),p=i(r,`translateSystem`,`delete`),{data:m,isError:h,isLoading:g}=V(fE(t.localization.systemTranslations.list.queryKey({}),e=>n.fetchQuery(t.localization.systemTranslations.list.queryOptions({sorting:[{id:`key`,desc:!1}],pagination:e,columnFilters:[],globalFilter:``})))),{data:_}=V(t.localization.languages.list.queryOptions()),v=(0,Y.useMemo)(()=>new Map((_??[]).map(e=>[e.code,e.englishName])),[_]),y=(0,Y.useMemo)(()=>Hj(m??[]),[m]).find(e=>e.key===a),b=(0,Y.useMemo)(()=>{let e=[...new Set((m??[]).map(e=>e.language))];return e.length===0&&e.push(`en`),e.sort((e,t)=>
116e.localeCompare(t))},[m]),x=(0,Y.useMemo)(()=>b.map(e=>({code:e,name:v.get(e)??e.toUpperCase()})),[v,b]),S=t.localization.systemTranslations.list.queryKey(),C=e=>{let t=t=>t.map(t=>t.id===e.id?{...t,...e}:t);n.setQueriesData({queryKey:S},e=>e&&(Array.isArray(e)?t(e):e.items?{...e,items:t(e.items)}:e))},w=B(t.localization.systemTranslations.update.mutationOptions({onSuccess:(e,t)=>{for(let e of t)C(e)},onError:()=>J.error(Z(`views.system-keys.update.error`))})),T=B(t.localization.systemTranslations.create.mutationOptions({onSuccess:async()=>{await n.invalidateQueries({queryKey:S}),u(!1),J.success(Z(`views.system-keys.create.success`))},onError:()=>J.error(Z(`views.system-keys.create.error`))})),E=B(t.localization.systemTranslations.remove.mutationOptions({onSuccess:async()=>{await n.invalidateQueries({queryKey:S}),u(!1),o(null),J.success(Z(`views.system-keys.delete.success`))},onError:()=>J.error(Z(`views.system-keys.delete.error`))})),D=e=>{c(e),u(!0)},O=e=>{if(s===`edit`&&l&&a===e){u(!1);return}o(e),D(`edit`)};return g?(0,X.jsxs)(`section`,{className:`flex w-full flex-col gap-6`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`font-medium`,children:Z(`common.system.keys`)}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`views.system-keys.description`)})]}),(0,X.jsx)(Jk,{})]}):h?(0,X.jsx)(`div`,{className:`p-6 text-sm text-destructive`,children:Z(`views.system-keys.error`)}):(0,X.jsxs)(`section`,{className:`flex w-full flex-col gap-6`,"data-quick-help":`system-keys`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`font-medium`,children:Z(`common.system.keys`)}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`views.system-keys.description`)}),(0,X.jsxs)(`div`,{className:`mt-3 flex w-fit items-center gap-2 rounded-lg border border-amber-500/30 bg-amber-500/10 px-3 py-2 text-sm text-amber-700 dark:text-amber-300`,children:[(0,X.jsx)(ua,{className:`size-4 shrink-0`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:Z(`views.system-keys.admin-only`)})]})]}),f&&(0,X.jsx)(`div`,{className:`flex shrink-0`,children:(0,X.jsxs)(U,{type:`button`,size:`sm`,onClick:()=>D(`create-key`),children:[(0,X.jsx)(Hr,{className:`size-4`,"aria-hidden":`true`}),Z(`views.system-keys.add-key`)]})})]}),!m||m.length===0?(0,X.jsxs)(`div`,{className:`flex min-h-80 flex-col items-center justify-center gap-3 px-6 text-center`,children:[(0,X.jsx)(`div`,{className:`flex size-11 items-center justify-center rounded-lg bg-muted text-muted-foreground`,children:(0,X.jsx)(jr,{className:`size-5`,"aria-hidden":`true`})}),(0,X.jsx)(`p`,{className:`max-w-sm text-sm text-muted-foreground`,children:Z(`views.system-keys.empty`)})]}):(0,X.jsx)(Xj,{translations:m,onSelect:e=>O(e.key),onDelete:async e=>{await E.mutateAsync(Object.values(e.byLanguage).map(e=>e.id))},canDelete:p}),(0,X.jsx)(Jj,{row:y,open:s===`edit`&&l,onOpenChange:u,desktopContainer:e,languageNames:v,canUpdate:d,saving:w.isPending,onSave:e=>w.mutate(e)},y?.key??`no-system-key-selected`),s===`create-key`&&(0,X.jsx)(Wj,{open:l,onOpenChange:u,desktopContainer:e,title:Z(`views.system-keys.create.title`),description:Z(`views.system-keys.create.description`),children:(0,X.jsx)(Uj,{languages:x,submitting:T.isPending,onCreate:e=>{let t=new Date;T.mutate(x.map(({code:n})=>({id:crypto.randomUUID(),key:e.key,value:e.values[n]??``,language:n,description:e.description||null,context:e.context||null,isActive:!0,createdAt:t,updatedAt:t})))}})})]})}var $j=e=>({DASHBOARD_HOME:`/${e}/dashboard/home`,DASHBOARD_CONTENT:`/${e}/dashboard/content`,DASHBOARD_LOCALIZATION:`/${e}/dashboard/localization`}),eM={content:Z(`common.collections`),labels:Z(`views.cms.navigation.labels`),system:Z(`common.system.keys`),localization:Z(`common.locales`)};function tM({organizationSlug:e,canViewLabels:t,canViewLocalization:n,canViewSystem:r,mobileNavigationOpen:i,onMobileNavigationOpenChange:a}){let o=c(),s=$j(e).DASHBOARD_HOME,l=y({name:`cmsMode`}),[u,d]=(0,Y.useState)(null),f=e=>l===`content`?(0,X.jsx)(zj,{onSelect:e}):l===`system`?null:l===`labels`&&t?(0,X.jsx)(TA,{onSelect:e}):(0,X.jsx)(HA,{onSelect:e});return(0,X.jsxs)(`div`,{className:`flex min-h-0 flex-1 overflow-hidden px-2 pb-2 md:px-0 md:pr-2`,children:[(0,X.jsx)(`div`,{className:`hidden md:block`,"data-quick-help":`content-navigation`,children:f()}),(0,X.jsx)(Ln,{open:i,onOpenChange:a,children:(0,X.jsxs)(Vn,{side:`left`,className:`w-[min(20rem,86vw)] p-0`,children:[(0,X.jsxs)(tr,{className:`sr-only`,children:[(0,X.jsx)(er,{children:eM[l]??eM.localization}
116),(0,X.jsx)(gr,{children:Z(l===`labels`?`views.cms.navigation.labels.description`:`views.cms.navigation.default.description`)})]}),(0,X.jsx)(`div`,{className:`border-b border-sidebar-border px-3 py-3`,children:(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>{a(!1),o(s)},"aria-label":Z(`views.cms.top-bar.back-to-dashboard`),children:[(0,X.jsx)(Ca,{className:`size-4`}),Z(`views.cms.top-bar.back-to-dashboard`)]})}),f(()=>a(!1))]})}),(0,X.jsx)(`div`,{className:q(`flex min-w-0 flex-1 flex-col overflow-y-auto rounded-xl bg-background`,$n({style:`base`})),"data-quick-help":`content-workspace`,children:(0,X.jsx)(`div`,{className:q(`p-3 md:p-6`,l===`content`&&`flex min-h-0 flex-1 flex-col`),children:l===`content`?(0,X.jsx)(iA,{editorSlot:u}):l===`system`&&r?(0,X.jsx)(Qj,{editorSlot:u}):l===`labels`&&t?(0,X.jsx)(SA,{}):n?(0,X.jsx)(wj,{}):null})}),(0,X.jsx)(`div`,{ref:d,className:`hidden md:block`})]})}var nM=lt({cmsMode:Xe([`content`,`localization`,`labels`,`system`])}),rM={cmsMode:`content`};function iM({canViewLocalization:e,canViewLabels:t,canViewSystem:n,onModeChange:r}){let{control:i,setValue:a}=p(),o=y({control:i,name:`cmsMode`});return(0,Y.useEffect)(()=>{(!e&&o===`localization`||!t&&o===`labels`||!n&&o===`system`)&&a(`cmsMode`,`content`)},[t,e,n,o,a]),(0,X.jsx)(h,{control:i,name:`cmsMode`,render:({field:i,fieldState:a})=>(0,X.jsx)(pu,{value:i.value,onValueChange:e=>{let t=e;i.onChange(t),r?.(t)},children:(0,X.jsxs)(hu,{"data-invalid":a.invalid?!0:void 0,"data-quick-help":`content-modes`,className:`max-w-full border border-neutral-200 bg-neutral-100 shadow-xs dark:border-border/70 dark:bg-muted/60`,children:[(0,X.jsxs)(gu,{value:`content`,className:`gap-1.5 md:gap-2`,"data-quick-help":`cms-tab-content`,children:[(0,X.jsx)(Zr,{className:`size-4`}),Z(`common.content`)]}),t&&(0,X.jsxs)(gu,{value:`labels`,className:`gap-1.5 md:gap-2`,"data-quick-help":`cms-tab-labels`,children:[(0,X.jsx)(Da,{className:`size-4`}),Z(`views.cms.mode.labels`)]}),e&&(0,X.jsxs)(gu,{value:`localization`,className:`gap-1.5 md:gap-2`,"data-quick-help":`cms-tab-localization`,children:[(0,X.jsx)(Na,{className:`size-4`}),Z(`views.cms.mode.localization`)]}),n&&(0,X.jsxs)(gu,{value:`system`,className:`gap-1.5 md:gap-2`,"data-quick-help":`cms-tab-system`,children:[(0,X.jsx)(jr,{className:`size-4`}),Z(`common.system`)]})]})})})}function aM({organizationSlug:e,onOpenNavigation:t}){let n=c(),r=$j(e).DASHBOARD_HOME;return(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-1 px-2 md:w-64 md:px-4`,children:[(0,X.jsx)(U,{variant:`outline`,type:`button`,size:`icon-lg`,onClick:t,className:`md:hidden`,"aria-label":Z(`views.cms.top-bar.open-navigation`),children:(0,X.jsx)(lo,{className:`size-4`})}),(0,X.jsxs)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:()=>n(r),className:`hidden md:inline-flex`,"aria-label":Z(`views.cms.top-bar.back-to-dashboard`),children:[(0,X.jsx)(Ca,{className:`size-4`}),Z(`views.cms.top-bar.back-to-dashboard`)]})]})}var oM={labels:`canViewLabels`,localization:`canViewLocalization`,system:`canViewSystem`};function sM(e,t){let n=oM[e];return!n||!t[n]?`content`:e}function cM(){let{setCurrentActiveLanguageCode:e}=UE(),{activeOrganization:t,canViewLabels:n,canViewLocalization:r,canViewSystem:i}=zk(),[a,s]=(0,Y.useState)(!1),[c,u]=o(),d=sM(c.get(`tab`),{canViewLabels:n,canViewLocalization:r,canViewSystem:i}),f=l({resolver:pn(nM),defaultValues:{...rM,cmsMode:d}});(0,Y.useEffect)(()=>{f.getValues(`cmsMode`)!==d&&f.setValue(`cmsMode`,d)},[f,d]);let p=e=>{u(t=>{let n=new URLSearchParams(t);return n.set(`tab`,e),n},{replace:!0})},m=t?.metadata;return Vk(t?.id,m,e),(0,X.jsx)(_,{...f,children:(0,X.jsxs)(`div`,{className:`flex h-screen flex-col bg-muted`,children:[(0,X.jsxs)(`div`,{className:`z-10 flex h-13 shrink-0 items-center`,children:[(0,X.jsx)(aM,{organizationSlug:t?.slug??``,onOpenNavigation:()=>s(!0)}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center justify-end gap-2 px-2 md:justify-between md:px-4`,children:[(0,X.jsx)(iM,{canViewLocalization:r,canViewLabels:n,canViewSystem:i,onModeChange:p}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,"data-quick-help":`content-transfer`,children:[(0,X.jsx)(Vl,{}),(0,X.jsx)(Rk,{})]})]})]}),(0,X.jsx)(tM,{organizationSlug:t?.slug??``,canViewLabels:n,canViewLocalization:r,canViewSystem:i,mobileNavigationOpen:a,onMobileNavigationOpenChange:s})]})})}var lM=({children:e})=>{let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(()=>localStorage.getItem(`cms-active-label-collection`)),[a,o]=(0,Y.useState)(null);(0,Y.useEffect)(()=>
116{if(r){localStorage.setItem(`cms-active-label-collection`,r);return}localStorage.removeItem(`cms-active-label-collection`)},[r]);let s=(0,Y.useMemo)(()=>({currentActiveCollectionId:t,setCurrentActiveCollectionId:n,currentActiveLabelCollectionId:r,setCurrentActiveLabelCollectionId:i,currentActiveLanguageCode:a,setCurrentActiveLanguageCode:o}),[t,r,a]);return(0,X.jsx)(HE.Provider,{value:s,children:e})};function uM(){return(0,X.jsx)(VE,{children:(0,X.jsx)(lM,{children:(0,X.jsx)(cM,{})})})}var dM={meeting:`Meeting`,webinar:`Webinar`,"solo-experience":`Solo experience`},fM={"solo-experience":`border border-violet-200 bg-violet-100 text-violet-800 dark:border-violet-800/50 dark:bg-violet-900/30 dark:text-violet-300`,webinar:`border border-sky-200 bg-sky-100 text-sky-800 dark:border-sky-800/50 dark:bg-sky-900/30 dark:text-sky-300`,meeting:`border border-emerald-200 bg-emerald-100 text-emerald-800 dark:border-emerald-800/50 dark:bg-emerald-900/30 dark:text-emerald-300`},pM=[{value:`meeting`,label:`Meeting`,description:`Interactive meeting where all participants can use AV.`},{value:`webinar`,label:`Webinar`,description:`Stage + audience; presenters use AV, audience consumes broadcast.`},{value:`solo-experience`,label:`Solo experience`,description:`No user-to-user communication; limited-access virtual experience.`}],mM=[{value:`auth`,label:`Members only`,description:`Sign-in required`},{value:`email-list`,label:`Invited only`,description:`Add emails or domains (*@company.com).`},{value:`public`,label:`Public`,description:`No sign-in required`}],hM=[{value:`enabled`,label:`Everyone`,description:`Everyone can see and send messages in chat.`},{value:`moderated`,label:`Moderated`,description:`Messages must be approved by a moderator.`},{value:`disabled`,label:`Disabled`,description:`Chat is disabled.`}],gM=[{value:`presenters`,label:`Presenters`,description:`Only presenters can share their screen.`},{value:`everyone`,label:`Everyone`,description:`All participants can share their screen.`}],_M=lt({name:H().min(1,`Give your event a name so people know what it is.`),slug:H().min(1,`Add a short URL slug, for example "company-kickoff".`),id:H().uuid().optional(),description:H().optional(),startAt:qt({required_error:`Choose when the event starts.`,invalid_type_error:`Please pick a valid start date and time.`}),endAt:qt({required_error:`Choose when the event ends.`,invalid_type_error:`Please pick a valid end date and time.`}),properties:lt({type:Xe([`webinar`,`meeting`,`solo-experience`]).default(`meeting`),authType:Xe([`email-list`,`auth`,`public`]).default(`auth`),requireEmailVerification:be().optional(),participantTransformLimit:We().optional(),chat:Xe([`disabled`,`enabled`,`moderated`]).default(`enabled`),screenSharing:Xe([`presenters`,`everyone`]).optional(),lockMeeting:be().optional(),waitingRoom:be().optional(),requirePasscode:be().optional(),passcode:H().optional(),allowJoinWithEmailOnly:be().optional(),allowParticipantsToUnmute:be().optional(),muteParticipantsOnEntry:be().optional(),chatVisibility:Xe([`open`,`presenterOnly`]).optional(),requireMessageApproval:be().optional(),raiseHand:be().optional(),enableReactions:be().optional(),sendInvitations:be().optional(),participantsVisibleToOthers:be().optional()}),timezone:H().optional(),initialSpaceId:H().uuid().optional(),lobbySpaceId:H().uuid().optional(),worldId:H().uuid().optional()}).refine(e=>e.endAt.getTime()>e.startAt.getTime(),{message:`End time must be after the start time.`,path:[`endAt`]}),vM=Array.from({length:24},(e,t)=>23-t),yM=Array.from({length:12},(e,t)=>t*5);function bM({value:e,onChange:t,...n}){let[r,i]=(0,Y.useState)(!1),a=(0,Y.useRef)(null),o=n=>{if(!n)return;let r=new Date(n);e&&r.setHours(e.getHours(),e.getMinutes(),0,0),t(r)},s=(n,r)=>{let i=e?new Date(e):new Date;n===`hour`?i.setHours(r,i.getMinutes(),0,0):(i.setMinutes(r),i.setSeconds(0,0)),t(i)};return(0,Y.useEffect)(function(){if(!r||!e)return;let t=setTimeout(()=>{let e=a.current;e&&e.querySelectorAll(`[data-selected="true"]`).forEach(e=>{e.scrollIntoView({block:`center`,inline:`center`})})},0);return()=>clearTimeout(t)},[r,e]),(0,X.jsxs)(jn,{open:r,onOpenChange:i,children:[(0,X.jsx)(Kn,{render:t=>(0,X.jsxs)(U,{...t,variant:`outline`,"aria-label":n[`aria-label`],"aria-invalid":n[`aria-invalid`],className:q(`w-full justify-start gap-2 text-left font-normal`,!e&&`text-muted-foreground`),children:[(0,X.jsx)(da,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),e?$i(e,`MMM d, yyyy  HH:mm`):(0,X.jsx)(`span`,{children:`Pick a date`})]})}),(0,X.jsx)(ur,{align:`start`,className:`w-auto max-w-[calc(100vw-2rem)] overflow-hidden p-0 sm:max-w-fit`,children:(0,X.jsxs)(`div`,{ref:a,className:`flex flex-col overflow-hidden sm:flex-row`,children:[(0,X.jsx)(Mw,{mode:`single`,selected:e,onSelect:o,defaultMonth:e}),(0,X.jsxs)(`div`,{className:`flex flex-col divide-y overflow-hidden sm:h-75 sm:flex-row sm:divide-x sm:divide-y-0`,children:[(0,X.jsxs)(jl,{className:`w-64 sm:w-12`,children:[(0,X.jsx)(`div`,{className:`flex p-1.5 sm:flex-col`,children:vM.map(t=>{let n=e?.getHours()===t;return(0,X.jsx)(U,{size:`icon`,variant:n?`default`:`ghost`,"data-selected":n,
116className:`aspect-square shrink-0 sm:w-full`,onClick:()=>s(`hour`,t),children:String(t).padStart(2,`0`)},t)})}),(0,X.jsx)(Ml,{orientation:`horizontal`,className:`sm:hidden`})]}),(0,X.jsxs)(jl,{className:`w-64 sm:w-12`,children:[(0,X.jsx)(`div`,{className:`flex p-1.5 sm:flex-col`,children:yM.map(t=>{let n=e?.getMinutes()===t;return(0,X.jsx)(U,{size:`icon`,variant:n?`default`:`ghost`,"data-selected":n,className:`aspect-square shrink-0 sm:w-full`,onClick:()=>s(`minute`,t),children:String(t).padStart(2,`0`)},t)})}),(0,X.jsx)(Ml,{orientation:`horizontal`,className:`sm:hidden`})]})]})]})})]})}bM.displayName=`DateTimePicker`;function xM(e,t){let n=t.getTime()-e.getTime();if(n<=0)return``;let r=Math.round(n/6e4),i=1440,a=i*7,o=43830,s=525960,c=Math.floor(r/s);r-=c*s;let l=Math.floor(r/o);r-=l*o;let u=Math.floor(r/a);r-=u*a;let d=Math.floor(r/i);r-=d*i;let f=Math.floor(r/60),p=r-f*60,m=[];return c&&m.push(`${c}y`),l&&m.push(`${l}mo`),u&&m.push(`${u}w`),d&&m.push(`${d}d`),f&&m.push(`${f}h`),p&&m.push(`${p}m`),m.length>0?m.join(` `):`0m`}function SM({syncFrom:e=`name`,baseUrl:t=`https://www.storyverse.fi/events/`}){let{control:n,setValue:r,getValues:i}=p(),a=y({control:n,name:e}),o=y({control:n,name:`properties.type`}),s=(0,Y.useRef)(!1),c=(0,Y.useRef)(void 0),l=()=>{let e=()=>Array.from({length:3}).map(()=>`abcdefghijklmnopqrstuvwxyz0123456789`[Math.floor(Math.random()*36)]).join(``);return`${e()}-${e()}-${e()}`};(0,Y.useEffect)(function(){if(!s.current){if(o===`meeting`){i(`slug`)||r(`slug`,l(),{shouldValidate:!0});return}a!==c.current&&(c.current=a,a&&r(`slug`,Bd(a),{shouldValidate:!0}))}},[o,a,r,i]);let u=y({control:n,name:`slug`}),d=p().getFieldState(`slug`);return(0,Y.useEffect)(function(){let e=i(`slug`);!a&&!e&&(s.current=!1)},[a,i]),(0,X.jsxs)(G,{"data-invalid":d.invalid,children:[(0,X.jsx)(K,{htmlFor:`slug`,children:Z(`components.form.event.form.slug`)}),(0,X.jsxs)(Me,{children:[(0,X.jsx)(Ve,{children:(0,X.jsx)(St,{children:t})}),(0,X.jsx)(ze,{id:`slug`,name:`slug`,value:u||``,onChange:e=>{s.current=!0,r(`slug`,e.target.value)},onBlur:e=>{r(`slug`,Bd(e.target.value),{shouldValidate:!0})},placeholder:`slug`,className:`pl-0.5! font-semibold`}),(0,X.jsx)(Ve,{align:`inline-end`,children:(0,X.jsxs)(Pn,{children:[(0,X.jsx)(dr,{render:e=>(0,X.jsx)(an,{className:`rounded-full`,size:`icon-xs`,...e,children:(0,X.jsx)(ua,{})})}),(0,X.jsx)(Gn,{children:Z(`components.form.event.form.slug.tooltip`)})]})})]}),d.invalid&&d.error&&(0,X.jsx)(kt,{errors:[d.error]})]})}var CM=()=>{let e=R(),{activeOrganization:t}=z(),n=p(),{data:r,isLoading:i,isError:a}=V(e.world.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:t?.id}));return i?(0,X.jsx)(`div`,{children:Z(`common.loading`)}):a?(0,X.jsx)(`div`,{children:Z(`common.error.loading.worlds`)}):r?(0,X.jsx)(h,{name:`worldId`,control:n.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`components.form.event.select.world.label`)}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:(0,X.jsxs)(Vt,{value:e.value,onValueChange:e.onChange,defaultValue:r.items[0]?.id,name:e.name,items:r.items.map(e=>({label:e.name,value:e.id})),children:[(0,X.jsx)(Dn,{className:`w-full`,children:(0,X.jsx)(Mt,{})}),(0,X.jsx)(Dt,{children:r.items.map(e=>(0,X.jsx)(yn,{value:e.id,children:e.name},e.id))})]})}),(0,X.jsx)(Gt,{children:Z(`components.form.event.select.world.description`)}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}):(0,X.jsx)(`div`,{children:Z(`common.no.worlds.found`)})};CM.displayName=`SelectWorld`;function wM({value:e,onChange:t,options:n,ariaLabel:r,className:i}){return(0,X.jsx)(`div`,{className:q(`inline-flex rounded-full bg-muted p-1`,i),role:`tablist`,"aria-label":r,children:n.map(n=>{let r=e===n.value;return(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>t(n.value),className:q(`rounded-full px-3 py-1.5 text-sm font-medium transition-all`,`focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-muted focus-visible:outline`,r?n.className??`bg-background text-foreground shadow-sm`:`text-muted-foreground hover:text-foreground
116/80`),children:n.label},n.value)})})}function TM({title:e,children:t,className:n}){return(0,X.jsxs)(`div`,{className:q(`space-y-4 rounded-lg border border-border bg-muted/30 p-4`,n),children:[(0,X.jsx)(`h3`,{className:`text-sm font-semibold`,children:e}),t]})}function EM({organizationSlug:e}){let t=p();t.watch(`properties.type`);let n=t.watch(`properties.chat`),r=t.watch(`properties.screenSharing`);return hM.find(e=>e.value===n)?.description,gM.find(e=>e.value===r)?.description,(0,X.jsxs)(`div`,{className:`min-w-0 space-y-6 overflow-visible`,"data-quick-help":`event-details`,children:[(0,X.jsx)(TM,{title:`Details`,children:(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(h,{name:`name`,control:t.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:`Name`}),(0,X.jsx)(W,{...e,id:e.name,type:`text`,"aria-invalid":t.invalid,placeholder:`Event name`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(SM,{syncFrom:`name`,baseUrl:`https://www.storyverse.fi/${e}/events/`}),(0,X.jsx)(h,{name:`description`,control:t.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:`Description`}),(0,X.jsx)(`textarea`,{...e,id:e.name,placeholder:`What is this event about?`,rows:2,className:`w-full resize-none rounded-md border border-input bg-background px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,"aria-invalid":t.invalid}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})})]})}),(0,X.jsxs)(TM,{title:`Date & time`,children:[(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(h,{name:`startAt`,control:t.control,render:({fieldState:e})=>(0,X.jsxs)(G,{"data-invalid":e.invalid,children:[(0,X.jsx)(K,{children:`Start`}),(0,X.jsx)(bM,{value:t.watch(`startAt`),onChange:e=>t.setValue(`startAt`,e,{shouldValidate:t.formState.isSubmitted}),"aria-label":`Start date and time`,"aria-invalid":e.invalid}),e.invalid&&(0,X.jsx)(kt,{errors:[e.error]})]})}),(0,X.jsx)(h,{name:`endAt`,control:t.control,render:({fieldState:e})=>(0,X.jsxs)(G,{"data-invalid":e.invalid,children:[(0,X.jsx)(K,{children:`End`}),(0,X.jsx)(bM,{value:t.watch(`endAt`),onChange:e=>t.setValue(`endAt`,e,{shouldValidate:t.formState.isSubmitted}),"aria-label":`End date and time`,"aria-invalid":e.invalid}),e.invalid&&(0,X.jsx)(kt,{errors:[e.error]})]})})]}),t.watch(`startAt`)&&t.watch(`endAt`)&&xM(t.watch(`startAt`),t.watch(`endAt`))&&(0,X.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Duration:`,` `,xM(t.watch(`startAt`),t.watch(`endAt`))]})]}),(0,X.jsx)(TM,{title:`World`,children:(0,X.jsx)(CM,{})})]})}var DM=/^[^\s@]{1,64}@[^\s@]{1,251}\.[^\s@]{2,63}$/;function OM(e){return e.startsWith(`*@`)||e.startsWith(`@`)}function kM(e){let t=e.trim();if(!t)return null;let n,r;if(OM(t)){n=t.startsWith(`@`)?`*${t}`:t;let e=n.slice(2);if(!e||!e.includes(`.`))return null;r=`domain`}else if(t.length<=254&&DM.test(t))n=t,r=`email`;else return null;return{id:crypto.randomUUID(),value:n,type:r}}function AM(e){let t=[],n=[];for(let r of e.split(/[\r\n]+/))for(let e of r.split(`,`)){let r=e.trim().replace(/^["']|["']$/g,``);if(!r||/^(email|address|participant)s?$/i.test(r))continue;let i=kM(r);i?t.push(i):n.push(r)}return{valid:t,errors:n}}function jM({open:e,onOpenChange:t,onImport:n}){let r=(0,Y.useRef)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(`add`),[c,l]=(0,Y.useState)(!1),u=e=>{let t=new FileReader;t.onload=e=>{let t=e.target?.result;typeof t==`string`&&a(AM(t))},t.readAsText(e)},d=e=>{e.preventDefault(),l(!1);let t=e.dataTransfer.files[0];t&&u(t)},f=()=>{a(null),t(!1)};return(0,X.jsx)(ar,{open:e,onOpenChange:f,children:(0,X.jsxs)(pr,{children:[(0,X.jsx)(rr,{children:(0,X.jsx)(mr,{children:`Import participants`})}),(0,X.jsx)(`div`,{className:`space-y-4`,children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/40 px-3 py-2.5`,children:[(0,X.jsxs)(`p`,{className:`text-sm font-medium`,children:[i.valid.length.toLocaleStr
116ing(),` valid entries found`]}),i.errors.length>0&&(0,X.jsxs)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:[i.errors.length,` invalid entries will be skipped`]})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:`Add to existing list or replace?`}),(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,children:[`add`,`replace`].map(e=>(0,X.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 text-sm`,children:[(0,X.jsx)(`input`,{type:`radio`,name:`import-merge-mode`,checked:o===e,onChange:()=>s(e),className:`border-input`}),e===`add`?`Add to existing list`:`Replace existing list`]},e))})]}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>a(null),className:`text-xs text-muted-foreground underline hover:text-foreground`,children:`← Choose a different file`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(_r,{children:[`Upload a CSV file with one email per row. Domain rules like`,` `,(0,X.jsx)(`code`,{className:`rounded bg-muted px-1 py-0.5 text-xs`,children:`*@company.com`}),` `,`are also supported.`]}),(0,X.jsxs)(`div`,{onDragOver:e=>{e.preventDefault(),l(!0)},onDragLeave:()=>l(!1),onDrop:d,onClick:()=>r.current?.click(),className:q(`flex cursor-pointer flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed px-4 py-10 text-sm transition-colors`,c?`border-primary bg-primary/5`:`border-border hover:border-primary/50 hover:bg-muted/30`),children:[(0,X.jsx)(wi,{className:`size-6 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`p`,{className:`font-medium`,children:`Drop a CSV file here`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`or click to browse (.csv, .txt)`})]})]}),(0,X.jsx)(`input`,{ref:r,type:`file`,accept:`.csv,.txt`,className:`sr-only`,onChange:e=>{let t=e.target.files?.[0];t&&u(t)}})]})}),i&&(0,X.jsxs)(lr,{children:[(0,X.jsx)(U,{variant:`outline`,onClick:f,children:`Cancel`}),(0,X.jsxs)(U,{disabled:i.valid.length===0,onClick:()=>{i&&(n(i.valid,o),f())},children:[`Import `,i.valid.length.toLocaleString(),` participants`]})]})]})})}function MM({open:e,onOpenChange:t,participants:n,onRemove:r,onRemoveMany:i}){let[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(0),[l,u]=(0,Y.useState)(new Set),d=(0,Y.useMemo)(()=>{if(!a.trim())return n;let e=a.toLowerCase();return n.filter(t=>t.value.toLowerCase().includes(e))},[n,a]),f=Math.ceil(d.length/50),p=d.slice(s*50,(s+1)*50),m=p.length>0&&p.every(e=>l.has(e.id)),h=e=>u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n}),g=()=>u(m?new Set:new Set(p.map(e=>e.id))),_=()=>{i([...l]),u(new Set)},v=n.filter(e=>e.type===`email`).length,y=n.filter(e=>e.type===`domain`).length;return(0,X.jsx)(Ln,{open:e,onOpenChange:t,children:(0,X.jsxs)(Vn,{side:`right`,className:`sm:max-w-lg`,showCloseButton:!0,children:[(0,X.jsxs)(tr,{className:`border-b border-border`,children:[(0,X.jsx)(er,{className:`text-sm font-semibold`,children:`Manage participants`}),(0,X.jsxs)(gr,{className:`text-xs`,children:[v.toLocaleString(),` email`,v===1?``:`s`,y>0&&` · ${y} domain rule${y===1?``:`s`}`]})]}),(0,X.jsxs)(`div`,{className:`space-y-2 border-b border-border px-4 py-3`,children:[(0,X.jsx)(`input`,{type:`search`,placeholder:`Search emails or domains…`,value:a,onChange:e=>{o(e.target.value),c(0)},"aria-label":`Search participants`,className:`w-full rounded-md border border-input bg-background px-3 py-1.5 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`}),l.size>0&&(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[l.size,` selected`]}),(0,X.jsx)(U,{variant:`destructive`,size:`sm`,onClick:_,children:`Remove selected`})]})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-y-auto`,children:p.length===0?(0,X.jsx)(`p`,{className:`px-4 py-8 text-center text-sm text-muted-foreground`,children:a.trim()?`No matching participants`:`No participants added yet`}):(0,X.jsxs)(`table`,{className:`w-full text-sm`,"aria-label":`Participants list`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`sticky top-0 border-b border-border bg-background`,children:[(0,X.jsx)(`th`,{className:`w-10 px-4 py-2 text-left font-normal`,children:(0,X.jsx)(`input`,{type:`checkbox`,checked:m,onChange:g,"aria-label":`Select all on this page`,className:`rounded border-input`})}),(0,X.jsx)(`th`,{className:`px-2 py-2 text-left text-xs font-medium text-muted-foreground`,children:`Participant`}),(0,X.jsx)(`th`,{className:`w-10`})]})}),(0,X.jsx)(`tbody`,{children:p.map(e=>(0,X.jsxs)(`tr`,{className:`group border-b border-border/50 hover:bg-muted/30`,children:[(0,X.jsx)(`td`,{className:`px-4 py-2`,children:(0,X.jsx)(`input`,{type:`checkbox`,checked:l.has(e.id),onChange:()=>h(e.id),"aria-label":`Select ${e.value}`,className:`rounded border-input`})}),(0,X.jsx)(`td`,{className:`px-2 py-2`,children:(0,X.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[e.type===`domain`&&(0,X.jsx)(Na,{className:`size-3.5 shrink-0 text-blue-500`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:q(`truncate`,e.type===`domain`&&`text-blue-700 dark:text-blue-400`),children:e.value}),e.type===`domain`&&(0,X.jsx)(`span`,{className:`shrink-0 rounded-full bg-blue-100 px-1.5 py-0.5 text-[10px] font-medium text-blue-700 dark:bg-blue-900/40 dark:text-blue-300`,children:`domain`}),e.status&&(0,X.jsxs)(`span`,{className:q(`shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium`,e.status===`accepted`&&`bg-green-100 text-green-700 dark:bg-green-900/40 dark:text-green-300`,e.status===`pen
116ding`&&`bg-amber-100 text-amber-700 dark:bg-amber-900/40 dark:text-amber-300`,e.status===`declined`&&`bg-red-100 text-red-700 dark:bg-red-900/40 dark:text-red-300`),children:[e.status.charAt(0).toUpperCase(),e.status.slice(1)]})]})}),(0,X.jsx)(`td`,{className:`px-2 py-2 text-right`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.id),"aria-label":`Remove ${e.value}`,className:`rounded p-1 text-muted-foreground opacity-0 transition-opacity group-hover:opacity-100 hover:text-destructive`,children:(0,X.jsx)(so,{className:`size-3.5`,"aria-hidden":!0})})})]},e.id))})]})}),f>1&&(0,X.jsxs)(Bn,{className:`flex-row items-center justify-between border-t border-border`,children:[(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`Page `,s+1,` of `,f,` ·`,` `,d.length.toLocaleString(),` results`]}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(U,{variant:`outline`,size:`sm`,disabled:s===0,onClick:()=>c(e=>e-1),children:`Previous`}),(0,X.jsx)(U,{variant:`outline`,size:`sm`,disabled:s>=f-1,onClick:()=>c(e=>e+1),children:`Next`})]})]})]})})}function NM({participant:e,onRemove:t}){let n=e.type===`domain`;return(0,X.jsxs)(`span`,{role:`listitem`,title:e.value,className:q(`inline-flex max-w-55 shrink-0 items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium`,n?`border-blue-200 bg-blue-50 text-blue-800 dark:border-blue-800 dark:bg-blue-950/50 dark:text-blue-300`:`border-border bg-muted text-foreground`),children:[n&&(0,X.jsx)(Na,{className:`size-3 shrink-0 text-blue-500`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.value}),e.status&&(0,X.jsx)(`span`,{className:q(`text-[10px] font-semibold opacity-70`,e.status===`accepted`&&`text-green-700 dark:text-green-400`,e.status===`pending`&&`text-amber-700 dark:text-amber-400`,e.status===`declined`&&`text-red-700 dark:text-red-400`),children:`•`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`Remove ${e.value}`,className:q(`ml-0.5 shrink-0 rounded-full p-0.5 transition-colors`,n?`hover:bg-blue-200 dark:hover:bg-blue-800`:`hover:bg-muted-foreground/20`),children:(0,X.jsx)(so,{className:`size-2.5`,"aria-hidden":!0})})]})}function PM({participants:e,onChange:t,className:n}){let r=(0,Y.useId)(),i=(0,Y.useRef)(null),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),p=(0,Y.useMemo)(()=>e.filter(e=>e.type===`email`).length,[e]),m=(0,Y.useMemo)(()=>e.filter(e=>e.type===`domain`).length,[e]),h=e.length,g=h<=20,_=(0,Y.useCallback)(n=>{let r=n.split(/[,;\n\t]+/).map(e=>e.trim()).filter(Boolean),i=new Set(e.map(e=>e.value.toLowerCase())),a=[],o=[];for(let e of r){if(i.has(e.toLowerCase()))continue;let t=kM(e);t?(a.push(t),i.add(t.value.toLowerCase())):o.push(e)}if(o.length>0){let e=o.slice(0,2).join(`, `),t=o.length-2,n=o.length>2?` and ${t} more`:``;c(`Invalid: ${e}${n}`)}else c(``);return a.length>0&&t([...e,...a]),a.length>0},[e,t]),v=n=>{if(n.key===`Enter`||n.key===`,`){n.preventDefault();let e=a.trim().replace(/,$/,``);e&&_(e)&&o(``)}else n.key===`Backspace`&&a===``&&e.length>0&&t(e.slice(0,-1)),c(``)},y=e=>{let t=e.clipboardData.getData(`text`);/[,;\n\t]/.test(t)&&(e.preventDefault(),_(t)&&o(``))},b=()=>{let e=a.trim();e&&_(e)&&o(``)},x=(0,Y.useCallback)(n=>t(e.filter(e=>e.id!==n)),[e,t]),S=(0,Y.useCallback)(n=>{let r=new Set(n);t(e.filter(e=>!r.has(e.id)))},[e,t]),C=(0,Y.useCallback)((n,r)=>{if(r===`replace`)t(n);else{let r=new Set(e.map(e=>e.value.toLowerCase())),i=n.filter(e=>!r.has(e.value.toLowerCase()));t([...e,...i])}},[e,t]);return(0,X.jsxs)(`div`,{className:q(`space-y-3`,n),children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`label`,{htmlFor:r,className:`text-sm font-medium`,children:[`Participants`,h>0&&(0,X.jsx)(`span`,{className:`ml-1.5 rounded-full bg-muted px-1.5 py-0.5 text-xs font-normal text-muted-foreground`,children:h.toLocaleString()})]}),h>0&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>u(!0),className:`text-xs text-muted-foreground underline hover:text-foreground`,children:`Manage list`})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(`input`,{ref:i,id:r,type:`text`,placeholder:`Type email or *@domain.com, then press Enter`,value:a,onChange:e=>{o(e.target.value),c(``)},onKeyDown:v,onPaste:y,onBlur:b,"aria-label":`Add participant`,"aria-describedby":s?`${r}-error`:`${r}-hint`,className:q(`w-full rounded-md border bg-background px-3 py-2 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring`,s?`border-destructive`:`border-input`)}),s?(0,X.jsx)(`p`,{id:`${r}-error`,role:`alert`,className:`text-xs text-destructive`,children:s}
116):(0,X.jsx)(`p`,{id:`${r}-hint`,className:`text-xs text-muted-foreground`,children:`Press Enter or comma to add · paste multiple emails to add all at once`})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,X.jsxs)(U,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>f(!0),className:`gap-1.5`,children:[(0,X.jsx)(wi,{className:`size-3.5`,"aria-hidden":!0}),`Import from CSV`]}),(0,X.jsxs)(U,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>{if(e.length===0)return;let t=[`type,value`,...e.map(e=>`${e.type},${e.value}`)],n=new Blob([t.join(`
117`)],{type:`text/csv`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`participants.csv`,i.click(),URL.revokeObjectURL(r)},disabled:e.length===0,"aria-label":`Export participants`,className:`gap-1.5`,children:[(0,X.jsx)(Wr,{className:`size-3.5`,"aria-hidden":!0}),`Export`]})]}),g&&h>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,role:`list`,"aria-label":`Added participants`,children:e.map(e=>(0,X.jsx)(NM,{participant:e,onRemove:x},e.id))}),!g&&(0,X.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border bg-muted/30 px-3 py-2.5 text-sm`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`span`,{className:`font-medium`,children:p.toLocaleString()}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`email`,p===1?``:`s`]}),m>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`mx-1.5 text-muted-foreground/40`,children:`·`}),(0,X.jsx)(`span`,{className:`font-medium`,children:m}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`domain rule`,m===1?``:`s`]})]})]}),(0,X.jsx)(U,{variant:`outline`,size:`sm`,type:`button`,onClick:()=>u(!0),children:`Manage list`})]}),(0,X.jsx)(MM,{open:l,onOpenChange:u,participants:e,onRemove:x,onRemoveMany:S}),(0,X.jsx)(jM,{open:d,onOpenChange:f,onImport:C})]})}function FM({participants:e,onParticipantsChange:t,isLoadingFormData:n,isSubmitting:r,isSendingInvitations:i,hasInvitations:a,onSendInvitations:o}){let s=p(),c=s.watch(`properties.authType`),l=mM.find(e=>e.value===c)?.description;return(0,X.jsxs)(`div`,{className:`space-y-6`,"data-quick-help":`event-access`,children:[(0,X.jsxs)(TM,{title:`Who can join`,children:[(0,X.jsx)(h,{name:`properties.authType`,control:s.control,render:({field:e})=>(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(wM,{value:e.value,onChange:e.onChange,options:mM.map(e=>({value:e.value,label:e.label})),ariaLabel:`Auth type`}),l&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l})]})}),(0,X.jsx)(h,{name:`properties.allowJoinWithEmailOnly`,control:s.control,render:({field:e})=>(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`allow-email-only`,checked:e.value??!1,onChange:t=>e.onChange(t.target.checked),className:`rounded border-input`}),(0,X.jsx)(`label`,{htmlFor:`allow-email-only`,className:`text-sm font-medium`,children:`Allow join with email only`})]}),(0,X.jsx)(`p`,{className:`pl-6 text-xs text-muted-foreground`,children:`When invited through other systems (e.g. calendar), participants can join by entering just their email.`})]})})]}),!n&&!r&&(0,X.jsxs)(TM,{title:`Participants`,children:[(0,X.jsx)(h,{name:`properties.sendInvitations`,control:s.control,render:({field:e})=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`send-invitations`,checked:e.value??!0,onChange:t=>e.onChange(t.target.checked),className:`rounded border-input`}),(0,X.jsx)(`label`,{htmlFor:`send-invitations`,className:`text-sm font-medium`,children:`Send invitations`})]})}),s.watch(`properties.sendInvitations`)&&(0,X.jsx)(h,{name:`properties.participantsVisibleToOthers`,control:s.control,render:({field:e})=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`input`,{type:`checkbox`,id:`participants-visible`,checked:e.value??!0,onChange:t=>e.onChange(t.target.checked),className:`rounded border-input`}),(0,X.jsx)(`label`,{htmlFor:`participants-visible`,className:`text-sm font-medium`,children:`Include attendee list in invitation emails`})]})}),(0,X.jsx)(PM,{participants:e,onChange:t}),a&&o&&(0,X.jsxs)(U,{variant:`outline`,size:`sm`,type:`button`,onClick:o,disabled:i,className:`gap-1.5`,children:[i?(0,X.jsx)(An,{className:`size-3.5`,"aria-hidden":!0}):(0,X.jsx)(Ii,{className:`size-3.5`,"aria-hidden":!0}),`Send invitations`]})]})]})}var IM=new Date(Date.now()).setMinutes(0,0,0)+0,LM=new Date(IM).setMinutes(0,0,0)+864e5;function RM(e){let{organizationSlug:t,eventId:n}=S(),r=c(),i=C(),a=fe(),{activeOrganization:o,hasPermissions:s}=z(),u=md(),[d,f]=(0,Y.useState)([]),p=ie(),m=R(),h=i.state??{},g=s(u,`organization`,`update`),_=h.eventType,v=_===`webinar`&&!g?`meeting`:_,y=n?Xn(n):!1,{data:b,isLoading:x}=V(m.event.list.queryOptions({sorting:[{id:`slug`,desc:!1}],organizationId:u}
117)),w=(y?n:b?.items.find(e=>e.slug===n)?.id)??void 0,T=m.event.get.queryKey([w??``]),E=m.event.list.queryKey({organizationId:o?.id}),D=l({resolver:pn(_M),mode:`onSubmit`,defaultValues:{name:h.title??``,slug:``,description:h.description??``,startAt:h.startDate?new Date(h.startDate):new Date(IM),endAt:h.endDate?new Date(h.endDate):new Date(LM),worldId:h.preSelectedWorldId??h.worldId??``,timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,properties:{type:v??`meeting`,authType:h.authType??`auth`,requireEmailVerification:!1,participantTransformLimit:100,chat:`enabled`,screenSharing:`presenters`,lockMeeting:!1,waitingRoom:!1,requirePasscode:!1,passcode:``,allowJoinWithEmailOnly:!1,allowParticipantsToUnmute:!0,muteParticipantsOnEntry:!1,raiseHand:!0,enableReactions:!0,sendInvitations:!0,participantsVisibleToOthers:!0}}}),{data:O,isLoading:k}=V(m.event.get.queryOptions([w??``],{enabled:e===`edit`&&!!w})),{data:A}=V(m.eventInvitations.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],eventId:w??``},{enabled:e===`edit`&&!!w}));(0,Y.useEffect)(function(){A?.items?.length&&f(A.items.map(e=>({id:e.id??crypto.randomUUID(),value:e.email,type:e.email.startsWith(`*@`)?`domain`:`email`,status:e.status})))},[A]);let j=B({mutationFn:async()=>{w&&await p.eventInvitations.sendInvitations.mutate({eventId:w,allowResend:!0})},onSuccess:()=>{J.success(`Invitations sent successfully`)},onError:e=>{console.error(`Failed to send invitations:`,e),J.error(`Failed to send invitations`)}}),M=(0,Y.useCallback)(async()=>{w&&A?.items?.length&&await j.mutateAsync()},[w,A,j]),N=(0,Y.useCallback)(async(e,t)=>{let n=(await p.world.get.query([t]))[0];if(!n)return;let r=n.spaces.find(e=>e.isDefault)?.id??n.spaces[0]?.id;r&&await p.event.updateState.mutate({eventId:e,state:{segment:r,selectedSpaceId:r}})},[p]),P=B({mutationFn:async({event:e,invitedEmails:t})=>{let[n]=await p.event.create.mutate([e]);if(!n?.id)throw Error(`Failed to create event`);return t.length>0&&await p.eventInvitations.import.mutate({eventId:n.id,emails:t,replace:!1}),e.properties?.sendInvitations&&(console.log(`sending invitations`,n.id,e),await p.eventInvitations.sendInvitations.mutate({eventId:n.id})),e.worldId&&await N(n.id,e.worldId),n},onSuccess:()=>{a.invalidateQueries({queryKey:E}),J.success(Z(`components.form.event.create.success`)),r(`/${o?.slug}/dashboard/events/`)},onError:e=>{console.error(`Failed to create event:`,e)}}),F=B({mutationFn:async({event:e,invitedEmails:t})=>{await p.event.update.mutate([e]);let n=new Set((A?.items??[]).map(e=>e.email)),r=t.filter(e=>!n.has(e));r.length>0&&await p.eventInvitations.import.mutate({eventId:e.id,emails:r,replace:!1}),e.properties?.sendInvitations&&(console.log(`sending invitations`,e.id,e),await p.eventInvitations.sendInvitations.mutate({eventId:e.id}));let{worldId:i}=e;i&&await N(e.id,i)},onSuccess:()=>{a.invalidateQueries({queryKey:T}),a.invalidateQueries({queryKey:E}),J.success(Z(`components.form.event.edit.success`)),r(`/${o?.slug}/dashboard/events/`)},onError:e=>{console.error(`Failed to update event:`,e)}}),I=x||k,L=P.isPending||F.isPending,ee=async t=>{let n=_M.parse(t);if(!o?.id){J.error(`No active organization found`);return}let r=d.map(e=>e.value),i={name:n.name,description:n.description??``,startAt:n.startAt,endAt:n.endAt,properties:n.properties,organizationId:o.id,slug:n.slug,worldId:n.worldId};try{if(e===`edit`){let e=n.id??w;if(!e){J.error(`Missing event id`);return}await F.mutateAsync({event:{id:e,...i},invitedEmails:r})}else await P.mutateAsync({event:{...i,id:xr()},invitedEmails:r})}catch(t){console.error(`Event operation failed:`,t);let n=t instanceof Error?t.message:`Unknown error occurred`;J.error(e===`create`?`Failed to create event: ${n}`:`Failed to update event: ${n}`)}};(0,Y.useEffect)(function(){let t=O?.[0];t&&e===`edit`&&D.reset({name:t.name,id:t.id,description:t.description,startAt:t.startAt,endAt:t.endAt,slug:t.slug,worldId:t.worldId,properties:t.properties})},[O,e]);let te=(0,Y.useCallback)(()=>{t&&r(`/${t}/dashboard/events`)},[t,r]);return{form:D,activeOrganization:o,canUseWebinar:g,participants:d,setParticipants:f,isLoadingFormData:I,isSubmitting:L,isSendingInvitations:j.isPending,hasInvitations:(A?.items?.length??0)>0,handleSubmit:ee,handleBack:te,handleSendInvitations:M}}var zM=({type:e})=>{let{form:t,activeOrganization:n,canUseWebinar:r,participants:i,setParticipants:a,isLoadingFormData:o,isSubmitting:s,isSendingInvitations:c,hasInvitations:l,handleSubmit:u,handleBack:d,handleSendInvitations:f}=RM(e),p=t.watch(`properties.type`),m=pM.find(e=>e.value===p)?.description,g=pM.filter(e=>r||e.value!==`webinar`),v=e===`create`?`create-event-form`:`edit-event-form`;return e===`edit`&&o?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center py-10`,children:(0,X.jsx)(An,{className:`h-6 w-6`})}):(0,X.jsx)(_,{...t,children:(0,X.jsxs)(`form`,{onSubmit:t.handleSubmit(u),id:v,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(CE,{title:Z(e===`edit`?`common.edit.event`:`common.create.event`),actions:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,"data-quick-help":`event-actions`,children:[(0,X.jsx)(U,{variant:`outline`,size:`sm`,type:`button`,onClick:d,children:`Cancel`}),(0,X.jsxs)(U,{type:`submit`,disabled:s,form:v,children:[s&&(0,X.jsx)(An,{className:`mr-2 size-4`}),e===`edit`?`Save`:`Create event`]})]})}),(0,X.jsxs)(wE,{className:`space-y-6`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,"data-quick-help":`event-type`,children:[(0,X.jsx)(`label`,{className:`block text-sm font-medium`,children:`Event type`}),(0,X.jsx)(h,{name:`properties.type`,control:t.control,render:({field:e})=>(0,X.jsx)(wM,{value:e.value,onChange:e.onChange,options:g.map(e=>({value:e.value,label:e.label,className:fM[e.value]})),ariaLabel:`Event type`})}),m&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:m})]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 overflow-visible md:grid-cols-[3fr_2fr]`,children:[(0,X.jsx)(EM,{organizationSlug:n?.slug}),(0,X.jsx)(FM,{participants:i,onParticipantsChange:a,isLoadingFormData:o,isSubmitting:s,isSendingInvitations:c,hasInvitations:l,onSendInvitations:f})]})]})]})})};zM.displayName=`FormEvent`;var BM=()=>(0,X.jsx)(zM,{type:`create`});BM.displayName=`CreateEvent`;var VM=lt({name:H().min(1),slug:H().min(1),description:H().optional(),spaces:Yt(lt({id:H(),name:H(),isDefault:be()})).optional(),thumbnailId:H().uuid().optional(),thumbnail:lt({id:H(),metadata:kn(H(),et()),mimetype:H(),type:H(),url:H().optional()}).optional()}),HM=()=>{let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(!1),i=R(),{activeOrganization:a}=z(),[o,s]=(0,Y.useState)(null),u=fe(),d=c(),f=i.world.list.queryKey();function p(e){r(!1),d(`/${a?.slug}/dashboard/worlds/${e}/edit`)}let m=i.world.create.mutationOptions({onSuccess:(e,t)=>
117{u.invalidateQueries({queryKey:f}),setTimeout(()=>{p(t[0]?.slug||``)},1500)},onError:()=>{J.error(Z(`components.form.world.form.create.error`)),t(!1)}}),g=B(m),v=l({resolver:pn(VM),defaultValues:{name:``,description:``,slug:``,spaces:[]}}),b=y({control:v.control,name:`name`}),x=(0,Y.useRef)(``);(0,Y.useEffect)(function(){let e=v.getValues(`slug`),t=x.current?Bd(x.current):``;b&&(e===``||e===t)&&v.setValue(`slug`,Bd(b)),x.current=b??``},[b,v]),(0,Y.useEffect)(function(){if(!o)return;let e=P.get$(`file.response`).pipe(O(e=>e.source===o)).subscribe(e=>{if(e.payload&&`files`in e.payload){let t=e.payload.files[0];t&&(v.setValue(`thumbnail`,t),v.setValue(`thumbnailId`,t.id)),s(null)}});return()=>{e.unsubscribe()}},[o,v]);let S=()=>{let e=xr();s(e),P.publish({type:`file.request`,id:e,payload:{fileType:`image`,multiple:!1,title:`Select World Thumbnail`,uploadOnly:!1}})},C=()=>{v.setValue(`thumbnail`,void 0),v.setValue(`thumbnailId`,void 0)},w=e=>{if(!a?.id)return;t(!0);let n=xr(),r=e.thumbnailId&&e.thumbnail?{type:`file`,id:e.thumbnailId,mimetype:e.thumbnail.mimetype,metadata:e.thumbnail.metadata,url:e.thumbnail.url}:void 0,i={name:e.name,id:n,description:e.description,slug:e.slug,organizationId:a.id,spaces:e.spaces?.map(e=>e)||[],thumbnailId:e.thumbnailId,thumbnail:r};try{g.mutateAsync([i]),J.success(Z(`common.world.created.successfully`))}catch(e){console.error(`Error submitting world`,e),v.setError(`slug`,{message:`Error submitting world`})}finally{v.reset({name:``,description:``,slug:``,spaces:[]})}};return(0,X.jsxs)(ar,{open:n,onOpenChange:r,children:[(0,X.jsx)(vr,{render:e=>(0,X.jsxs)(U,{...e,"data-quick-help":`create-world`,children:[(0,X.jsx)(Ci,{}),Z(`common.create.world`)]})}),(0,X.jsxs)(pr,{className:`max-h-[90vh] max-w-3xl overflow-y-auto`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:Z(`common.create.world`)}),(0,X.jsx)(_r,{children:Z(`components.form.world.form.create.description`)})]}),(0,X.jsxs)(_,{...v,children:[(0,X.jsx)(`div`,{className:q(`pointer-events-none fixed inset-0 top-0 left-0 z-999 flex h-full w-full items-center justify-center`,e?`bg-background opacity-100`:`bg-transparent opacity-0`),children:(0,X.jsx)(An,{className:`size-10`})}),(0,X.jsxs)(`form`,{className:`relative flex w-full flex-col gap-4`,onSubmit:v.handleSubmit(w),children:[(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-4`,children:[(0,X.jsx)(h,{control:v.control,name:`name`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`common.name`)}),(0,X.jsx)(W,{placeholder:`World Name`,...e,className:``,autoComplete:`off`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(UM,{formControl:v.control}),(0,X.jsx)(h,{control:v.control,name:`description`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`common.description`)}),(0,X.jsx)(W,{placeholder:`World Description`,...e}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:v.control,name:`thumbnail`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:`Thumbnail`}),(0,X.jsx)(`div`,{className:`flex aspect-video max-h-48 cursor-pointer flex-col items-center justify-center gap-2 rounded-md bg-muted/40 transition-colors hover:bg-muted`,onClick:S,children:e.value?.url?(0,X.jsx)(`img`,{src:e.value.url,alt:`World Thumbnail`,className:`h-full w-full rounded-md object-cover`,onError:e=>{console.error(`Error loading thumbnail`,e)}},e.value.url):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,X.jsx)(oo,{className:`h-6 w-6 text-muted-foreground`})}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select or Upload Thumbnail`})]})}),e.value?.id&&(0,X.jsxs)(`button`,{type:`button`,className:`flex w-full flex-row items-center justify-between gap-2 rounded-b-md bg-muted px-4 py-1`,onClick:C,children:[(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.value.url?e.value.url.split(`/`).pop():e.value.id}),(0,X.jsx)(Tr,{className:`size-4 shrink-0 text-red-500`})]}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})})]}),(0,X.jsxs)(U,{type:`submit`,className:`z-10`,children:[(0,X.jsx)(Ci,{}),g.isPending?(0,X.jsx)(An,{}):Z(`common.create.world`)]})]})]})]})]})};HM.displayName=`WorldForm`;var UM=({formControl:e})=>{let t=y({control:e,name:`slug`}),{activeOrganization:n}=z();return(0,X.jsx)(h,{control:e,name:`slug`,render:({field:e,fieldState:r})=>{let i=t=>{e.onChange(Bd(t))};
117return(0,X.jsxs)(G,{"data-invalid":r.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`common.world.address.slug`)}),(0,X.jsxs)(Me,{children:[(0,X.jsx)(Ve,{children:(0,X.jsx)(St,{children:`https://www.storyverse.fi/${n?.slug}/worlds/`})}),(0,X.jsx)(ze,{value:t||``,onChange:e.onChange,onBlur:e=>i(e.target.value),placeholder:`slug`,className:`pl-0.5! font-semibold`}),(0,X.jsx)(Ve,{align:`inline-end`,children:(0,X.jsxs)(Pn,{children:[(0,X.jsx)(dr,{render:e=>(0,X.jsx)(an,{className:`rounded-full`,size:`icon-xs`,...e,children:(0,X.jsx)(ua,{})})}),(0,X.jsx)(Gn,{children:Z(`components.form.world.form.slug.tooltip`)})]})})]}),r.invalid&&(0,X.jsx)(kt,{errors:[r.error]})]})}})},WM=()=>(0,X.jsx)(HM,{});WM.displayName=`CreateWorld`;var GM=()=>Sd({scope:`event`,action:`update`,fallback:`..`})||(0,X.jsx)(zM,{type:`edit`});GM.displayName=`EditEvent`;var KM=e=>e===`sent`?`default`:e===`pending`?`secondary`:e===`failed`?`destructive`:`outline`,qM=()=>{let e=R(),t=fe(),n=c(),{emailId:r}=S(),i=r,a=l({defaultValues:{id:``,from:``,to:[],cc:[],bcc:[],replyTo:``,subject:``,bodyHtml:``,bodyText:``}}),{data:o,isLoading:s,isError:u}=V(e.email.get.queryOptions(i?[i]:[],{enabled:!!i})),d=(0,Y.useMemo)(()=>o?.[0],[o]);(0,Y.useEffect)(function(){d&&a.reset({id:d.id,from:d.from,to:d.to??[],cc:d.cc??[],bcc:d.bcc??[],replyTo:d.replyTo??``,subject:d.subject,bodyHtml:d.bodyHtml??``,bodyText:d.bodyText??``})},[d,a]);let f=e.email.list.queryKey({sorting:[{id:`createdAt`,desc:!0}]}),p=e.email.update.mutationOptions({onSuccess:()=>{t.invalidateQueries({queryKey:f}),J.success(Z(`routes.emails.update.success`)),n(-1)},onError:e=>{console.error(`Failed to update email:`,e),J.error(Z(`routes.emails.update.error`))}}),m=B(p),g=e=>{e.id&&m.mutate([{id:e.id,from:e.from,to:e.to,cc:e.cc,bcc:e.bcc,replyTo:e.replyTo,subject:e.subject,bodyHtml:e.bodyHtml,bodyText:e.bodyText}])};return i?s?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`common.loading`)})}):u||!d?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`routes.emails.not.found`)})}):(0,X.jsxs)(`div`,{className:`flex w-full flex-col gap-4 py-6`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`icon`,onClick:()=>n(-1),className:`shrink-0`,children:(0,X.jsx)(Ca,{className:`size-4`})}),(0,X.jsx)(`h1`,{className:`truncate text-2xl font-bold`,children:d.subject}),(0,X.jsx)(fr,{variant:KM(d.status??``),children:d.status})]}),(0,X.jsxs)(`p`,{className:`pl-10 text-sm text-muted-foreground`,children:[`From `,(0,X.jsx)(`span`,{className:`font-medium`,children:d.from}),` →`,` `,d.to?.join(`, `)]})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 gap-2`,children:[(0,X.jsxs)(U,{type:`button`,variant:`outline`,onClick:()=>n(-1),children:[(0,X.jsx)(Ca,{className:`size-4`}),`Back`]}),(0,X.jsxs)(U,{type:`button`,onClick:a.handleSubmit(g),disabled:m.isPending,children:[m.isPending?(0,X.jsx)(An,{className:`size-4`}):(0,X.jsx)(io,{className:`size-4`}),`Save`]})]})]}),(0,X.jsxs)(Fo,{children:[(0,X.jsx)(Io,{children:(0,X.jsx)(Lo,{children:Z(`routes.emails.edit.details`)})}),(0,X.jsx)(zo,{className:`space-y-4`,children:(0,X.jsxs)(`form`,{className:`space-y-4`,onSubmit:a.handleSubmit(g),children:[(0,X.jsx)(h,{name:`from`,control:a.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`from`,children:`From`}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{id:`from`,...e})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{name:`to`,control:a.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`to`,children:`To`}),(0,X.jsx)(ln,{children:(0,X.jsx)(bt,{id:`to`,value:e.value?.join(`, `)??``,onChange:t=>e.onChange(t.target.value.split(`,`).map(e=>
117e.trim()).filter(Boolean)),rows:2})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{name:`cc`,control:a.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`cc`,children:`Cc`}),(0,X.jsx)(ln,{children:(0,X.jsx)(bt,{id:`cc`,value:e.value?.join(`, `)??``,onChange:t=>e.onChange(t.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),rows:2})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{name:`bcc`,control:a.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`bcc`,children:`Bcc`}),(0,X.jsx)(ln,{children:(0,X.jsx)(bt,{id:`bcc`,value:e.value?.join(`, `)??``,onChange:t=>e.onChange(t.target.value.split(`,`).map(e=>e.trim()).filter(Boolean)),rows:2})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{name:`replyTo`,control:a.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`replyTo`,children:`Reply-To`}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{id:`replyTo`,...e})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{name:`subject`,control:a.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`subject`,children:`Subject`}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{id:`subject`,...e})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{name:`bodyText`,control:a.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`bodyText`,children:`Body (text)`}),(0,X.jsx)(ln,{children:(0,X.jsx)(bt,{id:`bodyText`,rows:6,...e})}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})})]})})]}),(0,X.jsxs)(Fo,{children:[(0,X.jsx)(Io,{children:(0,X.jsx)(Lo,{children:Z(`routes.emails.edit.metadata`)})}),(0,X.jsx)(zo,{children:(0,X.jsxs)(`dl`,{className:`grid grid-cols-2 gap-x-6 gap-y-3 text-sm sm:grid-cols-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`dt`,{className:`text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Status`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(fr,{variant:KM(d.status??``),children:d.status??`-`})})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`dt`,{className:`text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Created`}),(0,X.jsx)(`dd`,{className:`font-medium`,children:$i(d.createdAt,`dd MMM yyyy HH:mm`)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`dt`,{className:`text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Updated`}),(0,X.jsx)(`dd`,{className:`font-medium`,children:$i(d.updatedAt,`dd MMM yyyy HH:mm`)})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5`,children:[(0,X.jsx)(`dt`,{className:`text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Sent`}),(0,X.jsx)(`dd`,{className:`font-medium`,children:d.sentAt?$i(d.sentAt,`dd MMM yyyy HH:mm`):(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`—`})})]}),d.externalMessageId&&(0,X.jsxs)(`div`,{className:`col-span-2 flex flex-col gap-0.5 sm:col-span-4`,children:[(0,X.jsx)(`dt`,{className:`text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:`Provider message ID`}),(0,X.jsx)(`dd`,{className:`truncate font-mono text-xs`,children:d.externalMessageId})]})]})})]})]}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`routes.emails.missing.id`)})})};qM.displayName=`EmailEdit`;var JM=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`}),enableSorting:!1,enableHiding:!1},{accessorKey:`to`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.emails.columns.to`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:``,children:e.original.to.join(`, `)})},{accessorKey:`status`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.status`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:``,children:e.original.status})},{accessorKey:`createdAt`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.created.at`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:``,children:$i(e.original.createdAt,`dd-MM-yyyy HH:mm`)})},{accessorKey:`updatedAt`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.updated.at`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:``,children:$i(e.original.updatedAt,`dd-MM-yyyy HH:mm`)})},{accessorKey:`sentAt`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.emails.columns.sent.at`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:``,children:e.original.sentAt?$i(e.original.sentAt,`dd-MM-yyyy HH:mm`):``})},{id:`actions`,cell:()=>(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{variant:`ghost`,className:`h-8 w-8 p-0`,...e,children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(xe,{}),(0,X.jsxs)(st,{children:[(0,X.jsx)(Qi,{className:`h-4 w-4 text-red-500`}),(0,X.jsx)(`span`,{className:`text-red-500`,children:Z(`routes.emails.columns.delete.email`)})]})]})})]})}],YM=()=>{let e=R(),{data:t,isLoading:n,isError:r}=V(e.email.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}]}));return n?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{className:`h-10 w-10`})}):r?(0,X.jsx)(`div`,{children:Z(`routes.emails.error`)}):t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.emails`)}
117),(0,X.jsx)(wE,{children:(0,X.jsx)(pd,{columns:JM,data:t.items,navigateTo:{key:`id`,additionalPath:`edit`}})})]}):(0,X.jsx)(`div`,{children:Z(`routes.emails.no.emails.found`)})};YM.displayName=`Emails`;function XM({id:e,deleteRow:t,title:n,description:r,open:i,setOpen:a,confirmText:o}){let[s,c]=(0,Y.useState)(``),l=!o||s===o,u=`delete-confirm-${e}`,d=e=>{e||c(``),a(e)};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(st,{variant:`destructive`,closeOnClick:!1,onClick:()=>a(!0),children:[(0,X.jsx)(Qi,{className:`size-4 text-red-500`}),(0,X.jsx)(`span`,{className:`text-red-500`,children:n})]}),(0,X.jsx)(ar,{open:i,onOpenChange:d,children:(0,X.jsxs)(pr,{children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:`Are you absolutely sure?`}),(0,X.jsx)(_r,{children:r??`This action cannot be undone. This will permanently delete the item and remove it from the database.`})]}),o&&(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)($t,{htmlFor:u,children:Z(`components.table.row.delete.confirm.label`).replace(`{{text}}`,o)}),(0,X.jsx)(W,{id:u,type:`text`,autoComplete:`off`,value:s,onChange:e=>c(e.target.value),onKeyDown:e=>e.stopPropagation(),placeholder:o})]}),(0,X.jsxs)(lr,{children:[(0,X.jsxs)(yr,{render:(0,X.jsx)(U,{variant:`outline`}),children:[(0,X.jsx)(Xa,{className:`size-4`}),`Cancel`]}),(0,X.jsxs)(U,{variant:`destructive`,disabled:!l,onClick:async()=>{try{await t(e),d(!1)}catch(e){console.error(`Failed to delete row:`,e)}},children:[(0,X.jsx)(Qi,{className:``}),`Delete`]})]})]})})]})}var ZM=({organizationSlug:e,eventSlug:t,onCloseMenu:n})=>{let r=b(`/${e}/events/${t}`),{copyToClipboard:i}=gd(),[a,o]=(0,Y.useState)(null),s=c(),l=async()=>{let n=typeof window<`u`?new URL(`/${e}/events/${t}`,window.location.origin).toString():`/${e}/events/${t}`;try{await i(n),J.success(`Link copied to clipboard`)}catch{J.error(`Failed to copy link to clipboard`)}},u=e=>{o(e?`new`:`same`),setTimeout(()=>{e?window.open(r,`_blank`):s(r),o(null),n?.()},1500)},d=[{label:Z(`common.join.event`),icon:(0,X.jsx)(Wa,{className:`size-4`}),loadingKey:`same`,onClick:()=>{u(!1)}},{label:Z(`routes.events.columns.join.in.new.window`),icon:(0,X.jsx)(_a,{className:`size-4`}),target:`_blank`,loadingKey:`new`,onClick:()=>{u(!0)}},{label:Z(`common.copy.link`),icon:(0,X.jsx)(pi,{className:`size-4`}),onClick:()=>{l()}}],f=a!==null;return(0,X.jsx)(X.Fragment,{children:d.map(e=>{let t=`loadingKey`in e&&a===e.loadingKey;return(0,X.jsxs)(st,{onClick:e.onClick,disabled:f,closeOnClick:`loadingKey`in e?!1:void 0,children:[t?(0,X.jsx)(An,{className:`size-4`}):e.icon,e.label]},e.label)})})},QM=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>{e.toggleSelected(!!t)},"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`name`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Name`}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.name})},{accessorKey:`properties`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Type`}),cell:({row:e})=>{let t=e.original.properties?.type;if(!t)return(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`—`});let n=dM[t]??t,r=fM[t];return(0,X.jsx)(fr,{variant:`outline`,className:r??``,children:n})}},{accessorKey:`startAt`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Starts`}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.startAt?$i(e.original.startAt,`MMM d, HH:mm`):`—`})},{accessorKey:`description`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Description`}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`max-w-37.5 truncate text-muted-foreground`,title:e.original.description||void 0,children:e.original.description||`—`}),enableHiding:!0},{id:`actions`,cell:({row:e})=>(0,X.jsx)($M,{row:e})}],$M=({row:e})=>{let t=e.original,{activeOrganization:n,hasPermissions:r}=z(),i=md(),a=r(i,`event`,`update`),o=r(i,`event`,`delete`),s=b(t.id),[c,l]=(0,Y.useState)(!1),d=(0,Y.useRef)(null),f=R(),p=fe(),m=f.event.list.queryKey(),h=f.event.remove.mutationOptions({onSuccess:()=>{p.invalidateQueries({queryKey:m})}}
117),g=B(h),_=n?.slug||`movya-oy`,v=t.slug;return(0,X.jsxs)(nt,{actionsRef:d,children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,variant:`ghost`,className:`z-50 h-8 w-8 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsxs)(Ue,{children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(ZM,{organizationSlug:_,eventSlug:v,onCloseMenu:()=>d.current?.close?.()}),a&&(0,X.jsx)(st,{nativeButton:!1,render:e=>(0,X.jsxs)(u,{to:s,...e,children:[(0,X.jsx)(va,{className:`size-4`}),Z(`common.edit.event`)]})})]}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(xe,{}),(0,X.jsx)(XM,{id:t.id,title:Z(`routes.events.columns.delete.event`),deleteRow:async()=>await g.mutateAsync([t.id]),open:c,setOpen:l})]})]})]})},eN=()=>{let e=R(),{activeOrganization:t,hasPermissions:n}=z(),r=md(),i=n(r,`event`,`create`),a=n(r,`event`,`delete`),o=fe(),s=c(),{data:l,isLoading:u,isError:d}=V(e.event.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:r})),f=e.event.list.queryKey(),p=e.event.remove.mutationOptions({onSuccess:()=>{o.invalidateQueries({queryKey:f})}}),m=B(p);return u?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{className:`h-10 w-10`})}):d?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`routes.events.error`)})}):l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.events`),actions:i?(0,X.jsxs)(U,{onClick:()=>s(`/${t?.slug}/dashboard/events/create`),"data-quick-help":`create-event`,children:[(0,X.jsx)(zi,{className:``}),Z(`routes.events.create.event`)]}):void 0}),(0,X.jsx)(wE,{children:(0,X.jsx)(pd,{columns:QM,data:l.items,navigateTo:{key:`slug`},onDeleteSelected:a?async e=>{let t=e.map(e=>e.id);await m.mutateAsync(t)}:void 0,multipleDeleteString:{start:`Delete`,end:`event`}})})]}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`routes.events.no.events.found`)})})};eN.displayName=`Events`;var tN=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`name`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.files.columns.filename`)}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.filename})},{accessorKey:`sizeBytes`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.size`)}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.sizeBytes})},{accessorKey:`visibility`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.files.columns.visibility`)}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.visibility})},{accessorKey:`status`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.status`)}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.status})},{accessorKey:`mimetype`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.files.columns.mimetype`)}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.mimetype})},{id:`actions`,cell:({row:e})=>(0,X.jsx)(nN,{row:e})}],nN=({row:e})=>{let t=e.original,n=R(),r=fe(),i=n.files.list.queryKey(),[a,o]=(0,Y.useState)(!1),s=n.files.remove.mutationOptions({onSuccess:()=>{r.invalidateQueries({queryKey:i})}}),c=B(s);return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,variant:`ghost`,className:`h-8 w-8 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(xe,{}),t.url&&(0,X.jsxs)(st,{onClick:()=>navigator.clipboard.writeText(t.url),children:[(0,X.jsx)(pi,{className:`h-4 w-4`}
117),Z(`routes.files.columns.copy.url`)]}),(0,X.jsx)(XM,{id:t.id,title:Z(`routes.files.columns.delete.file`),deleteRow:async()=>await c.mutateAsync({ids:[t.id]}),open:a,setOpen:o})]})})]})},rN=()=>{let e=R(),t=md(),n=fe(),{data:r,isLoading:i,isError:a}=V(e.files.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:t},{select(e){return{...e,items:e.items.filter(e=>e.status!==`deleted`)}}})),o=e.files.list.queryKey(),s=e.files.remove.mutationOptions({onSuccess:()=>{n.invalidateQueries({queryKey:o})}}),c=B(s);return i?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{className:`h-10 w-10`})}):a?(0,X.jsx)(`div`,{children:Z(`routes.files.error`)}):r?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.files`),actions:(0,X.jsxs)(U,{className:`h-8 text-[13px]`,onClick:()=>{P.publish({type:`file.request`,id:xr(),payload:{fileType:`any`,multiple:!0,title:`Select a file`,uploadOnly:!0,selectUploadedFile:!1}})},children:[(0,X.jsx)(Ci,{className:`size-5`}),Z(`routes.files.upload.file`)]})}),(0,X.jsx)(wE,{children:(0,X.jsx)(pd,{columns:tN,data:r.items.map(e=>({...e,url:e.url??``})),onDeleteSelected:async e=>{let t=e.map(e=>e.id);await c.mutateAsync({ids:t})},multipleDeleteString:{start:`Delete`,end:`file`}})})]}):(0,X.jsx)(`div`,{children:Z(`routes.files.no.files.found`)})};rN.displayName=`Files`;var iN=({className:e,...t})=>(0,X.jsx)(`div`,{className:q(`flex min-h-svh items-center justify-center bg-muted/50 p-4 sm:p-6`,e),...t,children:(0,X.jsx)(us,{})});iN.displayName=`ForgotPassword`;function aN(){let{session:e,isLoadingSession:t}=z(),[n]=(0,Y.useState)(()=>typeof window>`u`?!1:new URLSearchParams(window.location.search).get(`deleted`)===`1`),[r,i]=(0,Y.useState)(10),a=c();return(0,Y.useEffect)(function(){if(!n)return;let e=new URL(window.location.href);e.searchParams.delete(`deleted`),window.history.replaceState(null,``,e.toString())},[n]),(0,Y.useEffect)(function(){async function e(){await a(`/`)}r===0&&e();let t=setInterval(()=>{i(r-1)},1e3);return()=>clearInterval(t)},[r,a]),t?(0,X.jsx)(`div`,{className:`flex h-svh w-svw items-center justify-center`,role:`status`,"aria-label":Z(`views.goodbye.loading`),children:(0,X.jsx)(An,{className:`size-10`})}):e||!n?(0,X.jsx)(m,{to:`/`,replace:!0}):(0,X.jsx)(`main`,{className:`flex min-h-svh items-center justify-center bg-background px-6`,children:(0,X.jsxs)(`div`,{className:`flex max-w-md flex-col items-center gap-6 text-center`,children:[(0,X.jsx)(`img`,{src:`/assets/sidebar-logo.png`,alt:`Storyverse`,className:`h-auto w-45 object-contain`}),(0,X.jsx)(`h1`,{className:`text-4xl font-extrabold tracking-tight text-foreground`,children:Z(`views.goodbye.title`)}),(0,X.jsx)(`p`,{className:`text-lg text-muted-foreground`,children:Z(`views.goodbye.body`)}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`views.goodbye.thanks`)}),(0,X.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`You will be redirected to the home page in `,r,` seconds.`]})]})})}var oN=[`meeting`,`webinar`,`solo-experience`],sN=()=>{let{hasPermissions:e}=z(),t=md();return(0,Y.useMemo)(()=>{let n=e(t,`event`,`create`),r=e(t,`organization`,`update`),i=e(t,`event`,`list`);return{canCreateEvents:n,allowedEventTypes:n?oN.filter(e=>r||e!==`webinar`):[],canViewWorlds:e(t,`world`,`list`),canEditWorlds:e(t,`world`,`update`),canCreateWorlds:e(t,`world`,`create`),canViewRecentItems:i,usesEvents:i}},[t,e])},cN=()=>{let{activeOrganization:e}=z(),t=R(),n=fe(),r=c(),{organizationSlug:i}=S(),a=sN(),[o,s]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),_=md(),v=t.event.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:_},{enabled:a.usesEvents}),{data:y}=V(v),{data:b}=V(t.world.list.queryOptions({sorting:[{id:`updatedAt`,desc:!0}],organizationId:_},{enabled:a.canViewWorlds})),x=ie(),C=B({mutationFn:async({event:e,invitedEmails:t})=>{let[n]=await x.event.create.mutate([e]);if(!n?.id)throw Error(`Failed to create event`);return t.length>0&&await x.eventInvitations.import.mutate({eventId:n.id,emails:t,replace:!1}),e.properties?.sendInvitations&&await x.eventInvitations.sendInvitations.mutate({eventId:n.id}),n},onSuccess:()=>{n.invalidateQueries({queryKey:v.queryKey}),J.success(`Event created`)},onError:()=>{J.error(`Failed to create event`)}}),w=t.event.remove.mutationOptions({onSuccess:()=>{n.invalidateQueries({queryKey:v.queryKey}),J.success(`Event successfully deleted`)}}),T=B(w),E=(0,Y.useCallback)(async e=>{await T.mutateAsync([e])},[T]),D=y?.items;return{activeOrganization:e,capabilities:a,events:y,worlds:b,eventDetailEvent:(0,Y.useMemo)(()=>!o||!D?null:D.find(e=>e.id===o)??null,[o,D]),createEventOpen:l,createEventWorldId:d,createEventType:p,createEventDate:h,createEventMutation:C,handleCreateEvent:(0,Y.useCallback)((e,t)=>{f(null),m(e),g(t??null),u(!0)},[]),handleCreateEventFromWorld:(0,Y.useCallback)((e,t)=>{f(e),m(t),u(!0)},[]),handleCloseCreateEvent:(0,Y.useCallback)(()=>{u(!1),f(null),m(null),g(null)},[]),handleOpenWorld:(0,Y.useCallback)(e=>{let t=b?.items?.find(t=>
117t.id===e);i&&t&&r(`/${i}/dashboard/worlds/${t.slug}`)},[i,r,b?.items]),handleEditWorld:(0,Y.useCallback)(e=>{let t=b?.items?.find(t=>t.id===e);i&&t&&r(`/${i}/dashboard/worlds/${t.slug}/edit`)},[i,r,b?.items]),handleSeeMoreWorlds:(0,Y.useCallback)(()=>{i&&r(`/${i}/dashboard/worlds`)},[i,r]),getWorldOpenUrl:(0,Y.useCallback)(e=>i?`/${i}/worlds/${e.slug}`:``,[i]),handleOpenEvent:(0,Y.useCallback)(e=>{s(e)},[]),handleCloseEventDetail:(0,Y.useCallback)(()=>{s(null)},[]),handleJoinEvent:(0,Y.useCallback)(e=>{let t=y?.items?.find(t=>t.id===e);i&&t&&window.open(`/${i}/events/${t.slug}`,`_blank`)},[i,y?.items]),handleEditEvent:(0,Y.useCallback)(e=>{let t=y?.items?.find(t=>t.id===e);i&&r(`/${i}/dashboard/events/${t?.slug}`)},[i,r,y?.items]),handleDeleteEvent:E}},lN=(0,Y.createContext)(null),uN=({children:e})=>{let t=cN();return(0,X.jsx)(lN,{value:t,children:e})},dN=()=>{let e=(0,Y.use)(lN);if(!e)throw Error(`useHomeContext must be used within a HomeProvider`);return e};uN.displayName=`HomeProvider`;function fN(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}T${String(e.getHours()).padStart(2,`0`)}:${String(e.getMinutes()).padStart(2,`0`)}`}var pN=()=>new Date,mN=()=>{let e=new Date;return e.setHours(e.getHours()+1),e},hN=lt({title:H().min(1,`Event name is required`),eventType:Xe([`meeting`,`webinar`,`solo-experience`]),worldId:H().optional(),startDate:H().min(1,`Start date is required`),endDate:H().min(1,`End date is required`),description:H().optional()}).refine(e=>{let t=new Date(e.startDate);return new Date(e.endDate).getTime()>t.getTime()},{message:`End date must be after start date`,path:[`endDate`]});function gN(e){let t=e.trim();if(!t)return null;if(t.startsWith(`*@`)||t.startsWith(`@`)){let e=t.startsWith(`@`)?`*${t}`:t,n=e.slice(2);return!n||!n.includes(`.`)?null:{id:crypto.randomUUID(),value:e,type:`domain`}}return t.length<=254&&DM.test(t)?{id:crypto.randomUUID(),value:t,type:`email`}:null}function _N({worlds:e,value:t,onChange:n,className:r}){let i=e.find(e=>e.id===t);return(0,X.jsxs)(Vt,{value:t||``,onValueChange:e=>n(e??``),children:[(0,X.jsx)(Dn,{className:q(`w-full min-w-0 gap-2 px-2`,r),children:i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`size-6 shrink-0 overflow-hidden rounded bg-muted`,children:i.thumbnail?.url?(0,X.jsx)(`img`,{src:i.thumbnail.url,alt:``,className:`size-full object-cover`}):(0,X.jsx)(`div`,{className:`flex size-full items-center justify-center`,children:(0,X.jsx)(xi,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0})})}),(0,X.jsx)(`span`,{className:`min-w-0 truncate`,children:i.name})]}):(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`Select world`})}),(0,X.jsxs)(Dt,{align:`start`,alignItemWithTrigger:!1,children:[(0,X.jsxs)(yn,{value:``,className:`pr-2 pl-2`,children:[(0,X.jsx)(`div`,{className:`flex size-8 shrink-0 items-center justify-center rounded bg-muted`,children:(0,X.jsx)(xi,{className:`size-4 text-muted-foreground`,"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:`No world`})]}),e.map(e=>(0,X.jsxs)(yn,{value:e.id,className:`pr-2 pl-2`,children:[(0,X.jsx)(`div`,{className:`size-8 shrink-0 overflow-hidden rounded bg-muted`,children:e.thumbnail?.url?(0,X.jsx)(`img`,{src:e.thumbnail.url,alt:``,className:`size-full object-cover`}):(0,X.jsx)(`div`,{className:`flex size-full items-center justify-center`,children:(0,X.jsx)(xi,{className:`size-4 text-muted-foreground`,"aria-hidden":!0})})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 whitespace-normal`,children:[(0,X.jsx)(`span`,{className:`block truncate font-medium text-foreground`,children:e.name}),e.description&&(0,X.jsx)(`p`,{className:`mt-0.5 line-clamp-1 text-xs text-muted-foreground`,children:e.description})]})]},e.id))]})]})}function vN({participant:e,onRemove:t}){let n=e.type===`domain`;return(0,X.jsxs)(`span`,{role:`listitem`,title:e.value,className:q(`inline-flex max-w-55 shrink-0 items-center gap-1 rounded-full border px-2.5 py-1 text-xs font-medium`,n?`border-blue-200 bg-blue-50 text-blue-800 dark:border-blue-800 dark:bg-blue-950/50 dark:text-blue-300`:`border-border bg-muted text-foreground`),children:[n&&(0,X.jsx)(Na,{className:`size-3 shrink-0 text-blue-500`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`truncate`,children:e.value}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),"aria-label":`Remove ${e.value}`,className:q(`ml-0.5 shrink-0 rounded-full p-0.5 transition-colors`,n?`hover:bg-blue-200 dark:hover:bg-blue-800`:`hover:bg-muted-foreground
117/20`),children:(0,X.jsx)(so,{className:`size-2.5`,"aria-hidden":!0})})]})}var yN=()=>{let e=()=>Array.from({length:3}).map(()=>`abcdefghijklmnopqrstuvwxyz0123456789`[Math.floor(Math.random()*36)]).join(``);return`${e()}-${e()}-${e()}`},bN=({open:e,initialDate:t,initialEventType:n,initialWorldId:r,onClose:i})=>{let{capabilities:a,worlds:o,createEventMutation:s}=dN(),u=md(),d=a.allowedEventTypes,f=c(),{organizationSlug:p}=S(),m=(0,Y.useRef)(null),[g,v]=(0,Y.useState)([]),[y,b]=(0,Y.useState)(``),[x,C]=(0,Y.useState)(``),w=o?.items??[],T=(0,Y.useCallback)(()=>t?new Date(t):pN(),[t]),E=(0,Y.useCallback)(()=>{if(t){let e=new Date(t);return e.setHours(e.getHours()+1),e}return mN()},[t]),D=(0,Y.useCallback)(()=>({title:``,eventType:n??d[0]??`meeting`,worldId:r??``,startDate:fN(T()),endDate:fN(E()),description:``}),[n,d,r,T,E]),O=l({resolver:pn(hN),mode:`onSubmit`,defaultValues:D()});(0,Y.useEffect)(()=>{if(!e)return;O.reset(D());let t=setTimeout(()=>m.current?.focus(),0);return()=>clearTimeout(t)},[e,O,D]);let k=(0,Y.useCallback)(e=>{let t=e.split(/[,;\n\t]+/).map(e=>e.trim()).filter(Boolean),n=new Set(g.map(e=>e.value.toLowerCase())),r=[],i=[];for(let e of t){if(n.has(e.toLowerCase()))continue;let t=gN(e);t?(r.push(t),n.add(t.value.toLowerCase())):i.push(e)}return i.length>0?C(`Invalid: ${i.slice(0,2).join(`, `)}${i.length>2?` and ${i.length-2} more`:``}`):C(``),r.length>0&&v(e=>[...e,...r]),r.length>0},[g]),A=e=>{if(e.key===`Enter`||e.key===`,`){e.preventDefault();let t=y.trim().replace(/,$/,``);t&&k(t)&&b(``)}else e.key===`Backspace`&&y===``&&g.length>0&&v(e=>e.slice(0,-1)),C(``)},j=e=>{let t=e.clipboardData.getData(`text`);/[,;\n\t]/.test(t)&&(e.preventDefault(),k(t)&&b(``))},M=()=>{let e=y.trim();e&&k(e)&&b(``)},N=(0,Y.useCallback)(e=>{v(t=>t.filter(t=>t.id!==e))},[]),P=(0,Y.useCallback)(e=>{let t=e.eventType===`meeting`?yN():Bd(e.title.trim());s.mutate({event:{name:e.title.trim(),slug:t,organizationId:u,description:e.description||``,startAt:new Date(e.startDate),endAt:new Date(e.endDate),worldId:e.worldId||void 0,properties:{type:e.eventType,authType:`auth`,sendInvitations:g.length>0}},invitedEmails:g.map(e=>e.value)},{onSuccess:()=>{i()}})},[u,s,i,g]),F=(0,Y.useCallback)(()=>{if(!p)return;let e=O.getValues();f(`/${p}/dashboard/events/create`,{state:{eventType:e.eventType,title:e.title.trim()||void 0,worldId:e.worldId||void 0,preSelectedWorldId:r??void 0,startDate:new Date(e.startDate).toISOString(),endDate:new Date(e.endDate).toISOString(),description:e.description||void 0,attendees:g.length>0?g.map(e=>e.value).join(`, `):void 0}}),i()},[p,f,r,O,i,g]);return(0,X.jsx)(_,{...O,children:(0,X.jsxs)(`form`,{onSubmit:O.handleSubmit(P),children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border px-4 py-3`,children:[(0,X.jsx)(h,{control:O.control,name:`title`,render:({field:e})=>(0,X.jsx)(`input`,{...e,ref:t=>{e.ref(t),m.current=t},type:`text`,placeholder:`Add name`,className:`min-w-0 flex-1 bg-transparent text-base font-medium outline-none placeholder:text-muted-foreground`,"aria-label":`Event name`})}),(0,X.jsx)(`button`,{type:`button`,onClick:i,className:`shrink-0 rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,"aria-label":`Close`,children:(0,X.jsx)(so,{className:`size-5`,"aria-hidden":!0})})]}),(0,X.jsxs)(`div`,{className:`max-h-[70vh] overflow-y-auto p-4`,children:[O.formState.errors.title&&(0,X.jsx)(`div`,{className:`mb-3`,children:(0,X.jsx)(kt,{errors:[O.formState.errors.title]})}),d.length>1&&(0,X.jsx)(h,{control:O.control,name:`eventType`,render:({field:e})=>(0,X.jsxs)(`div`,{className:`mb-3 flex flex-col gap-2 py-1.5`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,X.jsx)(Ba,{className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),`Event type`]}),(0,X.jsx)(`div`,{className:`flex rounded-full border border-border bg-muted/30 p-0.5`,role:`radiogroup`,"aria-label":`Event type`,children:d.map(t=>(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":e.value===t,onClick:()=>e.onChange(t),className:q(`flex-1 rounded-full px-3 py-1.5 text-sm font-medium transition-colors`,e.value===t?fM[t]:`text-muted-foreground hover:text-foreground`),children:dM[t]},t))})]})}),d.length===1&&(0,X.jsxs)(`div`,{className:`mb-3 flex flex-col gap-2 py-1.5`,children:[(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm font-medium text-foreground`,children:[(0,X.jsx)(Ba,{className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),`Event type`]}
117),d[0]&&(0,X.jsx)(`span`,{className:q(`inline-flex w-fit rounded-md border px-2 py-1 text-xs font-medium`,fM[d[0]]),children:dM[d[0]]})]}),(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg py-1.5`,children:[(0,X.jsx)(bi,{className:`mt-2 size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`grid min-w-0 flex-1 grid-cols-2 gap-2`,children:[(0,X.jsx)(h,{control:O.control,name:`startDate`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{className:`text-xs text-muted-foreground`,children:`Start`}),(0,X.jsx)(bM,{value:e.value?new Date(e.value):void 0,onChange:t=>e.onChange(fN(t)),"aria-label":`Start date and time`,"aria-invalid":t.invalid}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:O.control,name:`endDate`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{className:`text-xs text-muted-foreground`,children:`End`}),(0,X.jsx)(bM,{value:e.value?new Date(e.value):void 0,onChange:t=>e.onChange(fN(t)),"aria-label":`End date and time`,"aria-invalid":t.invalid}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})})]})]}),(0,X.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg py-1.5`,children:[(0,X.jsx)(ti,{className:`mt-2 size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1 space-y-2`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsx)(W,{type:`text`,placeholder:`Add participants (email or *@domain.com)`,value:y,onChange:e=>{b(e.target.value),C(``)},onKeyDown:A,onPaste:j,onBlur:M,"aria-label":`Add participant`,"aria-invalid":!!x}),x&&(0,X.jsx)(`p`,{role:`alert`,className:`text-xs text-destructive`,children:x})]}),g.length>0&&(0,X.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,role:`list`,"aria-label":`Added participants`,children:g.map(e=>(0,X.jsx)(vN,{participant:e,onRemove:N},e.id))})]})]}),(0,X.jsx)(h,{control:O.control,name:`worldId`,render:({field:e})=>(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg py-1.5`,children:[(0,X.jsx)(xi,{className:`size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(_N,{worlds:w,value:e.value??``,onChange:e.onChange,className:`min-w-0 flex-1`})]})}),(0,X.jsx)(h,{control:O.control,name:`description`,render:({field:e})=>(0,X.jsxs)(`div`,{className:`flex items-start gap-3 rounded-lg py-1.5`,children:[(0,X.jsx)(ei,{className:`mt-0.5 size-5 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsx)(bt,{...e,placeholder:`Add description`,rows:2,className:`field-sizing-fixed min-h-0 min-w-0 flex-1 resize-none px-2 py-1.5`,"aria-label":`Add description`})]})})]})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-end gap-2 border-t border-border px-4 py-3`,children:[(0,X.jsx)(U,{type:`button`,variant:`outline`,onClick:F,children:`Advanced settings`}),(0,X.jsx)(U,{type:`submit`,children:`Create`})]})]})})};bN.displayName=`CreateEventForm`;var xN=()=>{let{createEventOpen:e,createEventDate:t,createEventType:n,createEventWorldId:r,handleCloseCreateEvent:i}=dN();return(0,X.jsx)(ar,{open:e,onOpenChange:e=>!e&&i(),children:(0,X.jsx)(pr,{className:`w-full max-w-lg p-0 sm:max-w-xl md:max-w-2xl`,showCloseButton:!1,children:(0,X.jsx)(bN,{open:e,initialDate:t,initialEventType:n,initialWorldId:r,onClose:i},`dialog-${e?`open`:`closed`}-${t?.toISOString()??``}-${n??``}-${r??``}`)})})};xN.displayName=`CreateEventModal`;var SN=({allowedEventTypes:e,onSelectEventType:t,buttonLabel:n=`Create event`,buttonSize:r=`default`,buttonVariant:i=`default`,className:a,quickHelpTarget:o})=>e.length===0?null:(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,size:r,variant:i,className:q(a),"aria-label":`${n}. Select event type`,"data-quick-help":o,children:[(0,X.jsx)(zi,{className:`size-4`,"aria-hidden":!0}),n,(0,X.jsx)(Ka,{className:`size-4`,"aria-hidden":!0})]})}),(0,X.jsx)(Ie,{align:`end`,children:e.map(e=>{let n=`bg-violet-500`;return e===`meeting`?n=`bg-emerald-500`:e===`webinar`&&(n=`bg-sky-500`),(0,X.jsx)(st,{onClick:()=>t(e),children:(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{className:q(`size-2 shrink-0 rounded-full`,n),"aria-hidden":!0}),dM[e]]})},e)})})]});SN.displayName=`CreateEventTypeDropdown`;var CN=e=>e.toLocaleDateString([],{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`}),wN=(e,t)=>`${e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})} – ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`,TN=()=>{let{eventDetailEvent:e,worlds:t,handleCloseEventDetail:n,handleJoinEvent:r,handleEditEvent:i,handleDeleteEvent:a}=dN(),o=c(),{organizationSlug:s}=S(),[l,u]=(0,Y.useState)(!1),d=e!=null,f=e,p=f?.worldId,m=t?.items,h=(0,Y.useMemo)(()=>
117{if(p&&m)return m.find(e=>e.id===p)},[p,m]),g=(0,Y.useCallback)(()=>{f&&(r(f.id),n())},[f,r,n]),_=(0,Y.useCallback)(()=>{f&&(i(f.id),n())},[f,i,n]),v=(0,Y.useCallback)(()=>{if(!f||!s)return;let e={eventType:f.properties?.type??`meeting`,title:f.name,description:f.description||void 0,worldId:f.worldId??void 0,preSelectedWorldId:f.worldId??void 0,startDate:new Date(f.startAt).toISOString(),endDate:f.endAt?new Date(f.endAt).toISOString():void 0};n(),o(`/${s}/dashboard/events/create`,{state:e})},[f,s,o,n]),y=(0,Y.useCallback)(()=>{u(!0)},[]),b=(0,Y.useCallback)(()=>{u(!1),f&&(a(f.id),n())},[f,n,a]),x=(0,Y.useCallback)(()=>{u(!1)},[]);if(!f)return null;let C=f.properties?.type,w=C?dM[C]??C:`Event`,T=C?fM[C]:void 0,E=new Date(f.startAt),D=f.endAt?new Date(f.endAt):null,O=h?.thumbnail?.url;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(ar,{open:d,onOpenChange:e=>!e&&n(),children:(0,X.jsxs)(pr,{className:`max-w-sm gap-0 overflow-hidden p-0`,showCloseButton:!1,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border px-4 py-3`,children:[(0,X.jsx)(`h2`,{className:`min-w-0 flex-1 text-lg font-semibold text-foreground`,children:f.name}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:_,className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,"aria-label":`Edit event`,children:(0,X.jsx)(va,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsx)(`button`,{type:`button`,onClick:y,className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,"aria-label":`Remove event`,children:(0,X.jsx)(Qi,{className:`size-5`,"aria-hidden":!0})}),(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsx)(`button`,{...e,type:`button`,className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,"aria-label":`More actions`,children:(0,X.jsx)(ma,{className:`size-5`,"aria-hidden":!0})})}),(0,X.jsx)(Ie,{align:`end`,children:(0,X.jsx)(st,{onClick:v,children:`Clone Event`})})]}),(0,X.jsx)(`button`,{type:`button`,onClick:n,className:`rounded-md p-1.5 text-muted-foreground hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,"aria-label":`Close`,children:(0,X.jsx)(so,{className:`size-5`,"aria-hidden":!0})})]})]}),(0,X.jsxs)(`div`,{className:`max-h-[70vh] space-y-3 overflow-y-auto px-4 py-3`,children:[O?(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(`div`,{className:`aspect-21/9 w-full overflow-hidden rounded-lg bg-muted`,children:(0,X.jsx)(`img`,{src:O,alt:``,className:`size-full object-cover`})}),(0,X.jsx)(fr,{variant:`outline`,className:q(`absolute top-2 left-2 text-xs capitalize`,T),children:w})]}):(0,X.jsx)(fr,{variant:`outline`,className:q(`text-xs capitalize`,T),children:w}),(0,X.jsxs)(`dl`,{className:`space-y-3 text-sm`,children:[(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(da,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`sr-only`,children:`Date`}),(0,X.jsx)(`dd`,{className:`text-foreground`,children:CN(E)})]})]}),D&&(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(bi,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`sr-only`,children:`Time`}),(0,X.jsx)(`dd`,{className:`text-foreground`,children:wN(E,D)})]})]}),h&&(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(xi,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`sr-only`,children:`World`}),(0,X.jsx)(`dd`,{className:`text-foreground`,children:h.name})]})]}),f.description&&(0,X.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,X.jsx)(Pi,{className:`mt-0.5 size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`dt`,{className:`sr-only`,children:`Description`}
117),(0,X.jsx)(`dd`,{className:`min-w-0 wrap-break-word whitespace-pre-wrap text-foreground`,children:f.description})]})]})]}),(0,X.jsx)(`div`,{className:`pt-2`,children:(0,X.jsx)(U,{onClick:g,className:`w-full`,"aria-label":`Join event`,children:`Join Event`})})]})]})}),(0,X.jsx)(ar,{open:l,onOpenChange:e=>!e&&x(),children:(0,X.jsxs)(pr,{className:`max-w-sm`,children:[(0,X.jsx)(rr,{children:(0,X.jsx)(mr,{children:`Remove event?`})}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`This action cannot be undone.`}),(0,X.jsxs)(lr,{children:[(0,X.jsx)(U,{variant:`outline`,onClick:x,children:`Cancel`}),(0,X.jsx)(U,{variant:`destructive`,onClick:b,children:`Remove`})]})]})})]})};TN.displayName=`EventDetailModal`;function EN({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`empty`,className:q(`flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-3xl border-dashed p-12 text-center text-balance`,e),...t})}rn(`mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{default:`bg-transparent`,icon:`flex size-10 shrink-0 items-center justify-center rounded-xl bg-muted text-foreground [&_svg:not([class*='size-'])]:size-5`}},defaultVariants:{variant:`default`}});function DN({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`empty-title`,className:q(`text-lg font-medium tracking-tight`,e),...t})}function ON({className:e,...t}){return(0,X.jsx)(`div`,{"data-slot":`empty-content`,className:q(`flex w-full max-w-sm min-w-0 flex-col items-center gap-4 text-sm text-balance`,e),...t})}var kN=[`Sun`,`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`],AN=[`S`,`M`,`T`,`W`,`T`,`F`,`S`],jN=Array.from({length:17},(e,t)=>t+6),MN=(e,t)=>`${e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})} – ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`,NN=e=>e.toLocaleDateString([],{weekday:`short`,month:`short`,day:`numeric`}),PN=e=>e.toLocaleDateString([],{month:`long`,year:`numeric`}),FN=e=>`${String(e).padStart(2,`0`)}:00`,IN=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`,LN=(e,t)=>e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate(),RN=e=>LN(e,new Date),zN=(e,t)=>{let n=new Date(e,t,1),r=new Date(e,t+1,0),i=n.getDay(),a=r.getDate(),o=new Date(e,t,0).getDate(),s=[];for(let n=0;n<i;n++){let r=o-i+n+1,a=new Date(e,t-1,r);s.push({date:a,isCurrentMonth:!1,dateKey:IN(a)})}for(let n=1;n<=a;n++){let r=new Date(e,t,n);s.push({date:r,isCurrentMonth:!0,dateKey:IN(r)})}let c=42-s.length;for(let n=0;n<c;n++){let r=new Date(e,t+1,n+1);s.push({date:r,isCurrentMonth:!1,dateKey:IN(r)})}return s},BN=e=>{let t=new Date(e);return t.setDate(t.getDate()-t.getDay()),t.setHours(0,0,0,0),t},VN=e=>Array.from({length:7},(t,n)=>{let r=new Date(e);return r.setDate(r.getDate()+n),r}),HN=e=>e.reduce((e,t)=>{let n=IN(new Date(t.startAt));return e[n]||(e[n]=[]),e[n].push(t),e},{}),UN=2592e5,WN=e=>e.createdAt?Date.now()-new Date(e.createdAt).getTime()<UN:!1,GN=(e,t,n)=>{let r=jN[0];return e.filter(e=>{let i=new Date(e.startAt);if(!LN(i,t))return!1;let a=i.getHours();return r?(a<r?r:a)===n:!1})},KN=({calendarDate:e,events:t,capabilities:n,onOpenEvent:r,onCreateEvent:i})=>{let a=RN(e),o=t=>{let n=new Date(e);return n.setHours(t,0,0,0),n};return(0,X.jsxs)(`div`,{className:`w-full overflow-hidden rounded-xl border border-border`,role:`application`,"aria-label":`Day calendar view`,children:[(0,X.jsxs)(`div`,{className:q(`flex items-center gap-3 border-b border-border px-4 py-3`,a&&`bg-primary/5`),children:[(0,X.jsx)(`span`,{className:q(`flex size-10 items-center justify-center rounded-full text-lg font-semibold`,a&&`bg-primary text-primary-foreground`,!a&&`bg-muted text-foreground`),children:e.getDate()}),(0,X.jsxs)(`div`,{className:`flex flex-col`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.toLocaleDateString([],{weekday:`long`,month:`long`,day:`numeric`})}),a&&(0,X.jsx)(`span`,{className:`text-xs font-medium text-primary`,children:`Today`})]})]}),(0,X.jsx)(`div`,{className:`max-h-130 overflow-y-auto`,children:jN.map(a=>{let s=GN(t,e,a);return(0,X.jsxs)(`div`,{className:q(`grid grid-cols-[56px_1fr] border-b border-border/50 last:border-b-0`,n.canCreateEvents&&`cursor-pointer hover:bg-muted/20`),onClick:e=>
117{n.canCreateEvents&&i?.(o(a),e)},children:[(0,X.jsx)(`div`,{className:`flex items-start justify-end border-r border-border/50 pt-1.5 pr-3 text-xs text-muted-foreground`,children:FN(a)}),(0,X.jsx)(`div`,{className:`min-h-12 px-2 py-1`,children:s.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r?.(e.id)},className:`mb-1 flex w-full items-center gap-2 rounded-md bg-primary/10 px-3 py-1.5 text-left transition-colors hover:bg-primary/20 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,"aria-label":`Open event: ${e.name}`,children:[(0,X.jsx)(`div`,{className:`h-4 w-0.5 shrink-0 rounded-full bg-primary`}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:e.name}),WN(e)&&(0,X.jsx)(`span`,{className:`ml-1.5 rounded bg-emerald-500/15 px-1 py-px text-[10px] leading-none font-semibold text-emerald-600 dark:text-emerald-400`,children:`New`}),e.endAt&&(0,X.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:MN(new Date(e.startAt),new Date(e.endAt))})]})]},e.id))})]},a)})})]})};KN.displayName=`CalendarDayView`;var qN=({calendarDate:e,events:t,capabilities:n,onOpenEvent:r,onCreateEvent:i})=>{let a=(0,Y.useMemo)(()=>HN(t),[t]),o=(0,Y.useMemo)(()=>zN(e.getFullYear(),e.getMonth()),[e]);return(0,X.jsx)(`div`,{className:`w-full`,role:`application`,"aria-label":`Month calendar view`,children:(0,X.jsxs)(`div`,{className:`grid grid-cols-7 gap-px overflow-hidden rounded-xl border border-border bg-border`,children:[kN.map(e=>(0,X.jsx)(`div`,{className:`bg-muted/30 px-2 py-2 text-center text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:e},e)),o.map(e=>{let t=a[e.dateKey]??[],o=RN(e.date);return(0,X.jsxs)(`div`,{className:q(`min-h-20 bg-background p-1.5 transition-colors`,!e.isCurrentMonth&&`bg-muted/10`,o&&`ring-1 ring-primary/30 ring-inset`,n.canCreateEvents&&`cursor-pointer hover:bg-muted/30`),onClick:t=>{n.canCreateEvents&&i?.(e.date,t)},children:[(0,X.jsx)(`span`,{className:q(`inline-block rounded px-1.5 py-0.5 text-xs font-medium`,!e.isCurrentMonth&&`text-muted-foreground/60`,e.isCurrentMonth&&o&&`bg-primary text-primary-foreground`,e.isCurrentMonth&&!o&&`text-foreground`),children:e.date.getDate()}),(0,X.jsxs)(`ul`,{className:`mt-1 space-y-0.5`,children:[t.slice(0,3).map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r?.(e.id)},className:`w-full truncate rounded px-1.5 py-0.5 text-left text-xs transition-colors hover:bg-muted/50 focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,title:e.name,"aria-label":`Open event: ${e.name}`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e.name}),WN(e)&&(0,X.jsx)(`span`,{className:`ml-1 rounded bg-emerald-500/15 px-1 py-px text-[10px] leading-none font-semibold text-emerald-600 dark:text-emerald-400`,children:`New`}),e.endAt&&(0,X.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:MN(new Date(e.startAt),new Date(e.endAt))})]})},e.id)),t.length>3&&(0,X.jsxs)(`li`,{className:`px-1.5 text-xs text-muted-foreground`,children:[`+`,t.length-3,` more`]})]})]},e.dateKey)})]})})};qN.displayName=`CalendarMonthView`;var JN=({calendarDate:e,events:t,capabilities:n,onOpenEvent:r,onNavigateToDay:i,onCreateEvent:a})=>{let o=(0,Y.useMemo)(()=>BN(e),[e]),s=(0,Y.useMemo)(()=>VN(o),[o]),c=(e,t)=>{let n=new Date(e);return n.setHours(t,0,0,0),n};return(0,X.jsxs)(`div`,{className:`w-full overflow-hidden rounded-xl border border-border`,role:`application`,"aria-label":`Week calendar view`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-[56px_repeat(7,1fr)] border-b border-border bg-muted/20`,children:[(0,X.jsx)(`div`,{className:`border-r border-border`}),s.map(e=>{let t=RN(e);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i?.(e),className:q(`flex flex-col items-center gap-0.5 border-r border-border px-1 py-2 text-xs transition-colors last:border-r-0 hover:bg-muted/40`,t&&`bg-primary/5`),children:[(0,X.jsx)(`span`,{className:q(`text-[10px] font-medium tracking-wide text-muted-foreground uppercase`,t&&`text-primary`),children:kN[e.getDay()]}),(0,X.jsx)(`span`,{className:q(`flex size-6 items-center justify-center rounded-full text-xs font-medium`,t&&`bg-primary text-primary-foreground`,!t&&`text-foreground`),children:e.getDate()})]},IN(e))})]}),(0,X.jsx)(`div`,{className:`max-h-120 overflow-y-auto`,children:jN.map(e=>(0,X.jsxs)(`div`,{className:`grid grid-cols-[56px_repeat(7,1fr)] border-b border-border/50 last:border-b-0`,children:[(0,X.jsx)(`div`,{className:`flex items-start justify-end border-r border-border/50 pt-1 pr-2 text-[10px] text-muted-foreground`,children:FN(e)}),s.map(i=>{let o=`${IN(i)}-${e}`,s=GN(t,i,e);return(0,X.jsx)(`div`,{className:q(`relative min-h-10 border-r border-border/30 px-0.5 py-0.5 transition-colors last:border-r-0`,n.canCreateEvents&&`cursor-pointer hover:bg-muted/30`),onClick:t=>{n.canCreateEvents&&a?.(c(i,e),t)},children:s.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),r?.(e.id)},className:`mb-0.5 w-full truncate rounded bg-primary/10 px-1 py-0.5 text-left text-[10px] font-medium text-primary transition-colors hover:bg-primary/20 focus-visible:ring-1 focus-visible:ring-ring focus-visible:outline`,title:e.name,"aria-label":`Open event: ${e.name}`,children:[e.name,WN(e)&&(0,X.jsx)(`span`,{className:`ml-0.5 rounded bg-emerald-500/15 px-0.5 text-[8px] font-semibold text-emerald-600 dark:text-emerald-400`,children:`New`})]},e.id))},o)})]},e))})]})};JN.displayName=`CalendarWeekView`;var YN=[`Jan`,`Feb`,`Mar`,`Apr`,`May`,`Jun`,`Jul`,`Aug`,`Sep`,`Oct`,`Nov`,`Dec`],XN=({calendarDate:e,events:t,onNavigateToMonth:n,onNavigateToDay:r})=>{let i=e.getFullYear(),a=(0,Y.useMemo)(()=>HN(t),[t]),o=(0,Y.useMemo)(()=>Array.from({length:12},(e,t)=>({month:t,grid:zN(i,t)})),[i]);return(0,X.jsx)(`div`,{className:`w-full`,role:`application`,"aria-label":`Year calendar view`,children:(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-6 sm:grid-cols-3 lg:grid-cols-4`,children:o.map(({month:e,grid:t})=>(0,X.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>n?.(new Date(i,e,1)),className:`rounded-md px-2 py-1 text-left text-sm font-semibold text-foreground transition-colors hover:bg-muted`,children:YN[e]}),(0,X.jsxs)(`div`,{className:`grid grid-cols-7 gap-px`,children:[AN.map((t,n)=>(0,X.jsx)(`div`,{className:`py-0.5 text-center text-[9px] font-medium text-muted-foreground`,children:t},`${e}-${n}`)),t.map(e=>{let t=(a[e.dateKey]?.length??0)>0,n=RN(e.date);return(0,X.jsxs)(`button`,{type:`button`,onClick:()=>r?.(e.date),className:q(`relative flex size-6 items-center justify-center rounded text-[10px] transition-colors`,e.isCurrentMonth?`text-foreground hover:bg-muted`:`text-muted-foreground
117/40`,n&&`bg-primary text-primary-foreground hover:bg-primary/90`),children:[e.date.getDate(),t&&e.isCurrentMonth&&!n&&(0,X.jsx)(`span`,{className:`absolute bottom-0.5 left-1/2 size-1 -translate-x-1/2 rounded-full bg-primary`}),t&&n&&(0,X.jsx)(`span`,{className:`absolute bottom-0.5 left-1/2 size-1 -translate-x-1/2 rounded-full bg-primary-foreground`})]},e.dateKey)})]})]},e))})})};XN.displayName=`CalendarYearView`;var ZN=(e,t)=>`${e.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})} – ${t.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`,QN=e=>e.toLocaleDateString([],{weekday:`short`,month:`short`,day:`numeric`}),$N=e=>{if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t},eP=({onOpen:e})=>(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsx)(U,{...e,size:`sm`,variant:`ghost`,className:`text-muted-foreground`,"aria-label":`Event actions`,children:(0,X.jsx)(ma,{className:`size-4`,"aria-hidden":!0})})}),(0,X.jsx)(Ie,{align:`end`,children:(0,X.jsx)(st,{onClick:e,children:`Open Event`})})]}),tP=[{value:`list`,label:`List`,icon:ei},{value:`day`,label:`Day`,icon:bi},{value:`week`,label:`Week`,icon:co},{value:`month`,label:`Month`,icon:da},{value:`year`,label:`Year`,icon:qi}],nP=({className:e})=>{let{capabilities:t,events:n,handleCreateEvent:r,handleOpenEvent:i}=dN(),[a,o]=(0,Y.useState)(`month`),[s,c]=(0,Y.useState)(()=>new Date),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p]=(0,Y.useState)(()=>Date.now()),m=!!l,h=t.usesEvents||t.canViewRecentItems,g=()=>{c(e=>{let t=new Date(e);return a===`day`?t.setDate(t.getDate()-1):a===`week`?t.setDate(t.getDate()-7):a===`month`?t.setMonth(t.getMonth()-1):a===`year`&&t.setFullYear(t.getFullYear()-1),t})},_=()=>{c(e=>{let t=new Date(e);return a===`day`?t.setDate(t.getDate()+1):a===`week`?t.setDate(t.getDate()+7):a===`month`?t.setMonth(t.getMonth()+1):a===`year`&&t.setFullYear(t.getFullYear()+1),t})},v=()=>c(new Date),y=()=>
117{if(a===`day`)return s.toLocaleDateString([],{weekday:`long`,month:`long`,day:`numeric`,year:`numeric`});if(a===`week`){let e=new Date(s);e.setDate(e.getDate()-e.getDay());let t=new Date(e);return t.setDate(t.getDate()+6),`${NN(e)} – ${NN(t)}`}return a===`year`?String(s.getFullYear()):PN(s)},b=e=>{c(e),o(`day`)},x=e=>{c(e),o(`month`)},S=(0,Y.useCallback)((e,t)=>{u(t.currentTarget),f(e)},[]),C=(0,Y.useCallback)(()=>{u(null),f(null)},[]),w=e=>{r(`meeting`,e)},T=a!==`list`,E;if(!h||!n?.items)return null;let D=n.items,O=[...D].filter(e=>{let t=$N(e.startAt),n=$N(e.endAt);return t?n?n.getTime()>=p:t.getTime()>=p:!1}).sort((e,t)=>($N(e.startAt)?.getTime()??2**53-1)-($N(t.startAt)?.getTime()??2**53-1)),k=[...D].sort((e,t)=>new Date(t.updatedAt).getTime()-new Date(e.updatedAt).getTime()).slice(0,10),A=O.length>0,j=k.length>0,M=!A&&!j,N=e=>{let t=e.properties?.type;return t?dM[t]??t:`Event`};return E=a===`list`?M?(0,X.jsxs)(EN,{className:`border bg-muted/30 py-12`,children:[(0,X.jsx)(DN,{className:`text-sm font-normal text-muted-foreground`,children:`No events yet`}),t.canCreateEvents&&(0,X.jsx)(ON,{children:(0,X.jsxs)(U,{onClick:()=>w(),variant:`secondary`,children:[(0,X.jsx)(zi,{className:`size-4`,"aria-hidden":!0}),`Create event`]})})]}):(0,X.jsxs)(`div`,{className:`grid gap-6 lg:grid-cols-2`,children:[t.usesEvents&&(0,X.jsxs)(Fo,{children:[(0,X.jsx)(Io,{className:`pb-2`,children:(0,X.jsx)(`h3`,{className:`text-base font-medium`,children:`Upcoming`})}),(0,X.jsx)(zo,{className:`pt-0`,children:A?(0,X.jsx)(`ul`,{className:`space-y-2`,role:`list`,children:O.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`div`,{className:`group flex items-start gap-2 rounded-lg border border-transparent p-3 transition-colors hover:bg-muted/50`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`flex min-w-0 flex-1 flex-col gap-1 rounded text-left focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,"aria-label":`Open event: ${e.name}`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e.name}),(0,X.jsx)(fr,{variant:`secondary`,className:`text-xs capitalize`,children:N(e)})]}),(0,X.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{children:QN(new Date(e.startAt))}),e.endAt&&(0,X.jsx)(`span`,{children:ZN(new Date(e.startAt),new Date(e.endAt))})]})]}),(0,X.jsx)(eP,{onOpen:()=>i(e.id)})]})},e.id))}):(0,X.jsx)(`p`,{className:`rounded-lg border border-dashed border-border bg-muted/20 py-6 text-center text-sm text-muted-foreground`,children:`No upcoming events`})})]}),t.canViewRecentItems&&(0,X.jsxs)(Fo,{children:[(0,X.jsx)(Io,{className:`pb-2`,children:(0,X.jsx)(`h3`,{className:`text-base font-medium`,children:`Recent`})}),(0,X.jsx)(zo,{className:`pt-0`,children:j?(0,X.jsx)(`ul`,{className:`space-y-2`,role:`list`,children:k.map(e=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`div`,{className:`group flex items-start gap-2 rounded-lg border border-transparent p-3 transition-colors hover:bg-muted/50`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(e.id),className:`flex min-w-0 flex-1 flex-col gap-1 rounded text-left focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline`,"aria-label":`Open ${e.name}`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`span`,{className:`font-medium text-foreground`,children:e.name}),(0,X.jsx)(fr,{variant:`secondary`,className:`text-xs capitalize`,children:N(e)})]}),(0,X.jsx)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-0 text-xs text-muted-foreground`,children:(0,X.jsx)(`span`,{children:QN(new Date(e.updatedAt))})})]}),(0,X.jsx)(eP,{onOpen:()=>i(e.id)})]})},e.id))}):(0,X.jsx)(`p`,{className:`rounded-lg border border-dashed border-border bg-muted/20 py-6 text-center text-sm text-muted-foreground`,children:`No recent activity yet`})})]})]}):a===`day`?(0,X.jsx)(KN,{calendarDate:s,events:D,capabilities:t,onOpenEvent:i,onCreateEvent:S}):a===`week`?(0,X.jsx)(JN,{calendarDate:s,events:D,capabilities:t,onOpenEvent:i,onNavigateToDay:b,onCreateEvent:S}):a===`month`?(0,X.jsx)(qN,{calendarDate:s,events:D,capabilities:t,onOpenEvent:i,onCreateEvent:S}):(0,X.jsx)(XN,{calendarDate:s,events:D,onNavigateToMonth:x,onNavigateToDay:b}),(0,X.jsxs)(`section`,{className:q(`space-y-4`,e),"aria-labelledby":`events-and-recent-heading`,"data-quick-help":`home-events`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{id:`events-and-recent-heading`,className:`text-lg font-semibold text-foreground`,children:`Events`}),T&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{variant:`outline`,size:`sm`,className:`h-7 px-2 text-xs`,onClick:v,children:`Today`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-0.5`,children:[(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`text-muted-foreground`,"aria-label":`Previous`,onClick:g,children:(0,X.jsx)(Zi,{className:`size-4`,"aria-hidden":!0})}),(0,X.jsx)(`span`,{className:`min-w-44 text-center text-sm font-medium text-foreground`,children:y()}),(0,X.jsx)(U,{variant:`ghost`,size:`sm`,className:`text-muted-foreground`,"aria-label":`Next`,onClick:_,children:(0,X.jsx)(Er,{className:`size-4`,"aria-hidden":!0})})]})]})]}),(0,X.jsx)(Ot,{variant:`outline`,size:`sm`,spacing:0,value:[a],onValueChange:e=>{let t=e.find(e=>e!==a);t&&o(t)},"aria-label":`View options`,children:tP.map(({value:e,label:t,icon:n})=>(0,X.jsxs)(nn,{value:e,className:`text-xs`,"aria-label":`${t} view`,children:[(0,X.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),(0,X.jsx)(`span`,{className:`hidden sm:inline`,children:t})]},e))})]}),E,(0,X.jsx)(Jn,{open:m,onOpenChange:e=>!e&&C(),children:(0,X.jsx)(Hn,{children:(0,X.jsx)(zn,{anchor:l,side:`bottom`,align:`start`,sideOffset:4,positionMethod:`absolute`,className:`isolate z-50`,children:(0,X.jsx)(In,{className:`w-120 origin-(--transform-origin) rounded-xl bg-popover shadow-lg ring-1 ring-foreground
117/10 outline-hidden duration-100 data-[side=bottom]:slide-in-from-top-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95`,children:(0,X.jsx)(bN,{open:m,initialDate:d,initialEventType:`meeting`,onClose:C},`popover-${m?`open`:`closed`}-${d?.toISOString()??``}`)})})})})]})};nP.displayName=`EventsAndRecentSection`;var rP=({world:e,className:t})=>{let{capabilities:n,handleCreateEventFromWorld:r,handleEditWorld:i,getWorldOpenUrl:a}=dN(),o=n.canCreateEvents,s=n.canEditWorlds,c=e.thumbnail?.url,l=a(e);return(0,X.jsxs)(Fo,{className:q(`animate-in gap-0! overflow-hidden py-0! transition-shadow fade-in-0 zoom-in-95 hover:ring-2 hover:ring-ring/50`,t),children:[(0,X.jsxs)(`button`,{type:`button`,className:`flex min-h-0 flex-1 flex-col text-left focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline focus-visible:ring-inset`,"aria-label":`Open world: ${e.name}`,children:[(0,X.jsx)(`div`,{className:`aspect-video w-full shrink-0 overflow-hidden bg-muted`,children:c?(0,X.jsx)(`img`,{src:c,alt:``,className:`h-full w-full object-cover`}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-muted-foreground`,children:(0,X.jsx)(_a,{className:`size-8`,"aria-hidden":!0})})}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col px-4 py-3`,children:[(0,X.jsx)(`span`,{className:`line-clamp-1 font-medium text-foreground`,children:e.name}),e.description&&(0,X.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-muted-foreground`,children:e.description})]})]}),(0,X.jsxs)(`div`,{className:`mt-auto flex flex-wrap items-center gap-2 border-t border-border bg-muted/20 px-4 py-3`,children:[o&&(0,X.jsx)(SN,{allowedEventTypes:n.allowedEventTypes,onSelectEventType:t=>r(e.id,t),buttonLabel:`Create event`,buttonSize:`sm`}),l?(0,X.jsx)(U,{size:`sm`,variant:`outline`,nativeButton:!1,render:t=>(0,X.jsxs)(`a`,{...t,href:l,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`Open ${e.name} in new tab`,children:[(0,X.jsx)(_a,{className:`size-4`,"aria-hidden":!0}),`Open`]})}):(0,X.jsxs)(U,{size:`sm`,variant:`outline`,"aria-label":`Open ${e.name}`,children:[(0,X.jsx)(_a,{className:`size-4`,"aria-hidden":!0}),`Open`]}),s&&(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsx)(U,{...e,size:`sm`,variant:`ghost`,className:`ml-auto`,"aria-label":`More options`,children:(0,X.jsx)(ma,{className:`size-4`,"aria-hidden":!0})})}),(0,X.jsx)(Ie,{align:`end`,children:(0,X.jsxs)(st,{onClick:()=>i(e.id),children:[(0,X.jsx)(ja,{className:`size-4`,"aria-hidden":!0}),`Edit`]})})]})]})]})};rP.displayName=`WorldCard`;var iP=({className:e})=>{let{capabilities:t,worlds:n,handleSeeMoreWorlds:r}=dN(),[i,a]=(0,Y.useState)(3),o=(0,Y.useMemo)(()=>n?.items?.slice(0,i)??[],[n,i]);if(!t.canViewWorlds||!n?.items)return null;let s=n.items.length===0,c=i<n.items.length;function l(){a(i+3)}return(0,X.jsxs)(`section`,{className:q(`space-y-4`,e),"aria-labelledby":`worlds-heading`,"data-quick-help":`home-worlds`,children:[(0,X.jsx)(`h2`,{id:`worlds-heading`,className:`text-lg font-semibold text-foreground`,children:`Worlds`}),s?(0,X.jsxs)(EN,{className:`border bg-muted/30 py-12`,children:[(0,X.jsx)(DN,{className:`text-sm font-normal text-muted-foreground`,children:`No worlds published yet`}),t.canCreateWorlds&&(0,X.jsx)(ON,{children:(0,X.jsxs)(U,{onClick:r,variant:`secondary`,children:[(0,X.jsx)(Pa,{className:`size-4`,"aria-hidden":!0}),`Go to worlds`]})})]}):(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`div`,{className:`grid auto-rows-fr gap-4 sm:grid-cols-2 lg:grid-cols-3`,children:o.map(e=>(0,X.jsx)(rP,{world:e},e.id))}),c&&(0,X.jsx)(`div`,{className:`flex justify-center pt-1`,children:(0,X.jsxs)(U,{variant:`outline`,size:`sm`,onClick:l,"aria-label":`See more worlds`,children:[`See more worlds`,(0,X.jsx)(sa,{className:`size-3.5`,"aria-hidden":!0})]})})]})]})};iP.displayName=`WorldsGridSection`;var aP=({className:e,children:t,...n})=>{let{capabilities:r,events:i,worlds:a,handleCreateEvent:o}=dN();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.home`),actions:r.canCreateEvents?(0,X.jsx)(SN,{allowedEventTypes:r.allowedEventTypes,onSelectEventType:e=>o(e),quickHelpTarget:`home-create-event`}):void 0}),(0,X.jsx)(wE,{children:(0,X.jsxs)(`div`,{className:q(`flex w-full flex-col gap-8 pb-20`,e),...n,children:[r.canViewWorlds&&a?.items&&(0,X.jsx)(iP,{}),r.usesEvents&&i?.items&&(0,X.jsx)(nP,{}),r.usesEvents&&(0,X.jsx)(TN,{}),r.canCreateEvents&&(0,X.jsx)(xN,{}),t]})})]})},oP=e=>(0,X.jsx)(uN,{children:(0,X.jsx)(aP,{...e})}),sP=()=>{let[e]=o(),t=c(),[n]=(0,Y.useState)(e.get(`token`)??void 0),{client:r}=z();return(0,Y.useEffect)(()=>{e.get(`token`)&&t(`/reset-password`,{replace:!0})},[t,e]),(0,X.jsx)(`div`,{className:`flex min-h-svh items-center justify-center bg-muted/50 p-4 sm:p-6`,children:(0,X.jsx)(ps,{token:n,onResetPassword:async(e,t)=>{let n=await r.resetPassword({newPassword:e,token:t});if(n.error)throw Error(n.error.message??`Failed to reset password. Please try again.`)}})})};sP.displayName=`ResetPassword`;var cP=e=>e?new Date(e).toLocaleDateString(void 0,{year:`numeric`,month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}):Z(`common.never`),lP=()=>[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`name`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.name`)}),cell:({row:e})=>
117(0,X.jsx)(`div`,{children:e.original.name||`Unnamed Key`})},{accessorKey:`prefix`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.prefix`)}),cell:({row:e})=>(0,X.jsx)(`code`,{className:`rounded bg-muted px-2 py-1 text-sm`,children:e.original.prefix||e.original.start||`—`})},{accessorKey:`enabled`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.api-keys.columns.enabled`)}),cell:({row:e})=>(0,X.jsx)(fr,{variant:e.original.enabled?`default`:`secondary`,children:e.original.enabled?Z(`routes.api-keys.columns.enabled.true`):Z(`routes.api-keys.columns.enabled.false`)})},{accessorKey:`requestCount`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.api-keys.columns.request-count`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`tabular-nums`,children:e.original.requestCount})},{accessorKey:`remaining`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.api-keys.columns.remaining`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`tabular-nums`,children:e.original.remaining===null?`∞`:e.original.remaining})},{accessorKey:`expiresAt`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.api-keys.columns.expires-at`)}),cell:({row:e})=>{let t=e.original.expiresAt;if(!t)return Z(`routes.api-keys.columns.no-expiry`);let n=new Date(t)<new Date;return(0,X.jsx)(`span`,{className:n?`text-red-500`:``,children:cP(t)})}},{accessorKey:`lastRequest`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.api-keys.columns.last-request`)}),cell:({row:e})=>cP(e.original.lastRequest)},{accessorKey:`createdAt`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.created.at`)}),cell:({row:e})=>cP(e.original.createdAt)},{id:`actions`,cell:({row:e})=>(0,X.jsx)(uP,{row:e})}],uP=({row:e})=>{let{client:t}=z(),n=fe(),[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,variant:`ghost`,className:`h-8 w-8 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(xe,{}),(0,X.jsx)(XM,{id:e.original.id,title:Z(`common.delete.api.key`),deleteRow:async()=>{await t.apiKey.delete({keyId:e.original.id}),await n.invalidateQueries({queryKey:[`api-keys`]})},open:r,setOpen:i})]})})]})},dP=()=>{let{client:e}=z(),t=fe(),{data:n,isLoading:r,isError:i}=V({queryKey:[`api-keys`],queryFn:()=>e.apiKey.list({})}),a=B({mutationFn:t=>e.apiKey.delete({keyId:t}),onSuccess:()=>{t.invalidateQueries({queryKey:[`api-keys`]})}}),o=(0,Y.useMemo)(()=>lP(),[]);return r?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{className:`h-10 w-10`})}):i?(0,X.jsx)(`div`,{children:Z(`routes.api-keys.error`)}):n?.data?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.api.keys`),actions:(0,X.jsxs)(U,{nativeButton:!1,render:(0,X.jsx)(u,{to:`create`}),children:[(0,X.jsx)(Hr,{className:`h-4 w-4`,"aria-hidden":`true`}),Z(`components.form.api-key.add.button`)]})}),(0,X.jsx)(wE,{children:(0,X.jsx)(pd,{columns:o,data:n.data,onDeleteSelected:async e=>{let t=e.map(e=>e.id);await Promise.all(t.map(e=>a.mutateAsync(e)))},multipleDeleteString:{start:`Delete`,end:`API key`}})})]}):(0,X.jsx)(`div`,{children:Z(`routes.api-keys.no.api-keys.found`)})};dP.displayName=`ApiKeys`;function fP({className:e,...t}){return(0,X.jsx)(Qu,{"data-slot":`radio-group`,className:q(`grid w-full gap-3`,e),...t})}function pP({className:e,...t}){return(0,X.jsx)(Yu,{"data-slot":`radio-group-item`,className:q(`group/radio-group-item peer relative flex aspect-square size-4 shrink-0 rounded-2xl border border-transparent bg-input/90 outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/30 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary`,e),...t,children:(0,X.jsx)(Xu,{"data-slot":`radio-group-indicator`,className:`flex size-4 items-center justify-center`,children:(0,X.jsx)(`span`,{className:`absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 roun
117ded-full bg-primary-foreground dark:size-2.5`})})})}var mP=({children:e})=>(0,X.jsxs)(_n,{children:[(0,X.jsxs)(At,{className:`flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground [&[data-panel-open]>svg:last-child]:rotate-90`,children:[(0,X.jsx)(ua,{className:`size-3.5 shrink-0`,"aria-hidden":`true`}),Z(`components.form.api-key.info.toggle`),(0,X.jsx)(Er,{className:`size-3.5 shrink-0 transition-transform duration-150`,"aria-hidden":`true`})]}),(0,X.jsx)(Tn,{children:(0,X.jsx)(`p`,{className:`mt-1 rounded-md bg-muted p-2 text-xs text-muted-foreground`,children:e})})]});mP.displayName=`FieldInfo`;var hP=[`create`,`list`,`get`,`update`,`delete`],gP=[{key:`world`,labelKey:`common.worlds`,actions:hP},{key:`event`,labelKey:`common.events`,actions:[...hP,`join`]},{key:`space`,labelKey:`common.spaces`,actions:hP},{key:`cms`,labelKey:`common.collections`,actions:hP},{key:`files`,labelKey:`common.files`,actions:hP},{key:`email`,labelKey:`common.emails`,actions:[`create`,`list`,`get`,`update`]},{key:`translateUi`,labelKey:`components.form.api-key.resource.translate-ui`,actions:hP},{key:`translateEntry`,labelKey:`components.form.api-key.resource.translate-entry`,actions:hP},{key:`translateLabel`,labelKey:`components.form.api-key.resource.translate-label`,actions:hP},{key:`translateSystem`,labelKey:`components.form.api-key.resource.translate-system`,actions:hP},{key:`organization`,labelKey:`common.organizations`,actions:hP}],_P={create:`common.create`,list:`components.form.api-key.action.list`,get:`components.form.api-key.action.get`,update:`components.form.api-key.action.update`,delete:`common.delete`,join:`components.form.api-key.action.join`},vP=`data-checked:border-emerald-500 data-checked:bg-emerald-500 data-checked:text-white dark:data-checked:bg-emerald-500 data-indeterminate:border-emerald-500 data-indeterminate:bg-emerald-500/50 data-indeterminate:text-white`;function yP({value:e,onChange:t,disabled:n=!1}){let r=(n,r)=>{let{[n]:i,...a}=e;t(r.length>0?{...a,[n]:r}:a)},i=(t,n)=>{let i=e[t]??[];r(t,i.includes(n)?i.filter(e=>e!==n):[...i,n])};return(0,X.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:gP.map(({key:t,labelKey:a,actions:o})=>{let s=e[t]??[],c=o.every(e=>s.includes(e)),l=!c&&s.length>0,u=`api-key-permission-${t}`;return(0,X.jsxs)(`fieldset`,{disabled:n,className:`rounded-lg border p-3 disabled:opacity-60`,children:[(0,X.jsx)(`legend`,{className:`sr-only`,children:Z(a)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Pd,{id:u,checked:c,indeterminate:l,disabled:n,className:vP,onCheckedChange:()=>r(t,c?[]:[...o])}),(0,X.jsx)($t,{htmlFor:u,className:`cursor-pointer font-medium`,children:Z(a)})]}),(0,X.jsx)(`div`,{className:`mt-2 ml-6 flex flex-wrap gap-x-4 gap-y-2`,children:o.map(e=>{let r=`${u}-${e}`;return(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,X.jsx)(Pd,{id:r,checked:s.includes(e),disabled:n,className:vP,onCheckedChange:()=>i(t,e)}),(0,X.jsx)($t,{htmlFor:r,className:`cursor-pointer text-sm text-muted-foreground`,children:Z(_P[e])})]},e)})})]},t)})})}yP.displayName=`PermissionsPicker`;var bP=({suggestions:e,disabled:t})=>(0,X.jsx)(`div`,{role:`group`,"aria-label":Z(`components.form.api-key.suggestions`),className:`flex flex-wrap gap-1.5`,children:e.map(e=>(0,X.jsx)(U,{type:`button`,size:`xs`,variant:e.isActive?`secondary`:`outline`,"aria-pressed":e.isActive,disabled:t,onClick:e.onSelect,children:e.label},e.id))});bP.displayName=`SuggestionChips`;var xP={seconds:1e3,minutes:6e4,hours:36e5,days:864e5},SP=[{value:`seconds`,label:Z(`components.form.api-key.rate-limit.window.unit.seconds`)},{value:`minutes`,label:Z(`components.form.api-key.rate-limit.window.unit.minutes`)},{value:`hours`,label:Z(`components.form.api-key.rate-limit.window.unit.hours`)},{value:`days`,label:Z(`components.form.api-key.rate-limit.window.unit.days`)}],CP=`fi-FI`,wP=[60,100,1e3,1e4],TP=[{id:`1-minute`,value:1,unit:`minutes`,label:Z(`components.form.api-key.rate-limit.window.suggestion.1-minute`)},{id:`15-minutes`,value:15,unit:`minutes`,label:Z(`components.form.api-key.rate-limit.window.suggestion.15-minutes`)},{id:`1-hour`,value:1,unit:`hours`,label:Z(`components.form.api-key.rate-limit.window.suggestion.1-hour`)},{id:`1-day`,value:1,unit:`days`,label:Z(`components.form.api-key.rate-limit.window.suggestion.1-day`)}],EP=e=>typeof e==`string`&&e in xP,DP=lt({name:H().min(1,`Name is required`),prefix:H().optional(),expiresIn:We().optional(),rateLimitEnabled:be(),rateLimitMax:We().int().positive().optional(),rateLimitTimeWindow:We().int().positive().optional(),rateLimitTimeWindowUnit:Xe([`seconds`,`minutes`,`hours`,`days`])}),OP=86400,kP=2e3,AP=`never`,jP=[{value:AP,label:Z(`common.never`)},{value:String(7*OP),label:Z(`components.form.api-key.expires-in.7-days`)},{value:String(30*OP),label:Z(`components.form.api-key.expires-in.30-days`)},{value:String(90*OP),label:Z(`components.form.api-key.expires-in.90-days`)},{value:String(365*OP),label:Z(`components.form.api-key.expires-in.1-year`)}],MP=e=>jP.find(t=>t.value===e)?.label,NP=`create-api-key-form`,PP=()=>{let e=R(),t=fe(),n=B(e.user.createApiKey.mutationOptions()),r=c(),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)({}),f=n.isPending,p=l({resolver:pn(DP),defaultValues:{name:``,prefix:``,expires
117In:void 0,rateLimitEnabled:!1,rateLimitMax:void 0,rateLimitTimeWindow:void 0,rateLimitTimeWindowUnit:`minutes`}}),m=p.watch(`rateLimitEnabled`),g=p.watch(`rateLimitTimeWindowUnit`),_=(e,t)=>{p.setValue(`rateLimitTimeWindow`,e,{shouldValidate:!0}),p.setValue(`rateLimitTimeWindowUnit`,t)},v=async e=>{let r=e.rateLimitTimeWindow===void 0?void 0:e.rateLimitTimeWindow*xP[e.rateLimitTimeWindowUnit];try{let i=await n.mutateAsync({name:e.name,prefix:e.prefix||void 0,expiresIn:e.expiresIn,rateLimitEnabled:e.rateLimitEnabled,rateLimitMax:e.rateLimitEnabled?e.rateLimitMax:void 0,rateLimitTimeWindow:e.rateLimitEnabled?r:void 0,permissions:u});a(i.key),t.invalidateQueries({queryKey:[`api-keys`]})}catch(e){console.error(`Failed to create API key`,e),J.error(Z(`components.form.api-key.create.error`))}},y=async()=>{i&&(await navigator.clipboard.writeText(i),s(!0),setTimeout(()=>s(!1),kP))},b=()=>r(`..`,{relative:`path`});return i?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`components.form.api-key.add.title`)}),(0,X.jsxs)(wE,{className:`max-w-3xl space-y-4`,children:[(0,X.jsxs)(`div`,{className:`rounded-lg border border-green-200 bg-green-50 p-4 dark:border-green-900 dark:bg-green-950`,children:[(0,X.jsx)(`p`,{className:`mb-2 text-sm font-medium text-green-800 dark:text-green-200`,children:Z(`components.form.api-key.created.title`)}),(0,X.jsx)(`p`,{className:`mb-3 text-xs text-green-700 dark:text-green-300`,children:Z(`components.form.api-key.created.description`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`code`,{className:`flex-1 rounded border bg-muted p-2 font-mono text-sm break-all`,children:i}),(0,X.jsx)(U,{variant:`outline`,size:`sm`,onClick:y,className:`shrink-0`,"aria-label":Z(`components.form.api-key.created.copy`),children:o?(0,X.jsx)(Ea,{className:`h-4 w-4 text-green-500`,"aria-hidden":!0}):(0,X.jsx)(pi,{className:`h-4 w-4`,"aria-hidden":!0})})]}),(0,X.jsx)(`p`,{role:`status`,className:`sr-only`,children:o?Z(`components.form.api-key.created.copied`):``})]}),(0,X.jsx)(U,{onClick:b,children:Z(`common.done`)})]})]}):(0,X.jsxs)(`form`,{id:NP,onSubmit:p.handleSubmit(v),"aria-busy":f,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsx)(CE,{title:Z(`components.form.api-key.add.title`),actions:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(U,{type:`button`,variant:`outline`,size:`sm`,onClick:b,disabled:f,children:Z(`common.cancel`)}),(0,X.jsxs)(U,{type:`submit`,form:NP,disabled:f,children:[f&&(0,X.jsx)(An,{"aria-hidden":`true`,role:void 0}),Z(f?`components.form.api-key.add.creating`:`components.form.api-key.add.button`)]})]})}),(0,X.jsxs)(wE,{className:`space-y-6`,children:[(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`components.form.api-key.add.description`)}),(0,X.jsxs)(`fieldset`,{disabled:f,className:`grid gap-4 sm:grid-cols-3`,children:[(0,X.jsx)(h,{control:p.control,name:`name`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`api-key-name`,children:Z(`common.name`)}),(0,X.jsx)(W,{...e,id:`api-key-name`,"aria-invalid":t.invalid,placeholder:Z(`components.form.api-key.name.placeholder`)}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:p.control,name:`prefix`,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{htmlFor:`api-key-prefix`,children:Z(`common.prefix`)}),(0,X.jsx)(W,{...e,id:`api-key-prefix`,placeholder:Z(`components.form.api-key.prefix.placeholder`)})]})}),(0,X.jsx)(h,{control:p.control,name:`expiresIn`,render:({field:e})=>(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{htmlFor:`api-key-expires-in`,children:Z(`components.form.api-key.expires-in`)}),(0,X.jsxs)(Vt,{value:e.value?.toString()??AP,onValueChange:t=>e.onChange(!t||t===AP?void 0:Number(t)),children:[(0,X.jsx)(Dn,{id:`api-key-expires-in`,className:`w-full`,children:(0,X.jsx)(Mt,{children:MP})}),(0,X.jsx)(Dt,{children:jP.map(e=>(0,X.jsx)(yn,{value:e.value,children:e.label},e.value))})]})]})})]}),(0,X.jsxs)(`fieldset`,{disabled:f,className:`space-y-4`,children:[(0,X.jsx)(`legend`,{className:`text-sm font-medium`,children:Z(`components.form.api-key.rate-limit`)}),(0,X.jsx)(mP,{children:Z(`components.form.api-key.rate-limit.info`)}),(0,X.jsx)(h,{control:p.control,name:`rateLimitEnabled`,render:({field:e})=>(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,X.jsx)(Cn,{id:`api-key-rate-limit-enabled`,checked:e.value,onCheckedChange:e.onChange}),(0,X.jsx)(K,{htmlFor:`api-key-rate-limit-enabled`,children:Z(`components.form.api-key.rate-limit.enabled`)})]})}),(0,X.jsxs)(`div`,{className:`grid gap-4 sm:grid-cols-2`,children:[(0,X.jsx)(h,{control:p.control,name:`rateLimitMax`,render:({field:e,fieldState:t})=>
117(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`api-key-rate-limit-max`,children:Z(`components.form.api-key.rate-limit.max`)}),(0,X.jsx)(mP,{children:Z(`components.form.api-key.rate-limit.max.info`)}),(0,X.jsx)(Wt.Root,{id:`api-key-rate-limit-max`,value:e.value??null,onValueChange:t=>e.onChange(t??void 0),onBlur:e.onBlur,min:1,step:1,locale:CP,disabled:!m,"aria-invalid":t.invalid,children:(0,X.jsxs)(Wt.Group,{children:[(0,X.jsx)(Wt.Decrement,{}),(0,X.jsx)(Wt.Input,{ref:e.ref,className:`flex-1`}),(0,X.jsx)(Wt.Increment,{})]})}),(0,X.jsx)(bP,{disabled:!m,suggestions:wP.map(t=>({id:String(t),label:t.toLocaleString(CP),isActive:e.value===t,onSelect:()=>e.onChange(t)}))}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:p.control,name:`rateLimitTimeWindow`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:`api-key-rate-limit-window`,children:Z(`components.form.api-key.rate-limit.window`)}),(0,X.jsx)(mP,{children:Z(`components.form.api-key.rate-limit.window.info`)}),(0,X.jsx)(Wt.Root,{id:`api-key-rate-limit-window`,value:e.value??null,onValueChange:t=>e.onChange(t??void 0),onBlur:e.onBlur,min:1,step:1,locale:CP,disabled:!m,"aria-invalid":t.invalid,children:(0,X.jsxs)(Wt.Group,{children:[(0,X.jsx)(Wt.Decrement,{}),(0,X.jsx)(Wt.Input,{ref:e.ref,className:`flex-1`}),(0,X.jsx)(Wt.Increment,{})]})}),(0,X.jsx)(h,{control:p.control,name:`rateLimitTimeWindowUnit`,render:({field:e})=>(0,X.jsx)(fP,{value:e.value,onValueChange:t=>{EP(t)&&e.onChange(t)},disabled:!m,"aria-label":Z(`components.form.api-key.rate-limit.window.unit`),className:`flex flex-wrap gap-4`,children:SP.map(e=>(0,X.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,X.jsx)(pP,{value:e.value}),e.label]},e.value))})}),(0,X.jsx)(bP,{disabled:!m,suggestions:TP.map(t=>({id:t.id,label:t.label,isActive:e.value===t.value&&g===t.unit,onSelect:()=>_(t.value,t.unit)}))}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})})]})]}),(0,X.jsxs)(G,{children:[(0,X.jsx)(K,{id:`api-key-permissions-label`,children:Z(`components.form.api-key.permissions.label`)}),(0,X.jsx)(Gt,{children:Z(`components.form.api-key.permissions.description`)}),(0,X.jsx)(`div`,{role:`group`,"aria-labelledby":`api-key-permissions-label`,children:(0,X.jsx)(yP,{value:u,onChange:d,disabled:f})})]})]})]})};PP.displayName=`CreateApiKey`;var FP=[{id:`team`,name:`Team`,description:`For small teams running branded events and spaces`,price:99,interval:`month`,features:[`Up to 10 spaces`,`Unlimited event creation`,`Built-in meetings (voice/video) for up to 25 participants`,`Team roles & permissions`,`Basic analytics`,`Email support`,`5GB storage`],stripePriceId:`price_team_monthly`},{id:`business`,name:`Business`,description:`For growing orgs scaling events, space
117s, and collaboration`,price:299,interval:`month`,features:[`Up to 100 spaces`,`Advanced event workflows (templates, approvals)`,`Meetings (voice/video) up to 100 participants + recordings`,`Custom branding for events and spaces`,`Advanced analytics & reporting`,`Priority support & onboarding`,`50GB storage`,`API access`],popular:!0,stripePriceId:`price_business_monthly`},{id:`enterprise`,name:`Enterprise`,description:`For large organizations with compliance and scale needs`,price:899,interval:`month`,features:[`Unlimited spaces & events`,`Meetings (voice/video) 500+ participants, breakout rooms`,`SSO/SAML, SCIM provisioning`,`Dedicated environments & custom SLAs`,`Advanced governance & audit logs`,`Custom integrations & webhooks`,`Dedicated CSM & 24/7 priority support`,`Unlimited storage`],stripePriceId:`price_enterprise_monthly`}],IP=({className:e,...t})=>{let[n,r]=(0,Y.useState)(`professional`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)([]),u=o?{plan:o.plan.name.toLowerCase(),status:o.status,nextBillingDate:new Date(o.currentPeriodEnd*1e3).toISOString().split(`T`)[0],amount:o.plan.amount/100}:{plan:`none`,status:`inactive`,nextBillingDate:`N/A`,amount:0};return(0,X.jsxs)(`div`,{className:q(``,e),...t,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Billing & Subscription`}),(0,X.jsx)(`p`,{className:`mt-2 text-muted-foreground`,children:`Manage your subscription and billing information`})]}),(0,X.jsxs)(pu,{defaultValue:`overview`,className:`space-y-6`,children:[(0,X.jsxs)(hu,{className:`border border-neutral-200 bg-neutral-100 shadow-xs dark:border-border/70 dark:bg-muted/60`,children:[(0,X.jsx)(gu,{value:`overview`,children:`Overview`}),(0,X.jsx)(gu,{value:`plans`,children:`Plans`}),(0,X.jsx)(gu,{value:`billing-history`,children:`Billing History`})]}),(0,X.jsxs)(_u,{value:`overview`,className:`space-y-6`,children:[(0,X.jsxs)(Fo,{children:[(0,X.jsxs)(Io,{children:[(0,X.jsx)(Lo,{children:`Current Subscription`}),(0,X.jsx)(Ro,{children:`Your current plan and billing information`})]}),(0,X.jsxs)(zo,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`div`,{}),(0,X.jsx)(fr,{variant:u.status===`active`?`default`:`secondary`,children:u.status})]}),(0,X.jsx)(gn,{}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-4 text-sm`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`Next billing date`}),(0,X.jsx)(`p`,{className:`font-medium`,children:u.nextBillingDate})]}),(0,X.jsx)(`div`,{children:(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`Amount`})})]})]}),(0,X.jsxs)(Bo,{className:`space-x-2`,children:[o&&o.status===`active`&&(0,X.jsx)(U,{variant:`outline`,onClick:()=>{},disabled:i,children:`Cancel Subscription`}),(0,X.jsx)(U,{variant:`outline`,onClick:()=>{},children:`Manage Billing`})]})]}),(0,X.jsxs)(Fo,{children:[(0,X.jsxs)(Io,{children:[(0,X.jsx)(Lo,{children:`Payment Method`}),(0,X.jsx)(Ro,{children:`Manage your payment information`})]}),(0,X.jsx)(zo,{children:(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`div`,{className:`flex items-center space-x-3`,children:[(0,X.jsx)(`div`,{className:`flex h-8 w-8 items-center justify-center rounded bg-blue-600`,children:(0,X.jsx)(`span`,{className:`text-xs font-bold text-white`,children:`VISA`})}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`font-medium`,children:`•••• •••• •••• 4242`}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Expires 12/25`})]})]}),(0,X.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>{},children:`Update`})]})})]})]}),(0,X.jsxs)(_u,{value:`plans`,className:`space-y-6`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`mb-2 text-2xl font-bold`,children:`Choose Your Plan`}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`Select the plan that best fits your needs. You can change or cancel anytime.`})]}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 gap-6 md:grid-cols-3`,children:FP.map(e=>(0,X.jsxs)(Fo,{className:q(`relative`,e.popular&&`border-primary shadow-lg`),children:[e.popular&&(0,X.jsx)(`div`,{className:`absolute -top-3 left-1/2 -translate-x-1/2 transform`,children:(0,X.jsx)(fr,{className:`bg-primary text-primary-foreground`,children:`Most Popular`})}),(0,X.jsxs)(Io,{className:`text-center`,children:[(0,X.jsx)(Lo,{className:`text-xl`,children:e.name}),(0,X.jsx)(Ro,{children:e.description}),(0,X.jsxs)(`div`,{className:`mt-4`,children:[(0,X.jsxs)(`span`,{className:`text-4xl font-bold`,children:[`$`,e.price]}),(0,X.jsxs)(`span`,{className:`text-muted-foreground`,children:[`/`,e.interval]})]})]}),(0,X.jsx)(zo,{children:(0,X.jsx)(`ul`,{className:`space-y-2`,children:e.features.map((e,t)=>(0,X.jsxs)(`li`,{className:`flex items-center text-sm`,children:[(0,X.jsx)(`div`,{className:`mr-3 flex h-4 w-4 items-center justify-center rounded-full bg-green-100`,children:(0,X.jsx)(`div`,{className:`h-2 w-2 rounded-full bg-green-600`})}),e]},t))})}
117),(0,X.jsx)(Bo,{children:(0,X.jsx)(U,{className:`w-full`,variant:e.popular?`default`:`outline`,onClick:()=>{},disabled:i||u.plan===e.id,children:u.plan===e.id?`Current Plan`:`Subscribe`})})]},e.id))})]}),(0,X.jsxs)(_u,{value:`billing-history`,className:`space-y-6`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{className:`mb-2 text-2xl font-bold`,children:`Billing History`}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:`View your past invoices and payments`})]}),(0,X.jsx)(Fo,{children:(0,X.jsx)(zo,{className:`p-0`,children:(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b`,children:[(0,X.jsx)(`th`,{className:`p-4 text-left font-medium`,children:`Date`}),(0,X.jsx)(`th`,{className:`p-4 text-left font-medium`,children:`Description`}),(0,X.jsx)(`th`,{className:`p-4 text-left font-medium`,children:`Amount`}),(0,X.jsx)(`th`,{className:`p-4 text-left font-medium`,children:`Status`}),(0,X.jsx)(`th`,{className:`p-4 text-left font-medium`,children:`Action`})]})}),(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{className:`border-b`,children:[(0,X.jsx)(`td`,{className:`p-4`,children:`Jan 15, 2024`}),(0,X.jsx)(`td`,{className:`p-4`,children:`Professional Plan - Monthly`}),(0,X.jsx)(`td`,{className:`p-4`,children:`$29.00`}),(0,X.jsx)(`td`,{className:`p-4`,children:(0,X.jsx)(fr,{variant:`default`,children:`Paid`})}),(0,X.jsx)(`td`,{className:`p-4`,children:(0,X.jsx)(U,{variant:`outline`,size:`sm`,children:`Download`})})]}),(0,X.jsxs)(`tr`,{className:`border-b`,children:[(0,X.jsx)(`td`,{className:`p-4`,children:`Dec 15, 2023`}),(0,X.jsx)(`td`,{className:`p-4`,children:`Professional Plan - Monthly`}),(0,X.jsx)(`td`,{className:`p-4`,children:`$29.00`}),(0,X.jsx)(`td`,{className:`p-4`,children:(0,X.jsx)(fr,{variant:`default`,children:`Paid`})}),(0,X.jsx)(`td`,{className:`p-4`,children:(0,X.jsx)(U,{variant:`outline`,size:`sm`,children:`Download`})})]})]})]})})})})]})]})]})};IP.displayName=`Billing`;var LP=[`member`,`user`,`event_user`,`content_user`,`insta_user`,`admin`,`owner`];function RP(e){if(e.isPlatformAdmin)return LP;switch(e.inviterOrgRole){case`owner`:return LP;case`admin`:return LP.filter(e=>e!==`owner`);case`user`:return LP.filter(e=>e!==`owner`&&e!==`admin`);default:return LP.filter(e=>[`member`,`user`,`event_user`,`content_user`].includes(e))}}function zP(e){switch(e){case`admin`:return Z(`components.form.members.role.admin`);case`owner`:return Z(`components.form.members.role.owner`);case`user`:return Z(`components.form.members.role.user`);case`event_user`:return Z(`components.form.members.role.event_user`);case`content_user`:return Z(`components.form.members.role.content_user`);case`insta_user`:return Z(`components.form.members.role.insta_user`);default:return Z(`components.form.members.role.member`)}}function BP(e){switch(e){case`admin`:return Z(`components.form.members.role.desc.admin`);case`owner`:return Z(`components.form.members.role.desc.owner`);case`user`:return Z(`components.form.members.role.desc.user`);case`event_user`:return Z(`components.form.members.role.desc.event_user`);case`content_user`:return Z(`components.form.members.role.desc.content_user`);case`insta_user`:return Z(`components.form.members.role.desc.insta_user`);default:return Z(`components.form.members.role.desc.member`)}}function VP({trigger:e,roles:t=LP}){return(0,X.jsxs)(ar,{children:[(0,X.jsx)(vr,{render:t=>e?(0,X.jsx)(`span`,{...t,children:e}):(0,X.jsx)(U,{variant:`ghost`,size:`icon-sm`,type:`button`,"aria-label":Z(`components.form.members.role.info.button`),...t,children:(0,X.jsx)(ua,{className:`size-4`,"aria-hidden":!0})})}),(0,X.jsxs)(pr,{className:`sm:max-w-lg`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:Z(`components.form.members.role.info.title`)}),(0,X.jsx)(_r,{children:Z(`components.form.members.role.info.description`)})]}),(0,X.jsx)(`ul`,{className:`space-y-3`,children:t.map(e=>{if(e===`content_user`)return(0,X.jsxs)(`li`,{className:`rounded-lg border border-border bg-muted/20 px-4 py-3`,children:[(0,X.jsx)(`div`,{className:`text-sm font-semibold`,children:zP(e)}),(0,X.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:BP(e)})]},e)})})]})]})}VP.displayName=`RoleInfoDialog`;function HP(e){let t=Xe(e);return lt({draftEmail:H(),draftRole:t,invitations:Yt(lt({email:H().email(),role:t})).min(1,{message:Z(`components.form.members.emails.min`)})})}function UP({assignableRoles:e,authClient:t,organizationId:n,setDialogOpen:r}){let i=(0,Y.useId)(),a=(0,Y.useId)(),o=(0,Y.useId)(),s=(0,Y.useMemo)(()=>HP(e),[e]),c=l({resolver:pn(s),defaultValues:{draftEmail:``,draftRole:`content_user`,invitations:[]}}),{fields:u,append:d,remove:f}=v({control:c.control,name:`invitations`}),p=(0,Y.useCallback)(()=>
117{c.setValue(`draftEmail`,``),c.setValue(`draftRole`,`content_user`),c.clearErrors(`draftEmail`)},[c]),m=()=>{let e=c.getValues(`draftEmail`),t=c.getValues(`draftRole`),n=(e??``).trim(),r=H().email().safeParse(n);if(!r.success){c.setError(`draftEmail`,{message:Z(`components.form.members.invalid.email`)});return}let i=r.data.toLowerCase();if(c.getValues(`invitations`).some(e=>e.email.toLowerCase()===i)){c.setError(`draftEmail`,{message:Z(`components.form.members.duplicate`)});return}d({email:r.data,role:t}),p(),c.clearErrors(`invitations`)},g=async e=>{let{invitations:i}=e,a=await Promise.all(i.map(e=>t.organization.inviteMember({organizationId:n,email:e.email,role:`content_user`}))),o=i.filter((e,t)=>!!a[t]?.error);if(o.length===i.length){J.error(Z(`components.form.members.add.error`)),c.setError(`invitations`,{message:Z(`components.form.members.add.error`)});return}if(o.length>0){let e=o.map(e=>`${e.email}`).join(`, `);J.warning(`${Z(`components.form.members.add.partial`)}${e}`)}if(o.length<i.length){let e=i.length-o.length;J.success(e===1?Z(`components.form.members.add.success`):Z(`components.form.members.add.success_plural`).replace(`{{count}}`,String(e))),c.reset({draftEmail:``,draftRole:`content_user`,invitations:[]}),r(!1)}},y=typeof c.formState.errors.invitations==`object`&&c.formState.errors.invitations!==null&&`message`in c.formState.errors.invitations&&typeof c.formState.errors.invitations.message==`string`?c.formState.errors.invitations:void 0,b=`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,x=`h-10 min-h-10 w-full`;return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(rr,{className:`space-y-1 text-left`,children:[(0,X.jsx)(mr,{className:`text-lg`,children:Z(`common.invite.members`)}),(0,X.jsx)(_r,{children:Z(`components.form.members.add.description`)})]}),(0,X.jsx)(_,{...c,children:(0,X.jsxs)(`form`,{onSubmit:c.handleSubmit(g),className:`flex flex-col gap-6`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-4 md:flex-row md:items-end md:gap-3`,children:[(0,X.jsx)(h,{name:`draftEmail`,control:c.control,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,className:`min-w-0 flex-1 gap-2`,children:[(0,X.jsx)(K,{htmlFor:i,className:b,children:Z(`common.email`)}),(0,X.jsxs)(ln,{children:[(0,X.jsx)(W,{id:i,type:`email`,autoComplete:`off`,placeholder:Z(`components.form.members.email.placeholder`),"aria-invalid":t.invalid,className:x,...e,value:e.value??``,onChange:t=>{e.onChange(t),c.clearErrors(`draftEmail`)},onKeyDown:e=>{e.key===`Enter`&&(e.preventDefault(),m())}}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})]})}),(0,X.jsx)(h,{name:`draftRole`,control:c.control,render:({field:t})=>(0,X.jsxs)(G,{className:`w-full shrink-0 gap-2 md:w-54`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)(K,{htmlFor:a,className:b,children:Z(`components.form.members.role.label`)}),(0,X.jsx)(VP,{roles:e})]}),(0,X.jsx)(ln,{children:(0,X.jsxs)(Vt,{value:t.value||`content_user`,onValueChange:e=>t.onChange(e),defaultValue:`content_user`,children:[(0,X.jsx)(Dn,{id:a,className:x,children:(0,X.jsx)(Mt,{children:t.value?zP(t.value):Z(`components.form.members.role.placeholder`)})}),(0,X.jsx)(Dt,{children:e.map(e=>{if(e===`content_user`)return(0,X.jsx)(yn,{value:e,children:zP(e)},e)})})]})})]})}),(0,X.jsxs)(`div`,{className:`flex w-full shrink-0 flex-col gap-2 md:w-22`,children:[(0,X.jsx)(K,{className:q(b,`pointer-events-none invisible block w-full`),"aria-hidden":!0,children:Z(`common.email`)}),(0,X.jsx)(U,{type:`button`,className:q(x,`justify-center px-4`),onClick:m,children:Z(`components.form.members.addtolist`)})]})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Z(`components.form.members.email.description`)}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)(K,{id:o,className:`text-sm font-semibold`,children:Z(`components.form.members.queue.label`)}),(0,X.jsx)(`div`,{className:`space-y-2`,children:u.length===0?(0,X.jsx)(`div`,{className:`rounded-lg border border-dashed border-border bg-muted/20 px-4 py-8 text-center text-sm text-muted-foreground`,children:Z(`components.form.members.queue.empty`)}
117):(0,X.jsx)(`ul`,{role:`list`,"aria-labelledby":o,className:`space-y-2`,children:u.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`div`,{className:`flex items-center gap-3 rounded-lg border border-border bg-muted/25 px-3 py-2.5`,children:[(0,X.jsx)(`div`,{className:`flex size-9 shrink-0 items-center justify-center rounded-full bg-muted`,"aria-hidden":!0,children:(0,X.jsx)(Di,{className:`size-4 text-muted-foreground`})}),(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsx)(`div`,{className:`truncate text-sm leading-tight font-medium`,children:e.email}),(0,X.jsx)(`div`,{className:q(`mt-0.5 text-[11px] font-semibold tracking-wider uppercase`,e.role===`member`?`text-muted-foreground`:`text-primary`),children:zP(e.role)})]}),(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-sm`,className:`shrink-0 text-muted-foreground hover:text-destructive`,"aria-label":`${Z(`components.form.members.remove`)} (${e.email})`,onClick:()=>f(t),children:(0,X.jsx)(Qi,{className:`size-4`,"aria-hidden":!0})})]})},e.id))})}),y?.message?(0,X.jsx)(kt,{errors:[y]}):null]}),(0,X.jsx)(lr,{className:`flex-col gap-2 sm:flex-col`,children:(0,X.jsxs)(U,{type:`submit`,className:`w-full gap-2`,size:`lg`,disabled:c.formState.isSubmitting,children:[(0,X.jsx)(Ii,{className:`size-4`,"aria-hidden":!0}),Z(`components.form.members.add.submit`)]})})]})})]})}UP.displayName=`AddMembersFormInner`;var WP=({className:e})=>{let[t,n]=(0,Y.useState)(!1),{client:r,session:i,hasPermissions:a}=z(),o=md(),s=a(o,`invitation`,`create`),c=i?.user?.organizations?.find(e=>e.id===o)?.role,l=i?.user?.role===`admin`,u=(0,Y.useMemo)(()=>RP({inviterOrgRole:c,isPlatformAdmin:l}),[c,l]);return!s||u.length===0?null:(0,X.jsxs)(ar,{open:t,onOpenChange:n,children:[(0,X.jsx)(vr,{render:t=>(0,X.jsxs)(U,{className:q(e),...t,children:[(0,X.jsx)(Ci,{className:``}),Z(`components.form.members.add.button`)]})}),(0,X.jsx)(pr,{className:`sm:max-w-xl`,children:(0,X.jsx)(UP,{assignableRoles:u,authClient:r,organizationId:o,className:e,setDialogOpen:n},`${o}-${u.join(`|`)}`)})]})};WP.displayName=`AddMembers`;var GP=`bg-green-500/15 text-green-700 dark:text-green-400 border-green-500/30`,KP=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`email`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Email`}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.user.email})},{accessorKey:`image`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Avatar`}),cell:({row:e})=>(0,X.jsxs)(rs,{className:`h-4 w-4 text-[8px] font-medium`,children:[(0,X.jsx)(is,{src:e.original.user.image||``}),(0,X.jsx)(as,{children:e.original.user.name.charAt(0)})]}),enableSorting:!1},{accessorKey:`name`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Name`}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.user.name})},{accessorKey:`role`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Role`}),cell:({row:e})=>(0,X.jsx)(`div`,{children:zP(e.original.role)})},{id:`status`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Status`}),cell:()=>(0,X.jsx)(fr,{variant:`outline`,className:GP,children:`Active`}),enableSorting:!1},{id:`actions`,cell:({row:e})=>(0,X.jsx)(qP,{row:e})}],qP=({row:e})=>{let t=e.original,n=b(t.userId),{client:r,activeOrganization:i}=z(),[a,o]=(0,Y.useState)(!1);return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,variant:`ghost`,className:`h-8 w-8 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(st,{render:e=>(0,X.jsxs)(u,{to:n,...e,children:[(0,X.jsx)(va,{className:`size-4`}),Z(`routes.settings.members.columns.edit.member`)]})}),(0,X.jsx)(xe,{}),(0,X.jsx)(XM,{id:t.id,title:Z(`routes.settings.members.columns.delete.member`),deleteRow:async()=>{await r.organization.removeMember({memberIdOrEmail:t.id,organizationId:i?.id})},open:a,setOpen:o})]})})]})},JP={pending:`bg-yellow-500/15 text-yellow-700 dark:text-yellow-400 border-yellow-500/30`,accepted:`bg-green-500/15 text-green-700 dark:text-green-400 border-green-500/30`,declined:`bg-red-500/15 text-red-700 dark:text-red-400 border-red-500/30`},YP=e=>{if(!e)return`—`;let t=Date.now(),n=e.getTime()-t;if(n<=0)return`Expired`;let r=Math.floor(n/864e5);if(r>=1)return`in ${r} day${r===1?``:`s`}`;let i=Math.floor(n/36e5);return i>=1?`in ${i} hour${i===1?``:`s`}`:`in ${Math.max(1,Math.floor(n/6e4))} min`},XP=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`email`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Email`}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.email})},{accessorKey:`role`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Role`}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.role})},{accessorKey:`status`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Status`}),cell:({row:e})=>(0,X.jsx)(fr,{variant:`outline`,className:JP[e.original.status],children:e.original.status}),enableSorting:!1},{accessorKey:`expiresAt`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Expires`}),cell:({row:e})=>{let t=e.original.expiresAt,n=!!t&&t.getTime()<=Date.now();return(0,X.jsx)(`span`,{className:n?`text-destructive`:`text-muted-foreground`,children:YP(t)})}},{id:`actions`,cell:({row:e})=>(0,X.jsx)(ZP,{row:e})}],ZP=({row:e})=>{let t=e.original,{client:n}=z(),[r,i]=(0,Y.useState)(!1);return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,variant:`ghost`,className:`h-8 w-8 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(XM,{id:t.id,title:`Cancel invitation`,description:`This action cannot be undone. This will permanently cancel the invitation and remove it from the database.`,deleteRow:async()=>{await n.organization.cancelInvitation({invitationId:t.id})},open:r,setOpen:i})]})})]})},QP=`organization-invitations`,$P=({excludeEmails:e})=>{let{client:t}=z(),n=fe(),r=md(),{data:i,isLoading:a,isError:o}=V({queryKey:[QP,r],queryFn:async()=>(await t.organization.listInvitations({query:{organizationId:r}})).data?.map(e=>({id:e.id,organizationId:e.organizationId,email:e.email,role:e.role,status:e.status,expiresAt:e.expiresAt?new Date(e.expiresAt):void 0,inviterId:e.inviterId}))??[]}),s=i??null;if(a)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{className:`h-10 w-10`})});if(o)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:Z(`routes.settings.members.error`)});let c=(s??[]).filter(t=>t.status!==`accepted`&&!e?.has(t.email.toLowerCase()));return c.length===0?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-muted-foreground`,children:`No invitations`}):(0,X.jsx)(pd,{columns:XP,data:c,onDeleteSelected:async e=>{await Promise.all(e.map(e=>t.organization.cancelInvitation({invitationId:e.id}))),await n.invalidateQueries({queryKey:[QP,r]})},multipleDeleteString:{start:`Cancel`,end:`invitation`}})};$P.displayName=`Invitations`;var eF=`organization-members`,tF=()=>{let{client:e}=z(),t=fe(),n=md(),{data:r,isLoading:i,isError:a}=V({queryKey:[eF,n],queryFn:async()=>(await e.organization.listMembers({query:{organizationId:n}})).data?.members??[]}),o=r??null,s=(0,Y.useMemo)(()=>new Set((o??[]).map(e=>e.user.email.toLowerCase())),[o]);if(i)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{className:`h-10 w-10`})});if(a)return(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:Z(`routes.settings.members.error`)});let c;return c=!o||o.length===0?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center text-muted-foreground`,children:Z(`routes.settings.members.no.members.found`)}
117):(0,X.jsx)(pd,{columns:KP,data:o,navigateTo:{key:`userId`},onDeleteSelected:async r=>{let i=r.map(e=>e.id);await Promise.all(i.map(t=>e.organization.removeMember({memberIdOrEmail:t,organizationId:n}))),await t.invalidateQueries({queryKey:[eF,n]})},multipleDeleteString:{start:`Remove`,end:`member`}}),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.members`),actions:(0,X.jsx)(WP,{})}),(0,X.jsx)(wE,{children:(0,X.jsxs)(pu,{defaultValue:`members`,className:`flex flex-1 flex-col`,children:[(0,X.jsxs)(hu,{className:`w-fit border border-neutral-200 bg-neutral-100 shadow-xs dark:border-border/70 dark:bg-muted/60`,children:[(0,X.jsx)(gu,{value:`members`,children:`Members`}),(0,X.jsx)(gu,{value:`invitations`,children:`Invitations`})]}),(0,X.jsx)(_u,{value:`members`,className:`mt-4`,children:c}),(0,X.jsx)(_u,{value:`invitations`,className:`mt-4`,children:(0,X.jsx)($P,{excludeEmails:s})})]})})]})};function nF({onChange:e,value:t}){return(0,X.jsxs)(`div`,{className:`flex gap-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)($t,{htmlFor:`date-picker`,className:`px-1`,children:`Ban Expires`}),(0,X.jsxs)(jn,{children:[(0,X.jsxs)(Kn,{render:(0,X.jsx)(U,{variant:`outline`,id:`date-picker`,className:`w-52 justify-between font-normal`}),children:[t?t.toLocaleDateString():`Expires in `,(0,X.jsx)(Ka,{})]}),(0,X.jsx)(ur,{className:`w-auto overflow-hidden p-0`,align:`start`,children:(0,X.jsx)(Mw,{mode:`single`,selected:t,captionLayout:`dropdown`,onSelect:t=>{e(t??new Date)}})})]})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[(0,X.jsx)($t,{htmlFor:`time-picker`,className:`px-1`,children:`Time`}),(0,X.jsx)(W,{type:`time`,id:`time-picker`,step:`1`,defaultValue:`10:30:00`,className:`appearance-none bg-background [&::-webkit-calendar-picker-indicator]:hidden [&::-webkit-calendar-picker-indicator]:appearance-none`})]})]})}var rF=()=>{let{client:e,session:t,isLoadingSession:n}=z(),r=md(),i=fe(),{id:a}=S(),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)(!0),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(null),[m,h]=(0,Y.useState)(``),[g,_]=(0,Y.useState)(!1),[v,y]=(0,Y.useState)(``),[b]=(0,Y.useState)(0),[x,C]=(0,Y.useState)(!1),[w,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(``),[O,k]=(0,Y.useState)(``),[A,j]=(0,Y.useState)(!1),[M,N]=(0,Y.useState)(void 0),P=(0,Y.useRef)(0),F=t?.user?.organizations?.find(e=>e.id===r)?.role,I=(0,Y.useMemo)(()=>RP({inviterOrgRole:F,isPlatformAdmin:!0}),[F]),L=(0,Y.useMemo)(()=>{let e=new Set(I);return m&&e.add(m),LP.filter(t=>e.has(t))},[I,m]);(0,Y.useEffect)(function(){async function t(){if(!a){s(null),d(``),p(null),h(``),l(!1);return}l(!0);let t=++P.current;try{let[n,i]=await Promise.all([e.admin.getUser({query:{id:a}}),e.organization.listMembers({query:{organizationId:r}})]);if(t===P.current){s(n.data);let e=i?.data?.members?.find(e=>e.userId===a)??null,t=e?.role??``;p(e?.id??null),h(t),d(t)}}catch(e){console.error(`Error fetching user`,e),t===P.current&&(s(null),d(``),p(null),h(``))}finally{t===P.current&&l(!1)}}t()},[a,e,r]);let ee=!!t?.user.id,te=!!u&&!!f&&u!==m&&I.includes(u);if(!ee&&!n)return null;if(n)return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`routes.settings.members.member.title`)}),(0,X.jsx)(wE,{children:(0,X.jsx)(`div`,{className:`flex min-h-[40vh] items-center justify-center`,children:(0,X.jsx)(Uk,{className:`h-10 w-48 rounded-lg`})})})]});async function ne(t,n){if(!I.includes(t)){J.error(`You cannot assign this role.`);return}_(!0);try{await e.organization.updateMemberRole({memberId:n,organizationId:r,role:t}),h(t),await i.invalidateQueries({queryKey:[eF,r]}),J.success(`Role updated successfully`)}catch(e){console.error(e),J.error(`Failed to update role`)}finally{_(!1)}}async function re(t,n,r){C(!0);try{await e.admin.banUser({userId:t,banReason:n,banExpiresIn:r}),s(e=>e&&{...e,banned:!0,banReason:n,banExpires:null}),J.success(`User has been banned`)}catch(e){console.error(e),J.error(`Failed to ban user`)}finally{C(!1)}}async function R(t,n){j(!0);try{await e.admin.setUserPassword({userId:t,newPassword:n}),D(``),k(``),J.success(`Password updated successfully`)}catch(e){console.error(e),J.error(`Failed to update password`)}finally{j(!1)}}async function ie(t){T(!0);try{await e.admin.unbanUser({userId:t}),s(e=>e&&{...e,banned:!1,banReason:null,banExpires:null}),J.success(`User has been unbanned`)}catch(e){console.error(e),J.error(`Failed to unban user`)}finally{T(!1)}}return c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`routes.settings.members.member.title`)}),(0,X.jsx)(wE,{children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 lg:grid-cols-12`,children:[(0,X.jsx)(`div`,{className:`lg:col-span-4`,children:(0,X.jsx)(`div`,{className:`rounded-xl bg-muted/30 p-8`,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,X.jsx)(Uk,{className:`size-32 rounded-full`}),(0,X.jsx)(Uk,{className:`h-8 w-48`}),(0,X.jsx)(Uk,{className:`h-4 w-36`})]})})}),(0,X.jsxs)(`div`,{className:`space-y-8 lg:col-span-8`,children:[(0,X.jsx)(Uk,{className:`h-64 w-full rounded-xl`}),(0,X.jsx)(Uk,{className:`h-80 w-full rounded-xl`})]})]})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`routes.settings.members.member.title`)}),(0,X.jsx)(wE,{children:(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 lg:grid-cols-12`,children:[(0,X.jsxs)(`div`,{className:`space-y-6 lg:col-span-4`,children:[(0,X.jsx)(`section`,{className:`rounded-xl bg-muted/30 p-8`,children:(0,X.jsxs)(`div`,{className:`flex flex-col items-center text-center`,children:[(0,X.jsxs)(`div`,{className:`relative mb-6`,children:[(0,X.jsxs)(rs,{className:`size-32 ring-4 ring-primary/20 ring-offset-4 ring-offset-background`,children:[(0,X.jsx)(is,{src:o?.image??void 0}),(0,X.jsx)(as,{className:`text-3xl font-bold`,children:o?.name?.charAt(0)})]}),o?.emailVerified&&(0,X.jsx)(`div`,{className:`absolute right-1 bottom-1 rounded-full bg-primary p-1.5 shadow-lg`,children:(0,X.jsx)(ta,{className:`size-3 text-primary-foreground`})})]}),(0,X.jsx)(`h1`,{className:`text-3xl font-extrabold tracking-tight`,children:o?.name??`-`}),(0,X.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:o?.email??`-`}),(0,X.jsxs)(`div`,{className:`mt-4 flex flex-wrap justify-center gap-2`,children:[m&&(0,X.jsx)(fr,{variant:`default`,className:`text-[10px] tracking-widest uppercase`,children:zP(m)}),o?.emailVerified&&(0,X.jsx)(fr,{variant:`secondary`,className:`text-[10px] tracking-widest uppercase`,children:`Verified`}),o?.banned&&(0,X.jsx)(fr,{variant:`destructive`,className:`text-[10px] tracking-widest uppercase`,children:`Banned`})]}),(0,X.jsx)(gn,{className:`my-8`}),(0,X.jsxs)(`div`,{className:`grid w-full grid-cols-2 gap-4 text-left`,children:[(0,X.jsx)(aF,{label:`Joined`,value:o?.createdAt?new Date(o.createdAt).toLocaleDateString():`-`}),(0,X.jsx)(aF,{label:`Last Updated`,value:o?.updatedAt?new Date(o.updatedAt).toLocaleDateString():`-`}),(0,X.jsx)(aF,{label:`Email Verified`,value:o?.emailVerified?`Yes`:`No`})]})]})}),o?.banned&&(0,X.jsxs)(`section`,{className:`rounded-xl border border-destructive/20 bg-destructive/5 p-6`,children:[(0,X.jsx)(`h3`,{className:`mb-4 text-[10px] font-bold tracking-widest text-destructive uppercase`,children:`Banned`}),(0,X.jsxs)(`div`,{className:`space-y-3`,children:[o.banReason&&(0,X.jsx)(oF,{label:`Reason`,value:o.banReason}),o.banExpires?(0,X.jsx)(oF,{label:`Expires`,value:new Date(o.banExpires).toLocaleStr
117ing()}):(0,X.jsx)(oF,{label:`Duration`,value:`Permanent`})]})]})]}),(0,X.jsxs)(`div`,{className:`space-y-8 lg:col-span-8`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-8 md:grid-cols-2`,children:[(0,X.jsxs)(`section`,{className:`rounded-xl bg-muted/30 p-8`,children:[(0,X.jsx)(sF,{icon:(0,X.jsx)(ta,{className:`size-5 text-primary`}),title:`Permissions`}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,X.jsx)($t,{className:`text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:`Member Role`}),(0,X.jsx)(VP,{roles:I})]}),(0,X.jsxs)(Vt,{value:u,onValueChange:e=>d(e),children:[(0,X.jsx)(Dn,{className:`mt-2 w-full`,children:(0,X.jsx)(Mt,{children:u?zP(u):Z(`components.form.members.role.placeholder`)})}),(0,X.jsx)(Dt,{children:L.map(e=>(0,X.jsx)(yn,{value:e,children:zP(e)},e))})]})]}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(U,{disabled:!f||!u||g||!te,onClick:()=>f&&u&&ne(u,f),children:g?`Saving...`:`Save Role`})})]})]}),(0,X.jsxs)(`section`,{className:`rounded-xl bg-muted/30 p-8`,children:[(0,X.jsx)(sF,{icon:(0,X.jsx)(Ta,{className:`size-5 text-primary`}),title:`Security Override`}),(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($t,{className:`text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:`New Password`}),(0,X.jsx)(W,{type:`password`,value:E,onChange:e=>D(e.target.value),placeholder:`Enter new password`,className:`mt-2 w-full`})]}),E.length>0&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)($t,{className:`text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:`Confirm Password`}),(0,X.jsx)(W,{type:`password`,value:O,onChange:e=>k(e.target.value),placeholder:`Confirm new password`,className:`mt-2 w-full`})]}),(0,X.jsx)(`div`,{className:`flex justify-end`,children:(0,X.jsx)(U,{disabled:!o?.id||!E||E!==O||A,onClick:()=>o?.id&&E&&R(o.id,E),children:A?`Saving...`:`Set Password`})})]})]})]}),(0,X.jsxs)(`section`,{className:`overflow-hidden rounded-xl border-l-4 border-destructive/50 bg-muted/30`,children:[(0,X.jsxs)(`div`,{className:`border-b border-border p-8`,children:[(0,X.jsxs)(`div`,{className:`mb-2 flex items-center gap-3`,children:[(0,X.jsx)(Sa,{className:`size-5 text-destructive`}),(0,X.jsx)(`h2`,{className:`text-lg font-bold tracking-tight`,children:`Restrictive Actions`})]}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Enforce account bans or temporary suspensions based on community violations.`})]}),(0,X.jsxs)(`div`,{className:`space-y-6 p-8`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-1 gap-6 md:grid-cols-2`,children:[(0,X.jsx)(nF,{value:M,onChange:e=>N(e)}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsx)($t,{className:`text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:`Duration Presets`}),(0,X.jsx)(`div`,{className:`mt-1 flex gap-2`,children:iF.map(e=>(0,X.jsx)(U,{variant:`outline`,size:`sm`,className:`flex-1`,onClick:()=>N(new Date(Date.now()+e.ms)),children:e.label},e.label))})]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($t,{className:`text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:`Ban Reason`}),(0,X.jsx)(bt,{value:v,onChange:e=>y(e.target.value),placeholder:`Specify the reason for this enforcement action...`,rows:3,className:`mt-2`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col items-center justify-between gap-4 pt-4 md:flex-row`,children:[(0,X.jsx)(U,{variant:`destructive`,disabled:!o?.id||x,onClick:()=>o?.id&&re(o.id,v,Number(b)||0),children:x?`Banning...`:`Ban User`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3`,children:[o?.banned&&(0,X.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[(0,X.jsx)(ri,{className:`mr-1 inline size-3`}),`Currently banned`]}),(0,X.jsx)(U,{variant:`ghost`,disabled:!o?.id||w||!o?.banned,onClick:()=>o?.id&&ie(o.id),children:w?`Unbanning...`:`Unban User`})]})]})]})]})]})]})})]})};rF.displayName=`Member`;var iF=[{label:`24h`,ms:864e5},{label:`7 Days`,ms:6048e5},{label:`30 Days`,ms:2592e6}];function aF({label:e,value:t}){return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:e}),(0,X.jsx)(`div`,{className:`mt-1 text-sm font-medium`,children:t})]})}function oF({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:e}),(0,X.jsx)(`span`,{className:`max-w-45 truncate text-sm font-medium`,children:t})]})}function sF({icon:e,title:t}){return(0,X.jsxs)(`div`,{className:`mb-6 flex items-center gap-3`,children:[e,(0,X.jsx)(`h2`,{className:`text-lg font-bold tracking-tight`,children:t})]})}var cF=lt({name:H().min(1)}),lF=()=>{let{client:e,activeOrganization:t}=z(),n=l({resolver:pn(cF),defaultValues:{name:t?.name}}),r=async n=>{let r=n.name;if(t?.id)try{await e.organization.update({organizationId:t?.id,data:{name:r}}),J.success(`Success !`,{description:`Your organization name has been changed successfully`})}catch(e){console.error(e),J.error(`Error changing organization name`)}};return(0,X.jsx)(`div`,{className:`space-y-2`,children:(0,X.jsx)(_,{...n,children:(0,X.jsxs)(`form`,{onSubmit:n.handleSubmit(r),id:`change-organization-name-form`,children:[(0,X.jsx)(`label`,{className:`block px-1 text-[10px] font-bold tracking-widest text-muted-foreground uppercase`,children:Z(`common.organization.name`)}),(0,X.jsx)(h,{control:n.control,name:`name`,render:({field:e})=>(0,X.jsx)(W,{...e,type:`text`,className:`mt-2 rounded-lg border-0 border-b-2 border-transparent bg-muted px-4 py-3 transition-all outline-none focus:border-primary focus:ring-0`})}),n.formState.isDirty&&(0,X.jsx)(U,{type:`submit`,size:`sm`,className:`mt-3`,disabled:n.formState.isSubmitting,children:n.formState.isSubmitting?`Saving...`:`Save`})]})})})};lF.displayName=`ChangeOrganizationName`;var uF=()=>{let{activeOrganization:e,client:t,refetchSession:n}=z(),{data:r,refetch:i}=t.useListOrganizations(),[a,o]=(0,Y.useState)(null),s=r?.find(t=>
117t.id===e?.id)?.logo??``;(0,Y.useEffect)(function(){if(!a)return;let r=P.get$(`file.response`).pipe(O(e=>e.source===a)).subscribe(async r=>{if(r.payload&&`files`in r.payload){let a=r.payload.files[0];if(a?.url&&e?.id)try{await t.organization.update({organizationId:e.id,data:{logo:a.url}}),i(),n(),J.success(`Organization logo updated successfully`)}catch(e){console.error(`Failed to update logo:`,e),J.error(`Failed to update logo`)}o(null)}});return()=>{r.unsubscribe()}},[a,t,e,n,i]);let c=()=>{let e=xr();o(e),P.publish({type:`file.request`,id:e,payload:{fileType:`image`,multiple:!1,title:`Select Organization Logo`,uploadOnly:!1}})};return(0,X.jsxs)(`div`,{className:`flex items-center gap-8 rounded-xl border border-border bg-card p-8`,children:[(0,X.jsx)(`div`,{className:`group relative`,children:(0,X.jsx)(`div`,{className:`cursor-pointer overflow-hidden rounded-xl ring-1 ring-border transition-shadow hover:ring-primary/40`,onClick:c,children:(0,X.jsxs)(rs,{className:`size-32 rounded-xl bg-background after:rounded-xl`,children:[(0,X.jsx)(is,{src:s,alt:e?.name,className:`rounded-xl object-contain p-3`}),(0,X.jsx)(as,{className:`rounded-xl text-2xl`,children:s?e?.name.charAt(0)||`O`:(0,X.jsx)(oo,{className:`h-8 w-8 text-muted-foreground`})})]})})}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h3`,{className:`text-xl font-bold`,children:e?.name}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`JPG, PNG or GIF. Max size 2MB.`}),(0,X.jsxs)(`div`,{className:`flex gap-3 pt-2`,children:[(0,X.jsx)(`button`,{type:`button`,className:`text-[10px] font-bold tracking-widest text-primary uppercase hover:underline`,onClick:c,children:`Upload New`}),s&&(0,X.jsx)(`button`,{type:`button`,className:`text-[10px] font-bold tracking-widest text-destructive/70 uppercase hover:text-destructive`,onClick:async()=>{if(e?.id)try{await t.organization.update({organizationId:e.id,data:{logo:``}}),i(),n(),J.success(`Logo removed`)}catch(e){console.error(`Failed to remove logo:`,e),J.error(`Failed to remove logo`)}},children:`Remove`})]})]})]})};uF.displayName=`OrganizationLogo`;var dF=()=>{let{activeOrganization:e}=z();return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:e?.name||Z(`common.organization`)}),(0,X.jsx)(wE,{children:(0,X.jsxs)(`div`,{className:`w-full max-w-5xl space-y-12`,children:[(0,X.jsx)(`p`,{className:`max-w-xl text-xs text-muted-foreground`,children:Z(`routes.settings.organization.subtitle`)}),(0,X.jsxs)(`section`,{className:`grid gap-8 md:grid-cols-3`,children:[(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold`,children:Z(`common.change.organization.name`)}),(0,X.jsx)(`p`,{className:`text-xs leading-relaxed text-muted-foreground`,children:Z(`common.svg.png.jpg.or.gif`)})]}),(0,X.jsxs)(`div`,{className:`space-y-6 md:col-span-2`,children:[(0,X.jsx)(uF,{}),(0,X.jsx)(lF,{})]})]})]})})]})},fF=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:!!(e.getIsAllPageRowsSelected()||e.getIsSomePageRowsSelected()),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`name`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.name`)}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.name})},{accessorKey:`slug`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.worlds.columns.slug`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:``,children:e.original.slug})},{accessorKey:`logo`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`routes.organizations.columns.logo`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`flex items-center justify-start`,children:e.original.logo?(0,X.jsx)(`img`,{src:e.original.logo,alt:`Organization Logo`,className:`aspect-square h-4 w-4 rounded-full object-cover`}):(0,X.jsx)(Ri,{className:`size-4 rounded-full text-muted-foreground opacity-50`})})},{accessorKey:`createdAt`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.created.at`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:``,children:$i(new Date(e.original.createdAt),`dd-MM-yyyy HH:mm`)})},{id:`actions`,cell:({row:e})=>(0,X.jsx)(pF,{row:e})}],pF=({row:e})=>{let t=e.original,{client:n,activeOrganization:r}=z(),[i,a]=(0,Y.useState)(!1),o=b(t.id),s=b(`/${r?.slug}/dashboard/settings/organizations/${e.original.id}`);return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,variant:`ghost`,className:`h-8 w-8 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(st,{render:e=>(0,X.jsx)(u,{to:o,...e,children:Z(`routes.organizations.columns.view.organization`)})}),(0,X.jsx)(st,{render:e=>(0,X.jsx)(u,{to:s,...e,children:Z(`routes.organizations.columns.edit.organization`)})}),(0,X.jsx)(xe,{}),(0,X.jsx)(XM,{id:e.original.id,title:Z(`routes.organizations.columns.delete.organization`),deleteRow:async()=>{await n.organization.delete({organizationId:e.original.id})},open:i,setOpen:a})]})})]})},mF={languageCode:`en`,name:`English`,nativeName:`English`,isDefault:!0,order:1},hF=lt({name:H().min(1),slug:H().min(1)}),gF=()=>{let[e,t]=(0,Y.useState)(!1),n=l({resolver:pn(hF),defaultValues:{name:``,slug:``}}),{client:r}=z(),i=async e=>{try{let t=(await r.organization.create({name:e.name,slug:e.slug})).data?.id;t&&await r.organization.update({organizationId:t,data:{metadata:{locales:[mF]}}}),J.success(`Organization created successfully`)}catch(e){console.error(e),J.error(`Failed to create organization`,{description:`Please try again`})}t(!1)};return(0,X.jsxs)(ar,{open:e,onOpenChange:t,children:[(0,X.jsx)(vr,{render:e=>(0,X.jsxs)(U,{...e,children:[(0,X.jsx)(Ci,{className:``}),Z(`common.create.organization`)]})}),(0,X.jsxs)(pr,{className:`sm:max-w-106.25`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:`Create organization`}),(0,X.jsx)(_r,{children:`Add a new organization to your account.`})]}),(0,X.jsx)(_,{...n,children:(0,X.jsxs)(`form`,{onSubmit:n.handleSubmit(i),className:`flex w-full flex-col gap-4`,children:[(0,X.jsx)(h,{control:n.control,name:`name`,render:({field:e,fieldState:t})=>
117(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:`Organization name`}),(0,X.jsx)(W,{id:`name`,placeholder:`Acme Inc.`,...e}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:n.control,name:`slug`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:`Organization slug`}),(0,X.jsx)(W,{id:`slug`,placeholder:`acme`,...e}),t.error&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsxs)(lr,{children:[(0,X.jsx)(U,{variant:`outline`,onClick:()=>t(!1),children:`Cancel`}),(0,X.jsx)(U,{onClick:()=>t(!1),children:`Create`})]})]})})]})]})},_F=()=>{let{client:e,hasPermissions:t,activeOrganization:n}=z(),{data:r,isPending:i,error:a}=e.useListOrganizations();return i?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{})}):a?(0,X.jsx)(`div`,{children:Z(`routes.organizations.error`)}):!r||!n?.id?(0,X.jsx)(`div`,{children:Z(`routes.organizations.no.organizations.found`)}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.organizations`),actions:t(n?.id,`organization`,`create`)?(0,X.jsx)(gF,{}):null}),(0,X.jsx)(wE,{children:(0,X.jsx)(pd,{columns:fF,data:r,navigateTo:{key:`id`}})})]})};_F.displayName=`Organizations`;var vF=lt({email:H().email(`Please enter a valid email address`),password:H().min(1,`Password is required`)});function yF({className:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(null),{signIn:a}=z(),{theme:o,setTheme:s}=qn(),c=l({resolver:pn(vF),defaultValues:{email:``,password:``}}),d=async e=>{n(!0),i(null);try{await a(e.email,e.password)}catch(e){console.error(e),i(Z(`routes.signin.error`))}finally{n(!1)}},f=o===`dark`||o===`system`&&typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches;return(0,X.jsxs)(`div`,{className:q(`w-full max-w-107`,e),children:[(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`fixed top-4 right-4 z-50 text-muted-foreground hover:text-foreground`,onClick:()=>s(f?`light`:`dark`),"aria-label":f?`Switch to light mode`:`Switch to dark mode`,children:f?(0,X.jsx)(fa,{className:`size-4`}):(0,X.jsx)(si,{className:`size-4`})}),(0,X.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-8 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-primary/10`,children:(0,X.jsx)(Kr,{className:`h-7 w-7 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`h1`,{className:`text-[1.75rem] font-normal tracking-tight text-foreground`,children:Z(`routes.signin.authheader.title`)}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:Z(`routes.signin.autheader.subtitle`)})]})]}),(0,X.jsxs)(`form`,{onSubmit:c.handleSubmit(d),className:`space-y-5`,children:[(0,X.jsx)(Vo,{error:r}),(0,X.jsx)(h,{control:c.control,name:`email`,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{"data-invalid":!!n.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`common.email`)}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,id:`email`,type:`email`,autoComplete:`email`,placeholder:Z(`routes.signin.email.input.placeholder`),disabled:t,className:`h-12 rounded-lg border-input bg-background px-4 focus-visible:ring-2 focus-visible:ring-primary/30`})}),(0,X.jsx)(kt,{errors:[n.error]})]})}),(0,X.jsx)(h,{control:c.control,name:`password`,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{"data-invalid":!!n.error,children:[(0,X.jsxs)(`div`,{className:`flex items-center`,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`common.password`)}),(0,X.jsx)(u,{to:`/forgot-password`,className:`ml-auto text-sm text-primary underline-offset-2 hover:underline`,children:Z(`common.forgot.password`)})]}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,id:`password`,type:`password`,autoComplete:`current-password`,disabled:t,className:`h-12 rounded-lg border-input bg-background px-4 focus-visible:ring-2 focus-visible:ring-primary/30`})}),(0,X.jsx)(kt,{errors:[n.error]})]})}),(0,X.jsx)(U,{type:`submit`,className:`mt-2 h-12 w-full rounded-full text-base font-medium`,size:`lg`,disabled:t,children:t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(An,{className:`mr-2 h-4 w-4`}),Z(`common.signing.in`)]}):Z(`common.sign.in`)})]})]}),(0,X.jsx)(ds,{})]})}yF.displayName=`SignInForm`;var bF=({className:e,...t})=>(0,X.jsx)(`div`,{className:q(`flex min-h-svh items-center justify-center bg-muted/50 p-4 sm:p-6`,e),...t,children:(0,X.jsx)(yF,{})});bF.displayName=`SignIn`;var xF=lt({email:H().email(`Please enter a valid email address`),name:H().min(1,`Name is required`),password:H().min(8,`Password must be at least 8 characters`),confirmPassword:H().min(8)}).refine(e=>e.password===e.confirmPassword,{message:Z(`routes.signup.password.error.match`),path:[`confirmPassword`]}),SF=[{label:e=>Z(e),key:`routes.signup.password.must.contain.at.least.8.characters`,test:e=>e.length>=8},{label:e=>Z(e),key:`routes.signup.password.must.contain.one.uppercase.letter`,test:e=>/[A-Z]/.test(e)},{label:e=>Z(e),key:`routes.signup.password.must.contain.one.lowercase.letter`,test:e=>/[a-z]/.test(e)},{label:e=>Z(e),key:`routes.signup.password.must.contain.one.number`,test:e=>/\d/.test(e)}];function CF({password:e}){let t=e.length===0;return(0,X.jsx)(`ul`,{className:`mt-1.5 space-y-1 pl-0.5`,children:SF.map(({key:n,label:r,test:i})=>{let a=i(e);return(0,X.jsxs)(`li`,{className:q(`flex items-center gap-1.5 text-xs transition-colors`,{"text-muted-foreground":t,"text-green-600 dark:text-green-400":!t&&a,"text-destructive":!t&&!a}),children:[(0,X.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full bg-current`}),r(n)]},n)})})}function wF({className:e}){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,d]=(0,Y.useState)(!1),{client:f}=z(),p=c(),m=C(),{theme:g,setTheme:_}=qn(),v=l({resolver:pn(xF),defaultValues:{email:``,name:``,password:``,confirmPassword:``}}),y=async e=>{n(!0),i(null);try{await f.signUp.email({email:e.email,password:e.password,name:e.name}),J.success(Z(`routes.signup.success`));let t=m.state?.from?.pathname;t&&p(t,{replace:!0})}catch{i(Z(`routes.signup.error`))}finally{n(!1)}},b=g===`dark`||g===`system`&&typeof window<`u`&&window.matchMedia?.(`(prefers-color-scheme: dark)`).matches;return(0,X.jsxs)(`div`,{className:q(`w-full max-w-107`,e),children:[(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`fixed top-4 right-4 z-50 text-muted-foreground hover:text-foreground`,onClick:()=>_(b?`light`:`dark`),"aria-label":b?`Switch to light mode`:`Switch to dark mode`,children:b?(0,X.jsx)(fa,{className:`size-4`}):(0,X.jsx)(si,{className:`size-4`})}),(0,X.jsxs)(`div`,{className:`rounded-2xl border border-border bg-card p-8 shadow-sm`,children:[(0,X.jsxs)(`div`,{className:`mb-8 flex flex-col items-center gap-3`,children:[(0,X.jsx)(`div`,{className:`flex h-14 w-14 items-center justify-center rounded-full bg-primary/10`,children:(0,X.jsx)(Di,{className:`h-7 w-7 text-primary`,"aria-hidden":!0})}),(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(`h1`,{className:`text-[1.75rem] font-normal tracking-tight text-foreground`,children:Z(`routes.signup.authheader.title`)}),(0,X.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:Z(`routes.signup.autheader.subtitle`)})]})]}),(0,X.jsxs)(`form`,{onSubmit:v.handleSubmit(y),className:`space-y-5`,children:[(0,X.jsx)(Vo,{error:r}),(0,X.jsx)(h,{control:v.control,name:`email`,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{"data-invalid":!!n.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`common.email`)}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,type:`email`,autoComplete:`email`,disabled:t,className:`h-12 rounded-lg border-input bg-background px-4 focus-visible:ring-2 focus-visible:ring-primary/30`})}),(0,X.jsx)(kt,{errors:[n.error]})]})}),(0,X.jsx)(h,{control:v.control,name:`name`,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{"data-invalid":!!n.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`common.name`)}),(0,X.jsx)(ln,{children:(0,X.jsx)(W,{...e,type:`text`,autoComplete:`name`,disabled:t,className:`h-12 rounded-lg border-input bg-background px-4 focus-visible:ring-2 focus-visible:ring-primary/30`})}),(0,X.jsx)(kt,{errors:[n.error]})]})}),(0,X.jsx)(h,{control:v.control,name:`password`,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{"data-invalid":!!n.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`common.password`)}),(0,X.jsx)(ln,{children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(W,{...e,type:a?`text`:`password`,autoComplete:`new-password`,disabled:t,className:`h-12 rounded-lg border-input bg-background px-4 pr-12 focus-visible:ring-2 focus-visible:ring-primary/30`}),e.value.length>0&&(0,X.jsx)(U,{variant:`ghost`,size:`icon`,type:`button`,className:`absolute top-0 right-0 h-12 w-12 text-muted-foreground hover:bg-transparent hover:text-foreground`,onClick:()=>o(!a),"aria-label":a?`Hide password`:`Show password`,children:a?(0,X.jsx)(li,{className:`h-4 w-4`}):(0,X.jsx)(Rr,{className:`h-4 w-4`})})]})}),(0,X.jsx)(CF,{password:e.value}),(0,X.jsx)(kt,{errors:[n.error]})]})}),(0,X.jsx)(h,{control:v.control,name:`confirmPassword`,render:({field:e,fieldState:n})=>(0,X.jsxs)(G,{"data-invalid":!!n.error,children:[(0,X.jsx)(K,{className:`text-sm font-medium text-muted-foreground`,children:Z(`routes.signup.password.for.confirmation`)}),(0,X.jsx)(ln,{children:(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(W,{...e,type:s?`text`:`password`,autoComplete:`new-password`,disabled:t,className:`h-12 rounded-lg border-input bg-background px-4 pr-12 focus-visible:ring-2 focus-visible:ring-primary/30`}),e.value.length>0&&(0,X.jsx)(U,{variant:`ghost`,size:`icon`,type:`button`,className:`absolute top-0 right-0 h-12 w-12 text-muted-foreground hover:bg-transparent hover:text-foreground`,onClick:()=>d(!s),"aria-label":s?`Hide password`:`Show password`,children:s?(0,X.jsx)(li,{className:`h-4 w-4`}):(0,X.jsx)(Rr,{className:`h-4 w-4`})})]})}),(0,X.jsx)(kt,{errors:[n.error]})]})}),(0,X.jsx)(U,{type:`submit`,className:`mt-2 h-12 w-full rounded-full text-base font-medium`,size:`lg`,disabled:t,children:t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(An,{className:`mr-2 h-4 w-4`}),Z(`common.sign.up`),`…`]}):Z(`common.sign.up`)}),(0,X.jsxs)(`div`,{className:`text-center text-sm text-muted-foreground`,children:[`Already have an account?`,` `,(0,X.jsx)(u,{to:`/signin`,className:`text-primary underline-offset-2 hover:underline`,children:`Sign in`})]})]})]}),(0,X.jsx)(ds,{})]})}wF.displayName=`SignUpForm`;var TF=({className:e,...t})=>(0,X.jsx)(`div`,{className:q(`flex h-svh items-center justify-center overflow-y-auto bg-muted/50 p-4 sm:p-6`,e),...t,children:(0,X.jsx)(wF,{})});TF.displayName=`SignUp`;function EF(e,t){let n=t.trim().toLowerCase();return n?e.filter(e=>e.name.toLowerCase().includes(n)):e}function DF({label:e,options:t,value:n,onChange:r,idPrefix:i,isLoading:a,error:o,emptyMessage:s}){return o?(0,X.jsx)(`p`,{role:`alert`,className:`text-sm text-destructive`,children:o}):a?(0,X.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,X.jsxs)(`span`,{role:`status`,className:`sr-only`,children:[`Loading `,e,`…`]}
117),(0,X.jsx)(`div`,{className:`flex flex-col gap-2`,"aria-hidden":`true`,children:[0,1,2,3].map(e=>(0,X.jsx)(Uk,{className:`h-8 w-full`},e))})]}):t.length===0?(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s}):(0,X.jsx)(OF,{label:e,options:t,value:n,onChange:r,idPrefix:i})}DF.displayName=`LinkedCollectionsBody`;function OF({label:e,options:t,value:n,onChange:r,idPrefix:i}){let[a,o]=(0,Y.useState)(``),s=(0,Y.useMemo)(()=>new Set(n),[n]),c=(0,Y.useMemo)(()=>EF(t,a),[t,a]),l=(e,t)=>{r(t?[...n,e]:n.filter(t=>t!==e))};return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(W,{value:a,onChange:e=>o(e.target.value),onKeyDown:e=>{e.key===`Enter`&&e.preventDefault()},placeholder:`Filter…`,"aria-label":`Filter ${e}`}),(0,X.jsxs)(`div`,{className:`flex max-h-64 flex-col gap-1 overflow-y-auto`,children:[c.map(e=>{let t=`${i}-${e.id}`,n=`${t}-label`;return(0,X.jsxs)(`div`,{className:`flex items-center gap-2 px-1 py-1.5`,children:[(0,X.jsx)(Pd,{id:t,"aria-labelledby":n,checked:s.has(e.id),onCheckedChange:t=>l(e.id,t===!0)}),(0,X.jsx)(`label`,{id:n,htmlFor:t,className:`flex-1 cursor-pointer text-sm`,children:e.name})]},e.id)}),c.length===0&&(0,X.jsx)(`p`,{className:`px-1 py-2 text-sm text-muted-foreground`,children:`No matches.`})]}),(0,X.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,X.jsxs)(`span`,{"aria-live":`polite`,className:`text-xs text-muted-foreground`,children:[n.length,` selected`]}),n.length>0&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>r([]),className:`text-xs text-muted-foreground underline`,children:`Clear`})]})]})}OF.displayName=`LinkedCollectionsList`;function kF({label:e,options:t,value:n,onChange:r,isLoading:i=!1,error:a=null,emptyMessage:o=`Nothing to link yet.`}){let[s,c]=(0,Y.useState)(!1),l=(0,Y.useId)();return(0,X.jsxs)(Zt,{className:`gap-2`,children:[(0,X.jsx)(Pt,{variant:`label`,className:`mb-0 w-full`,children:(0,X.jsxs)(`button`,{type:`button`,"aria-expanded":s,"aria-controls":l,onClick:()=>c(e=>!e),className:`flex w-full items-center gap-2 py-1 text-left`,children:[(0,X.jsx)(`span`,{className:`flex-1`,children:e}),(0,X.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[n.length,` linked`]}),(0,X.jsx)(Ka,{"aria-hidden":`true`,className:q(`size-4 shrink-0 transition-transform`,s&&`rotate-180`)})]})}),(0,X.jsx)(`div`,{id:l,hidden:!s,className:`flex flex-col gap-2`,children:(0,X.jsx)(DF,{label:e,options:t,value:n,onChange:r,idPrefix:l,isLoading:i,error:a,emptyMessage:o})})]})}kF.displayName=`LinkedCollectionsField`;function AF({label:e,errorMessage:t,emptyMessage:n,data:r,isLoading:i,isError:a,value:o,onChange:s}){return(0,X.jsx)(kF,{label:e,options:r?.items??[],value:o,onChange:s,isLoading:i,error:a?t:null,emptyMessage:n})}AF.displayName=`LinkedCollectionsSection`;function jF({value:e,onChange:t}){let n=R(),r=md(),{data:i,isLoading:a,isError:o}=V(n.cms.collections.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:r}));return(0,X.jsx)(AF,{label:`Collections`,errorMessage:`Could not load collections.`,emptyMessage:`No collections in this organization yet.`,data:i,isLoading:a,isError:o,value:e,onChange:t})}jF.displayName=`CmsCollectionsSection`;function MF({value:e,onChange:t}){let n=R(),r=md(),{data:i,isLoading:a,isError:o}=V(n.localization.labelCollections.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:r}));return(0,X.jsx)(AF,{label:`Labels`,errorMessage:`Could not load label collections.`,emptyMessage:`No label collections in this organization yet.`,data:i,isLoading:a,isError:o,value:e,onChange:t})}MF.displayName=`LabelCollectionsSection`;var NF=lt({name:H().min(1,{message:Z(`components.space.details.name.required`)}),description:H().optional(),thumbnail:lt({id:H(),metadata:kn(H(),et()),mimetype:H(),type:H(),url:H().optional()}).optional(),thumbnailId:H().optional().nullable(),template:be(),cmsCollectionIds:Yt(H()).optional(),labelCollectionIds:Yt(H()).optional()}),PF={details:{label:Z(`common.details`),description:Z(`components.space.details.tab.details.description`)},thumbnail:{label:Z(`common.thumbnail`),description:Z(`components.space.details.tab.thumbnail.description`)},collections:{label:Z(`common.content`),description:Z(`components.space.details.tab.collections.description`)}};function FF(){let e=p(),{capture:t,busy:n,isCapturing:r,isUploading:i}=xd({getFilename:()=>e.getValues(`name`)??``,onCaptured:({fileId:t,fileUrl:n})=>{e.setValue(`thumbnail`,{id:t,url:n,mimetype:`image/png`,type:`image`,metadata:{}},{shouldDirty:!0}),e.setValue(`thumbnailId`,t,{shouldDirty:!0})}}),a=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(za,{className:`size-4`}),Z(`components.space.details.thumbnail.capture`)]});return i?a=Z(`components.space.details.thumbnail.uploading`):r&&(a=Z(`components.space.details.thumbnail.capturing`)),(0,X.jsx)(U,{type:`button`,variant:`outline`,className:`w-full`,onClick:t,disabled:n,children:a})}function IF({id:e,worldId:t,open:n,onOpenChange:r,onSuccess:i,trigger:a}){let o=R(),s=fe(),[c,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(`details`),g=(0,Y.useRef)(n),v=(0,Y.useRef)(null),b=(0,Y.useId)(),x=`${b}-name`,S=`${b}-description`,C=`${b}-template`,w=o.space.get.queryOptions([e],{enabled:n&&!!e}),{data:T,dataUpdatedAt:E,isLoading:D}=V(w),k=T?.[0],A=o.space.list.queryKey(),j=o.space.get.queryKey([e]),M=t?o.world.get.queryKey([t]):void 0,N=B(o.space.update.mutationOptions()),F=l({resolver:pn(NF),defaultValues:{name:``,description:``,thumbnail:void 0,thumbnailId:void 0,template:!1,cmsCollectionIds:[],labelCollectionIds:[]}}),{dirtyFields:I,isDirty:L}=F.formState,{reset:ee}=F,te=y({control:F.control,name:`cmsCollectionIds`}),ne=y({control:F.control,name:`labelCollectionIds`});(0,Y.useEffect)(function(){if(!n){g.current&&(ee(),m(`details`)),g.current=!1,v.current=null;return}let e=!g.current;
117g.current=!0,k&&v.current!==E&&(!L||e)&&(ee({name:k.name||``,description:k.description||``,thumbnail:k.thumbnail,thumbnailId:k.thumbnailId,template:k.template??!1,cmsCollectionIds:k.cmsCollectionIds??[],labelCollectionIds:k.labelCollectionIds??[]}),v.current=E,m(`details`))},[E,k,L,n,ee]),(0,Y.useEffect)(function(){if(!d)return;let e=P.get$(`file.response`).pipe(O(e=>e.source===d)).subscribe(e=>{if(e.payload&&`files`in e.payload){let t=e.payload.files[0];t&&(F.setValue(`thumbnail`,t,{shouldDirty:!0}),F.setValue(`thumbnailId`,t.id,{shouldDirty:!0})),f(null)}});return()=>e.unsubscribe()},[d,F]);let re=()=>{let e=xr();f(e),P.publish({type:`file.request`,id:e,payload:{fileType:`image`,multiple:!1,title:Z(`components.space.details.thumbnail.select-hub`),uploadOnly:!1}})},ie=()=>{F.setValue(`thumbnail`,void 0,{shouldDirty:!0}),F.setValue(`thumbnailId`,null,{shouldDirty:!0})},ae=async t=>{u(!0);try{await N.mutateAsync([{id:e,name:t.name,description:t.description,thumbnailId:t.thumbnailId===null?null:t.thumbnailId??t.thumbnail?.id??void 0,template:t.template,cmsCollectionIds:I.cmsCollectionIds?t.cmsCollectionIds??[]:void 0,labelCollectionIds:I.labelCollectionIds?t.labelCollectionIds??[]:void 0}]),s.invalidateQueries({queryKey:A}),s.invalidateQueries({queryKey:j}),M&&s.invalidateQueries({queryKey:M}),J.success(Z(`common.space.updated.successfully`)),r(!1),i?.(t)}catch{J.error(Z(`components.space.form.update.error`))}finally{u(!1)}};return(0,X.jsxs)(ar,{open:n,onOpenChange:r,children:[a&&(0,X.jsx)(vr,{render:a}),(0,X.jsx)(pr,{className:`h-[min(44rem,85vh)] max-w-4xl! gap-0 overflow-hidden p-0 sm:max-w-4xl! [&>[data-slot=dialog-close]]:rounded-lg [&>[data-slot=dialog-close]]:bg-transparent [&>[data-slot=dialog-close]]:text-muted-foreground`,children:(0,X.jsx)(_,{...F,children:(0,X.jsx)(`form`,{className:`h-full min-h-0 w-full`,onSubmit:F.handleSubmit(ae),children:(0,X.jsxs)(pu,{orientation:`vertical`,value:p,onValueChange:e=>m(e),className:`h-full min-h-0 gap-0`,children:[(0,X.jsxs)(`aside`,{className:`w-36 shrink-0 border-r bg-muted/30 sm:w-52`,children:[(0,X.jsx)(`div`,{className:`px-4 pt-6 pb-3 sm:px-5`,children:(0,X.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:Z(`components.space.details.section.title`)})}),(0,X.jsx)(hu,{variant:`line`,className:`w-full items-stretch px-2 sm:px-3`,children:Object.entries(PF).map(([e,t])=>(0,X.jsx)(gu,{value:e,className:`h-auto min-h-0 justify-start rounded-lg px-2.5 py-[9px] font-normal text-muted-foreground after:hidden! data-active:bg-foreground! data-active:font-medium data-active:text-white!`,children:t.label},e))})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(rr,{className:`shrink-0 border-b px-6 py-5 pr-14`,children:[(0,X.jsx)(mr,{className:`text-lg font-semibold`,children:Z(`components.space.top.bar.name.edit`)}),(0,X.jsx)(_r,{children:PF[p].description}),(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:k?.name||Z(`components.space.top.bar.name.edit`)})]}),(0,X.jsx)(jl,{className:`min-h-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`p-6`,children:[(0,X.jsxs)(_u,{value:`details`,className:`space-y-5`,children:[(0,X.jsx)(h,{control:F.control,name:`name`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:x,children:Z(`common.name`)}),(0,X.jsx)(W,{placeholder:Z(`common.space.name`),...e,id:x,"aria-invalid":t.invalid,className:`w-full`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:F.control,name:`description`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,className:`w-full`,children:[(0,X.jsx)(K,{htmlFor:S,children:Z(`common.description`)}),(0,X.jsx)(W,{placeholder:Z(`common.space.description`),...e,id:S,"aria-invalid":t.invalid}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:F.control,name:`template`,render:({field:e})=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-4 rounded-xl border border-border p-4`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($t,{htmlFor:C,className:`text-sm font-medium`,children:Z(`components.space.details.template.label`)}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:Z(`components.space.details.template.description`)})]}),(0,X.jsx)(Cn,{id:C,checked:e.value,onCheckedChange:e.onChange})]})})]}),(0,X.jsxs)(_u,{value:`thumbnail`,className:`space-y-4`,children:[(0,X.jsx)(h,{control:F.control,name:`thumbnail`,render:({field:e,fieldState:t})=>
117(0,X.jsxs)(G,{"data-invalid":t.invalid,className:`w-full`,children:[(0,X.jsx)(K,{children:Z(`common.thumbnail`)}),(0,X.jsx)(U,{type:`button`,variant:`outline`,className:`aspect-video h-auto max-h-64 w-full overflow-hidden rounded-[10px] p-0`,onClick:re,children:e.value?.url?(0,X.jsx)(`img`,{src:e.value.url,alt:Z(`components.space.details.thumbnail.alt`),className:`h-full w-full object-cover`},e.value.url):(0,X.jsxs)(`span`,{className:`flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-full bg-muted`,children:(0,X.jsx)(oo,{className:`size-5`})}),(0,X.jsx)(`span`,{className:`text-xs`,children:Z(`components.space.details.thumbnail.select`)})]})}),e.value?.id&&(0,X.jsxs)(U,{type:`button`,variant:`ghost`,className:`w-full justify-between rounded-lg text-muted-foreground`,onClick:ie,"aria-label":`${Z(`components.space.details.thumbnail.remove`)} ${e.value.url?e.value.url.split(`/`).pop():e.value.id}`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs`,children:e.value.url?e.value.url.split(`/`).pop():e.value.id}),(0,X.jsx)(Tr,{className:`size-4 text-destructive`})]}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]}),(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,X.jsx)(gn,{className:`min-w-0 flex-1`}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Z(`common.or`)}),(0,X.jsx)(gn,{className:`min-w-0 flex-1`})]})]})}),(0,X.jsx)(FF,{})]}),(0,X.jsxs)(_u,{value:`collections`,className:`space-y-5`,children:[(0,X.jsx)(jF,{value:te??[],onChange:e=>F.setValue(`cmsCollectionIds`,e,{shouldDirty:!0})}),(0,X.jsx)(MF,{value:ne??[],onChange:e=>F.setValue(`labelCollectionIds`,e,{shouldDirty:!0})})]})]})}),(0,X.jsx)(lr,{className:`shrink-0 border-t bg-muted/20 px-6 py-4`,children:(0,X.jsx)(U,{type:`submit`,className:`h-auto rounded-lg bg-foreground px-[18px] py-[9px] text-white hover:bg-foreground
117/90`,disabled:c||D,children:N.isPending||c?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(An,{className:`size-5`}),Z(`common.saving`)]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(io,{}),Z(`common.save.changes`)]})})})]})]})})})})]})}IF.displayName=`SpaceDetailsDialog`;function LF({content:e,size:t=`default`,variant:n=`default`,className:r,onCopy:i}){let[a,o]=(0,Y.useState)(!1);return(0,X.jsx)(U,{size:t,variant:n,onClick:async()=>{try{await navigator.clipboard.writeText(e),o(!0),i?.(e),setTimeout(()=>o(!1),2e3)}catch(e){console.error(`Failed to copy text: `,e)}},className:q(`h-8 w-8 p-0`,r),type:`button`,children:a?(0,X.jsx)(Ea,{className:`h-3 w-3`}):(0,X.jsx)(pi,{className:`h-3 w-3`})})}var RF=lt({name:H().optional(),json:H().min(1)}),zF=({defaultName:e,defaultJson:t,onChange:n})=>{let r=l({resolver:pn(RF),defaultValues:{name:e??``,json:t?JSON.stringify(t,void 0,2):``},mode:`onChange`}),i=y({control:r.control,name:`name`}),a=y({control:r.control,name:`json`});(0,Y.useEffect)(function(){if(t!=null){let n=JSON.stringify(t,null,2);r.getValues(`json`)!==n&&r.reset({name:e??``,json:n})}else r.reset({name:e??``,json:``})},[t,e,r]);let o=(0,Y.useRef)(n);(0,Y.useEffect)(function(){o.current=n},[n]),(0,Y.useEffect)(function(){if(a)try{let e=JSON.parse(a);o.current?.({name:i,json:e})}catch{}},[a,i]);let s=()=>{let e=r.getValues(`json`);try{let t=JSON.stringify(JSON.parse(e),null,2);r.setValue(`json`,t,{shouldValidate:!0,shouldDirty:!0})}catch{}},c=(e,t)=>{console.log(`field`,t);let n=e.currentTarget,{selectionStart:i,selectionEnd:a,value:o}=n;if((e.ctrlKey||e.metaKey)&&e.altKey&&e.key.toLowerCase()===`f`){e.preventDefault(),s();return}if(e.key===`Tab`){e.preventDefault();let t=i??0,s=a??t,c=o.lastIndexOf(`
118`,t-1)+1,l=o.slice(c,s).includes(`
119`)||t!==s;if(e.shiftKey){let e=o.slice(0,c),i=o.slice(c,s),a=o.slice(s),u=e+i.split(`
120`).map(e=>e.startsWith(`	`)?e.slice(1):e.startsWith(`  `)?e.slice(2):e).join(`
121`)+a;r.setValue(`json`,u,{shouldDirty:!0,shouldValidate:!0});function d(e){return e.startsWith(`	`)?1:e.startsWith(`  `)?2:0}let f=i.split(`
122`).map(d),p=f[0]??0,m=f.reduce((e,t)=>e+t,0);requestAnimationFrame(()=>{let e=Math.max(c,t-p),r=Math.max(c,s-(l?m:p));n.setSelectionRange(e,r)})}else{let e=o.slice(0,c),i=o.slice(c,s),a=o.slice(s),l=e+i.split(`
123`).map(e=>`  `+e).join(`
124`)+a;r.setValue(`json`,l,{shouldDirty:!0,shouldValidate:!0});let u=i.split(`
125`).length-1;requestAnimationFrame(()=>{let e=t+2,r=s+2*(u+1);n.setSelectionRange(e,r)})}return``}};return(0,X.jsx)(_,{...r,children:(0,X.jsx)(`form`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:(0,X.jsx)(h,{control:r.control,name:`json`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,className:`flex min-h-0 flex-1 flex-col`,children:[(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between`,children:[(0,X.jsx)(K,{children:Z(`components.space.top.bar.command.import.json.label`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`sm`,onClick:s,children:(0,X.jsx)(qr,{className:`h-4 w-4`})}),(0,X.jsx)(LF,{content:e.value??``,size:`sm`,variant:`ghost`})]})]}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1`,children:(0,X.jsx)(bt,{...e,className:`h-full resize-none font-mono text-sm`,placeholder:Z(`components.space.top.bar.command.import.json.placeholder`),onKeyDown:t=>c(t,{value:e.value??``,onChange:e=>r.setValue(`json`,e,{shouldDirty:!0,shouldValidate:!0})})})}),(0,X.jsx)(kt,{errors:[t.error]})]})})})})};zF.displayName=`JsonEditor`;var BF=({onImport:e})=>{let[t,n]=(0,Y.useState)(void 0);return(0,X.jsxs)(VT,{value:t,onValueChange:n,onUpload:t=>{let n=t[0],r=new FileReader;r.onload=t=>{try{let n=JSON.parse(t.target?.result);e({resources:n?.resources??[],entities:n?.entities??[],systems:n?.systems??[],services:n?.services??[]})}catch(e){console.error(`Failed to parse import file`,e),J.error(`Invalid JSON file`)}},r.readAsText(n)},onFileReject:(e,t)=>{console.error(`File rejected`,e,t)},maxFiles:1,className:`w-full max-w-md`,multiple:!0,children:[(0,X.jsxs)(HT,{children:[(0,X.jsxs)(`div`,{className:`flex flex-col items-center gap-1 text-center`,children:[(0,X.jsx)(`div`,{className:`flex items-center justify-center rounded-full border p-2.5`,children:(0,X.jsx)(wi,{className:`size-6 text-muted-foreground`})}),(0,X.jsx)(`p`,{className:`text-sm font-medium`,children:`Drag & drop files here`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Or click to browse (max 1 files)`})]}),(0,X.jsx)(UT,{asChild:!0,children:(0,X.jsx)(U,{variant:`outline`,size:`sm`,className:`mt-2 w-fit`,children:`Browse files`})})]}),(0,X.jsx)(WT,{children:t&&t.map((e,t)=>(0,X.jsx)(qT,{value:e,className:`flex-col`,children:(0,X.jsxs)(`div`,{className:`flex w-full items-center gap-2`,children:[(0,X.jsx)(XT,{}),(0,X.jsx)(ZT,{}),(0,X.jsx)($T,{asChild:!0,children:(0,X.jsx)(U,{variant:`ghost`,size:`icon`,className:`size-7`,children:(0,X.jsx)(so,{})})})]})},t))})]})};BF.displayName=`JsonImporter`;var VF=re({id:M(),key:M(),type:k(),name:k().default(``),extends:M().optional(),shared:ee().optional(),persisted:ee().optional(),properties:N(k(),A()).optional(),resources:N(k(),A()).optional(),systems:N(k(),A()).optional(),value:N(k(),A()).optional(),components:ne(A()).optional(),createdAt:F(),updatedAt:F()}).passthrough(),HF=VF.extend({parent:k()}),UF=VF.extend({resources:N(k(),k()).optional()}),WF=[`entities`,`resources`,`systems`,`services`],GF=class extends 
125Error{code;detail;constructor(e,t=``){super(e),this.code=e,this.detail=t}};function KF(e){return!!e&&typeof e==`object`&&!Array.isArray(e)}function qF(e,t){let n=typeof e.extends==`object`?qF(e.extends,t):[];return[...e[t]??[],...n]}function JF({definition:e,existing:t,runtime:n={},newId:r,now:i}){if(!KF(e))throw new GF(`invalid`);let a=[],o=new Map,s=new Map,c=new Map,l=new Map;for(let i of WF){let u=e[i]??[];if(!Array.isArray(u))throw new GF(`invalid`,i);let d=qF(t,i),f=new Set,p=new Map,m=new Map,h=new Set,g=new Set(d.map(e=>e.id));for(let e of[...qF(n,i),...d])h.add(e.key||e.id),e.name&&h.add(e.name),m.set(e.id,e.key||e.id);for(let e of u){if(!KF(e))throw new GF(`invalid`,i);let o=`${i}: ${e.name||e.type||e.id||``}`;if(typeof e.key!=`string`||!e.key.trim())throw new GF(`missing-key`,o);if(typeof e.type!=`string`||!e.type||e.id!==void 0&&typeof e.id!=`string`||e.extends!==void 0&&typeof e.extends!=`string`)throw new GF(`invalid`,o);let s=e;if(f.has(s.key))throw new GF(`duplicate-key`,s.key);f.add(s.key);let c=(t[i]??[]).filter(e=>e.key===s.key);if(c.length>1)throw new GF(`duplicate-key`,s.key);let l=c[0],u=l?void 0:d.find(e=>e.key===s.key),_=l??u??qF(n,i).find(e=>e.key===s.key);if(_&&_.type!==s.type)throw new GF(`type-conflict`,s.key);let v=l?.id??r();if(s.id){if(p.has(s.id))throw new GF(`invalid`,s.id);p.set(s.id,v),m.set(s.id,s.key)}g.add(v),h.add(s.key),s.name&&h.add(s.name),a.push({category:i,input:s,current:l,inherited:u,id:v})}o.set(i,p),s.set(i,h),c.set(i,m),l.set(i,g)}let u=[],d=[];for(let{category:e,input:t,current:n,inherited:r,id:f}of a){let a=t.name||`${t.type} (${t.key})`,p=(e,t,n)=>{let r=s.get(t).has(e)?e:c.get(t).get(e)??e;return r&&!s.get(t).has(r)&&u.push({object:a,path:n,target:r}),r},m=(e,t=``)=>{let n={...e};for(let r of[`resources`,`systems`,`services`])KF(e[r])&&(n[r]=Object.fromEntries(Object.entries(e[r]).map(([e,n])=>[e,typeof n==`string`?p(n,r,`${t}${r}.${e}`):n])));if(typeof e.parent==`string`&&(n.parent=p(e.parent,`entities`,`${t}parent`)),KF(e.properties)){let r={...e.properties};typeof r.parent==`string`&&(r.parent=p(r.parent,`entities`,`${t}properties.parent`)),e.type===`SpawnEntity`&&typeof r.user==`string`&&(r.user=p(r.user,`entities`,`${t}properties.user`)),n.properties=r}return Array.isArray(e.components)&&(n.components=e.components.map((e,n)=>KF(e)?m(e,`${t}components.${n}.`):e)),n},h=m({...n??r,...t}),g=n?.extends??r?.id??(t.extends?o.get(e).get(t.extends)??t.extends:void 0);g&&!l.get(e).has(g)&&u.push({object:a,path:`extends`,target:g});let _={...h,id:f,key:t.key,extends:g,createdAt:n?.createdAt??i,updatedAt:i,...e===`entities`?{parent:h.parent??`root`}:{}},v=n?`update`:`add`;try{switch(e){case`entities`:d.push({category:e,action:v,value:HF.parse(_)});break;case`resources`:case`systems`:d.push({category:e,action:v,value:VF.parse(_)});break;case`services`:d.push({category:e,action:v,value:UF.parse(_)})}}catch{throw new GF(`invalid`,a)}}let f=[],p=new Set,m=new Set,h=e=>{if(p.has(e))return;if(m.has(e))throw new GF(`cyclic-extends`,e.value.key);m.add(e);let t=d.find(t=>t.category===e.category&&t.value.id===e.value.extends);t&&t!==e&&h(t),m.delete(e),p.add(e),f.push(e)};return d.forEach(h),{operations:f,missingReferences:u}}var YF={invalid:`dashboard.space-import.invalid`,"missing-key":`dashboard.space-import.missing-key`,"duplicate-key":`dashboard.space-import.duplicate-key`,"type-conflict":`dashboard.space-import.type-conflict`,"cyclic-extends":`dashboard.space-import.cyclic-extends`},XF=({open:e,setOpen:t})=>{let{spaceId:n}=S(),[r,i]=(0,Y.useState)(null),a=R(),o=ie(),s=fe(),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(null),f=(0,Y.useRef)(!1),p=B(a.space.addEntity.mutationOptions()),m=B(a.space.updateEntity.mutationOptions()),h=B(a.space.addResource.mutationOptions()),g=B(a.space.updateResource.mutationOptions()),_=B(a.space.addSystem.mutationOptions()),v=B(a.space.updateSystem.mutationOptions()),y=B(a.space.addService.mutationOptions()),b=B(a.space.updateService.mutationOptions());return(0,X.jsx)(ar,{open:e,onOpenChange:t,children:(0,X.jsxs)(pr,{"aria-describedby":void 0,"aria-labelledby":void 0,className:`flex h-[90svh] flex-col gap-2`,children:[(0,X.jsxs)(rr,{className:`pb-2`,children:[(0,X.jsx)(mr,{children:Z(`components.space.top.bar.command.import.title`)}),(0,X.jsx)(_r,{className:`sr-only`,children:Z(`components.space.top.bar.command.import.description`)})]}),(0,X.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col gap-4 overflow-hidden`,children:[(0,X.jsx)(BF,{onImport:i}),(0,X.jsx)(zF,{defaultJson:r,onChange:(0,Y.useCallback)(e=>{i(e?.json??null)},[])})]}),u&&(0,X.jsxs)(`div`,{role:`alert`,className:`rounded-md border border-destructive p-3 text-sm`,children:[(0,X.jsx)(`p`,{className:`font-medium`,children:Z(`dashboard.space-import.completed-with-errors`)}),(0,X.jsx)(`p`,{children:u.summary}),(0,X.jsx)(`ul`,{className:`mt-2 max-h-40 space-y-2 overflow-auto break-words`,children:u.failures.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsxs)(`p`,{className:`font-medium`,children:[e.name||e.type,` (`,e.type,`,`,` `,e.key,`)`]}),(0,X.jsx)(`p`,{children:e.message})]},`${e.category}:${e.key}`))})]}),(0,X.jsx)(lr,{children:(0,X.jsxs)(U,{onClick:async e=>{if(e.preventDefault(),e.stopPropagation(),r===null||!n||f.current)return;f.current=!0,l(!0),d(null);let c=!1;try{let[e]=await o.space.get.query([n]);if(!e)throw Error(Z(`dashboard.space-import.space-unavailable`));let a=L.getInstance(),s=JF({definition:r,existing:e,runtime:{entities:a.entities.getAll().map(e=>e.getDefinition()),resources:a.resources.getAll().map(e=>e.getDefinition()),systems:a.systems.getAll().map(e=>e.getDefinition()),services:a.services.getAll().map(e=>e.getDefinition())},newId:xr,now:new Date});s.missingReferences.length&&J.warning(Z(`dashboard.space-import.missing-references`),{duration:2e4,description:(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{children:Z(`dashboard.space-import.references-kept`)}),(0,X.jsx)(`ul`,{className:`mt-2 max-h-40 overflow-auto`,children:s.missingReferences.map((e,t)=>(0,X.jsxs)(`li`,{children:[e.object,`: `,e.path,` → `,e.target]},t))})]})});let l=[],u=0,f=0;for(let e of s.operations){c=!0;
125try{switch(e.category){case`entities`:await(e.action===`update`?m:p).mutateAsync({spaceId:n,entity:e.value});break;case`resources`:await(e.action===`update`?g:h).mutateAsync({spaceId:n,resource:e.value});break;case`systems`:await(e.action===`update`?v:_).mutateAsync({spaceId:n,system:e.value});break;case`services`:await(e.action===`update`?b:y).mutateAsync({spaceId:n,service:e.value})}e.action===`add`?u++:f++}catch(t){l.push({category:e.category,name:e.value.name,type:e.value.type,key:e.value.key??e.value.id,message:t instanceof Error?t.message:Z(`common.error`)})}}let x=Z(`dashboard.space-import.summary`).replace(`{created}`,String(u)).replace(`{updated}`,String(f));if(l.length){let e=`${x} ${Z(`dashboard.space-import.failure-summary`).replace(`{failed}`,String(l.length))}`;d({summary:e,failures:l}),J.error(Z(`dashboard.space-import.completed-with-errors`),{description:e,duration:2e4});return}J.success(Z(`dashboard.space-import.success`),{description:x}),t(!1),i(null)}catch(e){let t;e instanceof GF?(t=Z(YF[e.code]),e.detail&&(t+=` (${e.detail})`)):e instanceof Error&&(t=e.message),J.error(Z(`dashboard.space-import.failed`),{description:t})}finally{try{c&&await s.invalidateQueries({queryKey:a.space.get.queryKey([n])})}finally{f.current=!1,l(!1)}}},disabled:r===null||c,children:[c?(0,X.jsx)(An,{}):(0,X.jsx)(io,{}),Z(`common.save`)]})})]})})};XF.displayName=`Import`;var ZF=(e=[],t=[])=>{let n=new Set(e.map(e=>e.extends).filter(e=>!!e)),r=e.map(e=>({...e,id:e.extends??e.id})),i=t.filter(e=>!n.has(e.id));return[...r,...i]},QF=()=>{let{spaceId:e}=S(),t=ie(),[n,r]=(0,Y.useState)(!1);return(0,X.jsxs)(en,{className:``,children:[(0,X.jsx)(XF,{open:n,setOpen:r}),(0,X.jsxs)(en,{children:[(0,X.jsxs)(U,{onClick:()=>r(!0),variant:`outline`,children:[(0,X.jsx)(ro,{className:`size-5`}),Z(`components.space.top.bar.command.import`)]}),(0,X.jsx)(sn,{}),(0,X.jsxs)(U,{onClick:async n=>{n.preventDefault(),n.stopPropagation();try{let n=(await t.space.get.query([e]))?.[0];if(!n){J.error(`Space not found`);return}let r={extends:n.extends?.id,entities:ZF(n.entities,n.extends?.entities),resources:ZF(n.resources,n.extends?.resources),systems:ZF(n.systems,n.extends?.systems),services:ZF(n.services,n.extends?.services)},i=new Blob([JSON.stringify(r,null,2)],{type:`application/json`}),a=URL.createObjectURL(i),o=document.createElement(`a`);o.href=a;let s=new Date().toISOString().replace(/[:.]/g,`-`);o.download=`${n.name}-export-${s}.json`,o.click(),URL.revokeObjectURL(a)}catch(e){console.error(e),J.error(`Failed to export space`)}},variant:`outline`,children:[(0,X.jsx)(ra,{className:`size-5`}),Z(`components.space.top.bar.command.export`)]})]})]})};QF.displayName=`SpaceFileCommand`;var $F=({className:e,...t})=>{let{spaceId:n,organizationSlug:r}=S(),i=c();return(0,X.jsx)(`div`,{className:q(`flex items-center gap-2`,e),...t,children:(0,X.jsx)(U,{onClick:()=>i(`/${r}/dashboard/spaces/${n}/`),variant:`outline`,size:`icon`,className:`hover:bg-accent focus:bg-accent`,children:(0,X.jsx)(Gr,{className:`size-5`})})})};$F.displayName=`SpaceToggleButtons`;var eI=({className:e,...t})=>{let n=c(),{organizationSlug:r}=S();return(0,X.jsxs)(`div`,{className:q(`flex h-15 w-full flex-row items-center justify-between border-b border-border bg-muted px-5 transition-all duration-200 ease-linear`,e),...t,children:[(0,X.jsxs)(U,{onClick:()=>n(`/${r}/dashboard/spaces`),variant:`outline`,children:[(0,X.jsx)(Ca,{className:`size-5`}),Z(`common.go.to.dashboard`)]}),(0,X.jsx)(tI,{className:`justify-self-center`}),(0,X.jsxs)(en,{children:[(0,X.jsx)(QF,{}),(0,X.jsx)($F,{className:`justify-self-end`})]})]})};function tI({className:e}){let{spaceId:t}=S(),[n,r]=(0,Y.useState)(!1),i=R(),a=t??``,{data:o}=V(i.space.get.queryOptions([a],{enabled:!!t}));return(0,X.jsx)(IF,{id:a,open:n,onOpenChange:r,trigger:(0,X.jsxs)(U,{variant:`outline`,className:q(`max-w-md justify-start`,e),children:[o?.[0]?.thumbnail?.url?(0,X.jsx)(`img`,{src:o[0].thumbnail.url,alt:``,className:`size-5 rounded-md object-cover`}):(0,X.jsx)(oo,{className:`size-5`}),(0,X.jsx)(`span`,{className:`truncate`,children:o?.[0]?.name})]})})}eI.displayName=`SpaceTopBar`;var nI=()=>{let{spaceId:e}=S(),t=Sd({scope:`space`,action:`update`,fallback:`../..`}),n=R(),r=md(),i=No(),{data:a}=V(n.space.getSpaceLanguage.queryOptions({spaceId:e,organizationId:r,languageCode:i},{enabled:!!e}));return Nd((0,Y.useMemo)(()=>Od(i,a)??void 0,[i,a])),(0,Y.useEffect)(function(){let e=L.getInstance();return e.useDefaults(ae),e.useDefaults(_o),()=>{e.releaseDefaults(_o),e.releaseDefaults(ae),e.clear()}},[]),(0,Y.useEffect)(function(){let t=L.getInstance(),n=t.resources.get$(`spaceId`).subscribe(t=>{t?.setValue(e)}),r=P.get$(`space.enter`).subscribe(e=>{e.payload.id&&t.resources.setValue(`spaceId`,e.payload.id)});return()=>{n.unsubscribe(),r.unsubscribe()}},[e]),t||(0,X.jsxs)(`div`,{className:`flex h-svh w-svw flex-col overflow-hidden`,children:[(0,X.jsx)(eI,{className:`shrink-0`}),(0,X.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:(0,X.jsx)(go,{})})]})};nI.displayName=`SpaceEdit`;var rI=()=>{let{spaceId:e,organizationSlug:t}=S(),n=c(),r=C().pathname.includes(`dashboard`);(0,Y.useEffect)(function(){let e=L.getInstance();return e.useDefaults(ae),()=>{e.releaseDefaults(ae),e.resources.setValue(`spaceId`,void 0),e.clear()}},[]),(0,Y.useEffect)(function(){let t=L.getInstance(),n=t.resources.get$(`spaceId`).subscribe(t=>{t?.setValue(e)}),r=P.get$(`space.enter`).subscribe(e=>{e.payload.id&&t.resources.setValue(`spaceId`,e.payload.id)});return()=>{r.unsubscribe(),n.unsubscribe()}},[e]);let i=ho();return po({allowedOrigins:i}),(0,X.jsxs)(`div`,{className:`h-svh w-svw`,children:[r&&(0,X.jsx)(U,{onClick:()=>n(`/${t}/dashboard/spaces/${e}/edit`),className:`fixed top-3 right-5 z-50 text-white`,variant:`ghost`,size:`icon`,children:(0,X.jsx)(ja,{className:`size-5`})}),(0,X.jsxs)(mo,{children:[(0,X.jsx)(fo,{label:Z(`views.space-view.loading`)}),(0,X.jsx)(uo,{})]})]})};
125rI.displayName=`SpaceView`;var iI=lt({name:H().min(1),description:H().optional(),thumbnail:lt({id:H(),metadata:kn(H(),et()),mimetype:H(),type:H(),url:H().optional()}).optional(),organizationId:H().uuid().optional(),thumbnailId:H().optional().nullable(),template:be()}),aI=({id:e,open:t,onOpenChange:n,worldId:r})=>{let[i,a]=(0,Y.useState)(!1),o=t===void 0?i:t,s=n||a,u=c(),d=R(),[f,p]=(0,Y.useState)(null),m=fe(),{activeOrganization:g}=z(),v=d.space.list.queryKey(),[y,b]=(0,Y.useState)(!1),x=!!e,S=d.space.get.queryOptions([e],{enabled:x&&!!e}),{data:C,isLoading:w}=V(S),T=C?.[0],E=d.space.create.mutationOptions({onSuccess:(e,t,n)=>{console.log(`succ`,e,t,n),m.invalidateQueries({queryKey:v}),setTimeout(()=>{b(!1),J.success(Z(`components.space.form.create.success`)),s(!1),u(`/${g?.slug}/dashboard/spaces/${t.id}/edit`)},1500)},onError:(e,t,n)=>{console.log(`err`,e,t,n),b(!1)}}),D=d.world.get.queryKey([r]),k=d.space.update.mutationOptions({onSuccess:()=>{m.invalidateQueries({queryKey:v}),m.invalidateQueries({queryKey:D}),e&&m.invalidateQueries({queryKey:d.space.get.queryKey([e])}),setTimeout(()=>{b(!1),J.success(Z(`common.space.updated.successfully`)),s(!1)},1500)},onError:e=>{console.log(`err`,e),b(!1),J.error(Z(`components.space.form.update.error`))}}),A=B(E),j=B(k),M=l({resolver:pn(iI),defaultValues:{name:``,description:``,thumbnail:void 0,organizationId:g?.id,thumbnailId:void 0,template:!1}});(0,Y.useEffect)(function(){x&&T&&M.reset({name:T.name||``,description:T.description||``,thumbnail:T.thumbnail,thumbnailId:T.thumbnailId,template:T.template??!1})},[x,T,M]),(0,Y.useEffect)(function(){if(!f)return;let e=P.get$(`file.response`).pipe(O(e=>e.source===f)).subscribe(e=>{if(e.payload&&`files`in e.payload){let t=e.payload.files[0];t&&(M.setValue(`thumbnail`,t),M.setValue(`thumbnailId`,t.id)),p(null)}});return()=>{e.unsubscribe()}},[f,M]);let N=()=>{let e=xr();p(e),P.publish({type:`file.request`,id:e,payload:{fileType:`image`,multiple:!1,title:`Select Space Thumbnail`,uploadOnly:!1}})},F=()=>{M.setValue(`thumbnail`,void 0),M.setValue(`thumbnailId`,void 0)},I=t=>{b(!0);let n=t.thumbnail?.id||void 0;if(!g?.id){b(!1);return}if(x&&e)j.mutateAsync([{id:e,name:t.name,description:t.description,thumbnailId:n,template:t.template}]);else{let e={id:xr(),name:t.name,description:t.description,organizationId:g.id,thumbnail:t.thumbnail,thumbnailId:n,template:t.template};A.mutateAsync(e)}};return(0,X.jsxs)(ar,{open:o,onOpenChange:s,children:[!x&&(0,X.jsx)(vr,{render:e=>(0,X.jsxs)(U,{...e,children:[(0,X.jsx)(Ci,{className:`size-4`}),` `,Z(`common.create.space`)]})}),(0,X.jsxs)(pr,{className:`mb-5 h-auto w-full overflow-y-auto sm:max-w-lg`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:Z(x?`common.edit.space`:`common.create.space`)}),(0,X.jsx)(_r,{children:Z(x?`components.space.form.edit.description`:`components.space.form.create.description`)})]}),(0,X.jsx)(_,{...M,children:(0,X.jsxs)(`form`,{className:`flex h-full w-full flex-col gap-4`,onSubmit:M.handleSubmit(I),children:[(0,X.jsx)(h,{control:M.control,name:`name`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`common.name`)}),(0,X.jsx)(W,{placeholder:`Space Name`,...e,className:`w-full`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:M.control,name:`description`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,className:`w-full`,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`common.description`)}),(0,X.jsx)(W,{placeholder:`Space Description`,...e}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(h,{control:M.control,name:`template`,render:({field:e})=>(0,X.jsxs)(`div`,{className:`flex items-center justify-between rounded-lg border border-border p-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($t,{htmlFor:`template-switch`,className:`text-sm font-medium`,children:`Template`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Mark this space as a reusable template`})]}),(0,X.jsx)(Cn,{id:`template-switch`,checked:e.value,onCheckedChange:e.onChange})]})}),(0,X.jsx)(h,{control:M.control,name:`thumbnail`,render:({field:e,fieldState:t})=>
125(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:Z(`common.thumbnail`)}),(0,X.jsx)(`div`,{className:`flex aspect-video max-h-48 cursor-pointer flex-col items-center justify-center gap-2 rounded-md bg-muted/40 transition-colors hover:bg-muted`,onClick:N,children:e.value?.url?(0,X.jsx)(`img`,{src:e.value.url,alt:`Space Thumbnail`,className:`h-full w-full rounded-md object-cover`,onError:e=>{console.error(`Error loading thumbnail`,e)}},e.value.url):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`flex h-12 w-12 items-center justify-center rounded-full bg-muted`,children:(0,X.jsx)(oo,{className:`h-6 w-6 text-muted-foreground`})}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select or Upload Thumbnail`})]})}),e.value?.id&&(0,X.jsxs)(`button`,{type:`button`,className:`flex w-full flex-row items-center justify-between gap-2 rounded-b-md bg-muted px-4 py-1`,onClick:F,children:[(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.value.url?e.value.url.split(`/`).pop():e.value.id}),(0,X.jsx)(Tr,{className:`size-4 shrink-0 text-red-500`})]}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsxs)(U,{type:`submit`,className:`max-w-[200px] self-end`,disabled:y||w,children:[x?(0,X.jsx)(io,{}):(0,X.jsx)(Ci,{}),Z(x?`common.save`:`common.create.space`),(A.isPending||j.isPending||y)&&(0,X.jsx)(An,{className:`ml-2 size-5`})]})]})})]})]})};aI.displayName=`SpaceForm`;var oI=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:e.getIsAllPageRowsSelected()||!!e.getIsSomePageRowsSelected(),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`name`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.name`)}),cell:({row:e})=>(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`span`,{children:e.original.name}),e.original.template&&(0,X.jsx)(fr,{variant:`outline`,className:`border-emerald-200 bg-emerald-100 text-emerald-800 dark:border-emerald-800/50 dark:bg-emerald-900/30 dark:text-emerald-300`,children:Z(`routes.spaces.columns.template`)})]})},{accessorKey:`thumbnail`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.thumbnail`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`flex items-center justify-start`,children:e.original.thumbnail?.url?(0,X.jsx)(`img`,{src:e.original.thumbnail?.url,alt:`World Thumbnail`,className:`aspect-square h-4 w-4 rounded-full object-cover`}):(0,X.jsx)(Ri,{className:`size-4 rounded-full text-muted-foreground opacity-50`})})},{accessorKey:`description`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.description`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`max-w-37.5 truncate text-muted-foreground`,title:e.original.description||void 0,children:e.original.description||`—`})},{id:`actions`,cell:({row:e})=>(0,X.jsx)(cI,{row:e})}],sI=e=>`delete-${e.trim().replace(/\s+/g,`_`)}`,cI=({row:e})=>{let t=e.original,{activeOrganization:n,hasPermissions:r}=z(),i=md(),a=r(i,`space`,`update`),o=r(i,`space`,`delete`),s=`/${n?.slug}/spaces/${t.id}`,c=`/${n?.slug}/dashboard/spaces/${t.id}/edit`,[l,d]=(0,Y.useState)(!1),f=R(),p=fe(),m=f.space.list.queryKey(),h=f.space.remove.mutationOptions({onSuccess:()=>{p.invalidateQueries({queryKey:m})}}),g=B(h);return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:({className:e,...t})=>(0,X.jsxs)(U,{...t,variant:`ghost`,className:q(e,`h-8 w-8 p-0`),onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsxs)(Ue,{children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(st,{nativeButton:!1,render:({className:e,...t})=>(0,X.jsxs)(u,{to:s,className:e,...t,children:[(0,X.jsx)(Wa,{className:`size-4`}),Z(`routes.spaces.columns.view.space`)]})}),a&&(0,X.jsx)(st,{nativeButton:!1,render:({className:e,...t})=>(0,X.jsxs)(u,{to:c,className:e,...t,children:[(0,X.jsx)(va,{className:`size-4`}),Z(`common.edit.space`)]})})]}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(xe,{}),(0,X.jsx)(XM,{id:t.id,title:Z(`routes.spaces.columns.delete.space`),deleteRow:async()=>await g.mutateAsync([t.id]),description:t.template?Z(`routes.spaces.columns.delete.template.description`):void 0,confirmText:t.template?sI(t.name):void 0,open:l,setOpen:d})]})]})]})},lI=()=>{let e=R(),{hasPermissions:t}=z(),n=md(),r=t(n,`space`,`create`),i=t(n,`space`,`delete`),a=fe(),[o,s]=(0,Y.useState)(!1),c=e.space.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:n},{select(e){return o?e.items:e.items.filter(e=>e.template)}}),{data:l,isLoading:u,isError:d}=V(c),f=e.space.list.queryKey(),p=e.space.remove.mutationOptions({onSuccess:()=>{a.invalidateQueries({queryKey:f})},onError:e=>
125{console.error(`Error deleting spaces:`,e)}}),m=B(p);return u?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{className:`h-10 w-10`})}):d?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`routes.spaces.error`)})}):l?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.spaces`),actions:r?(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsx)(aI,{})}):void 0}),(0,X.jsx)(wE,{children:(0,X.jsx)(pd,{columns:oI,data:l.map(e=>({...e,createdAt:$i(new Date(e.createdAt.toISOString()),`dd-MM-yyyy HH:mm`),updatedAt:$i(new Date(e.updatedAt.toISOString()),`dd-MM-yyyy HH:mm`)})),navigateTo:{key:`id`,additionalPath:`edit`},primaryAction:{id:`toggle-show-all`,label:o?`Templates only`:`Show all`,icon:o?(0,X.jsx)(Dr,{className:`size-4`}):(0,X.jsx)(Ga,{className:`size-4`}),onClick:()=>s(e=>!e)},onDeleteSelected:i?async e=>{try{let t=e.map(e=>e.id);await m.mutateAsync(t)}catch(e){console.error(`Failed to delete spaces:`,e)}}:void 0,multipleDeleteString:{start:`Delete`,end:`space`}})})]}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`common.no.spaces.found`)})})};lI.displayName=`Spaces`;function uI(e=!1){let[t,n]=(0,Y.useState)(e);return{isOpen:t,setIsOpen:n,handleOpenChange:(0,Y.useCallback)(e=>{n(e)},[])}}function dI(){return typeof window<`u`&&window.location?.origin?window.location.origin:``}function fI(e,t){let n=dI(),r=e?.trim()?e.replace(/^\//,``):``;return r?`${n}/${t}/worlds/${r}`:n}var pI=2e3;function mI(){let[e,t]=(0,Y.useState)(!1),[n,r]=(0,Y.useState)(null);return{copy:(0,Y.useCallback)(async e=>{r(null);try{if(navigator.clipboard?.writeText)await navigator.clipboard.writeText(e);else{let t=document.createElement(`textarea`);t.value=e,t.style.position=`fixed`,t.style.left=`-999999px`,t.style.top=`-999999px`,document.body.appendChild(t),t.focus(),t.select(),document.execCommand(`copy`),t.remove()}t(!0);let n=setTimeout(()=>t(!1),pI);return()=>clearTimeout(n)}catch(e){let t=e instanceof Error?e:Error(String(e));throw r(t),t}},[]),copied:e,error:n}}function hI({publishUrl:e}){let[t,n]=(0,Y.useState)(`100%`),[r,i]=(0,Y.useState)(`600`),a=mI(),o=e?`<iframe src="${e}" width="${t}" height="${r}" frameborder="0" allowfullscreen></iframe>`:``;return(0,X.jsxs)(`div`,{className:`mt-4 space-y-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Mr,{className:`h-4 w-4 text-muted-foreground`}),(0,X.jsx)($t,{className:`text-sm`,children:`Embed Code`})]}),(0,X.jsxs)(`div`,{className:`relative`,children:[(0,X.jsx)(`pre`,{className:`overflow-x-auto rounded-lg bg-muted p-3 text-xs break-all whitespace-pre-wrap text-foreground`,children:o||`<iframe src="..." width="100%" height="600" ...></iframe>`}),(0,X.jsx)(U,{variant:`secondary`,size:`sm`,onClick:()=>a.copy(o).catch(()=>{}),disabled:!o,className:`absolute top-2 right-2`,children:a.copied?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ea,{className:`mr-1 h-3 w-3`}),`Copied`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pi,{className:`mr-1 h-3 w-3`}),`Copy`]})})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Paste this code into your website's HTML to embed the virtual world`})]}),(0,X.jsxs)(`div`,{className:`space-y-2`,children:[(0,X.jsx)($t,{className:`text-sm`,children:`Embed Preview`}),(0,X.jsx)(`div`,{className:`rounded-lg border-2 border-dashed border-border p-4`,children:(0,X.jsx)(`div`,{className:`flex aspect-video w-full overflow-hidden rounded bg-muted`,children:e?(0,X.jsx)(`iframe`,{src:e,className:`h-full w-full border-0`,allowFullScreen:!0,title:`World embed preview`}):(0,X.jsx)(`div`,{className:`flex w-full items-center justify-center`,children:(0,X.jsxs)(`div`,{className:`text-center`,children:[(0,X.jsx)(Na,{className:`mx-auto mb-1 h-8 w-8 text-muted-foreground`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Enter a slug to preview`})]})})})})]}),(0,X.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted p-3`,children:[(0,X.jsx)(`h4`,{className:`mb-2 text-xs font-medium text-foreground`,children:`Embed Options`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)($t,{htmlFor:`embed-width`,className:`text-xs text-muted-foreground`,children:`Width`}),(0,X.jsx)(W,{id:`embed-width`,value:t,onChange:e=>n(e.target.value),placeholder:`100%`,className:`mt-1 h-8`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)($t,{htmlFor:`embed-height`,className:`text-xs text-muted-foreground`,children:`Height`}),(0,X.jsx)(W,{id:`embed-height`,value:r,onChange:e=>i(e.target.value),placeholder:`600`,className:`mt-1 h-8`})]})]})]})]})}function gI({publishUrl:e}){let t=mI();return(0,X.jsx)(`div`,{className:`mt-4 space-y-4`,children:(0,X.jsxs)(`div`,{className:`space-y-3`,children:[(0,X.jsx)($t,{className:`text-sm`,children:`World URL`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(W,{value:e,readOnly:!0,className:`flex-1`}),(0,X.jsx)(U,{variant:`outline`,size:`sm`,onClick:()=>t.copy(e).catch(()=>{}),className:`shrink-0`,children:t.copied?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Ea,{className:`mr-2 h-4 w-4`}),`Copied`]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(pi,{className:`mr-2 h-4 w-4`}),`Copy`]})})]}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Share this URL with anyone to give them access to your virtual world`})]})})}function _I({worldId:e,publishedSnapshotId:t,showSnapshots:n=!0,showPublishStatus:r=!0}){let i=R(),a=fe(),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),u=i.world.listSnapshots.queryOptions({worldId:e,sorting:[{id:`createdAt`,desc:!0}],pagination:{pageIndex:0,pageSize:20},columnFilters:[],globalFilter:``},{enabled:!!e}),{data:d,isLoading:f}=V(u),p=Array.isArray(d)?d:d?.items??[],m=i.world.get.queryKey([e]),h=i.world.list.queryKey(),g=i.world.listSnapshots.queryKey(),_=()=>Promise.all([a.invalidateQueries({queryKey:h}),a.invalidateQueries({queryKey:m}),a.invalidateQueries({queryKey:g})]),v=B(i.world.publish.mutationOptions()),y=B(i.world.unpublish.mutationOptions()),b=async()=>{s(!0);try{await v.mutateAsync([e]),await _()}finally{s(!1)}},x=async()=>{s(!0);try{await y.mutateAsync([e]),await _()}finally{s(!1)}},S=o||v.isPending||y.isPending,C=t!=null,w=p.find(e=>e.id===t),T=C&&p.length>0&&p[0]?.id!==t;return f?(0,X.jsx)(`div`,{className:`rounded-lg border border-border bg-muted p-4`,children:(0,X.jsx)(An,{className:`h-4 w-4`})}):(0,X.jsxs)(`div`,{className:`space-y-3`,children:[r&&(0,X.jsxs)(`div`,{className:`rounded-lg border p-4 ${C?`border-green-500/30 bg-green-500/5`:`border-yellow-500/30 bg-yellow-500/5`}`,children:[(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-4`,children:[(0,X.jsxs)(`div`,{className:`space-y-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Jr,{className:`h-3 w-3 ${C?`animate-pulse fill-green-500 text-green-500`:`fill-yellow-500 text-yellow-500`}`}),(0,X.jsx)(`p`,{className:`text-sm font-medium ${C?`text-green-700 dark:text-green-400`:`text-yellow-700 dark:text-yellow-400`}`,children:Z(C?`views.world-edit.publish.status.published`:`views.world-edit.publish.status.draft`)})]}),C&&w&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1.5 pl-5 text-xs text-muted-foreground`,children:[(0,X.jsx)(bi,{className:`h-3 w-3`}),(0,X.jsxs)(`span`,{children:[`Published`,` `,Ki(new Date(w.createdAt),{addSuffix:!0}
125),` `,`· `,$i(new Date(w.createdAt),`PPp`)]})]}),!C&&(0,X.jsx)(`p`,{className:`pl-5 text-xs text-muted-foreground`,children:Z(`views.world-edit.publish.not-accessible`)})]}),(0,X.jsxs)(`div`,{className:`flex shrink-0 items-center gap-2`,children:[C&&(0,X.jsxs)(U,{variant:`outline`,size:`sm`,onClick:x,disabled:S,children:[S&&y.isPending?(0,X.jsx)(An,{className:`mr-1.5 h-3.5 w-3.5`}):null,Z(`views.world-edit.publish.unpublish`)]}),(0,X.jsxs)(U,{size:`sm`,onClick:b,disabled:S,children:[S&&v.isPending?(0,X.jsx)(An,{className:`mr-1.5 h-3.5 w-3.5`}):null,Z(C?`views.world-edit.publish.update`:`views.world-edit.publish.publish`)]})]})]}),T&&(0,X.jsxs)(`div`,{className:`mt-3 flex items-center gap-2 rounded-md border border-blue-500/20 bg-blue-500/5 px-3 py-2`,children:[(0,X.jsx)(gi,{className:`h-3.5 w-3.5 text-blue-600 dark:text-blue-400`}),(0,X.jsxs)(`p`,{className:`text-xs text-blue-700 dark:text-blue-400`,children:[`You have changes since the last publish. Click`,` `,(0,X.jsx)(`strong`,{children:`Publish update`}),` to make them live.`]})]})]}),n&&p.length>0&&(0,X.jsxs)(`div`,{className:`rounded-lg border border-border bg-muted/50 p-3`,children:[(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(!c),className:`flex w-full items-center justify-between text-sm font-medium text-foreground`,children:[(0,X.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(Ha,{className:`h-3.5 w-3.5 text-muted-foreground`}),Z(`views.world-edit.publish.snapshot-history`),(0,X.jsx)(`span`,{className:`rounded-full bg-muted px-1.5 py-0.5 text-xs font-normal text-muted-foreground`,children:p.length})]}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:Z(c?`common.hide`:`views.world-edit.publish.show`)})]}),c&&(0,X.jsx)(`ul`,{className:`mt-2 max-h-48 space-y-1 overflow-y-auto`,children:p.map(e=>{let n=e.id===t;return(0,X.jsxs)(`li`,{className:`flex items-center justify-between rounded-md px-2 py-1.5 text-sm ${n?`bg-green-500/10`:``}`,children:[(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:$i(new Date(e.createdAt),`PPp`)}),n&&(0,X.jsxs)(`span`,{className:`flex items-center gap-1 text-xs font-medium text-green-600 dark:text-green-400`,children:[(0,X.jsx)(Jr,{className:`h-2 w-2 fill-green-500 text-green-500`}),Z(`views.world-edit.publish.live`)]})]},e.id)})})]})]})}function vI({world:e}){let t=p(),{activeOrganization:n}=z(),{isOpen:r,handleOpenChange:i}=uI(),a=fI(t.getValues(`slug`)??``,n?.slug??``);return(0,X.jsxs)(ar,{open:r,onOpenChange:i,children:[(0,X.jsx)(vr,{render:e=>(0,X.jsxs)(U,{...e,"data-quick-help":`world-publish`,children:[(0,X.jsx)(Fa,{className:`size-3.5`}),`Publish`]})}),(0,X.jsxs)(pr,{className:`max-h-[85vh] max-w-2xl overflow-y-auto`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:`Publish World`}),(0,X.jsx)(_r,{children:`Publish your world to make it accessible, or share and embed it on your website.`})]}),(0,X.jsx)(_I,{worldId:e.id,publishedSnapshotId:e.publishedSnapshotId}),(0,X.jsxs)(pu,{defaultValue:`share`,className:`mt-2 w-full`,children:[(0,X.jsxs)(hu,{className:`grid w-full grid-cols-2 border border-neutral-200 bg-neutral-100 shadow-xs dark:border-border/70 dark:bg-muted/60`,children:[(0,X.jsx)(gu,{value:`share`,children:`Share`}),(0,X.jsx)(gu,{value:`embed`,children:`Embed`})]}),(0,X.jsx)(_u,{value:`share`,children:(0,X.jsx)(gI,{publishUrl:a,worldId:e.id,publishedSnapshotId:e.publishedSnapshotId})}),(0,X.jsx)(_u,{value:`embed`,children:(0,X.jsx)(hI,{publishUrl:a})})]}),(0,X.jsx)(`div`,{className:`mt-4 flex justify-end border-t border-border pt-4`,children:(0,X.jsx)(U,{variant:`outline`,onClick:()=>i(!1),children:`Close`})})]})]})}function yI({name:e,form:t,children:n,onBlur:r,onChange:i,defaultValue:a}){let o=p(),s=t||o;if(!s)throw Error(`ControlledField must be used within a FormProvider or receive a form prop`);return(0,X.jsx)(h,{name:e,control:s.control,defaultValue:a,render:({field:e,fieldState:t,formState:a})=>{let o=()=>{e.onBlur(),r?.(e.value)},s=t=>{e.onChange(t),i?.(t)},c={...e,onBlur:o,onChange:s};return typeof n==`function`?(0,X.jsx)(X.Fragment,{children:n({field:c,fieldState:t,formState:a})}):(0,Y.isValidElement)(n)?(0,Y.cloneElement)(n,{...c,error:t.error?.message,"data-invalid":t.invali
125d||void 0}):(0,X.jsx)(X.Fragment,{})}})}var bI=()=>{let{worldSlug:e}=S(),t=R(),n=md(),r=fe(),{data:i}=V(t.world.list.queryOptions({organizationId:n,sorting:[{id:`slug`,desc:!1}],pagination:{pageIndex:0,pageSize:100},columnFilters:[],globalFilter:``},{enabled:!!e})),a=i?.items.find(t=>t.slug===e)?.id,o=t.world.get.queryKey([a]),s=t.world.update.mutationOptions({onSuccess:()=>{r.invalidateQueries({queryKey:o})},onError:e=>{console.error(`Error updating world`,e)}}),c=B(s);return{handleSubmit:async e=>{if(!a)return;let t={name:e.name,description:e.description,slug:e.slug,organizationId:n,spaces:e.spaces?.map(e=>({id:e.id,name:e.name,isDefault:e.isDefault,order:e.order}))||[],cmsCollectionIds:e.cmsCollectionIds??void 0,labelCollectionIds:e.labelCollectionIds??void 0,thumbnailId:e.thumbnailId??e.thumbnail?.id??void 0,thumbnail:e.thumbnail?{id:e.thumbnail.id,metadata:e.thumbnail.metadata,mimetype:e.thumbnail.mimetype,type:e.thumbnail.type,url:e.thumbnail.url}:void 0};try{await c.mutateAsync([{id:a,...t}])}catch(e){throw console.error(`Error submitting world`,e),e}},worldId:a}};function xI({onCaptured:e}){let t=p(),n=t.watch(`spaces`)??[],[r,i]=(0,Y.useState)(()=>L.getInstance().resources.getValue(`spaceId`));(0,Y.useEffect)(function(){let{resources:e}=L.getInstance(),t=e.getValue(`spaceId`);return()=>{t&&e.setValue(`spaceId`,t)}},[]);let{capture:a,busy:o,isCapturing:s,isUploading:c}=xd({getFilename:()=>t.getValues(`name`)??``,onCaptured:e});if(n.length===0)return null;let l=[...n].sort((e,t)=>(e.order??0)-(t.order??0)),u=l.find(e=>e.id===r)?.name,d=e=>{e&&(i(e),L.getInstance().resources.setValue(`spaceId`,e))},f=`Capture space`;return c?f=`Uploading…`:s&&(f=`Capturing…`),(0,X.jsxs)(`div`,{className:`flex items-end gap-2`,"data-quick-help":`world-settings-capture-space`,children:[(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1.5`,children:[(0,X.jsx)($t,{htmlFor:`capture-space`,children:`Capture from space`}),(0,X.jsxs)(Vt,{value:r,onValueChange:d,children:[(0,X.jsx)(Dn,{id:`capture-space`,className:`w-full`,children:(0,X.jsx)(Mt,{placeholder:`Select a space`,children:u})}),(0,X.jsx)(Dt,{children:l.map(e=>(0,X.jsx)(yn,{value:e.id,children:e.name},e.id))})]})]}),(0,X.jsxs)(U,{type:`button`,variant:`outline`,className:`shrink-0`,onClick:a,disabled:o||!r,children:[(0,X.jsx)(za,{className:`size-4`}),` `,f]})]})}var SI={details:{label:Z(`common.details`),description:Z(`views.world-properties.tab.details.description`)},thumbnail:{label:Z(`views.world-properties.tab.thumbnail`),description:Z(`views.world-properties.tab.thumbnail.description`)},collections:{label:Z(`common.content`),description:Z(`views.world-properties.tab.collections.description`)}};function CI(){let e=bI(),t=p(),{organizationSlug:n}=S(),{isOpen:r,handleOpenChange:i}=uI(),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(`details`),d=y({control:t.control,name:`cmsCollectionIds`}),f=y({control:t.control,name:`labelCollectionIds`}),m=e=>{c(e),setTimeout(()=>c(null),1500)};(0,Y.useEffect)(function(){if(!a)return;let n=P.get$(`file.response`).pipe(O(e=>e.source===a)).subscribe(n=>{if(n.payload&&`files`in n.payload){let r=n.payload.files[0];r&&(t.setValue(`thumbnail`,r),t.setValue(`thumbnailId`,r.id),e.handleSubmit(t.getValues())),o(null)}});return()=>{n.unsubscribe()}},[a,t,e]);let g=()=>{let e=xr();o(e),P.publish({type:`file.request`,id:e,payload:{fileType:`image`,multiple:!1,title:Z(`views.world-properties.thumbnail.select-hub`),uploadOnly:!1}})},_=({fileId:n,fileUrl:r})=>{t.setValue(`thumbnail`,{id:n,url:r,mimetype:`image/png`,type:`file`,metadata:{}}),t.setValue(`thumbnailId`,n),e.handleSubmit(t.getValues()),m(`thumbnail`)},v=()=>{t.setValue(`thumbnail`,void 0),t.setValue(`thumbnailId`,void 0),e.handleSubmit(t.getValues()),m(`thumbnail`)},b=()=>{e.handleSubmit(t.getValues()),m(`name`)},x=()=>{e.handleSubmit(t.getValues()),m(`description`)},C=!!(t.formState.dirtyFields.cmsCollectionIds||t.formState.dirtyFields.labelCollectionIds),w=()=>{if(C){let n=t.getValues();e.handleSubmit(n),t.reset(n)}i(!1)},T=n=>{t.setValue(`slug`,Bd(n)),e.handleSubmit(t.getValues()),m(`slug`)};return(0,X.jsxs)(ar,{open:r,onOpenChange:i,children:[(0,X.jsx)(vr,{render:e=>(0,X.jsxs)(U,{variant:`outline`,...e,"data-quick-help":`world-detail
125s`,children:[(0,X.jsx)(ca,{className:`size-3.5`}),Z(`common.world.details`)]})}),(0,X.jsxs)(pr,{className:`h-[min(44rem,85vh)] max-w-4xl! gap-0 overflow-hidden p-0 sm:max-w-4xl!`,"data-quick-help":`world-settings-dialog`,children:[(0,X.jsx)(Hl,{guideId:`world-settings-dialog`,iconOnly:!0,className:`absolute top-4 right-14 z-10`}),(0,X.jsxs)(pu,{orientation:`vertical`,value:l,onValueChange:e=>u(e),className:`h-full min-h-0 gap-0`,children:[(0,X.jsxs)(`aside`,{className:`w-36 shrink-0 border-r bg-muted/30 sm:w-52`,children:[(0,X.jsx)(`div`,{className:`px-4 pt-6 pb-3 sm:px-5`,children:(0,X.jsx)(`p`,{className:`text-xs font-medium tracking-wide text-muted-foreground uppercase`,children:Z(`views.world-properties.section.title`)})}),(0,X.jsx)(hu,{variant:`line`,className:`w-full items-stretch px-2 sm:px-3`,children:Object.entries(SI).map(([e,t])=>(0,X.jsx)(gu,{value:e,"data-quick-help":`world-settings-tab-${e}`,className:`h-auto min-h-0 justify-start rounded-lg px-2.5 py-[9px] font-normal text-muted-foreground after:hidden! data-active:bg-foreground! data-active:font-medium data-active:text-white!`,children:t.label},e))})]}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:[(0,X.jsxs)(rr,{className:`shrink-0 border-b px-6 py-5 pr-14`,children:[(0,X.jsx)(mr,{className:`text-lg font-semibold`,children:SI[l].label}),(0,X.jsx)(_r,{children:SI[l].description}),(0,X.jsx)(h,{control:t.control,name:`name`,render:({field:e})=>(0,X.jsx)(`p`,{className:`truncate text-xs text-muted-foreground`,children:e.value||Z(`common.world.details`)})})]}),(0,X.jsx)(jl,{className:`min-h-0 flex-1`,children:(0,X.jsxs)(`div`,{className:`p-6`,children:[(0,X.jsxs)(_u,{value:`details`,className:`space-y-5`,"data-quick-help":`world-settings-details`,children:[(0,X.jsx)(yI,{name:`name`,form:t,children:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`common.name`)}),(0,X.jsx)(W,{placeholder:Z(`common.world.name`),...e,onBlur:b,className:`transition-colors duration-300 ${s===`name`?`border-green-500`:``}`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(yI,{name:`description`,form:t,children:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`common.description`)}),(0,X.jsx)(bt,{placeholder:Z(`common.world.description`),...e,onBlur:x,className:`transition-colors duration-300 ${s===`description`?`border-green-500`:``}`}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})}),(0,X.jsx)(yI,{name:`slug`,form:t,children:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{htmlFor:e.name,children:Z(`common.world.address.slug`)}),(0,X.jsxs)(Me,{className:`transition-colors duration-300 ${s===`slug`?`border-green-500`:``}`,children:[(0,X.jsx)(Ve,{children:(0,X.jsxs)(St,{children:[`https://storyverse.fi/`,n,`/worlds/`]})}),(0,X.jsx)(ze,{...e,onBlur:e=>{T(e.target.value)},placeholder:`slug`,className:`pl-0.5! font-semibold`})]}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})})]}),(0,X.jsx)(_u,{value:`thumbnail`,"data-quick-help":`world-settings-thumbnail`,children:(0,X.jsx)(h,{control:t.control,name:`thumbnail`,render:({field:e,fieldState:t})=>(0,X.jsxs)(G,{"data-invalid":t.invalid,children:[(0,X.jsx)(K,{children:`Thumbnail`}),(0,X.jsx)(U,{type:`button`,variant:`outline`,className:`aspect-video h-auto max-h-64 w-full overflow-hidden rounded-xl p-0 ${s===`thumbnail`?`border-green-500`:``}`,onClick:g,children:e.value?.url?(0,X.jsx)(`img`,{src:e.value.url,alt:Z(`views.world-properties.thumbnail.alt`),className:`h-full w-full object-cover`,onError:e=>{console.error(`Error loading thumbnail`,e)}},e.value.url):(0,X.jsxs)(`span`,{className:`flex flex-col items-center justify-center gap-2 text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:`flex size-10 items-center justify-center rounded-full bg-muted`,children:(0,X.jsx)(oo,{className:`size-5`})}),(0,X.jsx)(`span`,{className:`text-xs`,children:Z(`views.world-properties.thumbnail.select`)})]})}),e.value?.id&&(0,X.jsxs)(U,{type:`button`,variant:`ghost`,className:`w-full justify-between text-muted-foreground`,onClick:v,children:[(0,X.jsx)(`span`,{className:`truncate text-xs`,children:e.value.url?e.value.url.split(`/`).pop():e.value.id}),(0,X.jsx)(Tr,{className:`size-4 text-destructive`})]}),(0,X.jsx)(xI,{onCaptured:_}),t.invalid&&(0,X.jsx)(kt,{errors:[t.error]})]})})}),(0,X.jsxs)(_u,{value:`collections`,className:`space-y-5`,"data-quick-help":`world-settings-collections`,children:[(0,X.jsx)(`div`,{"data-quick-help":`world-settings-cms-collections`,children:(0,X.jsx)(jF,{value:d??[],onChange:e=>t.setValue(`cmsCollectionIds`,e,{shouldDirty:!0})})}),(0,X.jsx)(`div`,{"data-quick-help":`world-settings-label-collections`,children:(0,X.jsx)(MF,{value:f??[],onChange:e=>t.setValue(`labelCollectionIds`,e,{shouldDirty:!0})})})]})]})}),(0,X.jsx)(lr,{className:`shrink-0 border-t bg-muted/20 px-6 py-4`,children:(0,X.jsx)(U,{type:`button`,onClick:w,"data-quick-help":`world-settings-done`,children:C?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(io,{className:`size-4 text-emerald-500`}),` `,Z(`views.world-properties.save-changes`)]}):Z(`common.done`)})})]})]})]})]})}function wI({world:e}){return(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2`,children:[(0,X.jsx)(`div`,{className:`flex h-13 shrink-0 items-center justify-end px-2`,children:(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Vl,{}),(0,X.jsx)(CI,{}),(0,X.jsx)(vI,{world:e})]})})}),(0,X.jsx)(`div`,{className:`relative flex-1 cursor-pointer overflow-hidden rounded-xl`,"data-quick-help":`world-canvas`,children:(0,X.jsx)(`div`,{className:`h-full w-full`,children:(0,X.jsxs)(mo,{children:[(0,X.jsx)(fo,{}),(0,X.jsx)(uo,{})]})})})]})}function TI({item:e,depth:t}){return e.type===`AutoField`?(0,X.jsx)(fn,{pattern:e.path}):null}function EI({items:e,depth:t=0}){return e.length===0?null:(0,X.jsx)(`div`,{className:`flex flex-col gap-3`,children:e.map((e,n)=>(0,X.jsx)(DI,{item:e,depth:t},n))})}function DI({item:e,depth:t}){switch(e.type){case`Title`:return(0,X.jsx)(`h3`,{className:q(`text-sm font-semibold text-foreground`,t>0&&`text-xs`),children:e.text??``});case`Label`:return(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.text??``});case`Separator`:return(0,X.jsx)(gn,{});case`AutoField`:return(0,X.jsx)(TI,{item:e,depth:t});case`Group`:return t>=4?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground italic`,children:`Max nesting depth reached`}):(0,X.jsxs)(_n,{defaultOpen:!0,children:[(0,X.jsxs)(At,{className:`flex w-full items-center gap-1.5 px-1 py-1 text-left text-xs font-medium transition-colors hover:bg-muted/50 [&[data-state=open]>svg]:rotate-90`,children:[(0,X.jsx)(Er,{className:`size-3.5 shrink-0 text-muted-foreground transition-transform duration-150`}),(0,X.jsx)(`span`,{className:`truncate text-foreground`,children:e.label??`Group`})]}),(0,X.jsx)(Tn,{children:(0,X.jsx)(`div`,{className:`mt-1 border-l border-border/50 pl-4`,children:(0,X.jsx)(EI,{items:e.items,depth:t+1})})})]});default:return null}}function OI({keys:e,className:t}){let[n,r]=(0,Y.useState)([]);return(0,Y.useEffect)(function(){let t=L.getInstance().resources.getAll$().subscribe(t=>{let n=t.filter(e=>e.type===`PanelResource`),i=(e&&e.length>0?n.filter(t=>e.includes(t.key)):n).flatMap(e=>e.getPropertyValue(`items`)??e.getValue()??[]);r(e=>JSON.stringify(e)===JSON.stringify(i)?e:i)});return()=>{t.unsubscribe()}},[e]),(0,X.jsx)(`div`,{className:q(`flex w-full flex-col gap-3`,t),children:(0,X.jsx)(EI,{items:n})})}OI.displayName=`Panel`;var kI=[`SpotEntity`,`BasicSpotEntity`];function AI(e){return e instanceof ge||kI.includes(e.type)}var jI=`SpotEntity`;function MI(){return(0,Y.useCallback)(()=>{let e=L.getInstance(),t={type:jI,id:xr(),key:xr(),shared:!0,persisted:!0,name:`New Spot ${Math.floor(Math.random()*10)}`,properties:{parent:`root`,position:[0,0,0]}};try{let n=e.entities.create(t);return n?(e.entities.add(n),n.key):void 0}catch(e){console.error(`Failed to add spot`,e);return}},[])}function NI(e){let[t,n]=(0,Y.useState)(e.getPropertyValue(`visible`)!==!1);return(0,Y.useEffect)(()=>{let t=e.getPropertyValue$(`visible`).subscribe(e=>n(e!==!1));return()=>{t.unsubscribe()}},[e]),{visible:t,toggleVisibility:(0,Y.useCallback)(()=>{P.publish({type:`entity.definition.update`,payload:{key:e.key,"properties.visible":!t}})},[e,t])}}function PI({spot:e,isSelected:t,onSelect:n,onRequestDelete:r}){let{visible:i,toggleVisibility:a}=NI(e),o=e.definition.name||`Spot`;return(0,X.jsxs)(`li`,{className:q(`flex items-center gap-1 rounded-[10px] pr-1 pl-2 transition-colors`,t?`bg-background shadow-sm ring-1 ring-border`:`hover:bg-background/60`),children:[(0,X.jsxs)(`button`,{type:`button`,"aria-pressed":t,onClick:()=>n(e.key),className:`flex min-w-0 flex-1 items-center gap-2 rounded-md py-2 text-left outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`,"data-quick-help":`world-spot-select`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,
125className:q(`h-5 w-0.75 shrink-0 rounded-sm transition-colors`,t?`bg-foreground`:`bg-transparent`)}),(0,X.jsx)(`span`,{"aria-hidden":!0,className:q(`size-3 shrink-0 rotate-45 rounded-[2px] transition-colors`,t?`bg-foreground`:`bg-muted-foreground/45`)}),(0,X.jsx)(`span`,{className:q(`truncate text-sm transition-colors`,t?`font-semibold text-foreground`:`text-foreground/75`,!i&&`opacity-50`),children:o})]}),(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":i?`Hide ${o}`:`Show ${o}`,"aria-pressed":!i,className:q(`shrink-0`,i?`text-sky-500 hover:text-sky-600`:`text-muted-foreground/60 hover:text-sky-500`),onClick:a,"data-quick-help":`world-spot-visibility`,children:i?(0,X.jsx)(Rr,{}):(0,X.jsx)(li,{})}),(0,X.jsx)(U,{type:`button`,variant:`ghost`,size:`icon-xs`,"aria-label":`Delete ${o}`,className:`shrink-0 text-muted-foreground hover:text-destructive`,onClick:()=>r(e.key),children:(0,X.jsx)(so,{})})]})}PI.displayName=`SpotRow`;function FI({selectedSpotKey:e,onSelect:t}){let{entities:n}=_e(AI),r=MI(),[i,a]=(0,Y.useState)(void 0),o=n?.find(e=>e.key===i),s=n=>{t(e===n?void 0:n)},c=()=>{let e=r();e&&t(e)};function l(e){L.getInstance().entities.remove(e),t(void 0),a(void 0)}return(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 pt-2`,"data-quick-help":`world-spots-panel`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between gap-2 pl-1`,children:[(0,X.jsx)(`h3`,{className:`text-[11px] font-medium tracking-wider text-muted-foreground uppercase`,children:`Spots in scene`}),(0,X.jsxs)(U,{variant:`outline`,size:`xs`,onClick:c,"data-quick-help":`world-add-spot`,children:[(0,X.jsx)(Hr,{}),`Add`]})]}),!n||n.length===0?(0,X.jsx)(`p`,{className:`pb-1 pl-1 text-xs text-muted-foreground`,children:`No spots yet. Add one to place it in the scene.`}):(0,X.jsx)(`ul`,{className:`flex w-full flex-col gap-1.5`,"data-quick-help":`world-spots-list`,children:n.map(t=>(0,X.jsx)(PI,{spot:t,isSelected:e===t.key,onSelect:s,onRequestDelete:a},t.key))}),e&&(0,X.jsx)(`div`,{className:`duration-300s transform animate-accordion-up border-t border-border pt-3 transition-all`,"data-quick-help":`world-spot-properties`,children:(0,X.jsx)(fn,{publicOnly:!0,pattern:`entities.${e}.*`},e)}),(0,X.jsx)(cr,{open:!!o,onOpenChange:e=>!e&&a(void 0),children:(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:`Delete this spot?`}),(0,X.jsxs)(Cr,{children:[`This permanently deletes "`,o?.definition.name||`Spot`,`" and its properties. This cannot be undone.`]})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{type:`button`,children:`Cancel`}),(0,X.jsx)(sr,{type:`button`,variant:`destructive`,onClick:()=>o&&l(o.key),children:`Delete spot`})]})]})})]})}FI.displayName=`SpotsPanel`;var II=[`properties`,`spots`];function LI(e){return II.some(t=>t===e)}function RI({selectedSpotKey:e,onSelectSpot:t,className:n}){let[r,i]=(0,Y.useState)(`properties`),[a,o]=(0,Y.useState)(e);return e!==a&&(o(e),e&&i(`spots`)),(0,X.jsxs)(pu,{value:r,onValueChange:e=>{LI(e)&&i(e)},className:q(`flex min-h-0 flex-col gap-2`,n),children:[(0,X.jsxs)(hu,{className:`mx-4 w-auto shrink-0 border-b border-border`,children:[(0,X.jsxs)(gu,{value:`properties`,children:[(0,X.jsx)(Za,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`text-xs`,children:`Properties`})]}),(0,X.jsxs)(gu,{value:`spots`,"data-quick-help":`world-spots-tab`,children:[(0,X.jsx)(xi,{className:`size-3.5`}),(0,X.jsx)(`span`,{className:`text-xs`,children:`Spots`})]})]}),(0,X.jsx)(_u,{value:`properties`,className:`min-h-0`,children:(0,X.jsx)(jl,{className:`h-full px-4 pb-4`,children:(0,X.jsx)(OI,{})})}),(0,X.jsx)(_u,{value:`spots`,className:`min-h-0`,children:(0,X.jsx)(jl,{className:`h-full px-4 pb-4`,children:(0,X.jsx)(FI,{selectedSpotKey:e,onSelect:t})})})]})}RI.displayName=`SidePanelTabs`;function zI({selectedSpotKey:e,onSelectSpot:t}){let[n,r]=(0,Y.useState)(`worldEditor`);(0,Y.useEffect)(function(){let e=L.getInstance().resources.get$(te.ENVIRONMENT_SETTINGS_RESOURCE).pipe(D(e=>e?.definition$?e.definition$.pipe(w(e=>e.properties?.preset)):T(void 0))).subscribe(e=>r(e));return()=>e.unsubscribe()},[]);let i=(0,Y.useCallback)(e=>{L.getInstance().resources.updateDefinition({key:te.ENVIRONMENT_SETTINGS_RESOURCE,"properties.preset":e?`preview`:`worldEditor`})},[]);return(0,X.jsxs)(`aside`,{className:`flex h-full w-80 shrink-0 flex-col overflow-hidden`,"data-quick-help":`world-side-panel`,children:[(0,X.jsx)(`div`,{className:`flex h-13 shrink-0 items-center justify-end px-4`,children:(0,X.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-1.5 text-xs text-muted-foreground`,"data-quick-help":`world-preview`,children:[(0,X.jsx)(`span`,{children:`Preview`}),(0,X.jsx)(Cn,{size:`sm`,checked:n===`preview`,onCheckedChange:i,"aria-label":`Preview mode`})]})}),(0,X.jsx)(RI,{className:`min-h-0 flex-1`,selectedSpotKey:e,onSelectSpot:t})]})}zI.displayName=`SidePanel`;function BI(e,t){let n=`${e} Copy `,r=t.filter(t=>t===e||t.startsWith(n)).map(t=>{if(t===e)return 0;let n=t.match(/ Copy (\d+)$/);return n?parseInt(n[1]||`0`,10):0});return`${e} Copy ${r.length===0?1:Math.max(...r)+1}`}function VI(){let{isOpen:e,handleOpenChange:t}=uI(),[n,r]=(0,Y.useState)(!0),[i,a]=(0,Y.useState)(``),{activeOrganization:o}=z(),s=p(),{handleSubmit:c,worldId:l}=bI(),u=R(),d=fe(),{data:f}=V(u.space.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],pagination:{pageIndex:0,pageSize:100},organizationId:o?.id},{enabled:!!e})),m=(0,Y.useMemo)(()=>{let e=f?.items??[],t=i.trim().toLowerCase();return e.filter(e=>n&&!e.template?!1:!t||e.name.toLowerCase().includes(t)||(e.description?.toLowerCase().includes(t)??!1))},[f,i,n]),h=e=>{e||(a(``),r(!0)),t(e)},g=u.space.list.queryKey(),_=u.world.get.queryKey([l]),v=u.space.create.mutationOptions({onSuccess:async(e,t)=>{try{let e=s.getValues(`spaces`)??[],n=f?.items?.find(e=>e.id===t.extends),r=t.thumbnailId??n?.thumbnailId??n?.thumbnail?.id,i={id:t.id,name:t.name,isDefault:!1,order:e.length,...r?{thumbnailId:r}:{},...n?.thumbnail?{thumbnail:n.thumbnail}:{}};s.setValue(`spaces`,[...e,i],{shouldDirty:!0,shouldTouch:!0});let a=s.getValues();await c(a),await Promise.all([d.invalidateQueries({queryKey:g}),d.invalidateQueries({queryKey:_})]),J.success(`Space "${t.name}" added successfully`)}catch{J.error(`Failed to add space to world`)}},onError:(e,t)=>
125{J.error(`Failed to create space "${t.name}"`)}}),y=B(v),b=async e=>{let t=xr();if(!o?.id)return;let n=(s.getValues(`spaces`)||[]).map(e=>e.name).filter(e=>typeof e==`string`&&e.length>0),r=BI(e.name,n),i=e.thumbnailId??e.thumbnail?.id;await y.mutateAsync({id:t,organizationId:o?.id,extends:e.id,name:r,...i?{thumbnailId:i}:{}})};return(0,X.jsxs)(ar,{open:e,onOpenChange:h,children:[(0,X.jsx)(vr,{render:e=>(0,X.jsxs)(U,{variant:`outline`,...e,className:`w-full`,children:[(0,X.jsx)(Hr,{className:`mr-2 h-4 w-4`}),` New Space`]})}),(0,X.jsxs)(pr,{className:`md:max-w-4xl`,children:[(0,X.jsxs)(rr,{children:[(0,X.jsx)(mr,{children:`Add a Space`}),(0,X.jsx)(_r,{children:`Select a template or copy an existing space into your virtual environment`})]}),(0,X.jsxs)(`div`,{className:`flex flex-col gap-3 sm:flex-row sm:items-end sm:justify-between`,children:[(0,X.jsx)(pT,{title:`Search spaces`,placeholder:`Search by name or description`,searchValue:i,changeSearchValue:a}),(0,X.jsxs)(`label`,{className:`flex shrink-0 cursor-pointer items-center gap-2 pb-2 text-xs text-muted-foreground`,children:[(0,X.jsx)(`span`,{className:q(!n&&`text-foreground`),children:`All spaces`}),(0,X.jsx)(Cn,{size:`sm`,checked:n,onCheckedChange:e=>r(e),"aria-label":`Show only templates`}),(0,X.jsx)(`span`,{className:q(n&&`text-foreground`),children:`Templates`})]})]}),f&&m.length===0?(0,X.jsx)(`div`,{className:`flex h-40 items-center justify-center text-sm text-muted-foreground`,children:f.items.length===0?`No spaces available`:`No spaces match your search`}):(0,X.jsx)(jl,{className:`h-[50svh] w-full`,children:(0,X.jsx)(`div`,{className:`grid grid-cols-2 gap-4 pr-3 md:grid-cols-3`,children:m.map(e=>(0,X.jsxs)(`button`,{type:`button`,className:q(`group relative flex flex-col overflow-hidden rounded-lg border-2 border-border bg-card pb-2 text-left transition-all hover:border-primary hover:shadow-lg`),onClick:()=>{b({id:e.id,name:e.name,description:e.description,thumbnailId:e.thumbnailId??e.thumbnail?.id??void 0,thumbnail:e.thumbnail}),h(!1)},children:[(0,X.jsx)(`div`,{className:`relative aspect-4/3 w-full overflow-hidden`,children:(0,X.jsx)(mT,{src:e.thumbnail?.url,alt:e.name,className:`h-full w-full object-cover transition-transform duration-300`})}),(0,X.jsxs)(`div`,{className:`flex h-20 w-full flex-col gap-1 px-4 py-2`,children:[(0,X.jsx)(`h3`,{className:`truncate text-left text-foreground`,children:e.name}),(0,X.jsxs)(Pn,{children:[(0,X.jsx)(dr,{render:(0,X.jsx)(`span`,{className:`line-clamp-2 px-0 py-0 text-left text-xs text-muted-foreground`,children:e.description})}),(0,X.jsx)(Gn,{side:`bottom`,children:(0,X.jsx)(`p`,{children:e.description})})]})]})]},e.id))})})]})]})}var HI=`data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iODgiIGhlaWdodD0iODgiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjMDAwIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBvcGFjaXR5PSIuMyIgZmlsbD0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIzLjciPjxyZWN0IHg9IjE2IiB5PSIxNiIgd2lkdGg9IjU2IiBoZWlnaHQ9IjU2IiByeD0iNiIvPjxwYXRoIGQ9Im0xNiA1OCAxNi0xOCAzMiAzMiIvPjxjaXJjbGUgY3g9IjUzIiBjeT0iMzUiIHI9IjciLz48L3N2Zz4KCg==`;function UI(e){let[t,n]=(0,Y.useState)(!1),r=()=>{n(!0)},{src:i,alt:a,style:o,className:s,...c}=e;return t?(0,X.jsx)(`div`,{className:`inline-block bg-muted text-center align-middle ${s??``}`,style:o,children:(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`img`,{src:HI,alt:`Error loading image`,...c,"data-original-url":i})})}):(0,X.jsx)(`img`,{src:i,alt:a,className:s,style:o,...c,onError:r})}function WI({space:e,spaces:t,index:n,remove:r,replace:i,append:a,showSuccess:o=!1}){let[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(!1),[d,f]=(0,Y.useState)(!1),[m,h]=(0,Y.useState)(!1),g=p(),_=bI(),v=R(),y=e=>{L.getInstance().resources.setValue(`spaceId`,e)};(0,Y.useEffect)(function(){let t=L.getInstance().resources.getValue$(`spaceId`).subscribe(t=>{c(t===e.id)});return()=>{c(!1),t.unsubscribe()}},[e.id]);let b=e=>{let n=t?.map(t=>({...t,isDefault:t.id===e.id}));i(n)},x=v.space.duplicate.mutationOptions({onSuccess(e,n,r,i){console.log(`data`,e,n,r,i),J.success(`Space duplicated successfully ${r}`),a({id:e,name:n.name+` (Copy)`,isDefault:!1,order:t.length+1})},onError(){J.error(`Failed to duplicate space`)}}),S=B(x),C=async()=>{await S.mutateAsync({spaceId:e.id,name:e.name+` (Copy)`})},w=e?.thumbnail;return(0,X.jsxs)(Nt,{value:e.id,onClick:()=>y(e.id),asHandle:!0,onMouseEnter:()=>u(!0),onMouseLeave:()=>u(!1),className:`rounded-lg shadow-xl`,children:[(0,X.jsxs)(`div`,{className:q(`relative w-full cursor-pointer overflow-hidden rounded-lg border-2 transition-all duration-300`,o?`ring-2 ring-emerald-400 ring-offset-2`:s&&`ring-2 ring-primary ring-offset-2`),children:[(0,X.jsx)(`div`,{className:`relative z-40 aspect-4/3 overflow-hidden`,children:w?.url?(0,X.jsx)(UI,{src:w.url,alt:`Space Thumbn
125ail`,className:`h-full w-full object-cover`}):(0,X.jsx)(`div`,{className:`h-full w-full bg-muted`})}),(0,X.jsx)(`div`,{className:`absolute top-1 left-1 z-50 rounded bg-primary px-1.5 py-0.5 text-[10px] text-primary-foreground`,children:n+1}),(0,X.jsx)(`div`,{className:`absolute right-0 bottom-0 left-0 z-50 bg-linear-to-t from-black/70 to-transparent p-2`,children:(0,X.jsx)(`div`,{className:`truncate text-[11px] text-white`,children:e.name})}),t.length>0&&(0,X.jsxs)(`div`,{className:q(`absolute top-1.5 right-1.5 z-50 flex items-center gap-1 opacity-0 transition-opacity`,l&&`opacity-100`),children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":Z(`components.space.top.bar.name.edit`),className:`flex h-6 w-6 items-center justify-center rounded-md bg-black/60 text-white backdrop-blur-sm transition-colors hover:bg-black/80`,onClick:e=>{e.stopPropagation(),e.preventDefault(),h(!0)},children:(0,X.jsx)(ja,{className:`size-3.5`})}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Duplicate space`,className:`flex h-6 w-6 items-center justify-center rounded-md bg-black/60 text-white backdrop-blur-sm transition-colors hover:bg-black/80`,onClick:e=>{e.stopPropagation(),e.preventDefault(),C()},children:(0,X.jsx)(pi,{className:`size-3.5`})}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Delete space`,className:`flex h-6 w-6 items-center justify-center rounded-md bg-black/60 text-white backdrop-blur-sm transition-colors hover:bg-red-600`,onClick:e=>{f(!0),e.preventDefault(),e.stopPropagation()},children:(0,X.jsx)(Qi,{className:`size-3.5`})})]}),t.length>0&&(0,X.jsx)(`button`,{type:`button`,"aria-label":e.isDefault?`Default space`:`Set as default`,className:q(`absolute right-1.5 bottom-1.5 z-50 flex h-6 w-6 items-center justify-center transition-colors`,e.isDefault?`appearance-none rounded-none border-0 bg-transparent p-0 shadow-none backdrop-blur-none outline-none [-webkit-tap-highlight-color:transparent] hover:bg-transparent focus:bg-transparent focus-visible:bg-transparent focus-visible:ring-2 focus-visible:ring-primary/35 focus-visible:ring-offset-0 active:bg-transparent`:`rounded-md bg-black/60 backdrop-blur-sm outline-none hover:bg-black/80 focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2`,!e.isDefault&&`opacity-0`,l&&`opacity-100`),onClick:t=>{t.stopPropagation(),t.preventDefault(),b({...e,isDefault:!e.isDefault}),_.handleSubmit(g.getValues())},children:(0,X.jsx)(Bi,{className:q(`size-3.5`,e.isDefault?`fill-yellow-400 stroke-black/25 stroke-[1.25] text-yellow-400`:`text-white`)})}),t.length>0&&(0,X.jsxs)(cr,{open:d,onOpenChange:f,children:[(0,X.jsx)(Nn,{nativeButton:!1,render:e=>(0,X.jsx)(`span`,{...e})}),(0,X.jsxs)(br,{children:[(0,X.jsxs)(Sr,{children:[(0,X.jsx)(Yn,{children:`Delete Space`}),(0,X.jsx)(Cr,{children:`This action cannot be undone. This will permanently delete the space and remove it from the world.`})]}),(0,X.jsxs)(ir,{children:[(0,X.jsx)(nr,{children:`Cancel`}),(0,X.jsx)(sr,{className:`bg-destructive text-destructive-foreground hover:bg-destructive/90`,onClick:e=>{e.preventDefault(),e.stopPropagation(),r(n),_.handleSubmit(g.getValues())},children:`Delete`})]})]})]})]}),(0,X.jsx)(IF,{id:e.id,worldId:_.worldId??``,open:m,onOpenChange:h,onSuccess:e=>{i((g.getValues(`spaces`)??[]).map((t,r)=>{if(r!==n)return t;let i={...t};return e.thumbnailId===null?(delete i.thumbnail,i.thumbnailId=void 0):(i.thumbnailId=e.thumbnailId??e.thumbnail?.id??i.thumbnailId,e.thumbnail&&(i.thumbnail=e.thumbnail)),{...i,name:e.name,isDefault:t.isDefault,order:t.order??r}}))}})]},e.id+n.toString())}var GI=[Bt.configure({activationConstraints:[new Ht.Delay({value:250,tolerance:1/0})]})];function KI(){let e=p(),t=bI(),{organizationSlug:n}=S(),{fields:r,remove:i,replace:a,append:o}=v({control:e.control,name:`spaces`,keyName:`_id`}),s=c(),l=e.watch(`spaces`),[u,d]=(0,Y.useState)(null);return(0,X.jsxs)(`div`,{className:`flex h-full w-56 shrink-0 flex-col`,"data-quick-help":`world-spaces`,children:[(0,X.jsx)(`div`,{className:`flex h-13 shrink-0 items-center px-2`,children:(0,X.jsxs)(U,{variant:`outline`,onClick:()=>s(`/${n}/dashboard/worlds`),children:[(0,X.jsx)(Ca,{className:`size-4`}),`Back to Dashboard`]})}),(0,X.jsxs)(jl,{className:`flex w-full flex-1 flex-col items-center justify-center gap-2 overflow-hidden`,children:[r&&r.length>0?(0,X.jsxs)(mn,{...e.register(`spaces`),sensors:GI,value:r,onValueChange:n=>{let i=r.map(e=>e.id),o=n.map(e=>e.id),s=null,c=0;for(let e of i){let t=Math.abs(o.indexOf(e)-i.indexOf(e));t>
125c&&(c=t,s=e)}s&&(d(s),setTimeout(()=>d(null),1500));let l=e.getValues(`spaces`)??[],u=new Map(l.map(e=>[e.id,e])),f=n.map((e,t)=>({...u.get(e.id)??e,order:t}));a(f);let p=e.getValues();t.handleSubmit(p)},getItemValue:e=>e.id,children:[(0,X.jsx)(un,{className:`space-y-3 p-3`,children:r?.map((e,t)=>{let n=l?.[t]??e;return(0,X.jsx)(WI,{index:t,space:n,spaces:l??r,remove:i,replace:a,append:o,showSuccess:n.id===u},e.id)})}),(0,X.jsx)(Xt,{children:e=>{let t=e.value,n=l?.find(e=>e.id===t)??r?.find(e=>e.id===t);return n?(0,X.jsx)(WI,{index:r?.findIndex(e=>e.id===t)??0,space:n,spaces:l??r,remove:i,replace:a,append:o}):null}})]}):(0,X.jsx)(`div`,{className:`flex flex-col items-center gap-4 p-6`,children:(0,X.jsx)(`p`,{className:`text-center text-muted-foreground`,children:`No spaces added yet. Add your first space to get started.`})}),(0,X.jsx)(`div`,{className:`p-3`,children:(0,X.jsx)(VI,{})})]})]})}function qI(e){if(e&&AI(e))return e.key}function JI(){let[e,t]=(0,Y.useState)(void 0);return(0,Y.useEffect)(function(){let e=P.get$(`editor/entity/selected`).subscribe(e=>{let n=e.payload.entity,r=n?L.getInstance().entities.get(n):void 0;t(qI(r))});return()=>e.unsubscribe()},[]),[e,(0,Y.useCallback)(e=>{t(e),P.publish({type:`editor.entity.select`,payload:{entity:e}})},[])]}function YI(){return(0,X.jsxs)(`div`,{className:`flex h-svh gap-2 overflow-hidden bg-muted p-2`,children:[(0,X.jsxs)(`div`,{className:`flex h-full w-64 shrink-0 flex-col`,children:[(0,X.jsx)(`div`,{className:`flex h-13 shrink-0 items-center px-2`,children:(0,X.jsx)(Uk,{className:`h-4 w-36`})}),(0,X.jsx)(`div`,{className:`flex flex-col gap-3 p-3`,children:Array.from({length:4}).map((e,t)=>(0,X.jsx)(Uk,{className:`h-24 w-full rounded-lg`},t))})]}),(0,X.jsxs)(`div`,{className:`flex flex-1 flex-col gap-2`,children:[(0,X.jsxs)(`div`,{className:`flex h-13 shrink-0 items-center justify-between px-2`,children:[(0,X.jsx)(Uk,{className:`h-5 w-40`}),(0,X.jsxs)(`div`,{className:`flex gap-2`,children:[(0,X.jsx)(Uk,{className:`h-8 w-24`}),(0,X.jsx)(Uk,{className:`h-8 w-24`})]})]}),(0,X.jsx)(Uk,{className:`flex-1 rounded-none`})]}),(0,X.jsxs)(`div`,{className:`flex h-full w-80 shrink-0 flex-col`,children:[(0,X.jsx)(`div`,{className:`flex h-13 shrink-0 items-center px-2`,children:(0,X.jsx)(Uk,{className:`h-5 w-32`})}),(0,X.jsx)(`div`,{className:`flex flex-col gap-3 p-4`,children:Array.from({length:6}).map((e,t)=>(0,X.jsx)(Uk,{className:`h-8 w-full`},t))})]})]})}function XI(){let e=S(),t=e.worldSlug,n=e.organizationSlug,r=R(),{activeOrganization:i}=z(),a=md(),o=Sd({scope:`world`,action:`update`,fallback:`../..`}),s=l({defaultValues:{name:``,description:``,slug:``,organizationId:a,thumbnailId:``,thumbnail:void 0,spaces:[]}}),{data:c,isLoading:u}=V(r.world.list.queryOptions({organizationId:a,sorting:[{id:`slug`,desc:!1}],pagination:{pageIndex:0,pageSize:100},columnFilters:[],globalFilter:``},{enabled:!!t})),d=c?.items.find(e=>e.slug===t),f=d?.id,{data:p,isLoading:m,isError:h}=V(r.world.get.queryOptions([f],{enabled:!!f})),g=No(),{data:v}=V(r.world.getPreviewWorldLanguage.queryOptions({organizationSlug:i?.slug??``,worldSlug:t??``,languageCode:g},{enabled:!!f&&!!i?.slug}));Nd((0,Y.useMemo)(()=>Od(g,v)??void 0,[g,v]));let y=(0,Y.useRef)(!1),b=(0,Y.useRef)(!1),[x,C]=JI();return(0,Y.useEffect)(function(){let e=L.getInstance();return e.useDefaults(ae),e.useDefaults(_o),()=>{e.releaseDefaults(_o),e.releaseDefaults(ae),e.clear()}},[]),(0,Y.useEffect)(function(){y.current=!1,b.current=!1;let e=L.getInstance(),t=P.get$(`space.enter`).subscribe(t=>{t.payload.id&&e.resources.setValue(`spaceId`,t.payload.id)});return()=>{t.unsubscribe()}},[f]),(0,Y.useEffect)(function(){let e=L.getInstance(),t=e.resources.get$(te.ENVIRONMENT_SETTINGS_RESOURCE).pipe(O(e=>e!=null),E(1)).subscribe(()=>{e.resources.updateDefinition({key:te.ENVIRONMENT_SETTINGS_RESOURCE,"properties.preset":`worldEditor`})});return()=>t.unsubscribe()},[]),(0,Y.useEffect)(function(){if(y.current)return;let e=p?.[0]?.spaces?.[0]?.id;e&&(L.getInstance().resources.setValue(`spaceId`,e),y.current=!0)},[p]),(0,Y.useEffect)(function(){if(b.current||!p?.[0])return;let e=p[0];s.reset({id:e.id,organizationId:e.organizationId,createdAt:e.createdAt,updatedAt:e.updatedAt,name:e.name,description:e.description,slug:e.slug,spaces:e.spaces.sort((e,t)=>
125(e.order??0)-(t.order??0))||[],thumbnailId:e.thumbnailId,thumbnail:e.thumbnail,cmsCollectionIds:e.cmsCollectionIds??[],labelCollectionIds:e.labelCollectionIds??[]}),b.current=!0},[p,s]),o||(t&&c&&!d?(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,X.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,X.jsx)(`h2`,{className:`mb-2 text-2xl font-bold text-destructive`,children:`World Not Found`}),(0,X.jsxs)(`p`,{className:`text-muted-foreground`,children:[`World "`,t,`" not found`,n?` for organization "${n}"`:``,`.`]})]})}):u||f&&(m||!p)?(0,X.jsx)(YI,{}):h?(0,X.jsx)(`div`,{children:`Error loading world`}):(0,X.jsx)(_,{...s,children:(0,X.jsxs)(`form`,{className:`flex h-svh gap-2 overflow-hidden bg-muted p-2`,id:`world-form`,children:[(0,X.jsx)(KI,{}),p&&p[0]&&(0,X.jsx)(wI,{world:p[0]}),(0,X.jsx)(zI,{selectedSpotKey:x,onSelectSpot:C})]})}))}function ZI(e){return[...e.keys()].map((e,t)=>{let n=e,r=e;try{n=new Intl.DisplayNames([`en`],{type:`language`}).of(e)??e,r=new Intl.DisplayNames([e],{type:`language`}).of(e)??n}catch{}return{languageCode:e,name:n,nativeName:r,isDefault:t===0,order:t}})}function QI(e){if(e==null)return null;if(Array.isArray(e)){let t=e[0];return t&&typeof t==`object`&&`data`in t&&t.data!=null?t.data:null}return e}var $I=()=>{let[e,t]=(0,Y.useState)(void 0),[n,r]=(0,Y.useState)(!1),{organizationSlug:i,worldSlug:a}=S(),o=R(),s=c(),l=C().pathname.includes(`dashboard`),[u,d]=wo(),f=o.world.getPublishedWorld.queryOptions({organizationSlug:i??``,worldSlug:a??``},{enabled:!!i&&!!a,refetchOnWindowFocus:!1,staleTime:1/0}),{data:p,isLoading:m,isError:h,isSuccess:g}=V(f),{languageMap:_}=Nd((0,Y.useMemo)(()=>Ad(p)??void 0,[p])),v=(0,Y.useMemo)(()=>ZI(_),[_]);(0,Y.useEffect)(function(){let e=v[0]?.languageCode;e&&(u&&_.has(u)||d(e))},[v,_,u,d]),(0,Y.useEffect)(function(){return()=>d(null)},[d]);let y=(0,Y.useMemo)(()=>QI(p),[p]),b=(0,Y.useMemo)(()=>{let t=y?.spaces;if(t?.length){if(e){let n=t.find(t=>t.id===e);if(n)return n}return t.find(e=>e.isDefault===!0)??t[0]}},[y,e]),x=(0,Y.useMemo)(()=>y?.spaces??[],[y]),w=b?.name,T=(0,Y.useMemo)(()=>new Set(x.map(e=>e.id)),[x]);(0,Y.useEffect)(function(){if(!b)return;let e=L.getInstance(),t=oe(b),n=he(t,T);e.sync(n)},[b,T]),(0,Y.useEffect)(function(){return()=>{L.getInstance().clear()}},[]),(0,Y.useEffect)(function(){let e=P.get$(`space.enter`).subscribe(e=>{let n=e?.payload?.id;n&&T.has(n)&&t(n)});return()=>e.unsubscribe()},[T]);let E=ho();return po({allowedOrigins:E}),h?(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,X.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,X.jsx)(`h2`,{className:`mb-2 text-2xl font-bold text-destructive`,children:Z(`views.world-view.error.title`)}),(0,X.jsx)(`p`,{className:`text-muted-foreground`,children:Z(`views.world-view.error.description`)})]})}):g&&!m&&y==null&&a?(0,X.jsx)(`div`,{className:`flex min-h-screen items-center justify-center`,children:(0,X.jsxs)(`div`,{className:`p-8 text-center`,children:[(0,X.jsx)(`h2`,{className:`mb-2 text-2xl font-bold text-destructive`,children:Z(`views.world-view.not-found.title`)}),(0,X.jsxs)(`p`,{className:`text-muted-foreground`,children:[`No published world "`,a,`"`,i?` for organization &quot;${i}&quot;`:``,`.`]})]})}):m?(0,X.jsx)(`div`,{className:`flex h-svh w-svw items-center justify-center`,children:(0,X.jsx)(An,{})}):(0,X.jsxs)(`div`,{className:`h-svh w-svw`,children:[v.length>0&&(0,X.jsx)(`div`,{className:`pointer-events-auto fixed top-3 left-5 z-50`,children:(0,X.jsx)(jo,{hidden:!0,value:u,locales:v,onValueChange:e=>{d(e)}})}),l&&a&&(0,X.jsx)(U,{onClick:()=>s(`/${i}/dashboard/worlds/${a}/edit`),className:`fixed top-3 right-5 z-50 text-white`,variant:`ghost`,size:`icon`,children:(0,X.jsx)(ja,{className:`size-5`})}),x.length>0&&(0,X.jsx)(`div`,{className:`pointer-events-auto fixed top-3 left-1/2 z-50 -translate-x-1/2`,children:(0,X.jsxs)(jn,{open:n,onOpenChange:r,children:[(0,X.jsx)(Kn,{render:e=>(0,X.jsxs)(U,{variant:`ghost`,"aria-label":`Select space`,className:`group h-12 gap-2 rounded-lg bg-white px-3 hover:bg-neutral-100 active:scale-95 dark:bg-background dark:hover:bg-white/10`,...e,children:[(0,X.jsx)(xi,{"aria-hidden":!0,
125className:`h-4 w-4 text-black dark:text-white`}),(0,X.jsx)(`span`,{className:q(`hidden max-w-45 truncate text-sm font-semibold lg:inline`,w?`text-black dark:text-white`:`text-muted-foreground group-hover:text-foreground`),children:w||`Select Space`})]})}),(0,X.jsx)(ur,{side:`bottom`,align:`center`,sideOffset:8,className:q(`w-70 overflow-hidden p-0 sm:w-[320px]`,`border border-border bg-popover shadow-xl`),children:(0,X.jsxs)(`div`,{className:`px-2 pt-2 pb-2`,children:[(0,X.jsx)(`div`,{className:`mb-1 px-2`,children:(0,X.jsx)(`p`,{className:`text-xs font-semibold tracking-[0.2em] text-muted-foreground uppercase`,children:`Spaces`})}),(0,X.jsx)(`div`,{className:`flex flex-col gap-1.5`,children:x.map(e=>{let n=e.id===b?.id,i=e.thumbnail?.url;return(0,X.jsxs)(U,{variant:`ghost`,"aria-label":`Go to ${e.name}${n?` (current)`:``}`,"aria-current":n?`true`:`false`,disabled:n,className:q(`flex h-auto w-full items-center justify-start gap-3 px-2.5 py-2`,n&&`bg-primary text-primary-foreground`),onClick:()=>{t(e.id),r(!1)},children:[(0,X.jsx)(`div`,{className:`relative h-10 w-10 shrink-0 overflow-hidden rounded-md bg-muted`,children:i?(0,X.jsx)(`img`,{src:i,alt:`${e.name} thumbnail`,className:`h-full w-full object-cover`}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(Nr,{"aria-hidden":!0,className:`h-5 w-5 text-muted-foreground`})})}),(0,X.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col items-start`,children:[(0,X.jsx)(`span`,{className:`truncate text-sm font-medium`,children:e.name}),e.description?(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.description}):null]}),n?(0,X.jsx)(Ea,{"aria-hidden":!0,className:`h-4 w-4 shrink-0 text-white`}):null]},e.id)})}),(0,X.jsx)(`div`,{className:`mt-2 px-2`,children:(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground`,children:[x.length,` `,x.length===1?`space`:`spaces`,` `,`available`]})})]})})]})}),(0,X.jsxs)(mo,{children:[(0,X.jsx)(uo,{inboundMode:`wrapped`}),(0,X.jsx)(fo,{})]})]})};$I.displayName=`WorldView`;var eL=[{id:`select`,header:({table:e})=>(0,X.jsx)(Pd,{checked:e.getIsAllPageRowsSelected()||!!e.getIsSomePageRowsSelected(),onCheckedChange:t=>e.toggleAllPageRowsSelected(!!t),"aria-label":`Select all`}),cell:({row:e})=>(0,X.jsx)(Pd,{checked:e.getIsSelected(),onCheckedChange:t=>e.toggleSelected(!!t),"aria-label":`Select row`,onClick:e=>e.stopPropagation()}),enableSorting:!1,enableHiding:!1},{accessorKey:`name`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.name`)}),cell:({row:e})=>(0,X.jsx)(`div`,{children:e.original.name})},{id:`status`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:`Status`}),cell:({row:e})=>{let t=!!e.original.publishedSnapshotId;return(0,X.jsx)(fr,{variant:`outline`,className:t?`border-emerald-200 bg-emerald-100 text-emerald-800 dark:border-emerald-800/50 dark:bg-emerald-900/30 dark:text-emerald-300`:`border-amber-200 bg-amber-100 text-amber-800 dark:border-amber-800/50 dark:bg-amber-900/30 dark:text-amber-300`,children:t?`Published`:`Draft`})}},{accessorKey:`thumbnail`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.thumbnail`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`flex items-center justify-start`,children:e.original.thumbnail?.url?(0,X.jsx)(`img`,{src:e.original.thumbnail?.url,alt:`World Thumbnail`,className:`aspect-square h-4 w-4 rounded-full object-cover`}):(0,X.jsx)(Ri,{className:`size-4 rounded-full text-muted-foreground opacity-50`})})},{accessorKey:`description`,header:({column:e})=>(0,X.jsx)(Fd,{column:e,title:Z(`common.description`)}),cell:({row:e})=>(0,X.jsx)(`div`,{className:`max-w-37.5 truncate text-muted-foreground`,title:e.original.description||void 0,children:e.original.description||`—`})},{id:`actions`,cell:({row:e})=>(0,X.jsx)(tL,{row:e})}],tL=({row:e})=>{let t=e.original,{activeOrganization:n,hasPermissions:r}=z(),i=md(),a=r(i,`world`,`update`),o=r(i,`world`,`delete`),s=n?.slug??``,c=t.slug,l=b(`/${s}/dashboard/worlds/${c}/edit`),d=b(`/${s}/worlds/${c}`),[f,p]=(0,Y.useState)(!1),m=R(),h=fe(),g=m.world.list.queryKey(),_=m.world.remove.mutationOptions({onSuccess:()=>{h.invalidateQueries({queryKey:g})}}),v=B(_);return(0,X.jsxs)(nt,{children:[(0,X.jsx)(Pe,{render:e=>(0,X.jsxs)(U,{...e,variant:`ghost`,className:`h-8 w-8 p-0`,onClick:e=>{e.preventDefault(),e.stopPropagation()},children:[(0,X.jsx)(`span`,{className:`sr-only`,children:Z(`common.open.menu`)}),(0,X.jsx)(kr,{className:`h-4 w-4`})]})}),(0,X.jsx)(Ue,{children:(0,X.jsxs)(Ie,{align:`end`,className:`w-fit`,children:[(0,X.jsx)(On,{className:`text-xs font-medium`,children:Z(`common.actions`)}),(0,X.jsx)(st,{nativeButton:!1,render:e=>(0,X.jsxs)(u,{to:d,...e,children:[(0,X.jsx)(Wa,{className:`size-4`}),Z(`routes.worlds.columns.view.world`)]})}),a&&(0,X.jsx)(st,{nativeButton:!1,render:e=>(0,X.jsxs)(u,{to:l,...e,children:[(0,X.jsx)(va,{className:`size-4`}),Z(`common.edit.world`)]})}),o&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(xe,{}),(0,X.jsx)(XM,{id:t.id,title:Z(`routes.worlds.columns.delete.world`),deleteRow:async()=>await v.mutateAsync([t.id]),open:f,setOpen:p})]})]})})]})},nL=()=>{let e=R(),{hasPermissions:t}=z(),n=md(),r=t(n,`world`,`create`),i=t(n,`world`,`delete`),a=fe(),{data:o,isLoading:s,isError:c}=V(e.world.list.queryOptions({sorting:[{id:`createdAt`,desc:!0}],organizationId:n})),l=e.world.list.queryKey(),u=e.world.remove.mutationOptions({onSuccess:()=>{a.invalidateQueries({queryKey:l})}}),d=B(u);return s?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(An,{className:`h-10 w-10`})}):c?(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`common.error.loading.worlds`)})}):o?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(CE,{title:Z(`common.worlds`),actions:r?(0,X.jsx)(HM,{}):void 0}),(0,X.jsx)(wE,{children:(0,X.jsx)(pd,{columns:eL,data:o.items.map(e=>({...e,createdAt:$i(new Date(e.createdAt.toISOString()),`dd-MM-yyyy HH:mm`),updatedAt:$i(new Date(e.updatedAt.toISOString()),`dd-MM-yyyy HH:mm`)})),onDeleteSelected:i?async e=>{let t=e.map(e=>e.id);await d.mutateAsync(t)}:void 0,multipleDeleteString:{start:`Delete`,end:`world`},navigateTo:{key:`slug`,additionalPath:`edit`}})})]}):(0,X.jsx)(`div`,{className:`flex h-full w-full items-center justify-center`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:Z(`common.no.worlds.found`)})})};nL.displayName=`Worlds`;var rL={events:{type:`event`,action:`list-view`},"events/create":{type:`event`,action:`create`},"events/:eventId":{type:`event`,action:`list-view`},worlds:{type:`world`,action:`list-view`},"worlds/create":{type:`world`,action:`create`},"worlds/:worldSlug/edit":{type:`world`,action:`update`},spaces:{type:`space`,action:`list-view`},"spaces/:spaceId/edit":{type:`space`,action:`update`},content:{type:`cms`,action:`list-view`},files:{type:`user`,action:`list`},emails:{type:`user`,action:`list`},"emails/:emailId/edit":{type:`user`,action:`list`},"settings/api-keys":{type:`user`,action:`list`},"settings/api-keys/create":{type:`user`,action:`list`},"settings/members":{anyOf:[{type:`organization`,action:`list`},{type:`organization`,action:`update`}]},"settings/members/:id":{anyOf:[{type:`organization`,action:`list`},{type:`organization`,action:`update`}]},"settings/organization":{type:`organization`,action:`update`},"settings/organizations":{type:`organization`,action:`list`},"settings/organizations/:id":{type:`organization`,action:`list`},"settings/billing":{type:`organization`,action:`update`}};function iL(e,t){return(0,X.jsx)(hs,{...e,children:t})}var aL=(0,X.jsxs)(d,{path:`:organizationSlug/dashboard`,element:(0,X.jsxs)(bs,{children:[(0,X.jsx)(mE,{}),(0,X.jsx)(Kl,{children:(0,X.jsx)(f,{})})]}),children:[(0,X.jsxs)(d,{element:(0,X.jsx)(Yl,{children:(0,X.jsx)(f,{})}),children:[(0,X.jsx)(d,{index:!0,element:(0,X.jsx)(m,{to:`home`})}),(0,X.jsx)(d,{path:`home`,element:(0,X.jsx)(oP,{})}),(0,X.jsx)(d,{path:`worlds`,element:iL(rL.worlds,(0,X.jsx)(nL,{}))}),(0,X.jsx)(d,{path:`worlds/create`,element:iL(rL[`worlds/create`],(0,X.jsx)(WM,{}))}),(0,X.jsx)(d,{path:`events`,element:iL(rL.events,(0,X.jsx)(eN,{}))}),(0,X.jsx)(d,{path:`events/create`,element:iL(rL[`events/create`],(0,X.jsx)(BM,{}))}),(0,X.jsx)(d,{path:`events/:eventId`,element:iL(rL[`events/:eventId`],(0,X.jsx)(GM,{}))}),(0,X.jsx)(d,{path:`files`,element:iL(rL.files,(0,X.jsx)(rN,{}))}),(0,X.jsx)(d,{path:`spaces`,element:iL(rL.spaces,(0,X.jsx)(lI,{}))}),(0,X.jsx)(d,{path:`account`,element:(0,X.jsx)(BE,{})}),(0,X.jsx)(d,{path:`emails`,element:iL(rL.emails,(0,X.jsx)(YM,{}))}),(0,X.jsx)(d,{path:`emails/:emailId/edit`,element:iL(rL[`emails/:emailId/edit`],(0,X.jsx)(qM,{}))}),(0,X.jsxs)(d,{path:`settings`,children:[(0,X.jsx)(d,{path:`members`,element:iL(rL[`settings/members`],(0,X.jsx)(tF,{}))}),(0,X.jsx)(d,{path:`members/:id`,element:(0,X.jsx)(gs,{children:iL(rL[`settings/members/:id`],(0,X.jsx)(rF,{}))})}),(0,X.jsx)(d,{path:`billing`,element:iL(rL[`settings/billing`],(0,X.jsx)(IP,{}))}),(0,X.jsx)(d,{path:`organization`,element:iL(rL[`settings/organization`],(0,X.jsx)(dF,{}))}),(0,X.jsx)(d,{path:`api-keys`,element:iL(rL[`settings/api-keys`],(0,X.jsx)(dP,{}))}),(0,X.jsx)(d,{path:`api-keys/create`,element:iL(rL[`settings/api-keys/create`],(0,X.jsx)(PP,{}))}),(0,X.jsx)(d,{path:`organizations`,element:iL(rL[`settings/organizations`],(0,X.jsx)(_F,{}))}),(0,X.jsx)(d,{path:`organizations/:id`,element:iL(rL[`settings/organizations/:id`],(0,X.jsx)(Ql,{}))})]})]}),(0,X.jsxs)(d,{element:(0,X.jsx)(f,{}),children:[(0,X.jsx)(d,{path:`spaces/:spaceId`,element:(0,X.jsx)(rI,{})}),(0,X.jsx)(d,{path:`spaces/:spaceId/edit`,element:iL(rL[`spaces/:spaceId/edit`],(0,X.jsx)(nI,{}))}),(0,X.jsx)(d,{path:`worlds/:worldSlug/edit`,element:iL(rL[`worlds/:worldSlug/edit`],(0,X.jsx)(XI,{}))}),(0,X.jsx)(d,{path:`content`,element:iL(rL.content,(0,X.jsx)(uM,{}))})]})]}),oL=(0,X.jsxs)(d,{element:(0,X.jsx)(Ss,{children:(0,X.jsx)(f,{})}),children:[(0,X.jsx)(d,{path:`signin`,element:(0,X.jsx)(bF,{})}),(0,X.jsx)(d,{path:`signup`,element:(0,X.jsx)(TF,{})}),(0,X.jsx)(d,{path:`forgot-password`,element:(0,X.jsx)(iN,{})}),(0,X.jsx)(d,{path:`reset-password`,element:(0,X.jsx)(sP,{})}),(0,X.jsx)(d,{path:`goodbye`,element:(0,X.jsx)(aN,{})})]}),sL=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(d,{path:`:organizationSlug`,element:(0,X.jsx)(m,{to:`dashboard`,replace:!0})}),(0,X.jsx)(d,{path:`:organizationSlug/worlds/:worldSlug`,element:(0,X.jsx)($I,{})}),(0,X.jsx)(d,{path:`:organizationSlug/accept-invitation`,element:(0,X.jsx)(SE,{})})]});
125export{hE as i,aL as n,sL as r,oL as t};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.