{{ $automationId === null ? __('New platform default automation') : __('Edit platform default automation') }}

{{ __('Configure when a rule fires, which tickets it matches, and what it does. New accounts receive a copy of this rule on provisioning.') }}

{{ __('Back to list') }}
{{-- Platform-default impact notice. Sky / dark-mode safe. --}}
{{ __('Platform default. Edits apply to FUTURE provisioning only — existing tenant copies are untouched. Tenant copies land disabled; the tenant operator turns them on.') }}
{{-- ─── 1. BASIC ────────────────────────────────── --}}
{{ __('Basic') }} {{ __('Name') }} {{ __('Operator-facing label. The customer never sees this.') }} {{ __('Default enabled state for tenant copy') }} {{ __('Most platform defaults land disabled — tenant operator inspects + flips on before the cron picks the rule up.') }} {{ __('Enabled for new accounts') }} {{ __('When OFF, future tenants skip this default entirely. Existing tenant copies are not affected.') }}
{{-- ─── 2. TRIGGER + SCHEDULE ────────────────────── --}}
{{ __('Trigger + schedule') }}

{{ __('Push 2 ships scheduled ticket inactivity. Event-driven triggers are reserved for later.') }}

{{ __('Trigger type') }} @foreach ($this->triggerOptions() as $option) {{ $option['label'] }}@if (! $option['implemented']) — {{ __('coming soon') }}@endif @endforeach {{ __('Schedule') }} @foreach (\App\Enums\AutomationScheduleCadence::cases() as $case) {{ $case->label() }} @endforeach {{ __('The cron tick fires every 15 minutes; cadence controls how often the rule actually evaluates inside that envelope.') }}
{{-- ─── 3. CONDITIONS ────────────────────────────── --}}
{{ __('Conditions') }} {{ __('Add condition') }}

{{ __('Every condition must hold (AND logic). For "days since" rules, the activity basis controls which timestamp the clock anchors on.') }}

@if (! empty($errors->get('conditions')))
{{ $errors->first('conditions') }}
@endif
@foreach ($conditions as $i => $row) @php $field = $row['field'] ?? null; $fieldEnum = $field ? \App\Enums\AutomationConditionField::tryFrom($field) : null; $operatorOptions = $this->operatorOptionsForField($field); @endphp
{{-- Field --}}
@foreach (\App\Enums\AutomationConditionField::cases() as $case) {{ $case->label() }}@if (! $case->isImplemented()) — {{ __('coming soon') }}@endif @endforeach
{{-- Operator --}}
@foreach ($operatorOptions as $op) {{ $op['label'] }} @endforeach
{{-- Value (per-field type) --}}
@if ($fieldEnum === \App\Enums\AutomationConditionField::Status) @foreach (\App\Enums\TicketStatus::cases() as $case) {{ ucfirst($case->value) }} @endforeach @elseif ($fieldEnum === \App\Enums\AutomationConditionField::Priority) @foreach (\App\Enums\TicketPriority::cases() as $case) {{ ucfirst($case->value) }} @endforeach @elseif ($fieldEnum === \App\Enums\AutomationConditionField::AssignedUserId) {{-- Platform defaults can't bind to a specific tenant user. Surface this up-front rather than letting the operator pick a value that the save handler will strip. --}}

{{ __('Not available on platform defaults — set on the tenant copy.') }}

@elseif ($fieldEnum === \App\Enums\AutomationConditionField::ActivityAgeDays) @else @endif
{{-- Remove --}}
{{-- Basis (activity_age_days only) --}} @if ($fieldEnum === \App\Enums\AutomationConditionField::ActivityAgeDays)
{{ __('Measure inactivity from') }} @foreach (\App\Enums\AutomationActivityBasis::cases() as $basis) {{ $basis->label() }} @endforeach {{ __('Stale-pending rules default to “last agent reply” — internal notes never count, and a fresh customer reply reopens the ticket via the inbound pipeline before the rule can fire.') }}
@endif
@endforeach @if ($conditions === [])
{{ __('Add at least one condition before saving.') }}
@endif
{{-- ─── 4. ACTIONS ──────────────────────────────── --}}
{{ __('Actions') }} {{ __('Add action') }}

{{ __('Actions run in order. Each one is idempotent — closing a closed ticket is a safe no-op. Assign-user actions are not available on platform defaults; configure assignment on the tenant copy.') }}

@if (! empty($errors->get('actions')))
{{ $errors->first('actions') }}
@endif
@foreach ($actions as $i => $row) @php $type = $row['type'] ?? null; $typeEnum = $type ? \App\Enums\AutomationActionType::tryFrom($type) : null; @endphp
{{-- Type --}}
@foreach ($this->actionOptions() as $option) {{ $option['label'] }}@if (! $option['implemented']) — {{ __('coming soon') }}@endif @endforeach
{{-- Per-type params --}}
@if ($typeEnum === \App\Enums\AutomationActionType::AddInternalNote) @elseif ($typeEnum === \App\Enums\AutomationActionType::AssignUser)

{{ __('Not available on platform defaults. Pick a different action or configure assignment on the tenant copy.') }}

@elseif ($typeEnum === \App\Enums\AutomationActionType::ChangePriority) @foreach (\App\Enums\TicketPriority::cases() as $case) {{ ucfirst($case->value) }} @endforeach @elseif ($typeEnum === \App\Enums\AutomationActionType::CloseTicket || $typeEnum === \App\Enums\AutomationActionType::ReopenTicket)

{{ __('No extra options.') }}

@else

{{ __('This action type is not yet implemented.') }}

@endif
{{-- Remove --}}
@endforeach @if ($actions === [])
{{ __('Add at least one action before saving.') }}
@endif
{{-- Customer-side has a Scope (optional) section here. Intentionally omitted on platform defaults — scope filters reference tenant-side ids and only make sense on the tenant copy. Set scope on the tenant copy after provisioning. --}} {{-- ─── FOOTER BUTTONS ──────────────────────────── --}}
{{ $automationId === null ? __('Create platform default') : __('Save changes') }} {{ __('Cancel') }}