Repository: gbarillot/rails-vue-demo-app
Branch: main
Commit: 04ab3db3253c
Files: 162
Total size: 342.8 KB
Directory structure:
gitextract_56eg6khq/
├── .browserslistrc
├── .gitignore
├── .tool-versions
├── Gemfile
├── Procfile
├── README.md
├── Rakefile
├── app/
│ ├── assets/
│ │ ├── config/
│ │ │ └── manifest.js
│ │ ├── images/
│ │ │ └── .keep
│ │ └── stylesheets/
│ │ └── application.css
│ ├── channels/
│ │ ├── application_cable/
│ │ │ ├── channel.rb
│ │ │ └── connection.rb
│ │ └── chat_channel.rb
│ ├── controllers/
│ │ ├── admin_controller.rb
│ │ ├── api/
│ │ │ ├── admin/
│ │ │ │ ├── admin_controller.rb
│ │ │ │ ├── dashboard_controller.rb
│ │ │ │ └── musicians_controller.rb
│ │ │ ├── api_controller.rb
│ │ │ └── musicians_controller.rb
│ │ ├── application_controller.rb
│ │ └── concerns/
│ │ └── .keep
│ ├── helpers/
│ │ └── application_helper.rb
│ ├── javascript/
│ │ ├── admin/
│ │ │ ├── routes.js
│ │ │ ├── stores/
│ │ │ │ ├── dashboard_store.js
│ │ │ │ └── musician_store.js
│ │ │ └── views/
│ │ │ ├── dashboard/
│ │ │ │ └── index.vue
│ │ │ ├── musicians/
│ │ │ │ ├── _filters.vue
│ │ │ │ ├── _form.vue
│ │ │ │ ├── edit.vue
│ │ │ │ ├── index.vue
│ │ │ │ └── new.vue
│ │ │ ├── shared/
│ │ │ │ ├── _errors.vue
│ │ │ │ ├── _footer.vue
│ │ │ │ ├── _nav.vue
│ │ │ │ ├── _pagination.vue
│ │ │ │ └── layout.vue
│ │ │ └── websockets/
│ │ │ └── index.vue
│ │ ├── entrypoints/
│ │ │ ├── admin.js
│ │ │ └── front.js
│ │ ├── front/
│ │ │ ├── routes.js
│ │ │ ├── stores/
│ │ │ │ └── musician_store.js
│ │ │ └── views/
│ │ │ ├── musicians/
│ │ │ │ ├── index.vue
│ │ │ │ └── show.vue
│ │ │ ├── pages/
│ │ │ │ └── index.vue
│ │ │ └── shared/
│ │ │ ├── _footer.vue
│ │ │ ├── _nav.vue
│ │ │ └── layout.vue
│ │ └── plugins/
│ │ ├── api.js
│ │ └── cable.js
│ ├── jobs/
│ │ └── application_job.rb
│ ├── mailers/
│ │ └── application_mailer.rb
│ ├── models/
│ │ ├── application_record.rb
│ │ ├── concerns/
│ │ │ └── .keep
│ │ ├── musician.rb
│ │ └── user.rb
│ └── views/
│ ├── admin.html.erb
│ ├── api/
│ │ ├── admin/
│ │ │ ├── musicians/
│ │ │ │ ├── edit.json.jbuilder
│ │ │ │ ├── index.json.jbuilder
│ │ │ │ └── new.json.jbuilder
│ │ │ ├── shared/
│ │ │ │ └── _pagination.json.jbuilder
│ │ │ └── users/
│ │ │ ├── edit.json.jbuilder
│ │ │ ├── index.json.jbuilder
│ │ │ └── new.json.jbuilder
│ │ └── musicians/
│ │ ├── index.json.jbuilder
│ │ └── show.json.jbuilder
│ ├── application.html.erb
│ ├── devise/
│ │ └── sessions/
│ │ └── new.html.erb
│ └── layouts/
│ ├── devise.html.erb
│ ├── mailer.html.erb
│ └── mailer.text.erb
├── bin/
│ ├── bootsnap
│ ├── bundle
│ ├── foreman
│ ├── importmap
│ ├── irb
│ ├── nokogiri
│ ├── puma
│ ├── pumactl
│ ├── racc
│ ├── rackup
│ ├── rails
│ ├── rake
│ ├── rdbg
│ ├── setup
│ ├── spring
│ ├── sprockets
│ ├── thor
│ ├── tilt
│ └── vite
├── config/
│ ├── application.rb
│ ├── boot.rb
│ ├── cable.yml
│ ├── credentials.yml.enc
│ ├── database.yml
│ ├── environment.rb
│ ├── environments/
│ │ ├── development.rb
│ │ ├── production.rb
│ │ └── test.rb
│ ├── importmap.rb
│ ├── initializers/
│ │ ├── assets.rb
│ │ ├── content_security_policy.rb
│ │ ├── cypress_rails_initializer.rb
│ │ ├── devise.rb
│ │ ├── filter_parameter_logging.rb
│ │ ├── inflections.rb
│ │ ├── locales.rb
│ │ ├── new_framework_defaults_7_1.rb
│ │ └── permissions_policy.rb
│ ├── locales/
│ │ ├── devise.en.yml
│ │ ├── en.yml
│ │ └── fr.yml
│ ├── puma.rb
│ ├── routes.rb
│ ├── storage.yml
│ └── vite.json
├── config.ru
├── cypress/
│ ├── e2e/
│ │ └── home.cy.js
│ └── support/
│ └── e2e.js
├── cypress.config.js
├── db/
│ ├── migrate/
│ │ ├── 20220424120800_base_setup.rb
│ │ ├── 20240102193807_add_service_name_to_active_storage_blobs.active_storage.rb
│ │ ├── 20240102193808_create_active_storage_variant_records.active_storage.rb
│ │ └── 20240102193809_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb
│ ├── schema.rb
│ └── seeds.rb
├── docker-compose.yml
├── lib/
│ ├── assets/
│ │ └── .keep
│ └── tasks/
│ └── .keep
├── log/
│ └── .keep
├── package.json
├── public/
│ ├── 404.html
│ ├── 422.html
│ ├── 500.html
│ ├── css/
│ │ └── development/
│ │ ├── admin/
│ │ │ └── forms.css
│ │ ├── admin.css
│ │ ├── devise.css
│ │ ├── front.css
│ │ ├── grid.css
│ │ ├── main.css
│ │ ├── themes/
│ │ │ ├── dark.css
│ │ │ └── light.css
│ │ └── utilities.css
│ ├── robots.txt
│ └── vite-test/
│ ├── assets/
│ │ ├── admin-ebb17751.js
│ │ ├── front-f6acb49a.js
│ │ └── vue-i18n-6b73e0ca.js
│ ├── manifest-assets.json
│ └── manifest.json
├── storage/
│ └── .keep
├── test/
│ ├── application_system_test_case.rb
│ ├── controllers/
│ │ └── .keep
│ ├── fixtures/
│ │ └── files/
│ │ └── .keep
│ ├── helpers/
│ │ └── .keep
│ ├── javascript/
│ │ └── app.test.js
│ ├── mailers/
│ │ └── .keep
│ ├── models/
│ │ └── .keep
│ ├── system/
│ │ └── .keep
│ └── test_helper.rb
├── tmp/
│ └── .keep
├── vendor/
│ ├── .keep
│ └── javascript/
│ └── .keep
└── vite.config.ts
================================================
FILE CONTENTS
================================================
================================================
FILE: .browserslistrc
================================================
defaults
================================================
FILE: .gitignore
================================================
# See https://help.github.com/articles/ignoring-files for more about ignoring files.
#
# If you find yourself ignoring temporary files generated by your text editor
# or operating system, you probably want to add a global ignore instead:
# git config --global core.excludesfile '~/.gitignore_global'
# Ignore bundler config.
/.bundle
# Ignore the default SQLite database.
/db/*.sqlite3
/db/*.sqlite3-journal
/db/*.sqlite3-*
# Ignore all logfiles and tempfiles.
/log/*
/tmp/*
!/log/.keep
!/tmp/.keep
# Ignore uploaded files in development.
/storage/*
!/storage/.keep
/public/assets
.byebug_history
# Ignore master key for decrypting credentials and more.
/config/master.key
# Ignore Redis dump
/dump.rdb
/public/packs
/public/packs-test
/node_modules
/yarn-error.log
yarn-debug.log*
.yarn-integrity
================================================
FILE: .tool-versions
================================================
ruby 3.2.2
nodejs 20.2.0
================================================
FILE: Gemfile
================================================
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Bundle edge Rails instead: gem "rails", github: "rails/rails", branch: "main"
gem "rails", "~> 7.1.2"
gem 'sprockets-rails'
gem 'sqlite3'
gem 'puma'
gem 'jbuilder'
gem 'redis'
gem 'bootsnap', require: false
gem 'vite_rails'
gem 'foreman'
gem 'route_translator'
gem 'kaminari'
gem 'ransack'
gem 'devise'
gem 'cypress-rails'
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem "tzinfo-data", platforms: %i[ mingw mswin x64_mingw jruby ]
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem "debug", platforms: %i[ mri mingw x64_mingw ]
end
group :development do
# Use console on exceptions pages [https://github.com/rails/web-console]
gem "web-console"
end
group :test do
gem 'capybara'
gem 'minitest'
gem 'minitest-rails'
gem 'minitest-spec-rails'
gem 'minitest-focus'
gem 'capybara-email'
gem 'json-schema'
gem 'warden'
gem 'selenium-webdriver'
gem 'webdrivers'
end
================================================
FILE: Procfile
================================================
vite: bin/vite dev
web: bin/rails s --port 3000 -b 0.0.0.0
================================================
FILE: README.md
================================================
# Rails + Vite + Vue + Pina Demo App
### This repo is no longer maintained
Feel free to grab some ideas, but I will no longer update this codebase.
## Description
Demo Single Page Application based on Ruby on Rails 7.0.2, using Vue 3 + Pina, compiled with Vite.
All the basic features you need to build a real world app with:
- **Front / Admin namespaces**
- **I18n** (server side + client side)
- **Forms** (with progress and error handling)
- **Authentication** (Devise)
- **Pagination** (Kaminari)
- **Dynamic search filters** (Ransack)
- **Websockets** (ActionCable)
- **Bootstrap like grid** (using CSS Grid layout)
All of this is designed with maintainability and readability in mind, slightly inspired by the Rails conventions.
This is the follow up of the previous Rails + Vue + Vuex app from 2017 which is still
available on the Rails6 branch.
A lot of things has been updated/rewrote for this version, notably:
- Webpacker is now replaced by Vite
- Vue app in using Composition API
- Vuex is now replaced by Pinia to handle state management
- No longer depends on JQuery for API calls (replaced by Axios)
Nonetheless, a lot of opinions and conventions from the previous version remain valid, you may have a look at the original blog post for details (https://guillaume.barillot.me/2017/12/02/how-to-organize-your-vue-files-in-a-rails-5-1-project-using-webpack/).
Boostrapping the plumbing for basic stuff can take some time, but once you get the basic it's
pretty easy to extend and to get really efficient with Vue + Rails. With this example you have
all you need to build up your new project in minutes.
## Installation
```
git clone git@github.com:gbarillot/rails-vue-demo-app.git
cd rails-vue-demo-app
bundle install
yarn install
bundle exec rails db:migrate
bundle exec rails db:seed
```
## Booting the app
```
foreman start
```
Hot Module Reloading (HMR) is enabled by default. If you prefer to turn it off, set "hmr" to false
in /vite.config.ts.
## Running tests
### Rails side
```
rails test
```
### JS side
```
yarn test
```
## A note on CSS
CSS is done right in the public/css/development directory.
Pros:
- No compile time, greatly speed up page load time in dev
- Allows CSS editing + saving directly from Chrome Devtools
- Easier / more fexible to manage imports
Cons:
- You should disable cache in DevTools in Dev
- As of today, not suitable for production!
The purpose of this repo is Vue + Vite + Rails, not CSS, so feel free to use whatever method
you'd prefer to handle CSS. Sprocket is left as is and still works.
## Contributions
PR and feedbacks welcome!
## Licence
MIT
================================================
FILE: Rakefile
================================================
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require_relative "config/application"
Rails.application.load_tasks
================================================
FILE: app/assets/config/manifest.js
================================================
//= link_tree ../images
//= link_directory ../stylesheets .css
//= link_tree ../../javascript .js
//= link_tree ../../../vendor/javascript .js
================================================
FILE: app/assets/images/.keep
================================================
================================================
FILE: app/assets/stylesheets/application.css
================================================
/*
* This is a manifest file that'll be compiled into application.css, which will include all the files
* listed below.
*
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's
* vendor/assets/stylesheets directory can be referenced here using a relative path.
*
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
* files in this directory. Styles in this file should be added after the last require_* statement.
* It is generally better to create a new file per style scope.
*
*= require_self
*/
================================================
FILE: app/channels/application_cable/channel.rb
================================================
module ApplicationCable
class Channel < ActionCable::Channel::Base
end
end
================================================
FILE: app/channels/application_cable/connection.rb
================================================
module ApplicationCable
class Connection < ActionCable::Connection::Base
end
end
================================================
FILE: app/channels/chat_channel.rb
================================================
class ChatChannel < ApplicationCable::Channel
def subscribed
stream_from "ChatChannel"
end
def receive(data)
ActionCable.server.broadcast("ChatChannel", {
message: data['message'].upcase
})
end
end
================================================
FILE: app/controllers/admin_controller.rb
================================================
class AdminController < ApplicationController
before_action :auth_user!
def index
render template: 'admin'
end
private
# Proper redirect using I18n.locale
# Devise's authenticate_user! doesn't handle I18n properly here
def auth_user!
redirect_to new_user_session_path unless current_user
end
end
================================================
FILE: app/controllers/api/admin/admin_controller.rb
================================================
class Api::Admin::AdminController < Api::ApiController
before_action :authenticate_user!
def search_params
params[:q] ||= {} if params[:q] != ''
end
end
================================================
FILE: app/controllers/api/admin/dashboard_controller.rb
================================================
class Api::Admin::DashboardController < Api::Admin::AdminController
def index
render json: {metrics: {musicians: Musician.count}}
end
end
================================================
FILE: app/controllers/api/admin/musicians_controller.rb
================================================
class Api::Admin::MusiciansController < Api::Admin::AdminController
# DELETE ME: Dummy emulation of a slow network so you can see the UI animation in dev. mode
before_action :slow, only: [:create, :update]
before_action :load_musician, except: [:index, :new, :create]
def index
@musicians = Musician.ransack(search_params)
.result
.page(params[:page])
.per(params[:per_page])
end
def new
@musician = Musician.new
end
def create
@musician = Musician.create(musician_params)
if @musician.errors.empty?
render template: '/api/admin/musicians/edit'
else
render json: {errors: @musician.errors.messages}.to_json, status: 422
end
end
def edit
end
def update
if @musician.update(musician_params)
head :ok
else
render json: {errors: @musician.errors.messages}.to_json, status: 422
end
end
def destroy
if @musician.destroy
head :ok
else
render json: {errors: @musician.errors.messages}.to_json, status: 422
end
end
private
def musician_params
params.require(:musician).permit(
:name,
:band
)
end
def load_musician
@musician = Musician.find(params[:id])
end
def slow
sleep 1
end
end
================================================
FILE: app/controllers/api/api_controller.rb
================================================
class Api::ApiController < ApplicationController
end
================================================
FILE: app/controllers/api/musicians_controller.rb
================================================
class Api::MusiciansController < Api::ApiController
def index
@musicians = Musician.all
end
def show
if params[:id] == "this-will-trigger-a-500"
# Render a 500 to demonstrate how the front-end handles server side errors
render json: {error: "Internal server error"}, status: 500
elsif params[:id] == "this-will-trigger-a-401"
# Render a 401 to demonstrate how the front-end handles server side errors
render json: {error: "Not authenticated"}, status: 401
else
@musician = Musician.find(params[:id])
end
end
end
================================================
FILE: app/controllers/application_controller.rb
================================================
class ApplicationController < ActionController::Base
protect_from_forgery with: :exception
around_action :set_locale_from_url
#rescue_from Exception, with: :render_error
def index
render template: 'application'
end
def set_locale
I18n.locale = params[:locale] || session[:locale] || I18n.default_locale
session[:locale] = I18n.locale
end
def self.default_url_options
{ locale: I18n.locale }
end
def after_sign_in_path_for(resource)
admin_root_path
end
private
def render_error(e)
if e.class.name == "ActiveRecord::RecordNotFound"
render json: {error: "Not found"}.to_json, status: 404
else
render json: {error: "Internal server error"}.to_json, status: 500
end
end
end
================================================
FILE: app/controllers/concerns/.keep
================================================
================================================
FILE: app/helpers/application_helper.rb
================================================
module ApplicationHelper
def ui_translations(section)
translations = {current: I18n.t('.')[:vue][section]}
translations.to_json.html_safe
end
def paginate(scope, default_per_page = scope.default_per_page)
collection = scope.page(params[:page]).per((params[:per_page] || default_per_page).to_i)
current, total, per_page = collection.current_page, collection.total_pages, collection.limit_value
{
current: current,
previous: (current > 1 ? (current - 1) : nil),
next: (current == total ? nil : (current + 1)),
per_page: per_page,
pages: total,
count: collection.total_count
}
end
end
================================================
FILE: app/javascript/admin/routes.js
================================================
import { createWebHistory, createRouter } from 'vue-router'
import DashboardIndex from '@/admin/views/dashboard/index.vue';
import MusicianIndex from '@/admin/views/musicians/index.vue';
import MusicianNew from '@/admin/views/musicians/new.vue';
import MusicianEdit from '@/admin/views/musicians/edit.vue';
import WebsocketIndex from '@/admin/views/websockets/index.vue';
const router = createRouter({
history: createWebHistory(`/${I18n.prefix}admin`),
routes: [
{ path: '/', component: DashboardIndex, name: 'root_path' },
{ path: '/musicians', component: MusicianIndex, name: 'musicians_path' },
{ path: '/musicians/new', component: MusicianNew, name: 'new_musician_path' },
{ path: '/musicians/:id/edit', component: MusicianEdit, name: 'edit_musician_path' },
{ path: '/websockets', component: WebsocketIndex, name: 'websockets_path' }
]
});
// Handles 404 Not found
router.beforeEach((to, from, next) => {
if (!to.matched.length) {
window.location.href = '/404'
} else {
next();
}
});
export default router;
================================================
FILE: app/javascript/admin/stores/dashboard_store.js
================================================
import { defineStore } from 'pinia'
export const DashboardStore = defineStore('dashboard', {
state: () => {
return {
metrics: {}
}
},
actions: {
async index() {
return this.Api.get('/dashboard').then(response => {
this.metrics = response.data.metrics;
})
}
}
})
================================================
FILE: app/javascript/admin/stores/musician_store.js
================================================
import { defineStore } from 'pinia'
export const MusicianStore = defineStore('musicians', {
state: () => {
return {
progress: '',
errors: {},
bands: [],
musician: {},
musicians: [],
pagination: {}
}
},
actions: {
async index(path) {
return this.Api.get(path).then(response => {
this.pagination = response.data.pagination;
this.bands = response.data.bands;
this.musicians = response.data.musicians;
})
},
async new() {
this.errors = {};
this.musician = {};
return this.Api.get(`/musicians/new`).then(response => {
this.musician = response.data.musician;
})
},
async create() {
this.errors = {};
this.progress = 'loading';
return this.Api.post(`/musicians`, this.musician).then(response => {
this.musician = response.data.musician;
return true;
}).catch(error => {
this.errors = error.response.data.errors;
return false;
}).finally(() => {
this.progress = '';
})
},
async edit(id) {
this.errors = {};
this.musician = {};
return this.Api.get(`/musicians/${id}/edit`).then(response => {
this.musician = response.data.musician;
})
},
async update(id) {
this.errors = {};
this.progress = 'loading';
return this.Api.put(`/musicians/${id}`, this.musician).then(response => {
this.errors = {};
}).catch(error => {
this.errors = error.response.data.errors;
}).finally(() => {
this.progress = '';
})
},
async destroy(id) {
return this.Api.destroy(`/musicians/${id}`).then(response => {
this.errors = {};
}).catch(error => {
this.errors = error.response.data.errors;
})
}
}
})
================================================
FILE: app/javascript/admin/views/dashboard/index.vue
================================================
{{ $t('musicians.comment') }} {{ $t('websockets.comment1') }} {{ $t('websockets.comment2') }}
{{ $t('websockets.server_side') }}
{{ $t('websockets.comment3') }}
{{ message }} {{ $t('websockets.waiting_messages') }}
{{ $t('musicians.id') }}: {{ store.musician.id }}Rails 7
Vue 3
Pinia
Vue Router
ActionCable
Kaminari
Bootstrap grid
{{ $t('musicians.form.id') }}
{{ $t('musicians.form.name') }}
{{ $t('musicians.form.band') }}
{{ $t('no_result') }}
{{ $t('websockets.code_example') }}
{{ $t('home.title') }}
{{ $t('home.title') }}
{{ $t('musicians.title') }}
{{ $t('musicians.name') }}: {{ store.musician.name }}
{{ $t('musicians.band') }}: {{ store.musician.band }}
{{ $t('pages.title') }}
{{ $t('pages.admin_link') }}
You may have mistyped the address or the page may have moved.
If you are the application owner check the logs for more information.
Maybe you tried to change something you didn't have access to.
If you are the application owner check the logs for more information.
If you are the application owner check the logs for more information.
N!=="{"&&N!=="}"&&N!==gt&&N!==Ue;for(;u=me(c,E);)p+=u;return p}function ye(c){let u="",p="";for(;u=je(c);)p+=u;return p}function C(c){const u=(p=!1,E)=>{const N=c.currentChar();return N==="{"||N==="%"||N==="@"||N==="|"||N==="("||N===")"||!N||N===gt?E:N===Ue||N===up?(E+=N,c.next(),u(p,E)):(E+=N,c.next(),u(!0,E))};return u(!1,"")}function j(c){A(c);const u=y(c,"|");return A(c),u}function U(c,u){let p=null;switch(c.currentChar()){case"{":return u.braceNest>=1&&h(q.NOT_ALLOW_NEST_PLACEHOLDER,s(),0),c.next(),p=m(u,2,"{"),A(c),u.braceNest++,p;case"}":return u.braceNest>0&&u.currentType===2&&h(q.EMPTY_PLACEHOLDER,s(),0),c.next(),p=m(u,3,"}"),u.braceNest--,u.braceNest>0&&A(c),u.inLinked&&u.braceNest===0&&(u.inLinked=!1),p;case"@":return u.braceNest>0&&h(q.UNTERMINATED_CLOSING_BRACE,s(),0),p=W(c,u)||b(u),u.braceNest=0,p;default:let N=!0,w=!0,F=!0;if(te(c))return u.braceNest>0&&h(q.UNTERMINATED_CLOSING_BRACE,s(),0),p=m(u,1,j(c)),u.braceNest=0,u.inLinked=!1,p;if(u.braceNest>0&&(u.currentType===5||u.currentType===6||u.currentType===7))return h(q.UNTERMINATED_CLOSING_BRACE,s(),0),u.braceNest=0,Z(c,u);if(N=L(c,u))return p=m(u,5,Me(c)),A(c),p;if(w=T(c,u))return p=m(u,6,xe(c)),A(c),p;if(F=k(c,u))return p=m(u,7,ve(c)),A(c),p;if(!N&&!w&&!F)return p=m(u,13,pt(c)),h(q.INVALID_TOKEN_IN_PLACEHOLDER,s(),0,p.value),A(c),p;break}return p}function W(c,u){const{currentType:p}=u;let E=null;const N=c.currentChar();switch((p===8||p===9||p===12||p===10)&&(N===Ue||N===gt)&&h(q.INVALID_LINKED_FORMAT,s(),0),N){case"@":return c.next(),E=m(u,8,"@"),u.inLinked=!0,E;case".":return A(c),c.next(),m(u,9,".");case":":return A(c),c.next(),m(u,10,":");default:return te(c)?(E=m(u,1,j(c)),u.braceNest=0,u.inLinked=!1,E):M(c,u)||V(c,u)?(A(c),W(c,u)):I(c,u)?(A(c),m(u,12,ye(c))):K(c,u)?(A(c),N==="{"?U(c,u)||E:m(u,11,C(c))):(p===8&&h(q.INVALID_LINKED_FORMAT,s(),0),u.braceNest=0,u.inLinked=!1,Z(c,u))}}function Z(c,u){let p={type:14};if(u.braceNest>0)return U(c,u)||b(u);if(u.inLinked)return W(c,u)||b(u);switch(c.currentChar()){case"{":return U(c,u)||b(u);case"}":return h(q.UNBALANCED_CLOSING_BRACE,s(),0),c.next(),m(u,3,"}");case"@":return W(c,u)||b(u);default:if(te(c))return p=m(u,1,j(c)),u.braceNest=0,u.inLinked=!1,p;const{isModulo:N,hasSpace:w}=fe(c);if(N)return w?m(u,0,Ee(c)):m(u,4,ne(c));if(ae(c))return m(u,0,Ee(c));break}return p}function _(){const{currentType:c,offset:u,startLoc:p,endLoc:E}=a;return a.lastType=c,a.lastOffset=u,a.lastStartLoc=p,a.lastEndLoc=E,a.offset=o(),a.startLoc=s(),r.currentChar()===At?m(a,14):Z(r,a)}return{nextToken:_,currentOffset:o,currentPosition:s,context:f}}const hp="parser",mp=/(?:\\\\|\\'|\\u([0-9a-fA-F]{4})|\\U([0-9a-fA-F]{6}))/g;function pp(e,t,n){switch(e){case"\\\\":return"\\";case"\\'":return"'";default:{const r=parseInt(t||n,16);return r<=55295||r>=57344?String.fromCodePoint(r):"�"}}}function _p(e={}){const t=e.location!==!1,{onError:n}=e;function r(g,v,L,T,...k){const M=g.currentPosition();if(M.offset+=T,M.column+=T,n){const I=t?$s(L,M):null,V=Tn(v,I,{domain:hp,args:k});n(V)}}function o(g,v,L){const T={type:g};return t&&(T.start=v,T.end=v,T.loc={start:L,end:L}),T}function s(g,v,L,T){T&&(g.type=T),t&&(g.end=v,g.loc&&(g.loc.end=L))}function i(g,v){const L=g.context(),T=o(3,L.offset,L.startLoc);return T.value=v,s(T,g.currentOffset(),g.currentPosition()),T}function l(g,v){const L=g.context(),{lastOffset:T,lastStartLoc:k}=L,M=o(5,T,k);return M.index=parseInt(v,10),g.nextToken(),s(M,g.currentOffset(),g.currentPosition()),M}function a(g,v){const L=g.context(),{lastOffset:T,lastStartLoc:k}=L,M=o(4,T,k);return M.key=v,g.nextToken(),s(M,g.currentOffset(),g.currentPosition()),M}function f(g,v){const L=g.context(),{lastOffset:T,lastStartLoc:k}=L,M=o(9,T,k);return M.value=v.replace(mp,pp),g.nextToken(),s(M,g.currentOffset(),g.currentPosition()),M}function d(g){const v=g.nextToken(),L=g.context(),{lastOffset:T,lastStartLoc:k}=L,M=o(8,T,k);return v.type!==12?(r(g,q.UNEXPECTED_EMPTY_LINKED_MODIFIER,L.lastStartLoc,0),M.value="",s(M,T,k),{nextConsumeToken:v,node:M}):(v.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,L.lastStartLoc,0,at(v)),M.value=v.value||"",s(M,g.currentOffset(),g.currentPosition()),{node:M})}function h(g,v){const L=g.context(),T=o(7,L.offset,L.startLoc);return T.value=v,s(T,g.currentOffset(),g.currentPosition()),T}function m(g){const v=g.context(),L=o(6,v.offset,v.startLoc);let T=g.nextToken();if(T.type===9){const k=d(g);L.modifier=k.node,T=k.nextConsumeToken||g.nextToken()}switch(T.type!==10&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(T)),T=g.nextToken(),T.type===2&&(T=g.nextToken()),T.type){case 11:T.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(T)),L.key=h(g,T.value||"");break;case 5:T.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(T)),L.key=a(g,T.value||"");break;case 6:T.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(T)),L.key=l(g,T.value||"");break;case 7:T.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(T)),L.key=f(g,T.value||"");break;default:r(g,q.UNEXPECTED_EMPTY_LINKED_KEY,v.lastStartLoc,0);const k=g.context(),M=o(7,k.offset,k.startLoc);return M.value="",s(M,k.offset,k.startLoc),L.key=M,s(L,k.offset,k.startLoc),{nextConsumeToken:T,node:L}}return s(L,g.currentOffset(),g.currentPosition()),{node:L}}function b(g){const v=g.context(),L=v.currentType===1?g.currentOffset():v.offset,T=v.currentType===1?v.endLoc:v.startLoc,k=o(2,L,T);k.items=[];let M=null;do{const K=M||g.nextToken();switch(M=null,K.type){case 0:K.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(K)),k.items.push(i(g,K.value||""));break;case 6:K.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(K)),k.items.push(l(g,K.value||""));break;case 5:K.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(K)),k.items.push(a(g,K.value||""));break;case 7:K.value==null&&r(g,q.UNEXPECTED_LEXICAL_ANALYSIS,v.lastStartLoc,0,at(K)),k.items.push(f(g,K.value||""));break;case 8:const te=m(g);k.items.push(te.node),M=te.nextConsumeToken||null;break}}while(v.currentType!==14&&v.currentType!==1);const I=v.currentType===1?v.lastOffset:g.currentOffset(),V=v.currentType===1?v.lastEndLoc:g.currentPosition();return s(k,I,V),k}function y(g,v,L,T){const k=g.context();let M=T.items.length===0;const I=o(1,v,L);I.cases=[],I.cases.push(T);do{const V=b(g);M||(M=V.items.length===0),I.cases.push(V)}while(k.currentType!==14);return M&&r(g,q.MUST_HAVE_MESSAGES_IN_PLURAL,L,0),s(I,g.currentOffset(),g.currentPosition()),I}function S(g){const v=g.context(),{offset:L,startLoc:T}=v,k=b(g);return v.currentType===14?k:y(g,L,T,k)}function A(g){const v=dp(g,fc({},e)),L=v.context(),T=o(0,L.offset,L.startLoc);return t&&T.loc&&(T.loc.source=g),T.body=S(v),e.onCacheKey&&(T.cacheKey=e.onCacheKey(g)),L.currentType!==14&&r(v,q.UNEXPECTED_LEXICAL_ANALYSIS,L.lastStartLoc,0,g[L.offset]||""),s(T,v.currentOffset(),v.currentPosition()),T}return{parse:A}}function at(e){if(e.type===14)return"EOF";const t=(e.value||"").replace(/\r?\n/gu,"\\n");return t.length>10?t.slice(0,9)+"…":t}function gp(e,t={}){const n={ast:e,helpers:new Set};return{context:()=>n,helper:s=>(n.helpers.add(s),s)}}function zi(e,t){for(let n=0;n