How wavy is an array? A wave of power \$k\$ is an infinite array that looks like \$1,2,\dots,k,k-1,\dots,1,\dots,k,\dots,1,\dots\$, and so on.
For example, a wave of power 3 starts with \$1,2,3,2,1,2,3,2,1,...\$, and repeats indefinitely. A wave of power 1 is an infinite array of ones. They happen to be beautifully expressed as $$w_k[t] = k - |(t - 1)\bmod(2k - 2) - k + 1|\text{, 1-indexed}$$
In this challenge, all waves are trimmed to their first \$n\$ elements, where \$n\$ is the length of the input array.
A decomposition of an array into waves is an array of coefficients of length \$n\$ such that the original array equals the sum of the waves multiplied by their corresponding coefficients. Formally, if the original array is \$A\$, the decomposition is an array \$B\$  such that for any \$i\$  (\$1 \le i \le n\$) the following equality holds:
$$A[i] = \sum_{j=1}^\infty B[j] \cdot w_j[i]\text{, 1-indexed}$$
The waviness of an array is the index of the last non-zero value in its decomposition into waves.
The task is, given a positive integer array of length \$n\$, to calculate its waviness. Note that the decomposition can still include non-integer and negative numbers.
Test cases
All test cases below are 1-indexed. Your solution may use 0-indexing instead.
[1, 1, 1] -&gt; 1                 (decomposition: [1, 0, 0])
[1, 2, 1] -&gt; 2                 (decomposition: [0, 1, 0])
[1, 2, 3] -&gt; 3                 (decomposition: [0, 0, 1])
[1, 1, 2] -&gt; 3                 (decomposition: [1, -0.5, 0.5])
[1, 3, 3, 3, 1] -&gt; 3           (decomposition: [-1, 1, 1, 0, 0])
[1, 2, 2, 4] -&gt; 4              (decomposition: [0, 0.5, -0.5, 1]
[4, 6, 9, 1, 4, 3, 5] -&gt; 7     (decomposition: [2, -0.5, 5, -5, 6.5, -1, -3]
[4, 6, 9, 1, 4, 3, 5, 7] -&gt; 8  (decomposition: [2, -0.5, 5, -5, 6.5, -1, -10.5, 7.5])

This is tagged code-golf an uncommon justification, so the shortest answer wins.
JavaScript (ES6),  172 171  169 bytes
The output is 0-indexed.

a=&gt;a.map((_,i)=&gt;(D=m=&gt;+m||m.reduce((s,[v],i)=&gt;s+(i&amp;1?-v:v)*D(m.map(([,...r])=&gt;r).filter(_=&gt;i--)),0))(a.map((v,y)=&gt;a.map((_,x)=&gt;x-i?x-~-Math.abs(y%(2*x)-x):v)))&amp;&amp;(j=i))|j

Try it online!
How?
This is essentially an implementation of Cramer's rule, except that the denominator is not computed.
Given the input vector of length \$n\$, we define \$W_n\$ as the matrix holding the waves, stored column-wise.
Example:
$$W_5=\begin{pmatrix}
1&amp;1&amp;1&amp;1&amp;1\\
1&amp;2&amp;2&amp;2&amp;2\\
1&amp;1&amp;3&amp;3&amp;3\\
1&amp;2&amp;2&amp;4&amp;4\\
1&amp;1&amp;1&amp;3&amp;5\end{pmatrix}$$
We compute all values \$v_i=\det(M_i)\$ with \$0\le i&lt;n\$, where \$M_i\$ is the matrix formed by replacing the \$i\$-th column of \$W_n\$ with the input vector.
Example:
For the 5th test case and \$i=3\$, this gives:
$$v_3=\det(M_3)=\begin{vmatrix}
1&amp;1&amp;1&amp;\color{red}1&amp;1\\
1&amp;2&amp;2&amp;\color{red}3&amp;2\\
1&amp;1&amp;3&amp;\color{red}3&amp;3\\
1&amp;2&amp;2&amp;\color{red}3&amp;4\\
1&amp;1&amp;1&amp;\color{red}1&amp;5\end{vmatrix}=0$$
We return the highest index \$j\$ such that \$v_j\neq0\$.
Commented
The helper function \$D\$ uses Laplace expansion to compute the determinant:
D = m =&gt;                     // m[] = matrix
  +m ||                      // if the matrix is a singleton, return it
  m.reduce((s, [v], i) =&gt;    // otherwise, for each value v at (0, i):
    s                        //   take the previous sum s
    + (i &amp; 1 ? -v : v)       //   based on the parity of i, add either v or -v
    * D(                     //   multiplied by the result of a recursive call:
      m.map(([, ...r]) =&gt; r) //     pass m[] with the 1st column removed
      .filter(_ =&gt; i--)      //     and the i-th row removed
    ),                       //   end of recursive call
    0                        //   start with sum = 0
  )                          // end of reduce()

The matrix \$M_i\$ is computed with:
a.map((v, y) =&gt;         // for each value v at position y in the input vector a[]:
  a.map((_, x) =&gt;       //   for each value at position x in the input vector a[]:
    x - i ?             //     if this is not the i-th column:
      x -               //       compute the wave of power x+1 at position y:
      ~-Math.abs(       //         x - (|y mod (2*x) - x| - 1)
        y % (2 * x) - x //         (where y mod 0 is coerced to 0)
      )                 //
    :                   //     else:
      v                 //       append the value a[y] of the input vector
  )                     //   end of inner map()
)                       // end of outer map()