diff --git a/README.md b/README.md new file mode 100644 index 0000000..c28545f --- /dev/null +++ b/README.md @@ -0,0 +1,94 @@ +# Musenalm + +Bibliographie deutscher Almanache des 18. und 19. Jahrhunderts. Runs as a PocketBase-based web app with SQLite storage. + +## Commands + +Local build (dev assets + sqlite tags used in this repo): +```bash +./scripts/build.sh +``` + +Manual build equivalent: +```bash +go build -tags=dev,fts5,sqlite_icu -o ./tmp/musenalm . +``` + +Run (as used in the Docker image): +```bash +./scripts/run.sh +``` + +Docker image build: +```bash +./scripts/docker.sh +``` + +Reset local data directory: +```bash +./scripts/reset.sh +``` + +Docker Compose (prod/stage): +```bash +docker compose up --build +docker compose -f stage.docker-compose.yml up --build +``` + +## Build prerequisites + +- Go 1.24 (see `go.mod`, also used in `Dockerfile`). +- SQLite build tags used in this repo: + - Local/dev build: `dev,fts5,sqlite_icu` (see `scripts/build.sh`). + - Docker build: `sqlite_fts5,sqlite_json,sqlite_foreign_keys,sqlite_vtable` (see `Dockerfile`). +- The `dev` build tag serves templates/assets from disk (no embedding). Without it, assets are embedded into the binary. + +## Configuration + +Config files are loaded in this order, later values override earlier ones: +1) `config.dev.json` (dev defaults) +2) `config.json` (runtime overrides) +3) Environment variables with prefix `MUSENALM_` + +### Options + +`debug` (bool) +Enables PocketBase dev mode and, unless `disable_watchers` is true, turns on template watchers. + +`allow_test_login` (bool) +Creates/keeps a test superuser account (`demo@example.com` / `password`). When false, the test account is removed if present. + +`disable_watchers` (bool) +Disables template watchers even if `debug` is true. + +Environment variable equivalents: +- `MUSENALM_DEBUG` +- `MUSENALM_ALLOW_TEST_LOGIN` +- `MUSENALM_DISABLE_WATCHERS` + +## Hosting + +### Docker (recommended) + +`docker-compose.yml` runs the app on port 8090 and persists data in `/app/data/pb_data` via an external volume. + +Prereqs: +```bash +docker volume create musenalm +docker network create caddynet +``` + +Start: +```bash +docker compose up --build +``` + +Stage uses `stage.docker-compose.yml` and a separate external volume `musenalmstage`. + +### Bare binary + +Build the binary, then run it with a data directory: +```bash +./tmp/musenalm serve --http=0.0.0.0:8090 --dir=/path/to/pb_data +``` + diff --git a/controllers/exports_admin.go b/controllers/exports_admin.go new file mode 100644 index 0000000..c524b6f --- /dev/null +++ b/controllers/exports_admin.go @@ -0,0 +1,337 @@ +package controllers + +import ( + "fmt" + "net/http" + "os" + "path/filepath" + "strings" + "time" + + "github.com/Theodor-Springmann-Stiftung/musenalm/app" + "github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" + "github.com/Theodor-Springmann-Stiftung/musenalm/helpers/exports" + "github.com/Theodor-Springmann-Stiftung/musenalm/middleware" + "github.com/Theodor-Springmann-Stiftung/musenalm/pagemodels" + "github.com/Theodor-Springmann-Stiftung/musenalm/templating" + "github.com/pocketbase/pocketbase/core" + "github.com/pocketbase/pocketbase/tools/router" + "github.com/pocketbase/pocketbase/tools/types" +) + +const ( + URL_EXPORTS_ADMIN = "/redaktion/exports/" + URL_EXPORTS_RUN = "run/" + URL_EXPORTS_LIST = "list/" + URL_EXPORTS_DOWNLOAD = "download/" + URL_EXPORTS_DELETE = "delete/" + TEMPLATE_EXPORTS = "/redaktion/exports/" + TEMPLATE_EXPORTS_LIST = "/redaktion/exports/list/" + LAYOUT_EXPORTS_FRAGMENT = "fragment" +) + +func init() { + app.Register(&ExportsAdmin{}) +} + +type ExportsAdmin struct{} + +func (p *ExportsAdmin) Up(ia pagemodels.IApp, engine *templating.Engine) error { + return nil +} + +func (p *ExportsAdmin) Down(ia pagemodels.IApp, engine *templating.Engine) error { + return nil +} + +func (p *ExportsAdmin) Setup(router *router.Router[*core.RequestEvent], ia pagemodels.IApp, engine *templating.Engine) error { + appInstance := ia.Core() + exports.StartCleanup(appInstance, 12*time.Hour) + + rg := router.Group(URL_EXPORTS_ADMIN) + rg.BindFunc(middleware.Authenticated(appInstance)) + rg.BindFunc(middleware.IsAdmin()) + rg.GET("", p.pageHandler(engine, appInstance)) + rg.GET(URL_EXPORTS_LIST, p.listHandler(engine, appInstance)) + rg.POST(URL_EXPORTS_RUN, p.runHandler(appInstance)) + rg.GET(URL_EXPORTS_DOWNLOAD+"{id}", p.downloadHandler(appInstance)) + rg.POST(URL_EXPORTS_DELETE+"{id}", p.deleteHandler(appInstance)) + return nil +} + +type exportView struct { + Id string + Name string + Filename string + Type string + Status string + Progress int + TablesTotal int + TablesDone int + SizeBytes int64 + SizeLabel string + Created types.DateTime + Expires types.DateTime + CurrentTable string + Error string +} + +func (p *ExportsAdmin) pageHandler(engine *templating.Engine, app core.App) HandleFunc { + return func(e *core.RequestEvent) error { + data, err := exportsData(e, app) + if err != nil { + return engine.Response500(e, err, nil) + } + return engine.Response200(e, TEMPLATE_EXPORTS, data, pagemodels.LAYOUT_LOGIN_PAGES) + } +} + +func (p *ExportsAdmin) listHandler(engine *templating.Engine, app core.App) HandleFunc { + return func(e *core.RequestEvent) error { + data, err := exportsData(e, app) + if err != nil { + return engine.Response500(e, err, nil) + } + return engine.Response200(e, TEMPLATE_EXPORTS_LIST, data, LAYOUT_EXPORTS_FRAGMENT) + } +} + +func (p *ExportsAdmin) runHandler(app core.App) HandleFunc { + return func(e *core.RequestEvent) error { + req := templating.NewRequest(e) + if err := e.Request.ParseForm(); err != nil { + return e.JSON(http.StatusBadRequest, map[string]any{"error": "Formulardaten ungueltig."}) + } + csrfToken := e.Request.FormValue("csrf_token") + if err := req.CheckCSRF(csrfToken); err != nil { + session := req.Session() + if session == nil { + app.Logger().Warn("Export CSRF failed: no session", "token_len", len(csrfToken)) + } else { + app.Logger().Warn( + "Export CSRF failed", + "token_len", len(csrfToken), + "session_token_len", len(session.Token), + "session_csrf_len", len(session.CSRF), + "matches_token", csrfToken == session.Token, + "matches_csrf", csrfToken == session.CSRF, + ) + } + return e.JSON(http.StatusUnauthorized, map[string]any{"error": err.Error()}) + } + + exportType := strings.TrimSpace(e.Request.FormValue("export_type")) + if exportType == "" { + exportType = dbmodels.EXPORT_TYPE_DATA + } + if exportType != dbmodels.EXPORT_TYPE_DATA && exportType != dbmodels.EXPORT_TYPE_FILES { + return e.JSON(http.StatusBadRequest, map[string]any{"error": "Unbekannter Export-Typ."}) + } + + collection, err := app.FindCollectionByNameOrId(dbmodels.EXPORTS_TABLE) + if err != nil { + return e.JSON(http.StatusInternalServerError, map[string]any{"error": "Export-Tabelle nicht verfuegbar."}) + } + + record := core.NewRecord(collection) + now := time.Now() + var name string + if exportType == dbmodels.EXPORT_TYPE_FILES { + name = fmt.Sprintf("Dateien-Backup %s", now.Format("02.01.2006 15:04")) + } else { + name = fmt.Sprintf("XML-Export %s", now.Format("02.01.2006 15:04")) + } + record.Set(dbmodels.EXPORT_NAME_FIELD, name) + record.Set(dbmodels.EXPORT_TYPE_FIELD, exportType) + record.Set(dbmodels.EXPORT_STATUS_FIELD, dbmodels.EXPORT_STATUS_QUEUED) + record.Set(dbmodels.EXPORT_PROGRESS_FIELD, 0) + record.Set(dbmodels.EXPORT_TABLES_TOTAL_FIELD, 0) + record.Set(dbmodels.EXPORT_TABLES_DONE_FIELD, 0) + record.Set(dbmodels.EXPORT_EXPIRES_FIELD, types.NowDateTime().Add(7*24*time.Hour)) + record.Set(dbmodels.EXPORT_ERROR_FIELD, "") + record.Set(dbmodels.EXPORT_CURRENT_TABLE_FIELD, "") + + if user := req.User(); user != nil { + record.Set(dbmodels.EXPORT_CREATED_BY_FIELD, user.Id) + } + + if err := app.Save(record); err != nil { + return e.JSON(http.StatusInternalServerError, map[string]any{"error": err.Error()}) + } + + go func(exportID string) { + var runErr error + if exportType == dbmodels.EXPORT_TYPE_FILES { + runErr = exports.RunFiles(app, exportID) + } else { + runErr = exports.Run(app, exportID) + } + if runErr != nil { + app.Logger().Error("Export failed", "error", runErr, "export_id", exportID) + } + }(record.Id) + + return e.JSON(http.StatusOK, map[string]any{"success": true, "id": record.Id}) + } +} + +func (p *ExportsAdmin) downloadHandler(app core.App) HandleFunc { + return func(e *core.RequestEvent) error { + id := strings.TrimSpace(e.Request.PathValue("id")) + if id == "" { + return e.JSON(http.StatusBadRequest, map[string]any{"error": "Ungueltige Export-ID."}) + } + + record, err := app.FindRecordById(dbmodels.EXPORTS_TABLE, id) + if err != nil || record == nil { + return e.JSON(http.StatusNotFound, map[string]any{"error": "Export nicht gefunden."}) + } + + if record.GetString(dbmodels.EXPORT_STATUS_FIELD) != dbmodels.EXPORT_STATUS_COMPLETE { + return e.JSON(http.StatusBadRequest, map[string]any{"error": "Export ist noch nicht fertig."}) + } + + exportDir, err := exports.ExportDir(app) + if err != nil { + return e.JSON(http.StatusInternalServerError, map[string]any{"error": "Export-Verzeichnis nicht verfuegbar."}) + } + + filename := record.GetString(dbmodels.EXPORT_FILENAME_FIELD) + if filename == "" { + filename = record.Id + ".zip" + } + filename = filepath.Base(filename) + + path := filepath.Join(exportDir, filename) + if _, err := os.Stat(path); err != nil { + return e.JSON(http.StatusNotFound, map[string]any{"error": "Exportdatei nicht gefunden."}) + } + + e.Response.Header().Set("Content-Disposition", fmt.Sprintf("attachment; filename=\"%s\"", filename)) + return e.FileFS(os.DirFS(exportDir), filename) + } +} + +func (p *ExportsAdmin) deleteHandler(app core.App) HandleFunc { + return func(e *core.RequestEvent) error { + req := templating.NewRequest(e) + if err := e.Request.ParseForm(); err != nil { + return e.JSON(http.StatusBadRequest, map[string]any{"error": "Formulardaten ungueltig."}) + } + if err := req.CheckCSRF(e.Request.FormValue("csrf_token")); err != nil { + return e.JSON(http.StatusUnauthorized, map[string]any{"error": err.Error()}) + } + + id := strings.TrimSpace(e.Request.PathValue("id")) + if id == "" { + return e.JSON(http.StatusBadRequest, map[string]any{"error": "Ungueltige Export-ID."}) + } + + record, err := app.FindRecordById(dbmodels.EXPORTS_TABLE, id) + if err != nil || record == nil { + return e.JSON(http.StatusNotFound, map[string]any{"error": "Export nicht gefunden."}) + } + + status := record.GetString(dbmodels.EXPORT_STATUS_FIELD) + if status == dbmodels.EXPORT_STATUS_RUNNING || status == dbmodels.EXPORT_STATUS_QUEUED { + return e.JSON(http.StatusConflict, map[string]any{"error": "Export laeuft noch."}) + } + + exportDir, err := exports.ExportDir(app) + if err == nil { + filename := record.GetString(dbmodels.EXPORT_FILENAME_FIELD) + if filename == "" { + filename = record.Id + ".xml" + } + filename = filepath.Base(filename) + _ = os.Remove(filepath.Join(exportDir, filename)) + _ = os.Remove(filepath.Join(exportDir, filename+".tmp")) + } + + if err := app.Delete(record); err != nil { + return e.JSON(http.StatusInternalServerError, map[string]any{"error": err.Error()}) + } + + return e.JSON(http.StatusOK, map[string]any{"success": true, "message": "Export geloescht."}) + } +} + +func exportsData(e *core.RequestEvent, app core.App) (map[string]any, error) { + data := map[string]any{} + req := templating.NewRequest(e) + + exportsList, hasRunning, err := loadExports(app) + if err != nil { + return nil, err + } + + data["exports"] = exportsList + data["has_running"] = hasRunning + data["csrf_token"] = "" + if req.Session() != nil { + data["csrf_token"] = req.Session().Token + } + return data, nil +} + +func loadExports(app core.App) ([]exportView, bool, error) { + records := []*core.Record{} + err := app.RecordQuery(dbmodels.EXPORTS_TABLE). + OrderBy(dbmodels.CREATED_FIELD + " DESC"). + All(&records) + if err != nil { + return nil, false, err + } + + exportsList := make([]exportView, 0, len(records)) + hasRunning := false + for _, record := range records { + status := record.GetString(dbmodels.EXPORT_STATUS_FIELD) + if status == dbmodels.EXPORT_STATUS_RUNNING || status == dbmodels.EXPORT_STATUS_QUEUED { + hasRunning = true + } + exportType := record.GetString(dbmodels.EXPORT_TYPE_FIELD) + if exportType == "" { + exportType = dbmodels.EXPORT_TYPE_DATA + } + sizeBytes := int64(record.GetInt(dbmodels.EXPORT_SIZE_FIELD)) + exportsList = append(exportsList, exportView{ + Id: record.Id, + Name: record.GetString(dbmodels.EXPORT_NAME_FIELD), + Filename: record.GetString(dbmodels.EXPORT_FILENAME_FIELD), + Type: exportType, + Status: status, + Progress: record.GetInt(dbmodels.EXPORT_PROGRESS_FIELD), + TablesTotal: record.GetInt(dbmodels.EXPORT_TABLES_TOTAL_FIELD), + TablesDone: record.GetInt(dbmodels.EXPORT_TABLES_DONE_FIELD), + SizeBytes: sizeBytes, + SizeLabel: formatBytes(sizeBytes), + Created: record.GetDateTime(dbmodels.CREATED_FIELD), + Expires: record.GetDateTime(dbmodels.EXPORT_EXPIRES_FIELD), + CurrentTable: record.GetString(dbmodels.EXPORT_CURRENT_TABLE_FIELD), + Error: record.GetString(dbmodels.EXPORT_ERROR_FIELD), + }) + } + + return exportsList, hasRunning, nil +} + +func formatBytes(size int64) string { + if size <= 0 { + return "0 B" + } + units := []string{"B", "KB", "MB", "GB", "TB"} + value := float64(size) + unitIdx := 0 + for value >= 1024 && unitIdx < len(units)-1 { + value /= 1024 + unitIdx++ + } + if value >= 100 { + return fmt.Sprintf("%.0f %s", value, units[unitIdx]) + } + if value >= 10 { + return fmt.Sprintf("%.1f %s", value, units[unitIdx]) + } + return fmt.Sprintf("%.2f %s", value, units[unitIdx]) +} diff --git a/dbmodels/db_data.go b/dbmodels/db_data.go index 6eae388..f588cb9 100644 --- a/dbmodels/db_data.go +++ b/dbmodels/db_data.go @@ -444,6 +444,7 @@ const ( FILES_TABLE = "files" HTML_TABLE = "html" PAGES_TABLE = "pages" + EXPORTS_TABLE = "exports" ID_FIELD = "id" CREATED_FIELD = "created" @@ -499,7 +500,7 @@ const ( REFERENCES_FIELD = "refs" URI_FIELD = "uri" - URL_FIELD ="url" + URL_FIELD = "url" MUSENALM_BAENDE_STATUS_FIELD = "musenalm_status" MUSENALM_INHALTE_TYPE_FIELD = "musenalm_type" @@ -555,5 +556,18 @@ const ( LAYOUT_FIELD = "layout" TYPE_FIELD = "type" + EXPORT_NAME_FIELD = "name" + EXPORT_FILENAME_FIELD = "filename" + EXPORT_TYPE_FIELD = "export_type" + EXPORT_STATUS_FIELD = "status" + EXPORT_PROGRESS_FIELD = "progress" + EXPORT_TABLES_TOTAL_FIELD = "tables_total" + EXPORT_TABLES_DONE_FIELD = "tables_done" + EXPORT_SIZE_FIELD = "size_bytes" + EXPORT_CURRENT_TABLE_FIELD = "current_table" + EXPORT_ERROR_FIELD = "error" + EXPORT_EXPIRES_FIELD = "expires_at" + EXPORT_CREATED_BY_FIELD = "created_by" + SESSION_COOKIE_NAME = "sid" ) diff --git a/dbmodels/exports.go b/dbmodels/exports.go new file mode 100644 index 0000000..4fa118d --- /dev/null +++ b/dbmodels/exports.go @@ -0,0 +1,23 @@ +package dbmodels + +const ( + EXPORT_STATUS_QUEUED = "queued" + EXPORT_STATUS_RUNNING = "running" + EXPORT_STATUS_COMPLETE = "complete" + EXPORT_STATUS_FAILED = "failed" + + EXPORT_TYPE_DATA = "data" + EXPORT_TYPE_FILES = "files" +) + +var EXPORT_STATUS_VALUES = []string{ + EXPORT_STATUS_QUEUED, + EXPORT_STATUS_RUNNING, + EXPORT_STATUS_COMPLETE, + EXPORT_STATUS_FAILED, +} + +var EXPORT_TYPE_VALUES = []string{ + EXPORT_TYPE_DATA, + EXPORT_TYPE_FILES, +} diff --git a/helpers/exports/cleanup.go b/helpers/exports/cleanup.go new file mode 100644 index 0000000..0a2c101 --- /dev/null +++ b/helpers/exports/cleanup.go @@ -0,0 +1,67 @@ +package exports + +import ( + "os" + "path/filepath" + "sync" + "time" + + "github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" + "github.com/pocketbase/dbx" + "github.com/pocketbase/pocketbase/core" + "github.com/pocketbase/pocketbase/tools/types" +) + +var cleanupOnce sync.Once + +func StartCleanup(app core.App, interval time.Duration) { + if interval <= 0 { + interval = 12 * time.Hour + } + + cleanupOnce.Do(func() { + go func() { + CleanupExpired(app) + ticker := time.NewTicker(interval) + defer ticker.Stop() + for range ticker.C { + CleanupExpired(app) + } + }() + }) +} + +func CleanupExpired(app core.App) { + now := types.NowDateTime() + records := []*core.Record{} + err := app.RecordQuery(dbmodels.EXPORTS_TABLE). + Where(dbx.NewExp(dbmodels.EXPORT_EXPIRES_FIELD+" <= {:now}", dbx.Params{"now": now})). + All(&records) + if err != nil { + app.Logger().Error("Export cleanup query failed", "error", err) + return + } + + if len(records) == 0 { + return + } + + exportDir, err := ExportDir(app) + if err != nil { + app.Logger().Error("Export cleanup dir failed", "error", err) + return + } + + for _, record := range records { + filename := record.GetString(dbmodels.EXPORT_FILENAME_FIELD) + if filename == "" { + filename = record.Id + ".xml" + } + filename = filepath.Base(filename) + _ = os.Remove(filepath.Join(exportDir, filename)) + _ = os.Remove(filepath.Join(exportDir, filename+".tmp")) + if err := app.Delete(record); err != nil { + app.Logger().Error("Export cleanup delete failed", "error", err, "export_id", record.Id) + } + } +} diff --git a/helpers/exports/exporter.go b/helpers/exports/exporter.go new file mode 100644 index 0000000..bbf022f --- /dev/null +++ b/helpers/exports/exporter.go @@ -0,0 +1,302 @@ +package exports + +import ( + "archive/zip" + "encoding/xml" + "os" + "path/filepath" + "strings" + + "github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" + "github.com/pocketbase/dbx" + "github.com/pocketbase/pocketbase/core" +) + +const exportDirName = "exports" + +func ExportDir(app core.App) (string, error) { + base := filepath.Join(app.DataDir(), exportDirName) + if err := os.MkdirAll(base, 0o755); err != nil { + return "", err + } + return base, nil +} + +func ListTables(app core.App) ([]string, error) { + tables := []string{} + err := app.DB(). + NewQuery("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY name"). + Column(&tables) + if err != nil { + return nil, err + } + + excluded := map[string]struct{}{ + "_superusers": {}, + "_mfas": {}, + "_otps": {}, + "_externalAuths": {}, + "_authorigins": {}, + "_authOrigins": {}, + "access_tokens": {}, + } + + filtered := tables[:0] + for _, table := range tables { + if strings.HasPrefix(table, dbmodels.FTS5_PREFIX) { + continue + } + if _, ok := excluded[table]; ok { + continue + } + filtered = append(filtered, table) + } + return filtered, nil +} + +func Run(app core.App, exportID string) error { + record, err := app.FindRecordById(dbmodels.EXPORTS_TABLE, exportID) + if err != nil { + return err + } + + tables, err := ListTables(app) + if err != nil { + return markFailed(app, record, err) + } + + record.Set(dbmodels.EXPORT_STATUS_FIELD, dbmodels.EXPORT_STATUS_RUNNING) + record.Set(dbmodels.EXPORT_TABLES_TOTAL_FIELD, len(tables)) + record.Set(dbmodels.EXPORT_TABLES_DONE_FIELD, 0) + record.Set(dbmodels.EXPORT_PROGRESS_FIELD, 0) + record.Set(dbmodels.EXPORT_CURRENT_TABLE_FIELD, "") + record.Set(dbmodels.EXPORT_ERROR_FIELD, "") + if err := app.Save(record); err != nil { + return err + } + + exportDir, err := ExportDir(app) + if err != nil { + return markFailed(app, record, err) + } + + filename := exportID + ".zip" + tempPath := filepath.Join(exportDir, filename+".tmp") + finalPath := filepath.Join(exportDir, filename) + + file, err := os.Create(tempPath) + if err != nil { + return markFailed(app, record, err) + } + defer func() { + if file != nil { + _ = file.Close() + } + }() + + zipWriter := zip.NewWriter(file) + + for idx, table := range tables { + updateProgress(app, record, table, idx, len(tables)) + + if err := exportTableZipEntry(app, zipWriter, table); err != nil { + return markFailed(app, record, err) + } + + updateProgress(app, record, table, idx+1, len(tables)) + } + + if err := zipWriter.Close(); err != nil { + return markFailed(app, record, err) + } + if err := file.Close(); err != nil { + return markFailed(app, record, err) + } + file = nil + + if err := os.Rename(tempPath, finalPath); err != nil { + return markFailed(app, record, err) + } + + stat, err := os.Stat(finalPath) + if err != nil { + return markFailed(app, record, err) + } + + record.Set(dbmodels.EXPORT_STATUS_FIELD, dbmodels.EXPORT_STATUS_COMPLETE) + record.Set(dbmodels.EXPORT_PROGRESS_FIELD, 100) + record.Set(dbmodels.EXPORT_TABLES_DONE_FIELD, len(tables)) + record.Set(dbmodels.EXPORT_FILENAME_FIELD, filename) + record.Set(dbmodels.EXPORT_SIZE_FIELD, stat.Size()) + record.Set(dbmodels.EXPORT_CURRENT_TABLE_FIELD, "") + record.Set(dbmodels.EXPORT_ERROR_FIELD, "") + if err := app.Save(record); err != nil { + return err + } + + return nil +} + +func exportTableZipEntry(app core.App, zipWriter *zip.Writer, table string) error { + entryName := safeFilename(table) + if entryName == "" { + entryName = "table" + } + entryName += ".xml" + + entry, err := zipWriter.Create(entryName) + if err != nil { + return err + } + if _, err := entry.Write([]byte(xml.Header)); err != nil { + return err + } + + encoder := xml.NewEncoder(entry) + start := xml.StartElement{ + Name: xml.Name{Local: "table"}, + Attr: []xml.Attr{{Name: xml.Name{Local: "name"}, Value: table}}, + } + if err := encoder.EncodeToken(start); err != nil { + return err + } + + query := "SELECT * FROM " + quoteTableName(table) + rows, err := app.DB().NewQuery(query).Rows() + if err != nil { + return err + } + defer rows.Close() + + columns, err := rows.Columns() + if err != nil { + return err + } + + for rows.Next() { + rowData := dbx.NullStringMap{} + if err := rows.ScanMap(rowData); err != nil { + return err + } + + if err := encoder.EncodeToken(xml.StartElement{Name: xml.Name{Local: "row"}}); err != nil { + return err + } + + sensitiveFields := map[string]struct{}{} + if table == "users" { + sensitiveFields = map[string]struct{}{ + "password": {}, + "password_hash": {}, + "passwordhash": {}, + "tokenkey": {}, + "token_key": {}, + } + } + + for _, col := range columns { + lowerCol := strings.ToLower(col) + if _, ok := sensitiveFields[lowerCol]; ok { + if err := encoder.EncodeToken(xml.StartElement{Name: xml.Name{Local: col}, Attr: []xml.Attr{{Name: xml.Name{Local: "null"}, Value: "true"}}}); err != nil { + return err + } + if err := encoder.EncodeToken(xml.EndElement{Name: xml.Name{Local: col}}); err != nil { + return err + } + continue + } + + value := rowData[col] + attrs := []xml.Attr{} + if !value.Valid { + attrs = append(attrs, xml.Attr{Name: xml.Name{Local: "null"}, Value: "true"}) + } + + if err := encoder.EncodeToken(xml.StartElement{Name: xml.Name{Local: col}, Attr: attrs}); err != nil { + return err + } + if value.Valid { + if err := encoder.EncodeToken(xml.CharData([]byte(value.String))); err != nil { + return err + } + } + if err := encoder.EncodeToken(xml.EndElement{Name: xml.Name{Local: col}}); err != nil { + return err + } + } + + if err := encoder.EncodeToken(xml.EndElement{Name: xml.Name{Local: "row"}}); err != nil { + return err + } + } + + if err := rows.Err(); err != nil { + return err + } + + if err := encoder.EncodeToken(start.End()); err != nil { + return err + } + + return encoder.Flush() +} + +func updateProgress(app core.App, record *core.Record, table string, done, total int) { + progress := 0 + if total > 0 { + progress = int(float64(done) / float64(total) * 100) + } + record.Set(dbmodels.EXPORT_CURRENT_TABLE_FIELD, table) + record.Set(dbmodels.EXPORT_TABLES_DONE_FIELD, done) + record.Set(dbmodels.EXPORT_PROGRESS_FIELD, progress) + if err := app.Save(record); err != nil { + app.Logger().Error("Export progress update failed", "error", err, "export_id", record.Id) + } +} + +func markFailed(app core.App, record *core.Record, err error) error { + record.Set(dbmodels.EXPORT_STATUS_FIELD, dbmodels.EXPORT_STATUS_FAILED) + record.Set(dbmodels.EXPORT_ERROR_FIELD, err.Error()) + record.Set(dbmodels.EXPORT_CURRENT_TABLE_FIELD, "") + record.Set(dbmodels.EXPORT_PROGRESS_FIELD, 0) + if saveErr := app.Save(record); saveErr != nil { + return saveErr + } + + exportDir, dirErr := ExportDir(app) + if dirErr == nil { + filename := record.GetString(dbmodels.EXPORT_FILENAME_FIELD) + if filename == "" { + filename = record.Id + ".zip" + } + filename = filepath.Base(filename) + _ = os.Remove(filepath.Join(exportDir, filename)) + _ = os.Remove(filepath.Join(exportDir, filename+".tmp")) + } + + return err +} + +func quoteTableName(name string) string { + return "`" + strings.ReplaceAll(name, "`", "``") + "`" +} + +func safeFilename(name string) string { + name = strings.TrimSpace(name) + if name == "" { + return "" + } + var b strings.Builder + b.Grow(len(name)) + for _, r := range name { + if (r >= 'a' && r <= 'z') || + (r >= 'A' && r <= 'Z') || + (r >= '0' && r <= '9') || + r == '_' || r == '-' || r == '.' { + b.WriteRune(r) + } else { + b.WriteByte('_') + } + } + return b.String() +} diff --git a/helpers/exports/file_exporter.go b/helpers/exports/file_exporter.go new file mode 100644 index 0000000..2b6123b --- /dev/null +++ b/helpers/exports/file_exporter.go @@ -0,0 +1,254 @@ +package exports + +import ( + "archive/zip" + "encoding/json" + "fmt" + "io" + "os" + "path/filepath" + "strings" + "time" + + "github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" + "github.com/pocketbase/pocketbase/core" +) + +type fileEntry struct { + CollectionName string + CollectionId string + RecordId string + FieldName string + Filename string +} + +func RunFiles(app core.App, exportID string) error { + record, err := app.FindRecordById(dbmodels.EXPORTS_TABLE, exportID) + if err != nil { + return err + } + + files, err := collectFileEntries(app) + if err != nil { + return markFailed(app, record, err) + } + + record.Set(dbmodels.EXPORT_STATUS_FIELD, dbmodels.EXPORT_STATUS_RUNNING) + record.Set(dbmodels.EXPORT_TABLES_TOTAL_FIELD, len(files)) + record.Set(dbmodels.EXPORT_TABLES_DONE_FIELD, 0) + record.Set(dbmodels.EXPORT_PROGRESS_FIELD, 0) + record.Set(dbmodels.EXPORT_CURRENT_TABLE_FIELD, "") + record.Set(dbmodels.EXPORT_ERROR_FIELD, "") + record.Set(dbmodels.EXPORT_FILENAME_FIELD, exportID+"-files.zip") + if err := app.Save(record); err != nil { + return err + } + + exportDir, err := ExportDir(app) + if err != nil { + return markFailed(app, record, err) + } + + filename := exportID + "-files.zip" + tempPath := filepath.Join(exportDir, filename+".tmp") + finalPath := filepath.Join(exportDir, filename) + + file, err := os.Create(tempPath) + if err != nil { + return markFailed(app, record, err) + } + defer func() { + if file != nil { + _ = file.Close() + } + }() + + zipWriter := zip.NewWriter(file) + + missing := 0 + lastProgressSave := time.Now() + for idx, entry := range files { + label := entry.CollectionName + "/" + entry.RecordId + "/" + entry.Filename + if shouldUpdateProgress(idx, len(files), lastProgressSave) { + updateProgress(app, record, label, idx, len(files)) + lastProgressSave = time.Now() + } + + if err := addFileToZip(app, zipWriter, entry); err != nil { + if os.IsNotExist(err) { + missing++ + continue + } + return markFailed(app, record, err) + } + + if shouldUpdateProgress(idx+1, len(files), lastProgressSave) { + updateProgress(app, record, label, idx+1, len(files)) + lastProgressSave = time.Now() + } + } + + if err := zipWriter.Close(); err != nil { + return markFailed(app, record, err) + } + if err := file.Close(); err != nil { + return markFailed(app, record, err) + } + file = nil + + if err := os.Rename(tempPath, finalPath); err != nil { + return markFailed(app, record, err) + } + + stat, err := os.Stat(finalPath) + if err != nil { + return markFailed(app, record, err) + } + + record.Set(dbmodels.EXPORT_STATUS_FIELD, dbmodels.EXPORT_STATUS_COMPLETE) + record.Set(dbmodels.EXPORT_PROGRESS_FIELD, 100) + record.Set(dbmodels.EXPORT_TABLES_DONE_FIELD, len(files)) + record.Set(dbmodels.EXPORT_FILENAME_FIELD, filename) + record.Set(dbmodels.EXPORT_SIZE_FIELD, stat.Size()) + record.Set(dbmodels.EXPORT_CURRENT_TABLE_FIELD, "") + if missing > 0 { + record.Set(dbmodels.EXPORT_ERROR_FIELD, fmt.Sprintf("%d Datei(en) fehlen im Speicher.", missing)) + } else { + record.Set(dbmodels.EXPORT_ERROR_FIELD, "") + } + if err := app.Save(record); err != nil { + return err + } + + return nil +} + +func collectFileEntries(app core.App) ([]fileEntry, error) { + collections, err := app.FindAllCollections() + if err != nil { + return nil, err + } + + entries := make([]fileEntry, 0) + seen := make(map[string]struct{}) + + for _, collection := range collections { + if collection == nil || collection.IsView() { + continue + } + if strings.HasPrefix(collection.Name, "_") { + continue + } + + fileFields := make([]string, 0) + for _, field := range collection.Fields { + if field.Type() == core.FieldTypeFile { + fileFields = append(fileFields, field.GetName()) + } + } + if len(fileFields) == 0 { + continue + } + + records := []*core.Record{} + if err := app.RecordQuery(collection.Name).All(&records); err != nil { + return nil, err + } + + for _, record := range records { + if record == nil { + continue + } + for _, fieldName := range fileFields { + raw := record.GetRaw(fieldName) + for _, filename := range extractFileNames(raw) { + if filename == "" { + continue + } + key := collection.Id + "|" + record.Id + "|" + filename + if _, ok := seen[key]; ok { + continue + } + seen[key] = struct{}{} + entries = append(entries, fileEntry{ + CollectionName: collection.Name, + CollectionId: collection.Id, + RecordId: record.Id, + FieldName: fieldName, + Filename: filename, + }) + } + } + } + } + + return entries, nil +} + +func extractFileNames(raw any) []string { + switch value := raw.(type) { + case nil: + return nil + case string: + v := strings.TrimSpace(value) + if v == "" { + return nil + } + if strings.HasPrefix(v, "[") { + var list []string + if err := json.Unmarshal([]byte(v), &list); err == nil { + return list + } + } + return []string{v} + case []string: + return value + case []any: + out := make([]string, 0, len(value)) + for _, item := range value { + if s, ok := item.(string); ok { + out = append(out, s) + } + } + return out + case []byte: + var list []string + if err := json.Unmarshal(value, &list); err == nil { + return list + } + } + return nil +} + +func addFileToZip(app core.App, zipWriter *zip.Writer, entry fileEntry) error { + root := filepath.Join(app.DataDir(), "storage") + sourcePath := filepath.Join(root, entry.CollectionId, entry.RecordId, entry.Filename) + + reader, err := os.Open(sourcePath) + if err != nil { + return err + } + defer reader.Close() + + zipPath := entry.CollectionName + "/" + entry.RecordId + "/" + entry.Filename + zipEntry, err := zipWriter.Create(zipPath) + if err != nil { + return err + } + + _, err = io.Copy(zipEntry, reader) + return err +} + +func shouldUpdateProgress(done, total int, lastSave time.Time) bool { + if total == 0 { + return true + } + if done == 0 || done >= total { + return true + } + if done%200 == 0 { + return true + } + return time.Since(lastSave) > 2*time.Second +} diff --git a/migrations/1769000000_exports.go b/migrations/1769000000_exports.go new file mode 100644 index 0000000..8f6264b --- /dev/null +++ b/migrations/1769000000_exports.go @@ -0,0 +1,99 @@ +package migrations + +import ( + "strings" + + "github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" + "github.com/pocketbase/pocketbase/core" + m "github.com/pocketbase/pocketbase/migrations" +) + +func init() { + m.Register(func(app core.App) error { + usersCollection, err := app.FindCollectionByNameOrId(dbmodels.USERS_TABLE) + if err != nil { + app.Logger().Error("Failed to find users collection for exports migration", "error", err) + return err + } + + collection := core.NewBaseCollection(dbmodels.EXPORTS_TABLE) + fields := exportsFields(usersCollection.Id) + dbmodels.SetCreatedUpdatedFields(&fields) + collection.Fields = fields + + dbmodels.AddIndex(collection, dbmodels.EXPORT_STATUS_FIELD, false) + dbmodels.AddIndex(collection, dbmodels.EXPORT_EXPIRES_FIELD, false) + dbmodels.AddIndex(collection, dbmodels.EXPORT_CREATED_BY_FIELD, false) + + return app.Save(collection) + }, func(app core.App) error { + collection, err := app.FindCollectionByNameOrId(dbmodels.EXPORTS_TABLE) + if err != nil { + if strings.Contains(err.Error(), "not found") || strings.Contains(err.Error(), "no rows in result set") { + return nil + } + app.Logger().Error("Failed to find collection for deletion", "collection", dbmodels.EXPORTS_TABLE, "error", err) + return err + } + + return app.Delete(collection) + }) +} + +func exportsFields(usersCollectionId string) core.FieldsList { + fields := core.NewFieldsList( + &core.TextField{ + Name: dbmodels.EXPORT_NAME_FIELD, + Required: true, + Presentable: true, + }, + &core.TextField{ + Name: dbmodels.EXPORT_FILENAME_FIELD, + Presentable: true, + }, + &core.SelectField{ + Name: dbmodels.EXPORT_STATUS_FIELD, + Required: true, + Presentable: true, + MaxSelect: 1, + Values: dbmodels.EXPORT_STATUS_VALUES, + }, + &core.NumberField{ + Name: dbmodels.EXPORT_PROGRESS_FIELD, + Presentable: true, + }, + &core.NumberField{ + Name: dbmodels.EXPORT_TABLES_TOTAL_FIELD, + Presentable: true, + }, + &core.NumberField{ + Name: dbmodels.EXPORT_TABLES_DONE_FIELD, + Presentable: true, + }, + &core.NumberField{ + Name: dbmodels.EXPORT_SIZE_FIELD, + Presentable: true, + }, + &core.TextField{ + Name: dbmodels.EXPORT_CURRENT_TABLE_FIELD, + Presentable: true, + }, + &core.TextField{ + Name: dbmodels.EXPORT_ERROR_FIELD, + Presentable: true, + }, + &core.DateField{ + Name: dbmodels.EXPORT_EXPIRES_FIELD, + Presentable: true, + }, + &core.RelationField{ + Name: dbmodels.EXPORT_CREATED_BY_FIELD, + CollectionId: usersCollectionId, + MaxSelect: 1, + CascadeDelete: true, + Presentable: true, + }, + ) + + return fields +} diff --git a/migrations/1769000001_exports_type.go b/migrations/1769000001_exports_type.go new file mode 100644 index 0000000..8f791b4 --- /dev/null +++ b/migrations/1769000001_exports_type.go @@ -0,0 +1,41 @@ +package migrations + +import ( + "strings" + + "github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" + "github.com/pocketbase/pocketbase/core" + m "github.com/pocketbase/pocketbase/migrations" +) + +func init() { + m.Register(func(app core.App) error { + collection, err := app.FindCollectionByNameOrId(dbmodels.EXPORTS_TABLE) + if err != nil { + app.Logger().Error("Failed to find exports collection for type migration", "error", err) + return err + } + + field := &core.SelectField{ + Name: dbmodels.EXPORT_TYPE_FIELD, + Presentable: true, + MaxSelect: 1, + Values: dbmodels.EXPORT_TYPE_VALUES, + } + + collection.Fields.Add(field) + return app.Save(collection) + }, func(app core.App) error { + collection, err := app.FindCollectionByNameOrId(dbmodels.EXPORTS_TABLE) + if err != nil { + if strings.Contains(err.Error(), "not found") || strings.Contains(err.Error(), "no rows in result set") { + return nil + } + app.Logger().Error("Failed to find exports collection for type rollback", "error", err) + return err + } + + collection.Fields.RemoveByName(dbmodels.EXPORT_TYPE_FIELD) + return app.Save(collection) + }) +} diff --git a/templating/request.go b/templating/request.go index fcbe374..0e65c80 100644 --- a/templating/request.go +++ b/templating/request.go @@ -2,6 +2,7 @@ package templating import ( "fmt" + "strings" "github.com/Theodor-Springmann-Stiftung/musenalm/dbmodels" "github.com/pocketbase/pocketbase/core" @@ -87,7 +88,11 @@ func (r *Request) IsEditor() bool { } func (r *Request) CheckCSRF(target string) error { - if r.Session() == nil || target == "" || r.Session().Token != target { + target = strings.TrimSpace(target) + if r.Session() == nil || target == "" { + return fmt.Errorf("CSRF-Token nicht vorhanden oder ungültig") + } + if r.Session().Token != target && r.Session().CSRF != target { return fmt.Errorf("CSRF-Token nicht vorhanden oder ungültig") } return nil diff --git a/views/assets/scripts.js b/views/assets/scripts.js index 5a0b61e..dd31181 100644 --- a/views/assets/scripts.js +++ b/views/assets/scripts.js @@ -1,15 +1,22 @@ -var Pa = "2.1.16"; -const Bt = "[data-trix-attachment]", Sn = { preview: { presentation: "gallery", caption: { name: !0, size: !0 } }, file: { caption: { size: !0 } } }, X = { default: { tagName: "div", parse: !1 }, quote: { tagName: "blockquote", nestable: !0 }, heading1: { tagName: "h1", terminal: !0, breakOnReturn: !0, group: !1 }, code: { tagName: "pre", terminal: !0, htmlAttributes: ["language"], text: { plaintext: !0 } }, bulletList: { tagName: "ul", parse: !1 }, bullet: { tagName: "li", listAttribute: "bulletList", group: !1, nestable: !0, test(s) { - return ss(s.parentNode) === X[this.listAttribute].tagName; +var Za = Object.defineProperty; +var fs = (s) => { + throw TypeError(s); +}; +var to = (s, t, e) => t in s ? Za(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e; +var Xt = (s, t, e) => to(s, typeof t != "symbol" ? t + "" : t, e), Oi = (s, t, e) => t.has(s) || fs("Cannot " + e); +var Bi = (s, t, e) => (Oi(s, t, "read from private field"), e ? e.call(s) : t.get(s)), he = (s, t, e) => t.has(s) ? fs("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(s) : t.set(s, e), Ve = (s, t, e, i) => (Oi(s, t, "write to private field"), i ? i.call(s, e) : t.set(s, e), e), je = (s, t, e) => (Oi(s, t, "access private method"), e); +var eo = "2.1.16"; +const Mt = "[data-trix-attachment]", Pn = { preview: { presentation: "gallery", caption: { name: !0, size: !0 } }, file: { caption: { size: !0 } } }, X = { default: { tagName: "div", parse: !1 }, quote: { tagName: "blockquote", nestable: !0 }, heading1: { tagName: "h1", terminal: !0, breakOnReturn: !0, group: !1 }, code: { tagName: "pre", terminal: !0, htmlAttributes: ["language"], text: { plaintext: !0 } }, bulletList: { tagName: "ul", parse: !1 }, bullet: { tagName: "li", listAttribute: "bulletList", group: !1, nestable: !0, test(s) { + return bs(s.parentNode) === X[this.listAttribute].tagName; } }, numberList: { tagName: "ol", parse: !1 }, number: { tagName: "li", listAttribute: "numberList", group: !1, nestable: !0, test(s) { - return ss(s.parentNode) === X[this.listAttribute].tagName; -} }, attachmentGallery: { tagName: "div", exclusive: !0, terminal: !0, parse: !1, group: !1 } }, ss = (s) => { + return bs(s.parentNode) === X[this.listAttribute].tagName; +} }, attachmentGallery: { tagName: "div", exclusive: !0, terminal: !0, parse: !1, group: !1 } }, bs = (s) => { var t; return s == null || (t = s.tagName) === null || t === void 0 ? void 0 : t.toLowerCase(); -}, rs = navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i), Si = rs && parseInt(rs[1]); -var Te = { composesExistingText: /Android.*Chrome/.test(navigator.userAgent), recentAndroid: Si && Si > 12, samsungAndroid: Si && navigator.userAgent.match(/Android.*SM-/), forcesObjectResizing: /Trident.*rv:11/.test(navigator.userAgent), supportsInputEvents: typeof InputEvent < "u" && ["data", "getTargetRanges", "inputType"].every(((s) => s in InputEvent.prototype)) }, Mr = { ADD_ATTR: ["language"], SAFE_FOR_XML: !1, RETURN_DOM: !0 }, v = { attachFiles: "Attach Files", bold: "Bold", bullets: "Bullets", byte: "Byte", bytes: "Bytes", captionPlaceholder: "Add a caption…", code: "Code", heading1: "Heading", indent: "Increase Level", italic: "Italic", link: "Link", numbers: "Numbers", outdent: "Decrease Level", quote: "Quote", redo: "Redo", remove: "Remove", strike: "Strikethrough", undo: "Undo", unlink: "Unlink", url: "URL", urlPlaceholder: "Enter a URL…", GB: "GB", KB: "KB", MB: "MB", PB: "PB", TB: "TB" }; -const Fa = [v.bytes, v.KB, v.MB, v.GB, v.TB, v.PB]; -var Nr = { prefix: "IEC", precision: 2, formatter(s) { +}, _s = navigator.userAgent.match(/android\s([0-9]+.*Chrome)/i), Mi = _s && parseInt(_s[1]); +var Oe = { composesExistingText: /Android.*Chrome/.test(navigator.userAgent), recentAndroid: Mi && Mi > 12, samsungAndroid: Mi && navigator.userAgent.match(/Android.*SM-/), forcesObjectResizing: /Trident.*rv:11/.test(navigator.userAgent), supportsInputEvents: typeof InputEvent < "u" && ["data", "getTargetRanges", "inputType"].every((s) => s in InputEvent.prototype) }, Gr = { ADD_ATTR: ["language"], SAFE_FOR_XML: !1, RETURN_DOM: !0 }, v = { attachFiles: "Attach Files", bold: "Bold", bullets: "Bullets", byte: "Byte", bytes: "Bytes", captionPlaceholder: "Add a caption…", code: "Code", heading1: "Heading", indent: "Increase Level", italic: "Italic", link: "Link", numbers: "Numbers", outdent: "Decrease Level", quote: "Quote", redo: "Redo", remove: "Remove", strike: "Strikethrough", undo: "Undo", unlink: "Unlink", url: "URL", urlPlaceholder: "Enter a URL…", GB: "GB", KB: "KB", MB: "MB", PB: "PB", TB: "TB" }; +const io = [v.bytes, v.KB, v.MB, v.GB, v.TB, v.PB]; +var Jr = { prefix: "IEC", precision: 2, formatter(s) { switch (s) { case 0: return "0 ".concat(v.bytes); @@ -19,34 +26,34 @@ var Nr = { prefix: "IEC", precision: 2, formatter(s) { let t; this.prefix === "SI" ? t = 1e3 : this.prefix === "IEC" && (t = 1024); const e = Math.floor(Math.log(s) / Math.log(t)), i = (s / Math.pow(t, e)).toFixed(this.precision).replace(/0*$/, "").replace(/\.$/, ""); - return "".concat(i, " ").concat(Fa[e]); + return "".concat(i, " ").concat(io[e]); } } }; -const ni = "\uFEFF", St = " ", Pr = function(s) { +const ui = "\uFEFF", St = " ", Yr = function(s) { for (const t in s) { const e = s[t]; this[t] = e; } return this; -}, Ln = document.documentElement, Ha = Ln.matches, B = function(s) { +}, Fn = document.documentElement, no = Fn.matches, B = function(s) { let { onElement: t, matchingSelector: e, withCallback: i, inPhase: n, preventDefault: r, times: a } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - const o = t || Ln, l = e, c = n === "capturing", u = function(m) { + const o = t || Fn, l = e, c = n === "capturing", u = function(m) { a != null && --a == 0 && u.destroy(); const p = Lt(m.target, { matchingSelector: l }); - p != null && (i?.call(p, m, p), r && m.preventDefault()); + p != null && (i == null || i.call(p, m, p), r && m.preventDefault()); }; return u.destroy = () => o.removeEventListener(s, u, c), o.addEventListener(s, u, c), u; -}, Fr = function(s) { +}, Xr = function(s) { let { bubbles: t, cancelable: e, attributes: i } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; t = t !== !1, e = e !== !1; const n = document.createEvent("Events"); - return n.initEvent(s, t, e), i != null && Pr.call(n, i), n; -}, be = function(s) { + return n.initEvent(s, t, e), i != null && Yr.call(n, i), n; +}, Ae = function(s) { let { onElement: t, bubbles: e, cancelable: i, attributes: n } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - const r = t ?? Ln, a = Fr(s, { bubbles: e, cancelable: i, attributes: n }); + const r = t ?? Fn, a = Xr(s, { bubbles: e, cancelable: i, attributes: n }); return r.dispatchEvent(a); -}, Hr = function(s, t) { - if (s?.nodeType === 1) return Ha.call(s, t); +}, Qr = function(s, t) { + if ((s == null ? void 0 : s.nodeType) === 1) return no.call(s, t); }, Lt = function(s) { let { matchingSelector: t, untilNode: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; for (; s && s.nodeType !== Node.ELEMENT_NODE; ) s = s.parentNode; @@ -54,16 +61,16 @@ const ni = "\uFEFF", St = " ", Pr = function(s) { if (t == null) return s; if (s.closest && e == null) return s.closest(t); for (; s && s !== e; ) { - if (Hr(s, t)) return s; + if (Qr(s, t)) return s; s = s.parentNode; } } -}, Cn = (s) => document.activeElement !== s && Ot(s, document.activeElement), Ot = function(s, t) { +}, Hn = (s) => document.activeElement !== s && Ot(s, document.activeElement), Ot = function(s, t) { if (s && t) for (; t; ) { if (t === s) return !0; t = t.parentNode; } -}, Li = function(s) { +}, Ni = function(s) { var t; if ((t = s) === null || t === void 0 || !t.parentNode) return; let e = 0; @@ -72,7 +79,7 @@ const ni = "\uFEFF", St = " ", Pr = function(s) { }, Ct = (s) => { var t; return s == null || (t = s.parentNode) === null || t === void 0 ? void 0 : t.removeChild(s); -}, Qe = function(s) { +}, ri = function(s) { let { onlyNodesOfType: t, usingFilter: e, expandEntityReferences: i } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; const n = (() => { switch (t) { @@ -97,45 +104,45 @@ const ni = "\uFEFF", St = " ", Pr = function(s) { if (i.editable != null && (i.attributes == null && (i.attributes = {}), i.attributes.contenteditable = i.editable), i.attributes) for (t in i.attributes) e = i.attributes[t], n.setAttribute(t, e); if (i.style) for (t in i.style) e = i.style[t], n.style[t] = e; if (i.data) for (t in i.data) e = i.data[t], n.dataset[t] = e; - return i.className && i.className.split(" ").forEach(((r) => { + return i.className && i.className.split(" ").forEach((r) => { n.classList.add(r); - })), i.textContent && (n.textContent = i.textContent), i.childNodes && [].concat(i.childNodes).forEach(((r) => { + }), i.textContent && (n.textContent = i.textContent), i.childNodes && [].concat(i.childNodes).forEach((r) => { n.appendChild(r); - })), n; + }), n; }; -let le; -const _e = function() { - if (le != null) return le; - le = []; +let ue; +const Ee = function() { + if (ue != null) return ue; + ue = []; for (const s in X) { const t = X[s]; - t.tagName && le.push(t.tagName); + t.tagName && ue.push(t.tagName); } - return le; -}, Ci = (s) => Zt(s?.firstChild), as = function(s) { + return ue; +}, Pi = (s) => ee(s == null ? void 0 : s.firstChild), vs = function(s) { let { strict: t } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { strict: !0 }; - return t ? Zt(s) : Zt(s) || !Zt(s.firstChild) && (function(e) { - return _e().includes(Y(e)) && !_e().includes(Y(e.firstChild)); - })(s); -}, Zt = (s) => qa(s) && s?.data === "block", qa = (s) => s?.nodeType === Node.COMMENT_NODE, te = function(s) { + return t ? ee(s) : ee(s) || !ee(s.firstChild) && function(e) { + return Ee().includes(Y(e)) && !Ee().includes(Y(e.firstChild)); + }(s); +}, ee = (s) => so(s) && (s == null ? void 0 : s.data) === "block", so = (s) => (s == null ? void 0 : s.nodeType) === Node.COMMENT_NODE, ie = function(s) { let { name: t } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - if (s) return ve(s) ? s.data === ni ? !t || s.parentNode.dataset.trixCursorTarget === t : void 0 : te(s.firstChild); -}, Mt = (s) => Hr(s, Bt), qr = (s) => ve(s) && s?.data === "", ve = (s) => s?.nodeType === Node.TEXT_NODE, wn = { level2Enabled: !0, getLevel() { - return this.level2Enabled && Te.supportsInputEvents ? 2 : 0; + if (s) return xe(s) ? s.data === ui ? !t || s.parentNode.dataset.trixCursorTarget === t : void 0 : ie(s.firstChild); +}, Nt = (s) => Qr(s, Mt), Zr = (s) => xe(s) && (s == null ? void 0 : s.data) === "", xe = (s) => (s == null ? void 0 : s.nodeType) === Node.TEXT_NODE, qn = { level2Enabled: !0, getLevel() { + return this.level2Enabled && Oe.supportsInputEvents ? 2 : 0; }, pickFiles(s) { const t = x("input", { type: "file", multiple: !0, hidden: !0, id: this.fileInputId }); - t.addEventListener("change", (() => { + t.addEventListener("change", () => { s(t.files), Ct(t); - })), Ct(document.getElementById(this.fileInputId)), document.body.appendChild(t), t.click(); + }), Ct(document.getElementById(this.fileInputId)), document.body.appendChild(t), t.click(); } }; -var Je = { removeBlankTableCells: !1, tableCellSeparator: " | ", tableRowSeparator: ` -` }, Pt = { bold: { tagName: "strong", inheritable: !0, parser(s) { +var ii = { removeBlankTableCells: !1, tableCellSeparator: " | ", tableRowSeparator: ` +` }, Ft = { bold: { tagName: "strong", inheritable: !0, parser(s) { const t = window.getComputedStyle(s); return t.fontWeight === "bold" || t.fontWeight >= 600; } }, italic: { tagName: "em", inheritable: !0, parser: (s) => window.getComputedStyle(s).fontStyle === "italic" }, href: { groupTagName: "a", parser(s) { - const t = "a:not(".concat(Bt, ")"), e = s.closest(t); + const t = "a:not(".concat(Mt, ")"), e = s.closest(t); if (e) return e.getAttribute("href"); -} }, strike: { tagName: "del", inheritable: !0 }, frozen: { style: { backgroundColor: "highlight" } } }, $r = { getDefaultHTML: () => `
+} }, strike: { tagName: "del", inheritable: !0 }, frozen: { style: { backgroundColor: "highlight" } } }, ta = { getDefaultHTML: () => `
@@ -176,44 +183,44 @@ var Je = { removeBlankTableCells: !1, tableCellSeparator: " | ", tableRowSeparat
`) }; -const cn = { interval: 5e3 }; -var ke = Object.freeze({ __proto__: null, attachments: Sn, blockAttributes: X, browser: Te, css: { attachment: "attachment", attachmentCaption: "attachment__caption", attachmentCaptionEditor: "attachment__caption-editor", attachmentMetadata: "attachment__metadata", attachmentMetadataContainer: "attachment__metadata-container", attachmentName: "attachment__name", attachmentProgress: "attachment__progress", attachmentSize: "attachment__size", attachmentToolbar: "attachment__toolbar", attachmentGallery: "attachment-gallery" }, dompurify: Mr, fileSize: Nr, input: wn, keyNames: { 8: "backspace", 9: "tab", 13: "return", 27: "escape", 37: "left", 39: "right", 46: "delete", 68: "d", 72: "h", 79: "o" }, lang: v, parser: Je, textAttributes: Pt, toolbar: $r, undo: cn }); -class H { +const An = { interval: 5e3 }; +var Be = Object.freeze({ __proto__: null, attachments: Pn, blockAttributes: X, browser: Oe, css: { attachment: "attachment", attachmentCaption: "attachment__caption", attachmentCaptionEditor: "attachment__caption-editor", attachmentMetadata: "attachment__metadata", attachmentMetadataContainer: "attachment__metadata-container", attachmentName: "attachment__name", attachmentProgress: "attachment__progress", attachmentSize: "attachment__size", attachmentToolbar: "attachment__toolbar", attachmentGallery: "attachment-gallery" }, dompurify: Gr, fileSize: Jr, input: qn, keyNames: { 8: "backspace", 9: "tab", 13: "return", 27: "escape", 37: "left", 39: "right", 46: "delete", 68: "d", 72: "h", 79: "o" }, lang: v, parser: ii, textAttributes: Ft, toolbar: ta, undo: An }); +class q { static proxyMethod(t) { - const { name: e, toMethod: i, toProperty: n, optional: r } = $a(t); + const { name: e, toMethod: i, toProperty: n, optional: r } = ro(t); this.prototype[e] = function() { let a, o; var l, c; - return i ? o = r ? (l = this[i]) === null || l === void 0 ? void 0 : l.call(this) : this[i]() : n && (o = this[n]), r ? (a = (c = o) === null || c === void 0 ? void 0 : c[e], a ? os.call(a, o, arguments) : void 0) : (a = o[e], os.call(a, o, arguments)); + return i ? o = r ? (l = this[i]) === null || l === void 0 ? void 0 : l.call(this) : this[i]() : n && (o = this[n]), r ? (a = (c = o) === null || c === void 0 ? void 0 : c[e], a ? ys.call(a, o, arguments) : void 0) : (a = o[e], ys.call(a, o, arguments)); }; } } -const $a = function(s) { - const t = s.match(Ua); +const ro = function(s) { + const t = s.match(ao); if (!t) throw new Error("can't parse @proxyMethod expression: ".concat(s)); const e = { name: t[4] }; return t[2] != null ? e.toMethod = t[1] : e.toProperty = t[1], t[3] != null && (e.optional = !0), e; -}, { apply: os } = Function.prototype, Ua = new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$"); -var wi, Ti, ki; -class Le extends H { +}, { apply: ys } = Function.prototype, ao = new RegExp("^(.+?)(\\(\\))?(\\?)?\\.(.+?)$"); +var Fi, Hi, qi; +class ke extends q { static box() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; - return t instanceof this ? t : this.fromUCS2String(t?.toString()); + return t instanceof this ? t : this.fromUCS2String(t == null ? void 0 : t.toString()); } static fromUCS2String(t) { - return new this(t, hn(t)); + return new this(t, En(t)); } static fromCodepoints(t) { - return new this(un(t), t); + return new this(xn(t), t); } constructor(t, e) { super(...arguments), this.ucs2String = t, this.codepoints = e, this.length = this.codepoints.length, this.ucs2Length = this.ucs2String.length; } offsetToUCS2Offset(t) { - return un(this.codepoints.slice(0, Math.max(0, t))).length; + return xn(this.codepoints.slice(0, Math.max(0, t))).length; } offsetFromUCS2Offset(t) { - return hn(this.ucs2String.slice(0, Math.max(0, t))).length; + return En(this.ucs2String.slice(0, Math.max(0, t))).length; } slice() { return this.constructor.fromCodepoints(this.codepoints.slice(...arguments)); @@ -234,9 +241,9 @@ class Le extends H { return this.ucs2String; } } -const Va = ((wi = Array.from) === null || wi === void 0 ? void 0 : wi.call(Array, "👼").length) === 1, ja = ((Ti = " ".codePointAt) === null || Ti === void 0 ? void 0 : Ti.call(" ", 0)) != null, Wa = ((ki = String.fromCodePoint) === null || ki === void 0 ? void 0 : ki.call(String, 32, 128124)) === " 👼"; -let hn, un; -hn = Va && ja ? (s) => Array.from(s).map(((t) => t.codePointAt(0))) : function(s) { +const oo = ((Fi = Array.from) === null || Fi === void 0 ? void 0 : Fi.call(Array, "👼").length) === 1, lo = ((Hi = " ".codePointAt) === null || Hi === void 0 ? void 0 : Hi.call(" ", 0)) != null, co = ((qi = String.fromCodePoint) === null || qi === void 0 ? void 0 : qi.call(String, 32, 128124)) === " 👼"; +let En, xn; +En = oo && lo ? (s) => Array.from(s).map((t) => t.codePointAt(0)) : function(s) { const t = []; let e = 0; const { length: i } = s; @@ -249,25 +256,25 @@ hn = Va && ja ? (s) => Array.from(s).map(((t) => t.codePointAt(0))) : function(s t.push(n); } return t; -}, un = Wa ? (s) => String.fromCodePoint(...Array.from(s || [])) : function(s) { +}, xn = co ? (s) => String.fromCodePoint(...Array.from(s || [])) : function(s) { return (() => { const t = []; - return Array.from(s).forEach(((e) => { + return Array.from(s).forEach((e) => { let i = ""; e > 65535 && (e -= 65536, i += String.fromCharCode(e >>> 10 & 1023 | 55296), e = 56320 | 1023 & e), t.push(i + String.fromCharCode(e)); - })), t; + }), t; })().join(""); }; -let za = 0; -class qt extends H { +let ho = 0; +class $t extends q { static fromJSONString(t) { return this.fromJSON(JSON.parse(t)); } constructor() { - super(...arguments), this.id = ++za; + super(...arguments), this.id = ++ho; } hasSameConstructorAs(t) { - return this.constructor === t?.constructor; + return this.constructor === (t == null ? void 0 : t.constructor); } isEqualTo(t) { return this === t; @@ -286,69 +293,69 @@ class qt extends H { return JSON.stringify(this); } toUTF16String() { - return Le.box(this); + return ke.box(this); } getCacheKey() { return this.id.toString(); } } -const Ft = function() { +const Ht = function() { let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; if (s.length !== t.length) return !1; for (let e = 0; e < s.length; e++) if (s[e] !== t[e]) return !1; return !0; -}, Tn = function(s) { +}, $n = function(s) { const t = s.slice(0); for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), n = 1; n < e; n++) i[n - 1] = arguments[n]; return t.splice(...i), t; -}, Ka = /[\u05BE\u05C0\u05C3\u05D0-\u05EA\u05F0-\u05F4\u061B\u061F\u0621-\u063A\u0640-\u064A\u066D\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D5\u06E5\u06E6\u200F\u202B\u202E\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE72\uFE74\uFE76-\uFEFC]/, Ga = (function() { +}, uo = /[\u05BE\u05C0\u05C3\u05D0-\u05EA\u05F0-\u05F4\u061B\u061F\u0621-\u063A\u0640-\u064A\u066D\u0671-\u06B7\u06BA-\u06BE\u06C0-\u06CE\u06D0-\u06D5\u06E5\u06E6\u200F\u202B\u202E\uFB1F-\uFB28\uFB2A-\uFB36\uFB38-\uFB3C\uFB3E\uFB40\uFB41\uFB43\uFB44\uFB46-\uFBB1\uFBD3-\uFD3D\uFD50-\uFD8F\uFD92-\uFDC7\uFDF0-\uFDFB\uFE70-\uFE72\uFE74\uFE76-\uFEFC]/, mo = function() { const s = x("input", { dir: "auto", name: "x", dirName: "x.dir" }), t = x("textarea", { dir: "auto", name: "y", dirName: "y.dir" }), e = x("form"); e.appendChild(s), e.appendChild(t); - const i = (function() { + const i = function() { try { return new FormData(e).has(t.dirName); } catch { return !1; } - })(), n = (function() { + }(), n = function() { try { return s.matches(":dir(ltr),:dir(rtl)"); } catch { return !1; } - })(); + }(); return i ? function(r) { return t.value = r, new FormData(e).get(t.dirName); } : n ? function(r) { return s.value = r, s.matches(":dir(rtl)") ? "rtl" : "ltr"; } : function(r) { const a = r.trim().charAt(0); - return Ka.test(a) ? "rtl" : "ltr"; + return uo.test(a) ? "rtl" : "ltr"; }; -})(); -let Ii = null, Ri = null, Di = null, Fe = null; -const mn = () => (Ii || (Ii = Ya().concat(Ja())), Ii), P = (s) => X[s], Ja = () => (Ri || (Ri = Object.keys(X)), Ri), gn = (s) => Pt[s], Ya = () => (Di || (Di = Object.keys(Pt)), Di), Ur = function(s, t) { - Xa(s).textContent = t.replace(/%t/g, s); -}, Xa = function(s) { +}(); +let $i = null, Ui = null, Vi = null, We = null; +const Sn = () => ($i || ($i = po().concat(go())), $i), F = (s) => X[s], go = () => (Ui || (Ui = Object.keys(X)), Ui), Ln = (s) => Ft[s], po = () => (Vi || (Vi = Object.keys(Ft)), Vi), ea = function(s, t) { + fo(s).textContent = t.replace(/%t/g, s); +}, fo = function(s) { const t = document.createElement("style"); t.setAttribute("type", "text/css"), t.setAttribute("data-tag-name", s.toLowerCase()); - const e = Qa(); + const e = bo(); return e && t.setAttribute("nonce", e), document.head.insertBefore(t, document.head.firstChild), t; -}, Qa = function() { - const s = ls("trix-csp-nonce") || ls("csp-nonce"); +}, bo = function() { + const s = As("trix-csp-nonce") || As("csp-nonce"); if (s) { const { nonce: t, content: e } = s; return t == "" ? e : t; } -}, ls = (s) => document.head.querySelector("meta[name=".concat(s, "]")), ds = { "application/x-trix-feature-detection": "test" }, Vr = function(s) { +}, As = (s) => document.head.querySelector("meta[name=".concat(s, "]")), Es = { "application/x-trix-feature-detection": "test" }, ia = function(s) { const t = s.getData("text/plain"), e = s.getData("text/html"); - if (!t || !e) return t?.length; + if (!t || !e) return t == null ? void 0 : t.length; { const { body: i } = new DOMParser().parseFromString(e, "text/html"); if (i.textContent === t) return !i.querySelector("*"); } -}, jr = /Mac|^iP/.test(navigator.platform) ? (s) => s.metaKey : (s) => s.ctrlKey, kn = (s) => setTimeout(s, 1), Wr = function() { +}, na = /Mac|^iP/.test(navigator.platform) ? (s) => s.metaKey : (s) => s.ctrlKey, Un = (s) => setTimeout(s, 1), sa = function() { let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; const t = {}; for (const e in s) { @@ -356,28 +363,28 @@ const mn = () => (Ii || (Ii = Ya().concat(Ja())), Ii), P = (s) => X[s], Ja = () t[e] = i; } return t; -}, ne = function() { +}, re = function() { let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; if (Object.keys(s).length !== Object.keys(t).length) return !1; for (const e in s) if (s[e] !== t[e]) return !1; return !0; }, k = function(s) { - if (s != null) return Array.isArray(s) || (s = [s, s]), [cs(s[0]), cs(s[1] != null ? s[1] : s[0])]; -}, _t = function(s) { + if (s != null) return Array.isArray(s) || (s = [s, s]), [xs(s[0]), xs(s[1] != null ? s[1] : s[0])]; +}, vt = function(s) { if (s == null) return; const [t, e] = k(s); - return pn(t, e); -}, Ze = function(s, t) { + return Cn(t, e); +}, ai = function(s, t) { if (s == null || t == null) return; const [e, i] = k(s), [n, r] = k(t); - return pn(e, n) && pn(i, r); -}, cs = function(s) { - return typeof s == "number" ? s : Wr(s); -}, pn = function(s, t) { - return typeof s == "number" ? s === t : ne(s, t); + return Cn(e, n) && Cn(i, r); +}, xs = function(s) { + return typeof s == "number" ? s : sa(s); +}, Cn = function(s, t) { + return typeof s == "number" ? s === t : re(s, t); }; -class zr extends H { +class ra extends q { constructor() { super(...arguments), this.update = this.update.bind(this), this.selectionManagers = []; } @@ -391,10 +398,10 @@ class zr extends H { if (!this.selectionManagers.includes(t)) return this.selectionManagers.push(t), this.start(); } unregisterSelectionManager(t) { - if (this.selectionManagers = this.selectionManagers.filter(((e) => e !== t)), this.selectionManagers.length === 0) return this.stop(); + if (this.selectionManagers = this.selectionManagers.filter((e) => e !== t), this.selectionManagers.length === 0) return this.stop(); } notifySelectionManagersOfSelectionChange() { - return this.selectionManagers.map(((t) => t.selectionDidChange())); + return this.selectionManagers.map((t) => t.selectionDidChange()); } update() { this.notifySelectionManagersOfSelectionChange(); @@ -403,52 +410,52 @@ class zr extends H { this.update(); } } -const Ht = new zr(), Kr = function() { +const qt = new ra(), aa = function() { const s = window.getSelection(); if (s.rangeCount > 0) return s; -}, ye = function() { +}, Se = function() { var s; - const t = (s = Kr()) === null || s === void 0 ? void 0 : s.getRangeAt(0); - if (t && !Za(t)) return t; -}, Gr = function(s) { + const t = (s = aa()) === null || s === void 0 ? void 0 : s.getRangeAt(0); + if (t && !_o(t)) return t; +}, oa = function(s) { const t = window.getSelection(); - return t.removeAllRanges(), t.addRange(s), Ht.update(); -}, Za = (s) => hs(s.startContainer) || hs(s.endContainer), hs = (s) => !Object.getPrototypeOf(s), fe = (s) => s.replace(new RegExp("".concat(ni), "g"), "").replace(new RegExp("".concat(St), "g"), " "), In = new RegExp("[^\\S".concat(St, "]")), Rn = (s) => s.replace(new RegExp("".concat(In.source), "g"), " ").replace(/\ {2,}/g, " "), us = function(s, t) { + return t.removeAllRanges(), t.addRange(s), qt.update(); +}, _o = (s) => Ss(s.startContainer) || Ss(s.endContainer), Ss = (s) => !Object.getPrototypeOf(s), ye = (s) => s.replace(new RegExp("".concat(ui), "g"), "").replace(new RegExp("".concat(St), "g"), " "), Vn = new RegExp("[^\\S".concat(St, "]")), jn = (s) => s.replace(new RegExp("".concat(Vn.source), "g"), " ").replace(/\ {2,}/g, " "), Ls = function(s, t) { if (s.isEqualTo(t)) return ["", ""]; - const e = Oi(s, t), { length: i } = e.utf16String; + const e = ji(s, t), { length: i } = e.utf16String; let n; if (i) { const { offset: r } = e, a = s.codepoints.slice(0, r).concat(s.codepoints.slice(r + i)); - n = Oi(t, Le.fromCodepoints(a)); - } else n = Oi(t, s); + n = ji(t, ke.fromCodepoints(a)); + } else n = ji(t, s); return [e.utf16String.toString(), n.utf16String.toString()]; -}, Oi = function(s, t) { +}, ji = function(s, t) { let e = 0, i = s.length, n = t.length; for (; e < i && s.charAt(e).isEqualTo(t.charAt(e)); ) e++; for (; i > e + 1 && s.charAt(i - 1).isEqualTo(t.charAt(n - 1)); ) i--, n--; return { utf16String: s.slice(e, i), offset: e }; }; -class et extends qt { +class et extends $t { static fromCommonAttributesOfObjects() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; if (!t.length) return new this(); - let e = de(t[0]), i = e.getKeys(); - return t.slice(1).forEach(((n) => { - i = e.getKeysCommonToHash(de(n)), e = e.slice(i); - })), e; + let e = me(t[0]), i = e.getKeys(); + return t.slice(1).forEach((n) => { + i = e.getKeysCommonToHash(me(n)), e = e.slice(i); + }), e; } static box(t) { - return de(t); + return me(t); } constructor() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - super(...arguments), this.values = Ye(t); + super(...arguments), this.values = ni(t); } add(t, e) { - return this.merge(to(t, e)); + return this.merge(vo(t, e)); } remove(t) { - return new et(Ye(this.values, t)); + return new et(ni(this.values, t)); } get(t) { return this.values[t]; @@ -457,22 +464,22 @@ class et extends qt { return t in this.values; } merge(t) { - return new et(eo(this.values, io(t))); + return new et(yo(this.values, Ao(t))); } slice(t) { const e = {}; - return Array.from(t).forEach(((i) => { + return Array.from(t).forEach((i) => { this.has(i) && (e[i] = this.values[i]); - })), new et(e); + }), new et(e); } getKeys() { return Object.keys(this.values); } getKeysCommonToHash(t) { - return t = de(t), this.getKeys().filter(((e) => this.values[e] === t.values[e])); + return t = me(t), this.getKeys().filter((e) => this.values[e] === t.values[e]); } isEqualTo(t) { - return Ft(this.toArray(), de(t).toArray()); + return Ht(this.toArray(), me(t).toArray()); } isEmpty() { return this.getKeys().length === 0; @@ -489,7 +496,7 @@ class et extends qt { return this.array; } toObject() { - return Ye(this.values); + return ni(this.values); } toJSON() { return this.toObject(); @@ -498,32 +505,32 @@ class et extends qt { return { values: JSON.stringify(this.values) }; } } -const to = function(s, t) { +const vo = function(s, t) { const e = {}; return e[s] = t, e; -}, eo = function(s, t) { - const e = Ye(s); +}, yo = function(s, t) { + const e = ni(s); for (const i in t) { const n = t[i]; e[i] = n; } return e; -}, Ye = function(s, t) { +}, ni = function(s, t) { const e = {}; - return Object.keys(s).sort().forEach(((i) => { + return Object.keys(s).sort().forEach((i) => { i !== t && (e[i] = s[i]); - })), e; -}, de = function(s) { + }), e; +}, me = function(s) { return s instanceof et ? s : new et(s); -}, io = function(s) { +}, Ao = function(s) { return s instanceof et ? s.values : s; }; -class Dn { +class Wn { static groupObjects() { let t, e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], { depth: i, asTree: n } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; n && i == null && (i = 0); const r = []; - return Array.from(e).forEach(((a) => { + return Array.from(e).forEach((a) => { var o; if (t) { var l, c, u; @@ -531,7 +538,7 @@ class Dn { r.push(new this(t, { depth: i, asTree: n })), t = null; } (o = a.canBeGrouped) !== null && o !== void 0 && o.call(a, i) ? t = [a] : r.push(a); - })), t && r.push(new this(t, { depth: i, asTree: n })), r; + }), t && r.push(new this(t, { depth: i, asTree: n })), r; } constructor() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], { depth: e, asTree: i } = arguments.length > 1 ? arguments[1] : void 0; @@ -545,45 +552,45 @@ class Dn { } getCacheKey() { const t = ["objectGroup"]; - return Array.from(this.getObjects()).forEach(((e) => { + return Array.from(this.getObjects()).forEach((e) => { t.push(e.getCacheKey()); - })), t.join("/"); + }), t.join("/"); } } -class no extends H { +class Eo extends q { constructor() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; - super(...arguments), this.objects = {}, Array.from(t).forEach(((e) => { + super(...arguments), this.objects = {}, Array.from(t).forEach((e) => { const i = JSON.stringify(e); this.objects[i] == null && (this.objects[i] = e); - })); + }); } find(t) { const e = JSON.stringify(t); return this.objects[e]; } } -class so { +class xo { constructor(t) { this.reset(t); } add(t) { - const e = ms(t); + const e = Cs(t); this.elements[e] = t; } remove(t) { - const e = ms(t), i = this.elements[e]; + const e = Cs(t), i = this.elements[e]; if (i) return delete this.elements[e], i; } reset() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; - return this.elements = {}, Array.from(t).forEach(((e) => { + return this.elements = {}, Array.from(t).forEach((e) => { this.add(e); - })), t; + }), t; } } -const ms = (s) => s.dataset.trixStoreKey; -class ti extends H { +const Cs = (s) => s.dataset.trixStoreKey; +class oi extends q { isPerforming() { return this.performing === !0; } @@ -597,9 +604,9 @@ class ti extends H { return this.performed && !this.succeeded; } getPromise() { - return this.promise || (this.promise = new Promise(((t, e) => (this.performing = !0, this.perform(((i, n) => { + return this.promise || (this.promise = new Promise((t, e) => (this.performing = !0, this.perform((i, n) => { this.succeeded = i, this.performing = !1, this.performed = !0, this.succeeded ? t(n) : e(n); - })))))), this.promise; + })))), this.promise; } perform(t) { return t(!1); @@ -609,14 +616,14 @@ class ti extends H { (t = this.promise) === null || t === void 0 || (e = t.cancel) === null || e === void 0 || e.call(t), this.promise = null, this.performing = null, this.performed = null, this.succeeded = null; } } -ti.proxyMethod("getPromise().then"), ti.proxyMethod("getPromise().catch"); -class $t extends H { +oi.proxyMethod("getPromise().then"), oi.proxyMethod("getPromise().catch"); +class Ut extends q { constructor(t) { let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; super(...arguments), this.object = t, this.options = e, this.childViews = [], this.rootView = this; } getNodes() { - return this.nodes || (this.nodes = this.createNodes()), this.nodes.map(((t) => t.cloneNode(!0))); + return this.nodes || (this.nodes = this.createNodes()), this.nodes.map((t) => t.cloneNode(!0)); } invalidate() { var t; @@ -632,7 +639,7 @@ class $t extends H { } createChildView(t, e) { let i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; - e instanceof Dn && (i.viewClass = t, t = ro); + e instanceof Wn && (i.viewClass = t, t = So); const n = new t(e, i); return this.recordChildView(n); } @@ -641,15 +648,15 @@ class $t extends H { } getAllChildViews() { let t = []; - return this.childViews.forEach(((e) => { + return this.childViews.forEach((e) => { t.push(e), t = t.concat(e.getAllChildViews()); - })), t; + }), t; } findElement() { return this.findElementForObject(this.object); } findElementForObject(t) { - const e = t?.id; + const e = t == null ? void 0 : t.id; if (e) return this.rootView.element.querySelector("[data-trix-id='".concat(e, "']")); } findViewForObject(t) { @@ -678,246 +685,247 @@ class $t extends H { garbageCollectCachedViews() { const t = this.getViewCache(); if (t) { - const e = this.getAllChildViews().concat(this).map(((i) => i.object.getCacheKey())); + const e = this.getAllChildViews().concat(this).map((i) => i.object.getCacheKey()); for (const i in t) e.includes(i) || delete t[i]; } } } -class ro extends $t { +class So extends Ut { constructor() { super(...arguments), this.objectGroup = this.object, this.viewClass = this.options.viewClass, delete this.options.viewClass; } getChildViews() { - return this.childViews.length || Array.from(this.objectGroup.getObjects()).forEach(((t) => { + return this.childViews.length || Array.from(this.objectGroup.getObjects()).forEach((t) => { this.findOrCreateCachedChildView(this.viewClass, t, this.options); - })), this.childViews; + }), this.childViews; } createNodes() { const t = this.createContainerElement(); - return this.getChildViews().forEach(((e) => { - Array.from(e.getNodes()).forEach(((i) => { + return this.getChildViews().forEach((e) => { + Array.from(e.getNodes()).forEach((i) => { t.appendChild(i); - })); - })), [t]; + }); + }), [t]; } createContainerElement() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : this.objectGroup.getDepth(); return this.getChildViews()[0].createContainerElement(t); } } -const { entries: Jr, setPrototypeOf: gs, isFrozen: ao, getPrototypeOf: oo, getOwnPropertyDescriptor: lo } = Object; -let { freeze: Q, seal: st, create: Yr } = Object, { apply: fn, construct: bn } = typeof Reflect < "u" && Reflect; +/*! @license DOMPurify 3.2.7 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.2.7/LICENSE */ +const { entries: la, setPrototypeOf: ws, isFrozen: Lo, getPrototypeOf: Co, getOwnPropertyDescriptor: wo } = Object; +let { freeze: Q, seal: st, create: da } = Object, { apply: wn, construct: Tn } = typeof Reflect < "u" && Reflect; Q || (Q = function(s) { return s; }), st || (st = function(s) { return s; -}), fn || (fn = function(s, t) { +}), wn || (wn = function(s, t) { for (var e = arguments.length, i = new Array(e > 2 ? e - 2 : 0), n = 2; n < e; n++) i[n - 2] = arguments[n]; return s.apply(t, i); -}), bn || (bn = function(s) { +}), Tn || (Tn = function(s) { for (var t = arguments.length, e = new Array(t > 1 ? t - 1 : 0), i = 1; i < t; i++) e[i - 1] = arguments[i]; return new s(...e); }); -const He = Z(Array.prototype.forEach), co = Z(Array.prototype.lastIndexOf), ps = Z(Array.prototype.pop), ce = Z(Array.prototype.push), ho = Z(Array.prototype.splice), Xe = Z(String.prototype.toLowerCase), Bi = Z(String.prototype.toString), Mi = Z(String.prototype.match), he = Z(String.prototype.replace), uo = Z(String.prototype.indexOf), mo = Z(String.prototype.trim), lt = Z(Object.prototype.hasOwnProperty), J = Z(RegExp.prototype.test), ue = (fs = TypeError, function() { +const ze = Z(Array.prototype.forEach), To = Z(Array.prototype.lastIndexOf), Ts = Z(Array.prototype.pop), ge = Z(Array.prototype.push), ko = Z(Array.prototype.splice), si = Z(String.prototype.toLowerCase), Wi = Z(String.prototype.toString), zi = Z(String.prototype.match), pe = Z(String.prototype.replace), Io = Z(String.prototype.indexOf), Ro = Z(String.prototype.trim), lt = Z(Object.prototype.hasOwnProperty), J = Z(RegExp.prototype.test), fe = (ks = TypeError, function() { for (var s = arguments.length, t = new Array(s), e = 0; e < s; e++) t[e] = arguments[e]; - return bn(fs, t); + return Tn(ks, t); }); -var fs; +var ks; function Z(s) { return function(t) { t instanceof RegExp && (t.lastIndex = 0); for (var e = arguments.length, i = new Array(e > 1 ? e - 1 : 0), n = 1; n < e; n++) i[n - 1] = arguments[n]; - return fn(s, t, i); + return wn(s, t, i); }; } function L(s, t) { - let e = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : Xe; - gs && gs(s, null); + let e = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : si; + ws && ws(s, null); let i = t.length; for (; i--; ) { let n = t[i]; if (typeof n == "string") { const r = e(n); - r !== n && (ao(t) || (t[i] = r), n = r); + r !== n && (Lo(t) || (t[i] = r), n = r); } s[n] = !0; } return s; } -function go(s) { +function Do(s) { for (let t = 0; t < s.length; t++) lt(s, t) || (s[t] = null); return s; } function ft(s) { - const t = Yr(null); - for (const [e, i] of Jr(s)) - lt(s, e) && (Array.isArray(i) ? t[e] = go(i) : i && typeof i == "object" && i.constructor === Object ? t[e] = ft(i) : t[e] = i); + const t = da(null); + for (const [e, i] of la(s)) + lt(s, e) && (Array.isArray(i) ? t[e] = Do(i) : i && typeof i == "object" && i.constructor === Object ? t[e] = ft(i) : t[e] = i); return t; } -function me(s, t) { +function be(s, t) { for (; s !== null; ) { - const e = lo(s, t); + const e = wo(s, t); if (e) { if (e.get) return Z(e.get); if (typeof e.value == "function") return Z(e.value); } - s = oo(s); + s = Co(s); } return function() { return null; }; } -const bs = Q(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Ni = Q(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "slot", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Pi = Q(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), po = Q(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Fi = Q(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), fo = Q(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), _s = Q(["#text"]), vs = Q(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), Hi = Q(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), ys = Q(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), qe = Q(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), bo = st(/\{\{[\w\W]*|[\w\W]*\}\}/gm), _o = st(/<%[\w\W]*|[\w\W]*%>/gm), vo = st(/\$\{[\w\W]*/gm), yo = st(/^data-[\-\w.\u00B7-\uFFFF]+$/), Ao = st(/^aria-[\-\w]+$/), Xr = st(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), Eo = st(/^(?:\w+script|data):/i), xo = st(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), Qr = st(/^html$/i), So = st(/^[a-z][.\w]*(-[.\w]+)+$/i); -var As = Object.freeze({ __proto__: null, ARIA_ATTR: Ao, ATTR_WHITESPACE: xo, CUSTOM_ELEMENT: So, DATA_ATTR: yo, DOCTYPE_NAME: Qr, ERB_EXPR: _o, IS_ALLOWED_URI: Xr, IS_SCRIPT_OR_DATA: Eo, MUSTACHE_EXPR: bo, TMPLIT_EXPR: vo }); -const Lo = 1, Co = 3, wo = 7, To = 8, ko = 9, Io = function() { +const Is = Q(["a", "abbr", "acronym", "address", "area", "article", "aside", "audio", "b", "bdi", "bdo", "big", "blink", "blockquote", "body", "br", "button", "canvas", "caption", "center", "cite", "code", "col", "colgroup", "content", "data", "datalist", "dd", "decorator", "del", "details", "dfn", "dialog", "dir", "div", "dl", "dt", "element", "em", "fieldset", "figcaption", "figure", "font", "footer", "form", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "i", "img", "input", "ins", "kbd", "label", "legend", "li", "main", "map", "mark", "marquee", "menu", "menuitem", "meter", "nav", "nobr", "ol", "optgroup", "option", "output", "p", "picture", "pre", "progress", "q", "rp", "rt", "ruby", "s", "samp", "search", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "tr", "track", "tt", "u", "ul", "var", "video", "wbr"]), Ki = Q(["svg", "a", "altglyph", "altglyphdef", "altglyphitem", "animatecolor", "animatemotion", "animatetransform", "circle", "clippath", "defs", "desc", "ellipse", "enterkeyhint", "exportparts", "filter", "font", "g", "glyph", "glyphref", "hkern", "image", "inputmode", "line", "lineargradient", "marker", "mask", "metadata", "mpath", "part", "path", "pattern", "polygon", "polyline", "radialgradient", "rect", "slot", "stop", "style", "switch", "symbol", "text", "textpath", "title", "tref", "tspan", "view", "vkern"]), Gi = Q(["feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence"]), Oo = Q(["animate", "color-profile", "cursor", "discard", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignobject", "hatch", "hatchpath", "mesh", "meshgradient", "meshpatch", "meshrow", "missing-glyph", "script", "set", "solidcolor", "unknown", "use"]), Ji = Q(["math", "menclose", "merror", "mfenced", "mfrac", "mglyph", "mi", "mlabeledtr", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msup", "msubsup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "mprescripts"]), Bo = Q(["maction", "maligngroup", "malignmark", "mlongdiv", "mscarries", "mscarry", "msgroup", "mstack", "msline", "msrow", "semantics", "annotation", "annotation-xml", "mprescripts", "none"]), Rs = Q(["#text"]), Ds = Q(["accept", "action", "align", "alt", "autocapitalize", "autocomplete", "autopictureinpicture", "autoplay", "background", "bgcolor", "border", "capture", "cellpadding", "cellspacing", "checked", "cite", "class", "clear", "color", "cols", "colspan", "controls", "controlslist", "coords", "crossorigin", "datetime", "decoding", "default", "dir", "disabled", "disablepictureinpicture", "disableremoteplayback", "download", "draggable", "enctype", "enterkeyhint", "exportparts", "face", "for", "headers", "height", "hidden", "high", "href", "hreflang", "id", "inert", "inputmode", "integrity", "ismap", "kind", "label", "lang", "list", "loading", "loop", "low", "max", "maxlength", "media", "method", "min", "minlength", "multiple", "muted", "name", "nonce", "noshade", "novalidate", "nowrap", "open", "optimum", "part", "pattern", "placeholder", "playsinline", "popover", "popovertarget", "popovertargetaction", "poster", "preload", "pubdate", "radiogroup", "readonly", "rel", "required", "rev", "reversed", "role", "rows", "rowspan", "spellcheck", "scope", "selected", "shape", "size", "sizes", "slot", "span", "srclang", "start", "src", "srcset", "step", "style", "summary", "tabindex", "title", "translate", "type", "usemap", "valign", "value", "width", "wrap", "xmlns", "slot"]), Yi = Q(["accent-height", "accumulate", "additive", "alignment-baseline", "amplitude", "ascent", "attributename", "attributetype", "azimuth", "basefrequency", "baseline-shift", "begin", "bias", "by", "class", "clip", "clippathunits", "clip-path", "clip-rule", "color", "color-interpolation", "color-interpolation-filters", "color-profile", "color-rendering", "cx", "cy", "d", "dx", "dy", "diffuseconstant", "direction", "display", "divisor", "dur", "edgemode", "elevation", "end", "exponent", "fill", "fill-opacity", "fill-rule", "filter", "filterunits", "flood-color", "flood-opacity", "font-family", "font-size", "font-size-adjust", "font-stretch", "font-style", "font-variant", "font-weight", "fx", "fy", "g1", "g2", "glyph-name", "glyphref", "gradientunits", "gradienttransform", "height", "href", "id", "image-rendering", "in", "in2", "intercept", "k", "k1", "k2", "k3", "k4", "kerning", "keypoints", "keysplines", "keytimes", "lang", "lengthadjust", "letter-spacing", "kernelmatrix", "kernelunitlength", "lighting-color", "local", "marker-end", "marker-mid", "marker-start", "markerheight", "markerunits", "markerwidth", "maskcontentunits", "maskunits", "max", "mask", "media", "method", "mode", "min", "name", "numoctaves", "offset", "operator", "opacity", "order", "orient", "orientation", "origin", "overflow", "paint-order", "path", "pathlength", "patterncontentunits", "patterntransform", "patternunits", "points", "preservealpha", "preserveaspectratio", "primitiveunits", "r", "rx", "ry", "radius", "refx", "refy", "repeatcount", "repeatdur", "restart", "result", "rotate", "scale", "seed", "shape-rendering", "slope", "specularconstant", "specularexponent", "spreadmethod", "startoffset", "stddeviation", "stitchtiles", "stop-color", "stop-opacity", "stroke-dasharray", "stroke-dashoffset", "stroke-linecap", "stroke-linejoin", "stroke-miterlimit", "stroke-opacity", "stroke", "stroke-width", "style", "surfacescale", "systemlanguage", "tabindex", "tablevalues", "targetx", "targety", "transform", "transform-origin", "text-anchor", "text-decoration", "text-rendering", "textlength", "type", "u1", "u2", "unicode", "values", "viewbox", "visibility", "version", "vert-adv-y", "vert-origin-x", "vert-origin-y", "width", "word-spacing", "wrap", "writing-mode", "xchannelselector", "ychannelselector", "x", "x1", "x2", "xmlns", "y", "y1", "y2", "z", "zoomandpan"]), Os = Q(["accent", "accentunder", "align", "bevelled", "close", "columnsalign", "columnlines", "columnspan", "denomalign", "depth", "dir", "display", "displaystyle", "encoding", "fence", "frame", "height", "href", "id", "largeop", "length", "linethickness", "lspace", "lquote", "mathbackground", "mathcolor", "mathsize", "mathvariant", "maxsize", "minsize", "movablelimits", "notation", "numalign", "open", "rowalign", "rowlines", "rowspacing", "rowspan", "rspace", "rquote", "scriptlevel", "scriptminsize", "scriptsizemultiplier", "selection", "separator", "separators", "stretchy", "subscriptshift", "supscriptshift", "symmetric", "voffset", "width", "xmlns"]), Ke = Q(["xlink:href", "xml:id", "xlink:title", "xml:space", "xmlns:xlink"]), Mo = st(/\{\{[\w\W]*|[\w\W]*\}\}/gm), No = st(/<%[\w\W]*|[\w\W]*%>/gm), Po = st(/\$\{[\w\W]*/gm), Fo = st(/^data-[\-\w.\u00B7-\uFFFF]+$/), Ho = st(/^aria-[\-\w]+$/), ca = st(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i), qo = st(/^(?:\w+script|data):/i), $o = st(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g), ha = st(/^html$/i), Uo = st(/^[a-z][.\w]*(-[.\w]+)+$/i); +var Bs = Object.freeze({ __proto__: null, ARIA_ATTR: Ho, ATTR_WHITESPACE: $o, CUSTOM_ELEMENT: Uo, DATA_ATTR: Fo, DOCTYPE_NAME: ha, ERB_EXPR: No, IS_ALLOWED_URI: ca, IS_SCRIPT_OR_DATA: qo, MUSTACHE_EXPR: Mo, TMPLIT_EXPR: Po }); +const Vo = 1, jo = 3, Wo = 7, zo = 8, Ko = 9, Go = function() { return typeof window > "u" ? null : window; }; -var Ce = (function s() { - let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Io(); +var Ie = function s() { + let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : Go(); const e = (d) => s(d); - if (e.version = "3.2.7", e.removed = [], !t || !t.document || t.document.nodeType !== ko || !t.Element) return e.isSupported = !1, e; + if (e.version = "3.2.7", e.removed = [], !t || !t.document || t.document.nodeType !== Ko || !t.Element) return e.isSupported = !1, e; let { document: i } = t; - const n = i, r = n.currentScript, { DocumentFragment: a, HTMLTemplateElement: o, Node: l, Element: c, NodeFilter: u, NamedNodeMap: m = t.NamedNodeMap || t.MozNamedAttrMap, HTMLFormElement: p, DOMParser: h, trustedTypes: b } = t, A = c.prototype, I = me(A, "cloneNode"), q = me(A, "remove"), R = me(A, "nextSibling"), $ = me(A, "childNodes"), _ = me(A, "parentNode"); + const n = i, r = n.currentScript, { DocumentFragment: a, HTMLTemplateElement: o, Node: l, Element: c, NodeFilter: u, NamedNodeMap: m = t.NamedNodeMap || t.MozNamedAttrMap, HTMLFormElement: p, DOMParser: h, trustedTypes: f } = t, A = c.prototype, I = be(A, "cloneNode"), $ = be(A, "remove"), R = be(A, "nextSibling"), U = be(A, "childNodes"), _ = be(A, "parentNode"); if (typeof o == "function") { const d = i.createElement("template"); d.content && d.content.ownerDocument && (i = d.content.ownerDocument); } let S, E = ""; - const { implementation: j, createNodeIterator: ct, createDocumentFragment: wt, getElementsByTagName: mt } = i, { importNode: li } = n; - let K = { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; - e.isSupported = typeof Jr == "function" && typeof _ == "function" && j && j.createHTMLDocument !== void 0; - const { MUSTACHE_EXPR: Tt, ERB_EXPR: Vt, TMPLIT_EXPR: tt, DATA_ATTR: di, ARIA_ATTR: ci, IS_SCRIPT_OR_DATA: hi, ATTR_WHITESPACE: Ie, CUSTOM_ELEMENT: ui } = As; - let { IS_ALLOWED_URI: F } = As, D = null; - const Mn = L({}, [...bs, ...Ni, ...Pi, ...Fi, ..._s]); - let W = null; - const Nn = L({}, [...vs, ...Hi, ...ys, ...qe]); - let M = Object.seal(Yr(null, { tagNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, attributeNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, allowCustomizedBuiltInElements: { writable: !0, configurable: !1, enumerable: !0, value: !1 } })), re = null, mi = null, Pn = !0, gi = !0, Fn = !1, Hn = !0, jt = !1, Re = !0, kt = !1, pi = !1, fi = !1, Wt = !1, De = !1, Oe = !1, qn = !0, $n = !1, bi = !0, ae = !1, zt = {}, Kt = null; - const Un = L({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]); - let Vn = null; - const jn = L({}, ["audio", "video", "img", "source", "image", "track"]); - let _i = null; - const Wn = L({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), Be = "http://www.w3.org/1998/Math/MathML", Me = "http://www.w3.org/2000/svg", gt = "http://www.w3.org/1999/xhtml"; - let Gt = gt, vi = !1, yi = null; - const Da = L({}, [Be, Me, gt], Bi); - let Ne = L({}, ["mi", "mo", "mn", "ms", "mtext"]), Pe = L({}, ["annotation-xml"]); - const Oa = L({}, ["title", "style", "font", "a", "script"]); - let oe = null; - const Ba = ["application/xhtml+xml", "text/html"]; - let V = null, Jt = null; - const Ma = i.createElement("form"), zn = function(d) { + const { implementation: z, createNodeIterator: ct, createDocumentFragment: wt, getElementsByTagName: mt } = i, { importNode: bi } = n; + let V = { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; + e.isSupported = typeof la == "function" && typeof _ == "function" && z && z.createHTMLDocument !== void 0; + const { MUSTACHE_EXPR: Tt, ERB_EXPR: jt, TMPLIT_EXPR: tt, DATA_ATTR: _i, ARIA_ATTR: vi, IS_SCRIPT_OR_DATA: yi, ATTR_WHITESPACE: Me, CUSTOM_ELEMENT: Ai } = Bs; + let { IS_ALLOWED_URI: oe } = Bs, M = null; + const H = L({}, [...Is, ...Ki, ...Gi, ...Ji, ...Rs]); + let D = null; + const Gn = L({}, [...Ds, ...Yi, ...Os, ...Ke]); + let N = Object.seal(da(null, { tagNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, attributeNameCheck: { writable: !0, configurable: !1, enumerable: !0, value: null }, allowCustomizedBuiltInElements: { writable: !0, configurable: !1, enumerable: !0, value: !1 } })), le = null, Ei = null, Jn = !0, xi = !0, Yn = !1, Xn = !0, Wt = !1, Ne = !0, kt = !1, Si = !1, Li = !1, zt = !1, Pe = !1, Fe = !1, Qn = !0, Zn = !1, Ci = !0, de = !1, Kt = {}, Gt = null; + const ts = L({}, ["annotation-xml", "audio", "colgroup", "desc", "foreignobject", "head", "iframe", "math", "mi", "mn", "mo", "ms", "mtext", "noembed", "noframes", "noscript", "plaintext", "script", "style", "svg", "template", "thead", "title", "video", "xmp"]); + let es = null; + const is = L({}, ["audio", "video", "img", "source", "image", "track"]); + let wi = null; + const ns = L({}, ["alt", "class", "for", "id", "label", "name", "pattern", "placeholder", "role", "summary", "title", "value", "style", "xmlns"]), He = "http://www.w3.org/1998/Math/MathML", qe = "http://www.w3.org/2000/svg", gt = "http://www.w3.org/1999/xhtml"; + let Jt = gt, Ti = !1, ki = null; + const Ga = L({}, [He, qe, gt], Wi); + let $e = L({}, ["mi", "mo", "mn", "ms", "mtext"]), Ue = L({}, ["annotation-xml"]); + const Ja = L({}, ["title", "style", "font", "a", "script"]); + let ce = null; + const Ya = ["application/xhtml+xml", "text/html"]; + let W = null, Yt = null; + const Xa = i.createElement("form"), ss = function(d) { return d instanceof RegExp || d instanceof Function; - }, Ai = function() { + }, Ii = function() { let d = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - if (!Jt || Jt !== d) { - if (d && typeof d == "object" || (d = {}), d = ft(d), oe = Ba.indexOf(d.PARSER_MEDIA_TYPE) === -1 ? "text/html" : d.PARSER_MEDIA_TYPE, V = oe === "application/xhtml+xml" ? Bi : Xe, D = lt(d, "ALLOWED_TAGS") ? L({}, d.ALLOWED_TAGS, V) : Mn, W = lt(d, "ALLOWED_ATTR") ? L({}, d.ALLOWED_ATTR, V) : Nn, yi = lt(d, "ALLOWED_NAMESPACES") ? L({}, d.ALLOWED_NAMESPACES, Bi) : Da, _i = lt(d, "ADD_URI_SAFE_ATTR") ? L(ft(Wn), d.ADD_URI_SAFE_ATTR, V) : Wn, Vn = lt(d, "ADD_DATA_URI_TAGS") ? L(ft(jn), d.ADD_DATA_URI_TAGS, V) : jn, Kt = lt(d, "FORBID_CONTENTS") ? L({}, d.FORBID_CONTENTS, V) : Un, re = lt(d, "FORBID_TAGS") ? L({}, d.FORBID_TAGS, V) : ft({}), mi = lt(d, "FORBID_ATTR") ? L({}, d.FORBID_ATTR, V) : ft({}), zt = !!lt(d, "USE_PROFILES") && d.USE_PROFILES, Pn = d.ALLOW_ARIA_ATTR !== !1, gi = d.ALLOW_DATA_ATTR !== !1, Fn = d.ALLOW_UNKNOWN_PROTOCOLS || !1, Hn = d.ALLOW_SELF_CLOSE_IN_ATTR !== !1, jt = d.SAFE_FOR_TEMPLATES || !1, Re = d.SAFE_FOR_XML !== !1, kt = d.WHOLE_DOCUMENT || !1, Wt = d.RETURN_DOM || !1, De = d.RETURN_DOM_FRAGMENT || !1, Oe = d.RETURN_TRUSTED_TYPE || !1, fi = d.FORCE_BODY || !1, qn = d.SANITIZE_DOM !== !1, $n = d.SANITIZE_NAMED_PROPS || !1, bi = d.KEEP_CONTENT !== !1, ae = d.IN_PLACE || !1, F = d.ALLOWED_URI_REGEXP || Xr, Gt = d.NAMESPACE || gt, Ne = d.MATHML_TEXT_INTEGRATION_POINTS || Ne, Pe = d.HTML_INTEGRATION_POINTS || Pe, M = d.CUSTOM_ELEMENT_HANDLING || {}, d.CUSTOM_ELEMENT_HANDLING && zn(d.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (M.tagNameCheck = d.CUSTOM_ELEMENT_HANDLING.tagNameCheck), d.CUSTOM_ELEMENT_HANDLING && zn(d.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (M.attributeNameCheck = d.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), d.CUSTOM_ELEMENT_HANDLING && typeof d.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (M.allowCustomizedBuiltInElements = d.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), jt && (gi = !1), De && (Wt = !0), zt && (D = L({}, _s), W = [], zt.html === !0 && (L(D, bs), L(W, vs)), zt.svg === !0 && (L(D, Ni), L(W, Hi), L(W, qe)), zt.svgFilters === !0 && (L(D, Pi), L(W, Hi), L(W, qe)), zt.mathMl === !0 && (L(D, Fi), L(W, ys), L(W, qe))), d.ADD_TAGS && (D === Mn && (D = ft(D)), L(D, d.ADD_TAGS, V)), d.ADD_ATTR && (W === Nn && (W = ft(W)), L(W, d.ADD_ATTR, V)), d.ADD_URI_SAFE_ATTR && L(_i, d.ADD_URI_SAFE_ATTR, V), d.FORBID_CONTENTS && (Kt === Un && (Kt = ft(Kt)), L(Kt, d.FORBID_CONTENTS, V)), bi && (D["#text"] = !0), kt && L(D, ["html", "head", "body"]), D.table && (L(D, ["tbody"]), delete re.tbody), d.TRUSTED_TYPES_POLICY) { - if (typeof d.TRUSTED_TYPES_POLICY.createHTML != "function") throw ue('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); - if (typeof d.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw ue('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); + if (!Yt || Yt !== d) { + if (d && typeof d == "object" || (d = {}), d = ft(d), ce = Ya.indexOf(d.PARSER_MEDIA_TYPE) === -1 ? "text/html" : d.PARSER_MEDIA_TYPE, W = ce === "application/xhtml+xml" ? Wi : si, M = lt(d, "ALLOWED_TAGS") ? L({}, d.ALLOWED_TAGS, W) : H, D = lt(d, "ALLOWED_ATTR") ? L({}, d.ALLOWED_ATTR, W) : Gn, ki = lt(d, "ALLOWED_NAMESPACES") ? L({}, d.ALLOWED_NAMESPACES, Wi) : Ga, wi = lt(d, "ADD_URI_SAFE_ATTR") ? L(ft(ns), d.ADD_URI_SAFE_ATTR, W) : ns, es = lt(d, "ADD_DATA_URI_TAGS") ? L(ft(is), d.ADD_DATA_URI_TAGS, W) : is, Gt = lt(d, "FORBID_CONTENTS") ? L({}, d.FORBID_CONTENTS, W) : ts, le = lt(d, "FORBID_TAGS") ? L({}, d.FORBID_TAGS, W) : ft({}), Ei = lt(d, "FORBID_ATTR") ? L({}, d.FORBID_ATTR, W) : ft({}), Kt = !!lt(d, "USE_PROFILES") && d.USE_PROFILES, Jn = d.ALLOW_ARIA_ATTR !== !1, xi = d.ALLOW_DATA_ATTR !== !1, Yn = d.ALLOW_UNKNOWN_PROTOCOLS || !1, Xn = d.ALLOW_SELF_CLOSE_IN_ATTR !== !1, Wt = d.SAFE_FOR_TEMPLATES || !1, Ne = d.SAFE_FOR_XML !== !1, kt = d.WHOLE_DOCUMENT || !1, zt = d.RETURN_DOM || !1, Pe = d.RETURN_DOM_FRAGMENT || !1, Fe = d.RETURN_TRUSTED_TYPE || !1, Li = d.FORCE_BODY || !1, Qn = d.SANITIZE_DOM !== !1, Zn = d.SANITIZE_NAMED_PROPS || !1, Ci = d.KEEP_CONTENT !== !1, de = d.IN_PLACE || !1, oe = d.ALLOWED_URI_REGEXP || ca, Jt = d.NAMESPACE || gt, $e = d.MATHML_TEXT_INTEGRATION_POINTS || $e, Ue = d.HTML_INTEGRATION_POINTS || Ue, N = d.CUSTOM_ELEMENT_HANDLING || {}, d.CUSTOM_ELEMENT_HANDLING && ss(d.CUSTOM_ELEMENT_HANDLING.tagNameCheck) && (N.tagNameCheck = d.CUSTOM_ELEMENT_HANDLING.tagNameCheck), d.CUSTOM_ELEMENT_HANDLING && ss(d.CUSTOM_ELEMENT_HANDLING.attributeNameCheck) && (N.attributeNameCheck = d.CUSTOM_ELEMENT_HANDLING.attributeNameCheck), d.CUSTOM_ELEMENT_HANDLING && typeof d.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements == "boolean" && (N.allowCustomizedBuiltInElements = d.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements), Wt && (xi = !1), Pe && (zt = !0), Kt && (M = L({}, Rs), D = [], Kt.html === !0 && (L(M, Is), L(D, Ds)), Kt.svg === !0 && (L(M, Ki), L(D, Yi), L(D, Ke)), Kt.svgFilters === !0 && (L(M, Gi), L(D, Yi), L(D, Ke)), Kt.mathMl === !0 && (L(M, Ji), L(D, Os), L(D, Ke))), d.ADD_TAGS && (M === H && (M = ft(M)), L(M, d.ADD_TAGS, W)), d.ADD_ATTR && (D === Gn && (D = ft(D)), L(D, d.ADD_ATTR, W)), d.ADD_URI_SAFE_ATTR && L(wi, d.ADD_URI_SAFE_ATTR, W), d.FORBID_CONTENTS && (Gt === ts && (Gt = ft(Gt)), L(Gt, d.FORBID_CONTENTS, W)), Ci && (M["#text"] = !0), kt && L(M, ["html", "head", "body"]), M.table && (L(M, ["tbody"]), delete le.tbody), d.TRUSTED_TYPES_POLICY) { + if (typeof d.TRUSTED_TYPES_POLICY.createHTML != "function") throw fe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.'); + if (typeof d.TRUSTED_TYPES_POLICY.createScriptURL != "function") throw fe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.'); S = d.TRUSTED_TYPES_POLICY, E = S.createHTML(""); - } else S === void 0 && (S = (function(f, g) { - if (typeof f != "object" || typeof f.createPolicy != "function") return null; + } else S === void 0 && (S = function(b, g) { + if (typeof b != "object" || typeof b.createPolicy != "function") return null; let C = null; const T = "data-tt-policy-suffix"; g && g.hasAttribute(T) && (C = g.getAttribute(T)); const y = "dompurify" + (C ? "#" + C : ""); try { - return f.createPolicy(y, { createHTML: (U) => U, createScriptURL: (U) => U }); + return b.createPolicy(y, { createHTML: (j) => j, createScriptURL: (j) => j }); } catch { return console.warn("TrustedTypes policy " + y + " could not be created."), null; } - })(b, r)), S !== null && typeof E == "string" && (E = S.createHTML("")); - Q && Q(d), Jt = d; + }(f, r)), S !== null && typeof E == "string" && (E = S.createHTML("")); + Q && Q(d), Yt = d; } - }, Kn = L({}, [...Ni, ...Pi, ...po]), Gn = L({}, [...Fi, ...fo]), ht = function(d) { - ce(e.removed, { element: d }); + }, rs = L({}, [...Ki, ...Gi, ...Oo]), as = L({}, [...Ji, ...Bo]), ht = function(d) { + ge(e.removed, { element: d }); try { _(d).removeChild(d); } catch { - q(d); + $(d); } - }, It = function(d, f) { + }, It = function(d, b) { try { - ce(e.removed, { attribute: f.getAttributeNode(d), from: f }); + ge(e.removed, { attribute: b.getAttributeNode(d), from: b }); } catch { - ce(e.removed, { attribute: null, from: f }); + ge(e.removed, { attribute: null, from: b }); } - if (f.removeAttribute(d), d === "is") if (Wt || De) try { - ht(f); + if (b.removeAttribute(d), d === "is") if (zt || Pe) try { + ht(b); } catch { } else try { - f.setAttribute(d, ""); + b.setAttribute(d, ""); } catch { } - }, Jn = function(d) { - let f = null, g = null; - if (fi) d = "" + d; + }, os = function(d) { + let b = null, g = null; + if (Li) d = "" + d; else { - const y = Mi(d, /^[\r\n\t ]+/); + const y = zi(d, /^[\r\n\t ]+/); g = y && y[0]; } - oe === "application/xhtml+xml" && Gt === gt && (d = '' + d + ""); + ce === "application/xhtml+xml" && Jt === gt && (d = '' + d + ""); const C = S ? S.createHTML(d) : d; - if (Gt === gt) try { - f = new h().parseFromString(C, oe); + if (Jt === gt) try { + b = new h().parseFromString(C, ce); } catch { } - if (!f || !f.documentElement) { - f = j.createDocument(Gt, "template", null); + if (!b || !b.documentElement) { + b = z.createDocument(Jt, "template", null); try { - f.documentElement.innerHTML = vi ? E : C; + b.documentElement.innerHTML = Ti ? E : C; } catch { } } - const T = f.body || f.documentElement; - return d && g && T.insertBefore(i.createTextNode(g), T.childNodes[0] || null), Gt === gt ? mt.call(f, kt ? "html" : "body")[0] : kt ? f.documentElement : T; - }, Yn = function(d) { + const T = b.body || b.documentElement; + return d && g && T.insertBefore(i.createTextNode(g), T.childNodes[0] || null), Jt === gt ? mt.call(b, kt ? "html" : "body")[0] : kt ? b.documentElement : T; + }, ls = function(d) { return ct.call(d.ownerDocument || d, d, u.SHOW_ELEMENT | u.SHOW_COMMENT | u.SHOW_TEXT | u.SHOW_PROCESSING_INSTRUCTION | u.SHOW_CDATA_SECTION, null); - }, Ei = function(d) { + }, Ri = function(d) { return d instanceof p && (typeof d.nodeName != "string" || typeof d.textContent != "string" || typeof d.removeChild != "function" || !(d.attributes instanceof m) || typeof d.removeAttribute != "function" || typeof d.setAttribute != "function" || typeof d.namespaceURI != "string" || typeof d.insertBefore != "function" || typeof d.hasChildNodes != "function"); - }, Xn = function(d) { + }, ds = function(d) { return typeof l == "function" && d instanceof l; }; - function pt(d, f, g) { - He(d, ((C) => { - C.call(e, f, g, Jt); - })); + function pt(d, b, g) { + ze(d, (C) => { + C.call(e, b, g, Yt); + }); } - const Qn = function(d) { - let f = null; - if (pt(K.beforeSanitizeElements, d, null), Ei(d)) return ht(d), !0; - const g = V(d.nodeName); - if (pt(K.uponSanitizeElement, d, { tagName: g, allowedTags: D }), Re && d.hasChildNodes() && !Xn(d.firstElementChild) && J(/<[/\w!]/g, d.innerHTML) && J(/<[/\w!]/g, d.textContent) || d.nodeType === wo || Re && d.nodeType === To && J(/<[/\w]/g, d.data)) return ht(d), !0; - if (!D[g] || re[g]) { - if (!re[g] && ts(g) && (M.tagNameCheck instanceof RegExp && J(M.tagNameCheck, g) || M.tagNameCheck instanceof Function && M.tagNameCheck(g))) + const cs = function(d) { + let b = null; + if (pt(V.beforeSanitizeElements, d, null), Ri(d)) return ht(d), !0; + const g = W(d.nodeName); + if (pt(V.uponSanitizeElement, d, { tagName: g, allowedTags: M }), Ne && d.hasChildNodes() && !ds(d.firstElementChild) && J(/<[/\w!]/g, d.innerHTML) && J(/<[/\w!]/g, d.textContent) || d.nodeType === Wo || Ne && d.nodeType === zo && J(/<[/\w]/g, d.data)) return ht(d), !0; + if (!M[g] || le[g]) { + if (!le[g] && us(g) && (N.tagNameCheck instanceof RegExp && J(N.tagNameCheck, g) || N.tagNameCheck instanceof Function && N.tagNameCheck(g))) return !1; - if (bi && !Kt[g]) { - const C = _(d) || d.parentNode, T = $(d) || d.childNodes; + if (Ci && !Gt[g]) { + const C = _(d) || d.parentNode, T = U(d) || d.childNodes; if (T && C) for (let y = T.length - 1; y >= 0; --y) { - const U = I(T[y], !0); - U.__removalCount = (d.__removalCount || 0) + 1, C.insertBefore(U, R(d)); + const j = I(T[y], !0); + j.__removalCount = (d.__removalCount || 0) + 1, C.insertBefore(j, R(d)); } } return ht(d), !0; } - return d instanceof c && !(function(C) { + return d instanceof c && !function(C) { let T = _(C); - T && T.tagName || (T = { namespaceURI: Gt, tagName: "template" }); - const y = Xe(C.tagName), U = Xe(T.tagName); - return !!yi[C.namespaceURI] && (C.namespaceURI === Me ? T.namespaceURI === gt ? y === "svg" : T.namespaceURI === Be ? y === "svg" && (U === "annotation-xml" || Ne[U]) : !!Kn[y] : C.namespaceURI === Be ? T.namespaceURI === gt ? y === "math" : T.namespaceURI === Me ? y === "math" && Pe[U] : !!Gn[y] : C.namespaceURI === gt ? !(T.namespaceURI === Me && !Pe[U]) && !(T.namespaceURI === Be && !Ne[U]) && !Gn[y] && (Oa[y] || !Kn[y]) : !(oe !== "application/xhtml+xml" || !yi[C.namespaceURI])); - })(d) ? (ht(d), !0) : g !== "noscript" && g !== "noembed" && g !== "noframes" || !J(/<\/no(script|embed|frames)/i, d.innerHTML) ? (jt && d.nodeType === Co && (f = d.textContent, He([Tt, Vt, tt], ((C) => { - f = he(f, C, " "); - })), d.textContent !== f && (ce(e.removed, { element: d.cloneNode() }), d.textContent = f)), pt(K.afterSanitizeElements, d, null), !1) : (ht(d), !0); - }, Zn = function(d, f, g) { - if (qn && (f === "id" || f === "name") && (g in i || g in Ma)) return !1; - if (!(gi && !mi[f] && J(di, f))) { - if (!(Pn && J(ci, f))) { - if (!W[f] || mi[f]) { - if (!(ts(d) && (M.tagNameCheck instanceof RegExp && J(M.tagNameCheck, d) || M.tagNameCheck instanceof Function && M.tagNameCheck(d)) && (M.attributeNameCheck instanceof RegExp && J(M.attributeNameCheck, f) || M.attributeNameCheck instanceof Function && M.attributeNameCheck(f, d)) || f === "is" && M.allowCustomizedBuiltInElements && (M.tagNameCheck instanceof RegExp && J(M.tagNameCheck, g) || M.tagNameCheck instanceof Function && M.tagNameCheck(g)))) return !1; - } else if (!_i[f]) { - if (!J(F, he(g, Ie, ""))) { - if ((f !== "src" && f !== "xlink:href" && f !== "href" || d === "script" || uo(g, "data:") !== 0 || !Vn[d]) && !(Fn && !J(hi, he(g, Ie, "")))) { + T && T.tagName || (T = { namespaceURI: Jt, tagName: "template" }); + const y = si(C.tagName), j = si(T.tagName); + return !!ki[C.namespaceURI] && (C.namespaceURI === qe ? T.namespaceURI === gt ? y === "svg" : T.namespaceURI === He ? y === "svg" && (j === "annotation-xml" || $e[j]) : !!rs[y] : C.namespaceURI === He ? T.namespaceURI === gt ? y === "math" : T.namespaceURI === qe ? y === "math" && Ue[j] : !!as[y] : C.namespaceURI === gt ? !(T.namespaceURI === qe && !Ue[j]) && !(T.namespaceURI === He && !$e[j]) && !as[y] && (Ja[y] || !rs[y]) : !(ce !== "application/xhtml+xml" || !ki[C.namespaceURI])); + }(d) ? (ht(d), !0) : g !== "noscript" && g !== "noembed" && g !== "noframes" || !J(/<\/no(script|embed|frames)/i, d.innerHTML) ? (Wt && d.nodeType === jo && (b = d.textContent, ze([Tt, jt, tt], (C) => { + b = pe(b, C, " "); + }), d.textContent !== b && (ge(e.removed, { element: d.cloneNode() }), d.textContent = b)), pt(V.afterSanitizeElements, d, null), !1) : (ht(d), !0); + }, hs = function(d, b, g) { + if (Qn && (b === "id" || b === "name") && (g in i || g in Xa)) return !1; + if (!(xi && !Ei[b] && J(_i, b))) { + if (!(Jn && J(vi, b))) { + if (!D[b] || Ei[b]) { + if (!(us(d) && (N.tagNameCheck instanceof RegExp && J(N.tagNameCheck, d) || N.tagNameCheck instanceof Function && N.tagNameCheck(d)) && (N.attributeNameCheck instanceof RegExp && J(N.attributeNameCheck, b) || N.attributeNameCheck instanceof Function && N.attributeNameCheck(b, d)) || b === "is" && N.allowCustomizedBuiltInElements && (N.tagNameCheck instanceof RegExp && J(N.tagNameCheck, g) || N.tagNameCheck instanceof Function && N.tagNameCheck(g)))) return !1; + } else if (!wi[b]) { + if (!J(oe, pe(g, Me, ""))) { + if ((b !== "src" && b !== "xlink:href" && b !== "href" || d === "script" || Io(g, "data:") !== 0 || !es[d]) && !(Yn && !J(yi, pe(g, Me, "")))) { if (g) return !1; } } @@ -925,22 +933,22 @@ var Ce = (function s() { } } return !0; - }, ts = function(d) { - return d !== "annotation-xml" && Mi(d, ui); - }, es = function(d) { - pt(K.beforeSanitizeAttributes, d, null); - const { attributes: f } = d; - if (!f || Ei(d)) return; - const g = { attrName: "", attrValue: "", keepAttr: !0, allowedAttributes: W, forceKeepAttr: void 0 }; - let C = f.length; + }, us = function(d) { + return d !== "annotation-xml" && zi(d, Ai); + }, ms = function(d) { + pt(V.beforeSanitizeAttributes, d, null); + const { attributes: b } = d; + if (!b || Ri(d)) return; + const g = { attrName: "", attrValue: "", keepAttr: !0, allowedAttributes: D, forceKeepAttr: void 0 }; + let C = b.length; for (; C--; ) { - const T = f[C], { name: y, namespaceURI: U, value: vt } = T, rt = V(y), xi = vt; - let z = y === "value" ? xi : mo(xi); - if (g.attrName = rt, g.attrValue = z, g.keepAttr = !0, g.forceKeepAttr = void 0, pt(K.uponSanitizeAttribute, d, g), z = g.attrValue, !$n || rt !== "id" && rt !== "name" || (It(y, d), z = "user-content-" + z), Re && J(/((--!?|])>)|<\/(style|title|textarea)/i, z)) { + const T = b[C], { name: y, namespaceURI: j, value: yt } = T, rt = W(y), Di = yt; + let K = y === "value" ? Di : Ro(Di); + if (g.attrName = rt, g.attrValue = K, g.keepAttr = !0, g.forceKeepAttr = void 0, pt(V.uponSanitizeAttribute, d, g), K = g.attrValue, !Zn || rt !== "id" && rt !== "name" || (It(y, d), K = "user-content-" + K), Ne && J(/((--!?|])>)|<\/(style|title|textarea)/i, K)) { It(y, d); continue; } - if (rt === "attributename" && Mi(z, "href")) { + if (rt === "attributename" && zi(K, "href")) { It(y, d); continue; } @@ -949,94 +957,94 @@ var Ce = (function s() { It(y, d); continue; } - if (!Hn && J(/\/>/i, z)) { + if (!Xn && J(/\/>/i, K)) { It(y, d); continue; } - jt && He([Tt, Vt, tt], ((ns) => { - z = he(z, ns, " "); - })); - const is = V(d.nodeName); - if (Zn(is, rt, z)) { - if (S && typeof b == "object" && typeof b.getAttributeType == "function" && !U) switch (b.getAttributeType(is, rt)) { + Wt && ze([Tt, jt, tt], (ps) => { + K = pe(K, ps, " "); + }); + const gs = W(d.nodeName); + if (hs(gs, rt, K)) { + if (S && typeof f == "object" && typeof f.getAttributeType == "function" && !j) switch (f.getAttributeType(gs, rt)) { case "TrustedHTML": - z = S.createHTML(z); + K = S.createHTML(K); break; case "TrustedScriptURL": - z = S.createScriptURL(z); + K = S.createScriptURL(K); } - if (z !== xi) try { - U ? d.setAttributeNS(U, y, z) : d.setAttribute(y, z), Ei(d) ? ht(d) : ps(e.removed); + if (K !== Di) try { + j ? d.setAttributeNS(j, y, K) : d.setAttribute(y, K), Ri(d) ? ht(d) : Ts(e.removed); } catch { It(y, d); } } else It(y, d); } - pt(K.afterSanitizeAttributes, d, null); - }, Na = function d(f) { + pt(V.afterSanitizeAttributes, d, null); + }, Qa = function d(b) { let g = null; - const C = Yn(f); - for (pt(K.beforeSanitizeShadowDOM, f, null); g = C.nextNode(); ) pt(K.uponSanitizeShadowNode, g, null), Qn(g), es(g), g.content instanceof a && d(g.content); - pt(K.afterSanitizeShadowDOM, f, null); + const C = ls(b); + for (pt(V.beforeSanitizeShadowDOM, b, null); g = C.nextNode(); ) pt(V.uponSanitizeShadowNode, g, null), cs(g), ms(g), g.content instanceof a && d(g.content); + pt(V.afterSanitizeShadowDOM, b, null); }; return e.sanitize = function(d) { - let f = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, g = null, C = null, T = null, y = null; - if (vi = !d, vi && (d = ""), typeof d != "string" && !Xn(d)) { - if (typeof d.toString != "function") throw ue("toString is not a function"); - if (typeof (d = d.toString()) != "string") throw ue("dirty is not a string, aborting"); + let b = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, g = null, C = null, T = null, y = null; + if (Ti = !d, Ti && (d = ""), typeof d != "string" && !ds(d)) { + if (typeof d.toString != "function") throw fe("toString is not a function"); + if (typeof (d = d.toString()) != "string") throw fe("dirty is not a string, aborting"); } if (!e.isSupported) return d; - if (pi || Ai(f), e.removed = [], typeof d == "string" && (ae = !1), ae) { + if (Si || Ii(b), e.removed = [], typeof d == "string" && (de = !1), de) { if (d.nodeName) { - const rt = V(d.nodeName); - if (!D[rt] || re[rt]) throw ue("root node is forbidden and cannot be sanitized in-place"); + const rt = W(d.nodeName); + if (!M[rt] || le[rt]) throw fe("root node is forbidden and cannot be sanitized in-place"); } - } else if (d instanceof l) g = Jn(""), C = g.ownerDocument.importNode(d, !0), C.nodeType === Lo && C.nodeName === "BODY" || C.nodeName === "HTML" ? g = C : g.appendChild(C); + } else if (d instanceof l) g = os(""), C = g.ownerDocument.importNode(d, !0), C.nodeType === Vo && C.nodeName === "BODY" || C.nodeName === "HTML" ? g = C : g.appendChild(C); else { - if (!Wt && !jt && !kt && d.indexOf("<") === -1) return S && Oe ? S.createHTML(d) : d; - if (g = Jn(d), !g) return Wt ? null : Oe ? E : ""; + if (!zt && !Wt && !kt && d.indexOf("<") === -1) return S && Fe ? S.createHTML(d) : d; + if (g = os(d), !g) return zt ? null : Fe ? E : ""; } - g && fi && ht(g.firstChild); - const U = Yn(ae ? d : g); - for (; T = U.nextNode(); ) Qn(T), es(T), T.content instanceof a && Na(T.content); - if (ae) return d; - if (Wt) { - if (De) for (y = wt.call(g.ownerDocument); g.firstChild; ) y.appendChild(g.firstChild); + g && Li && ht(g.firstChild); + const j = ls(de ? d : g); + for (; T = j.nextNode(); ) cs(T), ms(T), T.content instanceof a && Qa(T.content); + if (de) return d; + if (zt) { + if (Pe) for (y = wt.call(g.ownerDocument); g.firstChild; ) y.appendChild(g.firstChild); else y = g; - return (W.shadowroot || W.shadowrootmode) && (y = li.call(n, y, !0)), y; + return (D.shadowroot || D.shadowrootmode) && (y = bi.call(n, y, !0)), y; } - let vt = kt ? g.outerHTML : g.innerHTML; - return kt && D["!doctype"] && g.ownerDocument && g.ownerDocument.doctype && g.ownerDocument.doctype.name && J(Qr, g.ownerDocument.doctype.name) && (vt = " -` + vt), jt && He([Tt, Vt, tt], ((rt) => { - vt = he(vt, rt, " "); - })), S && Oe ? S.createHTML(vt) : vt; + let yt = kt ? g.outerHTML : g.innerHTML; + return kt && M["!doctype"] && g.ownerDocument && g.ownerDocument.doctype && g.ownerDocument.doctype.name && J(ha, g.ownerDocument.doctype.name) && (yt = " +` + yt), Wt && ze([Tt, jt, tt], (rt) => { + yt = pe(yt, rt, " "); + }), S && Fe ? S.createHTML(yt) : yt; }, e.setConfig = function() { - Ai(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), pi = !0; + Ii(arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}), Si = !0; }, e.clearConfig = function() { - Jt = null, pi = !1; - }, e.isValidAttribute = function(d, f, g) { - Jt || Ai({}); - const C = V(d), T = V(f); - return Zn(C, T, g); - }, e.addHook = function(d, f) { - typeof f == "function" && ce(K[d], f); - }, e.removeHook = function(d, f) { - if (f !== void 0) { - const g = co(K[d], f); - return g === -1 ? void 0 : ho(K[d], g, 1)[0]; + Yt = null, Si = !1; + }, e.isValidAttribute = function(d, b, g) { + Yt || Ii({}); + const C = W(d), T = W(b); + return hs(C, T, g); + }, e.addHook = function(d, b) { + typeof b == "function" && ge(V[d], b); + }, e.removeHook = function(d, b) { + if (b !== void 0) { + const g = To(V[d], b); + return g === -1 ? void 0 : ko(V[d], g, 1)[0]; } - return ps(K[d]); + return Ts(V[d]); }, e.removeHooks = function(d) { - K[d] = []; + V[d] = []; }, e.removeAllHooks = function() { - K = { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; + V = { afterSanitizeAttributes: [], afterSanitizeElements: [], afterSanitizeShadowDOM: [], beforeSanitizeAttributes: [], beforeSanitizeElements: [], beforeSanitizeShadowDOM: [], uponSanitizeAttribute: [], uponSanitizeElement: [], uponSanitizeShadowNode: [] }; }, e; -})(); -Ce.addHook("uponSanitizeAttribute", (function(s, t) { +}(); +Ie.addHook("uponSanitizeAttribute", function(s, t) { /^data-trix-/.test(t.attrName) && (t.forceKeepAttr = !0); -})); -const Ro = "style href src width height language class".split(" "), Do = "javascript:".split(" "), Oo = "script iframe form noscript".split(" "); -class si extends H { +}); +const Jo = "style href src width height language class".split(" "), Yo = "javascript:".split(" "), Xo = "script iframe form noscript".split(" "); +class mi extends q { static setHTML(t, e, i) { const n = new this(e, i).sanitize(), r = n.getHTML ? n.getHTML() : n.outerHTML; t.innerHTML = r; @@ -1047,12 +1055,12 @@ class si extends H { } constructor(t) { let { allowedAttributes: e, forbiddenProtocols: i, forbiddenElements: n, purifyOptions: r } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - super(...arguments), this.allowedAttributes = e || Ro, this.forbiddenProtocols = i || Do, this.forbiddenElements = n || Oo, this.purifyOptions = r || {}, this.body = Bo(t); + super(...arguments), this.allowedAttributes = e || Jo, this.forbiddenProtocols = i || Yo, this.forbiddenElements = n || Xo, this.purifyOptions = r || {}, this.body = Qo(t); } sanitize() { this.sanitizeElements(), this.normalizeListElementNesting(); - const t = Object.assign({}, Mr, this.purifyOptions); - return Ce.setConfig(t), this.body = Ce.sanitize(this.body), this.body; + const t = Object.assign({}, Gr, this.purifyOptions); + return Ie.setConfig(t), this.body = Ie.sanitize(this.body), this.body; } getHTML() { return this.body.innerHTML; @@ -1061,7 +1069,7 @@ class si extends H { return this.body; } sanitizeElements() { - const t = Qe(this.body), e = []; + const t = ri(this.body), e = []; for (; t.nextNode(); ) { const i = t.currentNode; switch (i.nodeType) { @@ -1072,39 +1080,39 @@ class si extends H { e.push(i); } } - return e.forEach(((i) => Ct(i))), this.body; + return e.forEach((i) => Ct(i)), this.body; } sanitizeElement(t) { - return t.hasAttribute("href") && this.forbiddenProtocols.includes(t.protocol) && t.removeAttribute("href"), Array.from(t.attributes).forEach(((e) => { + return t.hasAttribute("href") && this.forbiddenProtocols.includes(t.protocol) && t.removeAttribute("href"), Array.from(t.attributes).forEach((e) => { let { name: i } = e; this.allowedAttributes.includes(i) || i.indexOf("data-trix") === 0 || t.removeAttribute(i); - })), t; + }), t; } normalizeListElementNesting() { - return Array.from(this.body.querySelectorAll("ul,ol")).forEach(((t) => { + return Array.from(this.body.querySelectorAll("ul,ol")).forEach((t) => { const e = t.previousElementSibling; e && Y(e) === "li" && e.appendChild(t); - })), this.body; + }), this.body; } elementIsRemovable(t) { - if (t?.nodeType === Node.ELEMENT_NODE) return this.elementIsForbidden(t) || this.elementIsntSerializable(t); + if ((t == null ? void 0 : t.nodeType) === Node.ELEMENT_NODE) return this.elementIsForbidden(t) || this.elementIsntSerializable(t); } elementIsForbidden(t) { return this.forbiddenElements.includes(Y(t)); } elementIsntSerializable(t) { - return t.getAttribute("data-trix-serialize") === "false" && !Mt(t); + return t.getAttribute("data-trix-serialize") === "false" && !Nt(t); } } -const Bo = function() { +const Qo = function() { let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; s = s.replace(/<\/html[^>]*>[^]*$/i, ""); const t = document.implementation.createHTMLDocument(""); - return t.documentElement.innerHTML = s, Array.from(t.head.querySelectorAll("style")).forEach(((e) => { + return t.documentElement.innerHTML = s, Array.from(t.head.querySelectorAll("style")).forEach((e) => { t.body.appendChild(e); - })), t.body; -}, { css: yt } = ke; -class On extends $t { + }), t.body; +}, { css: At } = Be; +class zn extends Ut { constructor() { super(...arguments), this.attachment = this.object, this.attachment.uploadProgressDelegate = this, this.attachmentPiece = this.options.piece; } @@ -1114,45 +1122,45 @@ class On extends $t { createNodes() { let t; const e = t = x({ tagName: "figure", className: this.getClassName(), data: this.getData(), editable: !1 }), i = this.getHref(); - return i && (t = x({ tagName: "a", editable: !1, attributes: { href: i, tabindex: -1 } }), e.appendChild(t)), this.attachment.hasContent() ? si.setHTML(t, this.attachment.getContent()) : this.createContentNodes().forEach(((n) => { + return i && (t = x({ tagName: "a", editable: !1, attributes: { href: i, tabindex: -1 } }), e.appendChild(t)), this.attachment.hasContent() ? mi.setHTML(t, this.attachment.getContent()) : this.createContentNodes().forEach((n) => { t.appendChild(n); - })), t.appendChild(this.createCaptionElement()), this.attachment.isPending() && (this.progressElement = x({ tagName: "progress", attributes: { class: yt.attachmentProgress, value: this.attachment.getUploadProgress(), max: 100 }, data: { trixMutable: !0, trixStoreKey: ["progressElement", this.attachment.id].join("/") } }), e.appendChild(this.progressElement)), [Es("left"), e, Es("right")]; + }), t.appendChild(this.createCaptionElement()), this.attachment.isPending() && (this.progressElement = x({ tagName: "progress", attributes: { class: At.attachmentProgress, value: this.attachment.getUploadProgress(), max: 100 }, data: { trixMutable: !0, trixStoreKey: ["progressElement", this.attachment.id].join("/") } }), e.appendChild(this.progressElement)), [Ms("left"), e, Ms("right")]; } createCaptionElement() { - const t = x({ tagName: "figcaption", className: yt.attachmentCaption }), e = this.attachmentPiece.getCaption(); - if (e) t.classList.add("".concat(yt.attachmentCaption, "--edited")), t.textContent = e; + const t = x({ tagName: "figcaption", className: At.attachmentCaption }), e = this.attachmentPiece.getCaption(); + if (e) t.classList.add("".concat(At.attachmentCaption, "--edited")), t.textContent = e; else { let i, n; const r = this.getCaptionConfig(); if (r.name && (i = this.attachment.getFilename()), r.size && (n = this.attachment.getFormattedFilesize()), i) { - const a = x({ tagName: "span", className: yt.attachmentName, textContent: i }); + const a = x({ tagName: "span", className: At.attachmentName, textContent: i }); t.appendChild(a); } if (n) { i && t.appendChild(document.createTextNode(" ")); - const a = x({ tagName: "span", className: yt.attachmentSize, textContent: n }); + const a = x({ tagName: "span", className: At.attachmentSize, textContent: n }); t.appendChild(a); } } return t; } getClassName() { - const t = [yt.attachment, "".concat(yt.attachment, "--").concat(this.attachment.getType())], e = this.attachment.getExtension(); - return e && t.push("".concat(yt.attachment, "--").concat(e)), t.join(" "); + const t = [At.attachment, "".concat(At.attachment, "--").concat(this.attachment.getType())], e = this.attachment.getExtension(); + return e && t.push("".concat(At.attachment, "--").concat(e)), t.join(" "); } getData() { const t = { trixAttachment: JSON.stringify(this.attachment), trixContentType: this.attachment.getContentType(), trixId: this.attachment.id }, { attributes: e } = this.attachmentPiece; return e.isEmpty() || (t.trixAttributes = JSON.stringify(e)), this.attachment.isPending() && (t.trixSerialize = !1), t; } getHref() { - if (!Mo(this.attachment.getContent(), "a")) { + if (!Zo(this.attachment.getContent(), "a")) { const t = this.attachment.getHref(); - if (t && Ce.isValidAttribute("a", "href", t)) return t; + if (t && Ie.isValidAttribute("a", "href", t)) return t; } } getCaptionConfig() { var t; - const e = this.attachment.getType(), i = Wr((t = Sn[e]) === null || t === void 0 ? void 0 : t.caption); + const e = this.attachment.getType(), i = sa((t = Pn[e]) === null || t === void 0 ? void 0 : t.caption); return e === "file" && (i.name = !0), i; } findProgressElement() { @@ -1164,11 +1172,11 @@ class On extends $t { e && (e.value = t); } } -const Es = (s) => x({ tagName: "span", textContent: ni, data: { trixCursorTarget: s, trixSerialize: !1 } }), Mo = function(s, t) { +const Ms = (s) => x({ tagName: "span", textContent: ui, data: { trixCursorTarget: s, trixSerialize: !1 } }), Zo = function(s, t) { const e = x("div"); - return si.setHTML(e, s || ""), e.querySelector(t); + return mi.setHTML(e, s || ""), e.querySelector(t); }; -class Zr extends On { +class ua extends zn { constructor() { super(...arguments), this.attachment.previewDelegate = this; } @@ -1199,7 +1207,7 @@ class Zr extends On { return this.refresh(this.image), this.refresh(); } } -class ta extends $t { +class ma extends Ut { constructor() { super(...arguments), this.piece = this.object, this.attributes = this.piece.getAttributes(), this.textConfig = this.options.textConfig, this.context = this.options.context, this.piece.attachment ? this.attachment = this.piece.attachment : this.string = this.piece.toString(); } @@ -1207,21 +1215,21 @@ class ta extends $t { let t = this.attachment ? this.createAttachmentNodes() : this.createStringNodes(); const e = this.createElement(); if (e) { - const i = (function(n) { + const i = function(n) { for (; (r = n) !== null && r !== void 0 && r.firstElementChild; ) { var r; n = n.firstElementChild; } return n; - })(e); - Array.from(t).forEach(((n) => { + }(e); + Array.from(t).forEach((n) => { i.appendChild(n); - })), t = [e]; + }), t = [e]; } return t; } createAttachmentNodes() { - const t = this.attachment.isPreviewable() ? Zr : On; + const t = this.attachment.isPreviewable() ? ua : zn; return this.createChildView(t, this.piece.attachment, { piece: this.piece }).getNodes(); } createStringNodes() { @@ -1249,7 +1257,7 @@ class ta extends $t { const n = {}; for (e in this.attributes) { i = this.attributes[e]; - const a = gn(e); + const a = Ln(e); if (a) { if (a.tagName) { var r; @@ -1264,7 +1272,7 @@ class ta extends $t { } createContainerElement() { for (const t in this.attributes) { - const e = this.attributes[t], i = gn(t); + const e = this.attributes[t], i = Ln(t); if (i && i.groupTagName) { const n = {}; return n[t] = e, x(i.groupTagName, n); @@ -1275,27 +1283,27 @@ class ta extends $t { return this.context.isLast && (t = t.replace(/\ $/, St)), t = t.replace(/(\S)\ {3}(\S)/g, "$1 ".concat(St, " $2")).replace(/\ {2}/g, "".concat(St, " ")).replace(/\ {2}/g, " ".concat(St)), (this.context.isFirst || this.context.followsWhitespace) && (t = t.replace(/^\ /, St)), t; } } -class ea extends $t { +class ga extends Ut { constructor() { super(...arguments), this.text = this.object, this.textConfig = this.options.textConfig; } createNodes() { - const t = [], e = Dn.groupObjects(this.getPieces()), i = e.length - 1; + const t = [], e = Wn.groupObjects(this.getPieces()), i = e.length - 1; for (let r = 0; r < e.length; r++) { const a = e[r], o = {}; - r === 0 && (o.isFirst = !0), r === i && (o.isLast = !0), No(n) && (o.followsWhitespace = !0); - const l = this.findOrCreateCachedChildView(ta, a, { textConfig: this.textConfig, context: o }); + r === 0 && (o.isFirst = !0), r === i && (o.isLast = !0), tl(n) && (o.followsWhitespace = !0); + const l = this.findOrCreateCachedChildView(ma, a, { textConfig: this.textConfig, context: o }); t.push(...Array.from(l.getNodes() || [])); var n = a; } return t; } getPieces() { - return Array.from(this.text.getPieces()).filter(((t) => !t.hasAttribute("blockBreak"))); + return Array.from(this.text.getPieces()).filter((t) => !t.hasAttribute("blockBreak")); } } -const No = (s) => /\s$/.test(s?.toString()), { css: xs } = ke; -class ia extends $t { +const tl = (s) => /\s$/.test(s == null ? void 0 : s.toString()), { css: Ns } = Be; +class pa extends Ut { constructor() { super(...arguments), this.block = this.object, this.attributes = this.block.getAttributes(); } @@ -1304,7 +1312,7 @@ class ia extends $t { if (this.block.isEmpty()) t.push(x("br")); else { var e; - const i = (e = P(this.block.getLastAttribute())) === null || e === void 0 ? void 0 : e.text, n = this.findOrCreateCachedChildView(ea, this.block.text, { textConfig: i }); + const i = (e = F(this.block.getLastAttribute())) === null || e === void 0 ? void 0 : e.text, n = this.findOrCreateCachedChildView(ga, this.block.text, { textConfig: i }); t.push(...Array.from(n.getNodes() || [])), this.shouldAddExtraNewlineElement() && t.push(x("br")); } if (this.attributes.length) return t; @@ -1313,51 +1321,51 @@ class ia extends $t { const { tagName: n } = X.default; this.block.isRTL() && (i = { dir: "rtl" }); const r = x({ tagName: n, attributes: i }); - return t.forEach(((a) => r.appendChild(a))), [r]; + return t.forEach((a) => r.appendChild(a)), [r]; } } createContainerElement(t) { const e = {}; let i; - const n = this.attributes[t], { tagName: r, htmlAttributes: a = [] } = P(n); + const n = this.attributes[t], { tagName: r, htmlAttributes: a = [] } = F(n); if (t === 0 && this.block.isRTL() && Object.assign(e, { dir: "rtl" }), n === "attachmentGallery") { const o = this.block.getBlockBreakPosition(); - i = "".concat(xs.attachmentGallery, " ").concat(xs.attachmentGallery, "--").concat(o); + i = "".concat(Ns.attachmentGallery, " ").concat(Ns.attachmentGallery, "--").concat(o); } - return Object.entries(this.block.htmlAttributes).forEach(((o) => { + return Object.entries(this.block.htmlAttributes).forEach((o) => { let [l, c] = o; a.includes(l) && (e[l] = c); - })), x({ tagName: r, className: i, attributes: e }); + }), x({ tagName: r, className: i, attributes: e }); } shouldAddExtraNewlineElement() { return /\n\n$/.test(this.block.toString()); } } -class ri extends $t { +class gi extends Ut { static render(t) { const e = x("div"), i = new this(t, { element: e }); return i.render(), i.sync(), e; } constructor() { - super(...arguments), this.element = this.options.element, this.elementStore = new so(), this.setDocument(this.object); + super(...arguments), this.element = this.options.element, this.elementStore = new xo(), this.setDocument(this.object); } setDocument(t) { t.isEqualTo(this.document) || (this.document = this.object = t); } render() { if (this.childViews = [], this.shadowElement = x("div"), !this.document.isEmpty()) { - const t = Dn.groupObjects(this.document.getBlocks(), { asTree: !0 }); - Array.from(t).forEach(((e) => { - const i = this.findOrCreateCachedChildView(ia, e); - Array.from(i.getNodes()).map(((n) => this.shadowElement.appendChild(n))); - })); + const t = Wn.groupObjects(this.document.getBlocks(), { asTree: !0 }); + Array.from(t).forEach((e) => { + const i = this.findOrCreateCachedChildView(pa, e); + Array.from(i.getNodes()).map((n) => this.shadowElement.appendChild(n)); + }); } } isSynced() { - return Po(this.shadowElement, this.element); + return el(this.shadowElement, this.element); } sync() { - const t = Fr("trix-before-render", { cancelable: !1, attributes: { render: (i, n) => { + const t = Xr("trix-before-render", { cancelable: !1, attributes: { render: (i, n) => { for (; i.lastChild; ) i.removeChild(i.lastChild); i.appendChild(n); } } }); @@ -1366,21 +1374,21 @@ class ri extends $t { return t.render(this.element, e), this.didSync(); } didSync() { - return this.elementStore.reset(Ss(this.element)), kn((() => this.garbageCollectCachedViews())); + return this.elementStore.reset(Ps(this.element)), Un(() => this.garbageCollectCachedViews()); } createDocumentFragmentForSync() { const t = document.createDocumentFragment(); - return Array.from(this.shadowElement.childNodes).forEach(((e) => { + return Array.from(this.shadowElement.childNodes).forEach((e) => { t.appendChild(e.cloneNode(!0)); - })), Array.from(Ss(t)).forEach(((e) => { + }), Array.from(Ps(t)).forEach((e) => { const i = this.elementStore.remove(e); i && e.parentNode.replaceChild(i, e); - })), t; + }), t; } } -const Ss = (s) => s.querySelectorAll("[data-trix-store-key]"), Po = (s, t) => Ls(s.innerHTML) === Ls(t.innerHTML), Ls = (s) => s.replace(/ /g, " "); -function Fo(s) { - var t = (function(e, i) { +const Ps = (s) => s.querySelectorAll("[data-trix-store-key]"), el = (s, t) => Fs(s.innerHTML) === Fs(t.innerHTML), Fs = (s) => s.replace(/ /g, " "); +function il(s) { + var t = function(e, i) { if (typeof e != "object" || !e) return e; var n = e[Symbol.toPrimitive]; if (n !== void 0) { @@ -1389,43 +1397,43 @@ function Fo(s) { throw new TypeError("@@toPrimitive must return a primitive value."); } return (i === "string" ? String : Number)(e); - })(s, "string"); + }(s, "string"); return typeof t == "symbol" ? t : String(t); } function G(s, t, e) { - return (t = Fo(t)) in s ? Object.defineProperty(s, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : s[t] = e, s; + return (t = il(t)) in s ? Object.defineProperty(s, t, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : s[t] = e, s; } function w(s, t) { - return Ho(s, na(s, t, "get")); + return nl(s, fa(s, t, "get")); } -function Ae(s, t, e) { - return qo(s, na(s, t, "set"), e), e; +function Le(s, t, e) { + return sl(s, fa(s, t, "set"), e), e; } -function na(s, t, e) { +function fa(s, t, e) { if (!t.has(s)) throw new TypeError("attempted to " + e + " private field on non-instance"); return t.get(s); } -function Ho(s, t) { +function nl(s, t) { return t.get ? t.get.call(s) : t.value; } -function qo(s, t, e) { +function sl(s, t, e) { if (t.set) t.set.call(s, e); else { if (!t.writable) throw new TypeError("attempted to set read only private field"); t.value = e; } } -function $e(s, t, e) { +function Ge(s, t, e) { if (!t.has(s)) throw new TypeError("attempted to get private field on non-instance"); return e; } -function sa(s, t) { +function ba(s, t) { if (t.has(s)) throw new TypeError("Cannot initialize the same private elements twice on an object"); } -function ee(s, t, e) { - sa(s, t), t.set(s, e); +function ne(s, t, e) { + ba(s, t), t.set(s, e); } -class Ut extends qt { +class Vt extends $t { static registerType(t, e) { e.type = t, this.types[t] = e; } @@ -1498,8 +1506,8 @@ class Ut extends qt { return !1; } } -G(Ut, "types", {}); -class ra extends ti { +G(Vt, "types", {}); +class _a extends oi { constructor(t) { super(...arguments), this.url = t; } @@ -1508,7 +1516,7 @@ class ra extends ti { e.onload = () => (e.width = this.width = e.naturalWidth, e.height = this.height = e.naturalHeight, t(!0, e)), e.onerror = () => t(!1), e.src = this.url; } } -class se extends qt { +class ae extends $t { static attachmentForFile(t) { const e = new this(this.attributesForFile(t)); return e.setFile(t), e; @@ -1548,7 +1556,7 @@ class se extends qt { return this.file != null && !(this.getURL() || this.getHref()); } isPreviewable() { - return this.attributes.has("previewable") ? this.attributes.get("previewable") : se.previewablePattern.test(this.getContentType()); + return this.attributes.has("previewable") ? this.attributes.get("previewable") : ae.previewablePattern.test(this.getContentType()); } getType() { return this.hasContent() ? "content" : this.isPreviewable() ? "preview" : "file"; @@ -1567,7 +1575,7 @@ class se extends qt { } getFormattedFilesize() { const t = this.attributes.get("filesize"); - return typeof t == "number" ? Nr.formatter(t) : ""; + return typeof t == "number" ? Jr.formatter(t) : ""; } getExtension() { var t; @@ -1628,16 +1636,16 @@ class se extends qt { } preload(t, e) { if (t && t !== this.getPreviewURL()) - return this.preloadingURL = t, new ra(t).then(((i) => { + return this.preloadingURL = t, new _a(t).then((i) => { let { width: n, height: r } = i; - return this.getWidth() && this.getHeight() || this.setAttributes({ width: n, height: r }), this.preloadingURL = null, this.setPreviewURL(t), e?.(); - })).catch((() => (this.preloadingURL = null, e?.()))); + return this.getWidth() && this.getHeight() || this.setAttributes({ width: n, height: r }), this.preloadingURL = null, this.setPreviewURL(t), e == null ? void 0 : e(); + }).catch(() => (this.preloadingURL = null, e == null ? void 0 : e())); } } -G(se, "previewablePattern", /^image(\/(gif|png|webp|jpe?g)|$)/); -class ie extends Ut { +G(ae, "previewablePattern", /^image(\/(gif|png|webp|jpe?g)|$)/); +class se extends Vt { static fromJSON(t) { - return new this(se.fromJSON(t.attachment), t.attributes); + return new this(ae.fromJSON(t.attachment), t.attributes); } constructor(t) { super(...arguments), this.attachment = t, this.length = 1, this.ensureAttachmentExclusivelyHasAttribute("href"), this.attachment.hasContent() || this.removeProhibitedAttributes(); @@ -1646,7 +1654,7 @@ class ie extends Ut { this.hasAttribute(t) && (this.attachment.hasAttribute(t) || this.attachment.setAttributes(this.attributes.slice([t])), this.attributes = this.attributes.remove(t)); } removeProhibitedAttributes() { - const t = this.attributes.slice(ie.permittedAttributes); + const t = this.attributes.slice(se.permittedAttributes); t.isEqualTo(this.attributes) || (this.attributes = t); } getValue() { @@ -1676,8 +1684,8 @@ class ie extends Ut { return JSON.stringify(this.toString()); } } -G(ie, "permittedAttributes", ["caption", "presentation"]), Ut.registerType("attachment", ie); -class Bn extends Ut { +G(se, "permittedAttributes", ["caption", "presentation"]), Vt.registerType("attachment", se); +class Kn extends Vt { static fromJSON(t) { return new this(t.string, t.attributes); } @@ -1714,8 +1722,8 @@ class Bn extends Ut { return t.length > 15 && (t = t.slice(0, 14) + "…"), JSON.stringify(t.toString()); } } -Ut.registerType("string", Bn); -class ei extends qt { +Vt.registerType("string", Kn); +class li extends $t { static box(t) { return t instanceof this ? t : new this(t); } @@ -1728,10 +1736,10 @@ class ei extends qt { } splice() { for (var t = arguments.length, e = new Array(t), i = 0; i < t; i++) e[i] = arguments[i]; - return new this.constructor(Tn(this.objects, ...e)); + return new this.constructor($n(this.objects, ...e)); } eachObject(t) { - return this.objects.map(((e, i) => t(e, i))); + return this.objects.map((e, i) => t(e, i)); } insertObjectAtIndex(t, e) { return this.splice(e, 0, t); @@ -1760,7 +1768,7 @@ class ei extends qt { return new this.constructor(e.slice(i, n + 1)); } selectSplittableList(t) { - const e = this.objects.filter(((i) => t(i))); + const e = this.objects.filter((i) => t(i)); return new this.constructor(e); } removeObjectsInRange(t) { @@ -1768,12 +1776,12 @@ class ei extends qt { return new this.constructor(e).splice(i, n - i + 1); } transformObjectsInRange(t, e) { - const [i, n, r] = this.splitObjectsAtRange(t), a = i.map(((o, l) => n <= l && l <= r ? e(o) : o)); + const [i, n, r] = this.splitObjectsAtRange(t), a = i.map((o, l) => n <= l && l <= r ? e(o) : o); return new this.constructor(a); } splitObjectsAtRange(t) { - let e, [i, n, r] = this.splitObjectAtPosition(Uo(t)); - return [i, e] = new this.constructor(i).splitObjectAtPosition(Vo(t) + r), [i, n, e - 1]; + let e, [i, n, r] = this.splitObjectAtPosition(al(t)); + return [i, e] = new this.constructor(i).splitObjectAtPosition(ol(t) + r), [i, n, e - 1]; } getObjectAtPosition(t) { const { index: e } = this.findIndexAndOffsetAtPosition(t); @@ -1793,10 +1801,10 @@ class ei extends qt { consolidate() { const t = []; let e = this.objects[0]; - return this.objects.slice(1).forEach(((i) => { + return this.objects.slice(1).forEach((i) => { var n, r; (n = (r = e).canBeConsolidatedWith) !== null && n !== void 0 && n.call(r, i) ? e = e.consolidateWith(i) : (t.push(e), e = i); - })), e && t.push(e), new this.constructor(t); + }), e && t.push(e), new this.constructor(t); } consolidateFromIndexToIndex(t, e) { const i = this.objects.slice(0).slice(t, e + 1), n = new this.constructor(i).consolidate().toArray(); @@ -1824,7 +1832,7 @@ class ei extends qt { return i; } getEndPosition() { - return this.endPosition == null && (this.endPosition = 0, this.objects.forEach(((t) => this.endPosition += t.getLength()))), this.endPosition; + return this.endPosition == null && (this.endPosition = 0, this.objects.forEach((t) => this.endPosition += t.getLength())), this.endPosition; } toString() { return this.objects.join(""); @@ -1836,13 +1844,13 @@ class ei extends qt { return this.toArray(); } isEqualTo(t) { - return super.isEqualTo(...arguments) || $o(this.objects, t?.objects); + return super.isEqualTo(...arguments) || rl(this.objects, t == null ? void 0 : t.objects); } contentsForInspection() { - return { objects: "[".concat(this.objects.map(((t) => t.inspect())).join(", "), "]") }; + return { objects: "[".concat(this.objects.map((t) => t.inspect()).join(", "), "]") }; } } -const $o = function(s) { +const rl = function(s) { let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; if (s.length !== t.length) return !1; let e = !0; @@ -1851,22 +1859,22 @@ const $o = function(s) { e && !n.isEqualTo(t[i]) && (e = !1); } return e; -}, Uo = (s) => s[0], Vo = (s) => s[1]; -class dt extends qt { +}, al = (s) => s[0], ol = (s) => s[1]; +class dt extends $t { static textForAttachmentWithAttributes(t, e) { - return new this([new ie(t, e)]); + return new this([new se(t, e)]); } static textForStringWithAttributes(t, e) { - return new this([new Bn(t, e)]); + return new this([new Kn(t, e)]); } static fromJSON(t) { - return new this(Array.from(t).map(((e) => Ut.fromJSON(e)))); + return new this(Array.from(t).map((e) => Vt.fromJSON(e))); } constructor() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; super(...arguments); - const e = t.filter(((i) => !i.isEmpty())); - this.pieceList = new ei(e); + const e = t.filter((i) => !i.isEmpty()); + this.pieceList = new li(e); } copy() { return this.copyWithPieceList(this.pieceList); @@ -1875,7 +1883,7 @@ class dt extends qt { return new this.constructor(t.consolidate().toArray()); } copyUsingObjectMap(t) { - const e = this.getPieces().map(((i) => t.find(i) || i)); + const e = this.getPieces().map((i) => t.find(i) || i); return new this.constructor(e); } appendText(t) { @@ -1900,20 +1908,20 @@ class dt extends qt { return n[t] = e, this.addAttributesAtRange(n, i); } addAttributesAtRange(t, e) { - return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, ((i) => i.copyWithAdditionalAttributes(t)))); + return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, (i) => i.copyWithAdditionalAttributes(t))); } removeAttributeAtRange(t, e) { - return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, ((i) => i.copyWithoutAttribute(t)))); + return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, (i) => i.copyWithoutAttribute(t))); } setAttributesAtRange(t, e) { - return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, ((i) => i.copyWithAttributes(t)))); + return this.copyWithPieceList(this.pieceList.transformObjectsInRange(e, (i) => i.copyWithAttributes(t))); } getAttributesAtPosition(t) { var e; return ((e = this.pieceList.getObjectAtPosition(t)) === null || e === void 0 ? void 0 : e.getAttributes()) || {}; } getCommonAttributes() { - const t = Array.from(this.pieceList.toArray()).map(((e) => e.getAttributes())); + const t = Array.from(this.pieceList.toArray()).map((e) => e.getAttributes()); return et.fromCommonAttributesOfObjects(t).toObject(); } getCommonAttributesAtRange(t) { @@ -1943,10 +1951,10 @@ class dt extends qt { return this.getStringAtRange([e - t.length, e]) === t; } getAttachmentPieces() { - return this.pieceList.toArray().filter(((t) => !!t.attachment)); + return this.pieceList.toArray().filter((t) => !!t.attachment); } getAttachments() { - return this.getAttachmentPieces().map(((t) => t.attachment)); + return this.getAttachmentPieces().map((t) => t.attachment); } getAttachmentAndPositionById(t) { let e = 0; @@ -1995,7 +2003,7 @@ class dt extends qt { return { pieceList: this.pieceList.inspect() }; } toSerializableText() { - const t = this.pieceList.selectSplittableList(((e) => e.isSerializable())); + const t = this.pieceList.selectSplittableList((e) => e.isSerializable()); return this.copyWithPieceList(t); } toString() { @@ -2005,27 +2013,27 @@ class dt extends qt { return this.pieceList.toJSON(); } toConsole() { - return JSON.stringify(this.pieceList.toArray().map(((t) => JSON.parse(t.toConsole())))); + return JSON.stringify(this.pieceList.toArray().map((t) => JSON.parse(t.toConsole()))); } getDirection() { - return Ga(this.toString()); + return mo(this.toString()); } isRTL() { return this.getDirection() === "rtl"; } } -class ut extends qt { +class ut extends $t { static fromJSON(t) { return new this(dt.fromJSON(t.text), t.attributes, t.htmlAttributes); } constructor(t, e, i) { - super(...arguments), this.text = jo(t || new dt()), this.attributes = e || [], this.htmlAttributes = i || {}; + super(...arguments), this.text = ll(t || new dt()), this.attributes = e || [], this.htmlAttributes = i || {}; } isEmpty() { return this.text.isBlockBreak(); } isEqualTo(t) { - return !!super.isEqualTo(t) || this.text.isEqualTo(t?.text) && Ft(this.attributes, t?.attributes) && ne(this.htmlAttributes, t?.htmlAttributes); + return !!super.isEqualTo(t) || this.text.isEqualTo(t == null ? void 0 : t.text) && Ht(this.attributes, t == null ? void 0 : t.attributes) && re(this.htmlAttributes, t == null ? void 0 : t.htmlAttributes); } copyWithText(t) { return new ut(t, this.attributes, this.htmlAttributes); @@ -2044,7 +2052,7 @@ class ut extends qt { return e ? this.copyWithText(e) : this.copyWithText(this.text.copyUsingObjectMap(t)); } addAttribute(t) { - const e = this.attributes.concat(Cs(t)); + const e = this.attributes.concat(Hs(t)); return this.copyWithAttributes(e); } addHTMLAttribute(t, e) { @@ -2052,14 +2060,14 @@ class ut extends qt { return new ut(this.text, this.attributes, i); } removeAttribute(t) { - const { listAttribute: e } = P(t), i = Ts(Ts(this.attributes, t), e); + const { listAttribute: e } = F(t), i = $s($s(this.attributes, t), e); return this.copyWithAttributes(i); } removeLastAttribute() { return this.removeAttribute(this.getLastAttribute()); } getLastAttribute() { - return ws(this.attributes); + return qs(this.attributes); } getAttributes() { return this.attributes.slice(0); @@ -2077,10 +2085,10 @@ class ut extends qt { return this.getAttributeLevel() > 0; } getLastNestableAttribute() { - return ws(this.getNestableAttributes()); + return qs(this.getNestableAttributes()); } getNestableAttributes() { - return this.attributes.filter(((t) => P(t).nestable)); + return this.attributes.filter((t) => F(t).nestable); } getNestingLevel() { return this.getNestableAttributes().length; @@ -2092,25 +2100,25 @@ class ut extends qt { increaseNestingLevel() { const t = this.getLastNestableAttribute(); if (t) { - const e = this.attributes.lastIndexOf(t), i = Tn(this.attributes, e + 1, 0, ...Cs(t)); + const e = this.attributes.lastIndexOf(t), i = $n(this.attributes, e + 1, 0, ...Hs(t)); return this.copyWithAttributes(i); } return this; } getListItemAttributes() { - return this.attributes.filter(((t) => P(t).listAttribute)); + return this.attributes.filter((t) => F(t).listAttribute); } isListItem() { var t; - return (t = P(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.listAttribute; + return (t = F(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.listAttribute; } isTerminalBlock() { var t; - return (t = P(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.terminal; + return (t = F(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.terminal; } breaksOnReturn() { var t; - return (t = P(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.breakOnReturn; + return (t = F(this.getLastAttribute())) === null || t === void 0 ? void 0 : t.breakOnReturn; } findLineBreakInDirectionFromPosition(t, e) { const i = this.toString(); @@ -2160,49 +2168,49 @@ class ut extends qt { return this.text.getLength() - 1; } getTextWithoutBlockBreak() { - return aa(this.text) ? this.text.getTextAtRange([0, this.getBlockBreakPosition()]) : this.text.copy(); + return va(this.text) ? this.text.getTextAtRange([0, this.getBlockBreakPosition()]) : this.text.copy(); } canBeGrouped(t) { return this.attributes[t]; } canBeGroupedWith(t, e) { const i = t.getAttributes(), n = i[e], r = this.attributes[e]; - return r === n && !(P(r).group === !1 && !(() => { - if (!Fe) { - Fe = []; + return r === n && !(F(r).group === !1 && !(() => { + if (!We) { + We = []; for (const a in X) { const { listAttribute: o } = X[a]; - o != null && Fe.push(o); + o != null && We.push(o); } } - return Fe; + return We; })().includes(i[e + 1])) && (this.getDirection() === t.getDirection() || t.isEmpty()); } } -const jo = function(s) { - return s = Wo(s), s = Ko(s); -}, Wo = function(s) { +const ll = function(s) { + return s = dl(s), s = hl(s); +}, dl = function(s) { let t = !1; const e = s.getPieces(); let i = e.slice(0, e.length - 1); const n = e[e.length - 1]; - return n ? (i = i.map(((r) => r.isBlockBreak() ? (t = !0, Go(r)) : r)), t ? new dt([...i, n]) : s) : s; -}, zo = dt.textForStringWithAttributes(` -`, { blockBreak: !0 }), Ko = function(s) { - return aa(s) ? s : s.appendText(zo); -}, aa = function(s) { + return n ? (i = i.map((r) => r.isBlockBreak() ? (t = !0, ul(r)) : r), t ? new dt([...i, n]) : s) : s; +}, cl = dt.textForStringWithAttributes(` +`, { blockBreak: !0 }), hl = function(s) { + return va(s) ? s : s.appendText(cl); +}, va = function(s) { const t = s.getLength(); return t === 0 ? !1 : s.getTextAtRange([t - 1, t]).isBlockBreak(); -}, Go = (s) => s.copyWithoutAttribute("blockBreak"), Cs = function(s) { - const { listAttribute: t } = P(s); +}, ul = (s) => s.copyWithoutAttribute("blockBreak"), Hs = function(s) { + const { listAttribute: t } = F(s); return t ? [t, s] : [s]; -}, ws = (s) => s.slice(-1)[0], Ts = function(s, t) { +}, qs = (s) => s.slice(-1)[0], $s = function(s, t) { const e = s.lastIndexOf(t); - return e === -1 ? s : Tn(s, e, 1); + return e === -1 ? s : $n(s, e, 1); }; -class nt extends qt { +class nt extends $t { static fromJSON(t) { - return new this(Array.from(t).map(((e) => ut.fromJSON(e)))); + return new this(Array.from(t).map((e) => ut.fromJSON(e))); } static fromString(t, e) { const i = dt.textForStringWithAttributes(t, e); @@ -2210,7 +2218,7 @@ class nt extends qt { } constructor() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; - super(...arguments), t.length === 0 && (t = [new ut()]), this.blockList = ei.box(t); + super(...arguments), t.length === 0 && (t = [new ut()]), this.blockList = li.box(t); } isEmpty() { const t = this.getBlockAtIndex(0); @@ -2221,19 +2229,19 @@ class nt extends qt { return new this.constructor(t); } copyUsingObjectsFromDocument(t) { - const e = new no(t.getObjects()); + const e = new Eo(t.getObjects()); return this.copyUsingObjectMap(e); } copyUsingObjectMap(t) { - const e = this.getBlocks().map(((i) => t.find(i) || i.copyUsingObjectMap(t))); + const e = this.getBlocks().map((i) => t.find(i) || i.copyUsingObjectMap(t)); return new this.constructor(e); } copyWithBaseBlockAttributes() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; - const e = this.getBlocks().map(((i) => { + const e = this.getBlocks().map((i) => { const n = t.concat(i.getAttributes()); return i.copyWithAttributes(n); - })); + }); return new this.constructor(e); } replaceBlock(t, e) { @@ -2247,18 +2255,18 @@ class nt extends qt { const { index: r, offset: a } = this.locationFromPosition(n); let o = this; const l = this.getBlockAtPosition(n); - return _t(e) && l.isEmpty() && !l.hasAttributes() ? o = new this.constructor(o.blockList.removeObjectAtIndex(r)) : l.getBlockBreakPosition() === a && n++, o = o.removeTextAtRange(e), new this.constructor(o.blockList.insertSplittableListAtPosition(i, n)); + return vt(e) && l.isEmpty() && !l.hasAttributes() ? o = new this.constructor(o.blockList.removeObjectAtIndex(r)) : l.getBlockBreakPosition() === a && n++, o = o.removeTextAtRange(e), new this.constructor(o.blockList.insertSplittableListAtPosition(i, n)); } mergeDocumentAtRange(t, e) { let i, n; e = k(e); const [r] = e, a = this.locationFromPosition(r), o = this.getBlockAtIndex(a.index).getAttributes(), l = t.getBaseBlockAttributes(), c = o.slice(-l.length); - if (Ft(l, c)) { + if (Ht(l, c)) { const p = o.slice(0, -l.length); i = t.copyWithBaseBlockAttributes(p); } else i = t.copy({ consolidateBlocks: !0 }).copyWithBaseBlockAttributes(o); const u = i.getBlockCount(), m = i.getBlockAtIndex(0); - if (Ft(o, m.getAttributes())) { + if (Ht(o, m.getAttributes())) { const p = m.getTextWithoutBlockBreak(); if (n = this.insertTextAtRange(p, e), u > 1) { i = new this.constructor(i.getBlocks().slice(1)); @@ -2271,22 +2279,22 @@ class nt extends qt { insertTextAtRange(t, e) { e = k(e); const [i] = e, { index: n, offset: r } = this.locationFromPosition(i), a = this.removeTextAtRange(e); - return new this.constructor(a.blockList.editObjectAtIndex(n, ((o) => o.copyWithText(o.text.insertTextAtPosition(t, r))))); + return new this.constructor(a.blockList.editObjectAtIndex(n, (o) => o.copyWithText(o.text.insertTextAtPosition(t, r)))); } removeTextAtRange(t) { let e; t = k(t); const [i, n] = t; - if (_t(t)) return this; + if (vt(t)) return this; const [r, a] = Array.from(this.locationRangeFromRange(t)), o = r.index, l = r.offset, c = this.getBlockAtIndex(o), u = a.index, m = a.offset, p = this.getBlockAtIndex(u); if (n - i == 1 && c.getBlockBreakPosition() === l && p.getBlockBreakPosition() !== m && p.text.getStringAtPosition(m) === ` -`) e = this.blockList.editObjectAtIndex(u, ((h) => h.copyWithText(h.text.removeTextAtRange([m, m + 1])))); +`) e = this.blockList.editObjectAtIndex(u, (h) => h.copyWithText(h.text.removeTextAtRange([m, m + 1]))); else { let h; - const b = c.text.getTextAtRange([0, l]), A = p.text.getTextAtRange([m, p.getLength()]), I = b.appendText(A); + const f = c.text.getTextAtRange([0, l]), A = p.text.getTextAtRange([m, p.getLength()]), I = f.appendText(A); h = o !== u && l === 0 && c.getAttributeLevel() >= p.getAttributeLevel() ? p.copyWithText(I) : c.copyWithText(I); - const q = u + 1 - o; - e = this.blockList.splice(o, q, h); + const $ = u + 1 - o; + e = this.blockList.splice(o, $, h); } return new this.constructor(e); } @@ -2303,23 +2311,23 @@ class nt extends qt { } addAttributeAtRange(t, e, i) { let { blockList: n } = this; - return this.eachBlockAtRange(i, ((r, a, o) => n = n.editObjectAtIndex(o, (function() { - return P(t) ? r.addAttribute(t, e) : a[0] === a[1] ? r : r.copyWithText(r.text.addAttributeAtRange(t, e, a)); - })))), new this.constructor(n); + return this.eachBlockAtRange(i, (r, a, o) => n = n.editObjectAtIndex(o, function() { + return F(t) ? r.addAttribute(t, e) : a[0] === a[1] ? r : r.copyWithText(r.text.addAttributeAtRange(t, e, a)); + })), new this.constructor(n); } addAttribute(t, e) { let { blockList: i } = this; - return this.eachBlock(((n, r) => i = i.editObjectAtIndex(r, (() => n.addAttribute(t, e))))), new this.constructor(i); + return this.eachBlock((n, r) => i = i.editObjectAtIndex(r, () => n.addAttribute(t, e))), new this.constructor(i); } removeAttributeAtRange(t, e) { let { blockList: i } = this; - return this.eachBlockAtRange(e, (function(n, r, a) { - P(t) ? i = i.editObjectAtIndex(a, (() => n.removeAttribute(t))) : r[0] !== r[1] && (i = i.editObjectAtIndex(a, (() => n.copyWithText(n.text.removeAttributeAtRange(t, r))))); - })), new this.constructor(i); + return this.eachBlockAtRange(e, function(n, r, a) { + F(t) ? i = i.editObjectAtIndex(a, () => n.removeAttribute(t)) : r[0] !== r[1] && (i = i.editObjectAtIndex(a, () => n.copyWithText(n.text.removeAttributeAtRange(t, r)))); + }), new this.constructor(i); } updateAttributesForAttachment(t, e) { const i = this.getRangeOfAttachment(e), [n] = Array.from(i), { index: r } = this.locationFromPosition(n), a = this.getTextAtIndex(r); - return new this.constructor(this.blockList.editObjectAtIndex(r, ((o) => o.copyWithText(a.updateAttributesForAttachment(t, e))))); + return new this.constructor(this.blockList.editObjectAtIndex(r, (o) => o.copyWithText(a.updateAttributesForAttachment(t, e)))); } removeAttributeForAttachment(t, e) { const i = this.getRangeOfAttachment(e); @@ -2333,13 +2341,13 @@ class nt extends qt { let e; t = k(t); const [i] = t, { offset: n } = this.locationFromPosition(i), r = this.removeTextAtRange(t); - return n === 0 && (e = [new ut()]), new this.constructor(r.blockList.insertSplittableListAtPosition(new ei(e), i)); + return n === 0 && (e = [new ut()]), new this.constructor(r.blockList.insertSplittableListAtPosition(new li(e), i)); } applyBlockAttributeAtRange(t, e, i) { const n = this.expandRangeToLineBreaksAndSplitBlocks(i); let r = n.document; i = n.range; - const a = P(t); + const a = F(t); if (a.listAttribute) { r = r.removeLastListAttributeAtRange(i, { exceptAttributeName: t }); const o = r.convertLineBreaksToBlockBreaksInRange(i); @@ -2349,23 +2357,23 @@ class nt extends qt { } removeLastListAttributeAtRange(t) { let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, { blockList: i } = this; - return this.eachBlockAtRange(t, (function(n, r, a) { + return this.eachBlockAtRange(t, function(n, r, a) { const o = n.getLastAttribute(); - o && P(o).listAttribute && o !== e.exceptAttributeName && (i = i.editObjectAtIndex(a, (() => n.removeAttribute(o)))); - })), new this.constructor(i); + o && F(o).listAttribute && o !== e.exceptAttributeName && (i = i.editObjectAtIndex(a, () => n.removeAttribute(o))); + }), new this.constructor(i); } removeLastTerminalAttributeAtRange(t) { let { blockList: e } = this; - return this.eachBlockAtRange(t, (function(i, n, r) { + return this.eachBlockAtRange(t, function(i, n, r) { const a = i.getLastAttribute(); - a && P(a).terminal && (e = e.editObjectAtIndex(r, (() => i.removeAttribute(a)))); - })), new this.constructor(e); + a && F(a).terminal && (e = e.editObjectAtIndex(r, () => i.removeAttribute(a))); + }), new this.constructor(e); } removeBlockAttributesAtRange(t) { let { blockList: e } = this; - return this.eachBlockAtRange(t, (function(i, n, r) { - i.hasAttributes() && (e = e.editObjectAtIndex(r, (() => i.copyWithoutAttributes()))); - })), new this.constructor(e); + return this.eachBlockAtRange(t, function(i, n, r) { + i.hasAttributes() && (e = e.editObjectAtIndex(r, () => i.copyWithoutAttributes())); + }), new this.constructor(e); } expandRangeToLineBreaksAndSplitBlocks(t) { let e; @@ -2387,9 +2395,9 @@ class nt extends qt { let [e] = t; const i = this.getStringAtRange(t).slice(0, -1); let n = this; - return i.replace(/.*?\n/g, (function(r) { + return i.replace(/.*?\n/g, function(r) { e += r.length, n = n.insertBlockBreakAtRange([e - 1, e]); - })), { document: n, range: t }; + }), { document: n, range: t }; } consolidateBlocksAtRange(t) { t = k(t); @@ -2466,19 +2474,19 @@ class nt extends qt { getCommonAttributesAtRange(t) { t = k(t); const [e] = t; - if (_t(t)) return this.getCommonAttributesAtPosition(e); + if (vt(t)) return this.getCommonAttributesAtPosition(e); { const i = [], n = []; - return this.eachBlockAtRange(t, (function(r, a) { - if (a[0] !== a[1]) return i.push(r.text.getCommonAttributesAtRange(a)), n.push(ks(r)); - })), et.fromCommonAttributesOfObjects(i).merge(et.fromCommonAttributesOfObjects(n)).toObject(); + return this.eachBlockAtRange(t, function(r, a) { + if (a[0] !== a[1]) return i.push(r.text.getCommonAttributesAtRange(a)), n.push(Us(r)); + }), et.fromCommonAttributesOfObjects(i).merge(et.fromCommonAttributesOfObjects(n)).toObject(); } } getCommonAttributesAtPosition(t) { let e, i; const { index: n, offset: r } = this.locationFromPosition(t), a = this.getBlockAtIndex(n); if (!a) return {}; - const o = ks(a), l = a.text.getAttributesAtPosition(r), c = a.text.getAttributesAtPosition(r - 1), u = Object.keys(Pt).filter(((m) => Pt[m].inheritable)); + const o = Us(a), l = a.text.getAttributesAtPosition(r), c = a.text.getAttributesAtPosition(r - 1), u = Object.keys(Ft).filter((m) => Ft[m].inheritable); for (e in c) i = c[e], (i === l[e] || u.includes(e)) && (o[e] = i); return o; } @@ -2503,13 +2511,13 @@ class nt extends qt { } getAttachmentPieces() { let t = []; - return this.blockList.eachObject(((e) => { + return this.blockList.eachObject((e) => { let { text: i } = e; return t = t.concat(i.getAttachmentPieces()); - })), t; + }), t; } getAttachments() { - return this.getAttachmentPieces().map(((t) => t.attachment)); + return this.getAttachmentPieces().map((t) => t.attachment); } getRangeOfAttachment(t) { let e = 0; @@ -2530,20 +2538,20 @@ class nt extends qt { findRangesForBlockAttribute(t) { let e = 0; const i = []; - return this.getBlocks().forEach(((n) => { + return this.getBlocks().forEach((n) => { const r = n.getLength(); n.hasAttribute(t) && i.push([e, e + r]), e += r; - })), i; + }), i; } findRangesForTextAttribute(t) { let { withValue: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, i = 0, n = []; const r = []; - return this.getPieces().forEach(((a) => { + return this.getPieces().forEach((a) => { const o = a.getLength(); (function(l) { return e ? l.getAttribute(t) === e : l.hasAttribute(t); })(a) && (n[1] === i ? n[1] = i + o : r.push(n = [i, i + o])), i += o; - })), r; + }), r; } locationFromPosition(t) { const e = this.blockList.findIndexAndOffsetAtPosition(Math.max(0, t)); @@ -2568,26 +2576,26 @@ class nt extends qt { let e; t = k(t); const i = this.positionFromLocation(t[0]); - return _t(t) || (e = this.positionFromLocation(t[1])), k([i, e]); + return vt(t) || (e = this.positionFromLocation(t[1])), k([i, e]); } isEqualTo(t) { - return this.blockList.isEqualTo(t?.blockList); + return this.blockList.isEqualTo(t == null ? void 0 : t.blockList); } getTexts() { - return this.getBlocks().map(((t) => t.text)); + return this.getBlocks().map((t) => t.text); } getPieces() { const t = []; - return Array.from(this.getTexts()).forEach(((e) => { + return Array.from(this.getTexts()).forEach((e) => { t.push(...Array.from(e.getPieces() || [])); - })), t; + }), t; } getObjects() { return this.getBlocks().concat(this.getTexts()).concat(this.getPieces()); } toSerializableDocument() { const t = []; - return this.blockList.eachObject(((e) => t.push(e.copyWithText(e.text.toSerializableText())))), new this.constructor(t); + return this.blockList.eachObject((e) => t.push(e.copyWithText(e.text.toSerializableText()))), new this.constructor(t); } toString() { return this.blockList.toString(); @@ -2596,23 +2604,23 @@ class nt extends qt { return this.blockList.toJSON(); } toConsole() { - return JSON.stringify(this.blockList.toArray().map(((t) => JSON.parse(t.text.toConsole())))); + return JSON.stringify(this.blockList.toArray().map((t) => JSON.parse(t.text.toConsole()))); } } -const ks = function(s) { +const Us = function(s) { const t = {}, e = s.getLastAttribute(); return e && (t[e] = !0), t; -}, qi = function(s) { +}, Xi = function(s) { let t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; - return { string: s = fe(s), attributes: t, type: "string" }; -}, Is = (s, t) => { + return { string: s = ye(s), attributes: t, type: "string" }; +}, Vs = (s, t) => { try { return JSON.parse(s.getAttribute("data-trix-".concat(t))); } catch { return {}; } }; -class we extends H { +class Re extends q { static parse(t, e) { const i = new this(t, e); return i.parse(), i; @@ -2626,8 +2634,8 @@ class we extends H { } parse() { try { - this.createHiddenContainer(), si.setHTML(this.containerElement, this.html, { purifyOptions: this.purifyOptions }); - const t = Qe(this.containerElement, { usingFilter: Yo }); + this.createHiddenContainer(), mi.setHTML(this.containerElement, this.html, { purifyOptions: this.purifyOptions }); + const t = ri(this.containerElement, { usingFilter: gl }); for (; t.nextNode(); ) this.processNode(t.currentNode); return this.translateBlockElementMarginsToNewlines(); } finally { @@ -2656,7 +2664,7 @@ class we extends H { if (e === this.containerElement || this.isBlockElement(e)) { var i; const n = this.getBlockAttributes(e), r = this.getBlockHTMLAttributes(e); - Ft(n, (i = this.currentBlock) === null || i === void 0 ? void 0 : i.attributes) || (this.currentBlock = this.appendBlockForAttributesWithElement(n, e, r), this.currentBlockElement = e); + Ht(n, (i = this.currentBlock) === null || i === void 0 ? void 0 : i.attributes) || (this.currentBlock = this.appendBlockForAttributesWithElement(n, e, r), this.currentBlockElement = e); } } appendBlockForElement(t) { @@ -2665,7 +2673,7 @@ class we extends H { if (!this.isInsignificantTextNode(t.firstChild) || !this.isBlockElement(t.firstElementChild)) { const n = this.getBlockAttributes(t), r = this.getBlockHTMLAttributes(t); if (t.firstChild) { - if (i && Ft(n, this.currentBlock.attributes)) return this.appendStringWithAttributes(` + if (i && Ht(n, this.currentBlock.attributes)) return this.appendStringWithAttributes(` `); this.currentBlock = this.appendBlockForAttributesWithElement(n, t, r), this.currentBlockElement = t; } @@ -2687,12 +2695,12 @@ class we extends H { processTextNode(t) { let e = t.data; var i; - return Rs(t.parentNode) || (e = Rn(e), oa((i = t.previousSibling) === null || i === void 0 ? void 0 : i.textContent) && (e = Xo(e))), this.appendStringWithAttributes(e, this.getTextAttributes(t.parentNode)); + return js(t.parentNode) || (e = jn(e), ya((i = t.previousSibling) === null || i === void 0 ? void 0 : i.textContent) && (e = pl(e))), this.appendStringWithAttributes(e, this.getTextAttributes(t.parentNode)); } processElement(t) { let e; - if (Mt(t)) { - if (e = Is(t, "attachment"), Object.keys(e).length) { + if (Nt(t)) { + if (e = Vs(t, "attachment"), Object.keys(e).length) { const i = this.getTextAttributes(t); this.appendAttachmentWithAttributes(e, i), t.innerHTML = ""; } @@ -2714,49 +2722,49 @@ class we extends H { } return this.appendAttachmentWithAttributes(e, this.getTextAttributes(t)), this.processedElements.push(t); case "tr": - if (this.needsTableSeparator(t)) return this.appendStringWithAttributes(Je.tableRowSeparator); + if (this.needsTableSeparator(t)) return this.appendStringWithAttributes(ii.tableRowSeparator); break; case "td": - if (this.needsTableSeparator(t)) return this.appendStringWithAttributes(Je.tableCellSeparator); + if (this.needsTableSeparator(t)) return this.appendStringWithAttributes(ii.tableCellSeparator); } } appendBlockForAttributesWithElement(t, e) { let i = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {}; this.blockElements.push(e); - const n = (function() { + const n = function() { return { text: [], attributes: arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, htmlAttributes: arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {} }; - })(t, i); + }(t, i); return this.blocks.push(n), n; } appendEmptyBlock() { return this.appendBlockForAttributesWithElement([], null); } appendStringWithAttributes(t, e) { - return this.appendPiece(qi(t, e)); + return this.appendPiece(Xi(t, e)); } appendAttachmentWithAttributes(t, e) { - return this.appendPiece((function(i) { + return this.appendPiece(function(i) { return { attachment: i, attributes: arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, type: "attachment" }; - })(t, e)); + }(t, e)); } appendPiece(t) { return this.blocks.length === 0 && this.appendEmptyBlock(), this.blocks[this.blocks.length - 1].text.push(t); } appendStringToTextAtIndex(t, e) { const { text: i } = this.blocks[e], n = i[i.length - 1]; - if (n?.type !== "string") return i.push(qi(t)); + if ((n == null ? void 0 : n.type) !== "string") return i.push(Xi(t)); n.string += t; } prependStringToTextAtIndex(t, e) { const { text: i } = this.blocks[e], n = i[0]; - if (n?.type !== "string") return i.unshift(qi(t)); + if ((n == null ? void 0 : n.type) !== "string") return i.unshift(Xi(t)); n.string = t + n.string; } getTextAttributes(t) { let e; const i = {}; - for (const n in Pt) { - const r = Pt[n]; + for (const n in Ft) { + const r = Ft[n]; if (r.tagName && Lt(t, { matchingSelector: r.tagName, untilNode: this.containerElement })) i[n] = !0; else if (r.parser) { if (e = r.parser(t), e) { @@ -2769,8 +2777,8 @@ class we extends H { } } else r.styleProperty && (e = t.style[r.styleProperty], e && (i[n] = e)); } - if (Mt(t)) { - const n = Is(t, "attributes"); + if (Nt(t)) { + const n = Vs(t, "attributes"); for (const r in n) e = n[r], i[r] = e; } return i; @@ -2788,32 +2796,32 @@ class we extends H { return e.reverse(); } getBlockHTMLAttributes(t) { - const e = {}, i = Object.values(X).find(((n) => n.tagName === Y(t))); - return (i?.htmlAttributes || []).forEach(((n) => { + const e = {}, i = Object.values(X).find((n) => n.tagName === Y(t)); + return ((i == null ? void 0 : i.htmlAttributes) || []).forEach((n) => { t.hasAttribute(n) && (e[n] = t.getAttribute(n)); - })), e; + }), e; } findBlockElementAncestors(t) { const e = []; for (; t && t !== this.containerElement; ) { const i = Y(t); - _e().includes(i) && e.push(t), t = t.parentNode; + Ee().includes(i) && e.push(t), t = t.parentNode; } return e; } isBlockElement(t) { - if (t?.nodeType === Node.ELEMENT_NODE && !Mt(t) && !Lt(t, { matchingSelector: "td", untilNode: this.containerElement })) return _e().includes(Y(t)) || window.getComputedStyle(t).display === "block"; + if ((t == null ? void 0 : t.nodeType) === Node.ELEMENT_NODE && !Nt(t) && !Lt(t, { matchingSelector: "td", untilNode: this.containerElement })) return Ee().includes(Y(t)) || window.getComputedStyle(t).display === "block"; } isInsignificantTextNode(t) { - if (t?.nodeType !== Node.TEXT_NODE || !Qo(t.data)) return; + if ((t == null ? void 0 : t.nodeType) !== Node.TEXT_NODE || !fl(t.data)) return; const { parentNode: e, previousSibling: i, nextSibling: n } = t; - return Jo(e.previousSibling) && !this.isBlockElement(e.previousSibling) || Rs(e) ? void 0 : !i || this.isBlockElement(i) || !n || this.isBlockElement(n); + return ml(e.previousSibling) && !this.isBlockElement(e.previousSibling) || js(e) ? void 0 : !i || this.isBlockElement(i) || !n || this.isBlockElement(n); } isExtraBR(t) { return Y(t) === "br" && this.isBlockElement(t.parentNode) && t.parentNode.lastChild === t; } needsTableSeparator(t) { - if (Je.removeBlankTableCells) { + if (ii.removeBlankTableCells) { var e; const i = (e = t.previousSibling) === null || e === void 0 ? void 0 : e.textContent; return i && /\S/.test(i); @@ -2831,56 +2839,56 @@ class we extends H { } getMarginOfBlockElementAtIndex(t) { const e = this.blockElements[t]; - if (e && e.textContent && !_e().includes(Y(e)) && !this.processedElements.includes(e)) return Ds(e); + if (e && e.textContent && !Ee().includes(Y(e)) && !this.processedElements.includes(e)) return Ws(e); } getMarginOfDefaultBlockElement() { const t = x(X.default.tagName); - return this.containerElement.appendChild(t), Ds(t); + return this.containerElement.appendChild(t), Ws(t); } } -const Rs = function(s) { +const js = function(s) { const { whiteSpace: t } = window.getComputedStyle(s); return ["pre", "pre-wrap", "pre-line"].includes(t); -}, Jo = (s) => s && !oa(s.textContent), Ds = function(s) { +}, ml = (s) => s && !ya(s.textContent), Ws = function(s) { const t = window.getComputedStyle(s); if (t.display === "block") return { top: parseInt(t.marginTop), bottom: parseInt(t.marginBottom) }; -}, Yo = function(s) { +}, gl = function(s) { return Y(s) === "style" ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; -}, Xo = (s) => s.replace(new RegExp("^".concat(In.source, "+")), ""), Qo = (s) => new RegExp("^".concat(In.source, "*$")).test(s), oa = (s) => /\s$/.test(s), Zo = ["contenteditable", "data-trix-id", "data-trix-store-key", "data-trix-mutable", "data-trix-placeholder", "tabindex"], _n = "data-trix-serialized-attributes", tl = "[".concat(_n, "]"), el = new RegExp("", "g"), il = { "application/json": function(s) { +}, pl = (s) => s.replace(new RegExp("^".concat(Vn.source, "+")), ""), fl = (s) => new RegExp("^".concat(Vn.source, "*$")).test(s), ya = (s) => /\s$/.test(s), bl = ["contenteditable", "data-trix-id", "data-trix-store-key", "data-trix-mutable", "data-trix-placeholder", "tabindex"], kn = "data-trix-serialized-attributes", _l = "[".concat(kn, "]"), vl = new RegExp("", "g"), yl = { "application/json": function(s) { let t; if (s instanceof nt) t = s; else { if (!(s instanceof HTMLElement)) throw new Error("unserializable object"); - t = we.parse(s.innerHTML).getDocument(); + t = Re.parse(s.innerHTML).getDocument(); } return t.toSerializableDocument().toJSONString(); }, "text/html": function(s) { let t; - if (s instanceof nt) t = ri.render(s); + if (s instanceof nt) t = gi.render(s); else { if (!(s instanceof HTMLElement)) throw new Error("unserializable object"); t = s.cloneNode(!0); } - return Array.from(t.querySelectorAll("[data-trix-serialize=false]")).forEach(((e) => { + return Array.from(t.querySelectorAll("[data-trix-serialize=false]")).forEach((e) => { Ct(e); - })), Zo.forEach(((e) => { - Array.from(t.querySelectorAll("[".concat(e, "]"))).forEach(((i) => { + }), bl.forEach((e) => { + Array.from(t.querySelectorAll("[".concat(e, "]"))).forEach((i) => { i.removeAttribute(e); - })); - })), Array.from(t.querySelectorAll(tl)).forEach(((e) => { + }); + }), Array.from(t.querySelectorAll(_l)).forEach((e) => { try { - const i = JSON.parse(e.getAttribute(_n)); - e.removeAttribute(_n); + const i = JSON.parse(e.getAttribute(kn)); + e.removeAttribute(kn); for (const n in i) { const r = i[n]; e.setAttribute(n, r); } } catch { } - })), t.innerHTML.replace(el, ""); + }), t.innerHTML.replace(vl, ""); } }; -var nl = Object.freeze({ __proto__: null }); -class O extends H { +var Al = Object.freeze({ __proto__: null }); +class O extends q { constructor(t, e) { super(...arguments), this.attachmentManager = t, this.attachment = e, this.id = this.attachment.id, this.file = this.attachment.file; } @@ -2889,12 +2897,12 @@ class O extends H { } } O.proxyMethod("attachment.getAttribute"), O.proxyMethod("attachment.hasAttribute"), O.proxyMethod("attachment.setAttribute"), O.proxyMethod("attachment.getAttributes"), O.proxyMethod("attachment.setAttributes"), O.proxyMethod("attachment.isPending"), O.proxyMethod("attachment.isPreviewable"), O.proxyMethod("attachment.getURL"), O.proxyMethod("attachment.getPreviewURL"), O.proxyMethod("attachment.setPreviewURL"), O.proxyMethod("attachment.getHref"), O.proxyMethod("attachment.getFilename"), O.proxyMethod("attachment.getFilesize"), O.proxyMethod("attachment.getFormattedFilesize"), O.proxyMethod("attachment.getExtension"), O.proxyMethod("attachment.getContentType"), O.proxyMethod("attachment.getFile"), O.proxyMethod("attachment.setFile"), O.proxyMethod("attachment.releaseFile"), O.proxyMethod("attachment.getUploadProgress"), O.proxyMethod("attachment.setUploadProgress"); -class la extends H { +class Aa extends q { constructor() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; - super(...arguments), this.managedAttachments = {}, Array.from(t).forEach(((e) => { + super(...arguments), this.managedAttachments = {}, Array.from(t).forEach((e) => { this.manageAttachment(e); - })); + }); } getAttachments() { const t = []; @@ -2919,7 +2927,7 @@ class la extends H { return delete this.managedAttachments[t.id], e; } } -class da { +class Ea { constructor(t) { this.composition = t, this.document = this.composition.document; const e = this.composition.getSelectedRange(); @@ -2944,7 +2952,7 @@ class da { return this.block.hasAttributes() && !this.block.isListItem() && this.block.isEmpty(); } } -class Et extends H { +class xt extends q { constructor() { super(...arguments), this.document = new nt(), this.attachments = [], this.currentAttributes = {}, this.revision = 0; } @@ -2990,7 +2998,7 @@ class Et extends H { return this.setSelection(i), this.notifyDelegateOfInsertionAtRange([e, i]); } insertLineBreak() { - const t = new da(this); + const t = new Ea(this); if (t.shouldDecreaseListLevel()) return this.decreaseListLevel(), this.setSelection(t.startPosition); if (t.shouldPrependListItem()) { const e = new nt([t.block.copyWithoutText()]); @@ -3000,13 +3008,13 @@ class Et extends H { `); } insertHTML(t) { - const e = we.parse(t, { purifyOptions: { SAFE_FOR_XML: !0 } }).getDocument(), i = this.getSelectedRange(); + const e = Re.parse(t, { purifyOptions: { SAFE_FOR_XML: !0 } }).getDocument(), i = this.getSelectedRange(); this.setDocument(this.document.mergeDocumentAtRange(e, i)); const n = i[0], r = n + e.getLength() - 1; return this.setSelection(r), this.notifyDelegateOfInsertionAtRange([n, r]); } replaceHTML(t) { - const e = we.parse(t).getDocument().copyUsingObjectsFromDocument(this.document), i = this.getLocationRange({ strict: !1 }), n = this.document.rangeFromLocationRange(i); + const e = Re.parse(t).getDocument().copyUsingObjectsFromDocument(this.document), i = this.getLocationRange({ strict: !1 }), n = this.document.rangeFromLocationRange(i); return this.setDocument(e), this.setSelection(n); } insertFile(t) { @@ -3014,30 +3022,30 @@ class Et extends H { } insertFiles(t) { const e = []; - return Array.from(t).forEach(((i) => { + return Array.from(t).forEach((i) => { var n; if ((n = this.delegate) !== null && n !== void 0 && n.compositionShouldAcceptFile(i)) { - const r = se.attachmentForFile(i); + const r = ae.attachmentForFile(i); e.push(r); } - })), this.insertAttachments(e); + }), this.insertAttachments(e); } insertAttachment(t) { return this.insertAttachments([t]); } insertAttachments(t) { let e = new dt(); - return Array.from(t).forEach(((i) => { + return Array.from(t).forEach((i) => { var n; - const r = i.getType(), a = (n = Sn[r]) === null || n === void 0 ? void 0 : n.presentation, o = this.getCurrentTextAttributes(); + const r = i.getType(), a = (n = Pn[r]) === null || n === void 0 ? void 0 : n.presentation, o = this.getCurrentTextAttributes(); a && (o.presentation = a); const l = dt.textForAttachmentWithAttributes(i, o); e = e.appendText(l); - })), this.insertText(e); + }), this.insertText(e); } shouldManageDeletingInDirection(t) { const e = this.getLocationRange(); - if (_t(e)) { + if (vt(e)) { if (t === "backward" && e[0].offset === 0 || this.shouldManageMovingCursorInDirection(t)) return !0; } else if (e[0].index !== e[1].index) return !0; return !1; @@ -3046,7 +3054,7 @@ class Et extends H { let e, i, n, { length: r } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; const a = this.getLocationRange(); let o = this.getSelectedRange(); - const l = _t(o); + const l = vt(o); if (l ? i = t === "backward" && a[0].offset === 0 : n = a[0].index !== a[1].index, i && this.canDecreaseBlockAttributeLevel()) { const c = this.getBlock(); if (c.isListItem() ? this.decreaseListLevel() : this.decreaseBlockAttributeLevel(), this.setSelection(o[0]), c.isEmpty()) return !1; @@ -3083,7 +3091,7 @@ class Et extends H { return e ? this.setCurrentAttribute(t, e) : this.removeCurrentAttribute(t); } canSetCurrentAttribute(t) { - return P(t) ? this.canSetCurrentBlockAttribute(t) : this.canSetCurrentTextAttribute(t); + return F(t) ? this.canSetCurrentBlockAttribute(t) : this.canSetCurrentTextAttribute(t); } canSetCurrentTextAttribute(t) { const e = this.getSelectedDocument(); @@ -3097,11 +3105,11 @@ class Et extends H { if (e) return !e.isTerminalBlock(); } setCurrentAttribute(t, e) { - return P(t) ? this.setBlockAttribute(t, e) : (this.setTextAttribute(t, e), this.currentAttributes[t] = e, this.notifyDelegateOfCurrentAttributesChange()); + return F(t) ? this.setBlockAttribute(t, e) : (this.setTextAttribute(t, e), this.currentAttributes[t] = e, this.notifyDelegateOfCurrentAttributesChange()); } setHTMLAtributeAtPosition(t, e, i) { var n; - const r = this.document.getBlockAtPosition(t), a = (n = P(r.getLastAttribute())) === null || n === void 0 ? void 0 : n.htmlAttributes; + const r = this.document.getBlockAtPosition(t), a = (n = F(r.getLastAttribute())) === null || n === void 0 ? void 0 : n.htmlAttributes; if (r && a != null && a.includes(e)) { const o = this.document.setHTMLAttributeAtPosition(t, e, i); this.setDocument(o); @@ -3122,7 +3130,7 @@ class Et extends H { if (this.canSetCurrentAttribute(t)) return this.setDocument(this.document.applyBlockAttributeAtRange(t, e, i)), this.setSelection(i); } removeCurrentAttribute(t) { - return P(t) ? (this.removeBlockAttribute(t), this.updateCurrentAttributes()) : (this.removeTextAttribute(t), delete this.currentAttributes[t], this.notifyDelegateOfCurrentAttributesChange()); + return F(t) ? (this.removeBlockAttribute(t), this.updateCurrentAttributes()) : (this.removeTextAttribute(t), delete this.currentAttributes[t], this.notifyDelegateOfCurrentAttributesChange()); } removeTextAttribute(t) { const e = this.getSelectedRange(); @@ -3140,13 +3148,13 @@ class Et extends H { var t; const e = this.getBlock(); if (e) { - if ((t = P(e.getLastNestableAttribute())) === null || t === void 0 || !t.listAttribute) return e.getNestingLevel() > 0; + if ((t = F(e.getLastNestableAttribute())) === null || t === void 0 || !t.listAttribute) return e.getNestingLevel() > 0; { const i = this.getPreviousBlock(); - if (i) return (function() { + if (i) return function() { let n = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; - return Ft((arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).slice(0, n.length), n); - })(i.getListItemAttributes(), e.getListItemAttributes()); + return Ht((arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []).slice(0, n.length), n); + }(i.getListItemAttributes(), e.getListItemAttributes()); } } } @@ -3182,19 +3190,19 @@ class Et extends H { const t = this.getSelectedRange({ ignoreLock: !0 }); if (t) { const e = this.document.getCommonAttributesAtRange(t); - if (Array.from(mn()).forEach(((i) => { + if (Array.from(Sn()).forEach((i) => { e[i] || this.canSetCurrentAttribute(i) || (e[i] = !1); - })), !ne(e, this.currentAttributes)) return this.currentAttributes = e, this.notifyDelegateOfCurrentAttributesChange(); + }), !re(e, this.currentAttributes)) return this.currentAttributes = e, this.notifyDelegateOfCurrentAttributesChange(); } } getCurrentAttributes() { - return Pr.call({}, this.currentAttributes); + return Yr.call({}, this.currentAttributes); } getCurrentTextAttributes() { const t = {}; for (const e in this.currentAttributes) { const i = this.currentAttributes[e]; - i !== !1 && gn(e) && (t[e] = i); + i !== !1 && Ln(e) && (t[e] = i); } return t; } @@ -3259,7 +3267,7 @@ class Et extends H { if (this.editingAttachment) i = this.document.getRangeOfAttachment(this.editingAttachment); else { const n = this.getSelectedRange(); - i = this.getExpandedRangeInDirection(t), e = !Ze(n, i); + i = this.getExpandedRangeInDirection(t), e = !ai(n, i); } if (t === "backward" ? this.setSelectedRange(i[0]) : this.setSelectedRange(i[1]), e) { const n = this.getAttachmentAtRange(i); @@ -3305,28 +3313,28 @@ class Et extends H { return this.attachments.slice(0); } refreshAttachments() { - const t = this.document.getAttachments(), { added: e, removed: i } = (function() { + const t = this.document.getAttachments(), { added: e, removed: i } = function() { let n = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : [], r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : []; const a = [], o = [], l = /* @__PURE__ */ new Set(); - n.forEach(((u) => { + n.forEach((u) => { l.add(u); - })); + }); const c = /* @__PURE__ */ new Set(); - return r.forEach(((u) => { + return r.forEach((u) => { c.add(u), l.has(u) || a.push(u); - })), n.forEach(((u) => { + }), n.forEach((u) => { c.has(u) || o.push(u); - })), { added: a, removed: o }; - })(this.attachments, t); - return this.attachments = t, Array.from(i).forEach(((n) => { + }), { added: a, removed: o }; + }(this.attachments, t); + return this.attachments = t, Array.from(i).forEach((n) => { var r, a; n.delegate = null, (r = this.delegate) === null || r === void 0 || (a = r.compositionDidRemoveAttachment) === null || a === void 0 || a.call(r, n); - })), (() => { + }), (() => { const n = []; - return Array.from(e).forEach(((r) => { + return Array.from(e).forEach((r) => { var a, o; r.delegate = this, n.push((a = this.delegate) === null || a === void 0 || (o = a.compositionDidAddAttachment) === null || o === void 0 ? void 0 : o.call(a, r)); - })), n; + }), n; })(); } attachmentDidChangeAttributes(t) { @@ -3391,15 +3399,15 @@ class Et extends H { return i.offsetToUCS2Offset(n + e); } } -Et.proxyMethod("getSelectionManager().getPointRange"), Et.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"), Et.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"), Et.proxyMethod("getSelectionManager().locationIsCursorTarget"), Et.proxyMethod("getSelectionManager().selectionIsExpanded"), Et.proxyMethod("delegate?.getSelectionManager"); -class vn extends H { +xt.proxyMethod("getSelectionManager().getPointRange"), xt.proxyMethod("getSelectionManager().setLocationRangeFromPointRange"), xt.proxyMethod("getSelectionManager().createLocationRangeFromDOMRange"), xt.proxyMethod("getSelectionManager().locationIsCursorTarget"), xt.proxyMethod("getSelectionManager().selectionIsExpanded"), xt.proxyMethod("delegate?.getSelectionManager"); +class In extends q { constructor(t) { super(...arguments), this.composition = t, this.undoEntries = [], this.redoEntries = []; } recordUndoEntry(t) { let { context: e, consolidatable: i } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; const n = this.undoEntries.slice(-1)[0]; - if (!i || !sl(n, t, e)) { + if (!i || !El(n, t, e)) { const r = this.createEntry({ description: t, context: e }); this.undoEntries.push(r), this.redoEntries = []; } @@ -3426,11 +3434,11 @@ class vn extends H { } createEntry() { let { description: t, context: e } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - return { description: t?.toString(), context: JSON.stringify(e), snapshot: this.composition.getSnapshot() }; + return { description: t == null ? void 0 : t.toString(), context: JSON.stringify(e), snapshot: this.composition.getSnapshot() }; } } -const sl = (s, t, e) => s?.description === t?.toString() && s?.context === JSON.stringify(e), $i = "attachmentGallery"; -class ca { +const El = (s, t, e) => (s == null ? void 0 : s.description) === (t == null ? void 0 : t.toString()) && (s == null ? void 0 : s.context) === JSON.stringify(e), Qi = "attachmentGallery"; +class xa { constructor(t) { this.document = t.document, this.selectedRange = t.selectedRange; } @@ -3441,18 +3449,18 @@ class ca { return { document: this.document, selectedRange: this.selectedRange }; } removeBlockAttribute() { - return this.findRangesOfBlocks().map(((t) => this.document = this.document.removeAttributeAtRange($i, t))); + return this.findRangesOfBlocks().map((t) => this.document = this.document.removeAttributeAtRange(Qi, t)); } applyBlockAttribute() { let t = 0; - this.findRangesOfPieces().forEach(((e) => { + this.findRangesOfPieces().forEach((e) => { e[1] - e[0] > 1 && (e[0] += t, e[1] += t, this.document.getCharacterAtPosition(e[1]) !== ` ` && (this.document = this.document.insertBlockBreakAtRange(e[1]), e[1] < this.selectedRange[1] && this.moveSelectedRangeForward(), e[1]++, t++), e[0] !== 0 && this.document.getCharacterAtPosition(e[0] - 1) !== ` -` && (this.document = this.document.insertBlockBreakAtRange(e[0]), e[0] < this.selectedRange[0] && this.moveSelectedRangeForward(), e[0]++, t++), this.document = this.document.applyBlockAttributeAtRange($i, !0, e)); - })); +` && (this.document = this.document.insertBlockBreakAtRange(e[0]), e[0] < this.selectedRange[0] && this.moveSelectedRangeForward(), e[0]++, t++), this.document = this.document.applyBlockAttributeAtRange(Qi, !0, e)); + }); } findRangesOfBlocks() { - return this.document.findRangesForBlockAttribute($i); + return this.document.findRangesForBlockAttribute(Qi); } findRangesOfPieces() { return this.document.findRangesForTextAttribute("presentation", { withValue: "gallery" }); @@ -3461,20 +3469,20 @@ class ca { this.selectedRange[0] += 1, this.selectedRange[1] += 1; } } -const ha = function(s) { - const t = new ca(s); +const Sa = function(s) { + const t = new xa(s); return t.perform(), t.getSnapshot(); -}, rl = [ha]; -class ua { +}, xl = [Sa]; +class La { constructor(t, e, i) { - this.insertFiles = this.insertFiles.bind(this), this.composition = t, this.selectionManager = e, this.element = i, this.undoManager = new vn(this.composition), this.filters = rl.slice(0); + this.insertFiles = this.insertFiles.bind(this), this.composition = t, this.selectionManager = e, this.element = i, this.undoManager = new In(this.composition), this.filters = xl.slice(0); } loadDocument(t) { return this.loadSnapshot({ document: t, selectedRange: [0, 0] }); } loadHTML() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; - const e = we.parse(t, { referenceElement: this.element }).getDocument(); + const e = Re.parse(t, { referenceElement: this.element }).getDocument(); return this.loadDocument(e); } loadJSON(t) { @@ -3482,7 +3490,7 @@ class ua { return e = nt.fromJSON(e), this.loadSnapshot({ document: e, selectedRange: i }); } loadSnapshot(t) { - return this.undoManager = new vn(this.composition), this.composition.loadSnapshot(t); + return this.undoManager = new In(this.composition), this.composition.loadSnapshot(t); } getDocument() { return this.composition.document; @@ -3590,32 +3598,32 @@ class ua { if (this.canUndo()) return this.undoManager.undo(); } } -class ma { +class Ca { constructor(t) { this.element = t; } findLocationFromContainerAndOffset(t, e) { let { strict: i } = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : { strict: !0 }, n = 0, r = !1; const a = { index: 0, offset: 0 }, o = this.findAttachmentElementParentForNode(t); - o && (t = o.parentNode, e = Li(o)); - const l = Qe(this.element, { usingFilter: ga }); + o && (t = o.parentNode, e = Ni(o)); + const l = ri(this.element, { usingFilter: wa }); for (; l.nextNode(); ) { const c = l.currentNode; - if (c === t && ve(t)) { - te(c) || (a.offset += e); + if (c === t && xe(t)) { + ie(c) || (a.offset += e); break; } if (c.parentNode === t) { if (n++ === e) break; } else if (!Ot(t, c) && n > 0) break; - as(c, { strict: i }) ? (r && a.index++, a.offset = 0, r = !0) : a.offset += Ui(c); + vs(c, { strict: i }) ? (r && a.index++, a.offset = 0, r = !0) : a.offset += Zi(c); } return a; } findContainerAndOffsetFromLocation(t) { let e, i; if (t.index === 0 && t.offset === 0) { - for (e = this.element, i = 0; e.firstChild; ) if (e = e.firstChild, Ci(e)) { + for (e = this.element, i = 0; e.firstChild; ) if (e = e.firstChild, Pi(e)) { i = 1; break; } @@ -3623,10 +3631,10 @@ class ma { } let [n, r] = this.findNodeAndOffsetFromLocation(t); if (n) { - if (ve(n)) Ui(n) === 0 ? (e = n.parentNode.parentNode, i = Li(n.parentNode), te(n, { name: "right" }) && i++) : (e = n, i = t.offset - r); + if (xe(n)) Zi(n) === 0 ? (e = n.parentNode.parentNode, i = Ni(n.parentNode), ie(n, { name: "right" }) && i++) : (e = n, i = t.offset - r); else { - if (e = n.parentNode, !as(n.previousSibling) && !Ci(e)) for (; n === e.lastChild && (n = e, e = e.parentNode, !Ci(e)); ) ; - i = Li(n), t.offset !== 0 && i++; + if (e = n.parentNode, !vs(n.previousSibling) && !Pi(e)) for (; n === e.lastChild && (n = e, e = e.parentNode, !Pi(e)); ) ; + i = Ni(n), t.offset !== 0 && i++; } return [e, i]; } @@ -3634,9 +3642,9 @@ class ma { findNodeAndOffsetFromLocation(t) { let e, i, n = 0; for (const r of this.getSignificantNodesForIndex(t.index)) { - const a = Ui(r); - if (t.offset <= n + a) if (ve(r)) { - if (e = r, i = n, t.offset === i && te(e)) break; + const a = Zi(r); + if (t.offset <= n + a) if (xe(r)) { + if (e = r, i = n, t.offset === i && ie(e)) break; } else e || (e = r, i = n); if (n += a, n > t.offset) break; } @@ -3644,17 +3652,17 @@ class ma { } findAttachmentElementParentForNode(t) { for (; t && t !== this.element; ) { - if (Mt(t)) return t; + if (Nt(t)) return t; t = t.parentNode; } } getSignificantNodesForIndex(t) { - const e = [], i = Qe(this.element, { usingFilter: al }); + const e = [], i = ri(this.element, { usingFilter: Sl }); let n = !1; for (; i.nextNode(); ) { const a = i.currentNode; var r; - if (Zt(a)) { + if (ee(a)) { if (r != null ? r++ : r = 0, r === t) n = !0; else if (n) break; } else n && e.push(a); @@ -3662,16 +3670,16 @@ class ma { return e; } } -const Ui = function(s) { - return s.nodeType === Node.TEXT_NODE ? te(s) ? 0 : s.textContent.length : Y(s) === "br" || Mt(s) ? 1 : 0; -}, al = function(s) { - return ol(s) === NodeFilter.FILTER_ACCEPT ? ga(s) : NodeFilter.FILTER_REJECT; -}, ol = function(s) { - return qr(s) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; -}, ga = function(s) { - return Mt(s.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; +const Zi = function(s) { + return s.nodeType === Node.TEXT_NODE ? ie(s) ? 0 : s.textContent.length : Y(s) === "br" || Nt(s) ? 1 : 0; +}, Sl = function(s) { + return Ll(s) === NodeFilter.FILTER_ACCEPT ? wa(s) : NodeFilter.FILTER_REJECT; +}, Ll = function(s) { + return Zr(s) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; +}, wa = function(s) { + return Nt(s.parentNode) ? NodeFilter.FILTER_REJECT : NodeFilter.FILTER_ACCEPT; }; -class pa { +class Ta { createDOMRangeFromPoint(t) { let e, { x: i, y: n } = t; if (document.caretPositionFromPoint) { @@ -3680,13 +3688,13 @@ class pa { } if (document.caretRangeFromPoint) return document.caretRangeFromPoint(i, n); if (document.body.createTextRange) { - const r = ye(); + const r = Se(); try { const a = document.body.createTextRange(); a.moveToPoint(i, n), a.select(); } catch { } - return e = ye(), Gr(r), e; + return e = Se(), oa(r), e; } } getClientRectsForDOMRange(t) { @@ -3694,19 +3702,19 @@ class pa { return [e[0], e[e.length - 1]]; } } -class Dt extends H { +class Dt extends q { constructor(t) { - super(...arguments), this.didMouseDown = this.didMouseDown.bind(this), this.selectionDidChange = this.selectionDidChange.bind(this), this.element = t, this.locationMapper = new ma(this.element), this.pointMapper = new pa(), this.lockCount = 0, B("mousedown", { onElement: this.element, withCallback: this.didMouseDown }); + super(...arguments), this.didMouseDown = this.didMouseDown.bind(this), this.selectionDidChange = this.selectionDidChange.bind(this), this.element = t, this.locationMapper = new Ca(this.element), this.pointMapper = new Ta(), this.lockCount = 0, B("mousedown", { onElement: this.element, withCallback: this.didMouseDown }); } getLocationRange() { let t = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}; - return t.strict === !1 ? this.createLocationRangeFromDOMRange(ye()) : t.ignoreLock ? this.currentLocationRange : this.lockedLocationRange ? this.lockedLocationRange : this.currentLocationRange; + return t.strict === !1 ? this.createLocationRangeFromDOMRange(Se()) : t.ignoreLock ? this.currentLocationRange : this.lockedLocationRange ? this.lockedLocationRange : this.currentLocationRange; } setLocationRange(t) { if (this.lockedLocationRange) return; t = k(t); const e = this.createDOMRangeFromLocationRange(t); - e && (Gr(e), this.updateCurrentLocationRange(t)); + e && (oa(e), this.updateCurrentLocationRange(t)); } setLocationRangeFromPointRange(t) { t = k(t); @@ -3719,7 +3727,7 @@ class Dt extends H { } locationIsCursorTarget(t) { const e = Array.from(this.findNodeAndOffsetFromLocation(t))[0]; - return te(e); + return ie(e); } lock() { this.lockCount++ == 0 && (this.updateCurrentLocationRange(), this.lockedLocationRange = this.getLocationRange()); @@ -3732,11 +3740,11 @@ class Dt extends H { } clearSelection() { var t; - return (t = Kr()) === null || t === void 0 ? void 0 : t.removeAllRanges(); + return (t = aa()) === null || t === void 0 ? void 0 : t.removeAllRanges(); } selectionIsCollapsed() { var t; - return ((t = ye()) === null || t === void 0 ? void 0 : t.collapsed) === !0; + return ((t = Se()) === null || t === void 0 ? void 0 : t.collapsed) === !0; } selectionIsExpanded() { return !this.selectionIsCollapsed(); @@ -3755,21 +3763,21 @@ class Dt extends H { let t; this.paused = !0; const e = () => { - if (this.paused = !1, clearTimeout(i), Array.from(t).forEach(((n) => { + if (this.paused = !1, clearTimeout(i), Array.from(t).forEach((n) => { n.destroy(); - })), Ot(document, this.element)) return this.selectionDidChange(); + }), Ot(document, this.element)) return this.selectionDidChange(); }, i = setTimeout(e, 200); - t = ["mousemove", "keydown"].map(((n) => B(n, { onElement: document, withCallback: e }))); + t = ["mousemove", "keydown"].map((n) => B(n, { onElement: document, withCallback: e })); } selectionDidChange() { - if (!this.paused && !Cn(this.element)) return this.updateCurrentLocationRange(); + if (!this.paused && !Hn(this.element)) return this.updateCurrentLocationRange(); } updateCurrentLocationRange(t) { var e, i; - if ((t ?? (t = this.createLocationRangeFromDOMRange(ye()))) && !Ze(t, this.currentLocationRange)) return this.currentLocationRange = t, (e = this.delegate) === null || e === void 0 || (i = e.locationRangeDidChange) === null || i === void 0 ? void 0 : i.call(e, this.currentLocationRange.slice(0)); + if ((t ?? (t = this.createLocationRangeFromDOMRange(Se()))) && !ai(t, this.currentLocationRange)) return this.currentLocationRange = t, (e = this.delegate) === null || e === void 0 || (i = e.locationRangeDidChange) === null || i === void 0 ? void 0 : i.call(e, this.currentLocationRange.slice(0)); } createDOMRangeFromLocationRange(t) { - const e = this.findContainerAndOffsetFromLocation(t[0]), i = _t(t) ? e : this.findContainerAndOffsetFromLocation(t[1]) || e; + const e = this.findContainerAndOffsetFromLocation(t[0]), i = vt(t) ? e : this.findContainerAndOffsetFromLocation(t[1]) || e; if (e != null && i != null) { const n = document.createRange(); return n.setStart(...Array.from(e || [])), n.setEnd(...Array.from(i || [])), n; @@ -3785,23 +3793,23 @@ class Dt extends H { } } Dt.proxyMethod("locationMapper.findLocationFromContainerAndOffset"), Dt.proxyMethod("locationMapper.findContainerAndOffsetFromLocation"), Dt.proxyMethod("locationMapper.findNodeAndOffsetFromLocation"), Dt.proxyMethod("pointMapper.createDOMRangeFromPoint"), Dt.proxyMethod("pointMapper.getClientRectsForDOMRange"); -var fa = Object.freeze({ __proto__: null, Attachment: se, AttachmentManager: la, AttachmentPiece: ie, Block: ut, Composition: Et, Document: nt, Editor: ua, HTMLParser: we, HTMLSanitizer: si, LineBreakInsertion: da, LocationMapper: ma, ManagedAttachment: O, Piece: Ut, PointMapper: pa, SelectionManager: Dt, SplittableList: ei, StringPiece: Bn, Text: dt, UndoManager: vn }), ll = Object.freeze({ __proto__: null, ObjectView: $t, AttachmentView: On, BlockView: ia, DocumentView: ri, PieceView: ta, PreviewableAttachmentView: Zr, TextView: ea }); -const { lang: Vi, css: Rt, keyNames: dl } = ke, ji = function(s) { +var ka = Object.freeze({ __proto__: null, Attachment: ae, AttachmentManager: Aa, AttachmentPiece: se, Block: ut, Composition: xt, Document: nt, Editor: La, HTMLParser: Re, HTMLSanitizer: mi, LineBreakInsertion: Ea, LocationMapper: Ca, ManagedAttachment: O, Piece: Vt, PointMapper: Ta, SelectionManager: Dt, SplittableList: li, StringPiece: Kn, Text: dt, UndoManager: In }), Cl = Object.freeze({ __proto__: null, ObjectView: Ut, AttachmentView: zn, BlockView: pa, DocumentView: gi, PieceView: ma, PreviewableAttachmentView: ua, TextView: ga }); +const { lang: tn, css: Rt, keyNames: wl } = Be, en = function(s) { return function() { const t = s.apply(this, arguments); t.do(), this.undos || (this.undos = []), this.undos.push(t.undo); }; }; -class ba extends H { +class Ia extends q { constructor(t, e, i) { let n = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : {}; - super(...arguments), G(this, "makeElementMutable", ji((() => ({ do: () => { + super(...arguments), G(this, "makeElementMutable", en(() => ({ do: () => { this.element.dataset.trixMutable = !0; - }, undo: () => delete this.element.dataset.trixMutable })))), G(this, "addToolbar", ji((() => { - const r = x({ tagName: "div", className: Rt.attachmentToolbar, data: { trixMutable: !0 }, childNodes: x({ tagName: "div", className: "trix-button-row", childNodes: x({ tagName: "span", className: "trix-button-group trix-button-group--actions", childNodes: x({ tagName: "button", className: "trix-button trix-button--remove", textContent: Vi.remove, attributes: { title: Vi.remove }, data: { trixAction: "remove" } }) }) }) }); - return this.attachment.isPreviewable() && r.appendChild(x({ tagName: "div", className: Rt.attachmentMetadataContainer, childNodes: x({ tagName: "span", className: Rt.attachmentMetadata, childNodes: [x({ tagName: "span", className: Rt.attachmentName, textContent: this.attachment.getFilename(), attributes: { title: this.attachment.getFilename() } }), x({ tagName: "span", className: Rt.attachmentSize, textContent: this.attachment.getFormattedFilesize() })] }) })), B("click", { onElement: r, withCallback: this.didClickToolbar }), B("click", { onElement: r, matchingSelector: "[data-trix-action]", withCallback: this.didClickActionButton }), be("trix-attachment-before-toolbar", { onElement: this.element, attributes: { toolbar: r, attachment: this.attachment } }), { do: () => this.element.appendChild(r), undo: () => Ct(r) }; - }))), G(this, "installCaptionEditor", ji((() => { - const r = x({ tagName: "textarea", className: Rt.attachmentCaptionEditor, attributes: { placeholder: Vi.captionPlaceholder }, data: { trixMutable: !0 } }); + }, undo: () => delete this.element.dataset.trixMutable }))), G(this, "addToolbar", en(() => { + const r = x({ tagName: "div", className: Rt.attachmentToolbar, data: { trixMutable: !0 }, childNodes: x({ tagName: "div", className: "trix-button-row", childNodes: x({ tagName: "span", className: "trix-button-group trix-button-group--actions", childNodes: x({ tagName: "button", className: "trix-button trix-button--remove", textContent: tn.remove, attributes: { title: tn.remove }, data: { trixAction: "remove" } }) }) }) }); + return this.attachment.isPreviewable() && r.appendChild(x({ tagName: "div", className: Rt.attachmentMetadataContainer, childNodes: x({ tagName: "span", className: Rt.attachmentMetadata, childNodes: [x({ tagName: "span", className: Rt.attachmentName, textContent: this.attachment.getFilename(), attributes: { title: this.attachment.getFilename() } }), x({ tagName: "span", className: Rt.attachmentSize, textContent: this.attachment.getFormattedFilesize() })] }) })), B("click", { onElement: r, withCallback: this.didClickToolbar }), B("click", { onElement: r, matchingSelector: "[data-trix-action]", withCallback: this.didClickActionButton }), Ae("trix-attachment-before-toolbar", { onElement: this.element, attributes: { toolbar: r, attachment: this.attachment } }), { do: () => this.element.appendChild(r), undo: () => Ct(r) }; + })), G(this, "installCaptionEditor", en(() => { + const r = x({ tagName: "textarea", className: Rt.attachmentCaptionEditor, attributes: { placeholder: tn.captionPlaceholder }, data: { trixMutable: !0 } }); r.value = this.attachmentPiece.getCaption(); const a = r.cloneNode(); a.classList.add("trix-autoresize-clone"), a.tabIndex = -1; @@ -3811,11 +3819,11 @@ class ba extends H { B("input", { onElement: r, withCallback: o }), B("input", { onElement: r, withCallback: this.didInputCaption }), B("keydown", { onElement: r, withCallback: this.didKeyDownCaption }), B("change", { onElement: r, withCallback: this.didChangeCaption }), B("blur", { onElement: r, withCallback: this.didBlurCaption }); const l = this.element.querySelector("figcaption"), c = l.cloneNode(); return { do: () => { - if (l.style.display = "none", c.appendChild(r), c.appendChild(a), c.classList.add("".concat(Rt.attachmentCaption, "--editing")), l.parentElement.insertBefore(c, l), o(), this.options.editCaption) return kn((() => r.focus())); + if (l.style.display = "none", c.appendChild(r), c.appendChild(a), c.classList.add("".concat(Rt.attachmentCaption, "--editing")), l.parentElement.insertBefore(c, l), o(), this.options.editCaption) return Un(() => r.focus()); }, undo() { Ct(c), l.style.display = null; } }; - }))), this.didClickToolbar = this.didClickToolbar.bind(this), this.didClickActionButton = this.didClickActionButton.bind(this), this.didKeyDownCaption = this.didKeyDownCaption.bind(this), this.didInputCaption = this.didInputCaption.bind(this), this.didChangeCaption = this.didChangeCaption.bind(this), this.didBlurCaption = this.didBlurCaption.bind(this), this.attachmentPiece = t, this.element = e, this.container = i, this.options = n, this.attachment = this.attachmentPiece.attachment, Y(this.element) === "a" && (this.element = this.element.firstChild), this.install(); + })), this.didClickToolbar = this.didClickToolbar.bind(this), this.didClickActionButton = this.didClickActionButton.bind(this), this.didKeyDownCaption = this.didKeyDownCaption.bind(this), this.didInputCaption = this.didInputCaption.bind(this), this.didChangeCaption = this.didChangeCaption.bind(this), this.didBlurCaption = this.didBlurCaption.bind(this), this.attachmentPiece = t, this.element = e, this.container = i, this.options = n, this.attachment = this.attachmentPiece.attachment, Y(this.element) === "a" && (this.element = this.element.firstChild), this.install(); } install() { this.makeElementMutable(), this.addToolbar(), this.attachment.isPreviewable() && this.installCaptionEditor(); @@ -3842,7 +3850,7 @@ class ba extends H { } didKeyDownCaption(t) { var e, i; - if (dl[t.keyCode] === "return") return t.preventDefault(), this.savePendingCaption(), (e = this.delegate) === null || e === void 0 || (i = e.attachmentEditorDidRequestDeselectingAttachment) === null || i === void 0 ? void 0 : i.call(e, this.attachment); + if (wl[t.keyCode] === "return") return t.preventDefault(), this.savePendingCaption(), (e = this.delegate) === null || e === void 0 || (i = e.attachmentEditorDidRequestDeselectingAttachment) === null || i === void 0 ? void 0 : i.call(e, this.attachment); } didInputCaption(t) { this.pendingCaption = t.target.value.replace(/\s/g, " ").trim(); @@ -3854,9 +3862,9 @@ class ba extends H { return this.savePendingCaption(); } } -class _a extends H { +class Ra extends q { constructor(t, e) { - super(...arguments), this.didFocus = this.didFocus.bind(this), this.didBlur = this.didBlur.bind(this), this.didClickAttachment = this.didClickAttachment.bind(this), this.element = t, this.composition = e, this.documentView = new ri(this.composition.document, { element: this.element }), B("focus", { onElement: this.element, withCallback: this.didFocus }), B("blur", { onElement: this.element, withCallback: this.didBlur }), B("click", { onElement: this.element, matchingSelector: "a[contenteditable=false]", preventDefault: !0 }), B("mousedown", { onElement: this.element, matchingSelector: Bt, withCallback: this.didClickAttachment }), B("click", { onElement: this.element, matchingSelector: "a".concat(Bt), preventDefault: !0 }); + super(...arguments), this.didFocus = this.didFocus.bind(this), this.didBlur = this.didBlur.bind(this), this.didClickAttachment = this.didClickAttachment.bind(this), this.element = t, this.composition = e, this.documentView = new gi(this.composition.document, { element: this.element }), B("focus", { onElement: this.element, withCallback: this.didFocus }), B("blur", { onElement: this.element, withCallback: this.didBlur }), B("click", { onElement: this.element, matchingSelector: "a[contenteditable=false]", preventDefault: !0 }), B("mousedown", { onElement: this.element, matchingSelector: Mt, withCallback: this.didClickAttachment }), B("click", { onElement: this.element, matchingSelector: "a".concat(Mt), preventDefault: !0 }); } didFocus(t) { var e; @@ -3867,10 +3875,10 @@ class _a extends H { return ((e = this.blurPromise) === null || e === void 0 ? void 0 : e.then(i)) || i(); } didBlur(t) { - this.blurPromise = new Promise(((e) => kn((() => { + this.blurPromise = new Promise((e) => Un(() => { var i, n; - return Cn(this.element) || (this.focused = null, (i = this.delegate) === null || i === void 0 || (n = i.compositionControllerDidBlur) === null || n === void 0 || n.call(i)), this.blurPromise = null, e(); - })))); + return Hn(this.element) || (this.focused = null, (i = this.delegate) === null || i === void 0 || (n = i.compositionControllerDidBlur) === null || n === void 0 || n.call(i)), this.blurPromise = null, e(); + })); } didClickAttachment(t, e) { var i, n; @@ -3912,7 +3920,7 @@ class _a extends H { if (!n) return; this.uninstallAttachmentEditor(); const r = this.composition.document.getAttachmentPieceForAttachment(t); - this.attachmentEditor = new ba(r, n, this.element, e), this.attachmentEditor.delegate = this; + this.attachmentEditor = new Ia(r, n, this.element, e), this.attachmentEditor.delegate = this; } uninstallAttachmentEditor() { var t; @@ -3944,15 +3952,15 @@ class _a extends H { return this.composition.document.getAttachmentById(parseInt(t.dataset.trixId, 10)); } } -class va extends H { +class Da extends q { } -const ya = "data-trix-mutable", cl = "[".concat(ya, "]"), hl = { attributes: !0, childList: !0, characterData: !0, characterDataOldValue: !0, subtree: !0 }; -class Aa extends H { +const Oa = "data-trix-mutable", Tl = "[".concat(Oa, "]"), kl = { attributes: !0, childList: !0, characterData: !0, characterDataOldValue: !0, subtree: !0 }; +class Ba extends q { constructor(t) { super(t), this.didMutate = this.didMutate.bind(this), this.element = t, this.observer = new window.MutationObserver(this.didMutate), this.start(); } start() { - return this.reset(), this.observer.observe(this.element, hl); + return this.reset(), this.observer.observe(this.element, kl); } stop() { return this.observer.disconnect(); @@ -3965,7 +3973,7 @@ class Aa extends H { this.mutations = []; } findSignificantMutations(t) { - return t.filter(((e) => this.mutationIsSignificant(e))); + return t.filter((e) => this.mutationIsSignificant(e)); } mutationIsSignificant(t) { if (this.nodeIsMutable(t.target)) return !1; @@ -3973,16 +3981,16 @@ class Aa extends H { return !1; } nodeIsSignificant(t) { - return t !== this.element && !this.nodeIsMutable(t) && !qr(t); + return t !== this.element && !this.nodeIsMutable(t) && !Zr(t); } nodeIsMutable(t) { - return Lt(t, { matchingSelector: cl }); + return Lt(t, { matchingSelector: Tl }); } nodesModifiedByMutation(t) { const e = []; switch (t.type) { case "attributes": - t.attributeName !== ya && e.push(t.target); + t.attributeName !== Oa && e.push(t.target); break; case "characterData": e.push(t.target.parentNode), e.push(t.target); @@ -3997,41 +4005,41 @@ class Aa extends H { } getTextMutationSummary() { const { additions: t, deletions: e } = this.getTextChangesFromCharacterData(), i = this.getTextChangesFromChildList(); - Array.from(i.additions).forEach(((o) => { + Array.from(i.additions).forEach((o) => { Array.from(t).includes(o) || t.push(o); - })), e.push(...Array.from(i.deletions || [])); + }), e.push(...Array.from(i.deletions || [])); const n = {}, r = t.join(""); r && (n.textAdded = r); const a = e.join(""); return a && (n.textDeleted = a), n; } getMutationsByType(t) { - return Array.from(this.mutations).filter(((e) => e.type === t)); + return Array.from(this.mutations).filter((e) => e.type === t); } getTextChangesFromChildList() { let t, e; const i = [], n = []; - Array.from(this.getMutationsByType("childList")).forEach(((o) => { + Array.from(this.getMutationsByType("childList")).forEach((o) => { i.push(...Array.from(o.addedNodes || [])), n.push(...Array.from(o.removedNodes || [])); - })), i.length === 0 && n.length === 1 && Zt(n[0]) ? (t = [], e = [` -`]) : (t = yn(i), e = yn(n)); - const r = t.filter(((o, l) => o !== e[l])).map(fe), a = e.filter(((o, l) => o !== t[l])).map(fe); + }), i.length === 0 && n.length === 1 && ee(n[0]) ? (t = [], e = [` +`]) : (t = Rn(i), e = Rn(n)); + const r = t.filter((o, l) => o !== e[l]).map(ye), a = e.filter((o, l) => o !== t[l]).map(ye); return { additions: r, deletions: a }; } getTextChangesFromCharacterData() { let t, e; const i = this.getMutationsByType("characterData"); if (i.length) { - const n = i[0], r = i[i.length - 1], a = (function(o, l) { + const n = i[0], r = i[i.length - 1], a = function(o, l) { let c, u; - return o = Le.box(o), (l = Le.box(l)).length < o.length ? [u, c] = us(o, l) : [c, u] = us(l, o), { added: c, removed: u }; - })(fe(n.oldValue), fe(r.target.data)); + return o = ke.box(o), (l = ke.box(l)).length < o.length ? [u, c] = Ls(o, l) : [c, u] = Ls(l, o), { added: c, removed: u }; + }(ye(n.oldValue), ye(r.target.data)); t = a.added, e = a.removed; } return { additions: t ? [t] : [], deletions: e ? [e] : [] }; } } -const yn = function() { +const Rn = function() { let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : []; const t = []; for (const e of Array.from(s)) switch (e.nodeType) { @@ -4040,11 +4048,11 @@ const yn = function() { break; case Node.ELEMENT_NODE: Y(e) === "br" ? t.push(` -`) : t.push(...Array.from(yn(e.childNodes) || [])); +`) : t.push(...Array.from(Rn(e.childNodes) || [])); } return t; }; -class Ea extends ti { +class Ma extends oi { constructor(t) { super(...arguments), this.file = t; } @@ -4060,15 +4068,15 @@ class Ea extends ti { }, e.readAsArrayBuffer(this.file); } } -class ul { +class Il { constructor(t) { this.element = t; } shouldIgnore(t) { - return !!Te.samsungAndroid && (this.previousEvent = this.event, this.event = t, this.checkSamsungKeyboardBuggyModeStart(), this.checkSamsungKeyboardBuggyModeEnd(), this.buggyMode); + return !!Oe.samsungAndroid && (this.previousEvent = this.event, this.event = t, this.checkSamsungKeyboardBuggyModeStart(), this.checkSamsungKeyboardBuggyModeEnd(), this.buggyMode); } checkSamsungKeyboardBuggyModeStart() { - this.insertingLongTextAfterUnidentifiedChar() && ml(this.element.innerText, this.event.data) && (this.buggyMode = !0, this.event.preventDefault()); + this.insertingLongTextAfterUnidentifiedChar() && Rl(this.element.innerText, this.event.data) && (this.buggyMode = !0, this.event.preventDefault()); } checkSamsungKeyboardBuggyModeEnd() { this.buggyMode && this.event.inputType !== "insertText" && (this.buggyMode = !1); @@ -4085,10 +4093,10 @@ class ul { return ((t = this.previousEvent) === null || t === void 0 ? void 0 : t.type) === "keydown" && ((e = this.previousEvent) === null || e === void 0 ? void 0 : e.key) === "Unidentified"; } } -const ml = (s, t) => Os(s) === Os(t), gl = new RegExp("(".concat("", "|").concat(ni, "|").concat(St, "|\\s)+"), "g"), Os = (s) => s.replace(gl, " ").trim(); -class ai extends H { +const Rl = (s, t) => zs(s) === zs(t), Dl = new RegExp("(".concat("", "|").concat(ui, "|").concat(St, "|\\s)+"), "g"), zs = (s) => s.replace(Dl, " ").trim(); +class pi extends q { constructor(t) { - super(...arguments), this.element = t, this.mutationObserver = new Aa(this.element), this.mutationObserver.delegate = this, this.flakyKeyboardDetector = new ul(this.element); + super(...arguments), this.element = t, this.mutationObserver = new Ba(this.element), this.mutationObserver.delegate = this, this.flakyKeyboardDetector = new Il(this.element); for (const e in this.constructor.events) B(e, { onElement: this.element, withCallback: this.handlerFor(e) }); } elementDidMutate(t) { @@ -4108,22 +4116,22 @@ class ai extends H { return (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidRequestReparse) === null || e === void 0 || e.call(t), this.requestRender(); } attachFiles(t) { - const e = Array.from(t).map(((i) => new Ea(i))); - return Promise.all(e).then(((i) => { - this.handleInput((function() { + const e = Array.from(t).map((i) => new Ma(i)); + return Promise.all(e).then((i) => { + this.handleInput(function() { var n, r; return (n = this.delegate) === null || n === void 0 || n.inputControllerWillAttachFiles(), (r = this.responder) === null || r === void 0 || r.insertFiles(i), this.requestRender(); - })); - })); + }); + }); } handlerFor(t) { return (e) => { - e.defaultPrevented || this.handleInput((() => { - if (!Cn(this.element)) { + e.defaultPrevented || this.handleInput(() => { + if (!Hn(this.element)) { if (this.flakyKeyboardDetector.shouldIgnore(e)) return; this.eventName = t, this.constructor.events[t].call(this, e); } - })); + }); }; } handleInput(t) { @@ -4140,11 +4148,11 @@ class ai extends H { return i.href = t, i.textContent = e || t, i.outerHTML; } } -var Wi; -G(ai, "events", {}); -const { browser: pl, keyNames: xa } = ke; -let fl = 0; -class bt extends ai { +var nn; +G(pi, "events", {}); +const { browser: Ol, keyNames: Na } = Be; +let Bl = 0; +class bt extends pi { constructor() { super(...arguments), this.resetInputSummary(); } @@ -4161,13 +4169,13 @@ class bt extends ai { this.inputSummary = {}; } reset() { - return this.resetInputSummary(), Ht.reset(); + return this.resetInputSummary(), qt.reset(); } elementDidMutate(t) { var e, i; - return this.isComposing() ? (e = this.delegate) === null || e === void 0 || (i = e.inputControllerDidAllowUnhandledInput) === null || i === void 0 ? void 0 : i.call(e) : this.handleInput((function() { + return this.isComposing() ? (e = this.delegate) === null || e === void 0 || (i = e.inputControllerDidAllowUnhandledInput) === null || i === void 0 ? void 0 : i.call(e) : this.handleInput(function() { return this.mutationIsSignificant(t) && (this.mutationIsExpected(t) ? this.requestRender() : this.requestReparse()), this.reset(); - })); + }); } mutationIsExpected(t) { let { textAdded: e, textDeleted: i } = t; @@ -4180,7 +4188,7 @@ class bt extends ai { const c = this.getSelectedRange(); if (c) { var l; - const u = a ? e.replace(/\n$/, "").length || -1 : e?.length || 1; + const u = a ? e.replace(/\n$/, "").length || -1 : (e == null ? void 0 : e.length) || 1; if ((l = this.responder) !== null && l !== void 0 && l.positionIsBlockBreak(c[1] + u)) return !0; } } @@ -4193,7 +4201,7 @@ class bt extends ai { } getCompositionInput() { if (this.isComposing()) return this.compositionInput; - this.compositionInput = new At(this); + this.compositionInput = new Et(this); } isComposing() { return this.compositionInput && !this.compositionInput.isEnded(); @@ -4204,10 +4212,10 @@ class bt extends ai { } serializeSelectionToDataTransfer(t) { var e; - if (!(function(n) { + if (!function(n) { if (n == null || !n.setData) return !1; - for (const r in ds) { - const a = ds[r]; + for (const r in Es) { + const a = Es[r]; try { if (n.setData(r, a), !n.getData(r) === a) return !1; } catch { @@ -4215,48 +4223,48 @@ class bt extends ai { } } return !0; - })(t)) return; + }(t)) return; const i = (e = this.responder) === null || e === void 0 ? void 0 : e.getSelectedDocument().toSerializableDocument(); - return t.setData("application/x-trix-document", JSON.stringify(i)), t.setData("text/html", ri.render(i).innerHTML), t.setData("text/plain", i.toString().replace(/\n$/, "")), !0; + return t.setData("application/x-trix-document", JSON.stringify(i)), t.setData("text/html", gi.render(i).innerHTML), t.setData("text/plain", i.toString().replace(/\n$/, "")), !0; } canAcceptDataTransfer(t) { const e = {}; - return Array.from(t?.types || []).forEach(((i) => { + return Array.from((t == null ? void 0 : t.types) || []).forEach((i) => { e[i] = !0; - })), e.Files || e["application/x-trix-document"] || e["text/html"] || e["text/plain"]; + }), e.Files || e["application/x-trix-document"] || e["text/html"] || e["text/plain"]; } getPastedHTMLUsingHiddenElement(t) { const e = this.getSelectedRange(), i = { position: "absolute", left: "".concat(window.pageXOffset, "px"), top: "".concat(window.pageYOffset, "px"), opacity: 0 }, n = x({ style: i, tagName: "div", editable: !0 }); - return document.body.appendChild(n), n.focus(), requestAnimationFrame((() => { + return document.body.appendChild(n), n.focus(), requestAnimationFrame(() => { const r = n.innerHTML; return Ct(n), this.setSelectedRange(e), t(r); - })); + }); } } G(bt, "events", { keydown(s) { this.isComposing() || this.resetInputSummary(), this.inputSummary.didInput = !0; - const t = xa[s.keyCode]; + const t = Na[s.keyCode]; if (t) { var e; let n = this.keys; - ["ctrl", "alt", "shift", "meta"].forEach(((r) => { + ["ctrl", "alt", "shift", "meta"].forEach((r) => { var a; s["".concat(r, "Key")] && (r === "ctrl" && (r = "control"), n = (a = n) === null || a === void 0 ? void 0 : a[r]); - })), ((e = n) === null || e === void 0 ? void 0 : e[t]) != null && (this.setInputSummary({ keyName: t }), Ht.reset(), n[t].call(this, s)); + }), ((e = n) === null || e === void 0 ? void 0 : e[t]) != null && (this.setInputSummary({ keyName: t }), qt.reset(), n[t].call(this, s)); } - if (jr(s)) { + if (na(s)) { const n = String.fromCharCode(s.keyCode).toLowerCase(); if (n) { var i; - const r = ["alt", "shift"].map(((a) => { + const r = ["alt", "shift"].map((a) => { if (s["".concat(a, "Key")]) return a; - })).filter(((a) => a)); + }).filter((a) => a); r.push(n), (i = this.delegate) !== null && i !== void 0 && i.inputControllerDidReceiveKeyboardCommand(r) && s.preventDefault(); } } }, keypress(s) { if (this.inputSummary.eventName != null || s.metaKey || s.ctrlKey && !s.altKey) return; - const t = vl(s); + const t = Pl(s); var e, i; return t ? ((e = this.delegate) === null || e === void 0 || e.inputControllerWillPerformTyping(), (i = this.responder) === null || i === void 0 || i.insertString(t), this.setInputSummary({ textAdded: t, didDelete: this.selectionIsExpanded() })) : void 0; }, textInput(s) { @@ -4276,7 +4284,7 @@ G(bt, "events", { keydown(s) { s.preventDefault(); const i = { x: s.clientX, y: s.clientY }; var t, e; - if (!ne(i, this.draggingPoint)) return this.draggingPoint = i, (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidReceiveDragOverPoint) === null || e === void 0 ? void 0 : e.call(t, this.draggingPoint); + if (!re(i, this.draggingPoint)) return this.draggingPoint = i, (t = this.delegate) === null || t === void 0 || (e = t.inputControllerDidReceiveDragOverPoint) === null || e === void 0 ? void 0 : e.call(t, this.draggingPoint); } }, dragend(s) { var t, e; @@ -4303,28 +4311,28 @@ G(bt, "events", { keydown(s) { (t = this.responder) !== null && t !== void 0 && t.selectionIsExpanded() && this.serializeSelectionToDataTransfer(s.clipboardData) && s.preventDefault(); }, paste(s) { const t = s.clipboardData || s.testClipboardData, e = { clipboard: t }; - if (!t || yl(s)) return void this.getPastedHTMLUsingHiddenElement(((_) => { - var S, E, j; - return e.type = "text/html", e.html = _, (S = this.delegate) === null || S === void 0 || S.inputControllerWillPaste(e), (E = this.responder) === null || E === void 0 || E.insertHTML(e.html), this.requestRender(), (j = this.delegate) === null || j === void 0 ? void 0 : j.inputControllerDidPaste(e); - })); + if (!t || Fl(s)) return void this.getPastedHTMLUsingHiddenElement((_) => { + var S, E, z; + return e.type = "text/html", e.html = _, (S = this.delegate) === null || S === void 0 || S.inputControllerWillPaste(e), (E = this.responder) === null || E === void 0 || E.insertHTML(e.html), this.requestRender(), (z = this.delegate) === null || z === void 0 ? void 0 : z.inputControllerDidPaste(e); + }); const i = t.getData("URL"), n = t.getData("text/html"), r = t.getData("public.url-name"); if (i) { var a, o, l; let _; - e.type = "text/html", _ = r ? Rn(r).trim() : i, e.html = this.createLinkHTML(i, _), (a = this.delegate) === null || a === void 0 || a.inputControllerWillPaste(e), this.setInputSummary({ textAdded: _, didDelete: this.selectionIsExpanded() }), (o = this.responder) === null || o === void 0 || o.insertHTML(e.html), this.requestRender(), (l = this.delegate) === null || l === void 0 || l.inputControllerDidPaste(e); - } else if (Vr(t)) { + e.type = "text/html", _ = r ? jn(r).trim() : i, e.html = this.createLinkHTML(i, _), (a = this.delegate) === null || a === void 0 || a.inputControllerWillPaste(e), this.setInputSummary({ textAdded: _, didDelete: this.selectionIsExpanded() }), (o = this.responder) === null || o === void 0 || o.insertHTML(e.html), this.requestRender(), (l = this.delegate) === null || l === void 0 || l.inputControllerDidPaste(e); + } else if (ia(t)) { var c, u, m; e.type = "text/plain", e.string = t.getData("text/plain"), (c = this.delegate) === null || c === void 0 || c.inputControllerWillPaste(e), this.setInputSummary({ textAdded: e.string, didDelete: this.selectionIsExpanded() }), (u = this.responder) === null || u === void 0 || u.insertString(e.string), this.requestRender(), (m = this.delegate) === null || m === void 0 || m.inputControllerDidPaste(e); } else if (n) { - var p, h, b; - e.type = "text/html", e.html = n, (p = this.delegate) === null || p === void 0 || p.inputControllerWillPaste(e), (h = this.responder) === null || h === void 0 || h.insertHTML(e.html), this.requestRender(), (b = this.delegate) === null || b === void 0 || b.inputControllerDidPaste(e); + var p, h, f; + e.type = "text/html", e.html = n, (p = this.delegate) === null || p === void 0 || p.inputControllerWillPaste(e), (h = this.responder) === null || h === void 0 || h.insertHTML(e.html), this.requestRender(), (f = this.delegate) === null || f === void 0 || f.inputControllerDidPaste(e); } else if (Array.from(t.types).includes("Files")) { var A, I; const _ = (A = t.items) === null || A === void 0 || (A = A[0]) === null || A === void 0 || (I = A.getAsFile) === null || I === void 0 ? void 0 : I.call(A); if (_) { - var q, R, $; - const S = bl(_); - !_.name && S && (_.name = "pasted-file-".concat(++fl, ".").concat(S)), e.type = "File", e.file = _, (q = this.delegate) === null || q === void 0 || q.inputControllerWillAttachFiles(), (R = this.responder) === null || R === void 0 || R.insertFile(e.file), this.requestRender(), ($ = this.delegate) === null || $ === void 0 || $.inputControllerDidPaste(e); + var $, R, U; + const S = Ml(_); + !_.name && S && (_.name = "pasted-file-".concat(++Bl, ".").concat(S)), e.type = "File", e.file = _, ($ = this.delegate) === null || $ === void 0 || $.inputControllerWillAttachFiles(), (R = this.responder) === null || R === void 0 || R.insertFile(e.file), this.requestRender(), (U = this.delegate) === null || U === void 0 || U.inputControllerDidPaste(e); } } s.preventDefault(); @@ -4384,16 +4392,16 @@ G(bt, "events", { keydown(s) { var t; return this.setInputSummary({ preferDocument: !1 }), (t = this.delegate) === null || t === void 0 ? void 0 : t.inputControllerWillPerformTyping(); } } }), bt.proxyMethod("responder?.getSelectedRange"), bt.proxyMethod("responder?.setSelectedRange"), bt.proxyMethod("responder?.expandSelectionInDirection"), bt.proxyMethod("responder?.selectionIsInCursorTarget"), bt.proxyMethod("responder?.selectionIsExpanded"); -const bl = (s) => { +const Ml = (s) => { var t; return (t = s.type) === null || t === void 0 || (t = t.match(/\/(\w+)$/)) === null || t === void 0 ? void 0 : t[1]; -}, _l = !((Wi = " ".codePointAt) === null || Wi === void 0 || !Wi.call(" ", 0)), vl = function(s) { - if (s.key && _l && s.key.codePointAt(0) === s.keyCode) return s.key; +}, Nl = !((nn = " ".codePointAt) === null || nn === void 0 || !nn.call(" ", 0)), Pl = function(s) { + if (s.key && Nl && s.key.codePointAt(0) === s.keyCode) return s.key; { let t; - if (s.which === null ? t = s.keyCode : s.which !== 0 && s.charCode !== 0 && (t = s.charCode), t != null && xa[t] !== "escape") return Le.fromCodepoints([t]).toString(); + if (s.which === null ? t = s.keyCode : s.which !== 0 && s.charCode !== 0 && (t = s.charCode), t != null && Na[t] !== "escape") return ke.fromCodepoints([t]).toString(); } -}, yl = function(s) { +}, Fl = function(s) { const t = s.clipboardData; if (t) { if (t.types.includes("text/html")) { @@ -4409,7 +4417,7 @@ const bl = (s) => { } } }; -class At extends H { +class Et extends q { constructor(t) { super(...arguments), this.inputController = t, this.responder = this.inputController.responder, this.delegate = this.inputController.delegate, this.inputSummary = this.inputController.inputSummary, this.data = {}; } @@ -4436,15 +4444,15 @@ class At extends H { return this.getEndData() != null; } isSignificant() { - return !pl.composesExistingText || this.inputSummary.didInput; + return !Ol.composesExistingText || this.inputSummary.didInput; } canApplyToDocument() { var t, e; return ((t = this.data.start) === null || t === void 0 ? void 0 : t.length) === 0 && ((e = this.data.end) === null || e === void 0 ? void 0 : e.length) > 0 && this.range; } } -At.proxyMethod("inputController.setInputSummary"), At.proxyMethod("inputController.requestRender"), At.proxyMethod("inputController.requestReparse"), At.proxyMethod("responder?.selectionIsExpanded"), At.proxyMethod("responder?.insertPlaceholder"), At.proxyMethod("responder?.selectPlaceholder"), At.proxyMethod("responder?.forgetPlaceholder"); -class Ee extends ai { +Et.proxyMethod("inputController.setInputSummary"), Et.proxyMethod("inputController.requestRender"), Et.proxyMethod("inputController.requestReparse"), Et.proxyMethod("responder?.selectionIsExpanded"), Et.proxyMethod("responder?.insertPlaceholder"), Et.proxyMethod("responder?.selectPlaceholder"), Et.proxyMethod("responder?.forgetPlaceholder"); +class Ce extends pi { constructor() { super(...arguments), this.render = this.render.bind(this); } @@ -4466,24 +4474,24 @@ class Ee extends ai { insertString() { var t; let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : "", i = arguments.length > 1 ? arguments[1] : void 0; - return (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), this.withTargetDOMRange((function() { + return (t = this.delegate) === null || t === void 0 || t.inputControllerWillPerformTyping(), this.withTargetDOMRange(function() { var n; return (n = this.responder) === null || n === void 0 ? void 0 : n.insertString(e, i); - })); + }); } toggleAttributeIfSupported(t) { var e; - if (mn().includes(t)) return (e = this.delegate) === null || e === void 0 || e.inputControllerWillPerformFormatting(t), this.withTargetDOMRange((function() { + if (Sn().includes(t)) return (e = this.delegate) === null || e === void 0 || e.inputControllerWillPerformFormatting(t), this.withTargetDOMRange(function() { var i; return (i = this.responder) === null || i === void 0 ? void 0 : i.toggleCurrentAttribute(t); - })); + }); } activateAttributeIfSupported(t, e) { var i; - if (mn().includes(t)) return (i = this.delegate) === null || i === void 0 || i.inputControllerWillPerformFormatting(t), this.withTargetDOMRange((function() { + if (Sn().includes(t)) return (i = this.delegate) === null || i === void 0 || i.inputControllerWillPerformFormatting(t), this.withTargetDOMRange(function() { var n; return (n = this.responder) === null || n === void 0 ? void 0 : n.setCurrentAttribute(t, e); - })); + }); } deleteInDirection(t) { let { recordUndoEntry: e } = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : { recordUndoEntry: !0 }; @@ -4497,14 +4505,14 @@ class Ee extends ai { } withTargetDOMRange(t, e) { var i; - return typeof t == "function" && (e = t, t = this.getTargetDOMRange()), t ? (i = this.responder) === null || i === void 0 ? void 0 : i.withTargetDOMRange(t, e.bind(this)) : (Ht.reset(), e.call(this)); + return typeof t == "function" && (e = t, t = this.getTargetDOMRange()), t ? (i = this.responder) === null || i === void 0 ? void 0 : i.withTargetDOMRange(t, e.bind(this)) : (qt.reset(), e.call(this)); } getTargetDOMRange() { var t, e; let { minLength: i } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : { minLength: 0 }; const n = (t = (e = this.event).getTargetRanges) === null || t === void 0 ? void 0 : t.call(e); if (n && n.length) { - const r = Al(n[0]); + const r = Hl(n[0]); if (i === 0 || r.toString().length >= i) return r; } } @@ -4519,10 +4527,10 @@ class Ee extends ai { return i; } } -G(Ee, "events", { keydown(s) { - if (jr(s)) { +G(Ce, "events", { keydown(s) { + if (na(s)) { var t; - const e = Sl(s); + const e = Ul(s); (t = this.delegate) !== null && t !== void 0 && t.inputControllerDidReceiveKeyboardCommand(e) && s.preventDefault(); } else { let e = s.key; @@ -4534,41 +4542,41 @@ G(Ee, "events", { keydown(s) { var t; let e; const i = (t = s.clipboardData) === null || t === void 0 ? void 0 : t.getData("URL"); - return Sa(s) ? (s.preventDefault(), this.attachFiles(s.clipboardData.files)) : xl(s) ? (s.preventDefault(), e = { type: "text/plain", string: s.clipboardData.getData("text/plain") }, (n = this.delegate) === null || n === void 0 || n.inputControllerWillPaste(e), (r = this.responder) === null || r === void 0 || r.insertString(e.string), this.render(), (a = this.delegate) === null || a === void 0 ? void 0 : a.inputControllerDidPaste(e)) : i ? (s.preventDefault(), e = { type: "text/html", html: this.createLinkHTML(i) }, (o = this.delegate) === null || o === void 0 || o.inputControllerWillPaste(e), (l = this.responder) === null || l === void 0 || l.insertHTML(e.html), this.render(), (c = this.delegate) === null || c === void 0 ? void 0 : c.inputControllerDidPaste(e)) : void 0; + return Pa(s) ? (s.preventDefault(), this.attachFiles(s.clipboardData.files)) : $l(s) ? (s.preventDefault(), e = { type: "text/plain", string: s.clipboardData.getData("text/plain") }, (n = this.delegate) === null || n === void 0 || n.inputControllerWillPaste(e), (r = this.responder) === null || r === void 0 || r.insertString(e.string), this.render(), (a = this.delegate) === null || a === void 0 ? void 0 : a.inputControllerDidPaste(e)) : i ? (s.preventDefault(), e = { type: "text/html", html: this.createLinkHTML(i) }, (o = this.delegate) === null || o === void 0 || o.inputControllerWillPaste(e), (l = this.responder) === null || l === void 0 || l.insertHTML(e.html), this.render(), (c = this.delegate) === null || c === void 0 ? void 0 : c.inputControllerDidPaste(e)) : void 0; var n, r, a, o, l, c; }, beforeinput(s) { const t = this.constructor.inputTypes[s.inputType], e = (i = s, !(!/iPhone|iPad/.test(navigator.userAgent) || i.inputType && i.inputType !== "insertParagraph")); var i; t && (this.withEvent(s, t), e || this.scheduleRender()), e && this.render(); }, input(s) { - Ht.reset(); + qt.reset(); }, dragstart(s) { var t, e; - (t = this.responder) !== null && t !== void 0 && t.selectionContainsAttachments() && (s.dataTransfer.setData("application/x-trix-dragging", !0), this.dragging = { range: (e = this.responder) === null || e === void 0 ? void 0 : e.getSelectedRange(), point: Ki(s) }); + (t = this.responder) !== null && t !== void 0 && t.selectionContainsAttachments() && (s.dataTransfer.setData("application/x-trix-dragging", !0), this.dragging = { range: (e = this.responder) === null || e === void 0 ? void 0 : e.getSelectedRange(), point: rn(s) }); }, dragenter(s) { - zi(s) && s.preventDefault(); + sn(s) && s.preventDefault(); }, dragover(s) { if (this.dragging) { s.preventDefault(); - const e = Ki(s); + const e = rn(s); var t; - if (!ne(e, this.dragging.point)) return this.dragging.point = e, (t = this.responder) === null || t === void 0 ? void 0 : t.setLocationRangeFromPointRange(e); - } else zi(s) && s.preventDefault(); + if (!re(e, this.dragging.point)) return this.dragging.point = e, (t = this.responder) === null || t === void 0 ? void 0 : t.setLocationRangeFromPointRange(e); + } else sn(s) && s.preventDefault(); }, drop(s) { var t, e; if (this.dragging) return s.preventDefault(), (t = this.delegate) === null || t === void 0 || t.inputControllerWillMoveText(), (e = this.responder) === null || e === void 0 || e.moveTextFromRange(this.dragging.range), this.dragging = null, this.scheduleRender(); - if (zi(s)) { + if (sn(s)) { var i; s.preventDefault(); - const n = Ki(s); + const n = rn(s); return (i = this.responder) === null || i === void 0 || i.setLocationRangeFromPointRange(n), this.attachFiles(s.dataTransfer.files); } }, dragend() { var s; this.dragging && ((s = this.responder) === null || s === void 0 || s.setSelectedRange(this.dragging.range), this.dragging = null); }, compositionend(s) { - this.composing && (this.composing = !1, Te.recentAndroid || this.scheduleRender()); -} }), G(Ee, "keys", { ArrowLeft() { + this.composing && (this.composing = !1, Oe.recentAndroid || this.scheduleRender()); +} }), G(Ce, "keys", { ArrowLeft() { var s, t; if ((s = this.responder) !== null && s !== void 0 && s.shouldManageMovingCursorInDirection("backward")) return this.event.preventDefault(), (t = this.responder) === null || t === void 0 ? void 0 : t.moveCursorInDirection("backward"); }, ArrowRight() { @@ -4583,15 +4591,15 @@ G(Ee, "events", { keydown(s) { }, "Tab+Shift"() { var s, t; if ((s = this.responder) !== null && s !== void 0 && s.canDecreaseNestingLevel()) return this.event.preventDefault(), (t = this.responder) === null || t === void 0 || t.decreaseNestingLevel(), this.render(); -} }), G(Ee, "inputTypes", { deleteByComposition() { +} }), G(Ce, "inputTypes", { deleteByComposition() { return this.deleteInDirection("backward", { recordUndoEntry: !1 }); }, deleteByCut() { return this.deleteInDirection("backward"); }, deleteByDrag() { - return this.event.preventDefault(), this.withTargetDOMRange((function() { + return this.event.preventDefault(), this.withTargetDOMRange(function() { var s; this.deleteByDragRange = (s = this.responder) === null || s === void 0 ? void 0 : s.getSelectedRange(); - })); + }); }, deleteCompositionText() { return this.deleteInDirection("backward", { recordUndoEntry: !1 }); }, deleteContent() { @@ -4624,10 +4632,10 @@ G(Ee, "events", { keydown(s) { return this.activateAttributeIfSupported("font", this.event.data); }, formatIndent() { var s; - if ((s = this.responder) !== null && s !== void 0 && s.canIncreaseNestingLevel()) return this.withTargetDOMRange((function() { + if ((s = this.responder) !== null && s !== void 0 && s.canIncreaseNestingLevel()) return this.withTargetDOMRange(function() { var t; return (t = this.responder) === null || t === void 0 ? void 0 : t.increaseNestingLevel(); - })); + }); }, formatItalic() { return this.toggleAttributeIfSupported("italic"); }, formatJustifyCenter() { @@ -4640,17 +4648,17 @@ G(Ee, "events", { keydown(s) { return this.toggleAttributeIfSupported("justifyRight"); }, formatOutdent() { var s; - if ((s = this.responder) !== null && s !== void 0 && s.canDecreaseNestingLevel()) return this.withTargetDOMRange((function() { + if ((s = this.responder) !== null && s !== void 0 && s.canDecreaseNestingLevel()) return this.withTargetDOMRange(function() { var t; return (t = this.responder) === null || t === void 0 ? void 0 : t.decreaseNestingLevel(); - })); + }); }, formatRemove() { - this.withTargetDOMRange((function() { + this.withTargetDOMRange(function() { for (const e in (s = this.responder) === null || s === void 0 ? void 0 : s.getCurrentAttributes()) { var s, t; (t = this.responder) === null || t === void 0 || t.removeCurrentAttribute(e); } - })); + }); }, formatSetBlockTextDirection() { return this.activateAttributeIfSupported("blockDir", this.event.data); }, formatSetInlineTextDirection() { @@ -4676,10 +4684,10 @@ G(Ee, "events", { keydown(s) { }, insertFromDrop() { const s = this.deleteByDragRange; var t; - if (s) return this.deleteByDragRange = null, (t = this.delegate) === null || t === void 0 || t.inputControllerWillMoveText(), this.withTargetDOMRange((function() { + if (s) return this.deleteByDragRange = null, (t = this.delegate) === null || t === void 0 || t.inputControllerWillMoveText(), this.withTargetDOMRange(function() { var e; return (e = this.responder) === null || e === void 0 ? void 0 : e.moveTextFromRange(s); - })); + }); }, insertFromPaste() { const { dataTransfer: s } = this.event, t = { dataTransfer: s }, e = s.getData("URL"), i = s.getData("text/html"); if (e) { @@ -4687,37 +4695,37 @@ G(Ee, "events", { keydown(s) { let l; this.event.preventDefault(), t.type = "text/html"; const c = s.getData("public.url-name"); - l = c ? Rn(c).trim() : e, t.html = this.createLinkHTML(e, l), (n = this.delegate) === null || n === void 0 || n.inputControllerWillPaste(t), this.withTargetDOMRange((function() { + l = c ? jn(c).trim() : e, t.html = this.createLinkHTML(e, l), (n = this.delegate) === null || n === void 0 || n.inputControllerWillPaste(t), this.withTargetDOMRange(function() { var u; return (u = this.responder) === null || u === void 0 ? void 0 : u.insertHTML(t.html); - })), this.afterRender = () => { + }), this.afterRender = () => { var u; return (u = this.delegate) === null || u === void 0 ? void 0 : u.inputControllerDidPaste(t); }; - } else if (Vr(s)) { + } else if (ia(s)) { var r; - t.type = "text/plain", t.string = s.getData("text/plain"), (r = this.delegate) === null || r === void 0 || r.inputControllerWillPaste(t), this.withTargetDOMRange((function() { + t.type = "text/plain", t.string = s.getData("text/plain"), (r = this.delegate) === null || r === void 0 || r.inputControllerWillPaste(t), this.withTargetDOMRange(function() { var l; return (l = this.responder) === null || l === void 0 ? void 0 : l.insertString(t.string); - })), this.afterRender = () => { + }), this.afterRender = () => { var l; return (l = this.delegate) === null || l === void 0 ? void 0 : l.inputControllerDidPaste(t); }; - } else if (El(this.event)) { + } else if (ql(this.event)) { var a; - t.type = "File", t.file = s.files[0], (a = this.delegate) === null || a === void 0 || a.inputControllerWillPaste(t), this.withTargetDOMRange((function() { + t.type = "File", t.file = s.files[0], (a = this.delegate) === null || a === void 0 || a.inputControllerWillPaste(t), this.withTargetDOMRange(function() { var l; return (l = this.responder) === null || l === void 0 ? void 0 : l.insertFile(t.file); - })), this.afterRender = () => { + }), this.afterRender = () => { var l; return (l = this.delegate) === null || l === void 0 ? void 0 : l.inputControllerDidPaste(t); }; } else if (i) { var o; - this.event.preventDefault(), t.type = "text/html", t.html = i, (o = this.delegate) === null || o === void 0 || o.inputControllerWillPaste(t), this.withTargetDOMRange((function() { + this.event.preventDefault(), t.type = "text/html", t.html = i, (o = this.delegate) === null || o === void 0 || o.inputControllerWillPaste(t), this.withTargetDOMRange(function() { var l; return (l = this.responder) === null || l === void 0 ? void 0 : l.insertHTML(t.html); - })), this.afterRender = () => { + }), this.afterRender = () => { var l; return (l = this.delegate) === null || l === void 0 ? void 0 : l.inputControllerDidPaste(t); }; @@ -4733,15 +4741,15 @@ G(Ee, "events", { keydown(s) { return this.toggleAttributeIfSupported("number"); }, insertParagraph() { var s; - return (s = this.delegate) === null || s === void 0 || s.inputControllerWillPerformTyping(), this.withTargetDOMRange((function() { + return (s = this.delegate) === null || s === void 0 || s.inputControllerWillPerformTyping(), this.withTargetDOMRange(function() { var t; return (t = this.responder) === null || t === void 0 ? void 0 : t.insertLineBreak(); - })); + }); }, insertReplacementText() { const s = this.event.dataTransfer.getData("text/plain"), t = this.event.getTargetRanges()[0]; - this.withTargetDOMRange(t, (() => { + this.withTargetDOMRange(t, () => { this.insertString(s, { updatePosition: !1 }); - })); + }); }, insertText() { var s; return this.insertString(this.event.data || ((s = this.event.dataTransfer) === null || s === void 0 ? void 0 : s.getData("text/plain"))); @@ -4750,49 +4758,49 @@ G(Ee, "events", { keydown(s) { }, insertUnorderedList() { return this.toggleAttributeIfSupported("bullet"); } }); -const Al = function(s) { +const Hl = function(s) { const t = document.createRange(); return t.setStart(s.startContainer, s.startOffset), t.setEnd(s.endContainer, s.endOffset), t; -}, zi = (s) => { +}, sn = (s) => { var t; return Array.from(((t = s.dataTransfer) === null || t === void 0 ? void 0 : t.types) || []).includes("Files"); -}, El = (s) => { +}, ql = (s) => { var t; - return ((t = s.dataTransfer.files) === null || t === void 0 ? void 0 : t[0]) && !Sa(s) && !((e) => { + return ((t = s.dataTransfer.files) === null || t === void 0 ? void 0 : t[0]) && !Pa(s) && !((e) => { let { dataTransfer: i } = e; return i.types.includes("Files") && i.types.includes("text/html") && i.getData("text/html").includes("urn:schemas-microsoft-com:office:office"); })(s); -}, Sa = function(s) { +}, Pa = function(s) { const t = s.clipboardData; if (t) - return Array.from(t.types).filter(((e) => e.match(/file/i))).length === t.types.length && t.files.length >= 1; -}, xl = function(s) { + return Array.from(t.types).filter((e) => e.match(/file/i)).length === t.types.length && t.files.length >= 1; +}, $l = function(s) { const t = s.clipboardData; if (t) return t.types.includes("text/plain") && t.types.length === 1; -}, Sl = function(s) { +}, Ul = function(s) { const t = []; return s.altKey && t.push("alt"), s.shiftKey && t.push("shift"), t.push(s.key), t; -}, Ki = (s) => ({ x: s.clientX, y: s.clientY }), An = "[data-trix-attribute]", En = "[data-trix-action]", Ll = "".concat(An, ", ").concat(En), oi = "[data-trix-dialog]", Cl = "".concat(oi, "[data-trix-active]"), wl = "".concat(oi, " [data-trix-method]"), Bs = "".concat(oi, " [data-trix-input]"), Ms = (s, t) => (t || (t = Qt(s)), s.querySelector("[data-trix-input][name='".concat(t, "']"))), Ns = (s) => s.getAttribute("data-trix-action"), Qt = (s) => s.getAttribute("data-trix-attribute") || s.getAttribute("data-trix-dialog-attribute"); -class La extends H { +}, rn = (s) => ({ x: s.clientX, y: s.clientY }), Dn = "[data-trix-attribute]", On = "[data-trix-action]", Vl = "".concat(Dn, ", ").concat(On), fi = "[data-trix-dialog]", jl = "".concat(fi, "[data-trix-active]"), Wl = "".concat(fi, " [data-trix-method]"), Ks = "".concat(fi, " [data-trix-input]"), Gs = (s, t) => (t || (t = te(s)), s.querySelector("[data-trix-input][name='".concat(t, "']"))), Js = (s) => s.getAttribute("data-trix-action"), te = (s) => s.getAttribute("data-trix-attribute") || s.getAttribute("data-trix-dialog-attribute"); +class Fa extends q { constructor(t) { - super(t), this.didClickActionButton = this.didClickActionButton.bind(this), this.didClickAttributeButton = this.didClickAttributeButton.bind(this), this.didClickDialogButton = this.didClickDialogButton.bind(this), this.didKeyDownDialogInput = this.didKeyDownDialogInput.bind(this), this.element = t, this.attributes = {}, this.actions = {}, this.resetDialogInputs(), B("mousedown", { onElement: this.element, matchingSelector: En, withCallback: this.didClickActionButton }), B("mousedown", { onElement: this.element, matchingSelector: An, withCallback: this.didClickAttributeButton }), B("click", { onElement: this.element, matchingSelector: Ll, preventDefault: !0 }), B("click", { onElement: this.element, matchingSelector: wl, withCallback: this.didClickDialogButton }), B("keydown", { onElement: this.element, matchingSelector: Bs, withCallback: this.didKeyDownDialogInput }); + super(t), this.didClickActionButton = this.didClickActionButton.bind(this), this.didClickAttributeButton = this.didClickAttributeButton.bind(this), this.didClickDialogButton = this.didClickDialogButton.bind(this), this.didKeyDownDialogInput = this.didKeyDownDialogInput.bind(this), this.element = t, this.attributes = {}, this.actions = {}, this.resetDialogInputs(), B("mousedown", { onElement: this.element, matchingSelector: On, withCallback: this.didClickActionButton }), B("mousedown", { onElement: this.element, matchingSelector: Dn, withCallback: this.didClickAttributeButton }), B("click", { onElement: this.element, matchingSelector: Vl, preventDefault: !0 }), B("click", { onElement: this.element, matchingSelector: Wl, withCallback: this.didClickDialogButton }), B("keydown", { onElement: this.element, matchingSelector: Ks, withCallback: this.didKeyDownDialogInput }); } didClickActionButton(t, e) { var i; (i = this.delegate) === null || i === void 0 || i.toolbarDidClickButton(), t.preventDefault(); - const n = Ns(e); + const n = Js(e); return this.getDialog(n) ? this.toggleDialog(n) : (r = this.delegate) === null || r === void 0 ? void 0 : r.toolbarDidInvokeAction(n, e); var r; } didClickAttributeButton(t, e) { var i; (i = this.delegate) === null || i === void 0 || i.toolbarDidClickButton(), t.preventDefault(); - const n = Qt(e); + const n = te(e); var r; return this.getDialog(n) ? this.toggleDialog(n) : (r = this.delegate) === null || r === void 0 || r.toolbarDidToggleAttribute(n), this.refreshAttributeButtons(); } didClickDialogButton(t, e) { - const i = Lt(e, { matchingSelector: oi }); + const i = Lt(e, { matchingSelector: fi }); return this[e.getAttribute("data-trix-method")].call(this, i); } didKeyDownDialogInput(t, e) { @@ -4807,27 +4815,27 @@ class La extends H { return this.actions = t, this.refreshActionButtons(); } refreshActionButtons() { - return this.eachActionButton(((t, e) => { + return this.eachActionButton((t, e) => { t.disabled = this.actions[e] === !1; - })); + }); } eachActionButton(t) { - return Array.from(this.element.querySelectorAll(En)).map(((e) => t(e, Ns(e)))); + return Array.from(this.element.querySelectorAll(On)).map((e) => t(e, Js(e))); } updateAttributes(t) { return this.attributes = t, this.refreshAttributeButtons(); } refreshAttributeButtons() { - return this.eachAttributeButton(((t, e) => (t.disabled = this.attributes[e] === !1, this.attributes[e] || this.dialogIsVisible(e) ? (t.setAttribute("data-trix-active", ""), t.classList.add("trix-active")) : (t.removeAttribute("data-trix-active"), t.classList.remove("trix-active"))))); + return this.eachAttributeButton((t, e) => (t.disabled = this.attributes[e] === !1, this.attributes[e] || this.dialogIsVisible(e) ? (t.setAttribute("data-trix-active", ""), t.classList.add("trix-active")) : (t.removeAttribute("data-trix-active"), t.classList.remove("trix-active")))); } eachAttributeButton(t) { - return Array.from(this.element.querySelectorAll(An)).map(((e) => t(e, Qt(e)))); + return Array.from(this.element.querySelectorAll(Dn)).map((e) => t(e, te(e))); } applyKeyboardCommand(t) { const e = JSON.stringify(t.sort()); for (const i of Array.from(this.element.querySelectorAll("[data-trix-key]"))) { const n = i.getAttribute("data-trix-key").split("+"); - if (JSON.stringify(n.sort()) === e) return be("mousedown", { onElement: i }), !0; + if (JSON.stringify(n.sort()) === e) return Ae("mousedown", { onElement: i }), !0; } return !1; } @@ -4842,53 +4850,53 @@ class La extends H { var e, i; this.hideDialog(), (e = this.delegate) === null || e === void 0 || e.toolbarWillShowDialog(); const n = this.getDialog(t); - n.setAttribute("data-trix-active", ""), n.classList.add("trix-active"), Array.from(n.querySelectorAll("input[disabled]")).forEach(((a) => { + n.setAttribute("data-trix-active", ""), n.classList.add("trix-active"), Array.from(n.querySelectorAll("input[disabled]")).forEach((a) => { a.removeAttribute("disabled"); - })); - const r = Qt(n); + }); + const r = te(n); if (r) { - const a = Ms(n, t); + const a = Gs(n, t); a && (a.value = this.attributes[r] || "", a.select()); } return (i = this.delegate) === null || i === void 0 ? void 0 : i.toolbarDidShowDialog(t); } setAttribute(t) { var e; - const i = Qt(t), n = Ms(t, i); + const i = te(t), n = Gs(t, i); return !n.willValidate || (n.setCustomValidity(""), n.checkValidity() && this.isSafeAttribute(n)) ? ((e = this.delegate) === null || e === void 0 || e.toolbarDidUpdateAttribute(i, n.value), this.hideDialog()) : (n.setCustomValidity("Invalid value"), n.setAttribute("data-trix-validate", ""), n.classList.add("trix-validate"), n.focus()); } isSafeAttribute(t) { - return !t.hasAttribute("data-trix-validate-href") || Ce.isValidAttribute("a", "href", t.value); + return !t.hasAttribute("data-trix-validate-href") || Ie.isValidAttribute("a", "href", t.value); } removeAttribute(t) { var e; - const i = Qt(t); + const i = te(t); return (e = this.delegate) === null || e === void 0 || e.toolbarDidRemoveAttribute(i), this.hideDialog(); } hideDialog() { - const t = this.element.querySelector(Cl); + const t = this.element.querySelector(jl); var e; if (t) return t.removeAttribute("data-trix-active"), t.classList.remove("trix-active"), this.resetDialogInputs(), (e = this.delegate) === null || e === void 0 ? void 0 : e.toolbarDidHideDialog(((i) => i.getAttribute("data-trix-dialog"))(t)); } resetDialogInputs() { - Array.from(this.element.querySelectorAll(Bs)).forEach(((t) => { + Array.from(this.element.querySelectorAll(Ks)).forEach((t) => { t.setAttribute("disabled", "disabled"), t.removeAttribute("data-trix-validate"), t.classList.remove("trix-validate"); - })); + }); } getDialog(t) { return this.element.querySelector("[data-trix-dialog=".concat(t, "]")); } } -class xe extends va { +class we extends Da { constructor(t) { let { editorElement: e, document: i, html: n } = t; - super(...arguments), this.editorElement = e, this.selectionManager = new Dt(this.editorElement), this.selectionManager.delegate = this, this.composition = new Et(), this.composition.delegate = this, this.attachmentManager = new la(this.composition.getAttachments()), this.attachmentManager.delegate = this, this.inputController = wn.getLevel() === 2 ? new Ee(this.editorElement) : new bt(this.editorElement), this.inputController.delegate = this, this.inputController.responder = this.composition, this.compositionController = new _a(this.editorElement, this.composition), this.compositionController.delegate = this, this.toolbarController = new La(this.editorElement.toolbarElement), this.toolbarController.delegate = this, this.editor = new ua(this.composition, this.selectionManager, this.editorElement), i ? this.editor.loadDocument(i) : this.editor.loadHTML(n); + super(...arguments), this.editorElement = e, this.selectionManager = new Dt(this.editorElement), this.selectionManager.delegate = this, this.composition = new xt(), this.composition.delegate = this, this.attachmentManager = new Aa(this.composition.getAttachments()), this.attachmentManager.delegate = this, this.inputController = qn.getLevel() === 2 ? new Ce(this.editorElement) : new bt(this.editorElement), this.inputController.delegate = this, this.inputController.responder = this.composition, this.compositionController = new Ra(this.editorElement, this.composition), this.compositionController.delegate = this, this.toolbarController = new Fa(this.editorElement.toolbarElement), this.toolbarController.delegate = this, this.editor = new La(this.composition, this.selectionManager, this.editorElement), i ? this.editor.loadDocument(i) : this.editor.loadHTML(n); } registerSelectionManager() { - return Ht.registerSelectionManager(this.selectionManager); + return qt.registerSelectionManager(this.selectionManager); } unregisterSelectionManager() { - return Ht.unregisterSelectionManager(this.selectionManager); + return qt.unregisterSelectionManager(this.selectionManager); } render() { return this.compositionController.render(); @@ -5028,7 +5036,7 @@ class xe extends va { this.selectionManager.setLocationRange(this.locationRangeBeforeDrag), this.locationRangeBeforeDrag = null; } locationRangeDidChange(t) { - return this.composition.updateCurrentAttributes(), this.updateCurrentActions(), this.attachmentLocationRange && !Ze(this.attachmentLocationRange, t) && this.composition.stopEditingAttachment(), this.notifyEditorElement("selection-change"); + return this.composition.updateCurrentAttributes(), this.updateCurrentActions(), this.attachmentLocationRange && !ai(this.attachmentLocationRange, t) && this.composition.stopEditingAttachment(), this.notifyEditorElement("selection-change"); } toolbarDidClickButton() { if (!this.getLocationRange()) return this.setLocationRange({ index: 0, offset: 0 }); @@ -5078,22 +5086,22 @@ class xe extends va { } updateCurrentActions() { const t = this.getCurrentActions(); - if (!ne(t, this.currentActions)) return this.currentActions = t, this.toolbarController.updateActions(this.currentActions), this.notifyEditorElement("actions-change", { actions: this.currentActions }); + if (!re(t, this.currentActions)) return this.currentActions = t, this.toolbarController.updateActions(this.currentActions), this.notifyEditorElement("actions-change", { actions: this.currentActions }); } runEditorFilters() { let t = this.composition.getSnapshot(); - if (Array.from(this.editor.filters).forEach(((n) => { + if (Array.from(this.editor.filters).forEach((n) => { const { document: r, selectedRange: a } = t; t = n.call(this.editor, t) || {}, t.document || (t.document = r), t.selectedRange || (t.selectedRange = a); - })), e = t, i = this.composition.getSnapshot(), !Ze(e.selectedRange, i.selectedRange) || !e.document.isEqualTo(i.document)) return this.composition.loadSnapshot(t); + }), e = t, i = this.composition.getSnapshot(), !ai(e.selectedRange, i.selectedRange) || !e.document.isEqualTo(i.document)) return this.composition.loadSnapshot(t); var e, i; } updateInputElement() { - const t = (function(e, i) { - const n = il[i]; + const t = function(e, i) { + const n = yl[i]; if (n) return n(e); throw new Error("unknown content type: ".concat(i)); - })(this.compositionController.getSerializableElement(), "text/html"); + }(this.compositionController.getSerializableElement(), "text/html"); return this.editorElement.setFormValue(t); } notifyEditorElement(t, e) { @@ -5116,8 +5124,8 @@ class xe extends va { return this.editor.recordUndoEntry("Delete Attachment"), this.composition.removeAttachment(t), this.render(); } recordFormattingUndoEntry(t) { - const e = P(t), i = this.selectionManager.getLocationRange(); - if (e || !_t(i)) return this.editor.recordUndoEntry("Formatting", { context: this.getUndoContext(), consolidatable: !0 }); + const e = F(t), i = this.selectionManager.getLocationRange(); + if (e || !vt(i)) return this.editor.recordUndoEntry("Formatting", { context: this.getUndoContext(), consolidatable: !0 }); } recordTypingUndoEntry() { return this.editor.recordUndoEntry("Typing", { context: this.getUndoContext(this.currentAttributes), consolidatable: !0 }); @@ -5128,10 +5136,10 @@ class xe extends va { } getLocationContext() { const t = this.selectionManager.getLocationRange(); - return _t(t) ? t[0].index : t; + return vt(t) ? t[0].index : t; } getTimeContext() { - return cn.interval > 0 ? Math.floor((/* @__PURE__ */ new Date()).getTime() / cn.interval) : 0; + return An.interval > 0 ? Math.floor((/* @__PURE__ */ new Date()).getTime() / An.interval) : 0; } isFocused() { var t; @@ -5144,7 +5152,7 @@ class xe extends va { return this.constructor.actions; } } -G(xe, "actions", { undo: { test() { +G(we, "actions", { undo: { test() { return this.editor.canUndo(); }, perform() { return this.editor.undo(); @@ -5163,10 +5171,10 @@ G(xe, "actions", { undo: { test() { }, perform() { return this.editor.decreaseNestingLevel() && this.render(); } }, attachFiles: { test: () => !0, perform() { - return wn.pickFiles(this.editor.insertFiles); -} } }), xe.proxyMethod("getSelectionManager().setLocationRange"), xe.proxyMethod("getSelectionManager().getLocationRange"); -var Tl = Object.freeze({ __proto__: null, AttachmentEditorController: ba, CompositionController: _a, Controller: va, EditorController: xe, InputController: ai, Level0InputController: bt, Level2InputController: Ee, ToolbarController: La }), kl = Object.freeze({ __proto__: null, MutationObserver: Aa, SelectionChangeObserver: zr }), Il = Object.freeze({ __proto__: null, FileVerificationOperation: Ea, ImagePreloadOperation: ra }); -Ur("trix-toolbar", `%t { + return qn.pickFiles(this.editor.insertFiles); +} } }), we.proxyMethod("getSelectionManager().setLocationRange"), we.proxyMethod("getSelectionManager().getLocationRange"); +var zl = Object.freeze({ __proto__: null, AttachmentEditorController: Ia, CompositionController: Ra, Controller: Da, EditorController: we, InputController: pi, Level0InputController: bt, Level2InputController: Ce, ToolbarController: Fa }), Kl = Object.freeze({ __proto__: null, MutationObserver: Ba, SelectionChangeObserver: ra }), Gl = Object.freeze({ __proto__: null, FileVerificationOperation: Ma, ImagePreloadOperation: _a }); +ea("trix-toolbar", `%t { display: block; } @@ -5185,9 +5193,9 @@ Ur("trix-toolbar", `%t { %t [data-trix-dialog] [data-trix-validate]:invalid { background-color: #ffdddd; }`); -class Ca extends HTMLElement { +class Ha extends HTMLElement { connectedCallback() { - this.innerHTML === "" && (this.innerHTML = $r.getDefaultHTML()); + this.innerHTML === "" && (this.innerHTML = ta.getDefaultHTML()); } get editorElements() { if (this.id) { @@ -5202,25 +5210,25 @@ class Ca extends HTMLElement { return t; } } -let Rl = 0; -const Dl = function(s) { - if (!s.hasAttribute("contenteditable")) return s.toggleAttribute("contenteditable", !s.disabled), (function(t) { +let Jl = 0; +const Yl = function(s) { + if (!s.hasAttribute("contenteditable")) return s.toggleAttribute("contenteditable", !s.disabled), function(t) { let e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}; return e.times = 1, B(t, e); - })("focus", { onElement: s, withCallback: () => Ol(s) }); -}, Ol = function(s) { - return Bl(s), Ml(); -}, Bl = function(s) { + }("focus", { onElement: s, withCallback: () => Xl(s) }); +}, Xl = function(s) { + return Ql(s), Zl(); +}, Ql = function(s) { var t, e; if ((t = (e = document).queryCommandSupported) !== null && t !== void 0 && t.call(e, "enableObjectResizing")) return document.execCommand("enableObjectResizing", !1, !1), B("mscontrolselect", { onElement: s, preventDefault: !0 }); -}, Ml = function(s) { +}, Zl = function(s) { var t, e; if ((t = (e = document).queryCommandSupported) !== null && t !== void 0 && t.call(e, "DefaultParagraphSeparator")) { const { tagName: i } = X.default; if (["div", "p"].includes(i)) return document.execCommand("DefaultParagraphSeparator", !1, i); } -}, Ps = Te.forcesObjectResizing ? { display: "inline", width: "auto" } : { display: "inline-block", width: "1px" }; -Ur("trix-editor", `%t { +}, Ys = Oe.forcesObjectResizing ? { display: "inline", width: "auto" } : { display: "inline-block", width: "1px" }; +ea("trix-editor", `%t { display: block; } @@ -5241,24 +5249,24 @@ Ur("trix-editor", `%t { height: auto; } -%t `.concat(Bt, ` figcaption textarea { +%t `.concat(Mt, ` figcaption textarea { resize: none; } -%t `).concat(Bt, ` figcaption textarea.trix-autoresize-clone { +%t `).concat(Mt, ` figcaption textarea.trix-autoresize-clone { position: absolute; left: -9999px; max-height: 0px; } -%t `).concat(Bt, ` figcaption[data-trix-placeholder]:empty::before { +%t `).concat(Mt, ` figcaption[data-trix-placeholder]:empty::before { content: attr(data-trix-placeholder); color: graytext; } %t [data-trix-cursor-target] { - display: `).concat(Ps.display, ` !important; - width: `).concat(Ps.width, ` !important; + display: `).concat(Ys.display, ` !important; + width: `).concat(Ys.width, ` !important; padding: 0 !important; margin: 0 !important; border: none !important; @@ -5273,14 +5281,14 @@ Ur("trix-editor", `%t { vertical-align: bottom !important; margin-right: -1px !important; }`)); -var ot = /* @__PURE__ */ new WeakMap(), Ue = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakSet(); -class Nl { +var ot = /* @__PURE__ */ new WeakMap(), Je = /* @__PURE__ */ new WeakMap(), _e = /* @__PURE__ */ new WeakSet(); +class td { constructor(t) { var e, i; - sa(e = this, i = ge), i.add(e), G(this, "value", ""), ee(this, ot, { writable: !0, value: void 0 }), ee(this, Ue, { writable: !0, value: void 0 }), this.element = t, Ae(this, ot, t.attachInternals()), Ae(this, Ue, !1); + ba(e = this, i = _e), i.add(e), G(this, "value", ""), ne(this, ot, { writable: !0, value: void 0 }), ne(this, Je, { writable: !0, value: void 0 }), this.element = t, Le(this, ot, t.attachInternals()), Le(this, Je, !1); } connectedCallback() { - $e(this, ge, Ve).call(this); + Ge(this, _e, Ye).call(this); } disconnectedCallback() { } @@ -5297,7 +5305,7 @@ class Nl { return w(this, ot).labels; } get disabled() { - return w(this, Ue) || this.element.hasAttribute("disabled"); + return w(this, Je) || this.element.hasAttribute("disabled"); } set disabled(t) { this.element.toggleAttribute("disabled", t); @@ -5306,7 +5314,7 @@ class Nl { return this.element.hasAttribute("required"); } set required(t) { - this.element.toggleAttribute("required", t), $e(this, ge, Ve).call(this); + this.element.toggleAttribute("required", t), Ge(this, _e, Ye).call(this); } get validity() { return w(this, ot).validity; @@ -5318,10 +5326,10 @@ class Nl { return w(this, ot).willValidate; } formDisabledCallback(t) { - Ae(this, Ue, t); + Le(this, Je, t); } setFormValue(t) { - this.value = t, $e(this, ge, Ve).call(this), w(this, ot).setFormValue(this.element.disabled ? void 0 : this.value); + this.value = t, Ge(this, _e, Ye).call(this), w(this, ot).setFormValue(this.element.disabled ? void 0 : this.value); } checkValidity() { return w(this, ot).checkValidity(); @@ -5330,40 +5338,40 @@ class Nl { return w(this, ot).reportValidity(); } setCustomValidity(t) { - $e(this, ge, Ve).call(this, t); + Ge(this, _e, Ye).call(this, t); } } -function Ve() { +function Ye() { let s = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : ""; const { required: t, value: e } = this.element, i = t && !e, n = !!s, r = x("input", { required: t }), a = s || r.validationMessage; w(this, ot).setValidity({ valueMissing: i, customError: n }, a); } -var Gi = /* @__PURE__ */ new WeakMap(), Ji = /* @__PURE__ */ new WeakMap(), Yi = /* @__PURE__ */ new WeakMap(); -class Pl { +var an = /* @__PURE__ */ new WeakMap(), on = /* @__PURE__ */ new WeakMap(), ln = /* @__PURE__ */ new WeakMap(); +class ed { constructor(t) { - ee(this, Gi, { writable: !0, value: void 0 }), ee(this, Ji, { writable: !0, value: (e) => { + ne(this, an, { writable: !0, value: void 0 }), ne(this, on, { writable: !0, value: (e) => { e.defaultPrevented || e.target === this.element.form && this.element.reset(); - } }), ee(this, Yi, { writable: !0, value: (e) => { + } }), ne(this, ln, { writable: !0, value: (e) => { if (e.defaultPrevented || this.element.contains(e.target)) return; const i = Lt(e.target, { matchingSelector: "label" }); i && Array.from(this.labels).includes(i) && this.element.focus(); } }), this.element = t; } connectedCallback() { - Ae(this, Gi, (function(t) { + Le(this, an, function(t) { if (t.hasAttribute("aria-label") || t.hasAttribute("aria-labelledby")) return; const e = function() { - const i = Array.from(t.labels).map(((r) => { + const i = Array.from(t.labels).map((r) => { if (!r.contains(t)) return r.textContent; - })).filter(((r) => r)), n = i.join(" "); + }).filter((r) => r), n = i.join(" "); return n ? t.setAttribute("aria-label", n) : t.removeAttribute("aria-label"); }; return e(), B("focus", { onElement: t, withCallback: e }); - })(this.element)), window.addEventListener("reset", w(this, Ji), !1), window.addEventListener("click", w(this, Yi), !1); + }(this.element)), window.addEventListener("reset", w(this, on), !1), window.addEventListener("click", w(this, ln), !1); } disconnectedCallback() { var t; - (t = w(this, Gi)) === null || t === void 0 || t.destroy(), window.removeEventListener("reset", w(this, Ji), !1), window.removeEventListener("click", w(this, Yi), !1); + (t = w(this, an)) === null || t === void 0 || t.destroy(), window.removeEventListener("reset", w(this, on), !1), window.removeEventListener("click", w(this, ln), !1); } get labels() { const t = []; @@ -5415,39 +5423,39 @@ class Pl { console.warn("This browser does not support setCustomValidity(validationMessage) for trix-editor elements."); } } -var N = /* @__PURE__ */ new WeakMap(); -class ii extends HTMLElement { +var P = /* @__PURE__ */ new WeakMap(); +class di extends HTMLElement { constructor() { - super(), ee(this, N, { writable: !0, value: void 0 }), this.willCreateInput = !0, Ae(this, N, this.constructor.formAssociated ? new Nl(this) : new Pl(this)); + super(), ne(this, P, { writable: !0, value: void 0 }), this.willCreateInput = !0, Le(this, P, this.constructor.formAssociated ? new td(this) : new ed(this)); } get trixId() { - return this.hasAttribute("trix-id") ? this.getAttribute("trix-id") : (this.setAttribute("trix-id", ++Rl), this.trixId); + return this.hasAttribute("trix-id") ? this.getAttribute("trix-id") : (this.setAttribute("trix-id", ++Jl), this.trixId); } get labels() { - return w(this, N).labels; + return w(this, P).labels; } get disabled() { const { inputElement: t } = this; - return t ? t.disabled : w(this, N).disabled; + return t ? t.disabled : w(this, P).disabled; } set disabled(t) { const { inputElement: e } = this; - e && (e.disabled = t), w(this, N).disabled = t; + e && (e.disabled = t), w(this, P).disabled = t; } get required() { - return w(this, N).required; + return w(this, P).required; } set required(t) { - w(this, N).required = t; + w(this, P).required = t; } get validity() { - return w(this, N).validity; + return w(this, P).validity; } get validationMessage() { - return w(this, N).validationMessage; + return w(this, P).validationMessage; } get willValidate() { - return w(this, N).willValidate; + return w(this, P).willValidate; } get type() { return this.localName; @@ -5462,7 +5470,7 @@ class ii extends HTMLElement { } get form() { const { inputElement: t } = this; - return t ? t.form : w(this, N).form; + return t ? t.form : w(this, P).form; } get inputElement() { var t; @@ -5474,51 +5482,51 @@ class ii extends HTMLElement { } get name() { const { inputElement: t } = this; - return t ? t.name : w(this, N).name; + return t ? t.name : w(this, P).name; } set name(t) { const { inputElement: e } = this; - e ? e.name = t : w(this, N).name = t; + e ? e.name = t : w(this, P).name = t; } get value() { const { inputElement: t } = this; - return t ? t.value : w(this, N).value; + return t ? t.value : w(this, P).value; } set value(t) { var e; this.defaultValue = t, (e = this.editor) === null || e === void 0 || e.loadHTML(this.defaultValue); } attributeChangedCallback(t, e, i) { - t === "connected" && this.isConnected && e != null && e !== i && requestAnimationFrame((() => this.reconnect())); + t === "connected" && this.isConnected && e != null && e !== i && requestAnimationFrame(() => this.reconnect()); } notify(t, e) { - if (this.editorController) return be("trix-".concat(t), { onElement: this, attributes: e }); + if (this.editorController) return Ae("trix-".concat(t), { onElement: this, attributes: e }); } setFormValue(t) { const { inputElement: e } = this; - e && (e.value = t), w(this, N).setFormValue(t); + e && (e.value = t), w(this, P).setFormValue(t); } connectedCallback() { if (!this.hasAttribute("data-trix-internal")) { - if (Dl(this), (function(t) { + if (Yl(this), function(t) { t.hasAttribute("role") || t.setAttribute("role", "textbox"); - })(this), !this.editorController) { - if (be("trix-before-initialize", { onElement: this }), this.defaultValue = this.inputElement ? this.inputElement.value : this.innerHTML, !this.hasAttribute("input") && this.parentNode && this.willCreateInput) { + }(this), !this.editorController) { + if (Ae("trix-before-initialize", { onElement: this }), this.defaultValue = this.inputElement ? this.inputElement.value : this.innerHTML, !this.hasAttribute("input") && this.parentNode && this.willCreateInput) { const t = "trix-input-".concat(this.trixId); this.setAttribute("input", t); const e = x("input", { type: "hidden", id: t }); this.parentNode.insertBefore(e, this.nextElementSibling); } - this.editorController = new xe({ editorElement: this, html: this.defaultValue }), requestAnimationFrame((() => be("trix-initialize", { onElement: this }))); + this.editorController = new we({ editorElement: this, html: this.defaultValue }), requestAnimationFrame(() => Ae("trix-initialize", { onElement: this })); } - this.editorController.registerSelectionManager(), w(this, N).connectedCallback(), this.toggleAttribute("connected", !0), (function(t) { + this.editorController.registerSelectionManager(), w(this, P).connectedCallback(), this.toggleAttribute("connected", !0), function(t) { !document.querySelector(":focus") && t.hasAttribute("autofocus") && document.querySelector("[autofocus]") === t && t.focus(); - })(this); + }(this); } } disconnectedCallback() { var t; - (t = this.editorController) === null || t === void 0 || t.unregisterSelectionManager(), w(this, N).disconnectedCallback(), this.toggleAttribute("connected", !1); + (t = this.editorController) === null || t === void 0 || t.unregisterSelectionManager(), w(this, P).disconnectedCallback(), this.toggleAttribute("connected", !1); } reconnect() { this.removeInternalToolbar(), this.disconnectedCallback(), this.connectedCallback(); @@ -5528,17 +5536,17 @@ class ii extends HTMLElement { (t = this.internalToolbar) === null || t === void 0 || t.remove(), this.internalToolbar = null; } checkValidity() { - return w(this, N).checkValidity(); + return w(this, P).checkValidity(); } reportValidity() { - return w(this, N).reportValidity(); + return w(this, P).reportValidity(); } setCustomValidity(t) { - w(this, N).setCustomValidity(t); + w(this, P).setCustomValidity(t); } formDisabledCallback(t) { const { inputElement: e } = this; - e && (e.disabled = t), this.toggleAttribute("contenteditable", !t), w(this, N).formDisabledCallback(t); + e && (e.disabled = t), this.toggleAttribute("contenteditable", !t), w(this, P).formDisabledCallback(t); } formResetCallback() { this.reset(); @@ -5547,12 +5555,12 @@ class ii extends HTMLElement { this.value = this.defaultValue; } } -G(ii, "formAssociated", "ElementInternals" in window), G(ii, "observedAttributes", ["connected"]); -const Fs = { VERSION: Pa, config: ke, core: nl, models: fa, views: ll, controllers: Tl, observers: kl, operations: Il, elements: Object.freeze({ __proto__: null, TrixEditorElement: ii, TrixToolbarElement: Ca }), filters: Object.freeze({ __proto__: null, Filter: ca, attachmentGalleryFilter: ha }) }; -Object.assign(Fs, fa), window.Trix = Fs, setTimeout((function() { - customElements.get("trix-toolbar") || customElements.define("trix-toolbar", Ca), customElements.get("trix-editor") || customElements.define("trix-editor", ii); -}), 0); -class Fl extends HTMLElement { +G(di, "formAssociated", "ElementInternals" in window), G(di, "observedAttributes", ["connected"]); +const Xs = { VERSION: eo, config: Be, core: Al, models: ka, views: Cl, controllers: zl, observers: Kl, operations: Gl, elements: Object.freeze({ __proto__: null, TrixEditorElement: di, TrixToolbarElement: Ha }), filters: Object.freeze({ __proto__: null, Filter: xa, attachmentGalleryFilter: Sa }) }; +Object.assign(Xs, ka), window.Trix = Xs, setTimeout(function() { + customElements.get("trix-toolbar") || customElements.define("trix-toolbar", Ha), customElements.get("trix-editor") || customElements.define("trix-editor", di); +}, 0); +class id extends HTMLElement { constructor() { super(), this._value = "", this.render(); } @@ -5621,112 +5629,109 @@ class Fl extends HTMLElement { `; } } -const je = "filter-list-list", Hl = "filter-list-item", ql = "filter-list-input", Hs = "filter-list-searchable"; -class $l extends HTMLElement { - #t = !1; +const Xe = "filter-list-list", nd = "filter-list-item", sd = "filter-list-input", Qs = "filter-list-searchable"; +var Bt, De, Bn; +class rd extends HTMLElement { constructor() { - super(), this._items = [], this._url = "", this._filterstart = !1, this._placeholder = "Liste filtern...", this._queryparam = "", this._startparams = null, this.render(); + super(); + he(this, De); + he(this, Bt, !1); + this._items = [], this._url = "", this._filterstart = !1, this._placeholder = "Liste filtern...", this._queryparam = "", this._startparams = null, this.render(); } static get observedAttributes() { return ["data-url"]; } - set items(t) { - Array.isArray(t) && (this._items = t, this.render()); + set items(e) { + Array.isArray(e) && (this._items = e, this.render()); } get items() { return this._items; } connectedCallback() { - this._url = this.getAttribute("data-url") || "./", this._filterstart = this.getAttribute("data-filterstart") === "true", this._placeholder = this.getAttribute("data-placeholder") || "Liste filtern...", this._queryparam = this.getAttribute("data-queryparam") || "", this._queryparam, this._filterstart && (this.#t = !0), this.addEventListener("input", this.onInput.bind(this)), this.addEventListener("keydown", this.onEnter.bind(this)), this.addEventListener("focusin", this.onGainFocus.bind(this)), this.addEventListener("focusout", this.onLoseFocus.bind(this)); + this._url = this.getAttribute("data-url") || "./", this._filterstart = this.getAttribute("data-filterstart") === "true", this._placeholder = this.getAttribute("data-placeholder") || "Liste filtern...", this._queryparam = this.getAttribute("data-queryparam") || "", this._queryparam, this._filterstart && Ve(this, Bt, !0), this.addEventListener("input", this.onInput.bind(this)), this.addEventListener("keydown", this.onEnter.bind(this)), this.addEventListener("focusin", this.onGainFocus.bind(this)), this.addEventListener("focusout", this.onLoseFocus.bind(this)); } - attributeChangedCallback(t, e, i) { - t === "data-url" && e !== i && (this._url = i, this.render()), t === "data-filterstart" && e !== i && (this._filterstart = i === "true", this.render()), t === "data-placeholder" && e !== i && (this._placeholder = i, this.render()), t === "data-queryparam" && e !== i && (this._queryparam = i, this.render()); + attributeChangedCallback(e, i, n) { + e === "data-url" && i !== n && (this._url = n, this.render()), e === "data-filterstart" && i !== n && (this._filterstart = n === "true", this.render()), e === "data-placeholder" && i !== n && (this._placeholder = n, this.render()), e === "data-queryparam" && i !== n && (this._queryparam = n, this.render()); } - onInput(t) { - t.target && t.target.tagName.toLowerCase() === "input" && (this._filter = t.target.value, this.renderList()); + onInput(e) { + e.target && e.target.tagName.toLowerCase() === "input" && (this._filter = e.target.value, this.renderList()); } - onGainFocus(t) { - t.target && t.target.tagName.toLowerCase() === "input" && (this.#t = !1, this.renderList()); + onGainFocus(e) { + e.target && e.target.tagName.toLowerCase() === "input" && (Ve(this, Bt, !1), this.renderList()); } - onLoseFocus(t) { - let e = this.querySelector("input"); - if (t.target && t.target === e) { - if (relatedElement = t.relatedTarget, relatedElement && this.contains(relatedElement)) + onLoseFocus(e) { + let i = this.querySelector("input"); + if (e.target && e.target === i) { + if (relatedElement = e.relatedTarget, relatedElement && this.contains(relatedElement)) return; - e.value = "", this._filter = "", this._filterstart && (this.#t = !0), this.renderList(); + i.value = "", this._filter = "", this._filterstart && Ve(this, Bt, !0), this.renderList(); } } - onEnter(t) { - if (t.target && t.target.tagName.toLowerCase() === "input" && t.key === "Enter") { - t.preventDefault(); - const e = this.querySelector("a"); - e && e.click(); + onEnter(e) { + if (e.target && e.target.tagName.toLowerCase() === "input" && e.key === "Enter") { + e.preventDefault(); + const i = this.querySelector("a"); + i && i.click(); } } mark() { if (typeof Mark != "function") return; - let t = this.querySelector("#" + je); - if (!t) + let e = this.querySelector("#" + Xe); + if (!e) return; - let e = new Mark(t.querySelectorAll("." + Hs)); - this._filter && e.mark(this._filter, { + let i = new Mark(e.querySelectorAll("." + Qs)); + this._filter && i.mark(this._filter, { separateWordSearch: !0 }); } // INFO: allows for setting a custom HREF of the list item // The function takes the item as parameter fn(item) and should return a string. - setHREFFunc(t) { - this.getHREF = t, this.render(); + setHREFFunc(e) { + this.getHREF = e, this.render(); } // INFO: allows for setting a custom link text of the list item // The function takes the item as parameter fn(item) and should return a string or // an HTML template literal. - setLinkTextFunc(t) { - this.getLinkText = t, this.render(); + setLinkTextFunc(e) { + this.getLinkText = e, this.render(); } // INFO: allows for setting the text that will be filtered for. // The function takes the item as parameter fn(item) and should return a string. - setSearchTextFunc(t) { - this.getSearchText = t, this.render(); + setSearchTextFunc(e) { + this.getSearchText = e, this.render(); } - getHREF(t) { - if (t) { - if (!t.id) + getHREF(e) { + if (e) { + if (!e.id) return ""; } else return ""; - return t.id; + return e.id; } - getHREFEncoded(t) { - return encodeURIComponent(this.getHREF(t)); + getHREFEncoded(e) { + return encodeURIComponent(this.getHREF(e)); } - getSearchText(t) { - if (t) { - if (!t.name) + getSearchText(e) { + if (e) { + if (!e.name) return ""; } else return ""; - return t.name; + return e.name; } - #e(t) { - if (!t) - return !1; - let e = this.getHREF(t); - return e === "" ? !1 : this._queryparam && (new URLSearchParams(window.location.search).get(this._queryparam) || "") === e ? !0 : !!window.location.href.endsWith(e); + getLinkText(e) { + let i = this.getSearchText(e); + return i === "" ? "" : `${i}`; } - getLinkText(t) { - let e = this.getSearchText(t); - return e === "" ? "" : `${e}`; - } - getURL(t) { + getURL(e) { if (this._queryparam) { - let e = new URL(window.location), i = new URLSearchParams(e.search); - return i.set(this._queryparam, this.getHREF(t)), i.delete("page"), e.search = i.toString(), e.toString(); + let i = new URL(window.location), n = new URLSearchParams(i.search); + return n.set(this._queryparam, this.getHREF(e)), n.delete("page"), i.search = n.toString(), i.toString(); } - return this._url + this.getHREFEncoded(t); + return this._url + this.getHREFEncoded(e); } renderList() { - let t = this.querySelector("#" + je); - t && (t.outerHTML = this.List()), this.mark(); + let e = this.querySelector("#" + Xe); + e && (e.outerHTML = this.List()), this.mark(); } render() { this.innerHTML = ` @@ -5736,11 +5741,11 @@ class $l extends HTMLElement { `, htmx && htmx.process(this); } - ActiveDot(t) { - return this.#e(t), ""; + ActiveDot(e) { + return je(this, De, Bn).call(this, e), ""; } - NoItems(t) { - return t.length === 0 ? '
Keine Einträge gefunden
' : ""; + NoItems(e) { + return e.length === 0 ? '
Keine Einträge gefunden
' : ""; } Input() { return ` @@ -5750,43 +5755,49 @@ class $l extends HTMLElement { + class="${sd} w-full placeholder:italic px-2 py-0.5" /> `; } List() { - let t = this._items; + let e = this._items; if (this._filter) if (this._filterstart) - t = this._items.filter((e) => this.getSearchText(e).toLowerCase().startsWith(this._filter.toLowerCase())); + e = this._items.filter((i) => this.getSearchText(i).toLowerCase().startsWith(this._filter.toLowerCase())); else { - let e = this._filter.split(" "); - t = this._items.filter((i) => e.every((n) => this.getSearchText(i).toLowerCase().includes(n.toLowerCase()))); + let i = this._filter.split(" "); + e = this._items.filter((n) => i.every((r) => this.getSearchText(n).toLowerCase().includes(r.toLowerCase()))); } return ` -
- ${t.map( - (e, i) => ` +
+ ${e.map( + (i, n) => ` - ${this.ActiveDot(e)} - ${this.getLinkText(e)} + class="${nd} block px-2.5 py-0.5 hover:bg-slate-200 no-underline ${n % 2 === 0 ? "bg-stone-100" : "bg-stone-50"}" + ${je(this, De, Bn).call(this, i) ? 'aria-current="page"' : ""}> + ${this.ActiveDot(i)} + ${this.getLinkText(i)} ` ).join("")} - ${this.NoItems(t)} + ${this.NoItems(e)}
`; } } -class Ul extends HTMLElement { +Bt = new WeakMap(), De = new WeakSet(), Bn = function(e) { + if (!e) + return !1; + let i = this.getHREF(e); + return i === "" ? !1 : this._queryparam && (new URLSearchParams(window.location.search).get(this._queryparam) || "") === i ? !0 : !!window.location.href.endsWith(i); +}; +class ad extends HTMLElement { constructor() { super(), this.handleScroll = this.handleScroll.bind(this), this.scrollToTop = this.scrollToTop.bind(this); } @@ -5822,35 +5833,36 @@ class Ul extends HTMLElement { window.scrollTo({ top: 0, behavior: "smooth" }); } } -class xt extends HTMLElement { +const _t = class _t extends HTMLElement { static get observedAttributes() { return ["position", "timeout"]; } - static _dragGuardInitialized = !1; static _setDragging(t) { window.__toolTipDragging = t, document.documentElement && document.documentElement.classList.toggle("dragging", t), document.body && (t ? document.body.dataset.dragging = "true" : delete document.body.dataset.dragging), t && document.querySelectorAll(".tooltip-box").forEach((e) => { e.classList.remove("opacity-100"), e.classList.add("opacity-0"), e.classList.add("hidden"); }); } static _ensureDragGuard() { - if (xt._dragGuardInitialized) + if (_t._dragGuardInitialized) return; - xt._dragGuardInitialized = !0; + _t._dragGuardInitialized = !0; const t = (i) => { - (i.target?.closest?.("[data-role='content-drag-handle']") || i.type === "dragstart") && xt._setDragging(!0); + var r, a; + (((a = (r = i.target) == null ? void 0 : r.closest) == null ? void 0 : a.call(r, "[data-role='content-drag-handle']")) || i.type === "dragstart") && _t._setDragging(!0); }, e = () => { - xt._setDragging(!1); + _t._setDragging(!1); }; document.addEventListener("pointerdown", t, !0), document.addEventListener("mousedown", t, !0), document.addEventListener("dragstart", t, !0), document.addEventListener("pointerup", e, !0), document.addEventListener("mouseup", e, !0), document.addEventListener("pointercancel", e, !0), document.addEventListener("dragend", e, !0), document.addEventListener("drop", e, !0), window.addEventListener("blur", e), window.addEventListener("contentsdragging", (i) => { - const n = !!i.detail?.active; - xt._setDragging(n); + var r; + const n = !!((r = i.detail) != null && r.active); + _t._setDragging(n); }); } constructor() { super(), this._tooltipBox = null, this._timeout = 200, this._hideTimeout = null, this._hiddenTimeout = null, this._dataTipElem = null, this._observer = null; } connectedCallback() { - xt._ensureDragGuard(), this.classList.add("relative", "block", "leading-none", "[&>*]:leading-normal"), this._dataTipElem = this.querySelector(".data-tip"); + _t._ensureDragGuard(), this.classList.add("relative", "block", "leading-none", "[&>*]:leading-normal"), this._dataTipElem = this.querySelector(".data-tip"); const t = this._dataTipElem ? this._dataTipElem.innerHTML : "Tooltip"; this._dataTipElem && this._dataTipElem.classList.add("hidden"), this._tooltipBox = document.createElement("div"), this._tooltipBox.innerHTML = t, this._tooltipBox.className = [ "tooltip-box", @@ -5866,8 +5878,9 @@ class xt extends HTMLElement { "shadow", "z-50", "whitespace-nowrap", - "transition-all", - "duration-200", + "transition-opacity", + "duration-100", + "ease-out", "font-sans" ].join(" "), this.appendChild(this._tooltipBox), this._updatePosition(), this.addEventListener("mouseenter", () => this._showTooltip()), this.addEventListener("mouseleave", () => this._hideTooltip()), this.addEventListener("pointerdown", () => this._forceHide()), this.addEventListener("mousedown", () => this._forceHide()), this.addEventListener("click", () => this._forceHide()), this.addEventListener("keydown", (e) => { (e.key === "Enter" || e.key === " ") && this._forceHide(); @@ -5889,7 +5902,8 @@ class xt extends HTMLElement { clearTimeout(this._hideTimeout), clearTimeout(this._hiddenTimeout), this._tooltipBox && (this._tooltipBox.classList.remove("opacity-100"), this._tooltipBox.classList.add("opacity-0"), this._tooltipBox.classList.add("hidden")); } _isDragging() { - return window.__toolTipDragging || document.body?.dataset?.dragging === "true" ? !0 : !!document.querySelector("[data-dragging='true']"); + var t, e; + return window.__toolTipDragging || ((e = (t = document.body) == null ? void 0 : t.dataset) == null ? void 0 : e.dragging) === "true" ? !0 : !!document.querySelector("[data-dragging='true']"); } _showTooltip() { if (this._isDragging()) { @@ -5920,14 +5934,17 @@ class xt extends HTMLElement { case "right": n = t.top + (t.height - e.height) / 2, r = t.right + i; break; + case "top": default: n = t.top - e.height - i, r = t.left + (t.width - e.width) / 2; } const o = 4, l = window.innerWidth - e.width - o, c = window.innerHeight - e.height - o; r = Math.max(o, Math.min(r, l)), n = Math.max(o, Math.min(n, c)), this._tooltipBox.style.left = `${r}px`, this._tooltipBox.style.top = `${n}px`; } -} -class Vl extends HTMLElement { +}; +Xt(_t, "_dragGuardInitialized", !1); +let Mn = _t; +class od extends HTMLElement { constructor() { super(), this.overlay = null, this._others = null, this._thisindex = -1, this._preview = null, this._description = null, this._imageURL = "", this._hideDLButton = !1; } @@ -6035,7 +6052,7 @@ class Vl extends HTMLElement { this.overlay.parentNode.removeChild(this.overlay), this.overlay = null; } } -class jl extends HTMLElement { +class ld extends HTMLElement { static get observedAttributes() { } constructor() { @@ -6153,7 +6170,7 @@ class jl extends HTMLElement { return null; } } -class Se extends HTMLElement { +class Te extends HTMLElement { static get observedAttributes() { return ["data-text", "data-abbrevmap"]; } @@ -6216,7 +6233,7 @@ class Se extends HTMLElement { }; } constructor() { - super(), this._abbrevMap = Se.defaultAbbrevMap; + super(), this._abbrevMap = Te.defaultAbbrevMap; } connectedCallback() { this.render(); @@ -6226,13 +6243,13 @@ class Se extends HTMLElement { } _parseAndSetAbbrevMap(t) { if (!t) { - this._abbrevMap = Se.defaultAbbrevMap; + this._abbrevMap = Te.defaultAbbrevMap; return; } try { this._abbrevMap = JSON.parse(t); } catch { - this._abbrevMap = Se.defaultAbbrevMap; + this._abbrevMap = Te.defaultAbbrevMap; } } setAbbrevMap(t) { @@ -6282,7 +6299,7 @@ class Se extends HTMLElement { return /\s|[.,;:!?]/.test(t); } } -class Wl extends HTMLElement { +class dd extends HTMLElement { constructor() { super(); } @@ -6300,32 +6317,46 @@ class Wl extends HTMLElement { } } } -class zl extends HTMLElement { - #t = 176; +var ci; +class cd extends HTMLElement { constructor() { - super(), this._images = []; + super(); + he(this, ci, 176); + this._images = []; } connectedCallback() { this._images = Array.from(this.querySelectorAll(".primages")), this.calculateShownImages(); - const t = new ResizeObserver((e, i) => { + const e = new ResizeObserver((i, n) => { this.calculateShownImages(); }); - this._resizeObserver = t, t.observe(this); + this._resizeObserver = e, e.observe(this); } disconnectedCallback() { this._resizeObserver.unobserve(this); } calculateShownImages() { - const t = this.getBoundingClientRect(); - console.log(t); - const e = Math.floor(t.width / (this.#t + 10)); - for (let i = 0; i < this._images.length; i++) - i < e - 1 ? this._images[i].classList.remove("hidden") : this._images[i].classList.add("hidden"); + const e = this.getBoundingClientRect(); + console.log(e); + const i = Math.floor(e.width / (Bi(this, ci) + 10)); + for (let n = 0; n < this._images.length; n++) + n < i - 1 ? this._images[n].classList.remove("hidden") : this._images[n].classList.add("hidden"); } } -const Kl = "msr-component-wrapper", qs = "msr-selected-items-container", $s = "msr-placeholder-no-selection-text", Gl = "msr-selected-item-pill", Jl = "msr-selected-item-text", Yl = "msr-item-name", Xl = "msr-item-additional-data", Ql = "msr-selected-item-role", Us = "msr-selected-item-delete-btn", Zl = "msr-controls-area", Vs = "msr-pre-add-button", js = "msr-input-area-wrapper", We = "msr-input-area-default-border", Xi = "msr-input-area-staged", Ws = "msr-staging-area-container", td = "msr-staged-item-pill", ed = "msr-staged-item-text", Qi = "msr-staged-role-select", zs = "msr-staged-cancel-btn", Ks = "msr-text-input", Gs = "msr-add-button", Js = "msr-options-list", Ys = "msr-option-item", id = "msr-option-item-name", nd = "msr-option-item-detail", Xs = "msr-option-item-highlighted", Zi = "msr-hidden-select", sd = "msr-state-no-selection", rd = "msr-state-has-selection", ad = "msr-state-list-open", od = "msr-state-item-staged"; -class ld extends HTMLElement { - static formAssociated = !0; +ci = new WeakMap(); +const hd = "msr-component-wrapper", Zs = "msr-selected-items-container", tr = "msr-placeholder-no-selection-text", ud = "msr-selected-item-pill", md = "msr-selected-item-text", gd = "msr-item-name", pd = "msr-item-additional-data", fd = "msr-selected-item-role", er = "msr-selected-item-delete-btn", bd = "msr-controls-area", ir = "msr-pre-add-button", nr = "msr-input-area-wrapper", Qe = "msr-input-area-default-border", dn = "msr-input-area-staged", sr = "msr-staging-area-container", _d = "msr-staged-item-pill", vd = "msr-staged-item-text", cn = "msr-staged-role-select", rr = "msr-staged-cancel-btn", ar = "msr-text-input", or = "msr-add-button", lr = "msr-options-list", dr = "msr-option-item", yd = "msr-option-item-name", Ad = "msr-option-item-detail", cr = "msr-option-item-highlighted", hn = "msr-hidden-select", Ed = "msr-state-no-selection", xd = "msr-state-has-selection", Sd = "msr-state-list-open", Ld = "msr-state-item-staged"; +class qa extends HTMLElement { + constructor() { + super(); + Xt(this, "_blurTimeout", null); + this.internals_ = this.attachInternals(), this._value = [], this._stagedItem = null, this._showAddButton = !0, this._placeholderNoSelection = "Keine Elemente ausgewählt", this._placeholderSearch = "Elemente suchen...", this._placeholderRoleSelect = "Rolle auswählen...", this._options = [], this._roles = [ + "Leitung", + "Unterstützung", + "Berater", + "Beobachter", + "Spezialist", + "Koordinator" + ], this._filteredOptions = [], this._highlightedIndex = -1, this._isOptionsListVisible = !1, this._setupTemplates(), this._bindEventHandlers(); + } static get observedAttributes() { return [ "disabled", @@ -6337,138 +6368,128 @@ class ld extends HTMLElement { "placeholder-role-select" ]; } - constructor() { - super(), this.internals_ = this.attachInternals(), this._value = [], this._stagedItem = null, this._showAddButton = !0, this._placeholderNoSelection = "Keine Elemente ausgewählt", this._placeholderSearch = "Elemente suchen...", this._placeholderRoleSelect = "Rolle auswählen...", this._options = [], this._roles = [ - "Leitung", - "Unterstützung", - "Berater", - "Beobachter", - "Spezialist", - "Koordinator" - ], this._filteredOptions = [], this._highlightedIndex = -1, this._isOptionsListVisible = !1, this._setupTemplates(), this._bindEventHandlers(); - } get showAddButton() { return this._showAddButton; } - set showAddButton(t) { - const e = typeof t == "string" ? t.toLowerCase() !== "false" : !!t; - this._showAddButton !== e && (this._showAddButton = e, this.setAttribute("show-add-button", String(e)), this.preAddButtonElement && this._updatePreAddButtonVisibility()); + set showAddButton(e) { + const i = typeof e == "string" ? e.toLowerCase() !== "false" : !!e; + this._showAddButton !== i && (this._showAddButton = i, this.setAttribute("show-add-button", String(i)), this.preAddButtonElement && this._updatePreAddButtonVisibility()); } get placeholderNoSelection() { return this._placeholderNoSelection; } - set placeholderNoSelection(t) { - const e = String(t || "Keine Elemente ausgewählt"); - this._placeholderNoSelection !== e && (this._placeholderNoSelection = e, this.setAttribute("placeholder-no-selection", e), this.selectedItemsContainer && this._value.length === 0 && this._renderSelectedItems()); + set placeholderNoSelection(e) { + const i = String(e || "Keine Elemente ausgewählt"); + this._placeholderNoSelection !== i && (this._placeholderNoSelection = i, this.setAttribute("placeholder-no-selection", i), this.selectedItemsContainer && this._value.length === 0 && this._renderSelectedItems()); } get placeholderSearch() { return this._placeholderSearch; } - set placeholderSearch(t) { - const e = String(t || "Elemente suchen..."); - this._placeholderSearch !== e && (this._placeholderSearch = e, this.setAttribute("placeholder-search", e), this.inputElement && (this.inputElement.placeholder = e)); + set placeholderSearch(e) { + const i = String(e || "Elemente suchen..."); + this._placeholderSearch !== i && (this._placeholderSearch = i, this.setAttribute("placeholder-search", i), this.inputElement && (this.inputElement.placeholder = i)); } get placeholderRoleSelect() { return this._placeholderRoleSelect; } - set placeholderRoleSelect(t) { - const e = String(t || "Rolle auswählen..."); - this._placeholderRoleSelect !== e && (this._placeholderRoleSelect = e, this.setAttribute("placeholder-role-select", e), this._stagedItem && this.stagedItemPillContainer && this._renderStagedPillOrInput()); + set placeholderRoleSelect(e) { + const i = String(e || "Rolle auswählen..."); + this._placeholderRoleSelect !== i && (this._placeholderRoleSelect = i, this.setAttribute("placeholder-role-select", i), this._stagedItem && this.stagedItemPillContainer && this._renderStagedPillOrInput()); } - attributeChangedCallback(t, e, i) { - if (e !== i) - switch (t) { + attributeChangedCallback(e, i, n) { + if (i !== n) + switch (e) { case "disabled": this.disabledCallback(this.hasAttribute("disabled")); break; case "name": - this.hiddenSelect && (this.hiddenSelect.name = i); + this.hiddenSelect && (this.hiddenSelect.name = n); break; case "value": break; case "show-add-button": - this.showAddButton = i; + this.showAddButton = n; break; case "placeholder-no-selection": - this.placeholderNoSelection = i; + this.placeholderNoSelection = n; break; case "placeholder-search": - this.placeholderSearch = i; + this.placeholderSearch = n; break; case "placeholder-role-select": - this.placeholderRoleSelect = i; + this.placeholderRoleSelect = n; break; } } _setupTemplates() { this.optionTemplate = document.createElement("template"), this.optionTemplate.innerHTML = ` -
  • - - +
  • + +
  • `, this.selectedItemTemplate = document.createElement("template"), this.selectedItemTemplate.innerHTML = ` - - - + + + `, this.stagedPlacePillTemplate = document.createElement("template"), this.stagedPlacePillTemplate.innerHTML = ` - - + + `, this.stagedCancelBtnTemplate = document.createElement("template"), this.stagedCancelBtnTemplate.innerHTML = ` - + `, this.stagedRoleSelectTemplate = document.createElement("template"), this.stagedRoleSelectTemplate.innerHTML = ` - `; } _bindEventHandlers() { this._handleInput = this._handleInput.bind(this), this._handleKeyDown = this._handleKeyDown.bind(this), this._handleInputKeyDown = this._handleInputKeyDown.bind(this), this._handleFocus = this._handleFocus.bind(this), this._handleBlur = this._handleBlur.bind(this), this._handleOptionMouseDown = this._handleOptionMouseDown.bind(this), this._handleOptionClick = this._handleOptionClick.bind(this), this._handleAddButtonClick = this._handleAddButtonClick.bind(this), this._handleCancelStagedItem = this._handleCancelStagedItem.bind(this), this._handleStagedRoleChange = this._handleStagedRoleChange.bind(this); } - _getItemById(t) { - return this._options.find((e) => e.id === t); + _getItemById(e) { + return this._options.find((i) => i.id === e); } - _getAvailableRolesForItem(t) { - const e = this._value.filter((i) => i.itemId === t).map((i) => i.role); - return this._roles.filter((i) => !e.includes(i)); + _getAvailableRolesForItem(e) { + const i = this._value.filter((n) => n.itemId === e).map((n) => n.role); + return this._roles.filter((n) => !i.includes(n)); } - setRoles(t) { - if (Array.isArray(t) && t.every((e) => typeof e == "string")) { - this._roles = [...t], this._stagedItem && this._stagedItem.item && (this._getAvailableRolesForItem(this._stagedItem.item.id).includes(this._stagedItem.currentRole) || (this._stagedItem.currentRole = ""), this._renderStagedPillOrInput(), this._updateAddButtonState()); - const e = this._value.filter((i) => this._roles.includes(i.role)); - e.length !== this._value.length && (this.value = e.map((i) => `${i.itemId},${i.role}`)); + setRoles(e) { + if (Array.isArray(e) && e.every((i) => typeof i == "string")) { + this._roles = [...e], this._stagedItem && this._stagedItem.item && (this._getAvailableRolesForItem(this._stagedItem.item.id).includes(this._stagedItem.currentRole) || (this._stagedItem.currentRole = ""), this._renderStagedPillOrInput(), this._updateAddButtonState()); + const i = this._value.filter((n) => this._roles.includes(n.role)); + i.length !== this._value.length && (this.value = i.map((n) => `${n.itemId},${n.role}`)); } else console.error("setRoles expects an array of strings."); } - setOptions(t) { - if (Array.isArray(t) && t.every((e) => e && typeof e.id == "string" && typeof e.name == "string")) { - this._options = [...t]; - const e = this._value.filter((i) => this._getItemById(i.itemId)); - e.length !== this._value.length && (this.value = e.map((i) => `${i.itemId},${i.role}`)), this._stagedItem && this._stagedItem.item && !this._getItemById(this._stagedItem.item.id) && this._handleCancelStagedItem(), this._filteredOptions = [], this._highlightedIndex = -1, this.inputElement && this.inputElement.value ? this._handleInput({ target: this.inputElement }) : this._hideOptionsList(); + setOptions(e) { + if (Array.isArray(e) && e.every((i) => i && typeof i.id == "string" && typeof i.name == "string")) { + this._options = [...e]; + const i = this._value.filter((n) => this._getItemById(n.itemId)); + i.length !== this._value.length && (this.value = i.map((n) => `${n.itemId},${n.role}`)), this._stagedItem && this._stagedItem.item && !this._getItemById(this._stagedItem.item.id) && this._handleCancelStagedItem(), this._filteredOptions = [], this._highlightedIndex = -1, this.inputElement && this.inputElement.value ? this._handleInput({ target: this.inputElement }) : this._hideOptionsList(); } else console.error("setOptions expects an array of objects with id and name properties."); } get value() { return this._value; } - set value(t) { - if (Array.isArray(t)) { - const e = t.map((r) => { - if (typeof r == "string") { - const a = r.split(","); - if (a.length === 2) { - const o = a[0].trim(), l = a[1].trim(); - if (this._getItemById(o) && this._roles.includes(l)) - return { itemId: o, role: l, instanceId: crypto.randomUUID() }; + set value(e) { + if (Array.isArray(e)) { + const i = e.map((a) => { + if (typeof a == "string") { + const o = a.split(","); + if (o.length === 2) { + const l = o[0].trim(), c = o[1].trim(); + if (this._getItemById(l) && this._roles.includes(c)) + return { itemId: l, role: c, instanceId: crypto.randomUUID() }; } } return null; - }).filter((r) => r !== null), i = [], n = /* @__PURE__ */ new Set(); - for (const r of e) { - const a = `${r.itemId},${r.role}`; - n.has(a) || (i.push(r), n.add(a)); + }).filter((a) => a !== null), n = [], r = /* @__PURE__ */ new Set(); + for (const a of i) { + const o = `${a.itemId},${a.role}`; + r.has(o) || (n.push(a), r.add(o)); } - this._value = i; + this._value = n; } else this._value = []; this._updateFormValue(), this.selectedItemsContainer && this._renderSelectedItems(), this._updateRootElementStateClasses(); @@ -6476,24 +6497,24 @@ class ld extends HTMLElement { get name() { return this.getAttribute("name"); } - set name(t) { - this.setAttribute("name", t), this.hiddenSelect && (this.hiddenSelect.name = t); + set name(e) { + this.setAttribute("name", e), this.hiddenSelect && (this.hiddenSelect.name = e); } connectedCallback() { - if (this.placeholderNoSelection = this.getAttribute("placeholder-no-selection") || this._placeholderNoSelection, this.placeholderSearch = this.getAttribute("placeholder-search") || this._placeholderSearch, this.placeholderRoleSelect = this.getAttribute("placeholder-role-select") || this._placeholderRoleSelect, this._render(), this.inputAreaWrapper = this.querySelector(`.${js}`), this.inputElement = this.querySelector(`.${Ks}`), this.stagedItemPillContainer = this.querySelector(`.${Ws}`), this.optionsListElement = this.querySelector(`.${Js}`), this.selectedItemsContainer = this.querySelector(`.${qs}`), this.addButtonElement = this.querySelector(`.${Gs}`), this.preAddButtonElement = this.querySelector(`.${Vs}`), this.hiddenSelect = this.querySelector(`.${Zi}`), this.name && this.hiddenSelect && (this.hiddenSelect.name = this.name), this.hasAttribute("show-add-button") ? this.showAddButton = this.getAttribute("show-add-button") : this.setAttribute("show-add-button", String(this._showAddButton)), this.inputElement && (this.inputElement.placeholder = this.placeholderSearch), this.inputElement.addEventListener("input", this._handleInput), this.inputElement.addEventListener("keydown", this._handleInputKeyDown), this.inputElement.addEventListener("focus", this._handleFocus), this.inputElement.addEventListener("blur", this._handleBlur), this.optionsListElement.addEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.addEventListener("click", this._handleOptionClick), this.addButtonElement.addEventListener("click", this._handleAddButtonClick), this.addEventListener("keydown", this._handleKeyDown), this._renderStagedPillOrInput(), this._updateAddButtonState(), this._updatePreAddButtonVisibility(), this._updateRootElementStateClasses(), this.hasAttribute("value")) { - const t = this.getAttribute("value"); + if (this.placeholderNoSelection = this.getAttribute("placeholder-no-selection") || this._placeholderNoSelection, this.placeholderSearch = this.getAttribute("placeholder-search") || this._placeholderSearch, this.placeholderRoleSelect = this.getAttribute("placeholder-role-select") || this._placeholderRoleSelect, this._render(), this.inputAreaWrapper = this.querySelector(`.${nr}`), this.inputElement = this.querySelector(`.${ar}`), this.stagedItemPillContainer = this.querySelector(`.${sr}`), this.optionsListElement = this.querySelector(`.${lr}`), this.selectedItemsContainer = this.querySelector(`.${Zs}`), this.addButtonElement = this.querySelector(`.${or}`), this.preAddButtonElement = this.querySelector(`.${ir}`), this.hiddenSelect = this.querySelector(`.${hn}`), this.name && this.hiddenSelect && (this.hiddenSelect.name = this.name), this.hasAttribute("show-add-button") ? this.showAddButton = this.getAttribute("show-add-button") : this.setAttribute("show-add-button", String(this._showAddButton)), this.inputElement && (this.inputElement.placeholder = this.placeholderSearch), this.inputElement.addEventListener("input", this._handleInput), this.inputElement.addEventListener("keydown", this._handleInputKeyDown), this.inputElement.addEventListener("focus", this._handleFocus), this.inputElement.addEventListener("blur", this._handleBlur), this.optionsListElement.addEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.addEventListener("click", this._handleOptionClick), this.addButtonElement.addEventListener("click", this._handleAddButtonClick), this.addEventListener("keydown", this._handleKeyDown), this._renderStagedPillOrInput(), this._updateAddButtonState(), this._updatePreAddButtonVisibility(), this._updateRootElementStateClasses(), this.hasAttribute("value")) { + const e = this.getAttribute("value"); try { - const e = JSON.parse(t); - Array.isArray(e) ? this.value = e : (console.warn("Parsed value attribute is not an array:", e), this.value = []); - } catch (e) { - if (console.warn("Failed to parse value attribute as JSON array. Attribute was:", t, e), t.startsWith("[") && t.endsWith("]")) + const i = JSON.parse(e); + Array.isArray(i) ? this.value = i : (console.warn("Parsed value attribute is not an array:", i), this.value = []); + } catch (i) { + if (console.warn("Failed to parse value attribute as JSON array. Attribute was:", e, i), e.startsWith("[") && e.endsWith("]")) try { - const i = t.slice(1, -1).split(",").map((n) => n.replace(/"/g, "").trim()).filter((n) => n); - this.value = i; - } catch (i) { - console.error("Manual parse of value attribute also failed:", t, i), this.value = []; + const n = e.slice(1, -1).split(",").map((r) => r.replace(/"/g, "").trim()).filter((r) => r); + this.value = n; + } catch (n) { + console.error("Manual parse of value attribute also failed:", e, n), this.value = []; } - else t.includes(",") ? this.value = [t] : this.value = []; + else e.includes(",") ? this.value = [e] : this.value = []; } } else this._renderSelectedItems(), this._synchronizeHiddenSelect(); @@ -6502,228 +6523,230 @@ class ld extends HTMLElement { disconnectedCallback() { this.inputElement && (this.inputElement.removeEventListener("input", this._handleInput), this.inputElement.removeEventListener("keydown", this._handleInputKeyDown), this.inputElement.removeEventListener("focus", this._handleFocus), this.inputElement.removeEventListener("blur", this._handleBlur)), this.optionsListElement && (this.optionsListElement.removeEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.removeEventListener("click", this._handleOptionClick)), this.addButtonElement && this.addButtonElement.removeEventListener("click", this._handleAddButtonClick), this.removeEventListener("keydown", this._handleKeyDown), clearTimeout(this._blurTimeout); } - formAssociatedCallback(t) { + formAssociatedCallback(e) { } - formDisabledCallback(t) { - this.disabledCallback(t); + formDisabledCallback(e) { + this.disabledCallback(e); } - disabledCallback(t) { - this.inputElement && (this.inputElement.disabled = t), this.classList.toggle("pointer-events-none", t), this.querySelectorAll(`.${Us}`).forEach( - (i) => i.disabled = t + disabledCallback(e) { + this.inputElement && (this.inputElement.disabled = e), this.classList.toggle("pointer-events-none", e), this.querySelectorAll(`.${er}`).forEach( + (n) => n.disabled = e ); - const e = this.querySelector(`.${Qi}`); - e && (e.disabled = t), this.hiddenSelect && (this.hiddenSelect.disabled = t), this._updateAddButtonState(), this._updatePreAddButtonVisibility(); + const i = this.querySelector(`.${cn}`); + i && (i.disabled = e), this.hiddenSelect && (this.hiddenSelect.disabled = e), this._updateAddButtonState(), this._updatePreAddButtonVisibility(); } formResetCallback() { this.value = [], this._stagedItem = null, this._renderStagedPillOrInput(), this._hideOptionsList(), this.inputElement && (this.inputElement.value = ""), this._updateRootElementStateClasses(); } - formStateRestoreCallback(t, e) { - Array.isArray(t) && t.every((i) => typeof i == "string" && i.includes(",")) ? this.value = t : this.value = [], this._updateRootElementStateClasses(), this._updatePreAddButtonVisibility(); + formStateRestoreCallback(e, i) { + Array.isArray(e) && e.every((n) => typeof n == "string" && n.includes(",")) ? this.value = e : this.value = [], this._updateRootElementStateClasses(), this._updatePreAddButtonVisibility(); } _synchronizeHiddenSelect() { - this.hiddenSelect && (this.hiddenSelect.innerHTML = "", this._value.forEach((t) => { - const e = document.createElement("option"); - e.value = `${t.itemId},${t.role}`, e.textContent = `${this._getItemById(t.itemId)?.name || t.itemId} (${t.role})`, e.selected = !0, this.hiddenSelect.appendChild(e); + this.hiddenSelect && (this.hiddenSelect.innerHTML = "", this._value.forEach((e) => { + var n; + const i = document.createElement("option"); + i.value = `${e.itemId},${e.role}`, i.textContent = `${((n = this._getItemById(e.itemId)) == null ? void 0 : n.name) || e.itemId} (${e.role})`, i.selected = !0, this.hiddenSelect.appendChild(i); })); } _updateFormValue() { this.internals_.setFormValue(null), this._synchronizeHiddenSelect(); } _updateRootElementStateClasses() { - this.classList.toggle(sd, this._value.length === 0), this.classList.toggle(rd, this._value.length > 0), this.classList.toggle(ad, this._isOptionsListVisible), this.classList.toggle(od, !!this._stagedItem); + this.classList.toggle(Ed, this._value.length === 0), this.classList.toggle(xd, this._value.length > 0), this.classList.toggle(Sd, this._isOptionsListVisible), this.classList.toggle(Ld, !!this._stagedItem); } _render() { - const t = this.id || `msr-${crypto.randomUUID().slice(0, 8)}`; - this.id || this.setAttribute("id", t), this.innerHTML = ` + const e = this.id || `msr-${crypto.randomUUID().slice(0, 8)}`; + this.id || this.setAttribute("id", e), this.innerHTML = ` -
    -
    - ${this._value.length === 0 ? `${this.placeholderNoSelection}` : ""} +
    +
    + ${this._value.length === 0 ? `${this.placeholderNoSelection}` : ""}
    -
    -
    - +
    +
    +
    - +
    - - + +
    `; } - _createStagedItemPillElement(t) { - const i = this.stagedPlacePillTemplate.content.cloneNode(!0).firstElementChild; - return i.querySelector('[data-ref="nameEl"]').textContent = t.name, i; + _createStagedItemPillElement(e) { + const n = this.stagedPlacePillTemplate.content.cloneNode(!0).firstElementChild; + return n.querySelector('[data-ref="nameEl"]').textContent = e.name, n; } - _createStagedRoleSelectElement(t, e) { - const n = this.stagedRoleSelectTemplate.content.cloneNode(!0).firstElementChild; - let r = ``; - return t.length === 0 && !this._roles.includes(e) ? (r += "", n.disabled = !0) : (t.forEach((a) => { - r += ``; - }), n.disabled = t.length === 0 && e === ""), n.innerHTML = r, n.addEventListener("change", this._handleStagedRoleChange), n; + _createStagedRoleSelectElement(e, i) { + const r = this.stagedRoleSelectTemplate.content.cloneNode(!0).firstElementChild; + let a = ``; + return e.length === 0 && !this._roles.includes(i) ? (a += "", r.disabled = !0) : (e.forEach((o) => { + a += ``; + }), r.disabled = e.length === 0 && i === ""), r.innerHTML = a, r.addEventListener("change", this._handleStagedRoleChange), r; } - _createStagedCancelButtonElement(t) { - const i = this.stagedCancelBtnTemplate.content.cloneNode(!0).firstElementChild; - return i.setAttribute("aria-label", `Auswahl von ${t} abbrechen`), i.addEventListener("click", this._handleCancelStagedItem), i; + _createStagedCancelButtonElement(e) { + const n = this.stagedCancelBtnTemplate.content.cloneNode(!0).firstElementChild; + return n.setAttribute("aria-label", `Auswahl von ${e} abbrechen`), n.addEventListener("click", this._handleCancelStagedItem), n; } _renderStagedPillOrInput() { if (!(!this.stagedItemPillContainer || !this.inputElement || !this.inputAreaWrapper)) { if (this.stagedItemPillContainer.innerHTML = "", this._stagedItem && this._stagedItem.item) { - this.inputAreaWrapper.classList.remove(We), this.inputAreaWrapper.classList.add(Xi); - const t = this._createStagedItemPillElement(this._stagedItem.item); - this.stagedItemPillContainer.appendChild(t); - const e = this._getAvailableRolesForItem(this._stagedItem.item.id), i = this._createStagedRoleSelectElement( - e, + this.inputAreaWrapper.classList.remove(Qe), this.inputAreaWrapper.classList.add(dn); + const e = this._createStagedItemPillElement(this._stagedItem.item); + this.stagedItemPillContainer.appendChild(e); + const i = this._getAvailableRolesForItem(this._stagedItem.item.id), n = this._createStagedRoleSelectElement( + i, this._stagedItem.currentRole ); - this.stagedItemPillContainer.appendChild(i); - const n = this._createStagedCancelButtonElement(this._stagedItem.item.name); - this.stagedItemPillContainer.appendChild(n), this.inputElement.classList.add("hidden"), this.inputElement.value = "", this.inputElement.removeAttribute("aria-activedescendant"), this.inputElement.setAttribute("aria-expanded", "false"); + this.stagedItemPillContainer.appendChild(n); + const r = this._createStagedCancelButtonElement(this._stagedItem.item.name); + this.stagedItemPillContainer.appendChild(r), this.inputElement.classList.add("hidden"), this.inputElement.value = "", this.inputElement.removeAttribute("aria-activedescendant"), this.inputElement.setAttribute("aria-expanded", "false"); } else - this.inputAreaWrapper.classList.add(We), this.inputAreaWrapper.classList.remove(Xi), this.inputElement.classList.remove("hidden"); + this.inputAreaWrapper.classList.add(Qe), this.inputAreaWrapper.classList.remove(dn), this.inputElement.classList.remove("hidden"); this._updateAddButtonState(), this._updatePreAddButtonVisibility(), this._updateRootElementStateClasses(); } } _updatePreAddButtonVisibility() { if (!this.preAddButtonElement) return; - const t = this.hasAttribute("disabled"), e = !this._stagedItem, i = this.showAddButton && e && !t; - this.preAddButtonElement.classList.toggle("hidden", !i), this.preAddButtonElement.disabled = t; + const e = this.hasAttribute("disabled"), i = !this._stagedItem, n = this.showAddButton && i && !e; + this.preAddButtonElement.classList.toggle("hidden", !n), this.preAddButtonElement.disabled = e; } - _handleStagedRoleChange(t) { - this._stagedItem && (this._stagedItem.currentRole = t.target.value, this._updateAddButtonState()); + _handleStagedRoleChange(e) { + this._stagedItem && (this._stagedItem.currentRole = e.target.value, this._updateAddButtonState()); } - _handleCancelStagedItem(t) { - t && t.stopPropagation(), this._stagedItem = null, this._renderStagedPillOrInput(), this.inputElement && (this.inputElement.value = "", this.inputElement.focus()), this._hideOptionsList(); + _handleCancelStagedItem(e) { + e && e.stopPropagation(), this._stagedItem = null, this._renderStagedPillOrInput(), this.inputElement && (this.inputElement.value = "", this.inputElement.focus()), this._hideOptionsList(); } - _createSelectedItemElement(t) { - const e = this._getItemById(t.itemId); - if (!e) return null; - const n = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, r = n.querySelector('[data-ref="textEl"]'); - let a = `${e.name}`, o = e.additional_data ? ` (${e.additional_data})` : "", l = ` ${t.role}`; - r.innerHTML = `${a}${o}${l}`; - const c = n.querySelector('[data-ref="deleteBtn"]'); - return c.setAttribute("aria-label", `Entferne ${e.name} als ${t.role}`), c.dataset.instanceId = t.instanceId, c.disabled = this.hasAttribute("disabled"), c.addEventListener("click", (u) => { - u.stopPropagation(), this._handleDeleteSelectedItem(t.instanceId); - }), n; + _createSelectedItemElement(e) { + const i = this._getItemById(e.itemId); + if (!i) return null; + const r = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, a = r.querySelector('[data-ref="textEl"]'); + let o = `${i.name}`, l = i.additional_data ? ` (${i.additional_data})` : "", c = ` ${e.role}`; + a.innerHTML = `${o}${l}${c}`; + const u = r.querySelector('[data-ref="deleteBtn"]'); + return u.setAttribute("aria-label", `Entferne ${i.name} als ${e.role}`), u.dataset.instanceId = e.instanceId, u.disabled = this.hasAttribute("disabled"), u.addEventListener("click", (m) => { + m.stopPropagation(), this._handleDeleteSelectedItem(e.instanceId); + }), r; } _renderSelectedItems() { - this.selectedItemsContainer && (this.selectedItemsContainer.innerHTML = "", this._value.length === 0 ? this.selectedItemsContainer.innerHTML = `${this.placeholderNoSelection}` : this._value.forEach((t) => { - const e = this._createSelectedItemElement(t); - e && this.selectedItemsContainer.appendChild(e); + this.selectedItemsContainer && (this.selectedItemsContainer.innerHTML = "", this._value.length === 0 ? this.selectedItemsContainer.innerHTML = `${this.placeholderNoSelection}` : this._value.forEach((e) => { + const i = this._createSelectedItemElement(e); + i && this.selectedItemsContainer.appendChild(i); }), this._updateRootElementStateClasses()); } _updateAddButtonState() { if (this.addButtonElement) { - const t = this.hasAttribute("disabled"), e = this._stagedItem && this._stagedItem.currentRole && this._roles.includes(this._stagedItem.currentRole), i = !this._stagedItem || !e || t; - this.addButtonElement.classList.toggle("hidden", i), this.addButtonElement.disabled = i; + const e = this.hasAttribute("disabled"), i = this._stagedItem && this._stagedItem.currentRole && this._roles.includes(this._stagedItem.currentRole), n = !this._stagedItem || !i || e; + this.addButtonElement.classList.toggle("hidden", n), this.addButtonElement.disabled = n; } } - _createOptionElement(t, e) { - const n = this.optionTemplate.content.cloneNode(!0).firstElementChild; - return n.querySelector('[data-ref="nameEl"]').textContent = t.name, n.querySelector('[data-ref="detailEl"]').textContent = t.additional_data ? `(${t.additional_data})` : "", n.dataset.id = t.id, n.setAttribute("aria-selected", String(e === this._highlightedIndex)), n.id = `${this.id || "msr"}-option-${t.id}`, e === this._highlightedIndex && n.classList.add(Xs), n; + _createOptionElement(e, i) { + const r = this.optionTemplate.content.cloneNode(!0).firstElementChild; + return r.querySelector('[data-ref="nameEl"]').textContent = e.name, r.querySelector('[data-ref="detailEl"]').textContent = e.additional_data ? `(${e.additional_data})` : "", r.dataset.id = e.id, r.setAttribute("aria-selected", String(i === this._highlightedIndex)), r.id = `${this.id || "msr"}-option-${e.id}`, i === this._highlightedIndex && r.classList.add(cr), r; } _renderOptionsList() { if (!(!this.optionsListElement || !this.inputElement)) { if (this.optionsListElement.innerHTML = "", this._filteredOptions.length === 0 || !this._isOptionsListVisible) this.optionsListElement.classList.add("hidden"), this.inputElement.setAttribute("aria-expanded", "false"), this.inputElement.removeAttribute("aria-activedescendant"), this.inputElement.removeAttribute("aria-controls"); else { - this.optionsListElement.classList.remove("hidden"), this.inputElement.setAttribute("aria-expanded", "true"), this.inputElement.setAttribute("aria-controls", this.optionsListElement.id), this._filteredOptions.forEach((e, i) => { - const n = this._createOptionElement(e, i); - this.optionsListElement.appendChild(n); + this.optionsListElement.classList.remove("hidden"), this.inputElement.setAttribute("aria-expanded", "true"), this.inputElement.setAttribute("aria-controls", this.optionsListElement.id), this._filteredOptions.forEach((i, n) => { + const r = this._createOptionElement(i, n); + this.optionsListElement.appendChild(r); }); - const t = this.optionsListElement.querySelector( - `.${Xs}` + const e = this.optionsListElement.querySelector( + `.${cr}` ); - t ? (t.scrollIntoView({ block: "nearest" }), this.inputElement.setAttribute("aria-activedescendant", t.id)) : this.inputElement.removeAttribute("aria-activedescendant"); + e ? (e.scrollIntoView({ block: "nearest" }), this.inputElement.setAttribute("aria-activedescendant", e.id)) : this.inputElement.removeAttribute("aria-activedescendant"); } this._updateRootElementStateClasses(); } } - _stageItem(t) { - if (this._getAvailableRolesForItem(t.id).length === 0) + _stageItem(e) { + if (this._getAvailableRolesForItem(e.id).length === 0) return; - this._stagedItem = { item: t, currentRole: "" }, this.inputElement && (this.inputElement.value = "", this.inputElement.setAttribute("aria-expanded", "false"), this.inputElement.removeAttribute("aria-activedescendant")), this._renderStagedPillOrInput(), this._hideOptionsList(); - const i = this.stagedItemPillContainer.querySelector( - `.${Qi}` + this._stagedItem = { item: e, currentRole: "" }, this.inputElement && (this.inputElement.value = "", this.inputElement.setAttribute("aria-expanded", "false"), this.inputElement.removeAttribute("aria-activedescendant")), this._renderStagedPillOrInput(), this._hideOptionsList(); + const n = this.stagedItemPillContainer.querySelector( + `.${cn}` ); - i && !i.disabled ? i.focus() : this.addButtonElement && !this.addButtonElement.disabled && this.addButtonElement.focus(); + n && !n.disabled ? n.focus() : this.addButtonElement && !this.addButtonElement.disabled && this.addButtonElement.focus(); } _handleAddButtonClick() { if (!this.hasAttribute("disabled") && this._stagedItem && this._stagedItem.item && this._stagedItem.currentRole && this._roles.includes(this._stagedItem.currentRole)) { - const t = { + const e = { itemId: this._stagedItem.item.id, role: this._stagedItem.currentRole, instanceId: crypto.randomUUID() }; if (this._value.find( - (i) => i.itemId === t.itemId && i.role === t.role + (n) => n.itemId === e.itemId && n.role === e.role )) { this._handleCancelStagedItem(); return; } - this._value.push(t), this._updateFormValue(), this._renderSelectedItems(), this._stagedItem = null, this._renderStagedPillOrInput(), this.inputElement && (this.inputElement.value = "", this.inputElement.focus()), this._hideOptionsList(); + this._value.push(e), this._updateFormValue(), this._renderSelectedItems(), this._stagedItem = null, this._renderStagedPillOrInput(), this.inputElement && (this.inputElement.value = "", this.inputElement.focus()), this._hideOptionsList(); } } - _handleInput(t) { + _handleInput(e) { if (this.hasAttribute("disabled")) return; this._stagedItem ? (this._stagedItem = null, this._renderStagedPillOrInput()) : this._updatePreAddButtonVisibility(); - const e = t.target.value; - if (e.length === 0) + const i = e.target.value; + if (i.length === 0) this._filteredOptions = [], this._isOptionsListVisible = !1; else { - const i = e.toLowerCase(); - this._filteredOptions = this._options.filter((n) => this._getAvailableRolesForItem(n.id).length === 0 || this._stagedItem && this._stagedItem.item.id === n.id ? !1 : n.name.toLowerCase().includes(i) || n.additional_data && n.additional_data.toLowerCase().includes(i)), this._isOptionsListVisible = this._filteredOptions.length > 0; + const n = i.toLowerCase(); + this._filteredOptions = this._options.filter((r) => this._getAvailableRolesForItem(r.id).length === 0 || this._stagedItem && this._stagedItem.item.id === r.id ? !1 : r.name.toLowerCase().includes(n) || r.additional_data && r.additional_data.toLowerCase().includes(n)), this._isOptionsListVisible = this._filteredOptions.length > 0; } this._highlightedIndex = this._filteredOptions.length > 0 ? 0 : -1, this._renderOptionsList(); } - _handleKeyDown(t) { + _handleKeyDown(e) { + var i; if (!this.hasAttribute("disabled")) { - if (t.key === "Enter" && this._stagedItem && this._stagedItem.item) { - const e = document.activeElement, i = this.stagedItemPillContainer?.querySelector( - `.${zs}` + if (e.key === "Enter" && this._stagedItem && this._stagedItem.item) { + const n = document.activeElement, r = (i = this.stagedItemPillContainer) == null ? void 0 : i.querySelector( + `.${rr}` ); - if (e === i) { - t.preventDefault(), this._handleCancelStagedItem(t); + if (n === r) { + e.preventDefault(), this._handleCancelStagedItem(e); return; } else if (this._stagedItem.currentRole && this._roles.includes(this._stagedItem.currentRole)) { - t.preventDefault(), this._handleAddButtonClick(); + e.preventDefault(), this._handleAddButtonClick(); return; } } - t.key === "Escape" && (this._isOptionsListVisible ? (t.preventDefault(), this._hideOptionsList(), this.inputElement && this.inputElement.focus()) : this._stagedItem && (t.preventDefault(), this._handleCancelStagedItem(t))); + e.key === "Escape" && (this._isOptionsListVisible ? (e.preventDefault(), this._hideOptionsList(), this.inputElement && this.inputElement.focus()) : this._stagedItem && (e.preventDefault(), this._handleCancelStagedItem(e))); } } - _handleInputKeyDown(t) { + _handleInputKeyDown(e) { if (!(this.hasAttribute("disabled") || this.inputElement && this.inputElement.disabled)) { if (!this._isOptionsListVisible || this._filteredOptions.length === 0) { - t.key === "Enter" && this.inputElement && this.inputElement.value === "" && t.preventDefault(); + e.key === "Enter" && this.inputElement && this.inputElement.value === "" && e.preventDefault(); return; } - switch (t.key) { + switch (e.key) { case "ArrowDown": - t.preventDefault(), this._highlightedIndex = (this._highlightedIndex + 1) % this._filteredOptions.length, this._renderOptionsList(); + e.preventDefault(), this._highlightedIndex = (this._highlightedIndex + 1) % this._filteredOptions.length, this._renderOptionsList(); break; case "ArrowUp": - t.preventDefault(), this._highlightedIndex = (this._highlightedIndex - 1 + this._filteredOptions.length) % this._filteredOptions.length, this._renderOptionsList(); + e.preventDefault(), this._highlightedIndex = (this._highlightedIndex - 1 + this._filteredOptions.length) % this._filteredOptions.length, this._renderOptionsList(); break; case "Enter": case "Tab": - this._highlightedIndex > -1 && this._filteredOptions[this._highlightedIndex] ? (t.preventDefault(), this._stageItem(this._filteredOptions[this._highlightedIndex])) : t.key === "Tab" && this._hideOptionsList(); + this._highlightedIndex > -1 && this._filteredOptions[this._highlightedIndex] ? (e.preventDefault(), this._stageItem(this._filteredOptions[this._highlightedIndex])) : e.key === "Tab" && this._hideOptionsList(); break; } } @@ -6733,41 +6756,42 @@ class ld extends HTMLElement { } _handleFocus() { if (!(this.hasAttribute("disabled") || this.inputElement && this.inputElement.disabled || this._stagedItem)) { - if (!this._stagedItem && this.inputAreaWrapper && (this.inputAreaWrapper.classList.add(We), this.inputAreaWrapper.classList.remove(Xi)), this.inputElement && this.inputElement.value.length > 0) { - const t = this.inputElement.value.toLowerCase(); - this._filteredOptions = this._options.filter((e) => this._getAvailableRolesForItem(e.id).length === 0 ? !1 : e.name.toLowerCase().includes(t) || e.additional_data && e.additional_data.toLowerCase().includes(t)), this._filteredOptions.length > 0 ? (this._isOptionsListVisible = !0, this._highlightedIndex = 0, this._renderOptionsList()) : this._hideOptionsList(); + if (!this._stagedItem && this.inputAreaWrapper && (this.inputAreaWrapper.classList.add(Qe), this.inputAreaWrapper.classList.remove(dn)), this.inputElement && this.inputElement.value.length > 0) { + const e = this.inputElement.value.toLowerCase(); + this._filteredOptions = this._options.filter((i) => this._getAvailableRolesForItem(i.id).length === 0 ? !1 : i.name.toLowerCase().includes(e) || i.additional_data && i.additional_data.toLowerCase().includes(e)), this._filteredOptions.length > 0 ? (this._isOptionsListVisible = !0, this._highlightedIndex = 0, this._renderOptionsList()) : this._hideOptionsList(); } else this._hideOptionsList(); this._updateRootElementStateClasses(), this._updatePreAddButtonVisibility(); } } - _blurTimeout = null; - _handleBlur(t) { + _handleBlur(e) { this._blurTimeout = setTimeout(() => { - const e = document.activeElement; - e !== this.addButtonElement && e !== this.preAddButtonElement && !(this.stagedItemPillContainer && this.stagedItemPillContainer.contains(e)) && !(this.optionsListElement && this.optionsListElement.contains(e)) && !this.contains(e) && this._hideOptionsList(); + const i = document.activeElement; + i !== this.addButtonElement && i !== this.preAddButtonElement && !(this.stagedItemPillContainer && this.stagedItemPillContainer.contains(i)) && !(this.optionsListElement && this.optionsListElement.contains(i)) && !this.contains(i) && this._hideOptionsList(); }, 150); } - _handleOptionMouseDown(t) { - t.preventDefault(); + _handleOptionMouseDown(e) { + e.preventDefault(); } - _handleOptionClick(t) { + _handleOptionClick(e) { if (this.hasAttribute("disabled")) return; - const e = t.target.closest(`li[data-id].${Ys}`); - if (e) { - const i = e.dataset.id, n = this._filteredOptions.find((r) => r.id === i); - n && this._stageItem(n); + const i = e.target.closest(`li[data-id].${dr}`); + if (i) { + const n = i.dataset.id, r = this._filteredOptions.find((a) => a.id === n); + r && this._stageItem(r); } } - _handleDeleteSelectedItem(t) { - this.hasAttribute("disabled") || (this._value = this._value.filter((e) => e.instanceId !== t), this._updateFormValue(), this._renderSelectedItems(), this._stagedItem && this._stagedItem.item && this._renderStagedPillOrInput(), this.inputElement && this.inputElement.focus(), this._updatePreAddButtonVisibility()); + _handleDeleteSelectedItem(e) { + this.hasAttribute("disabled") || (this._value = this._value.filter((i) => i.instanceId !== e), this._updateFormValue(), this._renderSelectedItems(), this._stagedItem && this._stagedItem.item && this._renderStagedPillOrInput(), this.inputElement && this.inputElement.focus(), this._updatePreAddButtonVisibility()); } } -const dd = "mss-component-wrapper", Qs = "mss-selected-items-container", cd = "mss-selected-item-pill", hd = "mss-selected-item-text", ud = "mss-selected-item-pill-detail", Zs = "mss-selected-item-delete-btn", md = "mss-selected-item-edit-link", tr = "mss-input-controls-container", er = "mss-input-wrapper", ir = "mss-input-wrapper-focused", nr = "mss-text-input", sr = "mss-create-new-button", rr = "mss-toggle-button", gd = "mss-inline-row", ar = "mss-options-list", pd = "mss-option-item", fd = "mss-option-item-name", bd = "mss-option-item-detail", or = "mss-option-item-highlighted", tn = "mss-hidden-select", en = "mss-no-items-text", lr = "mss-loading", nn = 1, sn = 10, _d = 250, vd = "mss-state-no-selection", yd = "mss-state-has-selection", Ad = "mss-state-list-open"; -class Ed extends HTMLElement { - static formAssociated = !0; +Xt(qa, "formAssociated", !0); +const Cd = "mss-component-wrapper", hr = "mss-selected-items-container", wd = "mss-selected-item-pill", Td = "mss-selected-item-text", kd = "mss-selected-item-pill-detail", ur = "mss-selected-item-delete-btn", Id = "mss-selected-item-edit-link", mr = "mss-input-controls-container", gr = "mss-input-wrapper", pr = "mss-input-wrapper-focused", fr = "mss-text-input", br = "mss-create-new-button", _r = "mss-toggle-button", Rd = "mss-inline-row", vr = "mss-options-list", Dd = "mss-option-item", Od = "mss-option-item-name", Bd = "mss-option-item-detail", yr = "mss-option-item-highlighted", un = "mss-hidden-select", mn = "mss-no-items-text", Ar = "mss-loading", gn = 1, pn = 10, Md = 250, Nd = "mss-state-no-selection", Pd = "mss-state-has-selection", Fd = "mss-state-list-open"; +class $a extends HTMLElement { constructor() { - super(), this.internals_ = this.attachInternals(), this._value = [], this._initialValue = [], this._initialOrder = [], this._displayOrder = [], this._removedIds = /* @__PURE__ */ new Set(), this._initialCaptured = !1, this._allowInitialCapture = !0, this._options = [ + super(); + Xt(this, "_blurTimeout", null); + this.internals_ = this.attachInternals(), this._value = [], this._initialValue = [], this._initialOrder = [], this._displayOrder = [], this._removedIds = /* @__PURE__ */ new Set(), this._initialCaptured = !1, this._allowInitialCapture = !0, this._options = [ { id: "abk", name: "Abchasisch" }, { id: "aar", name: "Afar" }, { id: "afr", name: "Afrikaans" }, @@ -6951,87 +6975,87 @@ class Ed extends HTMLElement { { id: "yor", name: "Yoruba" }, { id: "zha", name: "Zhuang" }, { id: "zul", name: "Zulu" } - ], this._filteredOptions = [], this._highlightedIndex = -1, this._isOptionsListVisible = !1, this._remoteEndpoint = null, this._remoteResultKey = "items", this._remoteMinChars = nn, this._remoteLimit = sn, this._remoteFetchController = null, this._remoteFetchTimeout = null, this._placeholder = this.getAttribute("placeholder") || "Search items...", this._showCreateButton = this.getAttribute("show-create-button") !== "false", this._toggleLabel = this.getAttribute("data-toggle-label") || "", this._toggleInput = this._toggleLabel !== "", this._inputCollapsed = this._toggleInput, this._editBase = this.getAttribute("data-edit-base") || "", this._editSuffix = this.getAttribute("data-edit-suffix") || "/edit", this._setupTemplates(), this._bindEventHandlers(); + ], this._filteredOptions = [], this._highlightedIndex = -1, this._isOptionsListVisible = !1, this._remoteEndpoint = null, this._remoteResultKey = "items", this._remoteMinChars = gn, this._remoteLimit = pn, this._remoteFetchController = null, this._remoteFetchTimeout = null, this._placeholder = this.getAttribute("placeholder") || "Search items...", this._showCreateButton = this.getAttribute("show-create-button") !== "false", this._toggleLabel = this.getAttribute("data-toggle-label") || "", this._toggleInput = this._toggleLabel !== "", this._inputCollapsed = this._toggleInput, this._editBase = this.getAttribute("data-edit-base") || "", this._editSuffix = this.getAttribute("data-edit-suffix") || "/edit", this._setupTemplates(), this._bindEventHandlers(); } _setupTemplates() { this.optionTemplate = document.createElement("template"), this.optionTemplate.innerHTML = ` -
  • - - +
  • + +
  • `, this.selectedItemTemplate = document.createElement("template"), this.selectedItemTemplate.innerHTML = ` - - - - - + `; } _bindEventHandlers() { this._handleInput = this._handleInput.bind(this), this._handleKeyDown = this._handleKeyDown.bind(this), this._handleFocus = this._handleFocus.bind(this), this._handleBlur = this._handleBlur.bind(this), this._handleOptionMouseDown = this._handleOptionMouseDown.bind(this), this._handleOptionClick = this._handleOptionClick.bind(this), this._handleCreateNewButtonClick = this._handleCreateNewButtonClick.bind(this), this._handleSelectedItemsContainerClick = this._handleSelectedItemsContainerClick.bind(this), this._handleToggleClick = this._handleToggleClick.bind(this); } - _getItemById(t) { - return this._options.find((e) => e.id === t); + _getItemById(e) { + return this._options.find((i) => i.id === e); } get placeholder() { return this._placeholder; } - set placeholder(t) { - this._placeholder = t, this.inputElement && (this.inputElement.placeholder = this._placeholder), this.setAttribute("placeholder", t); + set placeholder(e) { + this._placeholder = e, this.inputElement && (this.inputElement.placeholder = this._placeholder), this.setAttribute("placeholder", e); } get showCreateButton() { return this._showCreateButton; } - set showCreateButton(t) { - const e = String(t).toLowerCase() !== "false" && t !== !1; - this._showCreateButton !== e && (this._showCreateButton = e, this.createNewButton && this.createNewButton.classList.toggle("hidden", !this._showCreateButton), this.setAttribute("show-create-button", this._showCreateButton ? "true" : "false")); + set showCreateButton(e) { + const i = String(e).toLowerCase() !== "false" && e !== !1; + this._showCreateButton !== i && (this._showCreateButton = i, this.createNewButton && this.createNewButton.classList.toggle("hidden", !this._showCreateButton), this.setAttribute("show-create-button", this._showCreateButton ? "true" : "false")); } - setOptions(t) { - if (Array.isArray(t) && t.every((e) => e && typeof e.id == "string" && typeof e.name == "string")) { - this._options = t.map((i) => { - const n = { ...i }; - return n.name = this._normalizeText(n.name), n.additional_data = this._normalizeText(n.additional_data), n; + setOptions(e) { + if (Array.isArray(e) && e.every((i) => i && typeof i.id == "string" && typeof i.name == "string")) { + this._options = e.map((n) => { + const r = { ...n }; + return r.name = this._normalizeText(r.name), r.additional_data = this._normalizeText(r.additional_data), r; }); - const e = this._value.filter((i) => this._getItemById(i)); - e.length !== this._value.length ? this.value = e : this.selectedItemsContainer && this._renderSelectedItems(), this._filteredOptions = [], this._highlightedIndex = -1, this.inputElement && this.inputElement.value ? this._handleInput({ target: this.inputElement }) : this._hideOptionsList(); + const i = this._value.filter((n) => this._getItemById(n)); + i.length !== this._value.length ? this.value = i : this.selectedItemsContainer && this._renderSelectedItems(), this._filteredOptions = [], this._highlightedIndex = -1, this.inputElement && this.inputElement.value ? this._handleInput({ target: this.inputElement }) : this._hideOptionsList(); } else console.error("setOptions expects an array of objects with id and name properties."); } get value() { return this._value; } - set value(t) { - const e = JSON.stringify([...this._value].sort()); - if (Array.isArray(t)) - this._value = [...new Set(t.filter((n) => typeof n == "string" && this._getItemById(n)))]; - else if (typeof t == "string" && t.trim() !== "") { - const n = t.trim(); - this._getItemById(n) && !this._value.includes(n) ? this._value = [n] : this._getItemById(n) || (this._value = this._value.filter((r) => r !== n)); - } else this._value = []; + set value(e) { const i = JSON.stringify([...this._value].sort()); - this._value.forEach((n) => { - this._displayOrder.includes(n) || this._displayOrder.push(n); - }), !this._initialCaptured && this._allowInitialCapture && this._value.length > 0 && (this._initialValue = [...this._value], this._initialOrder = [...this._value], this._initialCaptured = !0), this._value.forEach((n) => { - this._removedIds.has(n) && this._removedIds.delete(n); - }), e !== i && (this._updateFormValue(), this.selectedItemsContainer && this._renderSelectedItems(), this._updateRootElementStateClasses(), this.dispatchEvent(new Event("change", { bubbles: !0 }))); + if (Array.isArray(e)) + this._value = [...new Set(e.filter((r) => typeof r == "string" && this._getItemById(r)))]; + else if (typeof e == "string" && e.trim() !== "") { + const r = e.trim(); + this._getItemById(r) && !this._value.includes(r) ? this._value = [r] : this._getItemById(r) || (this._value = this._value.filter((a) => a !== r)); + } else this._value = []; + const n = JSON.stringify([...this._value].sort()); + this._value.forEach((r) => { + this._displayOrder.includes(r) || this._displayOrder.push(r); + }), !this._initialCaptured && this._allowInitialCapture && this._value.length > 0 && (this._initialValue = [...this._value], this._initialOrder = [...this._value], this._initialCaptured = !0), this._value.forEach((r) => { + this._removedIds.has(r) && this._removedIds.delete(r); + }), i !== n && (this._updateFormValue(), this.selectedItemsContainer && this._renderSelectedItems(), this._updateRootElementStateClasses(), this.dispatchEvent(new Event("change", { bubbles: !0 }))); } get name() { return this.getAttribute("name"); } - set name(t) { - this.setAttribute("name", t), this.hiddenSelect && (this.hiddenSelect.name = t); + set name(e) { + this.setAttribute("name", e), this.hiddenSelect && (this.hiddenSelect.name = e); } connectedCallback() { - this._render(), this.inputControlsContainer = this.querySelector(`.${tr}`), this.inputWrapper = this.querySelector(`.${er}`), this.inputElement = this.querySelector(`.${nr}`), this.createNewButton = this.querySelector(`.${sr}`), this.toggleButton = this.querySelector(`.${rr}`), this.optionsListElement = this.querySelector(`.${ar}`), this.selectedItemsContainer = this.querySelector(`.${Qs}`), this.hiddenSelect = this.querySelector(`.${tn}`), this.placeholder = this.getAttribute("placeholder") || "Search items...", this.showCreateButton = this.getAttribute("show-create-button") !== "false", this._toggleLabel = this.getAttribute("data-toggle-label") || "", this._toggleInput = this._toggleLabel !== "", this._inputCollapsed = this._toggleInput, this._remoteEndpoint = this.getAttribute("data-endpoint") || null, this._remoteResultKey = this.getAttribute("data-result-key") || "items", this._remoteMinChars = this._parsePositiveInt(this.getAttribute("data-minchars"), nn), this._remoteLimit = this._parsePositiveInt(this.getAttribute("data-limit"), sn), this.name && this.hiddenSelect && (this.hiddenSelect.name = this.name), this.inputElement.addEventListener("input", this._handleInput), this.inputElement.addEventListener("keydown", this._handleKeyDown), this.inputElement.addEventListener("focus", this._handleFocus), this.inputElement.addEventListener("blur", this._handleBlur), this.optionsListElement.addEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.addEventListener("click", this._handleOptionClick), this.createNewButton.addEventListener("click", this._handleCreateNewButtonClick), this.selectedItemsContainer.addEventListener("click", this._handleSelectedItemsContainerClick), this.toggleButton && this.toggleButton.addEventListener("click", this._handleToggleClick); - const t = this.getAttribute("data-external-toggle-id"); - if (t && (this.externalToggleButton = document.getElementById(t), this.externalToggleButton && this.externalToggleButton.addEventListener("click", this._handleToggleClick)), this._updateRootElementStateClasses(), this.hasAttribute("value")) { - const e = this.getAttribute("value"); + this._render(), this.inputControlsContainer = this.querySelector(`.${mr}`), this.inputWrapper = this.querySelector(`.${gr}`), this.inputElement = this.querySelector(`.${fr}`), this.createNewButton = this.querySelector(`.${br}`), this.toggleButton = this.querySelector(`.${_r}`), this.optionsListElement = this.querySelector(`.${vr}`), this.selectedItemsContainer = this.querySelector(`.${hr}`), this.hiddenSelect = this.querySelector(`.${un}`), this.placeholder = this.getAttribute("placeholder") || "Search items...", this.showCreateButton = this.getAttribute("show-create-button") !== "false", this._toggleLabel = this.getAttribute("data-toggle-label") || "", this._toggleInput = this._toggleLabel !== "", this._inputCollapsed = this._toggleInput, this._remoteEndpoint = this.getAttribute("data-endpoint") || null, this._remoteResultKey = this.getAttribute("data-result-key") || "items", this._remoteMinChars = this._parsePositiveInt(this.getAttribute("data-minchars"), gn), this._remoteLimit = this._parsePositiveInt(this.getAttribute("data-limit"), pn), this.name && this.hiddenSelect && (this.hiddenSelect.name = this.name), this.inputElement.addEventListener("input", this._handleInput), this.inputElement.addEventListener("keydown", this._handleKeyDown), this.inputElement.addEventListener("focus", this._handleFocus), this.inputElement.addEventListener("blur", this._handleBlur), this.optionsListElement.addEventListener("mousedown", this._handleOptionMouseDown), this.optionsListElement.addEventListener("click", this._handleOptionClick), this.createNewButton.addEventListener("click", this._handleCreateNewButtonClick), this.selectedItemsContainer.addEventListener("click", this._handleSelectedItemsContainerClick), this.toggleButton && this.toggleButton.addEventListener("click", this._handleToggleClick); + const e = this.getAttribute("data-external-toggle-id"); + if (e && (this.externalToggleButton = document.getElementById(e), this.externalToggleButton && this.externalToggleButton.addEventListener("click", this._handleToggleClick)), this._updateRootElementStateClasses(), this.hasAttribute("value")) { + const i = this.getAttribute("value"); try { - this.value = JSON.parse(e); + this.value = JSON.parse(i); } catch { - this.value = e.split(",").map((n) => n.trim()).filter(Boolean); + this.value = i.split(",").map((r) => r.trim()).filter(Boolean); } } else this._renderSelectedItems(), this._synchronizeHiddenSelect(); @@ -7054,184 +7078,184 @@ class Ed extends HTMLElement { "data-toggle-label" ]; } - attributeChangedCallback(t, e, i) { - if (e !== i) - if (t === "disabled") this.disabledCallback(this.hasAttribute("disabled")); - else if (t === "name" && this.hiddenSelect) this.hiddenSelect.name = i; - else if (t === "value" && this.inputElement) + attributeChangedCallback(e, i, n) { + if (i !== n) + if (e === "disabled") this.disabledCallback(this.hasAttribute("disabled")); + else if (e === "name" && this.hiddenSelect) this.hiddenSelect.name = n; + else if (e === "value" && this.inputElement) try { - this.value = JSON.parse(i); + this.value = JSON.parse(n); } catch { - this.value = i.split(",").map((r) => r.trim()).filter(Boolean); + this.value = n.split(",").map((a) => a.trim()).filter(Boolean); } - else t === "placeholder" ? this.placeholder = i : t === "show-create-button" ? this.showCreateButton = i : t === "data-endpoint" ? this._remoteEndpoint = i || null : t === "data-result-key" ? this._remoteResultKey = i || "items" : t === "data-minchars" ? this._remoteMinChars = this._parsePositiveInt(i, nn) : t === "data-limit" ? this._remoteLimit = this._parsePositiveInt(i, sn) : t === "data-toggle-label" && (this._toggleLabel = i || "", this._toggleInput = this._toggleLabel !== ""); + else e === "placeholder" ? this.placeholder = n : e === "show-create-button" ? this.showCreateButton = n : e === "data-endpoint" ? this._remoteEndpoint = n || null : e === "data-result-key" ? this._remoteResultKey = n || "items" : e === "data-minchars" ? this._remoteMinChars = this._parsePositiveInt(n, gn) : e === "data-limit" ? this._remoteLimit = this._parsePositiveInt(n, pn) : e === "data-toggle-label" && (this._toggleLabel = n || "", this._toggleInput = this._toggleLabel !== ""); } - formAssociatedCallback(t) { + formAssociatedCallback(e) { } - formDisabledCallback(t) { - this.disabledCallback(t); + formDisabledCallback(e) { + this.disabledCallback(e); } formResetCallback() { this.value = [], this._displayOrder = [], this._hideOptionsList(), this.inputElement && (this.inputElement.value = ""), this.placeholder = this.getAttribute("placeholder") || "Search items...", this.showCreateButton = this.getAttribute("show-create-button") !== "false", this._updateRootElementStateClasses(), this._renderSelectedItems(), this._toggleInput && this._hideInputControls(); } - formStateRestoreCallback(t, e) { - this.value = Array.isArray(t) ? t : [], this._updateRootElementStateClasses(); + formStateRestoreCallback(e, i) { + this.value = Array.isArray(e) ? e : [], this._updateRootElementStateClasses(); } captureInitialSelection() { this._initialValue = [...this._value], this._initialOrder = [...this._value], this._displayOrder = [...this._value], this._removedIds.clear(), this._initialCaptured = !0, this._renderSelectedItems(); } _synchronizeHiddenSelect() { - this.hiddenSelect && (this.hiddenSelect.innerHTML = "", this._value.forEach((t) => { - const e = document.createElement("option"); - e.value = t; - const i = this._getItemById(t); - e.textContent = i ? i.name : t, e.selected = !0, this.hiddenSelect.appendChild(e); + this.hiddenSelect && (this.hiddenSelect.innerHTML = "", this._value.forEach((e) => { + const i = document.createElement("option"); + i.value = e; + const n = this._getItemById(e); + i.textContent = n ? n.name : e, i.selected = !0, this.hiddenSelect.appendChild(i); })); } _updateFormValue() { this.internals_.setFormValue(null), this._synchronizeHiddenSelect(); } - disabledCallback(t) { - this.inputElement && (this.inputElement.disabled = t), this.createNewButton && (this.createNewButton.disabled = t), this.toggleAttribute("disabled", t), this.querySelectorAll(`.${Zs}`).forEach((e) => e.disabled = t), this.hiddenSelect && (this.hiddenSelect.disabled = t), t && this._hideOptionsList(); + disabledCallback(e) { + this.inputElement && (this.inputElement.disabled = e), this.createNewButton && (this.createNewButton.disabled = e), this.toggleAttribute("disabled", e), this.querySelectorAll(`.${ur}`).forEach((i) => i.disabled = e), this.hiddenSelect && (this.hiddenSelect.disabled = e), e && this._hideOptionsList(); } _updateRootElementStateClasses() { - this.classList.toggle(vd, this._value.length === 0), this.classList.toggle(yd, this._value.length > 0), this.classList.toggle(Ad, this._isOptionsListVisible); + this.classList.toggle(Nd, this._value.length === 0), this.classList.toggle(Pd, this._value.length > 0), this.classList.toggle(Fd, this._isOptionsListVisible); } _render() { - const t = this.id || `mss-${crypto.randomUUID().slice(0, 8)}`; - this.id || this.setAttribute("id", t); - const e = this.getAttribute("data-toggle-label") || "", i = e !== "", n = i ? "hidden" : ""; + const e = this.id || `mss-${crypto.randomUUID().slice(0, 8)}`; + this.id || this.setAttribute("id", e); + const i = this.getAttribute("data-toggle-label") || "", n = i !== "", r = n ? "hidden" : ""; this.innerHTML = ` -
    -
    -
    - ${i ? `` : ""} -
    -
    +
    +
    +
    + ${n ? `` : ""} +
    +
    - +
    - - + +
    `; } - _createSelectedItemElement(t) { - const e = this._getItemById(t); - if (!e) return null; - const n = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, r = n.querySelector('[data-ref="textEl"]'), a = n.querySelector('[data-ref="detailEl"]'), o = n.querySelector('[data-ref="editLink"]'), l = n.querySelector('[data-ref="deleteBtn"]'); - r.textContent = this._normalizeText(e.name); - const c = this._normalizeText(e.additional_data); - c ? (a.textContent = `(${c})`, a.classList.remove("hidden")) : (a.textContent = "", a.classList.add("hidden")); - const u = this._removedIds.has(t); - if (!this._initialValue.includes(t)) { - const p = document.createElement("span"); - p.className = "ml-1 text-xs text-gray-600", p.textContent = "(Neu)", r.appendChild(p); + _createSelectedItemElement(e) { + const i = this._getItemById(e); + if (!i) return null; + const r = this.selectedItemTemplate.content.cloneNode(!0).firstElementChild, a = r.querySelector('[data-ref="textEl"]'), o = r.querySelector('[data-ref="detailEl"]'), l = r.querySelector('[data-ref="editLink"]'), c = r.querySelector('[data-ref="deleteBtn"]'); + a.textContent = this._normalizeText(i.name); + const u = this._normalizeText(i.additional_data); + u ? (o.textContent = `(${u})`, o.classList.remove("hidden")) : (o.textContent = "", o.classList.add("hidden")); + const m = this._removedIds.has(e); + if (!this._initialValue.includes(e)) { + const h = document.createElement("span"); + h.className = "ml-1 text-xs text-gray-600", h.textContent = "(Neu)", a.appendChild(h); } - return u && (n.classList.add("bg-red-100"), n.style.position = "relative"), o && (this._editBase && !u ? (o.href = `${this._editBase}${t}${this._editSuffix}`, o.target = "_blank", o.rel = "noreferrer", o.classList.remove("hidden")) : (o.classList.add("hidden"), o.removeAttribute("href"), o.removeAttribute("target"), o.removeAttribute("rel"))), l.setAttribute("aria-label", u ? `Undo remove ${e.name}` : `Remove ${e.name}`), l.dataset.id = t, l.disabled = this.hasAttribute("disabled"), l.innerHTML = u ? '' : "×", l.addEventListener("click", (p) => { - p.stopPropagation(), this._handleDeleteSelectedItem(t); - }), n; + return m && (r.classList.add("bg-red-100"), r.style.position = "relative"), l && (this._editBase && !m ? (l.href = `${this._editBase}${e}${this._editSuffix}`, l.target = "_blank", l.rel = "noreferrer", l.classList.remove("hidden")) : (l.classList.add("hidden"), l.removeAttribute("href"), l.removeAttribute("target"), l.removeAttribute("rel"))), c.setAttribute("aria-label", m ? `Undo remove ${i.name}` : `Remove ${i.name}`), c.dataset.id = e, c.disabled = this.hasAttribute("disabled"), c.innerHTML = m ? '' : "×", c.addEventListener("click", (h) => { + h.stopPropagation(), this._handleDeleteSelectedItem(e); + }), r; } _renderSelectedItems() { if (!this.selectedItemsContainer) return; this.selectedItemsContainer.innerHTML = ""; - const t = this._displayOrder.filter( - (e) => this._value.includes(e) || this._removedIds.has(e) + const e = this._displayOrder.filter( + (i) => this._value.includes(i) || this._removedIds.has(i) ); - if (t.length === 0) { - const e = this.getAttribute("data-empty-text") || "Keine Auswahl...", i = this._inputCollapsed ? "" : "hidden"; - this.selectedItemsContainer.innerHTML = `${e}`; + if (e.length === 0) { + const i = this.getAttribute("data-empty-text") || "Keine Auswahl...", n = this._inputCollapsed ? "" : "hidden"; + this.selectedItemsContainer.innerHTML = `${i}`; } else - t.forEach((e) => { - const i = this._createSelectedItemElement(e); - i && this.selectedItemsContainer.appendChild(i); + e.forEach((i) => { + const n = this._createSelectedItemElement(i); + n && this.selectedItemsContainer.appendChild(n); }); this._updateRootElementStateClasses(); } - _createOptionElement(t, e) { - const n = this.optionTemplate.content.cloneNode(!0).firstElementChild, r = n.querySelector('[data-ref="nameEl"]'), a = n.querySelector('[data-ref="detailEl"]'); - r.textContent = this._normalizeText(t.name); - const o = this._normalizeText(t.additional_data); - a.textContent = o ? `(${o})` : "", n.dataset.id = t.id, n.setAttribute("aria-selected", String(e === this._highlightedIndex)); - const l = `option-${this.id || "mss"}-${t.id}`; - return n.id = l, e === this._highlightedIndex && (n.classList.add(or), this.inputElement && this.inputElement.setAttribute("aria-activedescendant", l)), n; + _createOptionElement(e, i) { + const r = this.optionTemplate.content.cloneNode(!0).firstElementChild, a = r.querySelector('[data-ref="nameEl"]'), o = r.querySelector('[data-ref="detailEl"]'); + a.textContent = this._normalizeText(e.name); + const l = this._normalizeText(e.additional_data); + o.textContent = l ? `(${l})` : "", r.dataset.id = e.id, r.setAttribute("aria-selected", String(i === this._highlightedIndex)); + const c = `option-${this.id || "mss"}-${e.id}`; + return r.id = c, i === this._highlightedIndex && (r.classList.add(yr), this.inputElement && this.inputElement.setAttribute("aria-activedescendant", c)), r; } _renderOptionsList() { if (!(!this.optionsListElement || !this.inputElement)) { if (this.optionsListElement.innerHTML = "", this.inputElement.removeAttribute("aria-activedescendant"), this._filteredOptions.length === 0 || !this._isOptionsListVisible) this.optionsListElement.classList.add("hidden"), this.inputElement.setAttribute("aria-expanded", "false"); else { - this.optionsListElement.classList.remove("hidden"), this.inputElement.setAttribute("aria-expanded", "true"), this._filteredOptions.forEach((e, i) => { - const n = this._createOptionElement(e, i); - this.optionsListElement.appendChild(n); + this.optionsListElement.classList.remove("hidden"), this.inputElement.setAttribute("aria-expanded", "true"), this._filteredOptions.forEach((i, n) => { + const r = this._createOptionElement(i, n); + this.optionsListElement.appendChild(r); }); - const t = this.optionsListElement.querySelector(`.${or}`); - t && (t.scrollIntoView({ block: "nearest" }), this.inputElement.setAttribute("aria-activedescendant", t.id)); + const e = this.optionsListElement.querySelector(`.${yr}`); + e && (e.scrollIntoView({ block: "nearest" }), this.inputElement.setAttribute("aria-activedescendant", e.id)); } this._updateRootElementStateClasses(); } } - _handleSelectedItemsContainerClick(t) { - t.target === this.selectedItemsContainer && this.inputElement && !this.inputElement.disabled && this.inputElement.focus(); + _handleSelectedItemsContainerClick(e) { + e.target === this.selectedItemsContainer && this.inputElement && !this.inputElement.disabled && this.inputElement.focus(); } _handleCreateNewButtonClick() { if (this.hasAttribute("disabled") || !this.showCreateButton) return; - const t = this.inputElement ? this.inputElement.value.trim() : ""; + const e = this.inputElement ? this.inputElement.value.trim() : ""; this.dispatchEvent( new CustomEvent("createnew", { - detail: { value: t }, + detail: { value: e }, bubbles: !0, composed: !0 }) ); } - _handleInput(t) { - const e = t.target.value; + _handleInput(e) { + const i = e.target.value; if (this._remoteEndpoint) { - this._handleRemoteInput(e); + this._handleRemoteInput(i); return; } - if (e.length === 0) + if (i.length === 0) this._filteredOptions = [], this._isOptionsListVisible = !1; else { - const i = e.toLowerCase(); - this._filteredOptions = this._options.filter((n) => { - if (this._value.includes(n.id)) return !1; - const a = this._normalizeText(n.name).toLowerCase().includes(i), o = this._normalizeText(n.additional_data), l = o && o.toLowerCase().includes(i); - return a || l; + const n = i.toLowerCase(); + this._filteredOptions = this._options.filter((r) => { + if (this._value.includes(r.id)) return !1; + const o = this._normalizeText(r.name).toLowerCase().includes(n), l = this._normalizeText(r.additional_data), c = l && l.toLowerCase().includes(n); + return o || c; }), this._isOptionsListVisible = this._filteredOptions.length > 0; } this._highlightedIndex = this._filteredOptions.length > 0 ? 0 : -1, this._renderOptionsList(); } - _handleKeyDown(t) { + _handleKeyDown(e) { if (!this.inputElement.disabled) { if (!this._isOptionsListVisible || this._filteredOptions.length === 0) { - t.key === "Enter" && this.inputElement.value.length > 0 && t.preventDefault(), t.key === "Escape" && this._hideOptionsList(), (t.key === "ArrowDown" || t.key === "ArrowUp") && this.inputElement.value.length > 0 && this._handleInput({ target: this.inputElement }); + e.key === "Enter" && this.inputElement.value.length > 0 && e.preventDefault(), e.key === "Escape" && this._hideOptionsList(), (e.key === "ArrowDown" || e.key === "ArrowUp") && this.inputElement.value.length > 0 && this._handleInput({ target: this.inputElement }); return; } - switch (t.key) { + switch (e.key) { case "ArrowDown": - t.preventDefault(), this._highlightedIndex = (this._highlightedIndex + 1) % this._filteredOptions.length, this._renderOptionsList(); + e.preventDefault(), this._highlightedIndex = (this._highlightedIndex + 1) % this._filteredOptions.length, this._renderOptionsList(); break; case "ArrowUp": - t.preventDefault(), this._highlightedIndex = (this._highlightedIndex - 1 + this._filteredOptions.length) % this._filteredOptions.length, this._renderOptionsList(); + e.preventDefault(), this._highlightedIndex = (this._highlightedIndex - 1 + this._filteredOptions.length) % this._filteredOptions.length, this._renderOptionsList(); break; case "Enter": - t.stopPropagation(), t.preventDefault(), this._highlightedIndex > -1 && this._filteredOptions[this._highlightedIndex] && this._selectItem(this._filteredOptions[this._highlightedIndex].id); + e.stopPropagation(), e.preventDefault(), this._highlightedIndex > -1 && this._filteredOptions[this._highlightedIndex] && this._selectItem(this._filteredOptions[this._highlightedIndex].id); break; case "Escape": - t.preventDefault(), this._hideOptionsList(), this._toggleInput && this._hideInputControls(); + e.preventDefault(), this._hideOptionsList(), this._toggleInput && this._hideInputControls(); break; case "Tab": this._hideOptionsList(); @@ -7243,43 +7267,42 @@ class Ed extends HTMLElement { this._isOptionsListVisible = !1, this._highlightedIndex = -1, this.optionsListElement && this._renderOptionsList(); } _handleFocus() { - this.inputElement.disabled || (this.inputWrapper && this.inputWrapper.classList.add(ir), this.inputElement.value.length > 0 && this._handleInput({ target: this.inputElement }), this._updateRootElementStateClasses()); + this.inputElement.disabled || (this.inputWrapper && this.inputWrapper.classList.add(pr), this.inputElement.value.length > 0 && this._handleInput({ target: this.inputElement }), this._updateRootElementStateClasses()); } - _blurTimeout = null; _handleBlur() { - this.inputWrapper && this.inputWrapper.classList.remove(ir), this._blurTimeout = setTimeout(() => { + this.inputWrapper && this.inputWrapper.classList.remove(pr), this._blurTimeout = setTimeout(() => { this.contains(document.activeElement) || (this._hideOptionsList(), this._toggleInput && (!this.inputElement || this.inputElement.value.trim() === "") && this._hideInputControls()); }, 150); } - _handleOptionMouseDown(t) { - t.preventDefault(); + _handleOptionMouseDown(e) { + e.preventDefault(); } - _handleOptionClick(t) { - const e = t.target.closest("li[data-id]"); - e && e.dataset.id && this._selectItem(e.dataset.id); + _handleOptionClick(e) { + const i = e.target.closest("li[data-id]"); + i && i.dataset.id && this._selectItem(i.dataset.id); } - _selectItem(t) { - t && !this._value.includes(t) && (this.value = [...this._value, t]), this.inputElement && (this.inputElement.value = ""), this._filteredOptions = [], this._hideOptionsList(), this._toggleInput ? this._hideInputControls() : this.inputElement && !this.hasAttribute("disabled") && this.inputElement.focus(); + _selectItem(e) { + e && !this._value.includes(e) && (this.value = [...this._value, e]), this.inputElement && (this.inputElement.value = ""), this._filteredOptions = [], this._hideOptionsList(), this._toggleInput ? this._hideInputControls() : this.inputElement && !this.hasAttribute("disabled") && this.inputElement.focus(); } - _handleDeleteSelectedItem(t) { - if (this._removedIds.has(t)) { - this._removedIds.delete(t), this._value.includes(t) ? this._renderSelectedItems() : this.value = [...this._value, t]; + _handleDeleteSelectedItem(e) { + if (this._removedIds.has(e)) { + this._removedIds.delete(e), this._value.includes(e) ? this._renderSelectedItems() : this.value = [...this._value, e]; return; } - if (this._initialValue.includes(t)) { - this._removedIds.add(t), this.value = this._value.filter((e) => e !== t); + if (this._initialValue.includes(e)) { + this._removedIds.add(e), this.value = this._value.filter((i) => i !== e); return; } - this.value = this._value.filter((e) => e !== t), this.inputElement && this.inputElement.value && this._handleInput({ target: this.inputElement }), this.inputElement && !this.hasAttribute("disabled") && this.inputElement.focus(); + this.value = this._value.filter((i) => i !== e), this.inputElement && this.inputElement.value && this._handleInput({ target: this.inputElement }), this.inputElement && !this.hasAttribute("disabled") && this.inputElement.focus(); } - _handleToggleClick(t) { - t.preventDefault(), this._showInputControls(); + _handleToggleClick(e) { + e.preventDefault(), this._showInputControls(); } _showInputControls() { if (this.inputControlsContainer) { if (this.inputControlsContainer.classList.remove("hidden"), this.toggleButton && this.toggleButton.classList.add("hidden"), this._value.length === 0 && this.selectedItemsContainer) { - const t = this.selectedItemsContainer.querySelector(`.${en}`); - t && t.classList.add("hidden"); + const e = this.selectedItemsContainer.querySelector(`.${mn}`); + e && e.classList.add("hidden"); } this.inputElement && !this.hasAttribute("disabled") && this.inputElement.focus(), this._inputCollapsed = !1; } @@ -7287,90 +7310,91 @@ class Ed extends HTMLElement { _hideInputControls() { if (this.inputControlsContainer) { if (this.inputControlsContainer.classList.add("hidden"), this.toggleButton && this.toggleButton.classList.remove("hidden"), this._value.length === 0 && this.selectedItemsContainer) { - const t = this.selectedItemsContainer.querySelector(`.${en}`); - t && t.classList.remove("hidden"); + const e = this.selectedItemsContainer.querySelector(`.${mn}`); + e && e.classList.remove("hidden"); } this._hideOptionsList(), this._inputCollapsed = !0; } } - _parsePositiveInt(t, e) { - if (!t) return e; - const i = parseInt(t, 10); - return Number.isNaN(i) || i <= 0 ? e : i; + _parsePositiveInt(e, i) { + if (!e) return i; + const n = parseInt(e, 10); + return Number.isNaN(n) || n <= 0 ? i : n; } - _handleRemoteInput(t) { - if (this._remoteFetchTimeout && clearTimeout(this._remoteFetchTimeout), t.length < this._remoteMinChars) { + _handleRemoteInput(e) { + if (this._remoteFetchTimeout && clearTimeout(this._remoteFetchTimeout), e.length < this._remoteMinChars) { this._filteredOptions = [], this._isOptionsListVisible = !1, this._renderOptionsList(); return; } this._remoteFetchTimeout = setTimeout(() => { - this._fetchRemoteOptions(t); - }, _d); + this._fetchRemoteOptions(e); + }, Md); } _cancelRemoteFetch() { this._remoteFetchController && (this._remoteFetchController.abort(), this._remoteFetchController = null); } - async _fetchRemoteOptions(t) { + async _fetchRemoteOptions(e) { if (!this._remoteEndpoint) return; - this._cancelRemoteFetch(), this.classList.add(lr); - const e = new AbortController(); - this._remoteFetchController = e; + this._cancelRemoteFetch(), this.classList.add(Ar); + const i = new AbortController(); + this._remoteFetchController = i; try { - const i = new URL(this._remoteEndpoint, window.location.origin); - i.searchParams.set("q", t), this._remoteLimit && i.searchParams.set("limit", String(this._remoteLimit)); - const n = await fetch(i.toString(), { + const n = new URL(this._remoteEndpoint, window.location.origin); + n.searchParams.set("q", e), this._remoteLimit && n.searchParams.set("limit", String(this._remoteLimit)); + const r = await fetch(n.toString(), { headers: { Accept: "application/json" }, - signal: e.signal, + signal: i.signal, credentials: "same-origin" }); - if (!n.ok) - throw new Error(`Remote fetch failed with status ${n.status}`); - const r = await n.json(); - if (e.signal.aborted) + if (!r.ok) + throw new Error(`Remote fetch failed with status ${r.status}`); + const a = await r.json(); + if (i.signal.aborted) return; - const a = this._extractRemoteOptions(r); - this._applyRemoteResults(a); - } catch (i) { - if (e.signal.aborted) + const o = this._extractRemoteOptions(a); + this._applyRemoteResults(o); + } catch (n) { + if (i.signal.aborted) return; - console.error("MultiSelectSimple remote fetch error:", i), this._filteredOptions = [], this._isOptionsListVisible = !1, this._renderOptionsList(); + console.error("MultiSelectSimple remote fetch error:", n), this._filteredOptions = [], this._isOptionsListVisible = !1, this._renderOptionsList(); } finally { - this._remoteFetchController === e && (this._remoteFetchController = null), this.classList.remove(lr); + this._remoteFetchController === i && (this._remoteFetchController = null), this.classList.remove(Ar); } } - _extractRemoteOptions(t) { - if (!t) return []; - let e = []; - return Array.isArray(t) ? e = t : this._remoteResultKey && Array.isArray(t[this._remoteResultKey]) ? e = t[this._remoteResultKey] : Array.isArray(t.items) && (e = t.items), e.map((i) => { - if (!i) return null; - const n = i.id ?? i.ID ?? i.value ?? "", r = i.name ?? i.title ?? i.label ?? "", a = i.detail ?? i.additional_data ?? i.annotation ?? "", o = this._normalizeText(r), l = this._normalizeText(a); - return !n || !o ? null : { - id: String(n), - name: o, - additional_data: l + _extractRemoteOptions(e) { + if (!e) return []; + let i = []; + return Array.isArray(e) ? i = e : this._remoteResultKey && Array.isArray(e[this._remoteResultKey]) ? i = e[this._remoteResultKey] : Array.isArray(e.items) && (i = e.items), i.map((n) => { + if (!n) return null; + const r = n.id ?? n.ID ?? n.value ?? "", a = n.name ?? n.title ?? n.label ?? "", o = n.detail ?? n.additional_data ?? n.annotation ?? "", l = this._normalizeText(a), c = this._normalizeText(o); + return !r || !l ? null : { + id: String(r), + name: l, + additional_data: c }; }).filter(Boolean); } - _applyRemoteResults(t) { - const e = new Set(this._value), i = /* @__PURE__ */ new Map(); - this._options.forEach((n) => { - n?.id && i.set(n.id, n); - }), t.forEach((n) => { - n?.id && i.set(n.id, n); - }), this._options = Array.from(i.values()), this._filteredOptions = t.filter((n) => n && !e.has(n.id)), this._isOptionsListVisible = this._filteredOptions.length > 0, this._highlightedIndex = this._isOptionsListVisible ? 0 : -1, this._renderOptionsList(); + _applyRemoteResults(e) { + const i = new Set(this._value), n = /* @__PURE__ */ new Map(); + this._options.forEach((r) => { + r != null && r.id && n.set(r.id, r); + }), e.forEach((r) => { + r != null && r.id && n.set(r.id, r); + }), this._options = Array.from(n.values()), this._filteredOptions = e.filter((r) => r && !i.has(r.id)), this._isOptionsListVisible = this._filteredOptions.length > 0, this._highlightedIndex = this._isOptionsListVisible ? 0 : -1, this._renderOptionsList(); } - _normalizeText(t) { - if (t == null) + _normalizeText(e) { + if (e == null) return ""; - let e = String(t).trim(); - if (!e) + let i = String(e).trim(); + if (!i) return ""; - const i = e[0], n = e[e.length - 1]; - return (i === '"' && n === '"' || i === "'" && n === "'") && (e = e.slice(1, -1).trim(), !e) ? "" : e; + const n = i[0], r = i[i.length - 1]; + return (n === '"' && r === '"' || n === "'" && r === "'") && (i = i.slice(1, -1).trim(), !i) ? "" : i; } } -const xd = "rbi-button", Sd = "rbi-icon"; -class Ld extends HTMLElement { +Xt($a, "formAssociated", !0); +const Hd = "rbi-button", qd = "rbi-icon"; +class $d extends HTMLElement { constructor() { super(), this.initialStates = /* @__PURE__ */ new Map(), this._controlledElements = [], this.button = null, this.lastOverallModifiedState = null, this.handleInputChange = this.handleInputChange.bind(this), this.handleReset = this.handleReset.bind(this); } @@ -7379,10 +7403,10 @@ class Ld extends HTMLElement { } connectedCallback() { const t = ` - `; @@ -7425,6 +7449,7 @@ class Ld extends HTMLElement { selectedOptions: Array.from(t.options).filter((i) => i.selected).map((i) => i.value) }; break; + case "select-one": default: e = { value: t.value }; break; @@ -7444,6 +7469,7 @@ class Ld extends HTMLElement { i.selected = e.selectedOptions.includes(i.value); }); break; + case "select-one": default: t.value = e.value; break; @@ -7470,6 +7496,7 @@ class Ld extends HTMLElement { case "select-multiple": const i = Array.from(t.options).filter((r) => r.selected).map((r) => r.value), n = e.selectedOptions; return i.length !== n.length || i.some((r) => !n.includes(r)) || n.some((r) => !i.includes(r)); + case "select-one": default: return t.value !== e.value; } @@ -7523,47 +7550,47 @@ class Ld extends HTMLElement { this.button.setAttribute("aria-label", t); } } -const it = "hidden", dr = "dm-stay", ze = "dm-title", rn = "dm-menu-button", Cd = "dm-target", wd = "data-dm-target", cr = "dm-menu", hr = "dm-menu-item", Td = "dm-close-button"; -class kd extends HTMLElement { +const it = "hidden", Er = "dm-stay", Ze = "dm-title", fn = "dm-menu-button", Ud = "dm-target", Vd = "data-dm-target", xr = "dm-menu", Sr = "dm-menu-item", jd = "dm-close-button"; +var hi, Ua; +class Wd extends HTMLElement { constructor() { - super(), this.#t(), this.boundHandleClickOutside = this.handleClickOutside.bind(this); - } - #t() { - this._cildren = [], this._rendered = [], this._target = null, this._button = null, this._menu = null, this._originalButtonText = null; + super(); + he(this, hi); + je(this, hi, Ua).call(this), this.boundHandleClickOutside = this.handleClickOutside.bind(this); } connectedCallback() { - this._target = document.getElementById(this.getAttribute(Cd)), this._target || (this._target = this), this._cildren = Array.from(this.children).filter((e) => e.nodeType === Node.ELEMENT_NODE && !e.classList.contains(rn)).map((e) => ({ - node: e, + this._target = document.getElementById(this.getAttribute(Ud)), this._target || (this._target = this), this._cildren = Array.from(this.children).filter((i) => i.nodeType === Node.ELEMENT_NODE && !i.classList.contains(fn)).map((i) => ({ + node: i, target: () => { - const i = e.getAttribute(wd); - return i ? document.getElementById(i) || this._target : this._target; + const n = i.getAttribute(Vd); + return n ? document.getElementById(n) || this._target : this._target; }, - stay: () => e.hasAttribute(dr) && e.getAttribute(dr) == "true", - hidden: () => e.classList.contains(it), + stay: () => i.hasAttribute(Er) && i.getAttribute(Er) == "true", + hidden: () => i.classList.contains(it), name: () => { - const i = e.querySelector("label"); - return i ? i.innerHTML : e.hasAttribute(ze) ? e.getAttribute(ze) : ""; + const n = i.querySelector("label"); + return n ? n.innerHTML : i.hasAttribute(Ze) ? i.getAttribute(Ze) : ""; }, nameText: () => { - const i = e.querySelector("label"); - return i ? i.textContent.trim() : e.hasAttribute(ze) ? e.getAttribute(ze) : ""; + const n = i.querySelector("label"); + return n ? n.textContent.trim() : i.hasAttribute(Ze) ? i.getAttribute(Ze) : ""; } })); - const t = this._button; - this._button = this.querySelector(`.${rn}`), !this._button && t && (this._button = t, this._button.parentElement || this.appendChild(this._button)), this._button || (this._button = document.createElement("button"), this._button.type = "button", this._button.classList.add(rn, it), this._button.innerHTML = ' Felder hinzufügen', this.appendChild(this._button)), this._originalButtonText || (this._originalButtonText = this._button.innerHTML); - for (const e of this._cildren) - this.removeChild(e.node); + const e = this._button; + this._button = this.querySelector(`.${fn}`), !this._button && e && (this._button = e, this._button.parentElement || this.appendChild(this._button)), this._button || (this._button = document.createElement("button"), this._button.type = "button", this._button.classList.add(fn, it), this._button.innerHTML = ' Felder hinzufügen', this.appendChild(this._button)), this._originalButtonText || (this._originalButtonText = this._button.innerHTML); + for (const i of this._cildren) + this.removeChild(i.node); this._button.addEventListener("click", this._toggleMenu.bind(this)), this._button.classList.add("relative"); - for (const e of this._cildren) - e.node.querySelectorAll(`.${Td}`).forEach((n) => { - n.addEventListener("click", (r) => { - this.hideDiv(r, e.node); + for (const i of this._cildren) + i.node.querySelectorAll(`.${jd}`).forEach((r) => { + r.addEventListener("click", (a) => { + this.hideDiv(a, i.node); }); }); this.renderIntoTarget(), this.refresh(), this._observer = new MutationObserver(() => { this.refresh(); - }), this._cildren.forEach((e) => { - this._observer.observe(e.node, { attributes: !0, attributeFilter: ["class"] }); + }), this._cildren.forEach((i) => { + this._observer.observe(i.node, { attributes: !0, attributeFilter: ["class"] }); }); } disconnectedCallback() { @@ -7572,22 +7599,22 @@ class kd extends HTMLElement { refresh() { this.renderButton(), this.renderMenu(), this.updateTargetVisibility(); } - _toggleMenu(t) { - t.preventDefault(), t.stopPropagation(); - const e = this._cildren.filter((i) => i.hidden()); - if (e.length === 1) { - const i = this._cildren.indexOf(e[0]); - this.showDiv(t, i); + _toggleMenu(e) { + e.preventDefault(), e.stopPropagation(); + const i = this._cildren.filter((n) => n.hidden()); + if (i.length === 1) { + const n = this._cildren.indexOf(i[0]); + this.showDiv(e, n); return; } - if (e.length === 0) { + if (i.length === 0) { this.hideMenu(); return; } this.renderMenu(), this._menu.classList.contains(it) ? (this._menu.classList.remove(it), document.addEventListener("click", this.boundHandleClickOutside)) : (this._menu.classList.add(it), document.removeEventListener("click", this.boundHandleClickOutside)); } - handleClickOutside(t) { - this._menu && !this._menu.contains(t.target) && !this._button.contains(t.target) && this.hideMenu(); + handleClickOutside(e) { + this._menu && !this._menu.contains(e.target) && !this._button.contains(e.target) && this.hideMenu(); } hideMenu() { this._menu && (this._menu.classList.add(it), document.removeEventListener("click", this.boundHandleClickOutside)); @@ -7596,125 +7623,129 @@ class kd extends HTMLElement { if (!this._button) return; this._originalButtonText || (this._originalButtonText = this._button.innerHTML); - const t = this._cildren.filter((e) => e.hidden()); - if (t.length === 0) { + const e = this._cildren.filter((i) => i.hidden()); + if (e.length === 0) { this._button.classList.add(it), this._button.parentElement && this._button.parentElement.removeChild(this._button), this._menu = null, this.hideMenu(); return; } - if (this._button.parentElement || this.appendChild(this._button), this._button.classList.remove(it), t.length === 1) { - const e = this._button.querySelector("i"), i = e ? e.outerHTML : ''; - this._button.innerHTML = `${i} -${t[0].nameText()} hinzufügen`, this._menu = null, this.hideMenu(); + if (this._button.parentElement || this.appendChild(this._button), this._button.classList.remove(it), e.length === 1) { + const i = this._button.querySelector("i"), n = i ? i.outerHTML : ''; + this._button.innerHTML = `${n} +${e[0].nameText()} hinzufügen`, this._menu = null, this.hideMenu(); } else this._button.innerHTML = this._originalButtonText, this._menu = null; } - hideDiv(t, e) { - if (t && (t.preventDefault(), t.stopPropagation()), !e || !(e instanceof HTMLElement)) { + hideDiv(e, i) { + if (e && (e.preventDefault(), e.stopPropagation()), !i || !(i instanceof HTMLElement)) { console.error("DivManagerMenu: Invalid node provided."); return; } - const i = this._cildren.find((r) => r.node === e); - if (!i) { + const n = this._cildren.find((a) => a.node === i); + if (!n) { console.error("DivManagerMenu: Child not found."); return; } - i.node.classList.add(it), this._clearFields(i.node); - const n = i.target(); - n && n.contains(i.node) && n.removeChild(i.node), i.node.parentElement || this.appendChild(i.node), this.renderButton(), this.renderMenu(), this.updateTargetVisibility(); + n.node.classList.add(it), this._clearFields(n.node); + const r = n.target(); + r && r.contains(n.node) && r.removeChild(n.node), n.node.parentElement || this.appendChild(n.node), this.renderButton(), this.renderMenu(), this.updateTargetVisibility(); } - showDiv(t, e) { - if (t && (t.preventDefault(), t.stopPropagation()), e < 0 || e >= this._cildren.length) { + showDiv(e, i) { + if (e && (e.preventDefault(), e.stopPropagation()), i < 0 || i >= this._cildren.length) { console.error("DivManagerMenu: Invalid index."); return; } - const i = this._cildren[e]; - if (i.node.classList.remove(it), this.insertChildInOrder(i), this.renderMenu(), this.renderButton(), this.updateTargetVisibility(), typeof window.TextareaAutoResize == "function") { - const n = i.node.querySelectorAll("textarea"); - n.length > 0 && setTimeout(() => { - n.forEach((r) => { - r.dataset.dmResizeBound !== "true" && (r.dataset.dmResizeBound = "true", r.addEventListener("input", () => { - window.TextareaAutoResize(r); - })), window.TextareaAutoResize(r); + const n = this._cildren[i]; + if (n.node.classList.remove(it), this.insertChildInOrder(n), this.renderMenu(), this.renderButton(), this.updateTargetVisibility(), typeof window.TextareaAutoResize == "function") { + const r = n.node.querySelectorAll("textarea"); + r.length > 0 && setTimeout(() => { + r.forEach((a) => { + a.dataset.dmResizeBound !== "true" && (a.dataset.dmResizeBound = "true", a.addEventListener("input", () => { + window.TextareaAutoResize(a); + })), window.TextareaAutoResize(a); }); }, 10); } requestAnimationFrame(() => { - this._focusFirstField(i.node); + this._focusFirstField(n.node); }); } renderMenu() { - const t = this._cildren.filter((i) => i.hidden()); - if (t.length <= 1) { + const e = this._cildren.filter((n) => n.hidden()); + if (e.length <= 1) { this.hideMenu(); return; } - (!this._menu || !this._button.contains(this._menu)) && (this._button.insertAdjacentHTML("beforeend", ``), this._menu = this._button.querySelector(`.${cr}`)), this._menu.innerHTML = `${t.map((i, n) => ` - `).join("")}`, this._menu.querySelectorAll(`.${hr}`).forEach((i) => { - i.addEventListener("click", (n) => { - this.showDiv(n, parseInt(i.getAttribute("dm-itemno"))), this.hideMenu(), this.renderButton(); + (!this._menu || !this._button.contains(this._menu)) && (this._button.insertAdjacentHTML("beforeend", ``), this._menu = this._button.querySelector(`.${xr}`)), this._menu.innerHTML = `${e.map((n, r) => ` + `).join("")}`, this._menu.querySelectorAll(`.${Sr}`).forEach((n) => { + n.addEventListener("click", (r) => { + this.showDiv(r, parseInt(n.getAttribute("dm-itemno"))), this.hideMenu(), this.renderButton(); }); }); } renderIntoTarget() { - this._cildren.forEach((t) => { - t.hidden() || this.insertChildInOrder(t); + this._cildren.forEach((e) => { + e.hidden() || this.insertChildInOrder(e); }), this.updateTargetVisibility(); } - insertChildInOrder(t) { - const e = t.target(), i = this._cildren.indexOf(t), n = this._cildren.slice(i + 1).filter((r) => r.target() === e).map((r) => r.node).find((r) => e && e.contains(r)); - e && (n ? e.insertBefore(t.node, n) : e.appendChild(t.node)); + insertChildInOrder(e) { + const i = e.target(), n = this._cildren.indexOf(e), r = this._cildren.slice(n + 1).filter((a) => a.target() === i).map((a) => a.node).find((a) => i && i.contains(a)); + i && (r ? i.insertBefore(e.node, r) : i.appendChild(e.node)); } updateTargetVisibility() { new Set( - this._cildren.map((e) => e.target()).filter((e) => e && e !== this) - ).forEach((e) => { - const i = Array.from(e.children).some( - (n) => !n.classList.contains(it) + this._cildren.map((i) => i.target()).filter((i) => i && i !== this) + ).forEach((i) => { + const n = Array.from(i.children).some( + (r) => !r.classList.contains(it) ); - e.classList.toggle(it, !i); + i.classList.toggle(it, !n); }); } - _clearFields(t) { - t && (t.querySelectorAll("input, textarea, select").forEach((e) => { - if (e.matches("input[type='checkbox'], input[type='radio']")) { - e.checked = !1; + _clearFields(e) { + e && (e.querySelectorAll("input, textarea, select").forEach((i) => { + if (i.matches("input[type='checkbox'], input[type='radio']")) { + i.checked = !1; return; } - if (e.matches("select")) { - e.selectedIndex = -1; + if (i.matches("select")) { + i.selectedIndex = -1; return; } - e.value = ""; - }), t.querySelectorAll("trix-editor").forEach((e) => { - typeof e.editor?.loadHTML == "function" && e.editor.loadHTML(""); + i.value = ""; + }), e.querySelectorAll("trix-editor").forEach((i) => { + var n; + typeof ((n = i.editor) == null ? void 0 : n.loadHTML) == "function" && i.editor.loadHTML(""); })); } - _focusFirstField(t) { - if (!t) + _focusFirstField(e) { + if (!e) return; - const e = t.querySelectorAll( + const i = e.querySelectorAll( "input:not([type='hidden']):not([disabled]), textarea:not([disabled]), select:not([disabled]), [contenteditable='true'], trix-editor" ); - for (const i of e) - if (i instanceof HTMLElement && i.getClientRects().length !== 0) { + for (const n of i) + if (n instanceof HTMLElement && n.getClientRects().length !== 0) { try { - i.focus({ preventScroll: !0 }); + n.focus({ preventScroll: !0 }); } catch { - i.focus(); + n.focus(); } return; } } } -const at = "items-row", Id = "items-list", Rd = "items-template", Dd = "items-add-button", Od = "items-cancel-button", Ke = "items-remove-button", Bd = "items-edit-button", Md = "items-close-button", Nd = "items-summary", Pd = "items-edit-panel", an = "items_removed[]", pe = "data-items-removed"; -class Fd extends HTMLElement { +hi = new WeakSet(), Ua = function() { + this._cildren = [], this._rendered = [], this._target = null, this._button = null, this._menu = null, this._originalButtonText = null; +}; +const at = "items-row", zd = "items-list", Kd = "items-template", Gd = "items-add-button", Jd = "items-cancel-button", ti = "items-remove-button", Yd = "items-edit-button", Xd = "items-close-button", Qd = "items-summary", Zd = "items-edit-panel", bn = "items_removed[]", ve = "data-items-removed"; +class tc extends HTMLElement { constructor() { super(), this._list = null, this._template = null, this._addButton = null, this._idPrefix = `items-editor-${crypto.randomUUID().slice(0, 8)}`, this._handleAdd = this._onAddClick.bind(this); } connectedCallback() { - if (this._list = this.querySelector(`.${Id}`), this._template = this.querySelector(`template.${Rd}`), this._addButton = this.querySelector(`.${Dd}`), !this._list || !this._template || !this._addButton) { + if (this._list = this.querySelector(`.${zd}`), this._template = this.querySelector(`template.${Kd}`), this._addButton = this.querySelector(`.${Gd}`), !this._list || !this._template || !this._addButton) { console.error("ItemsEditor: Missing list, template, or add button."); return; } @@ -7738,16 +7769,16 @@ class Fd extends HTMLElement { const e = t.closest(`.${at}`); if (!e) return; - const i = e.getAttribute(pe) === "true"; + const i = e.getAttribute(ve) === "true"; this._setRowRemoved(e, !i); } _wireRemoveButtons(t = this) { - t.querySelectorAll(`.${Ke}`).forEach((e) => { + t.querySelectorAll(`.${ti}`).forEach((e) => { e.dataset.itemsBound !== "true" && (e.dataset.itemsBound = "true", e.addEventListener("click", (i) => { i.preventDefault(), this.removeItem(e); }), e.addEventListener("mouseenter", () => { const i = e.closest(`.${at}`); - if (!i || i.getAttribute(pe) !== "true") + if (!i || i.getAttribute(ve) !== "true") return; const n = e.querySelector("[data-delete-label]"); n && (n.textContent = n.getAttribute("data-delete-hover") || "Rückgängig"); @@ -7757,14 +7788,14 @@ class Fd extends HTMLElement { const i = e.closest(`.${at}`), n = e.querySelector("[data-delete-label]"); if (!n) return; - i && i.getAttribute(pe) === "true" ? n.textContent = n.getAttribute("data-delete-active") || "Wird entfernt" : n.textContent = n.getAttribute("data-delete-default") || "Entfernen"; + i && i.getAttribute(ve) === "true" ? n.textContent = n.getAttribute("data-delete-active") || "Wird entfernt" : n.textContent = n.getAttribute("data-delete-default") || "Entfernen"; const r = e.querySelector("i"); - r && (i && i.getAttribute(pe) === "true" ? (r.classList.add("hidden"), r.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (r.classList.remove("hidden"), r.classList.add("ri-delete-bin-line"), r.classList.remove("ri-arrow-go-back-line"))); + r && (i && i.getAttribute(ve) === "true" ? (r.classList.add("hidden"), r.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (r.classList.remove("hidden"), r.classList.add("ri-delete-bin-line"), r.classList.remove("ri-arrow-go-back-line"))); })); }); } _wireCancelButtons(t = this) { - t.querySelectorAll(`.${Od}`).forEach((e) => { + t.querySelectorAll(`.${Jd}`).forEach((e) => { e.dataset.itemsBound !== "true" && (e.dataset.itemsBound = "true", e.addEventListener("click", (i) => { i.preventDefault(); const n = e.closest(`.${at}`); @@ -7773,13 +7804,13 @@ class Fd extends HTMLElement { }); } _wireEditButtons(t = this) { - t.querySelectorAll(`.${Bd}`).forEach((e) => { + t.querySelectorAll(`.${Yd}`).forEach((e) => { e.dataset.itemsBound !== "true" && (e.dataset.itemsBound = "true", e.addEventListener("click", (i) => { i.preventDefault(); const n = e.closest(`.${at}`); n && this._setRowMode(n, "edit"); })); - }), t.querySelectorAll(`.${Md}`).forEach((e) => { + }), t.querySelectorAll(`.${Xd}`).forEach((e) => { e.dataset.itemsBound !== "true" && (e.dataset.itemsBound = "true", e.addEventListener("click", (i) => { i.preventDefault(); const n = e.closest(`.${at}`); @@ -7796,14 +7827,14 @@ class Fd extends HTMLElement { this._resetToOriginal(t), this._setRowMode(t, "summary"); } _setRowRemoved(t, e) { - t.setAttribute(pe, e ? "true" : "false"), t.classList.toggle("bg-red-50", e); + t.setAttribute(ve, e ? "true" : "false"), t.classList.toggle("bg-red-50", e); const i = t.querySelector(".items-edit-button"); i && (e ? i.classList.add("hidden") : i.classList.remove("hidden")), t.querySelectorAll("[data-delete-label]").forEach((a) => { - const o = a.closest(`.${Ke}`), l = o && o.matches(":hover"); + const o = a.closest(`.${ti}`), l = o && o.matches(":hover"); let c; e && l ? c = a.getAttribute("data-delete-hover") || "Rückgängig" : e ? c = a.getAttribute("data-delete-active") || "Wird entfernt" : c = a.getAttribute("data-delete-default") || "Entfernen", a.textContent = c; - }), t.querySelectorAll(`.${Ke} i`).forEach((a) => { - const o = a.closest(`.${Ke}`), l = o && o.matches(":hover"); + }), t.querySelectorAll(`.${ti} i`).forEach((a) => { + const o = a.closest(`.${ti}`), l = o && o.matches(":hover"); e ? l ? (a.classList.remove("hidden"), a.classList.add("ri-arrow-go-back-line"), a.classList.remove("ri-delete-bin-line")) : (a.classList.add("hidden"), a.classList.remove("ri-delete-bin-line", "ri-arrow-go-back-line")) : (a.classList.remove("hidden"), a.classList.add("ri-delete-bin-line"), a.classList.remove("ri-arrow-go-back-line")); }); const n = t.querySelector('input[name="items_id[]"]'), r = n ? n.value.trim() : ""; @@ -7812,7 +7843,7 @@ class Fd extends HTMLElement { }); } _setRowMode(t, e) { - const i = t.querySelector(`.${Nd}`), n = t.querySelector(`.${Pd}`); + const i = t.querySelector(`.${Qd}`), n = t.querySelector(`.${Zd}`); !i || !n || (e === "edit" ? (i.classList.add("hidden"), n.classList.remove("hidden")) : (i.classList.remove("hidden"), n.classList.add("hidden"), this._syncSummary(t))); } _captureAllOriginals() { @@ -7892,23 +7923,23 @@ class Fd extends HTMLElement { return t instanceof HTMLInputElement || t instanceof HTMLTextAreaElement ? t.value.trim() : ""; } _ensureRemovalInput(t) { - if (Array.from(this.querySelectorAll(`input[name="${an}"]`)).some( + if (Array.from(this.querySelectorAll(`input[name="${bn}"]`)).some( (n) => n.value === t )) return; const i = document.createElement("input"); - i.type = "hidden", i.name = an, i.value = t, this.appendChild(i); + i.type = "hidden", i.name = bn, i.value = t, this.appendChild(i); } _removeRemovalInput(t) { - const e = Array.from(this.querySelectorAll(`input[name="${an}"]`)); + const e = Array.from(this.querySelectorAll(`input[name="${bn}"]`)); for (const i of e) i.value === t && i.remove(); } } -const Hd = "ssr-wrapper", ur = "ssr-input", mr = "ssr-list", qd = "ssr-option", $d = "ssr-option-name", Ud = "ssr-option-detail", Vd = "ssr-option-bio", gr = "ssr-hidden-input", pr = "ssr-clear-button", on = 1, ln = 10, jd = 250; -class Wd extends HTMLElement { +const ec = "ssr-wrapper", Lr = "ssr-input", Cr = "ssr-list", ic = "ssr-option", nc = "ssr-option-name", sc = "ssr-option-detail", rc = "ssr-option-bio", wr = "ssr-hidden-input", Tr = "ssr-clear-button", _n = 1, vn = 10, ac = 250; +class oc extends HTMLElement { constructor() { - super(), this._endpoint = "", this._resultKey = "items", this._minChars = on, this._limit = ln, this._placeholder = "Search...", this._options = [], this._selected = null, this._highlightedIndex = -1, this._fetchTimeout = null, this._fetchController = null, this._listVisible = !1, this._linkBase = "", this._linkTarget = "_blank", this._linkButton = null, this._showWarningIcon = !1, this._linkField = "id", this._boundHandleInput = this._handleInput.bind(this), this._boundHandleFocus = this._handleFocus.bind(this), this._boundHandleKeyDown = this._handleKeyDown.bind(this), this._boundHandleClear = this._handleClear.bind(this), this._boundHandleClickOutside = this._handleClickOutside.bind(this); + super(), this._endpoint = "", this._resultKey = "items", this._minChars = _n, this._limit = vn, this._placeholder = "Search...", this._options = [], this._selected = null, this._highlightedIndex = -1, this._fetchTimeout = null, this._fetchController = null, this._listVisible = !1, this._linkBase = "", this._linkTarget = "_blank", this._linkButton = null, this._showWarningIcon = !1, this._linkField = "id", this._boundHandleInput = this._handleInput.bind(this), this._boundHandleFocus = this._handleFocus.bind(this), this._boundHandleKeyDown = this._handleKeyDown.bind(this), this._boundHandleClear = this._handleClear.bind(this), this._boundHandleClickOutside = this._handleClickOutside.bind(this); } static get observedAttributes() { return [ @@ -7926,7 +7957,7 @@ class Wd extends HTMLElement { ]; } connectedCallback() { - this._render(), this._input = this.querySelector(`.${ur}`), this._list = this.querySelector(`.${mr}`), this._hiddenInput = this.querySelector(`.${gr}`), this._clearButton = this.querySelector(`.${pr}`), this._endpoint = this.getAttribute("data-endpoint") || "", this._resultKey = this.getAttribute("data-result-key") || "items", this._minChars = this._parsePositiveInt(this.getAttribute("data-minchars"), on), this._limit = this._parsePositiveInt(this.getAttribute("data-limit"), ln), this._placeholder = this.getAttribute("placeholder") || "Search..."; + this._render(), this._input = this.querySelector(`.${Lr}`), this._list = this.querySelector(`.${Cr}`), this._hiddenInput = this.querySelector(`.${wr}`), this._clearButton = this.querySelector(`.${Tr}`), this._endpoint = this.getAttribute("data-endpoint") || "", this._resultKey = this.getAttribute("data-result-key") || "items", this._minChars = this._parsePositiveInt(this.getAttribute("data-minchars"), _n), this._limit = this._parsePositiveInt(this.getAttribute("data-limit"), vn), this._placeholder = this.getAttribute("placeholder") || "Search..."; const t = this.getAttribute("data-initial-id") || "", e = this.getAttribute("data-initial-name") || "", i = this.getAttribute("data-initial-link-id") || ""; this._linkBase = this.getAttribute("data-link-base") || "", this._linkTarget = this.getAttribute("data-link-target") || "_blank", this._linkField = this.getAttribute("data-link-field") || "id", this._showWarningIcon = this.getAttribute("data-show-warning-icon") === "true", this._input && (this._input.placeholder = this._placeholder, this._input.addEventListener("input", this._boundHandleInput), this._input.addEventListener("focus", this._boundHandleFocus), this._input.addEventListener("keydown", this._boundHandleKeyDown)), this._linkButton = this.querySelector("[data-role='ssr-open-link']"), this._clearButton && this._clearButton.addEventListener("click", this._boundHandleClear), t && e && (this._selected = { id: t, name: e, linkId: i }, this._input && (this._input.value = e), this._syncHiddenInput()), this._updateLinkButton(), document.addEventListener("click", this._boundHandleClickOutside); } @@ -7934,7 +7965,7 @@ class Wd extends HTMLElement { document.removeEventListener("click", this._boundHandleClickOutside), this._input && (this._input.removeEventListener("input", this._boundHandleInput), this._input.removeEventListener("focus", this._boundHandleFocus), this._input.removeEventListener("keydown", this._boundHandleKeyDown)), this._clearButton && this._clearButton.removeEventListener("click", this._boundHandleClear); } attributeChangedCallback(t, e, i) { - e !== i && (t === "data-endpoint" && (this._endpoint = i || ""), t === "data-result-key" && (this._resultKey = i || "items"), t === "data-minchars" && (this._minChars = this._parsePositiveInt(i, on)), t === "data-limit" && (this._limit = this._parsePositiveInt(i, ln)), t === "placeholder" && (this._placeholder = i || "Search...", this._input && (this._input.placeholder = this._placeholder)), t === "name" && this._hiddenInput && (this._hiddenInput.name = i || ""), t === "data-link-base" && (this._linkBase = i || ""), t === "data-link-target" && (this._linkTarget = i || "_blank"), t === "data-link-field" && (this._linkField = i || "id"), t === "data-show-warning-icon" && (this._showWarningIcon = i === "true")); + e !== i && (t === "data-endpoint" && (this._endpoint = i || ""), t === "data-result-key" && (this._resultKey = i || "items"), t === "data-minchars" && (this._minChars = this._parsePositiveInt(i, _n)), t === "data-limit" && (this._limit = this._parsePositiveInt(i, vn)), t === "placeholder" && (this._placeholder = i || "Search...", this._input && (this._input.placeholder = this._placeholder)), t === "name" && this._hiddenInput && (this._hiddenInput.name = i || ""), t === "data-link-base" && (this._linkBase = i || ""), t === "data-link-target" && (this._linkTarget = i || "_blank"), t === "data-link-field" && (this._linkField = i || "id"), t === "data-show-warning-icon" && (this._showWarningIcon = i === "true")); } _handleInput(t) { const e = t.target.value.trim(); @@ -7985,27 +8016,28 @@ class Wd extends HTMLElement { _debouncedFetch(t) { this._fetchTimeout && clearTimeout(this._fetchTimeout), this._fetchTimeout = setTimeout(() => { this._fetchOptions(t); - }, jd); + }, ac); } async _fetchOptions(t) { + var i; if (!this._endpoint) return; this._fetchController && this._fetchController.abort(), this.dispatchEvent(new CustomEvent("ssrbeforefetch", { bubbles: !0 })), this._fetchController = new AbortController(); const e = new URL(this._endpoint, window.location.origin); e.searchParams.set("q", t), this._limit > 0 && e.searchParams.set("limit", String(this._limit)); try { - const i = await fetch(e.toString(), { signal: this._fetchController.signal }); - if (!i.ok) + const n = await fetch(e.toString(), { signal: this._fetchController.signal }); + if (!n.ok) return; - const n = await i.json(); - let a = (Array.isArray(n?.[this._resultKey]) ? n[this._resultKey] : []).filter((o) => o && o.id && o.name); + const r = await n.json(); + let o = (Array.isArray(r == null ? void 0 : r[this._resultKey]) ? r[this._resultKey] : []).filter((l) => l && l.id && l.name); if (this._excludeIds && Array.isArray(this._excludeIds)) { - const o = new Set(this._excludeIds); - a = a.filter((l) => !o.has(l.id)); + const l = new Set(this._excludeIds); + o = o.filter((c) => !l.has(c.id)); } - this._options = a, this._highlightedIndex = this._options.length > 0 ? 0 : -1, this._maybeAutoSelectExactMatch(t), this._renderOptions(), this._options.length > 0 ? this._options.length === 1 && this._isExactMatch(t, this._options[0]?.name || "") ? this._hideList() : this._showList() : this._hideList(); - } catch (i) { - if (i?.name === "AbortError") + this._options = o, this._highlightedIndex = this._options.length > 0 ? 0 : -1, this._maybeAutoSelectExactMatch(t), this._renderOptions(), this._options.length > 0 ? this._options.length === 1 && this._isExactMatch(t, ((i = this._options[0]) == null ? void 0 : i.name) || "") ? this._hideList() : this._showList() : this._hideList(); + } catch (n) { + if ((n == null ? void 0 : n.name) === "AbortError") return; } } @@ -8014,31 +8046,32 @@ class Wd extends HTMLElement { return i !== "" && i === n; } _maybeAutoSelectExactMatch(t) { + var n; if (!t) return; - const e = this._options.find((n) => this._isExactMatch(t, n?.name || "")); + const e = this._options.find((r) => this._isExactMatch(t, (r == null ? void 0 : r.name) || "")); if (!e) return; - const i = this._selected?.id || ""; + const i = ((n = this._selected) == null ? void 0 : n.id) || ""; this._selected = e, this._syncHiddenInput(), this._updateLinkButton(), e.id !== i && (this.dispatchEvent(new CustomEvent("ssrchange", { bubbles: !0, detail: { item: e } })), this.dispatchEvent(new Event("change", { bubbles: !0 }))); } _renderOptions() { this._list && (this._list.innerHTML = "", this._options.forEach((t) => { const e = document.createElement("button"); e.type = "button", e.setAttribute("data-index", String(this._options.indexOf(t))), e.className = [ - qd, + ic, "w-full text-left px-3 py-2 hover:bg-slate-100 transition-colors" ].join(" "); const n = this._options.indexOf(t) === this._highlightedIndex; e.classList.toggle("bg-slate-100", n), e.classList.toggle("text-gray-900", n), e.setAttribute("aria-selected", n ? "true" : "false"); const r = document.createElement("div"); - if (r.className = [$d, "text-sm font-semibold text-gray-800"].join(" "), r.textContent = t.name, e.appendChild(r), t.detail) { + if (r.className = [nc, "text-sm font-semibold text-gray-800"].join(" "), r.textContent = t.name, e.appendChild(r), t.detail) { const a = document.createElement("div"); - a.className = [Ud, "text-xs text-gray-600"].join(" "), a.textContent = t.detail, e.appendChild(a); + a.className = [sc, "text-xs text-gray-600"].join(" "), a.textContent = t.detail, e.appendChild(a); } if (t.bio) { const a = document.createElement("div"); - a.className = [Vd, "text-xs text-gray-500"].join(" "), a.textContent = t.bio, e.appendChild(a); + a.className = [rc, "text-xs text-gray-500"].join(" "), a.textContent = t.bio, e.appendChild(a); } e.addEventListener("click", () => { this._selectOption(t); @@ -8071,7 +8104,8 @@ class Wd extends HTMLElement { this._selected = t, this._input && (this._input.value = t.name || ""), this._syncHiddenInput(), this._updateLinkButton(), this._hideList(), this.dispatchEvent(new CustomEvent("ssrchange", { bubbles: !0, detail: { item: t } })), this.dispatchEvent(new Event("change", { bubbles: !0 })); } _syncHiddenInput() { - this._hiddenInput && (this._hiddenInput.value = this._selected?.id || ""); + var t; + this._hiddenInput && (this._hiddenInput.value = ((t = this._selected) == null ? void 0 : t.id) || ""); } _showList() { !this._list || this._listVisible || (this._list.classList.remove("hidden"), this._listVisible = !0); @@ -8086,11 +8120,11 @@ class Wd extends HTMLElement { _render() { const t = this.getAttribute("name") || ""; this.innerHTML = ` -
    +
    -
    - - + +
    `; } _updateLinkButton() { + var i, n, r; if (!this._linkButton) return; - const t = this._selected?.[this._linkField] || this._selected?.linkId || this._selected?.id, e = this._linkButton.querySelector("[data-role='ssr-open-link-icon']"); + const t = ((i = this._selected) == null ? void 0 : i[this._linkField]) || ((n = this._selected) == null ? void 0 : n.linkId) || ((r = this._selected) == null ? void 0 : r.id), e = this._linkButton.querySelector("[data-role='ssr-open-link-icon']"); if (!t || !this._linkBase) { this._showWarningIcon ? (this._linkButton.classList.remove("hidden"), this._linkButton.removeAttribute("href"), this._linkButton.classList.add("ssr-open-link-warning"), this._linkButton.setAttribute("aria-label", "Auswahl fehlt"), e && (e.className = "ri-error-warning-line")) : (this._linkButton.classList.add("hidden"), this._linkButton.removeAttribute("href")); return; @@ -8125,8 +8160,8 @@ class Wd extends HTMLElement { this._linkButton.classList.remove("hidden"), this._linkButton.classList.remove("ssr-open-link-warning"), this._linkButton.setAttribute("href", `${this._linkBase}${t}`), this._linkButton.setAttribute("aria-label", "Auswahl öffnen"), e && (e.className = "ri-external-link-line"); } } -const Ge = "Bevorzugter Reihentitel"; -class zd extends HTMLElement { +const ei = "Bevorzugter Reihentitel"; +class lc extends HTMLElement { constructor() { super(), this._pendingAgent = null, this._form = null, this._saveButton = null, this._resetButton = null, this._deleteButton = null, this._deleteDialog = null, this._deleteConfirmButton = null, this._deleteCancelButton = null, this._statusEl = null, this._saveEndpoint = "", this._deleteEndpoint = "", this._isSaving = !1, this._preferredSeriesRelationId = "", this._preferredSeriesSeriesId = "", this._handleSaveClick = this._handleSaveClick.bind(this), this._handleSaveViewClick = this._handleSaveViewClick.bind(this), this._handleResetClick = this._handleResetClick.bind(this), this._handleDeleteClick = this._handleDeleteClick.bind(this), this._handleDeleteConfirmClick = this._handleDeleteConfirmClick.bind(this), this._handleDeleteCancelClick = this._handleDeleteCancelClick.bind(this); } @@ -8165,6 +8200,7 @@ class zd extends HTMLElement { case "ToDo": t.classList.add("ri-list-check"); break; + case "Unknown": default: t.classList.add("ri-forbid-2-line"); break; @@ -8191,18 +8227,19 @@ class zd extends HTMLElement { } } _initPlaces() { + var i; const t = this.querySelector("#places"); if (!t) return; const e = () => { - const i = this._parseJSONAttr(t, "data-initial-options") || [], n = this._parseJSONAttr(t, "data-initial-values") || []; - i.length > 0 && typeof t.setOptions == "function" && t.setOptions(i), n.length > 0 && (t.value = n, typeof t.captureInitialSelection == "function" && t.captureInitialSelection()); + const n = this._parseJSONAttr(t, "data-initial-options") || [], r = this._parseJSONAttr(t, "data-initial-values") || []; + n.length > 0 && typeof t.setOptions == "function" && t.setOptions(n), r.length > 0 && (t.value = r, typeof t.captureInitialSelection == "function" && t.captureInitialSelection()); }; if (typeof t.setOptions == "function") { e(); return; } - typeof window.customElements?.whenDefined == "function" && window.customElements.whenDefined("multi-select-simple").then(() => { + typeof ((i = window.customElements) == null ? void 0 : i.whenDefined) == "function" && window.customElements.whenDefined("multi-select-simple").then(() => { requestAnimationFrame(() => e()); }); } @@ -8217,7 +8254,8 @@ class zd extends HTMLElement { this._saveButton && this._saveButton.removeEventListener("click", this._handleSaveClick), this._saveViewButton && this._saveViewButton.removeEventListener("click", this._handleSaveViewClick), this._resetButton && this._resetButton.removeEventListener("click", this._handleResetClick), this._deleteButton && this._deleteButton.removeEventListener("click", this._handleDeleteClick), this._deleteConfirmButton && this._deleteConfirmButton.removeEventListener("click", this._handleDeleteConfirmClick), this._deleteCancelButton && this._deleteCancelButton.removeEventListener("click", this._handleDeleteCancelClick), this._deleteDialog && this._deleteDialog.removeEventListener("cancel", this._handleDeleteCancelClick), this._saveButton = null, this._saveViewButton = null, this._resetButton = null, this._deleteButton = null, this._deleteDialog = null, this._deleteConfirmButton = null, this._deleteCancelButton = null, this._statusEl = null; } _deriveSaveEndpoint() { - return window?.location?.pathname ? `${window.location.pathname.endsWith("/") ? window.location.pathname.slice(0, -1) : window.location.pathname}/save` : "/almanach/save"; + var e; + return (e = window == null ? void 0 : window.location) != null && e.pathname ? `${window.location.pathname.endsWith("/") ? window.location.pathname.slice(0, -1) : window.location.pathname}/save` : "/almanach/save"; } async _handleSaveClick(t) { if (t.preventDefault(), this._isSaving) @@ -8248,10 +8286,10 @@ class zd extends HTMLElement { n = null; } if (!i.ok) { - const r = n?.error || `Speichern fehlgeschlagen (${i.status}).`; + const r = (n == null ? void 0 : n.error) || `Speichern fehlgeschlagen (${i.status}).`; throw new Error(r); } - await this._reloadForm(n?.message || "Änderungen gespeichert."); + await this._reloadForm((n == null ? void 0 : n.message) || "Änderungen gespeichert."); } catch (i) { this._showStatus(i instanceof Error ? i.message : "Speichern fehlgeschlagen.", "error"); } finally { @@ -8259,22 +8297,23 @@ class zd extends HTMLElement { } } async _handleSaveViewClick(t) { + var n; if (t.preventDefault(), this._isSaving) return; - const e = this._saveViewButton?.getAttribute("data-redirect-url"); + const e = (n = this._saveViewButton) == null ? void 0 : n.getAttribute("data-redirect-url"); if (!e) return; this._clearStatus(); let i; try { i = this._buildPayload(); - } catch (n) { - this._showStatus(n instanceof Error ? n.message : String(n), "error"); + } catch (r) { + this._showStatus(r instanceof Error ? r.message : String(r), "error"); return; } this._setSavingState(!0); try { - const n = await fetch(this._saveEndpoint, { + const r = await fetch(this._saveEndpoint, { method: "POST", credentials: "same-origin", headers: { @@ -8283,17 +8322,18 @@ class zd extends HTMLElement { }, body: JSON.stringify(i) }); - if (!n.ok) { - let r = `Speichern fehlgeschlagen (${n.status}).`; + if (!r.ok) { + let a = `Speichern fehlgeschlagen (${r.status}).`; try { - r = (await n.clone().json())?.error || r; + const o = await r.clone().json(); + a = (o == null ? void 0 : o.error) || a; } catch { } - throw new Error(r); + throw new Error(a); } window.location.assign(e); - } catch (n) { - this._showStatus(n instanceof Error ? n.message : "Speichern fehlgeschlagen.", "error"); + } catch (r) { + this._showStatus(r instanceof Error ? r.message : "Speichern fehlgeschlagen.", "error"); } finally { this._setSavingState(!1); } @@ -8336,10 +8376,10 @@ class zd extends HTMLElement { r = null; } if (!n.ok) { - const o = r?.error || `Löschen fehlgeschlagen (${n.status}).`; + const o = (r == null ? void 0 : r.error) || `Löschen fehlgeschlagen (${n.status}).`; throw new Error(o); } - const a = r?.redirect || "/suche/baende"; + const a = (r == null ? void 0 : r.redirect) || "/suche/baende"; window.location.assign(a); } catch (e) { this._showStatus(e instanceof Error ? e.message : "Löschen fehlgeschlagen.", "error"); @@ -8388,25 +8428,25 @@ class zd extends HTMLElement { if (!p) throw new Error("Reihentitel ist erforderlich."); const h = (E) => { - E.type = Ge, E.uncertain = !1; + E.type = ei, E.uncertain = !1; }; - let b = !1; + let f = !1; c.forEach((E) => { - E.target_id === p && (h(E), b = !0); + E.target_id === p && (h(E), f = !0); }), m.forEach((E) => { - E.target_id === p && (h(E), b = !0); - }), b || (this._preferredSeriesRelationId && this._preferredSeriesSeriesId === p ? c.push({ + E.target_id === p && (h(E), f = !0); + }), f || (this._preferredSeriesRelationId && this._preferredSeriesSeriesId === p ? c.push({ id: this._preferredSeriesRelationId, target_id: p, - type: Ge, + type: ei, uncertain: !1 }) : m.push({ target_id: p, - type: Ge, + type: ei, uncertain: !1 })), this._preferredSeriesRelationId && this._preferredSeriesSeriesId && this._preferredSeriesSeriesId !== p && !u.includes(this._preferredSeriesRelationId) && u.push(this._preferredSeriesRelationId); const A = [...c, ...m].filter( - (E) => E.type === Ge + (E) => E.type === ei ).length; if (A === 0) throw new Error("Mindestens ein bevorzugter Reihentitel muss verknüpft sein."); @@ -8414,12 +8454,12 @@ class zd extends HTMLElement { throw new Error("Es darf nur ein bevorzugter Reihentitel gesetzt sein."); const { relations: I, - deleted: q + deleted: $ } = this._collectRelations(t, { prefix: "entries_agents", targetField: "agent" }), R = this._collectNewRelations("entries_agents"), _ = [...c, ...m].map((E) => E.target_id); - if (_.filter((E, j) => _.indexOf(E) !== j).length > 0) + if (_.filter((E, z) => _.indexOf(E) !== z).length > 0) throw new Error("Doppelte Reihenverknüpfungen sind nicht erlaubt."); return { csrf_token: this._readValue(t, "csrf_token"), @@ -8434,7 +8474,7 @@ class zd extends HTMLElement { deleted_series_relation_ids: u, agent_relations: I, new_agent_relations: R, - deleted_agent_relation_ids: q + deleted_agent_relation_ids: $ }; } _collectItems(t) { @@ -8445,17 +8485,17 @@ class zd extends HTMLElement { const p = e[m] || ""; if (p && c.has(p)) continue; - const h = (i[m] || "").trim(), b = (n[m] || "").trim(), A = (r[m] || "").trim(), I = (o[m] || "").trim(), q = (l[m] || "").trim(), R = (a[m] || "").trim(); - if (p || h || b || A || I || q || R) { + const h = (i[m] || "").trim(), f = (n[m] || "").trim(), A = (r[m] || "").trim(), I = (o[m] || "").trim(), $ = (l[m] || "").trim(), R = (a[m] || "").trim(); + if (p || h || f || A || I || $ || R) { if (!R) throw new Error(`Exemplar ${m + 1}: "Vorhanden als" muss ausgefüllt werden.`); u.push({ id: p, owner: h, - identifier: b, + identifier: f, location: A, annotation: I, - uri: q, + uri: $, media: R ? [R] : [] }); } @@ -8470,8 +8510,8 @@ class zd extends HTMLElement { for (const [a, o] of t.entries()) { if (!a.startsWith(`${e}_id[`)) continue; - const l = a.slice(a.indexOf("[") + 1, -1), c = `${e}_${i}[${l}]`, u = `${e}_type[${l}]`, m = `${e}_delete[${l}]`, p = `${e}_uncertain[${l}]`, h = (o || "").trim(), b = (t.get(c) || "").trim(); - if (!b || !h) + const l = a.slice(a.indexOf("[") + 1, -1), c = `${e}_${i}[${l}]`, u = `${e}_type[${l}]`, m = `${e}_delete[${l}]`, p = `${e}_uncertain[${l}]`, h = (o || "").trim(), f = (t.get(c) || "").trim(); + if (!f || !h) continue; if (t.has(m)) { r.push(h); @@ -8480,7 +8520,7 @@ class zd extends HTMLElement { const A = (t.get(u) || "").trim(); n.push({ id: h, - target_id: b, + target_id: f, type: A, uncertain: t.has(p) }); @@ -8499,8 +8539,8 @@ class zd extends HTMLElement { const c = a.value.trim(); c && n.push({ target_id: c, - type: (o?.value || "").trim(), - uncertain: !!l?.checked + type: ((o == null ? void 0 : o.value) || "").trim(), + uncertain: !!(l != null && l.checked) }); }), n; } @@ -8558,8 +8598,8 @@ class zd extends HTMLElement { }, 100); } } -const Kd = "[data-role='relation-add-toggle']", Gd = "[data-role='relation-add-panel']", Jd = "[data-role='relation-add-close']", Yd = "[data-role='relation-add-apply']", Xd = "[data-role='relation-add-error']", Qd = "[data-role='relation-add-row']", Zd = "[data-role='relation-add-select']", tc = "[data-role='relation-type-select']", ec = "[data-role='relation-uncertain']", ic = "template[data-role='relation-new-template']", fr = "[data-role='relation-new-delete']", Yt = "[data-rel-row]"; -class nc extends HTMLElement { +const dc = "[data-role='relation-add-toggle']", cc = "[data-role='relation-add-panel']", hc = "[data-role='relation-add-close']", uc = "[data-role='relation-add-apply']", mc = "[data-role='relation-add-error']", gc = "[data-role='relation-add-row']", pc = "[data-role='relation-add-select']", fc = "[data-role='relation-type-select']", bc = "[data-role='relation-uncertain']", _c = "template[data-role='relation-new-template']", kr = "[data-role='relation-new-delete']", Qt = "[data-rel-row]"; +class vc extends HTMLElement { constructor() { super(), this._pendingItem = null, this._pendingApply = !1; } @@ -8583,11 +8623,11 @@ class nc extends HTMLElement { this._addPanel && !this._addPanel.classList.contains("hidden") || e || i ? this._emptyText.classList.add("hidden") : this._emptyText.classList.remove("hidden"); } _setupAddPanel() { - if (this._addToggle = this.querySelector(Kd), this._addToggleId) { + if (this._addToggle = this.querySelector(dc), this._addToggleId) { const t = document.getElementById(this._addToggleId); t && (this._addToggle = t); } - this._addPanel = this.querySelector(Gd), this._addClose = this.querySelector(Jd), this._addApply = this.querySelector(Yd), this._addError = this.querySelector(Xd), this._addRow = this.querySelector(Qd), this._addSelect = this.querySelector(Zd), this._typeSelect = this.querySelector(tc), this._uncertain = this.querySelector(ec), this._template = this.querySelector(ic), this._addInput = this._addSelect ? this._addSelect.querySelector(".ssr-input") : null, !(!this._addPanel || !this._addRow || !this._addSelect || !this._typeSelect || !this._uncertain || !this._template) && (this._addSelect && this._prefix === "entries_series" && this._addSelect.addEventListener("ssrbeforefetch", () => { + this._addPanel = this.querySelector(cc), this._addClose = this.querySelector(hc), this._addApply = this.querySelector(uc), this._addError = this.querySelector(mc), this._addRow = this.querySelector(gc), this._addSelect = this.querySelector(pc), this._typeSelect = this.querySelector(fc), this._uncertain = this.querySelector(bc), this._template = this.querySelector(_c), this._addInput = this._addSelect ? this._addSelect.querySelector(".ssr-input") : null, !(!this._addPanel || !this._addRow || !this._addSelect || !this._typeSelect || !this._uncertain || !this._template) && (this._addSelect && this._prefix === "entries_series" && this._addSelect.addEventListener("ssrbeforefetch", () => { this._addSelect._excludeIds = Array.from(this._getExistingIds()); }), this._addToggle && this._addToggle.addEventListener("click", () => { const t = this._addPanel.classList.contains("hidden"); @@ -8613,7 +8653,8 @@ class nc extends HTMLElement { this._addError && this._addError.classList.add("hidden"), this._insertNewRow(); } }), this._addSelect.addEventListener("ssrchange", (t) => { - this._pendingItem = t.detail?.item || null, this._pendingItem && this._addError && this._addError.classList.add("hidden"), this._pendingApply && this._pendingItem && this._addApply && (this._pendingApply = !1, this._addApply.click()); + var e; + this._pendingItem = ((e = t.detail) == null ? void 0 : e.item) || null, this._pendingItem && this._addError && this._addError.classList.add("hidden"), this._pendingApply && this._pendingItem && this._addApply && (this._pendingApply = !1, this._addApply.click()); })); } _clearAddPanel() { @@ -8624,7 +8665,7 @@ class nc extends HTMLElement { this._typeSelect && (this._typeSelect.selectedIndex = 0), this._uncertain && (this._uncertain.checked = !1), this._addError && this._addError.classList.add("hidden"); } _insertNewRow() { - const t = this._template.content.cloneNode(!0), e = t.querySelector(Yt) || t.firstElementChild; + const t = this._template.content.cloneNode(!0), e = t.querySelector(Qt) || t.firstElementChild; if (!e) return; const i = t.querySelector("[data-rel-link]"); @@ -8642,12 +8683,12 @@ class nc extends HTMLElement { u.checked = this._uncertain.checked, u.name = `${this._prefix}_new_uncertain`, u.value = this._pendingItem.id; const h = `${this._prefix}_new_uncertain_row`; u.id = h; - const b = t.querySelector("[data-rel-uncertain-label]"); - b && b.setAttribute("for", h); + const f = t.querySelector("[data-rel-uncertain-label]"); + f && f.setAttribute("for", h); } const m = t.querySelector("[data-rel-input='id']"); m && (m.name = `${this._prefix}_new_id`, m.value = this._pendingItem.id); - const p = t.querySelector(fr); + const p = t.querySelector(kr); p && p.addEventListener("click", () => { e.remove(), this._pendingItem = null, this._clearAddPanel(), this._addPanel && this._addPanel.classList.add("hidden"), this._updateEmptyTextVisibility(); }), this._addRow.appendChild(t), this._pendingItem = null, this._clearAddPanel(), this._addPanel && this._addPanel.classList.add("hidden"), this._updateEmptyTextVisibility(), this._updatePreferredOptions(); @@ -8659,7 +8700,7 @@ class nc extends HTMLElement { if (!i) return; i.checked = !i.checked; - const n = t.closest(Yt); + const n = t.closest(Qt); n && (n.classList.toggle("bg-red-50", i.checked), n.querySelectorAll("select, input[type='checkbox']").forEach((l) => { l !== i && (l.disabled = i.checked); })); @@ -8689,9 +8730,9 @@ class nc extends HTMLElement { }); } _setupNewRowDeletes() { - this._addRow && this._addRow.querySelectorAll(fr).forEach((t) => { + this._addRow && this._addRow.querySelectorAll(kr).forEach((t) => { t.dataset.relationNewBound !== "true" && (t.dataset.relationNewBound = "true", t.addEventListener("click", () => { - const e = t.closest(Yt); + const e = t.closest(Qt); e && e.remove(), this._pendingItem = null, this._clearAddPanel(), this._addPanel && this._addPanel.classList.add("hidden"), this._updateEmptyTextVisibility(), this._updatePreferredOptions(); })); }); @@ -8706,14 +8747,14 @@ class nc extends HTMLElement { return; const t = this._preferredLabel.trim(), e = []; this.querySelectorAll(`select[name^="${this._prefix}_type["]`).forEach((n) => { - e.push({ select: n, row: n.closest(Yt), isAddPanel: !1 }); + e.push({ select: n, row: n.closest(Qt), isAddPanel: !1 }); }), this._addRow && this._addRow.querySelectorAll(`select[name='${this._prefix}_new_type']`).forEach((n) => { - e.push({ select: n, row: n.closest(Yt), isAddPanel: !1 }); - }), this._typeSelect && e.push({ select: this._typeSelect, row: this._typeSelect.closest(Yt), isAddPanel: !0 }); + e.push({ select: n, row: n.closest(Qt), isAddPanel: !1 }); + }), this._typeSelect && e.push({ select: this._typeSelect, row: this._typeSelect.closest(Qt), isAddPanel: !0 }); const i = e.some(({ select: n, row: r, isAddPanel: a }) => { if (a) return !1; - const o = (n?.value || "").trim(); + const o = ((n == null ? void 0 : n.value) || "").trim(); if (!n || o !== t) return !1; if (!r) @@ -8729,7 +8770,7 @@ class nc extends HTMLElement { return; const l = r ? r.querySelector(`input[name^="${this._prefix}_delete["]`) : null, c = !!(l && l.checked), u = (n.value || "").trim(), m = !i || u === t && !c; if (a && i && u === t) { - const h = Array.from(n.options).find((b) => b.value.trim() !== t); + const h = Array.from(n.options).find((f) => f.value.trim() !== t); h && (n.value = h.value); } const p = !m || a && i; @@ -8737,7 +8778,7 @@ class nc extends HTMLElement { }); } } -class sc extends HTMLElement { +class yc extends HTMLElement { connectedCallback() { setTimeout(() => { const t = this.querySelector("form"); @@ -8747,10 +8788,11 @@ class sc extends HTMLElement { _setupStatusSelect() { const t = Array.from(this.querySelectorAll(".status-select")); t.length !== 0 && t.forEach((e) => { - const i = e.parentElement?.querySelector(".status-icon"); - e.addEventListener("change", (n) => { - const r = n.target.value; - e.setAttribute("data-status", r), i && this._updateStatusIcon(i, r); + var n; + const i = (n = e.parentElement) == null ? void 0 : n.querySelector(".status-icon"); + e.addEventListener("change", (r) => { + const a = r.target.value; + e.setAttribute("data-status", a), i && this._updateStatusIcon(i, a); }); }); } @@ -8774,6 +8816,7 @@ class sc extends HTMLElement { case "ToDo": t.classList.add("ri-list-check"); break; + case "Unknown": default: t.classList.add("ri-forbid-2-line"); break; @@ -8810,38 +8853,39 @@ class sc extends HTMLElement { }); if (!m.ok) return; - const h = (await m.json().catch(() => null))?.redirect || "/"; + const p = await m.json().catch(() => null), h = (p == null ? void 0 : p.redirect) || "/"; window.location.assign(h); }); } } -class rc extends HTMLElement { +class Ac extends HTMLElement { constructor() { super(), this.state = null, this.handleClick = this.handleClick.bind(this), this.handleClickAway = this.handleClickAway.bind(this); } connectedCallback() { + var oe, M; const t = this.getAttribute("data-user-name") || "Benutzer", e = this.getAttribute("data-user-email") || "", i = this.getAttribute("data-user-id") || "", n = this.getAttribute("data-is-admin-or-editor") === "true", r = this.getAttribute("data-is-admin") === "true", a = this.getAttribute("data-redirect-path") || "", o = window.location.pathname; - let l = !1, c = "", u = !1, m = "", p = !1, h = !1, b = !1, A = "", I = !1, q = "", R = "", $ = !1, _ = ""; + let l = !1, c = "", u = !1, m = "", p = !1, h = !1, f = !1, A = "", I = !1, $ = "", R = "", U = !1, _ = ""; const S = o.match(/^\/reihe\/([^\/]+)\/?$/); if (S && S[1] !== "new") { l = !0, c = S[1]; - const F = document.querySelector('meta[name="entity-updated"]'); - F && F.content; + const H = document.querySelector('meta[name="entity-updated"]'); + H && H.content; } const E = o.match(/^\/person\/([^\/]+)\/?$/); E && E[1] !== "new" && (u = !0, m = E[1]); - const j = o.match(/^\/almanach\/([^\/]+)\/?$/); - if (j && j[1] !== "new") { - b = !0, A = j[1]; - const F = document.querySelector('meta[name="entity-updated"]'); - F && F.content; + const z = o.match(/^\/almanach\/([^\/]+)\/?$/); + if (z && z[1] !== "new") { + f = !0, A = z[1]; + const H = document.querySelector('meta[name="entity-updated"]'); + H && H.content; } const ct = o.match(/^\/beitrag\/([^\/]+)\/?$/); if (ct) { - I = !0, q = ct[1]; - const F = document.querySelector('#breadcrumbs a[href^="/almanach/"]'); - if (F) { - const D = F.getAttribute("href")?.match(/^\/almanach\/([^\/#]+)/); + I = !0, $ = ct[1]; + const H = document.querySelector('#breadcrumbs a[href^="/almanach/"]'); + if (H) { + const D = (oe = H.getAttribute("href")) == null ? void 0 : oe.match(/^\/almanach\/([^\/#]+)/); D && (R = D[1]); } } @@ -8854,16 +8898,16 @@ class rc extends HTMLElement { "lesekabinett", "reihen", "index" - ]), mt = o.replace(/\/+$/, "") || "/", li = (F) => !F || !wt.has(F) ? !1 : F === "index" ? mt === "/" || mt === "/index" : mt === `/${F}` || mt === `/redaktion/${F}`, Tt = document.querySelector('meta[name="page-key"]')?.content?.trim(); - if (Tt && li(Tt)) - $ = !0, _ = Tt; + ]), mt = o.replace(/\/+$/, "") || "/", bi = (H) => !H || !wt.has(H) ? !1 : H === "index" ? mt === "/" || mt === "/index" : mt === `/${H}` || mt === `/redaktion/${H}`, V = document.querySelector('meta[name="page-key"]'), Tt = (M = V == null ? void 0 : V.content) == null ? void 0 : M.trim(); + if (Tt && bi(Tt)) + U = !0, _ = Tt; else { - const F = mt.match(/^\/redaktion\/([^\/]+)$/), D = F ? F[1] : ""; - D && wt.has(D) ? ($ = !0, _ = D) : (mt === "/" || mt === "/index") && ($ = !0, _ = "index"); + const H = mt.match(/^\/redaktion\/([^\/]+)$/), D = H ? H[1] : ""; + D && wt.has(D) ? (U = !0, _ = D) : (mt === "/" || mt === "/index") && (U = !0, _ = "index"); } (o === "/reihen" || o === "/reihen/") && (p = !0), (o === "/personen" || o === "/personen/") && (h = !0); - const Vt = document.querySelector('input[name="csrf_token"]'); - Vt && Vt.value, this.hasContext = l || u || b || I || $ || p || h; + const jt = document.querySelector('input[name="csrf_token"]'); + jt && jt.value, this.hasContext = l || u || f || I || U || p || h; let tt = ""; n && l ? tt = `
    @@ -8881,7 +8925,7 @@ class rc extends HTMLElement { Bearbeiten - ` : n && b ? tt = ` + ` : n && f ? tt = `
    Almanach
    @@ -8901,7 +8945,7 @@ class rc extends HTMLElement {
    Beitrag
    - + Bearbeiten @@ -8929,7 +8973,7 @@ class rc extends HTMLElement { Neue Person - ` : n && $ && (tt = ` + ` : n && U && (tt = `
    Seite
    @@ -8938,7 +8982,7 @@ class rc extends HTMLElement { Seite bearbeiten `); - const di = n ? ` + const _i = n ? `
    Erstellen
    @@ -8979,7 +9023,7 @@ class rc extends HTMLElement {
    - ` : "", ci = n ? ` + ` : "", vi = n ? `
    Listen
    @@ -9038,10 +9082,19 @@ class rc extends HTMLElement {
    - ` : "", hi = r ? ` + ` : "", yi = r ? `
    Administration
    +
    - ` : "", Ie = tt || "", ui = tt ? '
    ' : ""; + ` : "", Me = tt || "", Ai = tt ? '
    ' : ""; this.innerHTML = `